@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,12 +1,10 @@
1
1
  import { ICON_NAMES } from "./icon-names.mjs";
2
2
  import { z } from "zod";
3
- // src/integrations/_shared/schemas.ts
3
+ // src/catalog/schemas.ts
4
4
  /**
5
- * Generative UI 統合の props スキーマ(純データ)。
6
- *
7
- * React に一切依存しない(`import type` のみ)ため **サーバー安全**。RSC の
8
- * サーバーコンポーネントから import して `catalog.prompt()` のプロンプト生成に
9
- * 使える。描画ロジックは ./renderers('use client')に分離している。
5
+ * React は `import type` でしか読まない。`@k8ordo/ui/catalog` はサーバーでも
6
+ * 読み込めることを約束していて、形式のつなぎはこのスキーマからプロンプトを作り、
7
+ * モデルの出力を確かめる。描き方は ./render('use client')に置く。
10
8
  *
11
9
  * ## 二重メンテ防止
12
10
  *
@@ -24,32 +22,47 @@ import { z } from "zod";
24
22
  * enum 値はトークン由来の固定値に制約することで、生成 UI が崩れないように
25
23
  * している。
26
24
  *
27
- * ## キーの並び順は公開 ABI
25
+ * ## キーの並び順は契約
28
26
  *
29
- * OpenUI Lang は完全な位置引数(`Button("ヘルプ", "outline", "base", ...)`)で、
30
- * @openuidev/lang-core が `Object.keys(properties)` の順に params を作る。
31
- * そのため **各 schema のキーの並び順がそのまま公開 ABI** になる。
27
+ * 位置引数で props を書く形式(OpenUI Lang の `Button("ヘルプ", "outline", "base", ...)`)
28
+ * は、引数をキーの並び順で props に戻す。そのため **各 schema のキーの並び順は
29
+ * 契約**で、モデルが書いた文字列も保存された文字列もそれに頼っている。
32
30
  *
33
- * - 既存キーのリネーム: 位置が変わらないので安全。
34
- * - 既存キーの削除・並べ替え: 保存済みの OpenUI 文字列の引数が全部ずれる。
35
- * - 新しいキーの追加: **必ず末尾に足す**。途中に挿入すると以降の位置が 1 つずつ
31
+ * - 新しい任意のキーは **必ず末尾に足す**。途中に挿入すると以降の位置が 1 つずつ
36
32
  * ずれ、既存の文字列が無言で誤描画される(型エラーにもならない)。
33
+ * - 新しい必須のキーは、その項目の保存済みの文字列をどれも通らなくするので、
34
+ * 並びを決め直してよい。入力欄の label は name の直後に置く。末尾に置くと、
35
+ * モデルは前にある任意の引数をすべて null で埋めて書くことになる。
36
+ * - 既存キーの削除・並べ替えも、後ろの引数を全部ずらす。
37
+ * - 既存キーのリネームは位置を変えないが、名前で props を書く形式(json-render、
38
+ * A2UI)の保存済みの spec を壊す。
37
39
  *
38
40
  * ## スキーマの実体が同一性
39
41
  *
40
- * @openuidev/lang-core の `createLibrary` は `reg.add(comp.props, { id: name })`
41
- * と **zod インスタンスそのもの**をキーに登録する。そのため 2 つのコンポーネントに
42
- * 同じインスタンスを渡すと後勝ちで上書きされ、先に登録した方が JSON Schema の
42
+ * 形式によっては zod のインスタンスそのものを鍵に部品を登録する(OpenUI の
43
+ * `createLibrary` は `reg.add(comp.props, { id: name })`)。2 つの部品に同じ
44
+ * インスタンスを渡すと後勝ちで上書きされ、先に登録した方が JSON Schema の
43
45
  * `$defs` から丸ごと消える(型エラーにもならない)。キーが同じ schema を作る
44
46
  * ときは、プレーンな shape オブジェクトを spread して **別インスタンス**にする。
47
+ *
48
+ * ## 入れ子のオブジェクトは strictObject
49
+ *
50
+ * zod の object は知らないキーを誤りにせず取り除く。props の知らないキーは
51
+ * catalogPropIssues が自分で数えて報告するが、その検査は入れ子に届かない。
52
+ * 列、項目、選択肢のように props の中に置くオブジェクトは z.strictObject で
53
+ * 書き、書き間違えたキー(`alig`)を誤りにする。
45
54
  */
46
55
  /**
47
56
  * LLM 生成の `href` は `<a href>` に直接渡るため、`javascript:` や `data:` の
48
- * スキームが通ると XSS になる。`http(s)://` 始まり、または `/` から始まる
57
+ * スキームが通ると XSS になる。`http(s)://` 始まり、または `/` 1 つから始まる
49
58
  * 相対パスのみを許可する。`z.url()` は `javascript:` を拒否しないため正規表現で
50
59
  * 明示的にブロックしている。
60
+ *
61
+ * `//host` と `/\host` はスキームを省いた別のサイトの URL で、`/` で始まっても
62
+ * パスではない。ブラウザは URL の途中のタブと改行を読み飛ばすので、`/<タブ>/host`
63
+ * も同じ URL になる。どれも弾く。
51
64
  */
52
- const safeUrl = z.string().regex(/^(https?:\/\/|\/)/u, "Only an http:// or https:// URL, or a path starting with /, is allowed");
65
+ const safeUrl = z.string().regex(/^(?:https?:\/\/|\/(?![/\\]))[^\t\n\r]*$/u, "Only an http:// or https:// URL, or a path starting with a single /, is allowed");
53
66
  const buttonProps = z.object({
54
67
  label: z.string(),
55
68
  variant: z.enum([
@@ -88,11 +101,11 @@ const iconButtonProps = z.object({
88
101
  "lg"
89
102
  ]).optional(),
90
103
  color: z.enum([
91
- "transparent",
92
104
  "base",
93
105
  "primary",
94
106
  "secondary"
95
- ]).optional()
107
+ ]).optional(),
108
+ variant: z.enum(["solid", "skeleton"]).optional()
96
109
  });
97
110
  const copyButtonProps = z.object({
98
111
  value: z.string().describe("Text copied to the clipboard"),
@@ -104,32 +117,6 @@ const copyButtonProps = z.object({
104
117
  "lg"
105
118
  ]).optional()
106
119
  });
107
- const chevronIconProps = z.object({
108
- direction: z.enum([
109
- "up",
110
- "down",
111
- "left",
112
- "right"
113
- ]),
114
- size: z.enum([
115
- "sm",
116
- "md",
117
- "lg"
118
- ]).optional()
119
- });
120
- const statusIconProps = z.object({
121
- status: z.enum([
122
- "success",
123
- "info",
124
- "warning",
125
- "error"
126
- ]),
127
- size: z.enum([
128
- "sm",
129
- "md",
130
- "lg"
131
- ]).optional()
132
- });
133
120
  const badgeProps = z.object({
134
121
  label: z.string(),
135
122
  tone: z.enum([
@@ -192,14 +179,27 @@ const carouselProps = z.object({
192
179
  "sm"
193
180
  ]).optional()
194
181
  });
195
- const accordionProps = z.object({ items: z.array(z.object({
182
+ const accordionProps = z.object({ items: z.array(z.strictObject({
196
183
  title: z.string(),
197
184
  content: z.string(),
198
185
  defaultOpen: z.boolean().optional()
199
186
  })).min(1).describe("Accordion items, each with a title and a plain-text body") });
187
+ const whenParsed = (...keys) => (payload) => payload.issues.every((issue) => {
188
+ const [key] = issue.path ?? [];
189
+ return typeof key === "string" && !keys.includes(key);
190
+ });
191
+ const rowsFitColumns = (props, ctx) => {
192
+ if (!Array.isArray(props.columns) || !Array.isArray(props.rows)) return;
193
+ const { length } = props.columns;
194
+ for (const [index, row] of props.rows.entries()) if (Array.isArray(row) && row.length !== length) ctx.addIssue({
195
+ code: "custom",
196
+ path: ["rows", index],
197
+ message: `Expected ${length} cells (one per column), received ${row.length}`
198
+ });
199
+ };
200
200
  const tableProps = z.object({
201
201
  caption: z.string().optional(),
202
- columns: z.array(z.object({
202
+ columns: z.array(z.strictObject({
203
203
  label: z.string(),
204
204
  align: z.enum([
205
205
  "left",
@@ -208,10 +208,10 @@ const tableProps = z.object({
208
208
  ]).optional()
209
209
  })).min(1),
210
210
  rows: z.array(z.array(z.string())).describe("Cell strings of each row, in the same order and number as columns")
211
- });
211
+ }).superRefine(rowsFitColumns, { when: whenParsed("columns", "rows") });
212
212
  const dataTableProps = z.object({
213
213
  label: z.string().describe("Accessible name of the table"),
214
- columns: z.array(z.object({
214
+ columns: z.array(z.strictObject({
215
215
  label: z.string(),
216
216
  align: z.enum([
217
217
  "left",
@@ -222,10 +222,10 @@ const dataTableProps = z.object({
222
222
  })).min(1),
223
223
  rows: z.array(z.array(z.string())).describe("Cell strings of each row, in the same order and number as columns"),
224
224
  selectable: z.boolean().optional()
225
- });
225
+ }).superRefine(rowsFitColumns, { when: whenParsed("columns", "rows") });
226
226
  const treeProps = z.object({
227
227
  label: z.string().describe("Accessible name of the tree"),
228
- items: z.array(z.object({
228
+ items: z.array(z.strictObject({
229
229
  id: z.string(),
230
230
  label: z.string(),
231
231
  parentId: z.string().optional(),
@@ -235,12 +235,12 @@ const treeProps = z.object({
235
235
  const cardProps = z.object({
236
236
  width: z.enum(["full", "fit"]).optional(),
237
237
  variant: z.enum(["shadow", "outline"]).optional(),
238
- interactive: z.boolean().optional(),
239
238
  size: z.enum([
240
239
  "sm",
241
240
  "md",
242
241
  "lg"
243
- ]).optional()
242
+ ]).optional(),
243
+ href: safeUrl.optional().describe("Makes the whole card a link to this URL")
244
244
  });
245
245
  const alertProps = z.object({
246
246
  tone: z.enum([
@@ -369,7 +369,7 @@ const breadcrumbProps = z.object({
369
369
  "md",
370
370
  "lg"
371
371
  ]).optional(),
372
- items: z.array(z.object({
372
+ items: z.array(z.strictObject({
373
373
  label: z.string(),
374
374
  href: safeUrl.optional(),
375
375
  current: z.boolean().optional()
@@ -377,9 +377,9 @@ const breadcrumbProps = z.object({
377
377
  });
378
378
  const sideNavProps = z.object({
379
379
  label: z.string().describe("Accessible name of the navigation"),
380
- groups: z.array(z.object({
380
+ groups: z.array(z.strictObject({
381
381
  title: z.string(),
382
- links: z.array(z.object({
382
+ links: z.array(z.strictObject({
383
383
  label: z.string(),
384
384
  href: safeUrl,
385
385
  current: z.boolean().optional()
@@ -396,7 +396,7 @@ const paginationProps = z.object({
396
396
  });
397
397
  const stepperProps = z.object({
398
398
  label: z.string().describe("Accessible name of the list of steps"),
399
- steps: z.array(z.object({
399
+ steps: z.array(z.strictObject({
400
400
  label: z.string(),
401
401
  description: z.string().optional()
402
402
  })).min(1).describe("Steps in order"),
@@ -405,34 +405,88 @@ const stepperProps = z.object({
405
405
  });
406
406
  const tabsProps = z.object({
407
407
  label: z.string().optional().describe("Accessible name of the tab list"),
408
- tabs: z.array(z.object({
408
+ tabs: z.array(z.strictObject({
409
409
  label: z.string(),
410
410
  content: z.string()
411
411
  })).min(1).describe("Label and text panel of each tab")
412
412
  });
413
+ const fieldLabel = () => z.string().describe("Visible label of the field");
414
+ const fieldHelpText = () => z.string().optional().describe("Help text shown under the field");
413
415
  const textInputShape = {
414
416
  name: z.string(),
417
+ label: fieldLabel(),
415
418
  placeholder: z.string().optional(),
416
419
  defaultValue: z.string().optional(),
417
420
  invalid: z.boolean().optional(),
418
421
  disabled: z.boolean().optional(),
419
422
  readOnly: z.boolean().optional()
420
423
  };
421
- const textFieldProps = z.object({ ...textInputShape });
424
+ const DATE_TIME_FORMATS = /* @__PURE__ */ new Map([
425
+ ["date", {
426
+ format: "YYYY-MM-DD",
427
+ schema: z.iso.date()
428
+ }],
429
+ ["time", {
430
+ format: "HH:MM or HH:MM:SS",
431
+ schema: z.iso.time()
432
+ }],
433
+ ["datetime-local", {
434
+ format: "YYYY-MM-DDTHH:MM or YYYY-MM-DDTHH:MM:SS",
435
+ schema: z.iso.datetime({ local: true })
436
+ }],
437
+ ["month", {
438
+ format: "YYYY-MM",
439
+ schema: z.string().regex(/^\d{4}-(?:0[1-9]|1[0-2])$/u)
440
+ }],
441
+ ["week", {
442
+ format: "YYYY-Www",
443
+ schema: z.string().regex(/^\d{4}-W(?:0[1-9]|[1-4]\d|5[0-3])$/u)
444
+ }]
445
+ ]);
446
+ const defaultValueFitsType = (props, ctx) => {
447
+ const { type, defaultValue } = props;
448
+ if (typeof type !== "string" || typeof defaultValue !== "string") return;
449
+ const kind = DATE_TIME_FORMATS.get(type);
450
+ if (kind !== void 0 && !kind.schema.safeParse(defaultValue).success) ctx.addIssue({
451
+ code: "custom",
452
+ path: ["defaultValue"],
453
+ message: `Expected ${kind.format} for type "${type}", received "${defaultValue}"`
454
+ });
455
+ };
456
+ const textFieldProps = z.object({
457
+ ...textInputShape,
458
+ type: z.enum([
459
+ "text",
460
+ "email",
461
+ "tel",
462
+ "url",
463
+ "search",
464
+ "date",
465
+ "time",
466
+ "datetime-local",
467
+ "month",
468
+ "week"
469
+ ]).optional().describe("Kind of value the field takes (text when omitted); a date or time kind holds the input format, such as YYYY-MM-DD for date"),
470
+ helpText: fieldHelpText()
471
+ }).superRefine(defaultValueFitsType, { when: whenParsed("type", "defaultValue") });
422
472
  const textareaProps = z.object({
423
473
  ...textInputShape,
424
474
  rows: z.int().min(1).max(40).optional().describe("Number of rows shown at first"),
425
- autoResize: z.boolean().optional().describe("Grow the height to fit the text")
475
+ autoResize: z.boolean().optional().describe("Grow the height to fit the text"),
476
+ helpText: fieldHelpText()
426
477
  });
427
478
  const passwordInputProps = z.object({
428
479
  name: z.string(),
480
+ label: fieldLabel(),
429
481
  placeholder: z.string().optional(),
430
482
  defaultValue: z.string().optional(),
431
483
  invalid: z.boolean().optional(),
432
- disabled: z.boolean().optional()
484
+ disabled: z.boolean().optional(),
485
+ helpText: fieldHelpText()
433
486
  });
434
487
  const numericInputShape = {
435
488
  name: z.string(),
489
+ label: fieldLabel(),
436
490
  defaultValue: z.number().optional(),
437
491
  min: z.number().optional(),
438
492
  max: z.number().optional(),
@@ -440,25 +494,28 @@ const numericInputShape = {
440
494
  invalid: z.boolean().optional(),
441
495
  disabled: z.boolean().optional()
442
496
  };
443
- const numberFieldProps = z.object({ ...numericInputShape });
497
+ const numberFieldProps = z.object({
498
+ ...numericInputShape,
499
+ helpText: fieldHelpText()
500
+ });
444
501
  const sliderProps = z.object({
445
502
  ...numericInputShape,
446
503
  min: z.number().optional().describe("Lower bound (0 when omitted)"),
447
- max: z.number().optional().describe("Upper bound (100 when omitted)")
504
+ max: z.number().optional().describe("Upper bound (100 when omitted)"),
505
+ helpText: fieldHelpText()
448
506
  });
449
507
  const isoDate = () => z.iso.date();
450
- const dateInputShape = {
508
+ const datePickerProps = z.object({
451
509
  name: z.string(),
452
- label: z.string().describe("Visible label of the field"),
510
+ label: fieldLabel(),
453
511
  defaultValue: isoDate().optional().describe("YYYY-MM-DD"),
454
512
  min: isoDate().optional().describe("Earliest date that can be entered"),
455
513
  max: isoDate().optional().describe("Latest date that can be entered"),
456
514
  invalid: z.boolean().optional(),
457
515
  disabled: z.boolean().optional(),
458
- required: z.boolean().optional()
459
- };
460
- const dateFieldProps = z.object({ ...dateInputShape });
461
- const datePickerProps = z.object({ ...dateInputShape });
516
+ required: z.boolean().optional(),
517
+ helpText: fieldHelpText()
518
+ });
462
519
  const calendarProps = z.object({
463
520
  name: z.string().describe("State key the picked date is stored under"),
464
521
  defaultValue: isoDate().optional().describe("YYYY-MM-DD"),
@@ -467,32 +524,35 @@ const calendarProps = z.object({
467
524
  });
468
525
  const rangeSliderProps = z.object({
469
526
  name: z.string().describe("Both thumbs submit under this name, lower value first"),
470
- label: z.string().describe("Accessible name of the slider"),
527
+ label: fieldLabel(),
471
528
  defaultValue: z.tuple([z.number(), z.number()]).optional().describe("[lower, upper]; the whole range when omitted"),
472
529
  min: z.number().optional().describe("Lower bound (0 when omitted)"),
473
530
  max: z.number().optional().describe("Upper bound (100 when omitted)"),
474
531
  step: z.number().optional(),
475
532
  invalid: z.boolean().optional(),
476
- disabled: z.boolean().optional()
533
+ disabled: z.boolean().optional(),
534
+ helpText: fieldHelpText()
477
535
  });
478
536
  const hexColor = () => z.string().regex(/^#[0-9a-fA-F]{6}$/u);
479
537
  const colorPickerProps = z.object({
480
538
  name: z.string(),
481
- label: z.string().describe("Visible label of the field"),
539
+ label: fieldLabel(),
482
540
  defaultValue: hexColor().optional().describe("#rrggbb"),
483
- swatches: z.array(z.object({
541
+ swatches: z.array(z.strictObject({
484
542
  value: hexColor().describe("#rrggbb"),
485
543
  label: z.string().describe("Name of the color, read out for the swatch")
486
544
  })).optional().describe("Preset colors offered as buttons"),
487
545
  invalid: z.boolean().optional(),
488
546
  disabled: z.boolean().optional(),
489
- required: z.boolean().optional()
547
+ required: z.boolean().optional(),
548
+ helpText: fieldHelpText()
490
549
  });
491
550
  const checkboxProps = z.object({
492
551
  name: z.string(),
493
552
  label: z.string(),
494
553
  defaultChecked: z.boolean().optional(),
495
- disabled: z.boolean().optional()
554
+ disabled: z.boolean().optional(),
555
+ helpText: fieldHelpText()
496
556
  });
497
557
  const switchProps = z.object({
498
558
  name: z.string(),
@@ -500,9 +560,10 @@ const switchProps = z.object({
500
560
  defaultChecked: z.boolean().optional(),
501
561
  disabled: z.boolean().optional(),
502
562
  invalid: z.boolean().optional(),
503
- required: z.boolean().optional()
563
+ required: z.boolean().optional(),
564
+ helpText: fieldHelpText()
504
565
  });
505
- const selectOption = z.object({
566
+ const selectOption = z.strictObject({
506
567
  value: z.string(),
507
568
  label: z.string()
508
569
  });
@@ -510,101 +571,100 @@ const radioCardOption = selectOption.extend({
510
571
  description: z.string().optional(),
511
572
  disabled: z.boolean().optional()
512
573
  });
574
+ const defaultValueIsOption = (props, ctx) => {
575
+ const { options, defaultValue } = props;
576
+ if (!Array.isArray(options)) return;
577
+ const values = options.flatMap((option) => typeof option === "object" && option !== null && "value" in option && typeof option.value === "string" ? [option.value] : []);
578
+ const chosen = Array.isArray(defaultValue) ? defaultValue.map((value, index) => [["defaultValue", index], value]) : [[["defaultValue"], defaultValue]];
579
+ for (const [path, value] of chosen) if (typeof value === "string" && !values.includes(value)) ctx.addIssue({
580
+ code: "custom",
581
+ path,
582
+ message: `Expected the value of an option (${values.map((v) => `"${v}"`).join(" | ")}), received "${value}"`
583
+ });
584
+ };
585
+ const whenOptionsParsed = { when: whenParsed("options", "defaultValue") };
513
586
  const selectProps = z.object({
514
587
  name: z.string(),
588
+ label: fieldLabel(),
515
589
  options: z.array(selectOption).min(1).describe("Choices (value / label)"),
516
590
  defaultValue: z.string().optional(),
517
591
  invalid: z.boolean().optional(),
518
- disabled: z.boolean().optional()
519
- });
592
+ disabled: z.boolean().optional(),
593
+ helpText: fieldHelpText()
594
+ }).superRefine(defaultValueIsOption, whenOptionsParsed);
520
595
  const radioProps = z.object({
521
596
  name: z.string(),
522
- label: z.string(),
597
+ label: fieldLabel(),
523
598
  options: z.array(selectOption).min(1),
524
599
  defaultValue: z.string().optional(),
525
- disabled: z.boolean().optional()
526
- });
600
+ disabled: z.boolean().optional(),
601
+ helpText: fieldHelpText()
602
+ }).superRefine(defaultValueIsOption, whenOptionsParsed);
527
603
  const radioCardProps = z.object({
528
604
  name: z.string(),
529
- label: z.string(),
605
+ label: fieldLabel(),
530
606
  options: z.array(radioCardOption).min(1),
531
607
  defaultValue: z.string().optional(),
532
608
  invalid: z.boolean().optional(),
533
- disabled: z.boolean().optional()
534
- });
609
+ disabled: z.boolean().optional(),
610
+ helpText: fieldHelpText()
611
+ }).superRefine(defaultValueIsOption, whenOptionsParsed);
535
612
  const checkboxCardProps = z.object({
536
613
  name: z.string(),
614
+ label: fieldLabel(),
537
615
  options: z.array(radioCardOption).min(1),
538
616
  defaultValue: z.array(z.string()).optional(),
539
617
  invalid: z.boolean().optional(),
540
618
  disabled: z.boolean().optional(),
541
- label: z.string()
542
- });
619
+ helpText: fieldHelpText()
620
+ }).superRefine(defaultValueIsOption, whenOptionsParsed);
543
621
  const listBoxProps = z.object({
544
- name: z.string(),
622
+ name: z.string().describe("State key the chosen value is stored under"),
623
+ label: z.string().describe("Name of the button that opens the list, read out before the chosen option"),
545
624
  options: z.array(selectOption).min(1),
546
- defaultValue: z.string().optional(),
547
- label: z.string().optional().describe("Accessible name of the trigger")
548
- });
625
+ defaultValue: z.string().optional()
626
+ }).superRefine(defaultValueIsOption, whenOptionsParsed);
549
627
  const checkboxGroupProps = z.object({
550
628
  name: z.string(),
629
+ label: fieldLabel(),
551
630
  options: z.array(selectOption).min(1),
552
631
  defaultValue: z.array(z.string()).optional(),
553
- label: z.string()
554
- });
632
+ helpText: fieldHelpText()
633
+ }).superRefine(defaultValueIsOption, whenOptionsParsed);
555
634
  const autocompleteProps = z.object({
556
635
  name: z.string(),
636
+ label: fieldLabel(),
557
637
  options: z.array(selectOption).min(1),
558
638
  defaultValue: z.array(z.string()).optional(),
559
639
  invalid: z.boolean().optional(),
560
- disabled: z.boolean().optional()
640
+ disabled: z.boolean().optional(),
641
+ helpText: fieldHelpText()
561
642
  });
562
643
  const comboboxProps = z.object({
563
644
  name: z.string(),
564
- label: z.string().describe("Visible label of the field"),
645
+ label: fieldLabel(),
565
646
  options: z.array(selectOption).min(1).describe("Choices (value / label); typing filters them by label"),
566
647
  defaultValue: z.string().optional().describe("value of the chosen option"),
567
648
  placeholder: z.string().optional(),
568
649
  invalid: z.boolean().optional(),
569
650
  disabled: z.boolean().optional(),
570
- required: z.boolean().optional()
651
+ required: z.boolean().optional(),
652
+ helpText: fieldHelpText()
571
653
  });
572
654
  const fileFieldProps = z.object({
655
+ label: fieldLabel(),
573
656
  triggerLabel: z.string().optional().describe("Text of the file picker button (the built-in wording when omitted)"),
574
657
  multiple: z.boolean().optional(),
575
658
  maxFiles: z.number().optional(),
576
659
  clearable: z.boolean().optional(),
577
- dropzone: z.boolean().optional().describe("Show an area files can be dropped onto, with the button in it")
578
- });
579
- const formControlProps = z.object({
580
- label: z.string(),
581
- fieldType: z.enum([
582
- "text",
583
- "textarea",
584
- "password"
585
- ]).optional(),
586
- name: z.string(),
587
- placeholder: z.string().optional(),
588
- defaultValue: z.string().optional(),
589
- helpText: z.string().optional(),
590
- errorText: z.string().optional(),
591
- required: z.boolean().optional(),
592
- invalid: z.boolean().optional()
593
- });
594
- const formProps = z.object({ action: safeUrl.optional().describe("URL the form submits to (optional)") });
595
- const modalProps = z.object({
596
- triggerLabel: z.string().describe("Text of the button that opens the modal"),
597
- title: z.string(),
598
- side: z.enum([
599
- "center",
600
- "bottom",
601
- "right",
602
- "left"
603
- ]).optional()
660
+ dropzone: z.boolean().optional().describe("Show an area files can be dropped onto, with the button in it"),
661
+ helpText: fieldHelpText()
604
662
  });
663
+ const formProps = z.object({});
605
664
  const dialogProps = z.object({
606
665
  triggerLabel: z.string().describe("Text of the button that opens the dialog"),
607
- title: z.string()
666
+ title: z.string(),
667
+ side: z.enum(["center", "bottom"]).optional()
608
668
  });
609
669
  const drawerProps = z.object({
610
670
  triggerLabel: z.string().describe("Text of the button that opens the drawer"),
@@ -618,14 +678,12 @@ const tooltipProps = z.object({
618
678
  });
619
679
  const toolbarProps = z.object({
620
680
  label: z.string().describe("Accessible name of the toolbar"),
621
- items: z.array(z.object({
681
+ items: z.array(z.strictObject({
622
682
  label: z.string(),
623
683
  icon: iconName.optional().describe("Show only this icon; label becomes its accessible name")
624
684
  })).min(1).describe("Buttons in the toolbar, in order"),
625
685
  orientation: z.enum(["horizontal", "vertical"]).optional()
626
686
  });
627
- const dropdownMenuProps = z.object({
628
- triggerLabel: z.string(),
629
- items: z.array(z.object({ label: z.string() })).min(1).describe("Menu items")
630
- });
631
- export { accordionProps, alertProps, anchorProps, autocompleteProps, avatarProps, badgeProps, breadcrumbProps, buttonProps, calendarProps, calloutProps, cardProps, carouselProps, checkboxCardProps, checkboxGroupProps, checkboxProps, chevronIconProps, codeProps, colorPickerProps, comboboxProps, copyButtonProps, dataTableProps, dateFieldProps, datePickerProps, dialogProps, drawerProps, dropdownMenuProps, emptyStateProps, fileFieldProps, formControlProps, formProps, gridProps, headingProps, iconButtonProps, iconName, iconProps, kbdProps, listBoxProps, modalProps, numberFieldProps, paginationProps, passwordInputProps, popoverProps, progressProps, radioCardProps, radioProps, rangeSliderProps, selectProps, separatorProps, sideNavProps, skeletonProps, sliderProps, spinnerProps, stackProps, statusIconProps, stepperProps, switchProps, tableProps, tabsProps, textFieldProps, textareaProps, toastProps, toolbarProps, tooltipProps, treeProps };
687
+ const dropdownMenuProps = z.object({ triggerLabel: z.string() });
688
+ const dropdownMenuItemProps = z.object({ label: z.string() });
689
+ export { accordionProps, alertProps, anchorProps, autocompleteProps, avatarProps, badgeProps, breadcrumbProps, buttonProps, calendarProps, calloutProps, cardProps, carouselProps, checkboxCardProps, checkboxGroupProps, checkboxProps, codeProps, colorPickerProps, comboboxProps, copyButtonProps, dataTableProps, datePickerProps, dialogProps, drawerProps, dropdownMenuItemProps, dropdownMenuProps, emptyStateProps, fileFieldProps, formProps, gridProps, headingProps, iconButtonProps, iconName, iconProps, kbdProps, listBoxProps, numberFieldProps, paginationProps, passwordInputProps, popoverProps, progressProps, radioCardProps, radioProps, rangeSliderProps, selectProps, separatorProps, sideNavProps, skeletonProps, sliderProps, spinnerProps, stackProps, stepperProps, switchProps, tableProps, tabsProps, textFieldProps, textareaProps, toastProps, toolbarProps, tooltipProps, treeProps };
@@ -0,0 +1,4 @@
1
+ import "../components/data-display/tree/index.mjs";
2
+ import { TreeItem } from "../components/data-display/tree/tree.mjs";
3
+ import { TreeProps } from "./schemas.mjs";
4
+ export declare const toTree: (items: TreeProps['items']) => TreeItem[];
@@ -0,0 +1,17 @@
1
+ // src/catalog/to-tree.ts
2
+ const toTree = (items) => {
3
+ const ids = new Set(items.map((item) => item.id));
4
+ const build = (parentId) => items.filter((item) => parentId === void 0 ? item.parentId === void 0 || !ids.has(item.parentId) : item.parentId === parentId).map((item) => {
5
+ const children = build(item.id);
6
+ return children.length > 0 ? {
7
+ id: item.id,
8
+ label: item.label,
9
+ children
10
+ } : {
11
+ id: item.id,
12
+ label: item.label
13
+ };
14
+ });
15
+ return build(void 0);
16
+ };
17
+ export { toTree };
@@ -0,0 +1 @@
1
+ export declare const checkedValuesAround: (box: HTMLInputElement) => string[];
@@ -0,0 +1,5 @@
1
+ // src/components/_internal/checked-values.ts
2
+ const checkedValuesAround = (box) => {
3
+ return [...box.closest("fieldset")?.querySelectorAll("input[type=\"checkbox\"]") ?? []].filter((input) => input.checked).map((input) => input.value);
4
+ };
5
+ export { checkedValuesAround };
@@ -0,0 +1,25 @@
1
+ @layer properties, theme, base;
2
+
3
+ @layer components {
4
+ .txpnMG_field {
5
+ flex-direction: column;
6
+ display: inline-flex;
7
+ }
8
+
9
+ .txpnMG_message {
10
+ margin-top: calc(var(--spacing) * 1);
11
+ padding-left: calc(var(--spacing) * .5);
12
+ font-size: var(--font-size-sm);
13
+ line-height: var(--line-height-sm);
14
+ }
15
+
16
+ .txpnMG_error {
17
+ color: var(--color-fg-error);
18
+ }
19
+
20
+ .txpnMG_help {
21
+ color: var(--color-fg-mute);
22
+ }
23
+ }
24
+
25
+ @layer utilities;
@@ -0,0 +1,10 @@
1
+ import { FC } from "react";
2
+ type Props = {
3
+ id: string;
4
+ errorText: string | undefined;
5
+ helpText: string | undefined;
6
+ };
7
+ export declare const hasErrorText: (errorText: string | undefined) => boolean;
8
+ export declare const describedByWith: (own: string | undefined, message: Props) => string | undefined;
9
+ export declare const FieldMessage: FC<Props>;
10
+ export {};
@@ -0,0 +1,22 @@
1
+ import field_message_module_default from "./field-message.module.mjs";
2
+ import { clsx } from "clsx";
3
+ import { jsx } from "react/jsx-runtime";
4
+ // src/components/_internal/field-message.tsx
5
+ const filled = (text) => text !== void 0 && text !== "";
6
+ const hasErrorText = (errorText) => filled(errorText);
7
+ const messageIdOf = ({ id, errorText, helpText }) => filled(errorText) ? `${id}-feedback` : filled(helpText) ? `${id}-helptext` : void 0;
8
+ const describedByWith = (own, message) => {
9
+ const ids = [own, messageIdOf(message)].filter(filled);
10
+ return ids.length === 0 ? void 0 : ids.join(" ");
11
+ };
12
+ const FieldMessage = ({ id, errorText, helpText }) => filled(errorText) ? /* @__PURE__ */ jsx("span", {
13
+ "aria-live": "polite",
14
+ className: clsx(field_message_module_default.message, field_message_module_default.error),
15
+ id: `${id}-feedback`,
16
+ children: errorText
17
+ }) : filled(helpText) ? /* @__PURE__ */ jsx("span", {
18
+ className: clsx(field_message_module_default.message, field_message_module_default.help),
19
+ id: `${id}-helptext`,
20
+ children: helpText
21
+ }) : null;
22
+ export { FieldMessage, describedByWith, hasErrorText };