@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.
- package/LICENSE +202 -0
- package/NOTICE +15 -0
- package/README.md +318 -0
- package/SECURITY.md +51 -0
- package/dist/components/badge.d.ts +13 -0
- package/dist/components/badge.d.ts.map +1 -0
- package/dist/components/badge.js +14 -0
- package/dist/components/badge.js.map +1 -0
- package/dist/components/checkbox.d.ts +24 -0
- package/dist/components/checkbox.d.ts.map +1 -0
- package/dist/components/checkbox.js +31 -0
- package/dist/components/checkbox.js.map +1 -0
- package/dist/components/code-block.d.ts +7 -0
- package/dist/components/code-block.d.ts.map +1 -0
- package/dist/components/code-block.js +23 -0
- package/dist/components/code-block.js.map +1 -0
- package/dist/components/completion-input.d.ts +31 -0
- package/dist/components/completion-input.d.ts.map +1 -0
- package/dist/components/completion-input.js +61 -0
- package/dist/components/completion-input.js.map +1 -0
- package/dist/components/components.css +2212 -0
- package/dist/components/confirm-dialog.d.ts +40 -0
- package/dist/components/confirm-dialog.d.ts.map +1 -0
- package/dist/components/confirm-dialog.js +11 -0
- package/dist/components/confirm-dialog.js.map +1 -0
- package/dist/components/control-styles.d.ts +12 -0
- package/dist/components/control-styles.d.ts.map +1 -0
- package/dist/components/control-styles.js +14 -0
- package/dist/components/control-styles.js.map +1 -0
- package/dist/components/copy-field.d.ts +8 -0
- package/dist/components/copy-field.d.ts.map +1 -0
- package/dist/components/copy-field.js +106 -0
- package/dist/components/copy-field.js.map +1 -0
- package/dist/components/dialog.d.ts +21 -0
- package/dist/components/dialog.d.ts.map +1 -0
- package/dist/components/dialog.js +25 -0
- package/dist/components/dialog.js.map +1 -0
- package/dist/components/drawer.d.ts +22 -0
- package/dist/components/drawer.d.ts.map +1 -0
- package/dist/components/drawer.js +32 -0
- package/dist/components/drawer.js.map +1 -0
- package/dist/components/error-boundary.d.ts +33 -0
- package/dist/components/error-boundary.d.ts.map +1 -0
- package/dist/components/error-boundary.js +36 -0
- package/dist/components/error-boundary.js.map +1 -0
- package/dist/components/extension-combo-builder.d.ts +70 -0
- package/dist/components/extension-combo-builder.d.ts.map +1 -0
- package/dist/components/extension-combo-builder.js +154 -0
- package/dist/components/extension-combo-builder.js.map +1 -0
- package/dist/components/extension-grouping.d.ts +65 -0
- package/dist/components/extension-grouping.d.ts.map +1 -0
- package/dist/components/extension-grouping.js +78 -0
- package/dist/components/extension-grouping.js.map +1 -0
- package/dist/components/extension-picker.d.ts +35 -0
- package/dist/components/extension-picker.d.ts.map +1 -0
- package/dist/components/extension-picker.js +31 -0
- package/dist/components/extension-picker.js.map +1 -0
- package/dist/components/external-link.d.ts +19 -0
- package/dist/components/external-link.d.ts.map +1 -0
- package/dist/components/external-link.js +12 -0
- package/dist/components/external-link.js.map +1 -0
- package/dist/components/field.d.ts +64 -0
- package/dist/components/field.d.ts.map +1 -0
- package/dist/components/field.js +56 -0
- package/dist/components/field.js.map +1 -0
- package/dist/components/fleet-report.d.ts +39 -0
- package/dist/components/fleet-report.d.ts.map +1 -0
- package/dist/components/fleet-report.js +50 -0
- package/dist/components/fleet-report.js.map +1 -0
- package/dist/components/fonts.css +22 -0
- package/dist/components/icons.d.ts +142 -0
- package/dist/components/icons.d.ts.map +1 -0
- package/dist/components/icons.js +139 -0
- package/dist/components/icons.js.map +1 -0
- package/dist/components/inputs.d.ts +52 -0
- package/dist/components/inputs.d.ts.map +1 -0
- package/dist/components/inputs.js +35 -0
- package/dist/components/inputs.js.map +1 -0
- package/dist/components/json-diff.d.ts +40 -0
- package/dist/components/json-diff.d.ts.map +1 -0
- package/dist/components/json-diff.js +119 -0
- package/dist/components/json-diff.js.map +1 -0
- package/dist/components/json-tree.d.ts +8 -0
- package/dist/components/json-tree.d.ts.map +1 -0
- package/dist/components/json-tree.js +70 -0
- package/dist/components/json-tree.js.map +1 -0
- package/dist/components/modal-focus.d.ts +15 -0
- package/dist/components/modal-focus.d.ts.map +1 -0
- package/dist/components/modal-focus.js +136 -0
- package/dist/components/modal-focus.js.map +1 -0
- package/dist/components/page-header.d.ts +56 -0
- package/dist/components/page-header.d.ts.map +1 -0
- package/dist/components/page-header.js +24 -0
- package/dist/components/page-header.js.map +1 -0
- package/dist/components/primitives.d.ts +186 -0
- package/dist/components/primitives.d.ts.map +1 -0
- package/dist/components/primitives.js +204 -0
- package/dist/components/primitives.js.map +1 -0
- package/dist/components/progress-bar.d.ts +29 -0
- package/dist/components/progress-bar.d.ts.map +1 -0
- package/dist/components/progress-bar.js +48 -0
- package/dist/components/progress-bar.js.map +1 -0
- package/dist/components/radio-group.d.ts +37 -0
- package/dist/components/radio-group.d.ts.map +1 -0
- package/dist/components/radio-group.js +56 -0
- package/dist/components/radio-group.js.map +1 -0
- package/dist/components/reveal-input.d.ts +13 -0
- package/dist/components/reveal-input.d.ts.map +1 -0
- package/dist/components/reveal-input.js +31 -0
- package/dist/components/reveal-input.js.map +1 -0
- package/dist/components/scroll-region.d.ts +85 -0
- package/dist/components/scroll-region.d.ts.map +1 -0
- package/dist/components/scroll-region.js +574 -0
- package/dist/components/scroll-region.js.map +1 -0
- package/dist/components/select.d.ts +53 -0
- package/dist/components/select.d.ts.map +1 -0
- package/dist/components/select.js +33 -0
- package/dist/components/select.js.map +1 -0
- package/dist/components/table.d.ts +59 -0
- package/dist/components/table.d.ts.map +1 -0
- package/dist/components/table.js +20 -0
- package/dist/components/table.js.map +1 -0
- package/dist/components/tabs.d.ts +15 -0
- package/dist/components/tabs.d.ts.map +1 -0
- package/dist/components/tabs.js +13 -0
- package/dist/components/tabs.js.map +1 -0
- package/dist/components/tags.d.ts +46 -0
- package/dist/components/tags.d.ts.map +1 -0
- package/dist/components/tags.js +68 -0
- package/dist/components/tags.js.map +1 -0
- package/dist/components/tokens.css +392 -0
- package/dist/components/tokens.d.ts +15 -0
- package/dist/components/tokens.d.ts.map +1 -0
- package/dist/components/tokens.js +101 -0
- package/dist/components/tokens.js.map +1 -0
- package/dist/components/tool-picker.d.ts +24 -0
- package/dist/components/tool-picker.d.ts.map +1 -0
- package/dist/components/tool-picker.js +97 -0
- package/dist/components/tool-picker.js.map +1 -0
- package/dist/components/tooltip.d.ts +17 -0
- package/dist/components/tooltip.d.ts.map +1 -0
- package/dist/components/tooltip.js +18 -0
- package/dist/components/tooltip.js.map +1 -0
- package/dist/components/version-history-panel.d.ts +71 -0
- package/dist/components/version-history-panel.d.ts.map +1 -0
- package/dist/components/version-history-panel.js +148 -0
- package/dist/components/version-history-panel.js.map +1 -0
- package/dist/download.d.ts +7 -0
- package/dist/download.d.ts.map +1 -0
- package/dist/download.js +18 -0
- package/dist/download.js.map +1 -0
- package/dist/element-slot.d.ts +4 -0
- package/dist/element-slot.d.ts.map +1 -0
- package/dist/element-slot.js +20 -0
- package/dist/element-slot.js.map +1 -0
- package/dist/elicitation/ElicitationForm.d.ts +34 -0
- package/dist/elicitation/ElicitationForm.d.ts.map +1 -0
- package/dist/elicitation/ElicitationForm.js +24 -0
- package/dist/elicitation/ElicitationForm.js.map +1 -0
- package/dist/errors.d.ts +9 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +15 -0
- package/dist/errors.js.map +1 -0
- package/dist/extension-combos.d.ts +13 -0
- package/dist/extension-combos.d.ts.map +1 -0
- package/dist/extension-combos.js +9 -0
- package/dist/extension-combos.js.map +1 -0
- package/dist/hooks/useApi.d.ts +1222 -0
- package/dist/hooks/useApi.d.ts.map +1 -0
- package/dist/hooks/useApi.js +22 -0
- package/dist/hooks/useApi.js.map +1 -0
- package/dist/hooks/useAuth.d.ts +13 -0
- package/dist/hooks/useAuth.d.ts.map +1 -0
- package/dist/hooks/useAuth.js +53 -0
- package/dist/hooks/useAuth.js.map +1 -0
- package/dist/hooks/useBreakpoint.d.ts +10 -0
- package/dist/hooks/useBreakpoint.d.ts.map +1 -0
- package/dist/hooks/useBreakpoint.js +66 -0
- package/dist/hooks/useBreakpoint.js.map +1 -0
- package/dist/hooks/useCapabilities.d.ts +88 -0
- package/dist/hooks/useCapabilities.d.ts.map +1 -0
- package/dist/hooks/useCapabilities.js +203 -0
- package/dist/hooks/useCapabilities.js.map +1 -0
- package/dist/hooks/useSse.d.ts +13 -0
- package/dist/hooks/useSse.d.ts.map +1 -0
- package/dist/hooks/useSse.js +298 -0
- package/dist/hooks/useSse.js.map +1 -0
- package/dist/hooks/useTheme.d.ts +20 -0
- package/dist/hooks/useTheme.d.ts.map +1 -0
- package/dist/hooks/useTheme.js +97 -0
- package/dist/hooks/useTheme.js.map +1 -0
- package/dist/hooks/useUnauthorized.d.ts +3 -0
- package/dist/hooks/useUnauthorized.d.ts.map +1 -0
- package/dist/hooks/useUnauthorized.js +18 -0
- package/dist/hooks/useUnauthorized.js.map +1 -0
- package/dist/host.d.ts +11 -0
- package/dist/host.d.ts.map +1 -0
- package/dist/host.js +10 -0
- package/dist/host.js.map +1 -0
- package/dist/index.d.ts +118 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +91 -0
- package/dist/index.js.map +1 -0
- package/dist/navigation/context.d.ts +25 -0
- package/dist/navigation/context.d.ts.map +1 -0
- package/dist/navigation/context.js +45 -0
- package/dist/navigation/context.js.map +1 -0
- package/dist/navigation/index.d.ts +4 -0
- package/dist/navigation/index.d.ts.map +1 -0
- package/dist/navigation/index.js +2 -0
- package/dist/navigation/index.js.map +1 -0
- package/dist/navigation/types.d.ts +97 -0
- package/dist/navigation/types.d.ts.map +1 -0
- package/dist/navigation/types.js +16 -0
- package/dist/navigation/types.js.map +1 -0
- package/dist/plugin/host-state.d.ts +45 -0
- package/dist/plugin/host-state.d.ts.map +1 -0
- package/dist/plugin/host-state.js +62 -0
- package/dist/plugin/host-state.js.map +1 -0
- package/dist/plugin/registry.d.ts +35 -0
- package/dist/plugin/registry.d.ts.map +1 -0
- package/dist/plugin/registry.js +129 -0
- package/dist/plugin/registry.js.map +1 -0
- package/dist/plugin/types.d.ts +165 -0
- package/dist/plugin/types.d.ts.map +1 -0
- package/dist/plugin/types.js +2 -0
- package/dist/plugin/types.js.map +1 -0
- package/dist/plugin/version.d.ts +34 -0
- package/dist/plugin/version.d.ts.map +1 -0
- package/dist/plugin/version.js +37 -0
- package/dist/plugin/version.js.map +1 -0
- package/dist/query-keys.d.ts +31 -0
- package/dist/query-keys.d.ts.map +1 -0
- package/dist/query-keys.js +31 -0
- package/dist/query-keys.js.map +1 -0
- package/dist/schema-editor/SchemaEditor.d.ts +43 -0
- package/dist/schema-editor/SchemaEditor.d.ts.map +1 -0
- package/dist/schema-editor/SchemaEditor.js +106 -0
- package/dist/schema-editor/SchemaEditor.js.map +1 -0
- package/dist/schema-editor/index.d.ts +10 -0
- package/dist/schema-editor/index.d.ts.map +1 -0
- package/dist/schema-editor/index.js +8 -0
- package/dist/schema-editor/index.js.map +1 -0
- package/dist/schema-editor/lint.d.ts +37 -0
- package/dist/schema-editor/lint.d.ts.map +1 -0
- package/dist/schema-editor/lint.js +49 -0
- package/dist/schema-editor/lint.js.map +1 -0
- package/dist/schema-form/SchemaForm.d.ts +70 -0
- package/dist/schema-form/SchemaForm.d.ts.map +1 -0
- package/dist/schema-form/SchemaForm.js +13 -0
- package/dist/schema-form/SchemaForm.js.map +1 -0
- package/dist/schema-form/array-field.d.ts +20 -0
- package/dist/schema-form/array-field.d.ts.map +1 -0
- package/dist/schema-form/array-field.js +39 -0
- package/dist/schema-form/array-field.js.map +1 -0
- package/dist/schema-form/classify.d.ts +87 -0
- package/dist/schema-form/classify.d.ts.map +1 -0
- package/dist/schema-form/classify.js +199 -0
- package/dist/schema-form/classify.js.map +1 -0
- package/dist/schema-form/context.d.ts +4 -0
- package/dist/schema-form/context.d.ts.map +1 -0
- package/dist/schema-form/context.js +14 -0
- package/dist/schema-form/context.js.map +1 -0
- package/dist/schema-form/default-value.d.ts +8 -0
- package/dist/schema-form/default-value.d.ts.map +1 -0
- package/dist/schema-form/default-value.js +64 -0
- package/dist/schema-form/default-value.js.map +1 -0
- package/dist/schema-form/enum-field.d.ts +19 -0
- package/dist/schema-form/enum-field.d.ts.map +1 -0
- package/dist/schema-form/enum-field.js +26 -0
- package/dist/schema-form/enum-field.js.map +1 -0
- package/dist/schema-form/field-group.d.ts +9 -0
- package/dist/schema-form/field-group.d.ts.map +1 -0
- package/dist/schema-form/field-group.js +32 -0
- package/dist/schema-form/field-group.js.map +1 -0
- package/dist/schema-form/field-node.d.ts +24 -0
- package/dist/schema-form/field-node.d.ts.map +1 -0
- package/dist/schema-form/field-node.js +51 -0
- package/dist/schema-form/field-node.js.map +1 -0
- package/dist/schema-form/index.d.ts +13 -0
- package/dist/schema-form/index.d.ts.map +1 -0
- package/dist/schema-form/index.js +11 -0
- package/dist/schema-form/index.js.map +1 -0
- package/dist/schema-form/media-field.d.ts +24 -0
- package/dist/schema-form/media-field.d.ts.map +1 -0
- package/dist/schema-form/media-field.js +169 -0
- package/dist/schema-form/media-field.js.map +1 -0
- package/dist/schema-form/media.d.ts +40 -0
- package/dist/schema-form/media.d.ts.map +1 -0
- package/dist/schema-form/media.js +65 -0
- package/dist/schema-form/media.js.map +1 -0
- package/dist/schema-form/object-fields.d.ts +20 -0
- package/dist/schema-form/object-fields.d.ts.map +1 -0
- package/dist/schema-form/object-fields.js +24 -0
- package/dist/schema-form/object-fields.js.map +1 -0
- package/dist/schema-form/resolve.d.ts +41 -0
- package/dist/schema-form/resolve.d.ts.map +1 -0
- package/dist/schema-form/resolve.js +102 -0
- package/dist/schema-form/resolve.js.map +1 -0
- package/dist/schema-form/string-field.d.ts +20 -0
- package/dist/schema-form/string-field.d.ts.map +1 -0
- package/dist/schema-form/string-field.js +68 -0
- package/dist/schema-form/string-field.js.map +1 -0
- package/dist/schema-form/styles.d.ts +18 -0
- package/dist/schema-form/styles.d.ts.map +1 -0
- package/dist/schema-form/styles.js +18 -0
- package/dist/schema-form/styles.js.map +1 -0
- package/dist/schema-form/types.d.ts +67 -0
- package/dist/schema-form/types.d.ts.map +1 -0
- package/dist/schema-form/types.js +10 -0
- package/dist/schema-form/types.js.map +1 -0
- package/dist/schema-form/union-field.d.ts +24 -0
- package/dist/schema-form/union-field.d.ts.map +1 -0
- package/dist/schema-form/union-field.js +55 -0
- package/dist/schema-form/union-field.js.map +1 -0
- package/dist/schema-form/union.d.ts +4 -0
- package/dist/schema-form/union.d.ts.map +1 -0
- package/dist/schema-form/union.js +68 -0
- package/dist/schema-form/union.js.map +1 -0
- package/dist/schema-form/unsupported-notice.d.ts +18 -0
- package/dist/schema-form/unsupported-notice.d.ts.map +1 -0
- package/dist/schema-form/unsupported-notice.js +8 -0
- package/dist/schema-form/unsupported-notice.js.map +1 -0
- package/dist/schema-form/validate.d.ts +18 -0
- package/dist/schema-form/validate.d.ts.map +1 -0
- package/dist/schema-form/validate.js +162 -0
- package/dist/schema-form/validate.js.map +1 -0
- package/dist/structured-output/StructuredOutput.d.ts +27 -0
- package/dist/structured-output/StructuredOutput.d.ts.map +1 -0
- package/dist/structured-output/StructuredOutput.js +41 -0
- package/dist/structured-output/StructuredOutput.js.map +1 -0
- package/dist/testing.d.ts +80 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +207 -0
- package/dist/testing.js.map +1 -0
- package/package.json +101 -0
- package/src/components/badge.tsx +31 -0
- package/src/components/checkbox.tsx +93 -0
- package/src/components/code-block.tsx +37 -0
- package/src/components/completion-input.tsx +137 -0
- package/src/components/components.css +2212 -0
- package/src/components/confirm-dialog.tsx +77 -0
- package/src/components/control-styles.ts +14 -0
- package/src/components/copy-field.tsx +178 -0
- package/src/components/dialog.tsx +76 -0
- package/src/components/drawer.tsx +83 -0
- package/src/components/error-boundary.tsx +56 -0
- package/src/components/extension-combo-builder.tsx +305 -0
- package/src/components/extension-grouping.ts +116 -0
- package/src/components/extension-picker.tsx +97 -0
- package/src/components/external-link.tsx +40 -0
- package/src/components/field.tsx +169 -0
- package/src/components/fleet-report.tsx +136 -0
- package/src/components/fonts.css +22 -0
- package/src/components/icons.tsx +504 -0
- package/src/components/inputs.tsx +125 -0
- package/src/components/json-diff.tsx +192 -0
- package/src/components/json-tree.tsx +129 -0
- package/src/components/modal-focus.ts +150 -0
- package/src/components/page-header.tsx +107 -0
- package/src/components/primitives.tsx +489 -0
- package/src/components/progress-bar.tsx +100 -0
- package/src/components/radio-group.tsx +160 -0
- package/src/components/reveal-input.tsx +87 -0
- package/src/components/scroll-region.tsx +703 -0
- package/src/components/select.tsx +149 -0
- package/src/components/table.tsx +94 -0
- package/src/components/tabs.tsx +51 -0
- package/src/components/tags.tsx +137 -0
- package/src/components/tokens.css +392 -0
- package/src/components/tokens.ts +102 -0
- package/src/components/tool-picker.tsx +175 -0
- package/src/components/tooltip.tsx +46 -0
- package/src/components/version-history-panel.tsx +407 -0
- package/src/css.d.ts +2 -0
- package/src/download.ts +17 -0
- package/src/element-slot.ts +22 -0
- package/src/elicitation/ElicitationForm.tsx +87 -0
- package/src/errors.ts +12 -0
- package/src/extension-combos.ts +18 -0
- package/src/hooks/useApi.ts +27 -0
- package/src/hooks/useAuth.ts +67 -0
- package/src/hooks/useBreakpoint.ts +78 -0
- package/src/hooks/useCapabilities.ts +242 -0
- package/src/hooks/useSse.ts +314 -0
- package/src/hooks/useTheme.ts +133 -0
- package/src/hooks/useUnauthorized.ts +20 -0
- package/src/host.ts +15 -0
- package/src/index.ts +267 -0
- package/src/navigation/context.tsx +90 -0
- package/src/navigation/index.ts +9 -0
- package/src/navigation/types.ts +90 -0
- package/src/plugin/host-state.ts +93 -0
- package/src/plugin/registry.ts +174 -0
- package/src/plugin/types.ts +178 -0
- package/src/plugin/version.ts +44 -0
- package/src/query-keys.ts +34 -0
- package/src/schema-editor/SchemaEditor.tsx +186 -0
- package/src/schema-editor/index.ts +9 -0
- package/src/schema-editor/lint.ts +70 -0
- package/src/schema-form/SchemaForm.tsx +107 -0
- package/src/schema-form/array-field.tsx +110 -0
- package/src/schema-form/classify.ts +302 -0
- package/src/schema-form/context.ts +17 -0
- package/src/schema-form/default-value.ts +65 -0
- package/src/schema-form/enum-field.tsx +65 -0
- package/src/schema-form/field-group.tsx +71 -0
- package/src/schema-form/field-node.tsx +161 -0
- package/src/schema-form/index.ts +12 -0
- package/src/schema-form/media-field.tsx +281 -0
- package/src/schema-form/media.ts +69 -0
- package/src/schema-form/object-fields.tsx +74 -0
- package/src/schema-form/resolve.ts +114 -0
- package/src/schema-form/string-field.tsx +161 -0
- package/src/schema-form/styles.ts +20 -0
- package/src/schema-form/types.ts +71 -0
- package/src/schema-form/union-field.tsx +122 -0
- package/src/schema-form/union.ts +78 -0
- package/src/schema-form/unsupported-notice.tsx +39 -0
- package/src/schema-form/validate.ts +183 -0
- package/src/structured-output/StructuredOutput.tsx +81 -0
- package/src/testing.ts +235 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `Badge` — a small tinted label. `variant` is a free string (extension "kind"
|
|
3
|
+
* values map straight to it); known variants get a themed tint plus its
|
|
4
|
+
* matching text color from the design-system classes, and any other value falls
|
|
5
|
+
* back to the neutral tint.
|
|
6
|
+
*/
|
|
7
|
+
import type { ReactNode } from 'react';
|
|
8
|
+
|
|
9
|
+
export interface BadgeProps {
|
|
10
|
+
readonly variant?: string;
|
|
11
|
+
readonly children: ReactNode;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const NEUTRAL_CLASS = 'tai-badge tai-badge-neutral';
|
|
15
|
+
|
|
16
|
+
/** `primary` is the base badge: the accent tint needs no modifier class. */
|
|
17
|
+
const VARIANT_CLASS: Record<string, string> = {
|
|
18
|
+
neutral: NEUTRAL_CLASS,
|
|
19
|
+
primary: 'tai-badge',
|
|
20
|
+
success: 'tai-badge tai-badge-ok',
|
|
21
|
+
warning: 'tai-badge tai-badge-warn',
|
|
22
|
+
danger: 'tai-badge tai-badge-err',
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export function Badge({ variant = 'neutral', children }: BadgeProps) {
|
|
26
|
+
return (
|
|
27
|
+
<span data-variant={variant} className={VARIANT_CLASS[variant] ?? NEUTRAL_CLASS}>
|
|
28
|
+
{children}
|
|
29
|
+
</span>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `Checkbox` — a design-system wrapper over Radix Checkbox (role `checkbox`). An
|
|
3
|
+
* optional inline `label` renders a linked `<label>` so clicking the text toggles
|
|
4
|
+
* the box (buttons are labelable). When the box carries no visible label (a
|
|
5
|
+
* selection column in a table), pass `aria-label` so it still has an accessible
|
|
6
|
+
* name. Inside a `Field` the box picks up the field id + a11y wiring instead.
|
|
7
|
+
*
|
|
8
|
+
* Appearance is the `tai-checkbox` class: Radix stamps `data-state` on the root,
|
|
9
|
+
* and the stylesheet paints the checked and indeterminate grounds from it, so the
|
|
10
|
+
* mark shows for a controlled AND an uncontrolled box alike. The two filled
|
|
11
|
+
* states share that ground, so the MARK is what tells them apart: `CheckIcon` for
|
|
12
|
+
* checked, `MinusIcon` for indeterminate, both decorative behind the control's
|
|
13
|
+
* own name.
|
|
14
|
+
*/
|
|
15
|
+
import * as RadixCheckbox from '@radix-ui/react-checkbox';
|
|
16
|
+
import { useId } from 'react';
|
|
17
|
+
|
|
18
|
+
import { useFieldControl } from './field';
|
|
19
|
+
import { CheckIcon, MinusIcon } from './icons';
|
|
20
|
+
|
|
21
|
+
export interface CheckboxProps {
|
|
22
|
+
/**
|
|
23
|
+
* `'indeterminate'` is the MIXED state a parent box wears while only some of
|
|
24
|
+
* the children it governs are checked. Radix reports it as
|
|
25
|
+
* `aria-checked="mixed"`; clicking it resolves to checked, which is why the
|
|
26
|
+
* change callback stays boolean.
|
|
27
|
+
*/
|
|
28
|
+
readonly checked?: boolean | 'indeterminate';
|
|
29
|
+
readonly defaultChecked?: boolean;
|
|
30
|
+
readonly onCheckedChange?: (checked: boolean) => void;
|
|
31
|
+
readonly disabled?: boolean;
|
|
32
|
+
readonly label?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Accessible name for a checkbox with no visible `label` (e.g. a table cell).
|
|
35
|
+
* An enclosing `Field` wins where both are given — it names the box from
|
|
36
|
+
* visible text, and `aria-label` would override that native label and leave
|
|
37
|
+
* the visible text out of the accessible name (WCAG 2.5.3).
|
|
38
|
+
*/
|
|
39
|
+
readonly 'aria-label'?: string;
|
|
40
|
+
readonly name?: string;
|
|
41
|
+
readonly value?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function Checkbox({
|
|
45
|
+
checked,
|
|
46
|
+
defaultChecked,
|
|
47
|
+
onCheckedChange,
|
|
48
|
+
disabled,
|
|
49
|
+
label,
|
|
50
|
+
'aria-label': ariaLabel,
|
|
51
|
+
name,
|
|
52
|
+
value,
|
|
53
|
+
}: CheckboxProps) {
|
|
54
|
+
const field = useFieldControl();
|
|
55
|
+
const generatedId = useId();
|
|
56
|
+
const id = field.id ?? generatedId;
|
|
57
|
+
|
|
58
|
+
const box = (
|
|
59
|
+
<RadixCheckbox.Root
|
|
60
|
+
id={id}
|
|
61
|
+
className="tai-checkbox"
|
|
62
|
+
// The caller's name is the FALLBACK. A box named by an inline `label` or
|
|
63
|
+
// by an enclosing `Field` is named from visible text, and `aria-label`
|
|
64
|
+
// outranks a native `<label for>` — emitting both would discard that text.
|
|
65
|
+
aria-label={field.id === undefined && label === undefined ? ariaLabel : undefined}
|
|
66
|
+
aria-describedby={field['aria-describedby']}
|
|
67
|
+
aria-invalid={field['aria-invalid']}
|
|
68
|
+
checked={checked}
|
|
69
|
+
defaultChecked={defaultChecked}
|
|
70
|
+
onCheckedChange={(next) => {
|
|
71
|
+
onCheckedChange?.(next === true);
|
|
72
|
+
}}
|
|
73
|
+
disabled={disabled}
|
|
74
|
+
name={name}
|
|
75
|
+
value={value}
|
|
76
|
+
>
|
|
77
|
+
{/* The indicator only ever holds the mark, so it is a bare flex box. The
|
|
78
|
+
checked and indeterminate grounds are the same accent fill, so a shared
|
|
79
|
+
mark would make the two states indistinguishable. */}
|
|
80
|
+
<RadixCheckbox.Indicator aria-hidden="true" style={{ display: 'flex' }}>
|
|
81
|
+
{checked === 'indeterminate' ? <MinusIcon /> : <CheckIcon />}
|
|
82
|
+
</RadixCheckbox.Indicator>
|
|
83
|
+
</RadixCheckbox.Root>
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
if (label === undefined) return box;
|
|
87
|
+
return (
|
|
88
|
+
<label htmlFor={id} className="tai-choice">
|
|
89
|
+
{box}
|
|
90
|
+
<span>{label}</span>
|
|
91
|
+
</label>
|
|
92
|
+
);
|
|
93
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `CodeBlock` — escaped, monospaced preformatted text for tool results and string
|
|
3
|
+
* payloads, on the design system's terminal ground (`tai-code-block`). The content
|
|
4
|
+
* is a React text child inside `<pre><code>`, so it is escaped by React and
|
|
5
|
+
* rendered verbatim; this component is NEVER an HTML sink (no
|
|
6
|
+
* `dangerouslySetInnerHTML`).
|
|
7
|
+
*
|
|
8
|
+
* The `<pre>` IS the scrolling box, so it carries the region attributes itself
|
|
9
|
+
* rather than sitting inside a `ScrollRegion` wrapper that would add a second
|
|
10
|
+
* scroller: a long line makes it a named keyboard target, a short one leaves it
|
|
11
|
+
* an ordinary block.
|
|
12
|
+
*/
|
|
13
|
+
import { useOverflowRegion } from './scroll-region';
|
|
14
|
+
|
|
15
|
+
export interface CodeBlockProps {
|
|
16
|
+
readonly code: string;
|
|
17
|
+
/** Optional language label, shown as a caption; purely informational. */
|
|
18
|
+
readonly language?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** The region's name when no language caption supplies one. */
|
|
22
|
+
const DEFAULT_LABEL = 'Code';
|
|
23
|
+
|
|
24
|
+
export function CodeBlock({ code, language }: CodeBlockProps) {
|
|
25
|
+
// No consumer ref: the measurement's own callback ref is the only thing that
|
|
26
|
+
// needs the `<pre>`, and this component publishes no `ref` prop.
|
|
27
|
+
const region = useOverflowRegion(undefined, language ?? DEFAULT_LABEL);
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<div className="tai-stack tai-stack-2">
|
|
31
|
+
{language !== undefined ? <span className="tai-label">{language}</span> : null}
|
|
32
|
+
<pre className="tai-code-block" {...region}>
|
|
33
|
+
<code>{code}</code>
|
|
34
|
+
</pre>
|
|
35
|
+
</div>
|
|
36
|
+
);
|
|
37
|
+
}
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `CompletionInput` — a text field wired to MCP `completion/complete`. As the
|
|
3
|
+
* human types, it asks the provided `fetchCompletions` (a thin wrapper over the
|
|
4
|
+
* MCP completions capability) for argument suggestions and renders them as a
|
|
5
|
+
* selectable list; picking one fills the field. A fetch failure clears the
|
|
6
|
+
* suggestions and surfaces through `onError` — never a silent swallow.
|
|
7
|
+
*
|
|
8
|
+
* The field is a `tai-input` and its popup wears the Select popup's classes
|
|
9
|
+
* (`tai-select-content` / `tai-select-item`), so a suggestion list and a select
|
|
10
|
+
* list are the same object to a reader.
|
|
11
|
+
*
|
|
12
|
+
* Reusable by any feature; the intended consumer is a `SchemaForm` string field
|
|
13
|
+
* that has a completion provider for its tool/prompt/resource argument.
|
|
14
|
+
*/
|
|
15
|
+
import type { CSSProperties, ReactNode } from 'react';
|
|
16
|
+
import { useEffect, useId, useRef, useState } from 'react';
|
|
17
|
+
|
|
18
|
+
import { useFieldControl } from './field';
|
|
19
|
+
|
|
20
|
+
export interface CompletionInputProps {
|
|
21
|
+
readonly value: string;
|
|
22
|
+
readonly onChange: (value: string) => void;
|
|
23
|
+
/** Fetch argument completions for the current input value. */
|
|
24
|
+
readonly fetchCompletions: (value: string) => Promise<readonly string[]>;
|
|
25
|
+
/** Surfaced (not swallowed) when a completion fetch fails. */
|
|
26
|
+
readonly onError?: (error: unknown) => void;
|
|
27
|
+
readonly placeholder?: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const wrapStyle: CSSProperties = { position: 'relative' };
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* The popup sits directly under the field rather than against its top edge. It
|
|
34
|
+
* is a `<ul>`, so it also drops the marker a host without a CSS reset would draw.
|
|
35
|
+
*/
|
|
36
|
+
const listStyle: CSSProperties = {
|
|
37
|
+
marginTop: 'var(--tai-space-1)',
|
|
38
|
+
marginBottom: 0,
|
|
39
|
+
listStyle: 'none',
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* A completion-backed text input. Suggestions refresh on every edit (a
|
|
44
|
+
* per-request sequence guard drops a stale response) and render as an ARIA
|
|
45
|
+
* listbox; selecting an option fills the field and clears the list.
|
|
46
|
+
*/
|
|
47
|
+
export function CompletionInput({
|
|
48
|
+
value,
|
|
49
|
+
onChange,
|
|
50
|
+
fetchCompletions,
|
|
51
|
+
onError,
|
|
52
|
+
placeholder,
|
|
53
|
+
}: CompletionInputProps): ReactNode {
|
|
54
|
+
const field = useFieldControl();
|
|
55
|
+
const listboxId = useId();
|
|
56
|
+
const [suggestions, setSuggestions] = useState<readonly string[]>([]);
|
|
57
|
+
// The list is only shown while the human is typing. Selecting an option (a
|
|
58
|
+
// programmatic value change) closes it until the next keystroke, so the field
|
|
59
|
+
// does not immediately re-suggest against the value it just accepted.
|
|
60
|
+
const [open, setOpen] = useState(false);
|
|
61
|
+
const seq = useRef(0);
|
|
62
|
+
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
const requestId = ++seq.current;
|
|
65
|
+
let cancelled = false;
|
|
66
|
+
fetchCompletions(value)
|
|
67
|
+
.then((values) => {
|
|
68
|
+
// Drop a stale response so a slow earlier request cannot overwrite a
|
|
69
|
+
// newer one's suggestions.
|
|
70
|
+
if (!cancelled && requestId === seq.current) setSuggestions(values);
|
|
71
|
+
})
|
|
72
|
+
.catch((error: unknown) => {
|
|
73
|
+
if (cancelled || requestId !== seq.current) return;
|
|
74
|
+
setSuggestions([]);
|
|
75
|
+
onError?.(error);
|
|
76
|
+
});
|
|
77
|
+
return () => {
|
|
78
|
+
cancelled = true;
|
|
79
|
+
};
|
|
80
|
+
}, [value, fetchCompletions, onError]);
|
|
81
|
+
|
|
82
|
+
const select = (suggestion: string) => {
|
|
83
|
+
setOpen(false);
|
|
84
|
+
setSuggestions([]);
|
|
85
|
+
onChange(suggestion);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const showList = open && suggestions.length > 0;
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<div style={wrapStyle}>
|
|
92
|
+
<input
|
|
93
|
+
{...field}
|
|
94
|
+
className="tai-input"
|
|
95
|
+
type="text"
|
|
96
|
+
role="combobox"
|
|
97
|
+
aria-expanded={showList}
|
|
98
|
+
aria-controls={listboxId}
|
|
99
|
+
aria-autocomplete="list"
|
|
100
|
+
value={value}
|
|
101
|
+
placeholder={placeholder}
|
|
102
|
+
onChange={(event) => {
|
|
103
|
+
setOpen(true);
|
|
104
|
+
onChange(event.target.value);
|
|
105
|
+
}}
|
|
106
|
+
/>
|
|
107
|
+
{/* `tai-select-viewport` carries the inset that gives an option's focus ring
|
|
108
|
+
room. This popup is its own clip box — it has no Radix viewport to put
|
|
109
|
+
the class on — so it wears both, or preflight's `* { padding: 0 }` zeroes
|
|
110
|
+
the inset and clips every ring. */}
|
|
111
|
+
{showList && (
|
|
112
|
+
<ul
|
|
113
|
+
id={listboxId}
|
|
114
|
+
role="listbox"
|
|
115
|
+
className="tai-select-content tai-select-viewport"
|
|
116
|
+
style={listStyle}
|
|
117
|
+
>
|
|
118
|
+
{suggestions.map((suggestion) => (
|
|
119
|
+
<li key={suggestion} role="presentation">
|
|
120
|
+
<button
|
|
121
|
+
type="button"
|
|
122
|
+
role="option"
|
|
123
|
+
aria-selected={false}
|
|
124
|
+
className="tai-select-item"
|
|
125
|
+
onClick={() => {
|
|
126
|
+
select(suggestion);
|
|
127
|
+
}}
|
|
128
|
+
>
|
|
129
|
+
{suggestion}
|
|
130
|
+
</button>
|
|
131
|
+
</li>
|
|
132
|
+
))}
|
|
133
|
+
</ul>
|
|
134
|
+
)}
|
|
135
|
+
</div>
|
|
136
|
+
);
|
|
137
|
+
}
|