@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,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `RadioGroup` — a design-system wrapper over Radix RadioGroup (role `radiogroup`
|
|
3
|
+
* with `radio` items), in two shapes.
|
|
4
|
+
*
|
|
5
|
+
* `list` (the default) renders one row per option: a dot indicator inside a
|
|
6
|
+
* linked `<label>`, so the option text is the radio's accessible name.
|
|
7
|
+
* `segmented` renders each option AS a segment — the Radix item itself is the
|
|
8
|
+
* control, carrying its icon and its label with no dot — which is the shape a
|
|
9
|
+
* compact single-choice control (a light / dark / system switcher) needs.
|
|
10
|
+
*
|
|
11
|
+
* The group takes its accessible name from a `label` it renders itself or from
|
|
12
|
+
* `aria-label`. It does NOT read one from an enclosing `Field`: a group `Field`
|
|
13
|
+
* renders its own named `role="group"` container around this component, so the
|
|
14
|
+
* name lives one level up and this component would otherwise duplicate it. A
|
|
15
|
+
* `Field` WITHOUT `group` around a RadioGroup is a mistake — the field's
|
|
16
|
+
* `<label for>` dangles at an id no element carries and neither element ends up
|
|
17
|
+
* named — and `field-group.test.ts` fails the build on it.
|
|
18
|
+
*
|
|
19
|
+
* Roving tabindex and arrow-key movement belong to Radix; this component only
|
|
20
|
+
* chooses the layout that matches `orientation` and passes the prop straight
|
|
21
|
+
* through, so a caller that names no orientation keeps Radix's both-axes default
|
|
22
|
+
* rather than being pinned to one.
|
|
23
|
+
*/
|
|
24
|
+
import * as RadixRadioGroup from '@radix-ui/react-radio-group';
|
|
25
|
+
import { useId } from 'react';
|
|
26
|
+
import type { ReactNode } from 'react';
|
|
27
|
+
|
|
28
|
+
import { useFieldControl } from './field';
|
|
29
|
+
|
|
30
|
+
export interface RadioOption {
|
|
31
|
+
readonly value: string;
|
|
32
|
+
readonly label: string;
|
|
33
|
+
readonly disabled?: boolean;
|
|
34
|
+
/** Mark rendered alongside the label. Decorative — the label carries the name. */
|
|
35
|
+
readonly icon?: ReactNode;
|
|
36
|
+
/** Render the label for screen readers only; it stays the option's accessible name. */
|
|
37
|
+
readonly visuallyHiddenLabel?: boolean;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface RadioGroupProps {
|
|
41
|
+
readonly options: readonly RadioOption[];
|
|
42
|
+
readonly value?: string;
|
|
43
|
+
readonly defaultValue?: string;
|
|
44
|
+
readonly onValueChange?: (value: string) => void;
|
|
45
|
+
readonly disabled?: boolean;
|
|
46
|
+
readonly name?: string;
|
|
47
|
+
/** Visible group label, rendered above the options and wired as the group's name. */
|
|
48
|
+
readonly label?: string;
|
|
49
|
+
/**
|
|
50
|
+
* Accessible group name when `label` supplies none. `label` wins where both are
|
|
51
|
+
* given — it names the group from visible text, and emitting both would leave
|
|
52
|
+
* this string computed by nothing.
|
|
53
|
+
*/
|
|
54
|
+
readonly 'aria-label'?: string;
|
|
55
|
+
/**
|
|
56
|
+
* Layout, and — when given — the arrow-key axis. Omitted, the options stack
|
|
57
|
+
* and BOTH axes move between them, which is what Radix does with no
|
|
58
|
+
* orientation and what every caller that never passed one already had. Pass a
|
|
59
|
+
* value only to pin the axis as well.
|
|
60
|
+
*/
|
|
61
|
+
readonly orientation?: 'horizontal' | 'vertical';
|
|
62
|
+
/** `list` is a stack of labelled radios; `segmented` is a compact segment strip. */
|
|
63
|
+
readonly variant?: 'list' | 'segmented';
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** The option's name text, hidden from sight but not from assistive tech on request. */
|
|
67
|
+
function OptionLabel({ option }: { readonly option: RadioOption }): ReactNode {
|
|
68
|
+
return (
|
|
69
|
+
<span className={option.visuallyHiddenLabel === true ? 'tai-visually-hidden' : undefined}>
|
|
70
|
+
{option.label}
|
|
71
|
+
</span>
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function RadioGroup({
|
|
76
|
+
options,
|
|
77
|
+
value,
|
|
78
|
+
defaultValue,
|
|
79
|
+
onValueChange,
|
|
80
|
+
disabled,
|
|
81
|
+
name,
|
|
82
|
+
label,
|
|
83
|
+
'aria-label': ariaLabel,
|
|
84
|
+
orientation,
|
|
85
|
+
variant = 'list',
|
|
86
|
+
}: RadioGroupProps) {
|
|
87
|
+
const field = useFieldControl();
|
|
88
|
+
const baseId = useId();
|
|
89
|
+
const ownLabelId = `${baseId}-label`;
|
|
90
|
+
// `label` is the STANDALONE fallback name. Inside a group `Field`, the Field
|
|
91
|
+
// renders the named `role="group"` container itself, so this component neither
|
|
92
|
+
// knows nor needs the field's label id — the group is named by construction.
|
|
93
|
+
const labelledBy = label === undefined ? undefined : ownLabelId;
|
|
94
|
+
|
|
95
|
+
const rootClassName =
|
|
96
|
+
variant === 'segmented'
|
|
97
|
+
? 'tai-segmented'
|
|
98
|
+
: orientation === 'horizontal'
|
|
99
|
+
? 'tai-row'
|
|
100
|
+
: 'tai-stack tai-stack-2';
|
|
101
|
+
|
|
102
|
+
const group = (
|
|
103
|
+
<RadixRadioGroup.Root
|
|
104
|
+
className={rootClassName}
|
|
105
|
+
aria-labelledby={labelledBy}
|
|
106
|
+
// The accessible-name computation takes `aria-labelledby` over `aria-label`,
|
|
107
|
+
// so emitting both would ship a caller string that nothing ever reads.
|
|
108
|
+
aria-label={labelledBy === undefined ? ariaLabel : undefined}
|
|
109
|
+
aria-describedby={field['aria-describedby']}
|
|
110
|
+
aria-invalid={field['aria-invalid']}
|
|
111
|
+
value={value}
|
|
112
|
+
defaultValue={defaultValue}
|
|
113
|
+
onValueChange={onValueChange}
|
|
114
|
+
disabled={disabled}
|
|
115
|
+
name={name}
|
|
116
|
+
orientation={orientation}
|
|
117
|
+
>
|
|
118
|
+
{options.map((option) => {
|
|
119
|
+
if (variant === 'segmented') {
|
|
120
|
+
return (
|
|
121
|
+
<RadixRadioGroup.Item
|
|
122
|
+
key={option.value}
|
|
123
|
+
className="tai-segment"
|
|
124
|
+
value={option.value}
|
|
125
|
+
disabled={option.disabled}
|
|
126
|
+
>
|
|
127
|
+
{option.icon}
|
|
128
|
+
<OptionLabel option={option} />
|
|
129
|
+
</RadixRadioGroup.Item>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
const itemId = `${baseId}-${option.value}`;
|
|
133
|
+
return (
|
|
134
|
+
<label key={option.value} htmlFor={itemId} className="tai-choice">
|
|
135
|
+
<RadixRadioGroup.Item
|
|
136
|
+
id={itemId}
|
|
137
|
+
className="tai-radio"
|
|
138
|
+
value={option.value}
|
|
139
|
+
disabled={option.disabled}
|
|
140
|
+
>
|
|
141
|
+
<RadixRadioGroup.Indicator className="tai-radio-indicator" />
|
|
142
|
+
</RadixRadioGroup.Item>
|
|
143
|
+
{option.icon}
|
|
144
|
+
<OptionLabel option={option} />
|
|
145
|
+
</label>
|
|
146
|
+
);
|
|
147
|
+
})}
|
|
148
|
+
</RadixRadioGroup.Root>
|
|
149
|
+
);
|
|
150
|
+
|
|
151
|
+
if (label === undefined) return group;
|
|
152
|
+
return (
|
|
153
|
+
<div className="tai-stack tai-stack-2">
|
|
154
|
+
<span id={ownLabelId} className="tai-field-label">
|
|
155
|
+
{label}
|
|
156
|
+
</span>
|
|
157
|
+
{group}
|
|
158
|
+
</div>
|
|
159
|
+
);
|
|
160
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `RevealInput` — a controlled text input whose value is MASKED by default with a
|
|
3
|
+
* reveal-on-click eye toggle. The masking is native (`type="password"` when
|
|
4
|
+
* hidden, `type="text"` when revealed) so editing never corrupts the value; it is
|
|
5
|
+
* purely visual — the real value always lives in the input's `value`. When
|
|
6
|
+
* `onChange` is omitted or `readOnly` is set the field is read-only but still
|
|
7
|
+
* revealable. The value is never logged.
|
|
8
|
+
*
|
|
9
|
+
* The field is a `tai-input` and the toggle a `tai-icon-btn` whose accessible name
|
|
10
|
+
* ("Show value" / "Hide value") states the action; the eye mark itself is
|
|
11
|
+
* decorative.
|
|
12
|
+
*/
|
|
13
|
+
import { useState } from 'react';
|
|
14
|
+
|
|
15
|
+
import { Field } from './field';
|
|
16
|
+
import { EyeIcon, EyeOffIcon } from './icons';
|
|
17
|
+
import { TextInput } from './inputs';
|
|
18
|
+
|
|
19
|
+
export interface RevealInputProps {
|
|
20
|
+
readonly value: string;
|
|
21
|
+
readonly onChange?: (value: string) => void;
|
|
22
|
+
readonly readOnly?: boolean;
|
|
23
|
+
readonly disabled?: boolean;
|
|
24
|
+
readonly idPrefix?: string;
|
|
25
|
+
readonly label?: string;
|
|
26
|
+
readonly placeholder?: string;
|
|
27
|
+
/** Accessible name for the inner input when no visual `label` is rendered. */
|
|
28
|
+
readonly 'aria-label'?: string;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function RevealInput({
|
|
32
|
+
value,
|
|
33
|
+
onChange,
|
|
34
|
+
readOnly,
|
|
35
|
+
disabled,
|
|
36
|
+
idPrefix = 'reveal-input',
|
|
37
|
+
label,
|
|
38
|
+
placeholder,
|
|
39
|
+
'aria-label': ariaLabel,
|
|
40
|
+
}: RevealInputProps) {
|
|
41
|
+
const [revealed, setRevealed] = useState(false);
|
|
42
|
+
const isReadOnly = readOnly === true || onChange === undefined;
|
|
43
|
+
const toggleLabel = revealed ? 'Hide value' : 'Show value';
|
|
44
|
+
|
|
45
|
+
const control = (
|
|
46
|
+
<div className="tai-row">
|
|
47
|
+
{/* The field takes the row; the toggle keeps its square icon-button size. */}
|
|
48
|
+
<div style={{ flex: 1 }}>
|
|
49
|
+
<TextInput
|
|
50
|
+
type={revealed ? 'text' : 'password'}
|
|
51
|
+
aria-label={ariaLabel}
|
|
52
|
+
value={value}
|
|
53
|
+
onChange={
|
|
54
|
+
isReadOnly
|
|
55
|
+
? undefined
|
|
56
|
+
: (event) => {
|
|
57
|
+
onChange(event.target.value);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
readOnly={isReadOnly}
|
|
61
|
+
disabled={disabled}
|
|
62
|
+
placeholder={placeholder}
|
|
63
|
+
autoComplete="off"
|
|
64
|
+
spellCheck={false}
|
|
65
|
+
/>
|
|
66
|
+
</div>
|
|
67
|
+
<button
|
|
68
|
+
type="button"
|
|
69
|
+
className="tai-icon-btn"
|
|
70
|
+
aria-label={toggleLabel}
|
|
71
|
+
data-testid={`${idPrefix}-toggle`}
|
|
72
|
+
disabled={disabled}
|
|
73
|
+
onClick={() => {
|
|
74
|
+
setRevealed((prev) => !prev);
|
|
75
|
+
}}
|
|
76
|
+
>
|
|
77
|
+
{revealed ? <EyeOffIcon /> : <EyeIcon />}
|
|
78
|
+
</button>
|
|
79
|
+
</div>
|
|
80
|
+
);
|
|
81
|
+
|
|
82
|
+
return (
|
|
83
|
+
<div data-testid={idPrefix}>
|
|
84
|
+
{label !== undefined ? <Field label={label}>{control}</Field> : control}
|
|
85
|
+
</div>
|
|
86
|
+
);
|
|
87
|
+
}
|