@tai42/studio-sdk 0.2.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 (422) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +15 -0
  3. package/README.md +318 -0
  4. package/SECURITY.md +51 -0
  5. package/dist/components/badge.d.ts +13 -0
  6. package/dist/components/badge.d.ts.map +1 -0
  7. package/dist/components/badge.js +14 -0
  8. package/dist/components/badge.js.map +1 -0
  9. package/dist/components/checkbox.d.ts +24 -0
  10. package/dist/components/checkbox.d.ts.map +1 -0
  11. package/dist/components/checkbox.js +31 -0
  12. package/dist/components/checkbox.js.map +1 -0
  13. package/dist/components/code-block.d.ts +7 -0
  14. package/dist/components/code-block.d.ts.map +1 -0
  15. package/dist/components/code-block.js +23 -0
  16. package/dist/components/code-block.js.map +1 -0
  17. package/dist/components/completion-input.d.ts +31 -0
  18. package/dist/components/completion-input.d.ts.map +1 -0
  19. package/dist/components/completion-input.js +61 -0
  20. package/dist/components/completion-input.js.map +1 -0
  21. package/dist/components/components.css +2212 -0
  22. package/dist/components/confirm-dialog.d.ts +40 -0
  23. package/dist/components/confirm-dialog.d.ts.map +1 -0
  24. package/dist/components/confirm-dialog.js +11 -0
  25. package/dist/components/confirm-dialog.js.map +1 -0
  26. package/dist/components/control-styles.d.ts +12 -0
  27. package/dist/components/control-styles.d.ts.map +1 -0
  28. package/dist/components/control-styles.js +14 -0
  29. package/dist/components/control-styles.js.map +1 -0
  30. package/dist/components/copy-field.d.ts +8 -0
  31. package/dist/components/copy-field.d.ts.map +1 -0
  32. package/dist/components/copy-field.js +106 -0
  33. package/dist/components/copy-field.js.map +1 -0
  34. package/dist/components/dialog.d.ts +21 -0
  35. package/dist/components/dialog.d.ts.map +1 -0
  36. package/dist/components/dialog.js +25 -0
  37. package/dist/components/dialog.js.map +1 -0
  38. package/dist/components/drawer.d.ts +22 -0
  39. package/dist/components/drawer.d.ts.map +1 -0
  40. package/dist/components/drawer.js +32 -0
  41. package/dist/components/drawer.js.map +1 -0
  42. package/dist/components/error-boundary.d.ts +33 -0
  43. package/dist/components/error-boundary.d.ts.map +1 -0
  44. package/dist/components/error-boundary.js +36 -0
  45. package/dist/components/error-boundary.js.map +1 -0
  46. package/dist/components/extension-combo-builder.d.ts +70 -0
  47. package/dist/components/extension-combo-builder.d.ts.map +1 -0
  48. package/dist/components/extension-combo-builder.js +154 -0
  49. package/dist/components/extension-combo-builder.js.map +1 -0
  50. package/dist/components/extension-grouping.d.ts +65 -0
  51. package/dist/components/extension-grouping.d.ts.map +1 -0
  52. package/dist/components/extension-grouping.js +78 -0
  53. package/dist/components/extension-grouping.js.map +1 -0
  54. package/dist/components/extension-picker.d.ts +35 -0
  55. package/dist/components/extension-picker.d.ts.map +1 -0
  56. package/dist/components/extension-picker.js +31 -0
  57. package/dist/components/extension-picker.js.map +1 -0
  58. package/dist/components/external-link.d.ts +19 -0
  59. package/dist/components/external-link.d.ts.map +1 -0
  60. package/dist/components/external-link.js +12 -0
  61. package/dist/components/external-link.js.map +1 -0
  62. package/dist/components/field.d.ts +64 -0
  63. package/dist/components/field.d.ts.map +1 -0
  64. package/dist/components/field.js +56 -0
  65. package/dist/components/field.js.map +1 -0
  66. package/dist/components/fleet-report.d.ts +39 -0
  67. package/dist/components/fleet-report.d.ts.map +1 -0
  68. package/dist/components/fleet-report.js +50 -0
  69. package/dist/components/fleet-report.js.map +1 -0
  70. package/dist/components/fonts.css +22 -0
  71. package/dist/components/icons.d.ts +142 -0
  72. package/dist/components/icons.d.ts.map +1 -0
  73. package/dist/components/icons.js +139 -0
  74. package/dist/components/icons.js.map +1 -0
  75. package/dist/components/inputs.d.ts +52 -0
  76. package/dist/components/inputs.d.ts.map +1 -0
  77. package/dist/components/inputs.js +35 -0
  78. package/dist/components/inputs.js.map +1 -0
  79. package/dist/components/json-diff.d.ts +40 -0
  80. package/dist/components/json-diff.d.ts.map +1 -0
  81. package/dist/components/json-diff.js +119 -0
  82. package/dist/components/json-diff.js.map +1 -0
  83. package/dist/components/json-tree.d.ts +8 -0
  84. package/dist/components/json-tree.d.ts.map +1 -0
  85. package/dist/components/json-tree.js +70 -0
  86. package/dist/components/json-tree.js.map +1 -0
  87. package/dist/components/modal-focus.d.ts +15 -0
  88. package/dist/components/modal-focus.d.ts.map +1 -0
  89. package/dist/components/modal-focus.js +136 -0
  90. package/dist/components/modal-focus.js.map +1 -0
  91. package/dist/components/page-header.d.ts +56 -0
  92. package/dist/components/page-header.d.ts.map +1 -0
  93. package/dist/components/page-header.js +24 -0
  94. package/dist/components/page-header.js.map +1 -0
  95. package/dist/components/primitives.d.ts +186 -0
  96. package/dist/components/primitives.d.ts.map +1 -0
  97. package/dist/components/primitives.js +204 -0
  98. package/dist/components/primitives.js.map +1 -0
  99. package/dist/components/progress-bar.d.ts +29 -0
  100. package/dist/components/progress-bar.d.ts.map +1 -0
  101. package/dist/components/progress-bar.js +48 -0
  102. package/dist/components/progress-bar.js.map +1 -0
  103. package/dist/components/radio-group.d.ts +37 -0
  104. package/dist/components/radio-group.d.ts.map +1 -0
  105. package/dist/components/radio-group.js +56 -0
  106. package/dist/components/radio-group.js.map +1 -0
  107. package/dist/components/reveal-input.d.ts +13 -0
  108. package/dist/components/reveal-input.d.ts.map +1 -0
  109. package/dist/components/reveal-input.js +31 -0
  110. package/dist/components/reveal-input.js.map +1 -0
  111. package/dist/components/scroll-region.d.ts +85 -0
  112. package/dist/components/scroll-region.d.ts.map +1 -0
  113. package/dist/components/scroll-region.js +574 -0
  114. package/dist/components/scroll-region.js.map +1 -0
  115. package/dist/components/select.d.ts +53 -0
  116. package/dist/components/select.d.ts.map +1 -0
  117. package/dist/components/select.js +33 -0
  118. package/dist/components/select.js.map +1 -0
  119. package/dist/components/table.d.ts +59 -0
  120. package/dist/components/table.d.ts.map +1 -0
  121. package/dist/components/table.js +20 -0
  122. package/dist/components/table.js.map +1 -0
  123. package/dist/components/tabs.d.ts +15 -0
  124. package/dist/components/tabs.d.ts.map +1 -0
  125. package/dist/components/tabs.js +13 -0
  126. package/dist/components/tabs.js.map +1 -0
  127. package/dist/components/tags.d.ts +46 -0
  128. package/dist/components/tags.d.ts.map +1 -0
  129. package/dist/components/tags.js +68 -0
  130. package/dist/components/tags.js.map +1 -0
  131. package/dist/components/tokens.css +392 -0
  132. package/dist/components/tokens.d.ts +15 -0
  133. package/dist/components/tokens.d.ts.map +1 -0
  134. package/dist/components/tokens.js +101 -0
  135. package/dist/components/tokens.js.map +1 -0
  136. package/dist/components/tool-picker.d.ts +24 -0
  137. package/dist/components/tool-picker.d.ts.map +1 -0
  138. package/dist/components/tool-picker.js +97 -0
  139. package/dist/components/tool-picker.js.map +1 -0
  140. package/dist/components/tooltip.d.ts +17 -0
  141. package/dist/components/tooltip.d.ts.map +1 -0
  142. package/dist/components/tooltip.js +18 -0
  143. package/dist/components/tooltip.js.map +1 -0
  144. package/dist/components/version-history-panel.d.ts +71 -0
  145. package/dist/components/version-history-panel.d.ts.map +1 -0
  146. package/dist/components/version-history-panel.js +148 -0
  147. package/dist/components/version-history-panel.js.map +1 -0
  148. package/dist/download.d.ts +7 -0
  149. package/dist/download.d.ts.map +1 -0
  150. package/dist/download.js +18 -0
  151. package/dist/download.js.map +1 -0
  152. package/dist/element-slot.d.ts +4 -0
  153. package/dist/element-slot.d.ts.map +1 -0
  154. package/dist/element-slot.js +20 -0
  155. package/dist/element-slot.js.map +1 -0
  156. package/dist/elicitation/ElicitationForm.d.ts +34 -0
  157. package/dist/elicitation/ElicitationForm.d.ts.map +1 -0
  158. package/dist/elicitation/ElicitationForm.js +24 -0
  159. package/dist/elicitation/ElicitationForm.js.map +1 -0
  160. package/dist/errors.d.ts +9 -0
  161. package/dist/errors.d.ts.map +1 -0
  162. package/dist/errors.js +15 -0
  163. package/dist/errors.js.map +1 -0
  164. package/dist/extension-combos.d.ts +13 -0
  165. package/dist/extension-combos.d.ts.map +1 -0
  166. package/dist/extension-combos.js +9 -0
  167. package/dist/extension-combos.js.map +1 -0
  168. package/dist/hooks/useApi.d.ts +1222 -0
  169. package/dist/hooks/useApi.d.ts.map +1 -0
  170. package/dist/hooks/useApi.js +22 -0
  171. package/dist/hooks/useApi.js.map +1 -0
  172. package/dist/hooks/useAuth.d.ts +13 -0
  173. package/dist/hooks/useAuth.d.ts.map +1 -0
  174. package/dist/hooks/useAuth.js +53 -0
  175. package/dist/hooks/useAuth.js.map +1 -0
  176. package/dist/hooks/useBreakpoint.d.ts +10 -0
  177. package/dist/hooks/useBreakpoint.d.ts.map +1 -0
  178. package/dist/hooks/useBreakpoint.js +66 -0
  179. package/dist/hooks/useBreakpoint.js.map +1 -0
  180. package/dist/hooks/useCapabilities.d.ts +88 -0
  181. package/dist/hooks/useCapabilities.d.ts.map +1 -0
  182. package/dist/hooks/useCapabilities.js +203 -0
  183. package/dist/hooks/useCapabilities.js.map +1 -0
  184. package/dist/hooks/useSse.d.ts +13 -0
  185. package/dist/hooks/useSse.d.ts.map +1 -0
  186. package/dist/hooks/useSse.js +298 -0
  187. package/dist/hooks/useSse.js.map +1 -0
  188. package/dist/hooks/useTheme.d.ts +20 -0
  189. package/dist/hooks/useTheme.d.ts.map +1 -0
  190. package/dist/hooks/useTheme.js +97 -0
  191. package/dist/hooks/useTheme.js.map +1 -0
  192. package/dist/hooks/useUnauthorized.d.ts +3 -0
  193. package/dist/hooks/useUnauthorized.d.ts.map +1 -0
  194. package/dist/hooks/useUnauthorized.js +18 -0
  195. package/dist/hooks/useUnauthorized.js.map +1 -0
  196. package/dist/host.d.ts +11 -0
  197. package/dist/host.d.ts.map +1 -0
  198. package/dist/host.js +10 -0
  199. package/dist/host.js.map +1 -0
  200. package/dist/index.d.ts +118 -0
  201. package/dist/index.d.ts.map +1 -0
  202. package/dist/index.js +91 -0
  203. package/dist/index.js.map +1 -0
  204. package/dist/navigation/context.d.ts +25 -0
  205. package/dist/navigation/context.d.ts.map +1 -0
  206. package/dist/navigation/context.js +45 -0
  207. package/dist/navigation/context.js.map +1 -0
  208. package/dist/navigation/index.d.ts +4 -0
  209. package/dist/navigation/index.d.ts.map +1 -0
  210. package/dist/navigation/index.js +2 -0
  211. package/dist/navigation/index.js.map +1 -0
  212. package/dist/navigation/types.d.ts +97 -0
  213. package/dist/navigation/types.d.ts.map +1 -0
  214. package/dist/navigation/types.js +16 -0
  215. package/dist/navigation/types.js.map +1 -0
  216. package/dist/plugin/host-state.d.ts +45 -0
  217. package/dist/plugin/host-state.d.ts.map +1 -0
  218. package/dist/plugin/host-state.js +62 -0
  219. package/dist/plugin/host-state.js.map +1 -0
  220. package/dist/plugin/registry.d.ts +35 -0
  221. package/dist/plugin/registry.d.ts.map +1 -0
  222. package/dist/plugin/registry.js +129 -0
  223. package/dist/plugin/registry.js.map +1 -0
  224. package/dist/plugin/types.d.ts +165 -0
  225. package/dist/plugin/types.d.ts.map +1 -0
  226. package/dist/plugin/types.js +2 -0
  227. package/dist/plugin/types.js.map +1 -0
  228. package/dist/plugin/version.d.ts +34 -0
  229. package/dist/plugin/version.d.ts.map +1 -0
  230. package/dist/plugin/version.js +37 -0
  231. package/dist/plugin/version.js.map +1 -0
  232. package/dist/query-keys.d.ts +31 -0
  233. package/dist/query-keys.d.ts.map +1 -0
  234. package/dist/query-keys.js +31 -0
  235. package/dist/query-keys.js.map +1 -0
  236. package/dist/schema-editor/SchemaEditor.d.ts +43 -0
  237. package/dist/schema-editor/SchemaEditor.d.ts.map +1 -0
  238. package/dist/schema-editor/SchemaEditor.js +106 -0
  239. package/dist/schema-editor/SchemaEditor.js.map +1 -0
  240. package/dist/schema-editor/index.d.ts +10 -0
  241. package/dist/schema-editor/index.d.ts.map +1 -0
  242. package/dist/schema-editor/index.js +8 -0
  243. package/dist/schema-editor/index.js.map +1 -0
  244. package/dist/schema-editor/lint.d.ts +37 -0
  245. package/dist/schema-editor/lint.d.ts.map +1 -0
  246. package/dist/schema-editor/lint.js +49 -0
  247. package/dist/schema-editor/lint.js.map +1 -0
  248. package/dist/schema-form/SchemaForm.d.ts +70 -0
  249. package/dist/schema-form/SchemaForm.d.ts.map +1 -0
  250. package/dist/schema-form/SchemaForm.js +13 -0
  251. package/dist/schema-form/SchemaForm.js.map +1 -0
  252. package/dist/schema-form/array-field.d.ts +20 -0
  253. package/dist/schema-form/array-field.d.ts.map +1 -0
  254. package/dist/schema-form/array-field.js +39 -0
  255. package/dist/schema-form/array-field.js.map +1 -0
  256. package/dist/schema-form/classify.d.ts +87 -0
  257. package/dist/schema-form/classify.d.ts.map +1 -0
  258. package/dist/schema-form/classify.js +199 -0
  259. package/dist/schema-form/classify.js.map +1 -0
  260. package/dist/schema-form/context.d.ts +4 -0
  261. package/dist/schema-form/context.d.ts.map +1 -0
  262. package/dist/schema-form/context.js +14 -0
  263. package/dist/schema-form/context.js.map +1 -0
  264. package/dist/schema-form/default-value.d.ts +8 -0
  265. package/dist/schema-form/default-value.d.ts.map +1 -0
  266. package/dist/schema-form/default-value.js +64 -0
  267. package/dist/schema-form/default-value.js.map +1 -0
  268. package/dist/schema-form/enum-field.d.ts +19 -0
  269. package/dist/schema-form/enum-field.d.ts.map +1 -0
  270. package/dist/schema-form/enum-field.js +26 -0
  271. package/dist/schema-form/enum-field.js.map +1 -0
  272. package/dist/schema-form/field-group.d.ts +9 -0
  273. package/dist/schema-form/field-group.d.ts.map +1 -0
  274. package/dist/schema-form/field-group.js +32 -0
  275. package/dist/schema-form/field-group.js.map +1 -0
  276. package/dist/schema-form/field-node.d.ts +24 -0
  277. package/dist/schema-form/field-node.d.ts.map +1 -0
  278. package/dist/schema-form/field-node.js +51 -0
  279. package/dist/schema-form/field-node.js.map +1 -0
  280. package/dist/schema-form/index.d.ts +13 -0
  281. package/dist/schema-form/index.d.ts.map +1 -0
  282. package/dist/schema-form/index.js +11 -0
  283. package/dist/schema-form/index.js.map +1 -0
  284. package/dist/schema-form/media-field.d.ts +24 -0
  285. package/dist/schema-form/media-field.d.ts.map +1 -0
  286. package/dist/schema-form/media-field.js +169 -0
  287. package/dist/schema-form/media-field.js.map +1 -0
  288. package/dist/schema-form/media.d.ts +40 -0
  289. package/dist/schema-form/media.d.ts.map +1 -0
  290. package/dist/schema-form/media.js +65 -0
  291. package/dist/schema-form/media.js.map +1 -0
  292. package/dist/schema-form/object-fields.d.ts +20 -0
  293. package/dist/schema-form/object-fields.d.ts.map +1 -0
  294. package/dist/schema-form/object-fields.js +24 -0
  295. package/dist/schema-form/object-fields.js.map +1 -0
  296. package/dist/schema-form/resolve.d.ts +41 -0
  297. package/dist/schema-form/resolve.d.ts.map +1 -0
  298. package/dist/schema-form/resolve.js +102 -0
  299. package/dist/schema-form/resolve.js.map +1 -0
  300. package/dist/schema-form/string-field.d.ts +20 -0
  301. package/dist/schema-form/string-field.d.ts.map +1 -0
  302. package/dist/schema-form/string-field.js +68 -0
  303. package/dist/schema-form/string-field.js.map +1 -0
  304. package/dist/schema-form/styles.d.ts +18 -0
  305. package/dist/schema-form/styles.d.ts.map +1 -0
  306. package/dist/schema-form/styles.js +18 -0
  307. package/dist/schema-form/styles.js.map +1 -0
  308. package/dist/schema-form/types.d.ts +67 -0
  309. package/dist/schema-form/types.d.ts.map +1 -0
  310. package/dist/schema-form/types.js +10 -0
  311. package/dist/schema-form/types.js.map +1 -0
  312. package/dist/schema-form/union-field.d.ts +24 -0
  313. package/dist/schema-form/union-field.d.ts.map +1 -0
  314. package/dist/schema-form/union-field.js +55 -0
  315. package/dist/schema-form/union-field.js.map +1 -0
  316. package/dist/schema-form/union.d.ts +4 -0
  317. package/dist/schema-form/union.d.ts.map +1 -0
  318. package/dist/schema-form/union.js +68 -0
  319. package/dist/schema-form/union.js.map +1 -0
  320. package/dist/schema-form/unsupported-notice.d.ts +18 -0
  321. package/dist/schema-form/unsupported-notice.d.ts.map +1 -0
  322. package/dist/schema-form/unsupported-notice.js +8 -0
  323. package/dist/schema-form/unsupported-notice.js.map +1 -0
  324. package/dist/schema-form/validate.d.ts +18 -0
  325. package/dist/schema-form/validate.d.ts.map +1 -0
  326. package/dist/schema-form/validate.js +162 -0
  327. package/dist/schema-form/validate.js.map +1 -0
  328. package/dist/structured-output/StructuredOutput.d.ts +27 -0
  329. package/dist/structured-output/StructuredOutput.d.ts.map +1 -0
  330. package/dist/structured-output/StructuredOutput.js +41 -0
  331. package/dist/structured-output/StructuredOutput.js.map +1 -0
  332. package/dist/testing.d.ts +80 -0
  333. package/dist/testing.d.ts.map +1 -0
  334. package/dist/testing.js +207 -0
  335. package/dist/testing.js.map +1 -0
  336. package/package.json +101 -0
  337. package/src/components/badge.tsx +31 -0
  338. package/src/components/checkbox.tsx +93 -0
  339. package/src/components/code-block.tsx +37 -0
  340. package/src/components/completion-input.tsx +137 -0
  341. package/src/components/components.css +2212 -0
  342. package/src/components/confirm-dialog.tsx +77 -0
  343. package/src/components/control-styles.ts +14 -0
  344. package/src/components/copy-field.tsx +178 -0
  345. package/src/components/dialog.tsx +76 -0
  346. package/src/components/drawer.tsx +83 -0
  347. package/src/components/error-boundary.tsx +56 -0
  348. package/src/components/extension-combo-builder.tsx +305 -0
  349. package/src/components/extension-grouping.ts +116 -0
  350. package/src/components/extension-picker.tsx +97 -0
  351. package/src/components/external-link.tsx +40 -0
  352. package/src/components/field.tsx +169 -0
  353. package/src/components/fleet-report.tsx +136 -0
  354. package/src/components/fonts.css +22 -0
  355. package/src/components/icons.tsx +504 -0
  356. package/src/components/inputs.tsx +125 -0
  357. package/src/components/json-diff.tsx +192 -0
  358. package/src/components/json-tree.tsx +129 -0
  359. package/src/components/modal-focus.ts +150 -0
  360. package/src/components/page-header.tsx +107 -0
  361. package/src/components/primitives.tsx +489 -0
  362. package/src/components/progress-bar.tsx +100 -0
  363. package/src/components/radio-group.tsx +160 -0
  364. package/src/components/reveal-input.tsx +87 -0
  365. package/src/components/scroll-region.tsx +703 -0
  366. package/src/components/select.tsx +149 -0
  367. package/src/components/table.tsx +94 -0
  368. package/src/components/tabs.tsx +51 -0
  369. package/src/components/tags.tsx +137 -0
  370. package/src/components/tokens.css +392 -0
  371. package/src/components/tokens.ts +102 -0
  372. package/src/components/tool-picker.tsx +175 -0
  373. package/src/components/tooltip.tsx +46 -0
  374. package/src/components/version-history-panel.tsx +407 -0
  375. package/src/css.d.ts +2 -0
  376. package/src/download.ts +17 -0
  377. package/src/element-slot.ts +22 -0
  378. package/src/elicitation/ElicitationForm.tsx +87 -0
  379. package/src/errors.ts +12 -0
  380. package/src/extension-combos.ts +18 -0
  381. package/src/hooks/useApi.ts +27 -0
  382. package/src/hooks/useAuth.ts +67 -0
  383. package/src/hooks/useBreakpoint.ts +78 -0
  384. package/src/hooks/useCapabilities.ts +242 -0
  385. package/src/hooks/useSse.ts +314 -0
  386. package/src/hooks/useTheme.ts +133 -0
  387. package/src/hooks/useUnauthorized.ts +20 -0
  388. package/src/host.ts +15 -0
  389. package/src/index.ts +267 -0
  390. package/src/navigation/context.tsx +90 -0
  391. package/src/navigation/index.ts +9 -0
  392. package/src/navigation/types.ts +90 -0
  393. package/src/plugin/host-state.ts +93 -0
  394. package/src/plugin/registry.ts +174 -0
  395. package/src/plugin/types.ts +178 -0
  396. package/src/plugin/version.ts +44 -0
  397. package/src/query-keys.ts +34 -0
  398. package/src/schema-editor/SchemaEditor.tsx +186 -0
  399. package/src/schema-editor/index.ts +9 -0
  400. package/src/schema-editor/lint.ts +70 -0
  401. package/src/schema-form/SchemaForm.tsx +107 -0
  402. package/src/schema-form/array-field.tsx +110 -0
  403. package/src/schema-form/classify.ts +302 -0
  404. package/src/schema-form/context.ts +17 -0
  405. package/src/schema-form/default-value.ts +65 -0
  406. package/src/schema-form/enum-field.tsx +65 -0
  407. package/src/schema-form/field-group.tsx +71 -0
  408. package/src/schema-form/field-node.tsx +161 -0
  409. package/src/schema-form/index.ts +12 -0
  410. package/src/schema-form/media-field.tsx +281 -0
  411. package/src/schema-form/media.ts +69 -0
  412. package/src/schema-form/object-fields.tsx +74 -0
  413. package/src/schema-form/resolve.ts +114 -0
  414. package/src/schema-form/string-field.tsx +161 -0
  415. package/src/schema-form/styles.ts +20 -0
  416. package/src/schema-form/types.ts +71 -0
  417. package/src/schema-form/union-field.tsx +122 -0
  418. package/src/schema-form/union.ts +78 -0
  419. package/src/schema-form/unsupported-notice.tsx +39 -0
  420. package/src/schema-form/validate.ts +183 -0
  421. package/src/structured-output/StructuredOutput.tsx +81 -0
  422. package/src/testing.ts +235 -0
@@ -0,0 +1,574 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /**
3
+ * `ScrollRegion` — a horizontally scrollable container that becomes a keyboard
4
+ * target ONLY while it actually overflows.
5
+ *
6
+ * A pane that scrolls must be reachable without a pointer (WCAG 2.1.1), which
7
+ * needs `tabIndex`, `role="region"` and a name. Applying those unconditionally
8
+ * would litter every screen with phantom landmarks and dead tab stops for tables
9
+ * that happen to fit, so the attributes are driven by a live measurement:
10
+ * `scrollWidth > clientWidth`, re-taken whenever the container or its content
11
+ * resizes and whenever the content is replaced.
12
+ *
13
+ * `useOverflowRegion` is the same measurement for a component that IS its own
14
+ * scrolling box (a `<pre>`, a JSON pane) and therefore cannot be wrapped in a
15
+ * `<div>` without gaining a second scroller. `useProseScrollRegions` applies the
16
+ * rules to the surfaces React never renders — the tables and code blocks inside
17
+ * `dangerouslySetInnerHTML` (rendered README/markdown), which cannot be wrapped
18
+ * in a component and are therefore instrumented imperatively.
19
+ *
20
+ * Both hooks hand back a CALLBACK REF for the element they measure, rather than
21
+ * reading one the caller holds: a ref object tells a hook nothing about WHEN it
22
+ * is filled, so a hook that read one would never instrument an element that
23
+ * mounts later than the hook (a README that arrives with the second render) and
24
+ * would never notice one being swapped for another.
25
+ */
26
+ import { useCallback, useState } from 'react';
27
+ /**
28
+ * The names for a prose surface that has no heading above it.
29
+ *
30
+ * They say what the surface IS and nothing about which document it came from,
31
+ * because this hook cannot know: it instruments whatever markup the caller
32
+ * injected. A default that named one document put that document's name on every
33
+ * caller's regions, and a region a reader hears the wrong name for is worse than
34
+ * a plain one. A caller that CAN say which document it is showing passes its own
35
+ * `labels`; a surface with a heading above it takes that heading instead, which
36
+ * is the usual case.
37
+ */
38
+ const DEFAULT_PROSE_LABELS = { table: 'Table', pre: 'Code block' };
39
+ const HEADING_SELECTOR = 'h1, h2, h3, h4, h5, h6';
40
+ /**
41
+ * Headings AND the surfaces they name, in one selector: a single query returns
42
+ * both interleaved in document order, which is what lets one walk name every
43
+ * surface (see `labelledProseSurfaces`).
44
+ */
45
+ const PROSE_SURFACE_SELECTOR = `${HEADING_SELECTOR}, table, pre`;
46
+ const SCROLL_REGION_CLASS = 'tai-scroll-region';
47
+ /**
48
+ * The most surfaces one rendered document is given regions for.
49
+ *
50
+ * The prose is publisher-authored and unbounded in length, and every region is
51
+ * an entry in the landmark list a screen-reader user navigates the page by: a
52
+ * README with more surfaces than this turns that list into the very thing the
53
+ * regions exist to spare a reader. Past the cap a table still gets its scrolling
54
+ * wrapper — the wrapper is what keeps it inside the column — but no name and no
55
+ * tab stop, so the landmark list stays a list a person can read.
56
+ */
57
+ const MAX_PROSE_REGIONS = 200;
58
+ function overflows(element) {
59
+ return element.scrollWidth > element.clientWidth;
60
+ }
61
+ /**
62
+ * Whether the element should carry the region attributes right now.
63
+ *
64
+ * A region that stops overflowing keeps its tab stop for as long as it holds
65
+ * focus: taking `tabindex` off the focused element drops the reader onto the
66
+ * document body, and a window resize is not their doing. Only an element that
67
+ * already has the stop can be the active element, so this can hold a stop open
68
+ * but never invent one.
69
+ */
70
+ function needsRegion(element) {
71
+ return overflows(element) || element.ownerDocument.activeElement === element;
72
+ }
73
+ /**
74
+ * Attaches `element` to a consumer ref of either form, and returns the detach
75
+ * for it. A callback ref that answers with its own cleanup gets that cleanup
76
+ * called rather than a second call with `null` — the contract React itself
77
+ * follows for a ref it owns.
78
+ */
79
+ function attachRef(ref, element) {
80
+ if (ref === undefined || ref === null)
81
+ return () => undefined;
82
+ if (typeof ref !== 'function') {
83
+ ref.current = element;
84
+ return () => {
85
+ ref.current = null;
86
+ };
87
+ }
88
+ const cleanup = ref(element);
89
+ if (typeof cleanup === 'function')
90
+ return cleanup;
91
+ return () => {
92
+ ref(null);
93
+ };
94
+ }
95
+ /**
96
+ * The handlers waiting on each observed element. A SET, not a single handler:
97
+ * one element can be both a box and another box's child — a `<pre>` inside a
98
+ * `ScrollRegion` is exactly that — and both owners must still hear its resize.
99
+ */
100
+ const resizeHandlers = new WeakMap();
101
+ let sharedResize;
102
+ function sharedResizeObserver() {
103
+ sharedResize ??= new ResizeObserver((entries) => {
104
+ // A box and its children are observed separately, so one frame can deliver
105
+ // several entries owned by the same handler; measuring once is enough.
106
+ const fired = new Set();
107
+ for (const entry of entries) {
108
+ for (const handler of resizeHandlers.get(entry.target) ?? [])
109
+ fired.add(handler);
110
+ }
111
+ for (const handler of fired)
112
+ handler();
113
+ });
114
+ return sharedResize;
115
+ }
116
+ /**
117
+ * Registers `handler` for `target`'s resizes, observing the element only the
118
+ * first time anyone asks for it: re-observing an element already under a
119
+ * `ResizeObserver` re-arms its initial notification, which spends a forced
120
+ * layout on a measurement nobody asked for.
121
+ */
122
+ function holdResizeTarget(target, handler) {
123
+ const handlers = resizeHandlers.get(target);
124
+ if (handlers !== undefined) {
125
+ handlers.add(handler);
126
+ return;
127
+ }
128
+ // Registered before the element is observed, so the initial notification the
129
+ // observation arms reaches the handler that asked for it.
130
+ resizeHandlers.set(target, new Set([handler]));
131
+ sharedResizeObserver().observe(target);
132
+ }
133
+ /** Stops observing `target` for `handler`, and entirely once nobody wants it. */
134
+ function releaseResizeTarget(target, handler) {
135
+ const handlers = resizeHandlers.get(target);
136
+ if (handlers === undefined)
137
+ return;
138
+ handlers.delete(handler);
139
+ if (handlers.size > 0)
140
+ return;
141
+ resizeHandlers.delete(target);
142
+ sharedResizeObserver().unobserve(target);
143
+ }
144
+ /** What a box wants to hear about: its content replaced, appended or edited. */
145
+ const CONTENT_OBSERVER_INIT = {
146
+ childList: true,
147
+ subtree: true,
148
+ characterData: true,
149
+ };
150
+ /**
151
+ * The handlers waiting on each observed box, and the boxes the shared observer
152
+ * currently holds. Keyed by `Node` because a `characterData` record names the
153
+ * TEXT node that changed, and the walk to the box that owns it goes through
154
+ * whatever nodes lie between.
155
+ */
156
+ const contentHandlers = new WeakMap();
157
+ const contentTargets = new Set();
158
+ let sharedContent;
159
+ /** Registrations the shared observer still holds for released boxes. */
160
+ let staleContentTargets = 0;
161
+ function deliverContentRecords(records) {
162
+ const fired = new Set();
163
+ for (const record of records) {
164
+ // A `childList` record names the changed parent and a `characterData` record
165
+ // the text node itself, either of them at any depth under a box. Every box
166
+ // on the ancestor chain therefore owns the change, exactly as a separate
167
+ // observer on each of them would have seen it — a `<pre>` inside a
168
+ // `ScrollRegion` measures both.
169
+ for (let node = record.target; node !== null; node = node.parentNode) {
170
+ for (const handler of contentHandlers.get(node) ?? [])
171
+ fired.add(handler);
172
+ }
173
+ }
174
+ for (const handler of fired)
175
+ handler();
176
+ }
177
+ function sharedContentObserver() {
178
+ sharedContent ??= new MutationObserver(deliverContentRecords);
179
+ return sharedContent;
180
+ }
181
+ function holdContentTarget(target, handler) {
182
+ let handlers = contentHandlers.get(target);
183
+ if (handlers === undefined) {
184
+ handlers = new Set();
185
+ contentHandlers.set(target, handlers);
186
+ contentTargets.add(target);
187
+ sharedContentObserver().observe(target, CONTENT_OBSERVER_INIT);
188
+ }
189
+ handlers.add(handler);
190
+ }
191
+ /**
192
+ * Stops watching `target`'s content for `handler`.
193
+ *
194
+ * `MutationObserver` has no `unobserve`: the only way to drop one registration
195
+ * is to disconnect the observer and re-observe everything else, which would cost
196
+ * one registration per surviving box every time a box unmounts. A released box
197
+ * is therefore dropped from the handler map at once — its records find no
198
+ * handler and are ignored — and the observer is rebuilt only once the dead
199
+ * registrations outnumber the live ones, which keeps the total registration work
200
+ * proportional to the number of mounts. Records already queued survive the
201
+ * rebuild: they are taken off the observer and delivered by hand.
202
+ */
203
+ function releaseContentTarget(target, handler) {
204
+ const handlers = contentHandlers.get(target);
205
+ if (handlers === undefined)
206
+ return;
207
+ handlers.delete(handler);
208
+ if (handlers.size > 0)
209
+ return;
210
+ contentHandlers.delete(target);
211
+ contentTargets.delete(target);
212
+ staleContentTargets += 1;
213
+ if (staleContentTargets <= contentTargets.size)
214
+ return;
215
+ const observer = sharedContentObserver();
216
+ const queued = observer.takeRecords();
217
+ observer.disconnect();
218
+ staleContentTargets = 0;
219
+ for (const live of contentTargets)
220
+ observer.observe(live, CONTENT_OBSERVER_INIT);
221
+ if (queued.length > 0)
222
+ deliverContentRecords(queued);
223
+ }
224
+ /**
225
+ * The conditional region attributes for a scrolling box, alongside the ref that
226
+ * names it. The ref must go on the scrolling box ITSELF — a `<pre>`, a JSON
227
+ * pane, or the `div` `ScrollRegion` renders. Use the hook when wrapping the
228
+ * content in a `ScrollRegion` would give the surface a second scroller.
229
+ *
230
+ * The box is measured as it is attached, whenever it or any child resizes, and
231
+ * whenever its content changes — replaced, appended, or edited in place. A
232
+ * replaced child is a NEW element, so the registration is re-pointed at the
233
+ * current children before each measurement, adding and dropping only the ones
234
+ * that actually changed; both sides of that are registrations on the shared
235
+ * observers, not observers of this mount's own. The only DOM change a
236
+ * measurement can cause is the region ATTRIBUTES this hook returns, and
237
+ * attributes are deliberately left unobserved — that, not an absence of
238
+ * mutation, is what stops the pair from re-triggering each other.
239
+ *
240
+ * @param ref - a consumer ref that wants the same element, or `undefined`.
241
+ * @param label - its accessible name, applied only while it actually scrolls.
242
+ */
243
+ export function useOverflowRegion(ref, label) {
244
+ const [scrollable, setScrollable] = useState(false);
245
+ // Attached and released with the element, so a box that mounts later than the
246
+ // hook, or is swapped for another, is instrumented exactly once either way.
247
+ const measuredRef = useCallback((box) => {
248
+ const detachConsumer = attachRef(ref, box);
249
+ const measure = () => {
250
+ setScrollable(needsRegion(box));
251
+ };
252
+ // The box gives resize; its children give the overflowing width. The
253
+ // shared observer is released target by target rather than disconnected,
254
+ // because every other scrolling box on the page is registered on the same
255
+ // one — and only the targets that actually came or went are touched, so an
256
+ // edit in place re-registers nothing and costs one measurement.
257
+ let observed = [];
258
+ const observeAll = () => {
259
+ const current = [box, ...box.children];
260
+ const kept = new Set(current);
261
+ for (const target of observed) {
262
+ if (!kept.has(target))
263
+ releaseResizeTarget(target, measure);
264
+ }
265
+ for (const target of current)
266
+ holdResizeTarget(target, measure);
267
+ observed = current;
268
+ measure();
269
+ };
270
+ // The whole subtree, text included: content is as often EDITED IN PLACE —
271
+ // a longer code string, a different JSON body — as it is replaced, and
272
+ // React reuses the element when it does, so watching the direct child list
273
+ // alone would freeze the measurement at whatever the first content needed.
274
+ // ATTRIBUTES are deliberately absent: the region attributes are what a
275
+ // measurement writes, and observing them would make each pass trigger the
276
+ // next.
277
+ holdContentTarget(box, observeAll);
278
+ observeAll();
279
+ // A stop held open only because the box had focus outlives its reason the
280
+ // moment the reader leaves, so re-measure then and let it go.
281
+ const releaseHeldStop = () => {
282
+ measure();
283
+ };
284
+ box.addEventListener('blur', releaseHeldStop);
285
+ return () => {
286
+ for (const target of observed)
287
+ releaseResizeTarget(target, measure);
288
+ observed = [];
289
+ releaseContentTarget(box, observeAll);
290
+ box.removeEventListener('blur', releaseHeldStop);
291
+ detachConsumer();
292
+ };
293
+ }, [ref]);
294
+ if (!scrollable)
295
+ return { ref: measuredRef };
296
+ return { ref: measuredRef, tabIndex: 0, role: 'region', 'aria-label': label };
297
+ }
298
+ export function ScrollRegion({ label, children, className, style, 'data-testid': testId, ref, }) {
299
+ const region = useOverflowRegion(ref, label);
300
+ return (_jsx("div", { className: className === undefined ? SCROLL_REGION_CLASS : `${SCROLL_REGION_CLASS} ${className}`, style: style, "data-testid": testId, ...region, children: children }));
301
+ }
302
+ /**
303
+ * The wrapper a prose table sits inside, creating it on first pass. Idempotent:
304
+ * a table already inside a `.tai-scroll-region` keeps the wrapper it has.
305
+ */
306
+ function ensureScrollWrapper(table) {
307
+ const parent = table.parentElement;
308
+ if (parent?.classList.contains(SCROLL_REGION_CLASS) === true)
309
+ return parent;
310
+ const wrapper = table.ownerDocument.createElement('div');
311
+ wrapper.className = SCROLL_REGION_CLASS;
312
+ table.replaceWith(wrapper);
313
+ wrapper.append(table);
314
+ return wrapper;
315
+ }
316
+ /**
317
+ * The text of the last heading in `headings` that does not ENCLOSE `surface`.
318
+ *
319
+ * A heading wrapping the surface does precede it in document order, but it is
320
+ * not a section the surface sits UNDER, so it is stepped over in favour of the
321
+ * heading before it — which is the answer an outward walk from the surface
322
+ * reaches. In well-formed prose no heading contains a table or a code block, so
323
+ * this returns the last heading on the first look.
324
+ */
325
+ function namingHeadingText(headings, surface) {
326
+ for (let index = headings.length - 1; index >= 0; index -= 1) {
327
+ const heading = headings[index];
328
+ if (heading !== undefined && !heading.element.contains(surface))
329
+ return heading.text;
330
+ }
331
+ return undefined;
332
+ }
333
+ /**
334
+ * Every scrollable prose surface under `root` — each `<table>` and each `<pre>`
335
+ * — paired with the text of the nearest heading PRECEDING it, or `undefined`
336
+ * when no heading does.
337
+ *
338
+ * One query returns the headings and the surfaces interleaved in document order,
339
+ * so a single walk over that list names all of them: the heading a surface
340
+ * belongs to is the last one seen before reaching it. Naming each surface by
341
+ * searching backwards from it instead would re-read the same prose once per
342
+ * surface, at a cost that grows with the product of the two.
343
+ *
344
+ * Blank headings never enter the list, so a decorative empty heading names
345
+ * nothing and the section above it is used instead. A heading INSIDE a surface
346
+ * (a `<pre>` or a table cell holding one) comes AFTER that surface in document
347
+ * order and so can never name it, though it does name later surfaces — exactly
348
+ * as being the last heading before them implies.
349
+ *
350
+ * Read in full before the pass wraps anything, and safely so: a name depends
351
+ * only on what PRECEDES its surface, and `ensureScrollWrapper` puts the wrapper
352
+ * in the table's own place, moving nothing else and leaving every heading where
353
+ * it was — so a name stays true whether its table is wrapped yet or not.
354
+ */
355
+ function labelledProseSurfaces(root) {
356
+ const headings = [];
357
+ const surfaces = [];
358
+ for (const node of root.querySelectorAll(PROSE_SURFACE_SELECTOR)) {
359
+ if (node.matches(HEADING_SELECTOR)) {
360
+ // textContent is nullable under strict DOM typings; the local eslint
361
+ // profile assumes non-null, so the necessary guard trips its rule.
362
+ // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
363
+ const text = (node.textContent ?? '').trim();
364
+ if (text !== '')
365
+ headings.push({ element: node, text });
366
+ continue;
367
+ }
368
+ surfaces.push({ element: node, heading: namingHeadingText(headings, node) });
369
+ }
370
+ return surfaces;
371
+ }
372
+ /**
373
+ * The same surfaces, each given a name no other one in the list carries.
374
+ *
375
+ * A name is only as useful as it is distinguishing, and one heading names every
376
+ * surface under it: two wide tables in one section, or two code blocks under no
377
+ * heading at all, would otherwise be two landmarks a reader hears identically
378
+ * and cannot choose between. A name more than one surface claims is therefore
379
+ * numbered, in document order, and a name only one surface claims is left alone.
380
+ */
381
+ function uniquelyNamed(boxes) {
382
+ const claims = new Map();
383
+ for (const { name } of boxes)
384
+ claims.set(name, (claims.get(name) ?? 0) + 1);
385
+ const taken = new Map();
386
+ return boxes.map(({ surface, name }) => {
387
+ if (claims.get(name) === 1)
388
+ return { surface, label: name };
389
+ const ordinal = (taken.get(name) ?? 0) + 1;
390
+ taken.set(name, ordinal);
391
+ return { surface, label: `${name} (${String(ordinal)})` };
392
+ });
393
+ }
394
+ /** Strips the region attributes from a surface that is not a region now. */
395
+ function clearScrollRegionAttributes(wrapper) {
396
+ wrapper.removeAttribute('tabindex');
397
+ wrapper.removeAttribute('role');
398
+ wrapper.removeAttribute('aria-label');
399
+ }
400
+ /** Applies the same conditional attribute set `ScrollRegion` renders. */
401
+ function applyScrollRegionAttributes(wrapper, label, scrolling) {
402
+ if (!scrolling) {
403
+ clearScrollRegionAttributes(wrapper);
404
+ return;
405
+ }
406
+ wrapper.setAttribute('tabindex', '0');
407
+ wrapper.setAttribute('role', 'region');
408
+ wrapper.setAttribute('aria-label', label);
409
+ }
410
+ /**
411
+ * Re-applies the region attributes to `tracked`, reading ALL of them before
412
+ * writing any.
413
+ *
414
+ * `needsRegion` reads `scrollWidth`, which forces layout if anything has been
415
+ * written since the last one — so measuring and writing surface by surface makes
416
+ * the browser re-lay-out the prose once per surface, every time. Two phases cost
417
+ * one layout for the whole batch however many surfaces it holds.
418
+ */
419
+ function refreshRegions(tracked) {
420
+ const scrolling = tracked.map((entry) => needsRegion(entry.surface));
421
+ for (const [index, entry] of tracked.entries()) {
422
+ applyScrollRegionAttributes(entry.surface, entry.label, scrolling[index] === true);
423
+ }
424
+ }
425
+ /**
426
+ * Instruments the scrollable surfaces under the element the returned ref is
427
+ * attached to — every `<table>` and every `<pre>` — as scroll regions. React
428
+ * cannot wrap markup it did not create, so this walks the DOM instead. A table
429
+ * is moved into a `div.tai-scroll-region` (once — the pass is idempotent)
430
+ * because the table itself is not the scrolling box; a `<pre>` already IS its
431
+ * own scrolling box, so it is instrumented in place. Either way the scrolling
432
+ * element carries the same conditional `tabindex`/`role`/`aria-label` as
433
+ * `ScrollRegion`.
434
+ *
435
+ * The name is the nearest heading preceding the surface — read for all of them
436
+ * in one document-order pass — so a reader landing on the region hears which
437
+ * section it belongs to; `labels` covers a surface with no heading above it, and
438
+ * a name shared by several surfaces is numbered so no two regions answer to the
439
+ * same one.
440
+ *
441
+ * The pass runs from the ref callback rather than an effect, which puts it in
442
+ * the commit phase, BEFORE the browser paints: `.tai-prose table` is
443
+ * `width: 100%` with no overflow of its own — the scroller exists only on the
444
+ * wrapper this builds — so a pass that ran after paint would show one frame at
445
+ * 320/360 px with the table overflowing the document, then jolt sideways. A
446
+ * passive-effect probe measured exactly that: at first paint wrappers=0 and the
447
+ * table's parent was `.tai-prose`.
448
+ *
449
+ * Injected HTML is replaced wholesale when its source changes, so the pass is
450
+ * re-run from a `MutationObserver` on the subtree rather than on attachment
451
+ * alone.
452
+ *
453
+ * @param labels - the names for surfaces with no preceding heading.
454
+ * @returns the ref for the element whose subtree holds the injected markup.
455
+ */
456
+ export function useProseScrollRegions(labels) {
457
+ const tableLabel = labels?.table ?? DEFAULT_PROSE_LABELS.table;
458
+ const preLabel = labels?.pre ?? DEFAULT_PROSE_LABELS.pre;
459
+ return useCallback((root) => {
460
+ // Every observed element, mapped to the surface whose width it reports and
461
+ // that surface's current name. This is what lets a resize re-measure just
462
+ // the surfaces that moved: an observer callback carries the elements that
463
+ // resized, and each of them answers here with the region it belongs to.
464
+ const surfaceOf = new WeakMap();
465
+ // What the observer holds and what wears region attributes right now. A
466
+ // re-instrumentation replaces the surfaces wholesale, and the elements it
467
+ // drops are detached ones: kept observed they would be registrations on
468
+ // dead nodes, kept named they would be landmarks nobody can reach.
469
+ let observed = new Set();
470
+ let instrumented = new Set();
471
+ // The box gives resize; its children give the overflowing width. A table
472
+ // that grows wider inside a parent-constrained wrapper resizes nothing
473
+ // else, so watching the wrapper alone would freeze the mount-time
474
+ // measurement. Membership of `observed` doubles as the re-observation
475
+ // guard: re-observing an element already under a ResizeObserver re-arms
476
+ // its initial notification, which would make each pass trigger the next
477
+ // one forever.
478
+ const track = (entry, next) => {
479
+ for (const target of [entry.surface, ...entry.surface.children]) {
480
+ // Rewritten even when already observed: a re-run may have found a new
481
+ // heading above the surface, and the name has to follow it.
482
+ surfaceOf.set(target, entry);
483
+ next.add(target);
484
+ if (!observed.has(target))
485
+ resizeObserver.observe(target);
486
+ }
487
+ };
488
+ // A pass over the whole subtree. It reads the observers declared below it,
489
+ // which is safe because nothing calls it until both exist.
490
+ const instrument = () => {
491
+ // Wrapping mutates the subtree; pause the observer so this pass cannot
492
+ // re-trigger itself, and drop the records it generated before resuming.
493
+ mutationObserver.disconnect();
494
+ // Every name comes from one document-order read of the prose, taken
495
+ // before the first wrapper goes in. The list is a static snapshot and
496
+ // the surfaces in it stay the same elements: wrapping moves a table one
497
+ // level down, into a `div` standing exactly where the table stood, so
498
+ // neither the remaining entries nor the names already computed for them
499
+ // change. Every table is wrapped, cap or no cap — the wrapper is what
500
+ // keeps a `width: 100%` table inside the column.
501
+ const boxes = labelledProseSurfaces(root).map(({ element, heading }) => {
502
+ const table = element instanceof HTMLTableElement;
503
+ return {
504
+ surface: table ? ensureScrollWrapper(element) : element,
505
+ name: heading ?? (table ? tableLabel : preLabel),
506
+ };
507
+ });
508
+ const tracked = uniquelyNamed(boxes.slice(0, MAX_PROSE_REGIONS));
509
+ const next = new Set();
510
+ for (const entry of tracked)
511
+ track(entry, next);
512
+ for (const target of observed) {
513
+ if (!next.has(target))
514
+ resizeObserver.unobserve(target);
515
+ }
516
+ observed = next;
517
+ const dropped = instrumented;
518
+ instrumented = new Set(tracked.map((entry) => entry.surface));
519
+ // Wrapping is done for every surface before the first measurement, so
520
+ // the whole pass costs one layout rather than one per surface.
521
+ refreshRegions(tracked);
522
+ for (const surface of dropped) {
523
+ if (!instrumented.has(surface) && root.contains(surface)) {
524
+ clearScrollRegionAttributes(surface);
525
+ }
526
+ }
527
+ mutationObserver.takeRecords();
528
+ mutationObserver.observe(root, { childList: true, subtree: true });
529
+ };
530
+ // Only the surfaces that actually resized are re-measured. Re-running the
531
+ // whole instrumentation pass from here re-queried the entire prose subtree
532
+ // on every resize frame, and a document with many surfaces spends that
533
+ // cost once per frame for the whole time a pane is being dragged.
534
+ const resizeObserver = new ResizeObserver((entries) => {
535
+ // A surface and its children are observed separately, so one frame can
536
+ // deliver several entries naming the same region; measuring it once is
537
+ // enough.
538
+ const affected = new Map();
539
+ for (const entry of entries) {
540
+ const tracked = surfaceOf.get(entry.target);
541
+ if (tracked !== undefined)
542
+ affected.set(tracked.surface, tracked);
543
+ }
544
+ refreshRegions([...affected.values()]);
545
+ });
546
+ const mutationObserver = new MutationObserver(instrument);
547
+ // A stop held open only because the region had focus outlives its reason
548
+ // the moment the reader leaves. `focusout` bubbles, so one listener on the
549
+ // root covers every instrumented surface under it, however often they are
550
+ // replaced; the attribute pair is exactly what this hook writes, so it is
551
+ // also what identifies a region among the prose's other focusable content.
552
+ const releaseHeldStop = (event) => {
553
+ const left = event.target;
554
+ if (!(left instanceof HTMLElement))
555
+ return;
556
+ if (left.getAttribute('role') !== 'region' || !left.hasAttribute('tabindex'))
557
+ return;
558
+ // The stop being released belongs to exactly one region, so re-measure
559
+ // that one rather than re-walking the prose. A region this hook did not
560
+ // instrument is not ours to release.
561
+ const tracked = surfaceOf.get(left);
562
+ if (tracked !== undefined)
563
+ refreshRegions([tracked]);
564
+ };
565
+ root.addEventListener('focusout', releaseHeldStop);
566
+ instrument();
567
+ return () => {
568
+ resizeObserver.disconnect();
569
+ mutationObserver.disconnect();
570
+ root.removeEventListener('focusout', releaseHeldStop);
571
+ };
572
+ }, [tableLabel, preLabel]);
573
+ }
574
+ //# sourceMappingURL=scroll-region.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scroll-region.js","sourceRoot":"","sources":["../../src/components/scroll-region.tsx"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAqB9C;;;;;;;;;;GAUG;AACH,MAAM,oBAAoB,GAAG,EAAE,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,YAAY,EAAW,CAAC;AAQ5E,MAAM,gBAAgB,GAAG,wBAAwB,CAAC;AAElD;;;;GAIG;AACH,MAAM,sBAAsB,GAAG,GAAG,gBAAgB,cAAc,CAAC;AAEjE,MAAM,mBAAmB,GAAG,mBAAmB,CAAC;AAEhD;;;;;;;;;GASG;AACH,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAE9B,SAAS,SAAS,CAAC,OAAoB;IACrC,OAAO,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC;AACnD,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,WAAW,CAAC,OAAoB;IACvC,OAAO,SAAS,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC,aAAa,CAAC,aAAa,KAAK,OAAO,CAAC;AAC/E,CAAC;AAED;;;;;GAKG;AACH,SAAS,SAAS,CAAC,GAAiC,EAAE,OAAoB;IACxE,IAAI,GAAG,KAAK,SAAS,IAAI,GAAG,KAAK,IAAI;QAAE,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC;IAC9D,IAAI,OAAO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,YAAY,CAAC,MAAM,CAAC,KAAK,QAAQ,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;gBAAE,OAAO;YACrF,uEAAuE;YACvE,wEAAwE;YACxE,qCAAqC;YACrC,MAAM,OAAO,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YACpC,IAAI,OAAO,KAAK,SAAS;gBAAE,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;QACvD,CAAC,CAAC;QACF,IAAI,CAAC,gBAAgB,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;QAEnD,UAAU,EAAE,CAAC;QAEb,OAAO,GAAG,EAAE;YACV,cAAc,CAAC,UAAU,EAAE,CAAC;YAC5B,gBAAgB,CAAC,UAAU,EAAE,CAAC;YAC9B,IAAI,CAAC,mBAAmB,CAAC,UAAU,EAAE,eAAe,CAAC,CAAC;QACxD,CAAC,CAAC;IACJ,CAAC,EACD,CAAC,UAAU,EAAE,QAAQ,CAAC,CACvB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,53 @@
1
+ export interface SelectOption {
2
+ readonly value: string;
3
+ readonly label: string;
4
+ readonly disabled?: boolean;
5
+ }
6
+ /** A labelled cluster of options (e.g. tools grouped by tag). */
7
+ export interface SelectGroup {
8
+ readonly label: string;
9
+ readonly options: readonly SelectOption[];
10
+ }
11
+ /** Everything the two listbox shapes have in common. */
12
+ interface SelectSharedProps {
13
+ readonly value?: string;
14
+ readonly defaultValue?: string;
15
+ readonly onValueChange?: (value: string) => void;
16
+ readonly placeholder?: string;
17
+ readonly disabled?: boolean;
18
+ readonly name?: string;
19
+ /**
20
+ * Accessible name for the trigger when it is not wired to an enclosing
21
+ * `Field`. A `Field` wins where both are given — it names the trigger from
22
+ * visible text, and `aria-label` would override that native label and leave
23
+ * the visible text out of the accessible name (WCAG 2.5.3).
24
+ */
25
+ readonly 'aria-label'?: string;
26
+ }
27
+ /** The FLAT listbox: one ungrouped run of options. */
28
+ export interface SelectProps extends SelectSharedProps {
29
+ readonly options: readonly SelectOption[];
30
+ }
31
+ /** The GROUPED listbox: labelled clusters, each carrying its own options. */
32
+ export interface SelectGroupsProps extends SelectSharedProps {
33
+ readonly groups: readonly SelectGroup[];
34
+ }
35
+ /**
36
+ * What `Select` ACCEPTS: exactly one of the two shapes, never both. Only one
37
+ * list can be rendered, so accepting `options` alongside `groups` means
38
+ * discarding every entry of the other without a word.
39
+ *
40
+ * The exclusion lives HERE and not on the two interfaces because both are
41
+ * published plugin API and must stay extendable: `groups?: undefined` written
42
+ * onto `SelectProps` makes `interface MyPicker extends SelectProps { groups:
43
+ * readonly SelectGroup[] }` a TS2430, and a union cannot be `extends`-ed at all
44
+ * (TS2312).
45
+ */
46
+ type SelectArgs = (SelectProps & {
47
+ readonly groups?: undefined;
48
+ }) | (SelectGroupsProps & {
49
+ readonly options?: undefined;
50
+ });
51
+ export declare function Select(props: SelectArgs): import("react").JSX.Element;
52
+ export {};
53
+ //# sourceMappingURL=select.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/components/select.tsx"],"names":[],"mappings":"AAiBA,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,iEAAiE;AACjE,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,SAAS,YAAY,EAAE,CAAC;CAC3C;AAED,wDAAwD;AACxD,UAAU,iBAAiB;IACzB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAA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