@dowel-ui/react 0.1.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 +21 -0
- package/dist/blocks/admin-users/meta.js +27 -0
- package/dist/blocks/admin-users/meta.js.map +1 -0
- package/dist/blocks/ai-chat/meta.js +30 -0
- package/dist/blocks/ai-chat/meta.js.map +1 -0
- package/dist/blocks/dashboard/meta.js +23 -0
- package/dist/blocks/dashboard/meta.js.map +1 -0
- package/dist/blocks/forgot-password/meta.js +24 -0
- package/dist/blocks/forgot-password/meta.js.map +1 -0
- package/dist/blocks/login/meta.js +26 -0
- package/dist/blocks/login/meta.js.map +1 -0
- package/dist/blocks/pricing/meta.js +24 -0
- package/dist/blocks/pricing/meta.js.map +1 -0
- package/dist/blocks/settings/meta.js +29 -0
- package/dist/blocks/settings/meta.js.map +1 -0
- package/dist/blocks/signup/meta.js +25 -0
- package/dist/blocks/signup/meta.js.map +1 -0
- package/dist/components/accordion/accordion.d.ts +19 -0
- package/dist/components/accordion/accordion.d.ts.map +1 -0
- package/dist/components/accordion/accordion.js +58 -0
- package/dist/components/accordion/accordion.js.map +1 -0
- package/dist/components/accordion/index.d.ts +2 -0
- package/dist/components/accordion/index.js +2 -0
- package/dist/components/accordion/meta.js +17 -0
- package/dist/components/accordion/meta.js.map +1 -0
- package/dist/components/activity-feed/activity-feed.d.ts +39 -0
- package/dist/components/activity-feed/activity-feed.d.ts.map +1 -0
- package/dist/components/activity-feed/activity-feed.js +77 -0
- package/dist/components/activity-feed/activity-feed.js.map +1 -0
- package/dist/components/activity-feed/index.d.ts +2 -0
- package/dist/components/activity-feed/index.js +2 -0
- package/dist/components/activity-feed/meta.js +17 -0
- package/dist/components/activity-feed/meta.js.map +1 -0
- package/dist/components/ai-agent-status/ai-agent-status.d.ts +30 -0
- package/dist/components/ai-agent-status/ai-agent-status.d.ts.map +1 -0
- package/dist/components/ai-agent-status/ai-agent-status.js +43 -0
- package/dist/components/ai-agent-status/ai-agent-status.js.map +1 -0
- package/dist/components/ai-agent-status/index.d.ts +2 -0
- package/dist/components/ai-agent-status/index.js +2 -0
- package/dist/components/ai-agent-status/meta.js +17 -0
- package/dist/components/ai-agent-status/meta.js.map +1 -0
- package/dist/components/ai-conversation/ai-conversation.d.ts +45 -0
- package/dist/components/ai-conversation/ai-conversation.d.ts.map +1 -0
- package/dist/components/ai-conversation/ai-conversation.js +138 -0
- package/dist/components/ai-conversation/ai-conversation.js.map +1 -0
- package/dist/components/ai-conversation/index.d.ts +2 -0
- package/dist/components/ai-conversation/index.js +2 -0
- package/dist/components/ai-conversation/meta.js +17 -0
- package/dist/components/ai-conversation/meta.js.map +1 -0
- package/dist/components/ai-message/ai-message.d.ts +56 -0
- package/dist/components/ai-message/ai-message.d.ts.map +1 -0
- package/dist/components/ai-message/ai-message.js +90 -0
- package/dist/components/ai-message/ai-message.js.map +1 -0
- package/dist/components/ai-message/index.d.ts +2 -0
- package/dist/components/ai-message/index.js +2 -0
- package/dist/components/ai-message/meta.js +17 -0
- package/dist/components/ai-message/meta.js.map +1 -0
- package/dist/components/ai-model-selector/ai-model-selector.d.ts +42 -0
- package/dist/components/ai-model-selector/ai-model-selector.d.ts.map +1 -0
- package/dist/components/ai-model-selector/ai-model-selector.js +48 -0
- package/dist/components/ai-model-selector/ai-model-selector.js.map +1 -0
- package/dist/components/ai-model-selector/index.d.ts +2 -0
- package/dist/components/ai-model-selector/index.js +2 -0
- package/dist/components/ai-model-selector/meta.js +17 -0
- package/dist/components/ai-model-selector/meta.js.map +1 -0
- package/dist/components/ai-prompt-input/ai-prompt-input.d.ts +61 -0
- package/dist/components/ai-prompt-input/ai-prompt-input.d.ts.map +1 -0
- package/dist/components/ai-prompt-input/ai-prompt-input.js +170 -0
- package/dist/components/ai-prompt-input/ai-prompt-input.js.map +1 -0
- package/dist/components/ai-prompt-input/index.d.ts +2 -0
- package/dist/components/ai-prompt-input/index.js +2 -0
- package/dist/components/ai-prompt-input/meta.js +17 -0
- package/dist/components/ai-prompt-input/meta.js.map +1 -0
- package/dist/components/ai-reasoning/ai-reasoning.d.ts +24 -0
- package/dist/components/ai-reasoning/ai-reasoning.d.ts.map +1 -0
- package/dist/components/ai-reasoning/ai-reasoning.js +64 -0
- package/dist/components/ai-reasoning/ai-reasoning.js.map +1 -0
- package/dist/components/ai-reasoning/index.d.ts +2 -0
- package/dist/components/ai-reasoning/index.js +2 -0
- package/dist/components/ai-reasoning/meta.js +17 -0
- package/dist/components/ai-reasoning/meta.js.map +1 -0
- package/dist/components/ai-response/ai-response.d.ts +36 -0
- package/dist/components/ai-response/ai-response.d.ts.map +1 -0
- package/dist/components/ai-response/ai-response.js +46 -0
- package/dist/components/ai-response/ai-response.js.map +1 -0
- package/dist/components/ai-response/index.d.ts +2 -0
- package/dist/components/ai-response/index.js +2 -0
- package/dist/components/ai-response/meta.js +17 -0
- package/dist/components/ai-response/meta.js.map +1 -0
- package/dist/components/ai-sources/ai-sources.d.ts +44 -0
- package/dist/components/ai-sources/ai-sources.d.ts.map +1 -0
- package/dist/components/ai-sources/ai-sources.js +112 -0
- package/dist/components/ai-sources/ai-sources.js.map +1 -0
- package/dist/components/ai-sources/index.d.ts +2 -0
- package/dist/components/ai-sources/index.js +2 -0
- package/dist/components/ai-sources/meta.js +17 -0
- package/dist/components/ai-sources/meta.js.map +1 -0
- package/dist/components/ai-token-usage/ai-token-usage.d.ts +34 -0
- package/dist/components/ai-token-usage/ai-token-usage.d.ts.map +1 -0
- package/dist/components/ai-token-usage/ai-token-usage.js +58 -0
- package/dist/components/ai-token-usage/ai-token-usage.js.map +1 -0
- package/dist/components/ai-token-usage/index.d.ts +2 -0
- package/dist/components/ai-token-usage/index.js +2 -0
- package/dist/components/ai-token-usage/meta.js +17 -0
- package/dist/components/ai-token-usage/meta.js.map +1 -0
- package/dist/components/ai-tool/ai-tool.d.ts +50 -0
- package/dist/components/ai-tool/ai-tool.d.ts.map +1 -0
- package/dist/components/ai-tool/ai-tool.js +129 -0
- package/dist/components/ai-tool/ai-tool.js.map +1 -0
- package/dist/components/ai-tool/index.d.ts +2 -0
- package/dist/components/ai-tool/index.js +2 -0
- package/dist/components/ai-tool/meta.js +17 -0
- package/dist/components/ai-tool/meta.js.map +1 -0
- package/dist/components/alert/alert.d.ts +32 -0
- package/dist/components/alert/alert.d.ts.map +1 -0
- package/dist/components/alert/alert.js +49 -0
- package/dist/components/alert/alert.js.map +1 -0
- package/dist/components/alert/index.d.ts +2 -0
- package/dist/components/alert/index.js +2 -0
- package/dist/components/alert/meta.js +17 -0
- package/dist/components/alert/meta.js.map +1 -0
- package/dist/components/avatar/avatar.d.ts +23 -0
- package/dist/components/avatar/avatar.d.ts.map +1 -0
- package/dist/components/avatar/avatar.js +44 -0
- package/dist/components/avatar/avatar.js.map +1 -0
- package/dist/components/avatar/index.d.ts +2 -0
- package/dist/components/avatar/index.js +2 -0
- package/dist/components/avatar/meta.js +17 -0
- package/dist/components/avatar/meta.js.map +1 -0
- package/dist/components/badge/badge.d.ts +20 -0
- package/dist/components/badge/badge.d.ts.map +1 -0
- package/dist/components/badge/badge.js +47 -0
- package/dist/components/badge/badge.js.map +1 -0
- package/dist/components/badge/index.d.ts +2 -0
- package/dist/components/badge/index.js +2 -0
- package/dist/components/badge/meta.js +17 -0
- package/dist/components/badge/meta.js.map +1 -0
- package/dist/components/button/button.d.ts +28 -0
- package/dist/components/button/button.d.ts.map +1 -0
- package/dist/components/button/button.js +77 -0
- package/dist/components/button/button.js.map +1 -0
- package/dist/components/button/index.d.ts +2 -0
- package/dist/components/button/index.js +2 -0
- package/dist/components/button/meta.js +17 -0
- package/dist/components/button/meta.js.map +1 -0
- package/dist/components/calendar/calendar.d.ts +16 -0
- package/dist/components/calendar/calendar.d.ts.map +1 -0
- package/dist/components/calendar/calendar.js +70 -0
- package/dist/components/calendar/calendar.js.map +1 -0
- package/dist/components/calendar/index.d.ts +2 -0
- package/dist/components/calendar/index.js +2 -0
- package/dist/components/calendar/meta.js +17 -0
- package/dist/components/calendar/meta.js.map +1 -0
- package/dist/components/card/card.d.ts +23 -0
- package/dist/components/card/card.d.ts.map +1 -0
- package/dist/components/card/card.js +53 -0
- package/dist/components/card/card.js.map +1 -0
- package/dist/components/card/index.d.ts +2 -0
- package/dist/components/card/index.js +2 -0
- package/dist/components/card/meta.js +17 -0
- package/dist/components/card/meta.js.map +1 -0
- package/dist/components/checkbox/checkbox.d.ts +15 -0
- package/dist/components/checkbox/checkbox.d.ts.map +1 -0
- package/dist/components/checkbox/checkbox.js +45 -0
- package/dist/components/checkbox/checkbox.js.map +1 -0
- package/dist/components/checkbox/index.d.ts +2 -0
- package/dist/components/checkbox/index.js +2 -0
- package/dist/components/checkbox/meta.js +17 -0
- package/dist/components/checkbox/meta.js.map +1 -0
- package/dist/components/code-block/code-block.d.ts +46 -0
- package/dist/components/code-block/code-block.d.ts.map +1 -0
- package/dist/components/code-block/code-block.js +110 -0
- package/dist/components/code-block/code-block.js.map +1 -0
- package/dist/components/code-block/index.d.ts +2 -0
- package/dist/components/code-block/index.js +2 -0
- package/dist/components/code-block/meta.js +17 -0
- package/dist/components/code-block/meta.js.map +1 -0
- package/dist/components/combobox/combobox.d.ts +59 -0
- package/dist/components/combobox/combobox.d.ts.map +1 -0
- package/dist/components/combobox/combobox.js +346 -0
- package/dist/components/combobox/combobox.js.map +1 -0
- package/dist/components/combobox/index.d.ts +2 -0
- package/dist/components/combobox/index.js +2 -0
- package/dist/components/combobox/meta.js +17 -0
- package/dist/components/combobox/meta.js.map +1 -0
- package/dist/components/command/command.d.ts +65 -0
- package/dist/components/command/command.d.ts.map +1 -0
- package/dist/components/command/command.js +330 -0
- package/dist/components/command/command.js.map +1 -0
- package/dist/components/command/index.d.ts +2 -0
- package/dist/components/command/index.js +2 -0
- package/dist/components/command/meta.js +17 -0
- package/dist/components/command/meta.js.map +1 -0
- package/dist/components/data-table/data-table.d.ts +91 -0
- package/dist/components/data-table/data-table.d.ts.map +1 -0
- package/dist/components/data-table/data-table.js +263 -0
- package/dist/components/data-table/data-table.js.map +1 -0
- package/dist/components/data-table/index.d.ts +2 -0
- package/dist/components/data-table/index.js +2 -0
- package/dist/components/data-table/meta.js +22 -0
- package/dist/components/data-table/meta.js.map +1 -0
- package/dist/components/date-picker/date-picker.d.ts +31 -0
- package/dist/components/date-picker/date-picker.d.ts.map +1 -0
- package/dist/components/date-picker/date-picker.js +123 -0
- package/dist/components/date-picker/date-picker.js.map +1 -0
- package/dist/components/date-picker/index.d.ts +2 -0
- package/dist/components/date-picker/index.js +2 -0
- package/dist/components/date-picker/meta.js +21 -0
- package/dist/components/date-picker/meta.js.map +1 -0
- package/dist/components/dialog/dialog.d.ts +30 -0
- package/dist/components/dialog/dialog.d.ts.map +1 -0
- package/dist/components/dialog/dialog.js +79 -0
- package/dist/components/dialog/dialog.js.map +1 -0
- package/dist/components/dialog/index.d.ts +2 -0
- package/dist/components/dialog/index.js +2 -0
- package/dist/components/dialog/meta.js +17 -0
- package/dist/components/dialog/meta.js.map +1 -0
- package/dist/components/drawer/drawer.d.ts +32 -0
- package/dist/components/drawer/drawer.d.ts.map +1 -0
- package/dist/components/drawer/drawer.js +153 -0
- package/dist/components/drawer/drawer.js.map +1 -0
- package/dist/components/drawer/index.d.ts +2 -0
- package/dist/components/drawer/index.js +2 -0
- package/dist/components/drawer/meta.js +17 -0
- package/dist/components/drawer/meta.js.map +1 -0
- package/dist/components/dropdown-menu/dropdown-menu.d.ts +43 -0
- package/dist/components/dropdown-menu/dropdown-menu.d.ts.map +1 -0
- package/dist/components/dropdown-menu/dropdown-menu.js +130 -0
- package/dist/components/dropdown-menu/dropdown-menu.js.map +1 -0
- package/dist/components/dropdown-menu/index.d.ts +2 -0
- package/dist/components/dropdown-menu/index.js +2 -0
- package/dist/components/dropdown-menu/meta.js +17 -0
- package/dist/components/dropdown-menu/meta.js.map +1 -0
- package/dist/components/empty-state/empty-state.d.ts +24 -0
- package/dist/components/empty-state/empty-state.d.ts.map +1 -0
- package/dist/components/empty-state/empty-state.js +73 -0
- package/dist/components/empty-state/empty-state.js.map +1 -0
- package/dist/components/empty-state/index.d.ts +2 -0
- package/dist/components/empty-state/index.js +2 -0
- package/dist/components/empty-state/meta.js +17 -0
- package/dist/components/empty-state/meta.js.map +1 -0
- package/dist/components/form/form.d.ts +43 -0
- package/dist/components/form/form.d.ts.map +1 -0
- package/dist/components/form/form.js +127 -0
- package/dist/components/form/form.js.map +1 -0
- package/dist/components/form/index.d.ts +2 -0
- package/dist/components/form/index.js +2 -0
- package/dist/components/form/meta.js +17 -0
- package/dist/components/form/meta.js.map +1 -0
- package/dist/components/input/index.d.ts +2 -0
- package/dist/components/input/index.js +2 -0
- package/dist/components/input/input.d.ts +21 -0
- package/dist/components/input/input.d.ts.map +1 -0
- package/dist/components/input/input.js +34 -0
- package/dist/components/input/input.js.map +1 -0
- package/dist/components/input/meta.js +17 -0
- package/dist/components/input/meta.js.map +1 -0
- package/dist/components/label/index.d.ts +2 -0
- package/dist/components/label/index.js +2 -0
- package/dist/components/label/label.d.ts +14 -0
- package/dist/components/label/label.d.ts.map +1 -0
- package/dist/components/label/label.js +20 -0
- package/dist/components/label/label.js.map +1 -0
- package/dist/components/label/meta.js +17 -0
- package/dist/components/label/meta.js.map +1 -0
- package/dist/components/pagination/index.d.ts +2 -0
- package/dist/components/pagination/index.js +2 -0
- package/dist/components/pagination/meta.js +17 -0
- package/dist/components/pagination/meta.js.map +1 -0
- package/dist/components/pagination/pagination.d.ts +33 -0
- package/dist/components/pagination/pagination.d.ts.map +1 -0
- package/dist/components/pagination/pagination.js +143 -0
- package/dist/components/pagination/pagination.js.map +1 -0
- package/dist/components/popover/index.d.ts +2 -0
- package/dist/components/popover/index.js +2 -0
- package/dist/components/popover/meta.js +17 -0
- package/dist/components/popover/meta.js.map +1 -0
- package/dist/components/popover/popover.d.ts +24 -0
- package/dist/components/popover/popover.d.ts.map +1 -0
- package/dist/components/popover/popover.js +60 -0
- package/dist/components/popover/popover.js.map +1 -0
- package/dist/components/progress/index.d.ts +2 -0
- package/dist/components/progress/index.js +2 -0
- package/dist/components/progress/meta.js +17 -0
- package/dist/components/progress/meta.js.map +1 -0
- package/dist/components/progress/progress.d.ts +21 -0
- package/dist/components/progress/progress.d.ts.map +1 -0
- package/dist/components/progress/progress.js +55 -0
- package/dist/components/progress/progress.js.map +1 -0
- package/dist/components/radio-group/index.d.ts +2 -0
- package/dist/components/radio-group/index.js +2 -0
- package/dist/components/radio-group/meta.js +17 -0
- package/dist/components/radio-group/meta.js.map +1 -0
- package/dist/components/radio-group/radio-group.d.ts +17 -0
- package/dist/components/radio-group/radio-group.d.ts.map +1 -0
- package/dist/components/radio-group/radio-group.js +29 -0
- package/dist/components/radio-group/radio-group.js.map +1 -0
- package/dist/components/select/index.d.ts +2 -0
- package/dist/components/select/index.js +2 -0
- package/dist/components/select/meta.js +17 -0
- package/dist/components/select/meta.js.map +1 -0
- package/dist/components/select/select.d.ts +37 -0
- package/dist/components/select/select.d.ts.map +1 -0
- package/dist/components/select/select.js +128 -0
- package/dist/components/select/select.js.map +1 -0
- package/dist/components/separator/index.d.ts +2 -0
- package/dist/components/separator/index.js +2 -0
- package/dist/components/separator/meta.js +17 -0
- package/dist/components/separator/meta.js.map +1 -0
- package/dist/components/separator/separator.d.ts +15 -0
- package/dist/components/separator/separator.d.ts.map +1 -0
- package/dist/components/separator/separator.js +23 -0
- package/dist/components/separator/separator.js.map +1 -0
- package/dist/components/sheet/index.d.ts +2 -0
- package/dist/components/sheet/index.js +2 -0
- package/dist/components/sheet/meta.js +17 -0
- package/dist/components/sheet/meta.js.map +1 -0
- package/dist/components/sheet/sheet.d.ts +31 -0
- package/dist/components/sheet/sheet.d.ts.map +1 -0
- package/dist/components/sheet/sheet.js +90 -0
- package/dist/components/sheet/sheet.js.map +1 -0
- package/dist/components/skeleton/index.d.ts +2 -0
- package/dist/components/skeleton/index.js +2 -0
- package/dist/components/skeleton/meta.js +17 -0
- package/dist/components/skeleton/meta.js.map +1 -0
- package/dist/components/skeleton/skeleton.d.ts +20 -0
- package/dist/components/skeleton/skeleton.d.ts.map +1 -0
- package/dist/components/skeleton/skeleton.js +29 -0
- package/dist/components/skeleton/skeleton.js.map +1 -0
- package/dist/components/slider/index.d.ts +2 -0
- package/dist/components/slider/index.js +2 -0
- package/dist/components/slider/meta.js +17 -0
- package/dist/components/slider/meta.js.map +1 -0
- package/dist/components/slider/slider.d.ts +29 -0
- package/dist/components/slider/slider.d.ts.map +1 -0
- package/dist/components/slider/slider.js +61 -0
- package/dist/components/slider/slider.js.map +1 -0
- package/dist/components/spinner/index.d.ts +2 -0
- package/dist/components/spinner/index.js +2 -0
- package/dist/components/spinner/meta.js +17 -0
- package/dist/components/spinner/meta.js.map +1 -0
- package/dist/components/spinner/spinner.d.ts +21 -0
- package/dist/components/spinner/spinner.d.ts.map +1 -0
- package/dist/components/spinner/spinner.js +45 -0
- package/dist/components/spinner/spinner.js.map +1 -0
- package/dist/components/switch/index.d.ts +2 -0
- package/dist/components/switch/index.js +2 -0
- package/dist/components/switch/meta.js +17 -0
- package/dist/components/switch/meta.js.map +1 -0
- package/dist/components/switch/switch.d.ts +15 -0
- package/dist/components/switch/switch.d.ts.map +1 -0
- package/dist/components/switch/switch.js +21 -0
- package/dist/components/switch/switch.js.map +1 -0
- package/dist/components/table/index.d.ts +2 -0
- package/dist/components/table/index.js +2 -0
- package/dist/components/table/meta.js +17 -0
- package/dist/components/table/meta.js.map +1 -0
- package/dist/components/table/table.d.ts +41 -0
- package/dist/components/table/table.d.ts.map +1 -0
- package/dist/components/table/table.js +78 -0
- package/dist/components/table/table.js.map +1 -0
- package/dist/components/tabs/index.d.ts +2 -0
- package/dist/components/tabs/index.js +2 -0
- package/dist/components/tabs/meta.js +17 -0
- package/dist/components/tabs/meta.js.map +1 -0
- package/dist/components/tabs/tabs.d.ts +28 -0
- package/dist/components/tabs/tabs.d.ts.map +1 -0
- package/dist/components/tabs/tabs.js +58 -0
- package/dist/components/tabs/tabs.js.map +1 -0
- package/dist/components/toast/index.d.ts +3 -0
- package/dist/components/toast/index.js +3 -0
- package/dist/components/toast/meta.js +17 -0
- package/dist/components/toast/meta.js.map +1 -0
- package/dist/components/toast/toast-store.d.ts +84 -0
- package/dist/components/toast/toast-store.d.ts.map +1 -0
- package/dist/components/toast/toast-store.js +115 -0
- package/dist/components/toast/toast-store.js.map +1 -0
- package/dist/components/toast/toast.d.ts +39 -0
- package/dist/components/toast/toast.d.ts.map +1 -0
- package/dist/components/toast/toast.js +140 -0
- package/dist/components/toast/toast.js.map +1 -0
- package/dist/components/tooltip/index.d.ts +2 -0
- package/dist/components/tooltip/index.js +2 -0
- package/dist/components/tooltip/meta.js +17 -0
- package/dist/components/tooltip/meta.js.map +1 -0
- package/dist/components/tooltip/tooltip.d.ts +24 -0
- package/dist/components/tooltip/tooltip.d.ts.map +1 -0
- package/dist/components/tooltip/tooltip.js +38 -0
- package/dist/components/tooltip/tooltip.js.map +1 -0
- package/dist/index.d.ts +97 -0
- package/dist/index.js +51 -0
- package/dist/lib/styles.d.ts +21 -0
- package/dist/lib/styles.d.ts.map +1 -0
- package/dist/lib/styles.js +22 -0
- package/dist/lib/styles.js.map +1 -0
- package/dist/lib/utils.d.ts +11 -0
- package/dist/lib/utils.d.ts.map +1 -0
- package/dist/lib/utils.js +21 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/registry/blocks.d.ts +15 -0
- package/dist/registry/blocks.d.ts.map +1 -0
- package/dist/registry/blocks.js +32 -0
- package/dist/registry/blocks.js.map +1 -0
- package/dist/registry/components.d.ts +18 -0
- package/dist/registry/components.d.ts.map +1 -0
- package/dist/registry/components.js +112 -0
- package/dist/registry/components.js.map +1 -0
- package/dist/registry/schema.d.ts +44 -0
- package/dist/registry/schema.d.ts.map +1 -0
- package/dist/registry/schema.js +33 -0
- package/dist/registry/schema.js.map +1 -0
- package/package.json +74 -0
- package/src/blocks/admin-users/admin-users.stories.tsx +83 -0
- package/src/blocks/admin-users/admin-users.test.tsx +159 -0
- package/src/blocks/admin-users/admin-users.tsx +251 -0
- package/src/blocks/admin-users/index.ts +1 -0
- package/src/blocks/admin-users/meta.ts +27 -0
- package/src/blocks/ai-chat/ai-chat.stories.tsx +149 -0
- package/src/blocks/ai-chat/ai-chat.test.tsx +166 -0
- package/src/blocks/ai-chat/ai-chat.tsx +280 -0
- package/src/blocks/ai-chat/index.ts +7 -0
- package/src/blocks/ai-chat/meta.ts +32 -0
- package/src/blocks/dashboard/dashboard.stories.tsx +106 -0
- package/src/blocks/dashboard/dashboard.test.tsx +94 -0
- package/src/blocks/dashboard/dashboard.tsx +192 -0
- package/src/blocks/dashboard/index.ts +6 -0
- package/src/blocks/dashboard/meta.ts +18 -0
- package/src/blocks/forgot-password/forgot-password.stories.tsx +41 -0
- package/src/blocks/forgot-password/forgot-password.test.tsx +62 -0
- package/src/blocks/forgot-password/forgot-password.tsx +158 -0
- package/src/blocks/forgot-password/index.ts +1 -0
- package/src/blocks/forgot-password/meta.ts +18 -0
- package/src/blocks/login/index.ts +1 -0
- package/src/blocks/login/login.stories.tsx +46 -0
- package/src/blocks/login/login.test.tsx +100 -0
- package/src/blocks/login/login.tsx +178 -0
- package/src/blocks/login/meta.ts +18 -0
- package/src/blocks/pricing/index.ts +1 -0
- package/src/blocks/pricing/meta.ts +18 -0
- package/src/blocks/pricing/pricing.stories.tsx +62 -0
- package/src/blocks/pricing/pricing.test.tsx +101 -0
- package/src/blocks/pricing/pricing.tsx +176 -0
- package/src/blocks/settings/index.ts +6 -0
- package/src/blocks/settings/meta.ts +29 -0
- package/src/blocks/settings/settings.stories.tsx +94 -0
- package/src/blocks/settings/settings.test.tsx +167 -0
- package/src/blocks/settings/settings.tsx +317 -0
- package/src/blocks/signup/index.ts +1 -0
- package/src/blocks/signup/meta.ts +18 -0
- package/src/blocks/signup/signup.stories.tsx +27 -0
- package/src/blocks/signup/signup.test.tsx +97 -0
- package/src/blocks/signup/signup.tsx +240 -0
- package/src/components/accordion/accordion.stories.tsx +90 -0
- package/src/components/accordion/accordion.test.tsx +156 -0
- package/src/components/accordion/accordion.tsx +88 -0
- package/src/components/accordion/index.ts +9 -0
- package/src/components/accordion/meta.ts +16 -0
- package/src/components/activity-feed/activity-feed.stories.tsx +163 -0
- package/src/components/activity-feed/activity-feed.test.tsx +125 -0
- package/src/components/activity-feed/activity-feed.tsx +115 -0
- package/src/components/activity-feed/index.ts +12 -0
- package/src/components/activity-feed/meta.ts +17 -0
- package/src/components/ai-agent-status/ai-agent-status.stories.tsx +86 -0
- package/src/components/ai-agent-status/ai-agent-status.test.tsx +66 -0
- package/src/components/ai-agent-status/ai-agent-status.tsx +88 -0
- package/src/components/ai-agent-status/index.ts +6 -0
- package/src/components/ai-agent-status/meta.ts +17 -0
- package/src/components/ai-conversation/ai-conversation.stories.tsx +126 -0
- package/src/components/ai-conversation/ai-conversation.test.tsx +144 -0
- package/src/components/ai-conversation/ai-conversation.tsx +229 -0
- package/src/components/ai-conversation/index.ts +9 -0
- package/src/components/ai-conversation/meta.ts +20 -0
- package/src/components/ai-message/ai-message.stories.tsx +106 -0
- package/src/components/ai-message/ai-message.test.tsx +160 -0
- package/src/components/ai-message/ai-message.tsx +162 -0
- package/src/components/ai-message/index.ts +13 -0
- package/src/components/ai-message/meta.ts +17 -0
- package/src/components/ai-model-selector/ai-model-selector.stories.tsx +66 -0
- package/src/components/ai-model-selector/ai-model-selector.test.tsx +120 -0
- package/src/components/ai-model-selector/ai-model-selector.tsx +112 -0
- package/src/components/ai-model-selector/index.ts +1 -0
- package/src/components/ai-model-selector/meta.ts +17 -0
- package/src/components/ai-prompt-input/ai-prompt-input.stories.tsx +145 -0
- package/src/components/ai-prompt-input/ai-prompt-input.test.tsx +273 -0
- package/src/components/ai-prompt-input/ai-prompt-input.tsx +306 -0
- package/src/components/ai-prompt-input/index.ts +11 -0
- package/src/components/ai-prompt-input/meta.ts +18 -0
- package/src/components/ai-reasoning/ai-reasoning.stories.tsx +60 -0
- package/src/components/ai-reasoning/ai-reasoning.test.tsx +95 -0
- package/src/components/ai-reasoning/ai-reasoning.tsx +106 -0
- package/src/components/ai-reasoning/index.ts +7 -0
- package/src/components/ai-reasoning/meta.ts +17 -0
- package/src/components/ai-response/ai-response.stories.tsx +75 -0
- package/src/components/ai-response/ai-response.test.tsx +96 -0
- package/src/components/ai-response/ai-response.tsx +95 -0
- package/src/components/ai-response/index.ts +7 -0
- package/src/components/ai-response/meta.ts +17 -0
- package/src/components/ai-sources/ai-sources.stories.tsx +93 -0
- package/src/components/ai-sources/ai-sources.test.tsx +102 -0
- package/src/components/ai-sources/ai-sources.tsx +186 -0
- package/src/components/ai-sources/index.ts +11 -0
- package/src/components/ai-sources/meta.ts +17 -0
- package/src/components/ai-token-usage/ai-token-usage.stories.tsx +59 -0
- package/src/components/ai-token-usage/ai-token-usage.test.tsx +83 -0
- package/src/components/ai-token-usage/ai-token-usage.tsx +105 -0
- package/src/components/ai-token-usage/index.ts +6 -0
- package/src/components/ai-token-usage/meta.ts +16 -0
- package/src/components/ai-tool/ai-tool.stories.tsx +96 -0
- package/src/components/ai-tool/ai-tool.test.tsx +137 -0
- package/src/components/ai-tool/ai-tool.tsx +235 -0
- package/src/components/ai-tool/index.ts +13 -0
- package/src/components/ai-tool/meta.ts +17 -0
- package/src/components/alert/alert.stories.tsx +101 -0
- package/src/components/alert/alert.test.tsx +94 -0
- package/src/components/alert/alert.tsx +89 -0
- package/src/components/alert/index.ts +8 -0
- package/src/components/alert/meta.ts +16 -0
- package/src/components/avatar/avatar.stories.tsx +58 -0
- package/src/components/avatar/avatar.test.tsx +64 -0
- package/src/components/avatar/avatar.tsx +68 -0
- package/src/components/avatar/index.ts +9 -0
- package/src/components/avatar/meta.ts +15 -0
- package/src/components/badge/badge.stories.tsx +68 -0
- package/src/components/badge/badge.test.tsx +61 -0
- package/src/components/badge/badge.tsx +54 -0
- package/src/components/badge/index.ts +1 -0
- package/src/components/badge/meta.ts +15 -0
- package/src/components/button/button.stories.tsx +128 -0
- package/src/components/button/button.test.tsx +224 -0
- package/src/components/button/button.tsx +114 -0
- package/src/components/button/index.ts +1 -0
- package/src/components/button/meta.ts +16 -0
- package/src/components/calendar/calendar.stories.tsx +105 -0
- package/src/components/calendar/calendar.test.tsx +255 -0
- package/src/components/calendar/calendar.tsx +115 -0
- package/src/components/calendar/index.ts +1 -0
- package/src/components/calendar/meta.ts +17 -0
- package/src/components/card/card.stories.tsx +61 -0
- package/src/components/card/card.test.tsx +66 -0
- package/src/components/card/card.tsx +81 -0
- package/src/components/card/index.ts +9 -0
- package/src/components/card/meta.ts +16 -0
- package/src/components/checkbox/checkbox.stories.tsx +124 -0
- package/src/components/checkbox/checkbox.test.tsx +121 -0
- package/src/components/checkbox/checkbox.tsx +66 -0
- package/src/components/checkbox/index.ts +1 -0
- package/src/components/checkbox/meta.ts +16 -0
- package/src/components/code-block/code-block.stories.tsx +62 -0
- package/src/components/code-block/code-block.test.tsx +139 -0
- package/src/components/code-block/code-block.tsx +188 -0
- package/src/components/code-block/index.ts +1 -0
- package/src/components/code-block/meta.ts +17 -0
- package/src/components/combobox/combobox.stories.tsx +171 -0
- package/src/components/combobox/combobox.test.tsx +429 -0
- package/src/components/combobox/combobox.tsx +544 -0
- package/src/components/combobox/index.ts +15 -0
- package/src/components/combobox/meta.ts +17 -0
- package/src/components/command/command.stories.tsx +152 -0
- package/src/components/command/command.test.tsx +380 -0
- package/src/components/command/command.tsx +482 -0
- package/src/components/command/index.ts +17 -0
- package/src/components/command/meta.ts +18 -0
- package/src/components/data-table/data-table.stories.tsx +151 -0
- package/src/components/data-table/data-table.test.tsx +288 -0
- package/src/components/data-table/data-table.tsx +485 -0
- package/src/components/data-table/index.ts +13 -0
- package/src/components/data-table/meta.ts +19 -0
- package/src/components/date-picker/date-picker.stories.tsx +103 -0
- package/src/components/date-picker/date-picker.test.tsx +205 -0
- package/src/components/date-picker/date-picker.tsx +198 -0
- package/src/components/date-picker/index.ts +6 -0
- package/src/components/date-picker/meta.ts +18 -0
- package/src/components/dialog/dialog.stories.tsx +140 -0
- package/src/components/dialog/dialog.test.tsx +186 -0
- package/src/components/dialog/dialog.tsx +132 -0
- package/src/components/dialog/index.ts +16 -0
- package/src/components/dialog/meta.ts +16 -0
- package/src/components/drawer/drawer.stories.tsx +111 -0
- package/src/components/drawer/drawer.test.tsx +187 -0
- package/src/components/drawer/drawer.tsx +293 -0
- package/src/components/drawer/index.ts +16 -0
- package/src/components/drawer/meta.ts +16 -0
- package/src/components/dropdown-menu/dropdown-menu.stories.tsx +128 -0
- package/src/components/dropdown-menu/dropdown-menu.test.tsx +321 -0
- package/src/components/dropdown-menu/dropdown-menu.tsx +242 -0
- package/src/components/dropdown-menu/index.ts +21 -0
- package/src/components/dropdown-menu/meta.ts +17 -0
- package/src/components/empty-state/empty-state.stories.tsx +70 -0
- package/src/components/empty-state/empty-state.test.tsx +97 -0
- package/src/components/empty-state/empty-state.tsx +92 -0
- package/src/components/empty-state/index.ts +9 -0
- package/src/components/empty-state/meta.ts +16 -0
- package/src/components/form/form.stories.tsx +144 -0
- package/src/components/form/form.test.tsx +203 -0
- package/src/components/form/form.tsx +221 -0
- package/src/components/form/index.ts +13 -0
- package/src/components/form/meta.ts +17 -0
- package/src/components/input/index.ts +1 -0
- package/src/components/input/input.stories.tsx +84 -0
- package/src/components/input/input.test.tsx +108 -0
- package/src/components/input/input.tsx +51 -0
- package/src/components/input/meta.ts +15 -0
- package/src/components/label/index.ts +1 -0
- package/src/components/label/label.stories.tsx +51 -0
- package/src/components/label/label.test.tsx +55 -0
- package/src/components/label/label.tsx +26 -0
- package/src/components/label/meta.ts +15 -0
- package/src/components/pagination/index.ts +10 -0
- package/src/components/pagination/meta.ts +17 -0
- package/src/components/pagination/pagination.stories.tsx +129 -0
- package/src/components/pagination/pagination.test.tsx +119 -0
- package/src/components/pagination/pagination.tsx +142 -0
- package/src/components/popover/index.ts +9 -0
- package/src/components/popover/meta.ts +18 -0
- package/src/components/popover/popover.stories.tsx +84 -0
- package/src/components/popover/popover.test.tsx +163 -0
- package/src/components/popover/popover.tsx +89 -0
- package/src/components/progress/index.ts +1 -0
- package/src/components/progress/meta.ts +17 -0
- package/src/components/progress/progress.stories.tsx +90 -0
- package/src/components/progress/progress.test.tsx +78 -0
- package/src/components/progress/progress.tsx +70 -0
- package/src/components/radio-group/index.ts +6 -0
- package/src/components/radio-group/meta.ts +16 -0
- package/src/components/radio-group/radio-group.stories.tsx +102 -0
- package/src/components/radio-group/radio-group.test.tsx +152 -0
- package/src/components/radio-group/radio-group.tsx +53 -0
- package/src/components/select/index.ts +14 -0
- package/src/components/select/meta.ts +16 -0
- package/src/components/select/select.stories.tsx +137 -0
- package/src/components/select/select.test.tsx +209 -0
- package/src/components/select/select.tsx +222 -0
- package/src/components/separator/index.ts +1 -0
- package/src/components/separator/meta.ts +15 -0
- package/src/components/separator/separator.stories.tsx +42 -0
- package/src/components/separator/separator.test.tsx +46 -0
- package/src/components/separator/separator.tsx +33 -0
- package/src/components/sheet/index.ts +14 -0
- package/src/components/sheet/meta.ts +16 -0
- package/src/components/sheet/sheet.stories.tsx +107 -0
- package/src/components/sheet/sheet.test.tsx +152 -0
- package/src/components/sheet/sheet.tsx +160 -0
- package/src/components/skeleton/index.ts +1 -0
- package/src/components/skeleton/meta.ts +15 -0
- package/src/components/skeleton/skeleton.stories.tsx +46 -0
- package/src/components/skeleton/skeleton.test.tsx +57 -0
- package/src/components/skeleton/skeleton.tsx +28 -0
- package/src/components/slider/index.ts +1 -0
- package/src/components/slider/meta.ts +19 -0
- package/src/components/slider/slider.stories.tsx +87 -0
- package/src/components/slider/slider.test.tsx +148 -0
- package/src/components/slider/slider.tsx +135 -0
- package/src/components/spinner/index.ts +1 -0
- package/src/components/spinner/meta.ts +15 -0
- package/src/components/spinner/spinner.stories.tsx +47 -0
- package/src/components/spinner/spinner.test.tsx +41 -0
- package/src/components/spinner/spinner.tsx +68 -0
- package/src/components/switch/index.ts +1 -0
- package/src/components/switch/meta.ts +15 -0
- package/src/components/switch/switch.stories.tsx +70 -0
- package/src/components/switch/switch.test.tsx +101 -0
- package/src/components/switch/switch.tsx +42 -0
- package/src/components/table/index.ts +11 -0
- package/src/components/table/meta.ts +17 -0
- package/src/components/table/table.stories.tsx +131 -0
- package/src/components/table/table.test.tsx +153 -0
- package/src/components/table/table.tsx +138 -0
- package/src/components/tabs/index.ts +11 -0
- package/src/components/tabs/meta.ts +17 -0
- package/src/components/tabs/tabs.stories.tsx +139 -0
- package/src/components/tabs/tabs.test.tsx +148 -0
- package/src/components/tabs/tabs.tsx +106 -0
- package/src/components/toast/index.ts +24 -0
- package/src/components/toast/meta.ts +18 -0
- package/src/components/toast/toast-store.ts +181 -0
- package/src/components/toast/toast.stories.tsx +167 -0
- package/src/components/toast/toast.test.tsx +306 -0
- package/src/components/toast/toast.tsx +241 -0
- package/src/components/tooltip/index.ts +8 -0
- package/src/components/tooltip/meta.ts +17 -0
- package/src/components/tooltip/tooltip.stories.tsx +89 -0
- package/src/components/tooltip/tooltip.test.tsx +120 -0
- package/src/components/tooltip/tooltip.tsx +58 -0
- package/src/index.ts +50 -0
- package/src/lib/styles.ts +26 -0
- package/src/lib/utils.test.ts +32 -0
- package/src/lib/utils.ts +24 -0
- package/src/registry/blocks.ts +30 -0
- package/src/registry/components.ts +114 -0
- package/src/registry/meta.test.ts +234 -0
- package/src/registry/schema.ts +58 -0
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { render, screen } from "@testing-library/react";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
|
|
4
|
+
import { expectNoA11yViolations } from "../../../test/a11y";
|
|
5
|
+
import { TokenCount, TokenUsage } from "./ai-token-usage";
|
|
6
|
+
|
|
7
|
+
describe("TokenUsage", () => {
|
|
8
|
+
it("shows the numbers, which are the actual content", () => {
|
|
9
|
+
render(<TokenUsage used={12000} limit={200000} />);
|
|
10
|
+
expect(screen.getByText("12,000 / 200,000")).toBeInTheDocument();
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it("labels what is being measured", () => {
|
|
14
|
+
render(<TokenUsage used={100} limit={1000} />);
|
|
15
|
+
expect(screen.getByText("Context used")).toBeInTheDocument();
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it("accepts a custom label and formatter", () => {
|
|
19
|
+
render(
|
|
20
|
+
<TokenUsage
|
|
21
|
+
used={1500}
|
|
22
|
+
limit={4000}
|
|
23
|
+
label="Budget"
|
|
24
|
+
format={(value) => `${String(Math.round(value / 1000))}k`}
|
|
25
|
+
/>,
|
|
26
|
+
);
|
|
27
|
+
expect(screen.getByText("Budget")).toBeInTheDocument();
|
|
28
|
+
expect(screen.getByText("2k / 4k")).toBeInTheDocument();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it("hides the bar, since it only restates the numbers", () => {
|
|
32
|
+
const { container } = render(<TokenUsage used={100} limit={1000} />);
|
|
33
|
+
// Not a second progressbar to read past.
|
|
34
|
+
expect(container.querySelector("[aria-hidden='true']")).toBeInTheDocument();
|
|
35
|
+
expect(screen.queryByRole("progressbar")).not.toBeInTheDocument();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("marks the warning state past the threshold", () => {
|
|
39
|
+
const { container } = render(<TokenUsage used={900} limit={1000} />);
|
|
40
|
+
expect(container.firstElementChild).toHaveAttribute("data-warning", "true");
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
it("does not warn below the threshold", () => {
|
|
44
|
+
const { container } = render(<TokenUsage used={100} limit={1000} />);
|
|
45
|
+
expect(container.firstElementChild).not.toHaveAttribute("data-warning");
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it("marks going over the limit", () => {
|
|
49
|
+
const { container } = render(<TokenUsage used={1200} limit={1000} />);
|
|
50
|
+
expect(container.firstElementChild).toHaveAttribute("data-over", "true");
|
|
51
|
+
// The figures stay readable even when over.
|
|
52
|
+
expect(screen.getByText("1,200 / 1,000")).toBeInTheDocument();
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("clamps the bar rather than overflowing it", () => {
|
|
56
|
+
const { container } = render(<TokenUsage used={5000} limit={1000} />);
|
|
57
|
+
const fill = container.querySelector("[aria-hidden='true'] > div");
|
|
58
|
+
expect(fill).toHaveStyle({ width: "100%" });
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("survives a zero limit without dividing by it", () => {
|
|
62
|
+
const { container } = render(<TokenUsage used={10} limit={0} />);
|
|
63
|
+
const fill = container.querySelector("[aria-hidden='true'] > div");
|
|
64
|
+
expect(fill).toHaveStyle({ width: "0%" });
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("has no accessibility violations", async () => {
|
|
68
|
+
const { container } = render(<TokenUsage used={180000} limit={200000} />);
|
|
69
|
+
await expectNoA11yViolations(container);
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
describe("TokenCount", () => {
|
|
74
|
+
it("formats the count", () => {
|
|
75
|
+
render(<TokenCount value={12345} />);
|
|
76
|
+
expect(screen.getByText("12,345 tokens")).toBeInTheDocument();
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it("accepts a custom unit", () => {
|
|
80
|
+
render(<TokenCount value={42} label="output tokens" />);
|
|
81
|
+
expect(screen.getByText("42 output tokens")).toBeInTheDocument();
|
|
82
|
+
});
|
|
83
|
+
});
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import type { ComponentPropsWithRef } from "react";
|
|
4
|
+
|
|
5
|
+
import { cn } from "@/lib/utils";
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* How much of the context window a conversation has used.
|
|
9
|
+
*
|
|
10
|
+
* Worth showing because running out of context is a cliff, not a slope: the
|
|
11
|
+
* conversation stops behaving the way it did, and without a gauge that looks
|
|
12
|
+
* like the model getting worse rather than a limit being reached.
|
|
13
|
+
*
|
|
14
|
+
* The numbers are the message; the bar is a summary of them. Both are present,
|
|
15
|
+
* and the numbers are what a screen reader gets.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
export interface TokenUsageProps extends ComponentPropsWithRef<"div"> {
|
|
19
|
+
/** Tokens used so far. */
|
|
20
|
+
used: number;
|
|
21
|
+
/** The context window. */
|
|
22
|
+
limit: number;
|
|
23
|
+
label?: string;
|
|
24
|
+
/** Fraction of the limit past which the gauge warns. */
|
|
25
|
+
warnAt?: number;
|
|
26
|
+
/** Formats the numbers. Defaults to the runtime locale's grouping. */
|
|
27
|
+
format?: (value: number) => string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function defaultFormat(value: number): string {
|
|
31
|
+
return new Intl.NumberFormat().format(value);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function TokenUsage({
|
|
35
|
+
className,
|
|
36
|
+
used,
|
|
37
|
+
limit,
|
|
38
|
+
label = "Context used",
|
|
39
|
+
warnAt = 0.85,
|
|
40
|
+
format = defaultFormat,
|
|
41
|
+
...props
|
|
42
|
+
}: TokenUsageProps) {
|
|
43
|
+
const fraction = limit > 0 ? Math.min(1, Math.max(0, used / limit)) : 0;
|
|
44
|
+
const percent = Math.round(fraction * 100);
|
|
45
|
+
const warning = fraction >= warnAt;
|
|
46
|
+
const over = used > limit;
|
|
47
|
+
|
|
48
|
+
return (
|
|
49
|
+
<div
|
|
50
|
+
data-slot="token-usage"
|
|
51
|
+
data-warning={warning || undefined}
|
|
52
|
+
data-over={over || undefined}
|
|
53
|
+
className={cn("flex w-full flex-col gap-1", className)}
|
|
54
|
+
{...props}
|
|
55
|
+
>
|
|
56
|
+
<div className="flex items-baseline justify-between gap-2 text-xs">
|
|
57
|
+
<span className="text-muted-foreground">{label}</span>
|
|
58
|
+
<span
|
|
59
|
+
className={cn(
|
|
60
|
+
"tabular-nums",
|
|
61
|
+
over ? "text-destructive" : warning ? "text-warning" : "text-muted-foreground",
|
|
62
|
+
)}
|
|
63
|
+
>
|
|
64
|
+
{format(used)} / {format(limit)}
|
|
65
|
+
</span>
|
|
66
|
+
</div>
|
|
67
|
+
{/* The bar summarises what the numbers above already say, so it is
|
|
68
|
+
decorative rather than a second progressbar to read through. */}
|
|
69
|
+
<div aria-hidden="true" className="h-1 w-full overflow-hidden rounded-full bg-muted">
|
|
70
|
+
<div
|
|
71
|
+
className={cn(
|
|
72
|
+
"h-full rounded-full transition-[width] duration-[var(--duration-slow)] ease-[var(--ease-out-quint)]",
|
|
73
|
+
over ? "bg-destructive" : warning ? "bg-warning" : "bg-primary",
|
|
74
|
+
)}
|
|
75
|
+
style={{ width: `${String(percent)}%` }}
|
|
76
|
+
/>
|
|
77
|
+
</div>
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export interface TokenCountProps extends ComponentPropsWithRef<"span"> {
|
|
83
|
+
value: number;
|
|
84
|
+
label?: string;
|
|
85
|
+
format?: (value: number) => string;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** A bare token count, for a message footer or a toolbar. */
|
|
89
|
+
export function TokenCount({
|
|
90
|
+
className,
|
|
91
|
+
value,
|
|
92
|
+
label = "tokens",
|
|
93
|
+
format = defaultFormat,
|
|
94
|
+
...props
|
|
95
|
+
}: TokenCountProps) {
|
|
96
|
+
return (
|
|
97
|
+
<span
|
|
98
|
+
data-slot="token-count"
|
|
99
|
+
className={cn("text-2xs text-muted-foreground tabular-nums", className)}
|
|
100
|
+
{...props}
|
|
101
|
+
>
|
|
102
|
+
{format(value)} {label}
|
|
103
|
+
</span>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { defineMeta } from "@/registry/schema";
|
|
2
|
+
|
|
3
|
+
export const meta = defineMeta({
|
|
4
|
+
name: "ai-token-usage",
|
|
5
|
+
title: "AI Token Usage",
|
|
6
|
+
description: "A gauge showing how much of the context window a conversation has used.",
|
|
7
|
+
category: "ai",
|
|
8
|
+
status: "stable",
|
|
9
|
+
dependencies: [],
|
|
10
|
+
registryDependencies: [],
|
|
11
|
+
files: ["ai-token-usage.tsx"],
|
|
12
|
+
a11y:
|
|
13
|
+
"The numbers are the content and the bar only summarises them, so the bar is aria-hidden " +
|
|
14
|
+
"rather than a second progressbar to read past. Counts are formatted for the locale. Warning " +
|
|
15
|
+
"and over-limit states change the wording's colour but never remove the figures.",
|
|
16
|
+
});
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { Decorator, Meta, StoryObj } from "@storybook/react-vite";
|
|
2
|
+
|
|
3
|
+
import { Tool, ToolContent, ToolHeader, ToolPayload, ToolSection } from "./ai-tool";
|
|
4
|
+
|
|
5
|
+
/** Named so its type is nameable in declaration output (TS2883). */
|
|
6
|
+
const withFixedWidth: Decorator = (Story) => (
|
|
7
|
+
<div className="w-[32rem]">
|
|
8
|
+
<Story />
|
|
9
|
+
</div>
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
const meta = {
|
|
13
|
+
title: "AI/Tool Call",
|
|
14
|
+
component: Tool,
|
|
15
|
+
args: { status: "success" },
|
|
16
|
+
argTypes: {
|
|
17
|
+
status: { control: "inline-radio", options: ["pending", "running", "success", "error"] },
|
|
18
|
+
},
|
|
19
|
+
decorators: [withFixedWidth],
|
|
20
|
+
} satisfies Meta<typeof Tool>;
|
|
21
|
+
|
|
22
|
+
export default meta;
|
|
23
|
+
type Story = StoryObj<typeof meta>;
|
|
24
|
+
|
|
25
|
+
export const Default: Story = {
|
|
26
|
+
render: (args) => (
|
|
27
|
+
<Tool {...args}>
|
|
28
|
+
<ToolHeader name="search_web" status={args.status ?? "success"} />
|
|
29
|
+
<ToolContent>
|
|
30
|
+
<ToolSection label="Arguments">
|
|
31
|
+
<ToolPayload label="Arguments">
|
|
32
|
+
{JSON.stringify({ query: "accessible data tables", limit: 5 }, null, 2)}
|
|
33
|
+
</ToolPayload>
|
|
34
|
+
</ToolSection>
|
|
35
|
+
<ToolSection label="Result">
|
|
36
|
+
<ToolPayload label="Result">
|
|
37
|
+
{JSON.stringify(
|
|
38
|
+
{ results: [{ title: "ARIA authoring practices", url: "https://example.org" }] },
|
|
39
|
+
null,
|
|
40
|
+
2,
|
|
41
|
+
)}
|
|
42
|
+
</ToolPayload>
|
|
43
|
+
</ToolSection>
|
|
44
|
+
</ToolContent>
|
|
45
|
+
</Tool>
|
|
46
|
+
),
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/** Status is always a word, never only a colour. */
|
|
50
|
+
export const Statuses: Story = {
|
|
51
|
+
parameters: { controls: { disable: true } },
|
|
52
|
+
render: () => (
|
|
53
|
+
<div className="grid gap-2">
|
|
54
|
+
{(["pending", "running", "success", "error"] as const).map((status) => (
|
|
55
|
+
<Tool key={status} status={status}>
|
|
56
|
+
<ToolHeader name={`tool_${status}`} status={status} />
|
|
57
|
+
<ToolContent>
|
|
58
|
+
<ToolSection label="Result">
|
|
59
|
+
<ToolPayload label="Result">{`Status: ${status}`}</ToolPayload>
|
|
60
|
+
</ToolSection>
|
|
61
|
+
</ToolContent>
|
|
62
|
+
</Tool>
|
|
63
|
+
))}
|
|
64
|
+
</div>
|
|
65
|
+
),
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
export const CustomStatusWording: Story = {
|
|
69
|
+
parameters: { controls: { disable: true } },
|
|
70
|
+
render: () => (
|
|
71
|
+
<Tool status="running">
|
|
72
|
+
<ToolHeader name="crawl_site" status="running" statusLabel="Fetching page 12 of 40" />
|
|
73
|
+
<ToolContent>
|
|
74
|
+
<ToolSection label="Progress">
|
|
75
|
+
<ToolPayload label="Progress">Crawling https://example.org…</ToolPayload>
|
|
76
|
+
</ToolSection>
|
|
77
|
+
</ToolContent>
|
|
78
|
+
</Tool>
|
|
79
|
+
),
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export const Failed: Story = {
|
|
83
|
+
parameters: { controls: { disable: true } },
|
|
84
|
+
render: () => (
|
|
85
|
+
<Tool status="error" defaultOpen>
|
|
86
|
+
<ToolHeader name="read_file" status="error" />
|
|
87
|
+
<ToolContent>
|
|
88
|
+
<ToolSection label="Error">
|
|
89
|
+
<ToolPayload label="Error">
|
|
90
|
+
{"ENOENT: no such file or directory, open '/app/missing.ts'"}
|
|
91
|
+
</ToolPayload>
|
|
92
|
+
</ToolSection>
|
|
93
|
+
</ToolContent>
|
|
94
|
+
</Tool>
|
|
95
|
+
),
|
|
96
|
+
};
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { render, screen, waitFor } from "@testing-library/react";
|
|
2
|
+
import userEvent from "@testing-library/user-event";
|
|
3
|
+
import { describe, expect, it } from "vitest";
|
|
4
|
+
|
|
5
|
+
import { expectNoA11yViolations } from "../../../test/a11y";
|
|
6
|
+
import {
|
|
7
|
+
Tool,
|
|
8
|
+
ToolContent,
|
|
9
|
+
ToolHeader,
|
|
10
|
+
ToolPayload,
|
|
11
|
+
ToolSection,
|
|
12
|
+
type ToolStatus,
|
|
13
|
+
} from "./ai-tool";
|
|
14
|
+
|
|
15
|
+
function Example({ status = "success" }: { status?: ToolStatus } = {}) {
|
|
16
|
+
return (
|
|
17
|
+
<Tool status={status}>
|
|
18
|
+
<ToolHeader name="search_web" status={status} />
|
|
19
|
+
<ToolContent>
|
|
20
|
+
<ToolSection label="Arguments">
|
|
21
|
+
<ToolPayload label="Arguments">{'{ "query": "capital of France" }'}</ToolPayload>
|
|
22
|
+
</ToolSection>
|
|
23
|
+
<ToolSection label="Result">
|
|
24
|
+
<ToolPayload label="Result">{'{ "answer": "Paris" }'}</ToolPayload>
|
|
25
|
+
</ToolSection>
|
|
26
|
+
</ToolContent>
|
|
27
|
+
</Tool>
|
|
28
|
+
);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
describe("Tool", () => {
|
|
32
|
+
it("is collapsed by default, because provenance is not the answer", () => {
|
|
33
|
+
render(<Example />);
|
|
34
|
+
expect(screen.getByRole("button", { name: /search_web/ })).toHaveAttribute(
|
|
35
|
+
"aria-expanded",
|
|
36
|
+
"false",
|
|
37
|
+
);
|
|
38
|
+
expect(screen.queryByText(/capital of France/)).not.toBeInTheDocument();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("opens on click", async () => {
|
|
42
|
+
const user = userEvent.setup();
|
|
43
|
+
render(<Example />);
|
|
44
|
+
|
|
45
|
+
await user.click(screen.getByRole("button", { name: /search_web/ }));
|
|
46
|
+
expect(await screen.findByText(/capital of France/)).toBeInTheDocument();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("opens from the keyboard", async () => {
|
|
50
|
+
const user = userEvent.setup();
|
|
51
|
+
render(<Example />);
|
|
52
|
+
|
|
53
|
+
await user.tab();
|
|
54
|
+
await user.keyboard("{Enter}");
|
|
55
|
+
await waitFor(() => {
|
|
56
|
+
expect(screen.getByRole("button", { name: /search_web/ })).toHaveAttribute(
|
|
57
|
+
"aria-expanded",
|
|
58
|
+
"true",
|
|
59
|
+
);
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it.each([
|
|
64
|
+
["pending", "Queued"],
|
|
65
|
+
["running", "Running"],
|
|
66
|
+
["success", "Completed"],
|
|
67
|
+
["error", "Failed"],
|
|
68
|
+
] as const)("states the %s status in words, not only in colour", (status, label) => {
|
|
69
|
+
render(<Example status={status} />);
|
|
70
|
+
// A coloured dot says nothing to a screen reader, and nothing to anyone who
|
|
71
|
+
// cannot distinguish the colours.
|
|
72
|
+
expect(screen.getByRole("button", { name: new RegExp(label) })).toBeInTheDocument();
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
it("accepts custom status wording", () => {
|
|
76
|
+
render(
|
|
77
|
+
<Tool status="running">
|
|
78
|
+
<ToolHeader name="fetch" status="running" statusLabel="Fetching page 2 of 5" />
|
|
79
|
+
<ToolContent>Body</ToolContent>
|
|
80
|
+
</Tool>,
|
|
81
|
+
);
|
|
82
|
+
expect(screen.getByText("Fetching page 2 of 5")).toBeInTheDocument();
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it("marks the status for styling", () => {
|
|
86
|
+
const { container } = render(<Example status="error" />);
|
|
87
|
+
expect(container.querySelector("[data-slot='tool']")).toHaveAttribute(
|
|
88
|
+
"data-status",
|
|
89
|
+
"error",
|
|
90
|
+
);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
it("makes payloads focusable named regions", async () => {
|
|
94
|
+
const user = userEvent.setup();
|
|
95
|
+
render(<Example />);
|
|
96
|
+
|
|
97
|
+
await user.click(screen.getByRole("button", { name: /search_web/ }));
|
|
98
|
+
|
|
99
|
+
// JSON scrolls, and a scroll box that cannot take focus is unreachable by
|
|
100
|
+
// keyboard.
|
|
101
|
+
const payload = await screen.findByRole("region", { name: "Arguments" });
|
|
102
|
+
expect(payload).toHaveAttribute("tabindex", "0");
|
|
103
|
+
});
|
|
104
|
+
|
|
105
|
+
it("labels each section", async () => {
|
|
106
|
+
const user = userEvent.setup();
|
|
107
|
+
render(<Example />);
|
|
108
|
+
|
|
109
|
+
await user.click(screen.getByRole("button", { name: /search_web/ }));
|
|
110
|
+
expect(await screen.findByText("Arguments")).toBeInTheDocument();
|
|
111
|
+
expect(screen.getByText("Result")).toBeInTheDocument();
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("can be opened by default", () => {
|
|
115
|
+
render(
|
|
116
|
+
<Tool status="success" defaultOpen>
|
|
117
|
+
<ToolHeader name="read_file" status="success" />
|
|
118
|
+
<ToolContent>Contents</ToolContent>
|
|
119
|
+
</Tool>,
|
|
120
|
+
);
|
|
121
|
+
expect(screen.getByText("Contents")).toBeInTheDocument();
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
it("has no accessibility violations when open", async () => {
|
|
125
|
+
const { container } = render(
|
|
126
|
+
<Tool status="success" defaultOpen>
|
|
127
|
+
<ToolHeader name="search_web" status="success" />
|
|
128
|
+
<ToolContent>
|
|
129
|
+
<ToolSection label="Result">
|
|
130
|
+
<ToolPayload label="Result">{'{ "answer": "Paris" }'}</ToolPayload>
|
|
131
|
+
</ToolSection>
|
|
132
|
+
</ToolContent>
|
|
133
|
+
</Tool>,
|
|
134
|
+
);
|
|
135
|
+
await expectNoA11yViolations(container);
|
|
136
|
+
});
|
|
137
|
+
});
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import { cva, type VariantProps } from "class-variance-authority";
|
|
4
|
+
import { Collapsible as CollapsiblePrimitive } from "radix-ui";
|
|
5
|
+
import type { ComponentPropsWithRef, ReactNode } from "react";
|
|
6
|
+
|
|
7
|
+
import { focusRing } from "@/lib/styles";
|
|
8
|
+
import { cn } from "@/lib/utils";
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* A tool the model called, and what came back.
|
|
12
|
+
*
|
|
13
|
+
* Collapsed by default: a tool call is provenance, not the answer. Someone
|
|
14
|
+
* checking why a response says what it does needs to open it; everybody else
|
|
15
|
+
* needs it to stay out of the way.
|
|
16
|
+
*
|
|
17
|
+
* The status is the whole point of the header, so it is text, never a coloured
|
|
18
|
+
* dot alone.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
export type ToolStatus = "pending" | "running" | "success" | "error";
|
|
22
|
+
|
|
23
|
+
const STATUS_LABEL: Record<ToolStatus, string> = {
|
|
24
|
+
pending: "Queued",
|
|
25
|
+
running: "Running",
|
|
26
|
+
success: "Completed",
|
|
27
|
+
error: "Failed",
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const toolVariants = cva("overflow-hidden rounded-lg border text-sm", {
|
|
31
|
+
variants: {
|
|
32
|
+
status: {
|
|
33
|
+
pending: "border-border bg-muted/30",
|
|
34
|
+
running: "border-info/30 bg-info/5",
|
|
35
|
+
success: "border-border bg-muted/30",
|
|
36
|
+
error: "border-destructive/30 bg-destructive/5",
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
defaultVariants: {
|
|
40
|
+
status: "pending",
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
export interface ToolProps
|
|
45
|
+
extends
|
|
46
|
+
ComponentPropsWithRef<typeof CollapsiblePrimitive.Root>,
|
|
47
|
+
VariantProps<typeof toolVariants> {
|
|
48
|
+
status?: ToolStatus;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function Tool({ className, status = "pending", ...props }: ToolProps) {
|
|
52
|
+
return (
|
|
53
|
+
<CollapsiblePrimitive.Root
|
|
54
|
+
data-slot="tool"
|
|
55
|
+
data-status={status}
|
|
56
|
+
className={cn(toolVariants({ status }), className)}
|
|
57
|
+
{...props}
|
|
58
|
+
/>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface ToolHeaderProps extends ComponentPropsWithRef<
|
|
63
|
+
typeof CollapsiblePrimitive.Trigger
|
|
64
|
+
> {
|
|
65
|
+
/** The tool's name, as the model called it. */
|
|
66
|
+
name: string;
|
|
67
|
+
status?: ToolStatus;
|
|
68
|
+
/** Overrides the status wording. */
|
|
69
|
+
statusLabel?: string;
|
|
70
|
+
icon?: ReactNode;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export function ToolHeader({
|
|
74
|
+
className,
|
|
75
|
+
name,
|
|
76
|
+
status = "pending",
|
|
77
|
+
statusLabel,
|
|
78
|
+
icon,
|
|
79
|
+
...props
|
|
80
|
+
}: ToolHeaderProps) {
|
|
81
|
+
return (
|
|
82
|
+
<CollapsiblePrimitive.Trigger
|
|
83
|
+
data-slot="tool-header"
|
|
84
|
+
className={cn(
|
|
85
|
+
"flex w-full items-center gap-2 px-3 py-2 text-left",
|
|
86
|
+
"transition-colors duration-[var(--duration-fast)] hover:bg-accent/50",
|
|
87
|
+
"[&[data-state=open]>svg:last-child]:rotate-180",
|
|
88
|
+
focusRing,
|
|
89
|
+
className,
|
|
90
|
+
)}
|
|
91
|
+
{...props}
|
|
92
|
+
>
|
|
93
|
+
{icon ?? <ToolIcon status={status} />}
|
|
94
|
+
<span className="font-mono text-xs font-medium">{name}</span>
|
|
95
|
+
{/* Status in words. A coloured dot alone says nothing to a screen reader
|
|
96
|
+
and nothing to anyone who cannot distinguish the colours. */}
|
|
97
|
+
<span
|
|
98
|
+
data-slot="tool-status"
|
|
99
|
+
className={cn(
|
|
100
|
+
"ml-auto text-xs",
|
|
101
|
+
status === "error" ? "text-destructive" : "text-muted-foreground",
|
|
102
|
+
)}
|
|
103
|
+
>
|
|
104
|
+
{statusLabel ?? STATUS_LABEL[status]}
|
|
105
|
+
</span>
|
|
106
|
+
<svg
|
|
107
|
+
viewBox="0 0 24 24"
|
|
108
|
+
fill="none"
|
|
109
|
+
aria-hidden="true"
|
|
110
|
+
className="size-3.5 shrink-0 text-muted-foreground transition-transform duration-[var(--duration-normal)]"
|
|
111
|
+
>
|
|
112
|
+
<path
|
|
113
|
+
d="m6 9 6 6 6-6"
|
|
114
|
+
stroke="currentColor"
|
|
115
|
+
strokeWidth="2"
|
|
116
|
+
strokeLinecap="round"
|
|
117
|
+
strokeLinejoin="round"
|
|
118
|
+
/>
|
|
119
|
+
</svg>
|
|
120
|
+
</CollapsiblePrimitive.Trigger>
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
function ToolIcon({ status }: { status: ToolStatus }) {
|
|
125
|
+
if (status === "running") {
|
|
126
|
+
return (
|
|
127
|
+
<svg
|
|
128
|
+
viewBox="0 0 24 24"
|
|
129
|
+
fill="none"
|
|
130
|
+
aria-hidden="true"
|
|
131
|
+
className="size-3.5 shrink-0 animate-spin text-info"
|
|
132
|
+
>
|
|
133
|
+
<circle cx="12" cy="12" r="9" stroke="currentColor" strokeWidth="2.5" opacity="0.25" />
|
|
134
|
+
<path
|
|
135
|
+
d="M12 3a9 9 0 0 1 9 9"
|
|
136
|
+
stroke="currentColor"
|
|
137
|
+
strokeWidth="2.5"
|
|
138
|
+
strokeLinecap="round"
|
|
139
|
+
/>
|
|
140
|
+
</svg>
|
|
141
|
+
);
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return (
|
|
145
|
+
<svg
|
|
146
|
+
viewBox="0 0 24 24"
|
|
147
|
+
fill="none"
|
|
148
|
+
aria-hidden="true"
|
|
149
|
+
className={cn(
|
|
150
|
+
"size-3.5 shrink-0",
|
|
151
|
+
status === "error" ? "text-destructive" : "text-muted-foreground",
|
|
152
|
+
)}
|
|
153
|
+
>
|
|
154
|
+
<path
|
|
155
|
+
d={
|
|
156
|
+
status === "success"
|
|
157
|
+
? "m5 13 4 4L19 7"
|
|
158
|
+
: status === "error"
|
|
159
|
+
? "M12 8v5m0 3h.01M10.3 4.3 2.6 18a2 2 0 0 0 1.7 3h15.4a2 2 0 0 0 1.7-3L13.7 4.3a2 2 0 0 0-3.4 0Z"
|
|
160
|
+
: "M14.7 6.3a4 4 0 0 1-5 5L5 16v3h3l4.7-4.7a4 4 0 0 1 5-5l-2.3 2.3"
|
|
161
|
+
}
|
|
162
|
+
stroke="currentColor"
|
|
163
|
+
strokeWidth="2"
|
|
164
|
+
strokeLinecap="round"
|
|
165
|
+
strokeLinejoin="round"
|
|
166
|
+
/>
|
|
167
|
+
</svg>
|
|
168
|
+
);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
export function ToolContent({
|
|
172
|
+
className,
|
|
173
|
+
...props
|
|
174
|
+
}: ComponentPropsWithRef<typeof CollapsiblePrimitive.Content>) {
|
|
175
|
+
return (
|
|
176
|
+
<CollapsiblePrimitive.Content
|
|
177
|
+
data-slot="tool-content"
|
|
178
|
+
className={cn(
|
|
179
|
+
"overflow-hidden border-t border-border",
|
|
180
|
+
"data-[state=closed]:animate-accordion-close data-[state=open]:animate-accordion-open",
|
|
181
|
+
className,
|
|
182
|
+
)}
|
|
183
|
+
{...props}
|
|
184
|
+
/>
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export interface ToolSectionProps extends ComponentPropsWithRef<"div"> {
|
|
189
|
+
label: string;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
/** A labelled block inside the disclosure: the arguments, or the result. */
|
|
193
|
+
export function ToolSection({ className, label, children, ...props }: ToolSectionProps) {
|
|
194
|
+
return (
|
|
195
|
+
<div
|
|
196
|
+
data-slot="tool-section"
|
|
197
|
+
className={cn("border-b border-border/60 px-3 py-2 last:border-b-0", className)}
|
|
198
|
+
{...props}
|
|
199
|
+
>
|
|
200
|
+
<p className="mb-1 text-2xs font-medium tracking-wide text-muted-foreground uppercase">
|
|
201
|
+
{label}
|
|
202
|
+
</p>
|
|
203
|
+
{children}
|
|
204
|
+
</div>
|
|
205
|
+
);
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Serialised arguments or output.
|
|
210
|
+
*
|
|
211
|
+
* A `<pre>` with a tabindex, because JSON of any size scrolls and a scrollable
|
|
212
|
+
* box that cannot be focused is unreachable by keyboard.
|
|
213
|
+
*/
|
|
214
|
+
export interface ToolPayloadProps extends ComponentPropsWithRef<"pre"> {
|
|
215
|
+
label?: string;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export function ToolPayload({ className, label = "Payload", ...props }: ToolPayloadProps) {
|
|
219
|
+
return (
|
|
220
|
+
<pre
|
|
221
|
+
data-slot="tool-payload"
|
|
222
|
+
tabIndex={0}
|
|
223
|
+
role="region"
|
|
224
|
+
aria-label={label}
|
|
225
|
+
className={cn(
|
|
226
|
+
"max-h-56 overflow-auto rounded-md bg-muted/60 p-2 font-mono text-xs leading-relaxed",
|
|
227
|
+
focusRing,
|
|
228
|
+
className,
|
|
229
|
+
)}
|
|
230
|
+
{...props}
|
|
231
|
+
/>
|
|
232
|
+
);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export { toolVariants };
|