@tetrascience-npm/tetrascience-react-ui 0.7.0-beta.108.1 → 0.7.0-beta.128.1
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/README.md +2 -2
- package/dist/components/ai/chain-of-thought.cjs +1 -1
- package/dist/components/ai/chain-of-thought.cjs.map +1 -1
- package/dist/components/ai/chain-of-thought.js +1 -1
- package/dist/components/ai/chain-of-thought.js.map +1 -1
- package/dist/components/ai/confirmation.cjs +1 -1
- package/dist/components/ai/confirmation.cjs.map +1 -1
- package/dist/components/ai/confirmation.js +1 -1
- package/dist/components/ai/confirmation.js.map +1 -1
- package/dist/components/ai/context.cjs +1 -1
- package/dist/components/ai/context.cjs.map +1 -1
- package/dist/components/ai/context.js +36 -35
- package/dist/components/ai/context.js.map +1 -1
- package/dist/components/ai/message.cjs +1 -1
- package/dist/components/ai/message.cjs.map +1 -1
- package/dist/components/ai/message.js +68 -68
- package/dist/components/ai/message.js.map +1 -1
- package/dist/components/ai/prompt-input.cjs +1 -1
- package/dist/components/ai/prompt-input.cjs.map +1 -1
- package/dist/components/ai/prompt-input.js +4 -2
- package/dist/components/ai/prompt-input.js.map +1 -1
- package/dist/components/ai/queue.cjs +1 -1
- package/dist/components/ai/queue.cjs.map +1 -1
- package/dist/components/ai/queue.js +9 -9
- package/dist/components/ai/queue.js.map +1 -1
- package/dist/components/ai/reasoning.cjs +1 -1
- package/dist/components/ai/reasoning.cjs.map +1 -1
- package/dist/components/ai/reasoning.js +67 -67
- package/dist/components/ai/reasoning.js.map +1 -1
- package/dist/components/ai/stream-status.cjs +1 -1
- package/dist/components/ai/stream-status.cjs.map +1 -1
- package/dist/components/ai/stream-status.js +41 -39
- package/dist/components/ai/stream-status.js.map +1 -1
- package/dist/components/ai/streamdown-code-plugin.cjs +2 -0
- package/dist/components/ai/streamdown-code-plugin.cjs.map +1 -0
- package/dist/components/ai/streamdown-code-plugin.js +42 -0
- package/dist/components/ai/streamdown-code-plugin.js.map +1 -0
- package/dist/components/ai/streamdown-plugins.cjs +2 -0
- package/dist/components/ai/streamdown-plugins.cjs.map +1 -0
- package/dist/components/ai/streamdown-plugins.js +14 -0
- package/dist/components/ai/streamdown-plugins.js.map +1 -0
- package/dist/components/ai/task.cjs +1 -1
- package/dist/components/ai/task.cjs.map +1 -1
- package/dist/components/ai/task.js +18 -11
- package/dist/components/ai/task.js.map +1 -1
- package/dist/components/ai/tool.cjs +1 -1
- package/dist/components/ai/tool.cjs.map +1 -1
- package/dist/components/ai/tool.js +51 -55
- package/dist/components/ai/tool.js.map +1 -1
- package/dist/components/ai/use-streamdown-plugins.cjs +2 -0
- package/dist/components/ai/use-streamdown-plugins.cjs.map +1 -0
- package/dist/components/ai/use-streamdown-plugins.js +25 -0
- package/dist/components/ai/use-streamdown-plugins.js.map +1 -0
- package/dist/components/charts/AreaPlot/AreaPlot.cjs +2 -0
- package/dist/components/charts/AreaPlot/AreaPlot.cjs.map +1 -0
- package/dist/components/charts/AreaPlot/AreaPlot.js +270 -0
- package/dist/components/charts/AreaPlot/AreaPlot.js.map +1 -0
- package/dist/components/charts/BarChart/BarChart.cjs +2 -0
- package/dist/components/charts/BarChart/BarChart.cjs.map +1 -0
- package/dist/components/charts/BarChart/BarChart.js +219 -0
- package/dist/components/charts/BarChart/BarChart.js.map +1 -0
- package/dist/components/charts/BoxPlot/BoxPlot.cjs +2 -0
- package/dist/components/charts/BoxPlot/BoxPlot.cjs.map +1 -0
- package/dist/components/charts/{Boxplot/Boxplot.js → BoxPlot/BoxPlot.js} +78 -79
- package/dist/components/charts/BoxPlot/BoxPlot.js.map +1 -0
- package/dist/components/charts/ChartTooltip/ChartTooltip.cjs +1 -1
- package/dist/components/charts/ChartTooltip/ChartTooltip.cjs.map +1 -1
- package/dist/components/charts/ChartTooltip/ChartTooltip.js +22 -22
- package/dist/components/charts/ChartTooltip/ChartTooltip.js.map +1 -1
- package/dist/components/charts/Chromatogram/Chromatogram.cjs +1 -1
- package/dist/components/charts/Chromatogram/Chromatogram.cjs.map +1 -1
- package/dist/components/charts/Chromatogram/Chromatogram.js +232 -170
- package/dist/components/charts/Chromatogram/Chromatogram.js.map +1 -1
- package/dist/components/charts/Chromatogram/annotations.cjs +2 -0
- package/dist/components/charts/Chromatogram/annotations.cjs.map +1 -0
- package/dist/components/charts/Chromatogram/annotations.js +137 -0
- package/dist/components/charts/Chromatogram/annotations.js.map +1 -0
- package/dist/components/charts/Chromatogram/boundaryMarkers.cjs.map +1 -0
- package/dist/components/charts/Chromatogram/boundaryMarkers.js.map +1 -0
- package/dist/components/charts/Chromatogram/constants.cjs.map +1 -0
- package/dist/components/charts/Chromatogram/constants.js.map +1 -0
- package/dist/components/charts/Chromatogram/dataProcessing.cjs.map +1 -0
- package/dist/components/charts/Chromatogram/dataProcessing.js.map +1 -0
- package/dist/components/charts/Chromatogram/peakDetection.cjs.map +1 -0
- package/dist/components/charts/Chromatogram/peakDetection.js.map +1 -0
- package/dist/components/charts/Chromatogram/plotBuilder.cjs +2 -0
- package/dist/components/charts/Chromatogram/plotBuilder.cjs.map +1 -0
- package/dist/components/charts/Chromatogram/plotBuilder.js +216 -0
- package/dist/components/charts/Chromatogram/plotBuilder.js.map +1 -0
- package/dist/components/charts/Chromatogram/regionOverlays.cjs.map +1 -0
- package/dist/components/charts/Chromatogram/regionOverlays.js.map +1 -0
- package/dist/components/charts/Electropherogram/Electropherogram.cjs +2 -0
- package/dist/components/charts/Electropherogram/Electropherogram.cjs.map +1 -0
- package/dist/components/charts/Electropherogram/Electropherogram.js +180 -0
- package/dist/components/charts/Electropherogram/Electropherogram.js.map +1 -0
- package/dist/components/charts/Histogram/Histogram.cjs +1 -1
- package/dist/components/charts/Histogram/Histogram.cjs.map +1 -1
- package/dist/components/charts/Histogram/Histogram.js +107 -108
- package/dist/components/charts/Histogram/Histogram.js.map +1 -1
- package/dist/components/charts/LinePlot/LinePlot.cjs +2 -0
- package/dist/components/charts/LinePlot/LinePlot.cjs.map +1 -0
- package/dist/components/charts/LinePlot/LinePlot.js +224 -0
- package/dist/components/charts/LinePlot/LinePlot.js.map +1 -0
- package/dist/components/charts/PieChart/PieChart.cjs +1 -1
- package/dist/components/charts/PieChart/PieChart.cjs.map +1 -1
- package/dist/components/charts/PieChart/PieChart.js +62 -61
- package/dist/components/charts/PieChart/PieChart.js.map +1 -1
- package/dist/components/charts/PlateMap/PlateMap.cjs +1 -1
- package/dist/components/charts/PlateMap/PlateMap.cjs.map +1 -1
- package/dist/components/charts/PlateMap/PlateMap.js +246 -242
- package/dist/components/charts/PlateMap/PlateMap.js.map +1 -1
- package/dist/components/charts/ScatterPlot/ScatterPlot.cjs +2 -0
- package/dist/components/charts/ScatterPlot/ScatterPlot.cjs.map +1 -0
- package/dist/components/charts/ScatterPlot/ScatterPlot.js +252 -0
- package/dist/components/charts/ScatterPlot/ScatterPlot.js.map +1 -0
- package/dist/components/charts/ScatterPlotInteractive/ScatterPlotInteractive.cjs +2 -0
- package/dist/components/charts/ScatterPlotInteractive/ScatterPlotInteractive.cjs.map +1 -0
- package/dist/components/charts/ScatterPlotInteractive/ScatterPlotInteractive.js +215 -0
- package/dist/components/charts/ScatterPlotInteractive/ScatterPlotInteractive.js.map +1 -0
- package/dist/components/charts/ScatterPlotInteractive/constants.cjs +2 -0
- package/dist/components/charts/ScatterPlotInteractive/constants.cjs.map +1 -0
- package/dist/components/charts/ScatterPlotInteractive/constants.js +38 -0
- package/dist/components/charts/ScatterPlotInteractive/constants.js.map +1 -0
- package/dist/components/charts/ScatterPlotInteractive/utils.cjs +2 -0
- package/dist/components/charts/ScatterPlotInteractive/utils.cjs.map +1 -0
- package/dist/components/charts/ScatterPlotInteractive/utils.js +261 -0
- package/dist/components/charts/ScatterPlotInteractive/utils.js.map +1 -0
- package/dist/components/charts/StackedChromatogram/StackedChromatogram.cjs +2 -0
- package/dist/components/charts/StackedChromatogram/StackedChromatogram.cjs.map +1 -0
- package/dist/components/charts/StackedChromatogram/StackedChromatogram.js +40 -0
- package/dist/components/charts/StackedChromatogram/StackedChromatogram.js.map +1 -0
- package/dist/components/charts/StackedChromatogram/transforms.cjs.map +1 -0
- package/dist/components/charts/StackedChromatogram/transforms.js.map +1 -0
- package/dist/components/charts/plotly-loader.cjs +2 -0
- package/dist/components/charts/plotly-loader.cjs.map +1 -0
- package/dist/components/charts/plotly-loader.js +22 -0
- package/dist/components/charts/plotly-loader.js.map +1 -0
- package/dist/components/composed/AssistantLayout/AssistantLayout.cjs +2 -0
- package/dist/components/composed/AssistantLayout/AssistantLayout.cjs.map +1 -0
- package/dist/components/composed/AssistantLayout/AssistantLayout.js +142 -0
- package/dist/components/composed/AssistantLayout/AssistantLayout.js.map +1 -0
- package/dist/components/composed/AssistantLayout/dockLayout.cjs +2 -0
- package/dist/components/composed/AssistantLayout/dockLayout.cjs.map +1 -0
- package/dist/components/composed/AssistantLayout/dockLayout.js +10 -0
- package/dist/components/composed/AssistantLayout/dockLayout.js.map +1 -0
- package/dist/components/composed/Chat/Chat.cjs +1 -1
- package/dist/components/composed/Chat/Chat.cjs.map +1 -1
- package/dist/components/composed/Chat/Chat.js +23 -23
- package/dist/components/composed/Chat/Chat.js.map +1 -1
- package/dist/components/composed/ConfirmDialog/ConfirmDialog.cjs +1 -1
- package/dist/components/composed/ConfirmDialog/ConfirmDialog.cjs.map +1 -1
- package/dist/components/composed/ConfirmDialog/ConfirmDialog.js +33 -29
- package/dist/components/composed/ConfirmDialog/ConfirmDialog.js.map +1 -1
- package/dist/components/composed/DataAppShell/CollapseButton.cjs +2 -0
- package/dist/components/composed/DataAppShell/CollapseButton.cjs.map +1 -0
- package/dist/components/composed/DataAppShell/CollapseButton.js +42 -0
- package/dist/components/composed/DataAppShell/CollapseButton.js.map +1 -0
- package/dist/components/composed/DataAppShell/DataAppShell.cjs +1 -1
- package/dist/components/composed/DataAppShell/DataAppShell.cjs.map +1 -1
- package/dist/components/composed/DataAppShell/DataAppShell.js +349 -313
- package/dist/components/composed/DataAppShell/DataAppShell.js.map +1 -1
- package/dist/components/composed/DataAppShell/PrimaryNav.cjs +2 -0
- package/dist/components/composed/DataAppShell/PrimaryNav.cjs.map +1 -0
- package/dist/components/composed/DataAppShell/PrimaryNav.js +268 -0
- package/dist/components/composed/DataAppShell/PrimaryNav.js.map +1 -0
- package/dist/components/composed/DataAppShell/RightPanel.cjs +2 -0
- package/dist/components/composed/DataAppShell/RightPanel.cjs.map +1 -0
- package/dist/components/composed/DataAppShell/RightPanel.js +282 -0
- package/dist/components/composed/DataAppShell/RightPanel.js.map +1 -0
- package/dist/components/composed/DataAppShell/SecondaryNav.cjs +2 -0
- package/dist/components/composed/DataAppShell/SecondaryNav.cjs.map +1 -0
- package/dist/components/composed/DataAppShell/SecondaryNav.js +364 -0
- package/dist/components/composed/DataAppShell/SecondaryNav.js.map +1 -0
- package/dist/components/composed/DataAppShell/ShellContext.cjs +2 -0
- package/dist/components/composed/DataAppShell/ShellContext.cjs.map +1 -0
- package/dist/components/composed/DataAppShell/ShellContext.js +23 -0
- package/dist/components/composed/DataAppShell/ShellContext.js.map +1 -0
- package/dist/components/composed/MoleculeStructure/MoleculeStructure.cjs +2 -0
- package/dist/components/composed/MoleculeStructure/MoleculeStructure.cjs.map +1 -0
- package/dist/components/composed/MoleculeStructure/MoleculeStructure.js +87 -0
- package/dist/components/composed/MoleculeStructure/MoleculeStructure.js.map +1 -0
- package/dist/components/composed/MoleculeStructure/rdkit-loader.cjs +2 -0
- package/dist/components/composed/MoleculeStructure/rdkit-loader.cjs.map +1 -0
- package/dist/components/composed/MoleculeStructure/rdkit-loader.js +89 -0
- package/dist/components/composed/MoleculeStructure/rdkit-loader.js.map +1 -0
- package/dist/components/composed/MoleculeStructure/use-rdkit.cjs +2 -0
- package/dist/components/composed/MoleculeStructure/use-rdkit.cjs.map +1 -0
- package/dist/components/composed/MoleculeStructure/use-rdkit.js +19 -0
- package/dist/components/composed/MoleculeStructure/use-rdkit.js.map +1 -0
- package/dist/components/composed/PlateMapEditor/ManifestFilterPopover.cjs +1 -1
- package/dist/components/composed/PlateMapEditor/ManifestFilterPopover.cjs.map +1 -1
- package/dist/components/composed/PlateMapEditor/ManifestFilterPopover.js +17 -17
- package/dist/components/composed/PlateMapEditor/ManifestFilterPopover.js.map +1 -1
- package/dist/components/composed/PlateMapEditor/PlateMapActionsMenu.cjs +1 -1
- package/dist/components/composed/PlateMapEditor/PlateMapActionsMenu.cjs.map +1 -1
- package/dist/components/composed/PlateMapEditor/PlateMapActionsMenu.js +33 -33
- package/dist/components/composed/PlateMapEditor/PlateMapActionsMenu.js.map +1 -1
- package/dist/components/composed/PlateMapEditor/PlateMapPlateSelector.cjs +1 -1
- package/dist/components/composed/PlateMapEditor/PlateMapPlateSelector.cjs.map +1 -1
- package/dist/components/composed/PlateMapEditor/PlateMapPlateSelector.js +7 -7
- package/dist/components/composed/PlateMapEditor/PlateMapPlateSelector.js.map +1 -1
- package/dist/components/composed/PlateMapEditor/PlatePaintGrid.cjs +1 -1
- package/dist/components/composed/PlateMapEditor/PlatePaintGrid.cjs.map +1 -1
- package/dist/components/composed/PlateMapEditor/PlatePaintGrid.js +1 -1
- package/dist/components/composed/PlateMapEditor/PlatePaintGrid.js.map +1 -1
- package/dist/components/composed/PlateMapEditor/WellLegend.cjs +1 -1
- package/dist/components/composed/PlateMapEditor/WellLegend.cjs.map +1 -1
- package/dist/components/composed/PlateMapEditor/WellLegend.js +24 -12
- package/dist/components/composed/PlateMapEditor/WellLegend.js.map +1 -1
- package/dist/components/composed/PlateMapEditor/WellManifestTable.cjs +1 -1
- package/dist/components/composed/PlateMapEditor/WellManifestTable.cjs.map +1 -1
- package/dist/components/composed/PlateMapEditor/WellManifestTable.js +1 -1
- package/dist/components/composed/PlateMapEditor/WellManifestTable.js.map +1 -1
- package/dist/components/composed/TdpSearch/components/DefaultFilters.cjs +1 -1
- package/dist/components/composed/TdpSearch/components/DefaultFilters.cjs.map +1 -1
- package/dist/components/composed/TdpSearch/components/DefaultFilters.js +3 -3
- package/dist/components/composed/TdpSearch/components/DefaultFilters.js.map +1 -1
- package/dist/components/composed/TopBar/TopBar.cjs +2 -0
- package/dist/components/composed/TopBar/TopBar.cjs.map +1 -0
- package/dist/components/composed/TopBar/TopBar.js +56 -0
- package/dist/components/composed/TopBar/TopBar.js.map +1 -0
- package/dist/components/composed/UserMenu/UserMenu.cjs +2 -0
- package/dist/components/composed/UserMenu/UserMenu.cjs.map +1 -0
- package/dist/components/composed/UserMenu/UserMenu.js +99 -0
- package/dist/components/composed/UserMenu/UserMenu.js.map +1 -0
- package/dist/components/composed/tdp-link.cjs +1 -1
- package/dist/components/composed/tdp-link.cjs.map +1 -1
- package/dist/components/composed/tdp-link.js +5 -5
- package/dist/components/composed/tdp-link.js.map +1 -1
- package/dist/components/ui/alert.cjs +1 -1
- package/dist/components/ui/alert.cjs.map +1 -1
- package/dist/components/ui/alert.js +12 -12
- package/dist/components/ui/alert.js.map +1 -1
- package/dist/components/ui/badge.cjs +1 -1
- package/dist/components/ui/badge.cjs.map +1 -1
- package/dist/components/ui/badge.js +14 -14
- package/dist/components/ui/badge.js.map +1 -1
- package/dist/components/ui/banner.cjs +1 -1
- package/dist/components/ui/banner.cjs.map +1 -1
- package/dist/components/ui/banner.js +17 -17
- package/dist/components/ui/banner.js.map +1 -1
- package/dist/components/ui/button.cjs +1 -1
- package/dist/components/ui/button.cjs.map +1 -1
- package/dist/components/ui/button.js +16 -16
- package/dist/components/ui/button.js.map +1 -1
- package/dist/components/ui/calendar.cjs +1 -1
- package/dist/components/ui/calendar.cjs.map +1 -1
- package/dist/components/ui/calendar.js +3 -3
- package/dist/components/ui/calendar.js.map +1 -1
- package/dist/components/ui/code-block.cjs +3 -3
- package/dist/components/ui/code-block.cjs.map +1 -1
- package/dist/components/ui/code-block.js +136 -118
- package/dist/components/ui/code-block.js.map +1 -1
- package/dist/components/ui/code-editor.cjs +1 -1
- package/dist/components/ui/code-editor.cjs.map +1 -1
- package/dist/components/ui/code-editor.js +14 -12
- package/dist/components/ui/code-editor.js.map +1 -1
- package/dist/components/ui/combobox.cjs +1 -1
- package/dist/components/ui/combobox.cjs.map +1 -1
- package/dist/components/ui/combobox.js +33 -29
- package/dist/components/ui/combobox.js.map +1 -1
- package/dist/components/ui/command.cjs +1 -1
- package/dist/components/ui/command.cjs.map +1 -1
- package/dist/components/ui/command.js +81 -77
- package/dist/components/ui/command.js.map +1 -1
- package/dist/components/ui/context-menu.cjs +1 -1
- package/dist/components/ui/context-menu.cjs.map +1 -1
- package/dist/components/ui/context-menu.js +13 -13
- package/dist/components/ui/context-menu.js.map +1 -1
- package/dist/components/ui/data-table/data-table-column-toggle.cjs +1 -1
- package/dist/components/ui/data-table/data-table-column-toggle.cjs.map +1 -1
- package/dist/components/ui/data-table/data-table-column-toggle.js +70 -62
- package/dist/components/ui/data-table/data-table-column-toggle.js.map +1 -1
- package/dist/components/ui/data-table/data-table-filter.cjs +1 -1
- package/dist/components/ui/data-table/data-table-filter.cjs.map +1 -1
- package/dist/components/ui/data-table/data-table-filter.js +24 -23
- package/dist/components/ui/data-table/data-table-filter.js.map +1 -1
- package/dist/components/ui/data-table/data-table-group.cjs +1 -1
- package/dist/components/ui/data-table/data-table-group.cjs.map +1 -1
- package/dist/components/ui/data-table/data-table-group.js +17 -16
- package/dist/components/ui/data-table/data-table-group.js.map +1 -1
- package/dist/components/ui/data-table/data-table-pagination.cjs +1 -1
- package/dist/components/ui/data-table/data-table-pagination.cjs.map +1 -1
- package/dist/components/ui/data-table/data-table-pagination.js +15 -15
- package/dist/components/ui/data-table/data-table-pagination.js.map +1 -1
- package/dist/components/ui/data-table/data-table.cjs +1 -1
- package/dist/components/ui/data-table/data-table.cjs.map +1 -1
- package/dist/components/ui/data-table/data-table.js +191 -190
- package/dist/components/ui/data-table/data-table.js.map +1 -1
- package/dist/components/ui/dialog.cjs +1 -1
- package/dist/components/ui/dialog.cjs.map +1 -1
- package/dist/components/ui/dialog.js +1 -1
- package/dist/components/ui/dialog.js.map +1 -1
- package/dist/components/ui/dropdown-menu.cjs +1 -1
- package/dist/components/ui/dropdown-menu.cjs.map +1 -1
- package/dist/components/ui/dropdown-menu.js +12 -4
- package/dist/components/ui/dropdown-menu.js.map +1 -1
- package/dist/components/ui/hover-card.cjs +1 -1
- package/dist/components/ui/hover-card.cjs.map +1 -1
- package/dist/components/ui/hover-card.js +3 -3
- package/dist/components/ui/hover-card.js.map +1 -1
- package/dist/components/ui/item.cjs +1 -1
- package/dist/components/ui/item.cjs.map +1 -1
- package/dist/components/ui/item.js +44 -36
- package/dist/components/ui/item.js.map +1 -1
- package/dist/components/ui/menubar.cjs +1 -1
- package/dist/components/ui/menubar.cjs.map +1 -1
- package/dist/components/ui/menubar.js +2 -2
- package/dist/components/ui/menubar.js.map +1 -1
- package/dist/components/ui/navigation-menu.cjs +1 -1
- package/dist/components/ui/navigation-menu.cjs.map +1 -1
- package/dist/components/ui/navigation-menu.js +1 -1
- package/dist/components/ui/navigation-menu.js.map +1 -1
- package/dist/components/ui/popover.cjs +1 -1
- package/dist/components/ui/popover.cjs.map +1 -1
- package/dist/components/ui/popover.js +1 -1
- package/dist/components/ui/popover.js.map +1 -1
- package/dist/components/ui/scroll-area.cjs +1 -1
- package/dist/components/ui/scroll-area.cjs.map +1 -1
- package/dist/components/ui/scroll-area.js +1 -0
- package/dist/components/ui/scroll-area.js.map +1 -1
- package/dist/components/ui/select.cjs +1 -1
- package/dist/components/ui/select.cjs.map +1 -1
- package/dist/components/ui/select.js +1 -1
- package/dist/components/ui/select.js.map +1 -1
- package/dist/components/ui/sheet.cjs +1 -1
- package/dist/components/ui/sheet.cjs.map +1 -1
- package/dist/components/ui/sheet.js +5 -5
- package/dist/components/ui/sheet.js.map +1 -1
- package/dist/components/ui/sidebar.cjs +1 -1
- package/dist/components/ui/sidebar.cjs.map +1 -1
- package/dist/components/ui/sidebar.js +2 -2
- package/dist/components/ui/sidebar.js.map +1 -1
- package/dist/components/ui/slider.cjs +1 -1
- package/dist/components/ui/slider.cjs.map +1 -1
- package/dist/components/ui/slider.js +10 -9
- package/dist/components/ui/slider.js.map +1 -1
- package/dist/components/ui/sonner.cjs +1 -1
- package/dist/components/ui/sonner.cjs.map +1 -1
- package/dist/components/ui/sonner.js +25 -10
- package/dist/components/ui/sonner.js.map +1 -1
- package/dist/components/ui/table.cjs +1 -1
- package/dist/components/ui/table.cjs.map +1 -1
- package/dist/components/ui/table.js +1 -0
- package/dist/components/ui/table.js.map +1 -1
- package/dist/components/ui/tabs.cjs +1 -1
- package/dist/components/ui/tabs.cjs.map +1 -1
- package/dist/components/ui/tabs.js +18 -18
- package/dist/components/ui/tabs.js.map +1 -1
- package/dist/components/ui/tetra-molecule-icon.cjs +2 -0
- package/dist/components/ui/tetra-molecule-icon.cjs.map +1 -0
- package/dist/components/ui/tetra-molecule-icon.js +49 -0
- package/dist/components/ui/tetra-molecule-icon.js.map +1 -0
- package/dist/components/ui/toggle-group.cjs +1 -1
- package/dist/components/ui/toggle-group.cjs.map +1 -1
- package/dist/components/ui/toggle-group.js +35 -31
- package/dist/components/ui/toggle-group.js.map +1 -1
- package/dist/hooks/use-plotly-theme.cjs +1 -1
- package/dist/hooks/use-plotly-theme.cjs.map +1 -1
- package/dist/hooks/use-plotly-theme.js +4 -3
- package/dist/hooks/use-plotly-theme.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.css +1 -1
- package/dist/index.d.ts +1073 -136
- package/dist/index.js +698 -647
- package/dist/index.js.map +1 -1
- package/dist/index.tailwind.css +1 -1
- package/dist/lib/shiki.cjs +2 -0
- package/dist/lib/shiki.cjs.map +1 -0
- package/dist/lib/shiki.js +72 -0
- package/dist/lib/shiki.js.map +1 -0
- package/package.json +23 -12
- package/dist/components/charts/AreaGraph/AreaGraph.cjs +0 -2
- package/dist/components/charts/AreaGraph/AreaGraph.cjs.map +0 -1
- package/dist/components/charts/AreaGraph/AreaGraph.js +0 -271
- package/dist/components/charts/AreaGraph/AreaGraph.js.map +0 -1
- package/dist/components/charts/BarGraph/BarGraph.cjs +0 -2
- package/dist/components/charts/BarGraph/BarGraph.cjs.map +0 -1
- package/dist/components/charts/BarGraph/BarGraph.js +0 -220
- package/dist/components/charts/BarGraph/BarGraph.js.map +0 -1
- package/dist/components/charts/Boxplot/Boxplot.cjs +0 -2
- package/dist/components/charts/Boxplot/Boxplot.cjs.map +0 -1
- package/dist/components/charts/Boxplot/Boxplot.js.map +0 -1
- package/dist/components/charts/ChromatogramChart/ChromatogramChart.cjs +0 -2
- package/dist/components/charts/ChromatogramChart/ChromatogramChart.cjs.map +0 -1
- package/dist/components/charts/ChromatogramChart/ChromatogramChart.js +0 -241
- package/dist/components/charts/ChromatogramChart/ChromatogramChart.js.map +0 -1
- package/dist/components/charts/ChromatogramChart/annotations.cjs +0 -2
- package/dist/components/charts/ChromatogramChart/annotations.cjs.map +0 -1
- package/dist/components/charts/ChromatogramChart/annotations.js +0 -136
- package/dist/components/charts/ChromatogramChart/annotations.js.map +0 -1
- package/dist/components/charts/ChromatogramChart/boundaryMarkers.cjs.map +0 -1
- package/dist/components/charts/ChromatogramChart/boundaryMarkers.js.map +0 -1
- package/dist/components/charts/ChromatogramChart/constants.cjs.map +0 -1
- package/dist/components/charts/ChromatogramChart/constants.js.map +0 -1
- package/dist/components/charts/ChromatogramChart/dataProcessing.cjs.map +0 -1
- package/dist/components/charts/ChromatogramChart/dataProcessing.js.map +0 -1
- package/dist/components/charts/ChromatogramChart/peakDetection.cjs.map +0 -1
- package/dist/components/charts/ChromatogramChart/peakDetection.js.map +0 -1
- package/dist/components/charts/ChromatogramChart/plotBuilder.cjs +0 -2
- package/dist/components/charts/ChromatogramChart/plotBuilder.cjs.map +0 -1
- package/dist/components/charts/ChromatogramChart/plotBuilder.js +0 -207
- package/dist/components/charts/ChromatogramChart/plotBuilder.js.map +0 -1
- package/dist/components/charts/ChromatogramChart/regionOverlays.cjs.map +0 -1
- package/dist/components/charts/ChromatogramChart/regionOverlays.js.map +0 -1
- package/dist/components/charts/DotPlot/DotPlot.cjs +0 -2
- package/dist/components/charts/DotPlot/DotPlot.cjs.map +0 -1
- package/dist/components/charts/DotPlot/DotPlot.js +0 -208
- package/dist/components/charts/DotPlot/DotPlot.js.map +0 -1
- package/dist/components/charts/Heatmap/Heatmap.cjs +0 -2
- package/dist/components/charts/Heatmap/Heatmap.cjs.map +0 -1
- package/dist/components/charts/Heatmap/Heatmap.js +0 -67
- package/dist/components/charts/Heatmap/Heatmap.js.map +0 -1
- package/dist/components/charts/LineGraph/LineGraph.cjs +0 -2
- package/dist/components/charts/LineGraph/LineGraph.cjs.map +0 -1
- package/dist/components/charts/LineGraph/LineGraph.js +0 -225
- package/dist/components/charts/LineGraph/LineGraph.js.map +0 -1
- package/dist/components/charts/ScatterGraph/ScatterGraph.cjs +0 -2
- package/dist/components/charts/ScatterGraph/ScatterGraph.cjs.map +0 -1
- package/dist/components/charts/ScatterGraph/ScatterGraph.js +0 -234
- package/dist/components/charts/ScatterGraph/ScatterGraph.js.map +0 -1
- package/dist/components/charts/StackedChromatogramChart/StackedChromatogramChart.cjs +0 -2
- package/dist/components/charts/StackedChromatogramChart/StackedChromatogramChart.cjs.map +0 -1
- package/dist/components/charts/StackedChromatogramChart/StackedChromatogramChart.js +0 -40
- package/dist/components/charts/StackedChromatogramChart/StackedChromatogramChart.js.map +0 -1
- package/dist/components/charts/StackedChromatogramChart/transforms.cjs.map +0 -1
- package/dist/components/charts/StackedChromatogramChart/transforms.js.map +0 -1
- /package/dist/components/charts/{ChromatogramChart → Chromatogram}/boundaryMarkers.cjs +0 -0
- /package/dist/components/charts/{ChromatogramChart → Chromatogram}/boundaryMarkers.js +0 -0
- /package/dist/components/charts/{ChromatogramChart → Chromatogram}/constants.cjs +0 -0
- /package/dist/components/charts/{ChromatogramChart → Chromatogram}/constants.js +0 -0
- /package/dist/components/charts/{ChromatogramChart → Chromatogram}/dataProcessing.cjs +0 -0
- /package/dist/components/charts/{ChromatogramChart → Chromatogram}/dataProcessing.js +0 -0
- /package/dist/components/charts/{ChromatogramChart → Chromatogram}/peakDetection.cjs +0 -0
- /package/dist/components/charts/{ChromatogramChart → Chromatogram}/peakDetection.js +0 -0
- /package/dist/components/charts/{ChromatogramChart → Chromatogram}/regionOverlays.cjs +0 -0
- /package/dist/components/charts/{ChromatogramChart → Chromatogram}/regionOverlays.js +0 -0
- /package/dist/components/charts/{StackedChromatogramChart → StackedChromatogram}/transforms.cjs +0 -0
- /package/dist/components/charts/{StackedChromatogramChart → StackedChromatogram}/transforms.js +0 -0
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../../lib/shiki.cjs"),r=["github-light","github-dark"],d=new Map,o=new Map,c=100,f=(e,l)=>{const s=e.slice(0,c),g=e.length>c?e.slice(-c):"";return`${l}:${e.length}:${s}:${g}`},C={name:"shiki",type:"code-highlighter",getSupportedLanguages:()=>i.getSupportedCodeBlockLanguages(),getThemes:()=>r,supportsLanguage:e=>i.resolveCodeBlockLanguage(e)!==null,highlight({code:e,language:l},s){const g=i.resolveCodeBlockLanguage(l)??"text",n=f(e,g),a=d.get(n);if(a)return a;if(s){let t=o.get(n);t||(t=new Set,o.set(n,t)),t.add(s)}return i.getCodeBlockHighlighter(g).then(({highlighter:t,lang:p})=>{const h=t.codeToTokens(e,{lang:p,themes:{dark:r[1],light:r[0]}});d.set(n,h);const u=o.get(n);if(u){for(const k of u)k(h);o.delete(n)}}).catch(t=>{console.error("Failed to highlight code:",t),o.delete(n)}),null}};exports.streamdownCodePlugin=C;
|
|
2
|
+
//# sourceMappingURL=streamdown-code-plugin.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streamdown-code-plugin.cjs","sources":["../../../src/components/ai/streamdown-code-plugin.ts"],"sourcesContent":["/**\n * Slim replacement for `@streamdown/code` (SW-2007).\n *\n * The upstream plugin statically imports the full \"shiki\" bundle (~200\n * grammars), landing a second full Shiki copy in every consumer build. This\n * plugin implements the same streamdown `CodeHighlighterPlugin` contract on\n * top of the shared slim highlighter in `@/lib/shiki`, so only the explicit\n * language set is bundled and every grammar arrives as a lazy chunk.\n */\n\nimport type { BundledLanguage } from \"shiki\";\nimport type { CodeHighlighterPlugin } from \"streamdown\";\n\nimport {\n getCodeBlockHighlighter,\n getSupportedCodeBlockLanguages,\n resolveCodeBlockLanguage,\n} from \"@/lib/shiki\";\n\ntype HighlightCallback = NonNullable<Parameters<CodeHighlighterPlugin[\"highlight\"]>[1]>;\ntype HighlightResult = Parameters<HighlightCallback>[0];\n\nconst THEMES: ReturnType<CodeHighlighterPlugin[\"getThemes\"]> = [\n \"github-light\",\n \"github-dark\",\n];\n\n// Highlighted-token cache + pending-callback registry, mirroring the\n// upstream plugin's sync-return/async-callback protocol: return cached\n// tokens synchronously, otherwise kick off highlighting and notify via the\n// callback when tokens are ready.\nconst resultsCache = new Map<string, HighlightResult>();\nconst subscribers = new Map<string, Set<HighlightCallback>>();\n\nconst KEY_SLICE_LENGTH = 100;\n\nconst cacheKey = (code: string, lang: string): string => {\n const head = code.slice(0, KEY_SLICE_LENGTH);\n const tail = code.length > KEY_SLICE_LENGTH ? code.slice(-KEY_SLICE_LENGTH) : \"\";\n return `${lang}:${code.length}:${head}:${tail}`;\n};\n\nexport const streamdownCodePlugin: CodeHighlighterPlugin = {\n name: \"shiki\",\n type: \"code-highlighter\",\n getSupportedLanguages: () => getSupportedCodeBlockLanguages() as BundledLanguage[],\n getThemes: () => THEMES,\n supportsLanguage: (language) => resolveCodeBlockLanguage(language) !== null,\n highlight({ code, language }, callback) {\n // Unsupported languages resolve to plaintext inside the shared\n // highlighter, so streaming still renders the raw code.\n const lang = resolveCodeBlockLanguage(language) ?? \"text\";\n const key = cacheKey(code, lang);\n\n const cached = resultsCache.get(key);\n if (cached) {\n return cached;\n }\n\n if (callback) {\n let pending = subscribers.get(key);\n if (!pending) {\n pending = new Set();\n subscribers.set(key, pending);\n }\n pending.add(callback);\n }\n\n getCodeBlockHighlighter(lang)\n .then(({ highlighter, lang: resolvedLang }) => {\n const result = highlighter.codeToTokens(code, {\n lang: resolvedLang,\n themes: { dark: THEMES[1], light: THEMES[0] },\n });\n resultsCache.set(key, result);\n const pending = subscribers.get(key);\n if (pending) {\n for (const notify of pending) {\n notify(result);\n }\n subscribers.delete(key);\n }\n })\n .catch((error: unknown) => {\n console.error(\"Failed to highlight code:\", error);\n subscribers.delete(key);\n });\n\n return null;\n },\n};\n"],"names":["THEMES","resultsCache","subscribers","KEY_SLICE_LENGTH","cacheKey","code","lang","head","tail","streamdownCodePlugin","getSupportedCodeBlockLanguages","language","resolveCodeBlockLanguage","callback","key","cached","pending","getCodeBlockHighlighter","highlighter","resolvedLang","result","notify","error"],"mappings":"uHAsBMA,EAAyD,CAC7D,eACA,aACF,EAMMC,MAAmB,IACnBC,MAAkB,IAElBC,EAAmB,IAEnBC,EAAW,CAACC,EAAcC,IAAyB,CACvD,MAAMC,EAAOF,EAAK,MAAM,EAAGF,CAAgB,EACrCK,EAAOH,EAAK,OAASF,EAAmBE,EAAK,MAAM,CAACF,CAAgB,EAAI,GAC9E,MAAO,GAAGG,CAAI,IAAID,EAAK,MAAM,IAAIE,CAAI,IAAIC,CAAI,EAC/C,EAEaC,EAA8C,CACzD,KAAM,QACN,KAAM,mBACN,sBAAuB,IAAMC,EAAAA,+BAAA,EAC7B,UAAW,IAAMV,EACjB,iBAAmBW,GAAaC,2BAAyBD,CAAQ,IAAM,KACvE,UAAU,CAAE,KAAAN,EAAM,SAAAM,CAAA,EAAYE,EAAU,CAGtC,MAAMP,EAAOM,EAAAA,yBAAyBD,CAAQ,GAAK,OAC7CG,EAAMV,EAASC,EAAMC,CAAI,EAEzBS,EAASd,EAAa,IAAIa,CAAG,EACnC,GAAIC,EACF,OAAOA,EAGT,GAAIF,EAAU,CACZ,IAAIG,EAAUd,EAAY,IAAIY,CAAG,EAC5BE,IACHA,MAAc,IACdd,EAAY,IAAIY,EAAKE,CAAO,GAE9BA,EAAQ,IAAIH,CAAQ,CACtB,CAEAI,OAAAA,EAAAA,wBAAwBX,CAAI,EACzB,KAAK,CAAC,CAAE,YAAAY,EAAa,KAAMC,KAAmB,CAC7C,MAAMC,EAASF,EAAY,aAAab,EAAM,CAC5C,KAAMc,EACN,OAAQ,CAAE,KAAMnB,EAAO,CAAC,EAAG,MAAOA,EAAO,CAAC,CAAA,CAAE,CAC7C,EACDC,EAAa,IAAIa,EAAKM,CAAM,EAC5B,MAAMJ,EAAUd,EAAY,IAAIY,CAAG,EACnC,GAAIE,EAAS,CACX,UAAWK,KAAUL,EACnBK,EAAOD,CAAM,EAEflB,EAAY,OAAOY,CAAG,CACxB,CACF,CAAC,EACA,MAAOQ,GAAmB,CACzB,QAAQ,MAAM,4BAA6BA,CAAK,EAChDpB,EAAY,OAAOY,CAAG,CACxB,CAAC,EAEI,IACT,CACF"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { resolveCodeBlockLanguage as u, getCodeBlockHighlighter as k, getSupportedCodeBlockLanguages as m } from "../../lib/shiki.js";
|
|
2
|
+
const l = [
|
|
3
|
+
"github-light",
|
|
4
|
+
"github-dark"
|
|
5
|
+
], d = /* @__PURE__ */ new Map(), o = /* @__PURE__ */ new Map(), h = 100, C = (e, i) => {
|
|
6
|
+
const g = e.slice(0, h), s = e.length > h ? e.slice(-h) : "";
|
|
7
|
+
return `${i}:${e.length}:${g}:${s}`;
|
|
8
|
+
}, E = {
|
|
9
|
+
name: "shiki",
|
|
10
|
+
type: "code-highlighter",
|
|
11
|
+
getSupportedLanguages: () => m(),
|
|
12
|
+
getThemes: () => l,
|
|
13
|
+
supportsLanguage: (e) => u(e) !== null,
|
|
14
|
+
highlight({ code: e, language: i }, g) {
|
|
15
|
+
const s = u(i) ?? "text", n = C(e, s), r = d.get(n);
|
|
16
|
+
if (r)
|
|
17
|
+
return r;
|
|
18
|
+
if (g) {
|
|
19
|
+
let t = o.get(n);
|
|
20
|
+
t || (t = /* @__PURE__ */ new Set(), o.set(n, t)), t.add(g);
|
|
21
|
+
}
|
|
22
|
+
return k(s).then(({ highlighter: t, lang: p }) => {
|
|
23
|
+
const c = t.codeToTokens(e, {
|
|
24
|
+
lang: p,
|
|
25
|
+
themes: { dark: l[1], light: l[0] }
|
|
26
|
+
});
|
|
27
|
+
d.set(n, c);
|
|
28
|
+
const a = o.get(n);
|
|
29
|
+
if (a) {
|
|
30
|
+
for (const f of a)
|
|
31
|
+
f(c);
|
|
32
|
+
o.delete(n);
|
|
33
|
+
}
|
|
34
|
+
}).catch((t) => {
|
|
35
|
+
console.error("Failed to highlight code:", t), o.delete(n);
|
|
36
|
+
}), null;
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
export {
|
|
40
|
+
E as streamdownCodePlugin
|
|
41
|
+
};
|
|
42
|
+
//# sourceMappingURL=streamdown-code-plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streamdown-code-plugin.js","sources":["../../../src/components/ai/streamdown-code-plugin.ts"],"sourcesContent":["/**\n * Slim replacement for `@streamdown/code` (SW-2007).\n *\n * The upstream plugin statically imports the full \"shiki\" bundle (~200\n * grammars), landing a second full Shiki copy in every consumer build. This\n * plugin implements the same streamdown `CodeHighlighterPlugin` contract on\n * top of the shared slim highlighter in `@/lib/shiki`, so only the explicit\n * language set is bundled and every grammar arrives as a lazy chunk.\n */\n\nimport type { BundledLanguage } from \"shiki\";\nimport type { CodeHighlighterPlugin } from \"streamdown\";\n\nimport {\n getCodeBlockHighlighter,\n getSupportedCodeBlockLanguages,\n resolveCodeBlockLanguage,\n} from \"@/lib/shiki\";\n\ntype HighlightCallback = NonNullable<Parameters<CodeHighlighterPlugin[\"highlight\"]>[1]>;\ntype HighlightResult = Parameters<HighlightCallback>[0];\n\nconst THEMES: ReturnType<CodeHighlighterPlugin[\"getThemes\"]> = [\n \"github-light\",\n \"github-dark\",\n];\n\n// Highlighted-token cache + pending-callback registry, mirroring the\n// upstream plugin's sync-return/async-callback protocol: return cached\n// tokens synchronously, otherwise kick off highlighting and notify via the\n// callback when tokens are ready.\nconst resultsCache = new Map<string, HighlightResult>();\nconst subscribers = new Map<string, Set<HighlightCallback>>();\n\nconst KEY_SLICE_LENGTH = 100;\n\nconst cacheKey = (code: string, lang: string): string => {\n const head = code.slice(0, KEY_SLICE_LENGTH);\n const tail = code.length > KEY_SLICE_LENGTH ? code.slice(-KEY_SLICE_LENGTH) : \"\";\n return `${lang}:${code.length}:${head}:${tail}`;\n};\n\nexport const streamdownCodePlugin: CodeHighlighterPlugin = {\n name: \"shiki\",\n type: \"code-highlighter\",\n getSupportedLanguages: () => getSupportedCodeBlockLanguages() as BundledLanguage[],\n getThemes: () => THEMES,\n supportsLanguage: (language) => resolveCodeBlockLanguage(language) !== null,\n highlight({ code, language }, callback) {\n // Unsupported languages resolve to plaintext inside the shared\n // highlighter, so streaming still renders the raw code.\n const lang = resolveCodeBlockLanguage(language) ?? \"text\";\n const key = cacheKey(code, lang);\n\n const cached = resultsCache.get(key);\n if (cached) {\n return cached;\n }\n\n if (callback) {\n let pending = subscribers.get(key);\n if (!pending) {\n pending = new Set();\n subscribers.set(key, pending);\n }\n pending.add(callback);\n }\n\n getCodeBlockHighlighter(lang)\n .then(({ highlighter, lang: resolvedLang }) => {\n const result = highlighter.codeToTokens(code, {\n lang: resolvedLang,\n themes: { dark: THEMES[1], light: THEMES[0] },\n });\n resultsCache.set(key, result);\n const pending = subscribers.get(key);\n if (pending) {\n for (const notify of pending) {\n notify(result);\n }\n subscribers.delete(key);\n }\n })\n .catch((error: unknown) => {\n console.error(\"Failed to highlight code:\", error);\n subscribers.delete(key);\n });\n\n return null;\n },\n};\n"],"names":["THEMES","resultsCache","subscribers","KEY_SLICE_LENGTH","cacheKey","code","lang","head","tail","streamdownCodePlugin","getSupportedCodeBlockLanguages","language","resolveCodeBlockLanguage","callback","key","cached","pending","getCodeBlockHighlighter","highlighter","resolvedLang","result","notify","error"],"mappings":";AAsBA,MAAMA,IAAyD;AAAA,EAC7D;AAA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Y,CAAG;AAAA,MACxB;AAAA,IACF,CAAC,EACA,MAAM,CAACQ,MAAmB;AACzB,cAAQ,MAAM,6BAA6BA,CAAK,GAChDpB,EAAY,OAAOY,CAAG;AAAA,IACxB,CAAC,GAEI;AAAA,EACT;AACF;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("@streamdown/cjk"),r=require("@streamdown/math"),t=require("@streamdown/mermaid"),o=require("./streamdown-code-plugin.cjs"),n={cjk:e.cjk,code:o.streamdownCodePlugin,math:r.math,mermaid:t.mermaid};exports.streamdownPlugins=n;
|
|
2
|
+
//# sourceMappingURL=streamdown-plugins.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streamdown-plugins.cjs","sources":["../../../src/components/ai/streamdown-plugins.ts"],"sourcesContent":["/**\n * Full streamdown plugin set for `MessageResponse` / `Reasoning` markdown.\n *\n * This module is only ever reached through `useStreamdownPlugins`'s dynamic\n * import (SW-2007): mermaid, KaTeX, and the shiki grammars behind these\n * plugins land in a lazy chunk instead of the consumer's main bundle. Do not\n * import it statically from component code.\n */\nimport { cjk } from \"@streamdown/cjk\";\nimport { math } from \"@streamdown/math\";\nimport { mermaid } from \"@streamdown/mermaid\";\n\nimport { streamdownCodePlugin } from \"./streamdown-code-plugin\";\n\nimport type { PluginConfig } from \"streamdown\";\n\nexport const streamdownPlugins: PluginConfig = {\n cjk,\n code: streamdownCodePlugin,\n math,\n mermaid,\n};\n"],"names":["streamdownPlugins","cjk","streamdownCodePlugin","math","mermaid"],"mappings":"4NAgBaA,EAAkC,CAAA,IAC7CC,EAAAA,IACA,KAAMC,EAAAA,qBAAA,KACNC,EAAAA,KAAA,QACAC,EAAAA,OACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { cjk as o } from "@streamdown/cjk";
|
|
2
|
+
import { math as m } from "@streamdown/math";
|
|
3
|
+
import { mermaid as r } from "@streamdown/mermaid";
|
|
4
|
+
import { streamdownCodePlugin as t } from "./streamdown-code-plugin.js";
|
|
5
|
+
const p = {
|
|
6
|
+
cjk: o,
|
|
7
|
+
code: t,
|
|
8
|
+
math: m,
|
|
9
|
+
mermaid: r
|
|
10
|
+
};
|
|
11
|
+
export {
|
|
12
|
+
p as streamdownPlugins
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=streamdown-plugins.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"streamdown-plugins.js","sources":["../../../src/components/ai/streamdown-plugins.ts"],"sourcesContent":["/**\n * Full streamdown plugin set for `MessageResponse` / `Reasoning` markdown.\n *\n * This module is only ever reached through `useStreamdownPlugins`'s dynamic\n * import (SW-2007): mermaid, KaTeX, and the shiki grammars behind these\n * plugins land in a lazy chunk instead of the consumer's main bundle. Do not\n * import it statically from component code.\n */\nimport { cjk } from \"@streamdown/cjk\";\nimport { math } from \"@streamdown/math\";\nimport { mermaid } from \"@streamdown/mermaid\";\n\nimport { streamdownCodePlugin } from \"./streamdown-code-plugin\";\n\nimport type { PluginConfig } from \"streamdown\";\n\nexport const streamdownPlugins: PluginConfig = {\n cjk,\n code: streamdownCodePlugin,\n math,\n mermaid,\n};\n"],"names":["streamdownPlugins","cjk","streamdownCodePlugin","math","mermaid"],"mappings":";;;;AAgBO,MAAMA,IAAkC;AAAA,EAC7C,KAAAC;AAAA,EACA,MAAMC;AAAA,EACN,MAAAC;AAAA,EACA,SAAAC;AACF;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("react/jsx-runtime"),C=require("@radix-ui/react-use-controllable-state"),m=require("lucide-react"),a=require("react"),i=require("../ui/collapsible.cjs"),r=require("../../lib/utils.cjs"),T=({children:s,className:e,...o})=>t.jsx("div",{className:r.cn("inline-flex items-center gap-1 rounded-md border bg-secondary px-1.5 py-0.5 text-foreground text-xs",e),...o,children:s}),h=({children:s,className:e,...o})=>t.jsx("div",{className:r.cn("text-muted-foreground text-sm",e),...o,children:s}),j=1e3,k=({defaultOpen:s=!0,isStreaming:e=!1,open:o,onOpenChange:l,className:f,...x})=>{const[c,n]=C.useControllableState({defaultProp:s,onChange:l,prop:o}),d=a.useRef(e),[p,g]=a.useState(!1);a.useEffect(()=>{e&&(d.current=!0)},[e]),a.useEffect(()=>{if(d.current&&!e&&c&&!p){const u=setTimeout(()=>{n(!1),g(!0)},j);return()=>clearTimeout(u)}},[e,c,n,p]);const b=a.useCallback(u=>n(u),[n]);return t.jsx(i.Collapsible,{className:r.cn(f),onOpenChange:b,open:c,...x})},v=({children:s,className:e,title:o,...l})=>t.jsx(i.CollapsibleTrigger,{asChild:!0,className:r.cn("group",e),...l,children:s??t.jsxs("button",{type:"button",className:"group flex w-full cursor-pointer items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",children:[t.jsx(m.SearchIcon,{className:"size-4"}),t.jsx("span",{className:"text-sm",children:o}),t.jsx(m.ChevronDownIcon,{className:"size-4 opacity-0 transition-all group-focus-visible:opacity-100 group-hover:opacity-100 group-data-[state=open]:rotate-180 group-data-[state=open]:opacity-100","data-slot":"collapsible-chevron"})]})}),y=({children:s,className:e,...o})=>t.jsx(i.CollapsibleContent,{className:r.cn("data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",e),...o,children:t.jsx("div",{className:"mt-4 space-y-2 border-border border-l-2 pl-4",children:s})});exports.Task=k;exports.TaskContent=y;exports.TaskItem=h;exports.TaskItemFile=T;exports.TaskTrigger=v;
|
|
2
2
|
//# sourceMappingURL=task.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task.cjs","sources":["../../../src/components/ai/task.tsx"],"sourcesContent":["import { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport { ChevronDownIcon, SearchIcon } from \"lucide-react\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport type { ComponentProps } from \"react\";\n\nimport {\n Collapsible,\n CollapsibleContent,\n CollapsibleTrigger,\n} from \"@/components/ui/collapsible\";\nimport { cn } from \"@/lib/utils\";\n\nexport type TaskItemFileProps = ComponentProps<\"div\">;\n\nexport const TaskItemFile = ({\n children,\n className,\n ...props\n}: TaskItemFileProps) => (\n <div\n className={cn(\n \"inline-flex items-center gap-1 rounded-md border bg-secondary px-1.5 py-0.5 text-foreground text-xs\",\n className\n )}\n {...props}\n >\n {children}\n </div>\n);\n\nexport type TaskItemProps = ComponentProps<\"div\">;\n\nexport const TaskItem = ({ children, className, ...props }: TaskItemProps) => (\n <div className={cn(\"text-muted-foreground text-sm\", className)} {...props}>\n {children}\n </div>\n);\n\nconst AUTO_CLOSE_DELAY = 1000;\n\nexport type TaskProps = ComponentProps<typeof Collapsible> & {\n isStreaming?: boolean;\n};\n\nexport const Task = ({\n defaultOpen = true,\n isStreaming = false,\n open,\n onOpenChange,\n className,\n ...props\n}: TaskProps) => {\n const [isOpen, setIsOpen] = useControllableState<boolean>({\n defaultProp: defaultOpen,\n onChange: onOpenChange,\n prop: open,\n });\n\n const hasEverStreamedRef = useRef(isStreaming);\n const [hasAutoClosed, setHasAutoClosed] = useState(false);\n\n useEffect(() => {\n if (isStreaming) hasEverStreamedRef.current = true;\n }, [isStreaming]);\n\n useEffect(() => {\n if (hasEverStreamedRef.current && !isStreaming && isOpen && !hasAutoClosed) {\n const timer = setTimeout(() => {\n setIsOpen(false);\n setHasAutoClosed(true);\n }, AUTO_CLOSE_DELAY);\n return () => clearTimeout(timer);\n }\n }, [isStreaming, isOpen, setIsOpen, hasAutoClosed]);\n\n const handleOpenChange = useCallback(\n (newOpen: boolean) => setIsOpen(newOpen),\n [setIsOpen]\n );\n\n return (\n <Collapsible\n className={cn(className)}\n onOpenChange={handleOpenChange}\n open={isOpen}\n {...props}\n />\n );\n};\n\nexport type TaskTriggerProps = ComponentProps<typeof CollapsibleTrigger> & {\n title: string;\n};\n\nexport const TaskTrigger = ({\n children,\n className,\n title,\n ...props\n}: TaskTriggerProps) => (\n <CollapsibleTrigger asChild className={cn(\"group\", className)} {...props}>\n {children ?? (\n <
|
|
1
|
+
{"version":3,"file":"task.cjs","sources":["../../../src/components/ai/task.tsx"],"sourcesContent":["import { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport { ChevronDownIcon, SearchIcon } from \"lucide-react\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport type { ComponentProps } from \"react\";\n\nimport {\n Collapsible,\n CollapsibleContent,\n CollapsibleTrigger,\n} from \"@/components/ui/collapsible\";\nimport { cn } from \"@/lib/utils\";\n\nexport type TaskItemFileProps = ComponentProps<\"div\">;\n\nexport const TaskItemFile = ({\n children,\n className,\n ...props\n}: TaskItemFileProps) => (\n <div\n className={cn(\n \"inline-flex items-center gap-1 rounded-md border bg-secondary px-1.5 py-0.5 text-foreground text-xs\",\n className\n )}\n {...props}\n >\n {children}\n </div>\n);\n\nexport type TaskItemProps = ComponentProps<\"div\">;\n\nexport const TaskItem = ({ children, className, ...props }: TaskItemProps) => (\n <div className={cn(\"text-muted-foreground text-sm\", className)} {...props}>\n {children}\n </div>\n);\n\nconst AUTO_CLOSE_DELAY = 1000;\n\nexport type TaskProps = ComponentProps<typeof Collapsible> & {\n isStreaming?: boolean;\n};\n\nexport const Task = ({\n defaultOpen = true,\n isStreaming = false,\n open,\n onOpenChange,\n className,\n ...props\n}: TaskProps) => {\n const [isOpen, setIsOpen] = useControllableState<boolean>({\n defaultProp: defaultOpen,\n onChange: onOpenChange,\n prop: open,\n });\n\n const hasEverStreamedRef = useRef(isStreaming);\n const [hasAutoClosed, setHasAutoClosed] = useState(false);\n\n useEffect(() => {\n if (isStreaming) hasEverStreamedRef.current = true;\n }, [isStreaming]);\n\n useEffect(() => {\n if (hasEverStreamedRef.current && !isStreaming && isOpen && !hasAutoClosed) {\n const timer = setTimeout(() => {\n setIsOpen(false);\n setHasAutoClosed(true);\n }, AUTO_CLOSE_DELAY);\n return () => clearTimeout(timer);\n }\n }, [isStreaming, isOpen, setIsOpen, hasAutoClosed]);\n\n const handleOpenChange = useCallback(\n (newOpen: boolean) => setIsOpen(newOpen),\n [setIsOpen]\n );\n\n return (\n <Collapsible\n className={cn(className)}\n onOpenChange={handleOpenChange}\n open={isOpen}\n {...props}\n />\n );\n};\n\nexport type TaskTriggerProps = ComponentProps<typeof CollapsibleTrigger> & {\n title: string;\n};\n\nexport const TaskTrigger = ({\n children,\n className,\n title,\n ...props\n}: TaskTriggerProps) => (\n <CollapsibleTrigger asChild className={cn(\"group\", className)} {...props}>\n {children ?? (\n <button\n type=\"button\"\n className=\"group flex w-full cursor-pointer items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground\"\n >\n <SearchIcon className=\"size-4\" />\n <span className=\"text-sm\">{title}</span>\n <ChevronDownIcon\n className=\"size-4 opacity-0 transition-all group-focus-visible:opacity-100 group-hover:opacity-100 group-data-[state=open]:rotate-180 group-data-[state=open]:opacity-100\"\n data-slot=\"collapsible-chevron\"\n />\n </button>\n )}\n </CollapsibleTrigger>\n);\n\nexport type TaskContentProps = ComponentProps<typeof CollapsibleContent>;\n\nexport const TaskContent = ({\n children,\n className,\n ...props\n}: TaskContentProps) => (\n <CollapsibleContent\n className={cn(\n \"data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in\",\n className\n )}\n {...props}\n >\n <div className=\"mt-4 space-y-2 border-border border-l-2 pl-4\">\n {children}\n </div>\n </CollapsibleContent>\n);\n"],"names":["TaskItemFile","children","className","props","jsx","cn","TaskItem","AUTO_CLOSE_DELAY","Task","defaultOpen","isStreaming","open","onOpenChange","isOpen","setIsOpen","useControllableState","hasEverStreamedRef","useRef","hasAutoClosed","setHasAutoClosed","useState","useEffect","timer","handleOpenChange","useCallback","newOpen","Collapsible","TaskTrigger","title","CollapsibleTrigger","jsxs","SearchIcon","ChevronDownIcon","TaskContent","CollapsibleContent"],"mappings":"0RAeaA,EAAe,CAAC,CAC3B,SAAAC,EACA,UAAAC,EACA,GAAGC,CACL,IACEC,EAAAA,IAAC,MAAA,CACC,UAAWC,EAAAA,GACT,sGACAH,CAAA,EAED,GAAGC,EAEH,SAAAF,CAAA,CACH,EAKWK,EAAW,CAAC,CAAE,SAAAL,EAAU,UAAAC,EAAW,GAAGC,CAAA,IACjDC,MAAC,MAAA,CAAI,UAAWC,EAAAA,GAAG,gCAAiCH,CAAS,EAAI,GAAGC,EACjE,SAAAF,CAAA,CACH,EAGIM,EAAmB,IAMZC,EAAO,CAAC,CACnB,YAAAC,EAAc,GACd,YAAAC,EAAc,GACd,KAAAC,EACA,aAAAC,EACA,UAAAV,EACA,GAAGC,CACL,IAAiB,CACf,KAAM,CAACU,EAAQC,CAAS,EAAIC,uBAA8B,CACxD,YAAaN,EACb,SAAUG,EACV,KAAMD,CAAA,CACP,EAEKK,EAAqBC,EAAAA,OAAOP,CAAW,EACvC,CAACQ,EAAeC,CAAgB,EAAIC,EAAAA,SAAS,EAAK,EAExDC,EAAAA,UAAU,IAAM,CACVX,MAAgC,QAAU,GAChD,EAAG,CAACA,CAAW,CAAC,EAEhBW,EAAAA,UAAU,IAAM,CACd,GAAIL,EAAmB,SAAW,CAACN,GAAeG,GAAU,CAACK,EAAe,CAC1E,MAAMI,EAAQ,WAAW,IAAM,CAC7BR,EAAU,EAAK,EACfK,EAAiB,EAAI,CACvB,EAAGZ,CAAgB,EACnB,MAAO,IAAM,aAAae,CAAK,CACjC,CACF,EAAG,CAACZ,EAAaG,EAAQC,EAAWI,CAAa,CAAC,EAElD,MAAMK,EAAmBC,EAAAA,YACtBC,GAAqBX,EAAUW,CAAO,EACvC,CAACX,CAAS,CAAA,EAGZ,OACEV,EAAAA,IAACsB,EAAAA,YAAA,CACC,UAAWrB,EAAAA,GAAGH,CAAS,EACvB,aAAcqB,EACd,KAAMV,EACL,GAAGV,CAAA,CAAA,CAGV,EAMawB,EAAc,CAAC,CAC1B,SAAA1B,EACA,UAAAC,EACA,MAAA0B,EACA,GAAGzB,CACL,IACEC,EAAAA,IAACyB,EAAAA,mBAAA,CAAmB,QAAO,GAAC,UAAWxB,EAAAA,GAAG,QAASH,CAAS,EAAI,GAAGC,EAChE,SAAAF,GACC6B,EAAAA,KAAC,SAAA,CACC,KAAK,SACL,UAAU,4HAEV,SAAA,CAAA1B,EAAAA,IAAC2B,EAAAA,WAAA,CAAW,UAAU,QAAA,CAAS,EAC/B3B,EAAAA,IAAC,OAAA,CAAK,UAAU,UAAW,SAAAwB,EAAM,EACjCxB,EAAAA,IAAC4B,EAAAA,gBAAA,CACC,UAAU,iKACV,YAAU,qBAAA,CAAA,CACZ,CAAA,CACF,CAAA,CAEJ,EAKWC,EAAc,CAAC,CAC1B,SAAAhC,EACA,UAAAC,EACA,GAAGC,CACL,IACEC,EAAAA,IAAC8B,EAAAA,mBAAA,CACC,UAAW7B,EAAAA,GACT,gNACAH,CAAA,EAED,GAAGC,EAEJ,SAAAC,EAAAA,IAAC,MAAA,CAAI,UAAU,+CACZ,SAAAH,CAAA,CACH,CAAA,CACF"}
|
|
@@ -59,17 +59,24 @@ const L = ({
|
|
|
59
59
|
className: e,
|
|
60
60
|
title: o,
|
|
61
61
|
...n
|
|
62
|
-
}) => /* @__PURE__ */ s(O, { asChild: !0, className: a("group", e), ...n, children: t ?? /* @__PURE__ */ h(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
62
|
+
}) => /* @__PURE__ */ s(O, { asChild: !0, className: a("group", e), ...n, children: t ?? /* @__PURE__ */ h(
|
|
63
|
+
"button",
|
|
64
|
+
{
|
|
65
|
+
type: "button",
|
|
66
|
+
className: "group flex w-full cursor-pointer items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground",
|
|
67
|
+
children: [
|
|
68
|
+
/* @__PURE__ */ s(C, { className: "size-4" }),
|
|
69
|
+
/* @__PURE__ */ s("span", { className: "text-sm", children: o }),
|
|
70
|
+
/* @__PURE__ */ s(
|
|
71
|
+
b,
|
|
72
|
+
{
|
|
73
|
+
className: "size-4 opacity-0 transition-all group-focus-visible:opacity-100 group-hover:opacity-100 group-data-[state=open]:rotate-180 group-data-[state=open]:opacity-100",
|
|
74
|
+
"data-slot": "collapsible-chevron"
|
|
75
|
+
}
|
|
76
|
+
)
|
|
77
|
+
]
|
|
78
|
+
}
|
|
79
|
+
) }), H = ({
|
|
73
80
|
children: t,
|
|
74
81
|
className: e,
|
|
75
82
|
...o
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"task.js","sources":["../../../src/components/ai/task.tsx"],"sourcesContent":["import { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport { ChevronDownIcon, SearchIcon } from \"lucide-react\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport type { ComponentProps } from \"react\";\n\nimport {\n Collapsible,\n CollapsibleContent,\n CollapsibleTrigger,\n} from \"@/components/ui/collapsible\";\nimport { cn } from \"@/lib/utils\";\n\nexport type TaskItemFileProps = ComponentProps<\"div\">;\n\nexport const TaskItemFile = ({\n children,\n className,\n ...props\n}: TaskItemFileProps) => (\n <div\n className={cn(\n \"inline-flex items-center gap-1 rounded-md border bg-secondary px-1.5 py-0.5 text-foreground text-xs\",\n className\n )}\n {...props}\n >\n {children}\n </div>\n);\n\nexport type TaskItemProps = ComponentProps<\"div\">;\n\nexport const TaskItem = ({ children, className, ...props }: TaskItemProps) => (\n <div className={cn(\"text-muted-foreground text-sm\", className)} {...props}>\n {children}\n </div>\n);\n\nconst AUTO_CLOSE_DELAY = 1000;\n\nexport type TaskProps = ComponentProps<typeof Collapsible> & {\n isStreaming?: boolean;\n};\n\nexport const Task = ({\n defaultOpen = true,\n isStreaming = false,\n open,\n onOpenChange,\n className,\n ...props\n}: TaskProps) => {\n const [isOpen, setIsOpen] = useControllableState<boolean>({\n defaultProp: defaultOpen,\n onChange: onOpenChange,\n prop: open,\n });\n\n const hasEverStreamedRef = useRef(isStreaming);\n const [hasAutoClosed, setHasAutoClosed] = useState(false);\n\n useEffect(() => {\n if (isStreaming) hasEverStreamedRef.current = true;\n }, [isStreaming]);\n\n useEffect(() => {\n if (hasEverStreamedRef.current && !isStreaming && isOpen && !hasAutoClosed) {\n const timer = setTimeout(() => {\n setIsOpen(false);\n setHasAutoClosed(true);\n }, AUTO_CLOSE_DELAY);\n return () => clearTimeout(timer);\n }\n }, [isStreaming, isOpen, setIsOpen, hasAutoClosed]);\n\n const handleOpenChange = useCallback(\n (newOpen: boolean) => setIsOpen(newOpen),\n [setIsOpen]\n );\n\n return (\n <Collapsible\n className={cn(className)}\n onOpenChange={handleOpenChange}\n open={isOpen}\n {...props}\n />\n );\n};\n\nexport type TaskTriggerProps = ComponentProps<typeof CollapsibleTrigger> & {\n title: string;\n};\n\nexport const TaskTrigger = ({\n children,\n className,\n title,\n ...props\n}: TaskTriggerProps) => (\n <CollapsibleTrigger asChild className={cn(\"group\", className)} {...props}>\n {children ?? (\n <
|
|
1
|
+
{"version":3,"file":"task.js","sources":["../../../src/components/ai/task.tsx"],"sourcesContent":["import { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport { ChevronDownIcon, SearchIcon } from \"lucide-react\";\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport type { ComponentProps } from \"react\";\n\nimport {\n Collapsible,\n CollapsibleContent,\n CollapsibleTrigger,\n} from \"@/components/ui/collapsible\";\nimport { cn } from \"@/lib/utils\";\n\nexport type TaskItemFileProps = ComponentProps<\"div\">;\n\nexport const TaskItemFile = ({\n children,\n className,\n ...props\n}: TaskItemFileProps) => (\n <div\n className={cn(\n \"inline-flex items-center gap-1 rounded-md border bg-secondary px-1.5 py-0.5 text-foreground text-xs\",\n className\n )}\n {...props}\n >\n {children}\n </div>\n);\n\nexport type TaskItemProps = ComponentProps<\"div\">;\n\nexport const TaskItem = ({ children, className, ...props }: TaskItemProps) => (\n <div className={cn(\"text-muted-foreground text-sm\", className)} {...props}>\n {children}\n </div>\n);\n\nconst AUTO_CLOSE_DELAY = 1000;\n\nexport type TaskProps = ComponentProps<typeof Collapsible> & {\n isStreaming?: boolean;\n};\n\nexport const Task = ({\n defaultOpen = true,\n isStreaming = false,\n open,\n onOpenChange,\n className,\n ...props\n}: TaskProps) => {\n const [isOpen, setIsOpen] = useControllableState<boolean>({\n defaultProp: defaultOpen,\n onChange: onOpenChange,\n prop: open,\n });\n\n const hasEverStreamedRef = useRef(isStreaming);\n const [hasAutoClosed, setHasAutoClosed] = useState(false);\n\n useEffect(() => {\n if (isStreaming) hasEverStreamedRef.current = true;\n }, [isStreaming]);\n\n useEffect(() => {\n if (hasEverStreamedRef.current && !isStreaming && isOpen && !hasAutoClosed) {\n const timer = setTimeout(() => {\n setIsOpen(false);\n setHasAutoClosed(true);\n }, AUTO_CLOSE_DELAY);\n return () => clearTimeout(timer);\n }\n }, [isStreaming, isOpen, setIsOpen, hasAutoClosed]);\n\n const handleOpenChange = useCallback(\n (newOpen: boolean) => setIsOpen(newOpen),\n [setIsOpen]\n );\n\n return (\n <Collapsible\n className={cn(className)}\n onOpenChange={handleOpenChange}\n open={isOpen}\n {...props}\n />\n );\n};\n\nexport type TaskTriggerProps = ComponentProps<typeof CollapsibleTrigger> & {\n title: string;\n};\n\nexport const TaskTrigger = ({\n children,\n className,\n title,\n ...props\n}: TaskTriggerProps) => (\n <CollapsibleTrigger asChild className={cn(\"group\", className)} {...props}>\n {children ?? (\n <button\n type=\"button\"\n className=\"group flex w-full cursor-pointer items-center gap-2 text-muted-foreground text-sm transition-colors hover:text-foreground\"\n >\n <SearchIcon className=\"size-4\" />\n <span className=\"text-sm\">{title}</span>\n <ChevronDownIcon\n className=\"size-4 opacity-0 transition-all group-focus-visible:opacity-100 group-hover:opacity-100 group-data-[state=open]:rotate-180 group-data-[state=open]:opacity-100\"\n data-slot=\"collapsible-chevron\"\n />\n </button>\n )}\n </CollapsibleTrigger>\n);\n\nexport type TaskContentProps = ComponentProps<typeof CollapsibleContent>;\n\nexport const TaskContent = ({\n children,\n className,\n ...props\n}: TaskContentProps) => (\n <CollapsibleContent\n className={cn(\n \"data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in\",\n className\n )}\n {...props}\n >\n <div className=\"mt-4 space-y-2 border-border border-l-2 pl-4\">\n {children}\n </div>\n </CollapsibleContent>\n);\n"],"names":["TaskItemFile","children","className","props","jsx","cn","TaskItem","AUTO_CLOSE_DELAY","Task","defaultOpen","isStreaming","open","onOpenChange","isOpen","setIsOpen","useControllableState","hasEverStreamedRef","useRef","hasAutoClosed","setHasAutoClosed","useState","useEffect","timer","handleOpenChange","useCallback","newOpen","Collapsible","TaskTrigger","title","CollapsibleTrigger","jsxs","SearchIcon","ChevronDownIcon","TaskContent","CollapsibleContent"],"mappings":";;;;;;AAeO,MAAMA,IAAe,CAAC;AAAA,EAC3B,UAAAC;AAAA,EACA,WAAAC;AAAA,EACA,GAAGC;AACL,MACE,gBAAAC;AAAA,EAAC;AAAA,EAAA;AAAA,IACC,WAAWC;AAAA,MACT;AAAA,MACAH;AAAA,IAAA;AAAA,IAED,GAAGC;AAAA,IAEH,UAAAF;AAAA,EAAA;AACH,GAKWK,IAAW,CAAC,EAAE,UAAAL,GAAU,WAAAC,GAAW,GAAGC,EAAA,MACjD,gBAAAC,EAAC,OAAA,EAAI,WAAWC,EAAG,iCAAiCH,CAAS,GAAI,GAAGC,GACjE,UAAAF,EAAA,CACH,GAGIM,IAAmB,KAMZC,IAAO,CAAC;A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AAA,IAEV,UAAA;AAAA,MAAA,gBAAA1B,EAAC2B,GAAA,EAAW,WAAU,SAAA,CAAS;AAAA,MAC/B,gBAAA3B,EAAC,QAAA,EAAK,WAAU,WAAW,UAAAwB,GAAM;AAAA,MACjC,gBAAAxB;AAAA,QAAC4B;AAAA,QAAA;AAAA,UACC,WAAU;AAAA,UACV,aAAU;AAAA,QAAA;AAAA,MAAA;AAAA,IACZ;AAAA,EAAA;AACF,EAAA,CAEJ,GAKWC,IAAc,CAAC;AAAA,EAC1B,UAAAhC;AAAA,EACA,WAAAC;AAAA,EACA,GAAGC;AACL,MACE,gBAAAC;AAAA,EAAC8B;AAAA,EAAA;AAAA,IACC,WAAW7B;AAAA,MACT;AAAA,MACAH;AAAA,IAAA;AAAA,IAED,GAAGC;AAAA,IAEJ,UAAA,gBAAAC,EAAC,OAAA,EAAI,WAAU,gDACZ,UAAAH,EAAA,CACH;AAAA,EAAA;AACF;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),h=require("@radix-ui/react-use-controllable-state"),a=require("lucide-react"),l=require("react"),v=require("../ui/badge.cjs"),N=require("../ui/banner.cjs"),m=require("../ui/code-block.cjs"),x=require("../ui/collapsible.cjs"),i=require("../../lib/utils.cjs"),y=1e3,I=({className:s,isStreaming:t=!1,open:o,onOpenChange:r,defaultOpen:n,...u})=>{const[c,d]=h.useControllableState({defaultProp:n??!0,onChange:r,prop:o}),g=l.useRef(t),[f,C]=l.useState(!1);l.useEffect(()=>{t&&(g.current=!0)},[t]),l.useEffect(()=>{if(g.current&&!t&&c&&!f){const p=setTimeout(()=>{d(!1),C(!0)},y);return()=>clearTimeout(p)}},[t,c,d,f]);const b=l.useCallback(p=>d(p),[d]);return e.jsx(x.Collapsible,{className:i.cn("group not-prose mb-4 w-full rounded-md border bg-background",s),onOpenChange:b,open:c,...u})},k={"approval-requested":"Awaiting Approval","approval-responded":"Responded","input-available":"Running","input-streaming":"Pending","output-available":"Completed","output-denied":"Denied","output-error":"Error"},w={"approval-requested":e.jsx(a.ClockIcon,{className:"size-4 text-yellow-600"}),"approval-responded":e.jsx(a.CheckCircleIcon,{className:"size-4 text-blue-600"}),"input-available":e.jsx(a.ClockIcon,{className:"size-4 animate-pulse"}),"input-streaming":e.jsx(a.CircleIcon,{className:"size-4"}),"output-available":e.jsx(a.CheckCircleIcon,{className:"size-4 text-green-600"}),"output-denied":e.jsx(a.XCircleIcon,{className:"size-4 text-orange-600"}),"output-error":e.jsx(a.XCircleIcon,{className:"size-4 text-red-600"})},j=s=>e.jsxs(v.Badge,{className:"gap-1.5 rounded-full text-xs",variant:"secondary",children:[w[s],k[s]]}),O=({className:s,title:t,type:o,state:r,toolName:n,...u})=>{const c=o==="dynamic-tool"?n:o.split("-").slice(1).join("-");return e.jsxs(x.CollapsibleTrigger,{className:i.cn("flex w-full items-center justify-between gap-4 p-3",s),...u,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(a.WrenchIcon,{className:"size-4 text-muted-foreground"}),e.jsx("span",{className:"font-medium text-sm",children:t??c}),j(r)]}),e.jsx(a.ChevronDownIcon,{className:"size-4 text-muted-foreground opacity-0 transition-all group-focus-within:opacity-100 group-hover:opacity-100 group-data-[state=open]:rotate-180 group-data-[state=open]:opacity-100","data-slot":"collapsible-chevron"})]})},T=({className:s,...t})=>e.jsx(x.CollapsibleContent,{className:i.cn("data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 space-y-4 p-4 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",s),...t}),q=({className:s,input:t,...o})=>e.jsxs("div",{className:i.cn("space-y-2 overflow-hidden",s),...o,children:[e.jsx("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:"Parameters"}),e.jsx("div",{className:"rounded-md bg-muted/50",children:e.jsx(m.CodeBlock,{code:JSON.stringify(t,null,2),language:"json"})})]}),z=({className:s,output:t,errorText:o,...r})=>{if(!(t||o))return null;let n=e.jsx("div",{children:t});return typeof t=="object"&&!l.isValidElement(t)?n=e.jsx(m.CodeBlock,{code:JSON.stringify(t,null,2),language:"json"}):typeof t=="string"&&(n=e.jsx(m.CodeBlock,{code:t,language:"json"})),e.jsxs("div",{className:i.cn("space-y-2",s),...r,children:[e.jsx("h4",{className:"font-medium text-muted-foreground text-xs uppercase tracking-wide",children:o?"Error":"Result"}),o?e.jsx(N.Banner,{variant:"destructive",description:o,className:"rounded-md text-xs"}):e.jsx("div",{className:"overflow-x-auto rounded-md bg-muted/50 text-foreground text-xs [&_table]:w-full",children:n})]})};exports.Tool=I;exports.ToolContent=T;exports.ToolHeader=O;exports.ToolInput=q;exports.ToolOutput=z;exports.getStatusBadge=j;
|
|
2
2
|
//# sourceMappingURL=tool.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.cjs","sources":["../../../src/components/ai/tool.tsx"],"sourcesContent":["import { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport {\n CheckCircleIcon,\n ChevronDownIcon,\n CircleIcon,\n ClockIcon,\n WrenchIcon,\n XCircleIcon,\n} from \"lucide-react\";\nimport { isValidElement, useCallback, useEffect, useRef, useState } from \"react\";\n\n\nimport type { DynamicToolUIPart, ToolUIPart } from \"ai\";\nimport type { ComponentProps, ReactNode } from \"react\";\n\nimport { Badge } from \"@/components/ui/badge\";\nimport { CodeBlock } from \"@/components/ui/code-block\";\nimport {\n Collapsible,\n CollapsibleContent,\n CollapsibleTrigger,\n} from \"@/components/ui/collapsible\";\nimport { cn } from \"@/lib/utils\";\n\n\n\n\nconst AUTO_CLOSE_DELAY = 1000;\n\nexport type ToolProps = ComponentProps<typeof Collapsible> & {\n isStreaming?: boolean;\n};\n\nexport const Tool = ({\n className,\n isStreaming = false,\n open,\n onOpenChange,\n defaultOpen,\n ...props\n}: ToolProps) => {\n const [isOpen, setIsOpen] = useControllableState<boolean>({\n defaultProp: defaultOpen ?? true,\n onChange: onOpenChange,\n prop: open,\n });\n\n const hasEverStreamedRef = useRef(isStreaming);\n const [hasAutoClosed, setHasAutoClosed] = useState(false);\n\n useEffect(() => {\n if (isStreaming) hasEverStreamedRef.current = true;\n }, [isStreaming]);\n\n useEffect(() => {\n if (hasEverStreamedRef.current && !isStreaming && isOpen && !hasAutoClosed) {\n const timer = setTimeout(() => {\n setIsOpen(false);\n setHasAutoClosed(true);\n }, AUTO_CLOSE_DELAY);\n return () => clearTimeout(timer);\n }\n }, [isStreaming, isOpen, setIsOpen, hasAutoClosed]);\n\n const handleOpenChange = useCallback(\n (newOpen: boolean) => setIsOpen(newOpen),\n [setIsOpen]\n );\n\n return (\n <Collapsible\n className={cn(\"group not-prose mb-4 w-full rounded-md border bg-background\", className)}\n onOpenChange={handleOpenChange}\n open={isOpen}\n {...props}\n />\n );\n};\n\nexport type ToolPart = ToolUIPart | DynamicToolUIPart;\n\nexport type ToolHeaderProps = {\n title?: string;\n className?: string;\n} & (\n | { type: ToolUIPart[\"type\"]; state: ToolUIPart[\"state\"]; toolName?: never }\n | {\n type: DynamicToolUIPart[\"type\"];\n state: DynamicToolUIPart[\"state\"];\n toolName: string;\n }\n);\n\nconst statusLabels: Record<ToolPart[\"state\"], string> = {\n \"approval-requested\": \"Awaiting Approval\",\n \"approval-responded\": \"Responded\",\n \"input-available\": \"Running\",\n \"input-streaming\": \"Pending\",\n \"output-available\": \"Completed\",\n \"output-denied\": \"Denied\",\n \"output-error\": \"Error\",\n};\n\nconst statusIcons: Record<ToolPart[\"state\"], ReactNode> = {\n \"approval-requested\": <ClockIcon className=\"size-4 text-yellow-600\" />,\n \"approval-responded\": <CheckCircleIcon className=\"size-4 text-blue-600\" />,\n \"input-available\": <ClockIcon className=\"size-4 animate-pulse\" />,\n \"input-streaming\": <CircleIcon className=\"size-4\" />,\n \"output-available\": <CheckCircleIcon className=\"size-4 text-green-600\" />,\n \"output-denied\": <XCircleIcon className=\"size-4 text-orange-600\" />,\n \"output-error\": <XCircleIcon className=\"size-4 text-red-600\" />,\n};\n\nexport const getStatusBadge = (status: ToolPart[\"state\"]) => (\n <Badge className=\"gap-1.5 rounded-full text-xs\" variant=\"secondary\">\n {statusIcons[status]}\n {statusLabels[status]}\n </Badge>\n);\n\nexport const ToolHeader = ({\n className,\n title,\n type,\n state,\n toolName,\n ...props\n}: ToolHeaderProps) => {\n const derivedName =\n type === \"dynamic-tool\" ? toolName : type.split(\"-\").slice(1).join(\"-\");\n\n return (\n <CollapsibleTrigger\n className={cn(\n \"flex w-full items-center justify-between gap-4 p-3\",\n className\n )}\n {...props}\n >\n <div className=\"flex items-center gap-2\">\n <WrenchIcon className=\"size-4 text-muted-foreground\" />\n <span className=\"font-medium text-sm\">{title ?? derivedName}</span>\n {getStatusBadge(state)}\n </div>\n <ChevronDownIcon\n className=\"size-4 text-muted-foreground opacity-0 transition-all group-focus-within:opacity-100 group-hover:opacity-100 group-data-[state=open]:rotate-180 group-data-[state=open]:opacity-100\"\n data-slot=\"collapsible-chevron\"\n />\n </CollapsibleTrigger>\n );\n};\n\nexport type ToolContentProps = ComponentProps<typeof CollapsibleContent>;\n\nexport const ToolContent = ({ className, ...props }: ToolContentProps) => (\n <CollapsibleContent\n className={cn(\n \"data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 space-y-4 p-4 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in\",\n className\n )}\n {...props}\n />\n);\n\nexport type ToolInputProps = ComponentProps<\"div\"> & {\n input: ToolPart[\"input\"];\n};\n\nexport const ToolInput = ({ className, input, ...props }: ToolInputProps) => (\n <div className={cn(\"space-y-2 overflow-hidden\", className)} {...props}>\n <h4 className=\"font-medium text-muted-foreground text-xs uppercase tracking-wide\">\n Parameters\n </h4>\n <div className=\"rounded-md bg-muted/50\">\n <CodeBlock code={JSON.stringify(input, null, 2)} language=\"json\" />\n </div>\n </div>\n);\n\nexport type ToolOutputProps = ComponentProps<\"div\"> & {\n output: ToolPart[\"output\"];\n errorText: ToolPart[\"errorText\"];\n};\n\nexport const ToolOutput = ({\n className,\n output,\n errorText,\n ...props\n}: ToolOutputProps) => {\n if (!(output || errorText)) {\n return null;\n }\n\n let Output = <div>{output as ReactNode}</div>;\n\n if (typeof output === \"object\" && !isValidElement(output)) {\n Output = (\n <CodeBlock code={JSON.stringify(output, null, 2)} language=\"json\" />\n );\n } else if (typeof output === \"string\") {\n Output = <CodeBlock code={output} language=\"json\" />;\n }\n\n return (\n <div className={cn(\"space-y-2\", className)} {...props}>\n <h4 className=\"font-medium text-muted-foreground text-xs uppercase tracking-wide\">\n {errorText ? \"Error\" : \"Result\"}\n </h4>\n <div\n className={cn(\n \"overflow-x-auto rounded-md text-xs [&_table]:w-full\",\n errorText\n ? \"bg-destructive/10 text-destructive\"\n : \"bg-muted/50 text-foreground\"\n )}\n >\n {errorText && <div>{errorText}</div>}\n {Output}\n </div>\n </div>\n );\n};\n"],"names":["AUTO_CLOSE_DELAY","Tool","className","isStreaming","open","onOpenChange","defaultOpen","props","isOpen","setIsOpen","useControllableState","hasEverStreamedRef","useRef","hasAutoClosed","setHasAutoClosed","useState","useEffect","timer","handleOpenChange","useCallback","newOpen","jsx","Collapsible","cn","statusLabels","statusIcons","ClockIcon","CheckCircleIcon","CircleIcon","XCircleIcon","getStatusBadge","status","jsxs","Badge","ToolHeader","title","type","state","toolName","derivedName","CollapsibleTrigger","WrenchIcon","ChevronDownIcon","ToolContent","CollapsibleContent","ToolInput","input","CodeBlock","ToolOutput","output","errorText","Output","isValidElement"],"mappings":"yVA2BMA,EAAmB,IAMZC,EAAO,CAAC,CACnB,UAAAC,EACA,YAAAC,EAAc,GACd,KAAAC,EACA,aAAAC,EACA,YAAAC,EACA,GAAGC,CACL,IAAiB,CACf,KAAM,CAACC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CAAG,UAAU,oEAAoE,SAAA,aAElF,EACAA,EAAAA,IAAC,MAAA,CAAI,UAAU,yBACb,eAAC0B,EAAAA,UAAA,CAAU,KAAM,KAAK,UAAUD,EAAO,KAAM,CAAC,EAAG,SAAS,OAAO,CAAA,CACnE,CAAA,CAAA,CACF,EAQWE,EAAa,CAAC,CACzB,UAAA9C,EACA,OAAA+C,EACA,UAAAC,EACA,GAAG3C,CACL,IAAuB,CACrB,GAAI,EAAE0C,GAAUC,GACd,OAAO,KAGT,IAAIC,EAAS9B,EAAAA,IAAC,MAAA,CAAK,SAAA4B,CAAA,CAAoB,EAEvC,OAAI,OAAOA,GAAW,UAAY,CAACG,EAAAA,eAAeH,CAAM,EACtDE,EACE9B,EAAAA,IAAC0B,EAAAA,UAAA,CAAU,KAAM,KAAK,UAAUE,EAAQ,KAAM,CAAC,EAAG,SAAS,MAAA,CAAO,EAE3D,OAAOA,GAAW,WAC3BE,EAAS9B,EAAAA,IAAC0B,YAAA,CAAU,KAAME,EAAQ,SAAS,OAAO,GAIlDjB,EAAAA,KAAC,OAAI,UAAWT,EAAAA,GAAG,YAAarB,CAAS,EAAI,GAAGK,EAC9C,SAAA,CAAAc,MAAC,KAAA,CAAG,UAAU,oEACX,SAAA6B,EAAY,QAAU,SACzB,EACAlB,EAAAA,KAAC,MAAA,CACC,UAAWT,EAAAA,GACT,sDACA2B,EACI,qCACA,6BAAA,EAGL,SAAA,CAAAA,GAAa7B,EAAAA,IAAC,OAAK,SAAA6B,CAAA,CAAU,EAC7BC,CAAA,CAAA,CAAA,CACH,EACF,CAEJ"}
|
|
1
|
+
{"version":3,"file":"tool.cjs","sources":["../../../src/components/ai/tool.tsx"],"sourcesContent":["import { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport {\n CheckCircleIcon,\n ChevronDownIcon,\n CircleIcon,\n ClockIcon,\n WrenchIcon,\n XCircleIcon,\n} from \"lucide-react\";\nimport { isValidElement, useCallback, useEffect, useRef, useState } from \"react\";\n\n\nimport type { DynamicToolUIPart, ToolUIPart } from \"ai\";\nimport type { ComponentProps, ReactNode } from \"react\";\n\nimport { Badge } from \"@/components/ui/badge\";\nimport { Banner } from \"@/components/ui/banner\";\nimport { CodeBlock } from \"@/components/ui/code-block\";\nimport {\n Collapsible,\n CollapsibleContent,\n CollapsibleTrigger,\n} from \"@/components/ui/collapsible\";\nimport { cn } from \"@/lib/utils\";\n\n\n\n\nconst AUTO_CLOSE_DELAY = 1000;\n\nexport type ToolProps = ComponentProps<typeof Collapsible> & {\n isStreaming?: boolean;\n};\n\nexport const Tool = ({\n className,\n isStreaming = false,\n open,\n onOpenChange,\n defaultOpen,\n ...props\n}: ToolProps) => {\n const [isOpen, setIsOpen] = useControllableState<boolean>({\n defaultProp: defaultOpen ?? true,\n onChange: onOpenChange,\n prop: open,\n });\n\n const hasEverStreamedRef = useRef(isStreaming);\n const [hasAutoClosed, setHasAutoClosed] = useState(false);\n\n useEffect(() => {\n if (isStreaming) hasEverStreamedRef.current = true;\n }, [isStreaming]);\n\n useEffect(() => {\n if (hasEverStreamedRef.current && !isStreaming && isOpen && !hasAutoClosed) {\n const timer = setTimeout(() => {\n setIsOpen(false);\n setHasAutoClosed(true);\n }, AUTO_CLOSE_DELAY);\n return () => clearTimeout(timer);\n }\n }, [isStreaming, isOpen, setIsOpen, hasAutoClosed]);\n\n const handleOpenChange = useCallback(\n (newOpen: boolean) => setIsOpen(newOpen),\n [setIsOpen]\n );\n\n return (\n <Collapsible\n className={cn(\"group not-prose mb-4 w-full rounded-md border bg-background\", className)}\n onOpenChange={handleOpenChange}\n open={isOpen}\n {...props}\n />\n );\n};\n\nexport type ToolPart = ToolUIPart | DynamicToolUIPart;\n\nexport type ToolHeaderProps = {\n title?: string;\n className?: string;\n} & (\n | { type: ToolUIPart[\"type\"]; state: ToolUIPart[\"state\"]; toolName?: never }\n | {\n type: DynamicToolUIPart[\"type\"];\n state: DynamicToolUIPart[\"state\"];\n toolName: string;\n }\n);\n\nconst statusLabels: Record<ToolPart[\"state\"], string> = {\n \"approval-requested\": \"Awaiting Approval\",\n \"approval-responded\": \"Responded\",\n \"input-available\": \"Running\",\n \"input-streaming\": \"Pending\",\n \"output-available\": \"Completed\",\n \"output-denied\": \"Denied\",\n \"output-error\": \"Error\",\n};\n\nconst statusIcons: Record<ToolPart[\"state\"], ReactNode> = {\n \"approval-requested\": <ClockIcon className=\"size-4 text-yellow-600\" />,\n \"approval-responded\": <CheckCircleIcon className=\"size-4 text-blue-600\" />,\n \"input-available\": <ClockIcon className=\"size-4 animate-pulse\" />,\n \"input-streaming\": <CircleIcon className=\"size-4\" />,\n \"output-available\": <CheckCircleIcon className=\"size-4 text-green-600\" />,\n \"output-denied\": <XCircleIcon className=\"size-4 text-orange-600\" />,\n \"output-error\": <XCircleIcon className=\"size-4 text-red-600\" />,\n};\n\nexport const getStatusBadge = (status: ToolPart[\"state\"]) => (\n <Badge className=\"gap-1.5 rounded-full text-xs\" variant=\"secondary\">\n {statusIcons[status]}\n {statusLabels[status]}\n </Badge>\n);\n\nexport const ToolHeader = ({\n className,\n title,\n type,\n state,\n toolName,\n ...props\n}: ToolHeaderProps) => {\n const derivedName =\n type === \"dynamic-tool\" ? toolName : type.split(\"-\").slice(1).join(\"-\");\n\n return (\n <CollapsibleTrigger\n className={cn(\n \"flex w-full items-center justify-between gap-4 p-3\",\n className\n )}\n {...props}\n >\n <div className=\"flex items-center gap-2\">\n <WrenchIcon className=\"size-4 text-muted-foreground\" />\n <span className=\"font-medium text-sm\">{title ?? derivedName}</span>\n {getStatusBadge(state)}\n </div>\n <ChevronDownIcon\n className=\"size-4 text-muted-foreground opacity-0 transition-all group-focus-within:opacity-100 group-hover:opacity-100 group-data-[state=open]:rotate-180 group-data-[state=open]:opacity-100\"\n data-slot=\"collapsible-chevron\"\n />\n </CollapsibleTrigger>\n );\n};\n\nexport type ToolContentProps = ComponentProps<typeof CollapsibleContent>;\n\nexport const ToolContent = ({ className, ...props }: ToolContentProps) => (\n <CollapsibleContent\n className={cn(\n \"data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 space-y-4 p-4 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in\",\n className\n )}\n {...props}\n />\n);\n\nexport type ToolInputProps = ComponentProps<\"div\"> & {\n input: ToolPart[\"input\"];\n};\n\nexport const ToolInput = ({ className, input, ...props }: ToolInputProps) => (\n <div className={cn(\"space-y-2 overflow-hidden\", className)} {...props}>\n <h4 className=\"font-medium text-muted-foreground text-xs uppercase tracking-wide\">\n Parameters\n </h4>\n <div className=\"rounded-md bg-muted/50\">\n <CodeBlock code={JSON.stringify(input, null, 2)} language=\"json\" />\n </div>\n </div>\n);\n\nexport type ToolOutputProps = ComponentProps<\"div\"> & {\n output: ToolPart[\"output\"];\n errorText: ToolPart[\"errorText\"];\n};\n\nexport const ToolOutput = ({\n className,\n output,\n errorText,\n ...props\n}: ToolOutputProps) => {\n if (!(output || errorText)) {\n return null;\n }\n\n let Output = <div>{output as ReactNode}</div>;\n\n if (typeof output === \"object\" && !isValidElement(output)) {\n Output = (\n <CodeBlock code={JSON.stringify(output, null, 2)} language=\"json\" />\n );\n } else if (typeof output === \"string\") {\n Output = <CodeBlock code={output} language=\"json\" />;\n }\n\n return (\n <div className={cn(\"space-y-2\", className)} {...props}>\n <h4 className=\"font-medium text-muted-foreground text-xs uppercase tracking-wide\">\n {errorText ? \"Error\" : \"Result\"}\n </h4>\n {errorText ? (\n <Banner\n variant=\"destructive\"\n description={errorText}\n className=\"rounded-md text-xs\"\n />\n ) : (\n <div className=\"overflow-x-auto rounded-md bg-muted/50 text-foreground text-xs [&_table]:w-full\">\n {Output}\n </div>\n )}\n </div>\n );\n};\n"],"names":["AUTO_CLOSE_DELAY","Tool","className","isStreaming","open","onOpenChange","defaultOpen","props","isOpen","setIsOpen","useControllableState","hasEverStreamedRef","useRef","hasAutoClosed","setHasAutoClosed","useState","useEffect","timer","handleOpenChange","useCallback","newOpen","jsx","Collapsible","cn","statusLabels","statusIcons","ClockIcon","CheckCircleIcon","CircleIcon","XCircleIcon","getStatusBadge","status","jsxs","Badge","ToolHeader","title","type","state","toolName","derivedName","CollapsibleTrigger","WrenchIcon","ChevronDownIcon","ToolContent","CollapsibleContent","ToolInput","input","CodeBlock","ToolOutput","output","errorText","Output","isValidElement","Banner"],"mappings":"uXA4BMA,EAAmB,IAMZC,EAAO,CAAC,CACnB,UAAAC,EACA,YAAAC,EAAc,GACd,KAAAC,EACA,aAAAC,EACA,YAAAC,EACA,GAAGC,CACL,IAAiB,CACf,KAAM,CAACC,EAAQC,CAAS,EAAIC,uBAA8B,CACxD,YAAaJ,GAAe,GAC5B,SAAUD,EACV,KAAMD,CAAA,CACP,EAEKO,EAAqBC,EAAAA,OAAOT,CAAW,EACvC,CAACU,EAAeC,CAAgB,EAAIC,EAAAA,SAAS,EAAK,EAExDC,EAAAA,UAAU,IAAM,CACVb,MAAgC,QAAU,GAChD,EAAG,CAACA,CAAW,CAAC,EAEhBa,EAAAA,UAAU,IAAM,CACd,GAAIL,EAAmB,SAAW,CAACR,GAAeK,GAAU,CAACK,EAAe,CAC1E,MAAMI,EAAQ,WAAW,IAAM,CAC7BR,EAAU,EAAK,EACfK,EAAiB,EAAI,CACvB,EAAGd,CAAgB,EACnB,MAAO,IAAM,aAAaiB,CAAK,CACjC,CACF,EAAG,CAACd,EAAaK,EAAQC,EAAWI,CAAa,CAAC,EAElD,MAAMK,EAAmBC,EAAAA,YACtBC,GAAqBX,EAAUW,CAAO,EACvC,CAACX,CAAS,CAAA,EAGZ,OACEY,EAAAA,IAACC,EAAAA,YAAA,CACC,UAAWC,EAAAA,GAAG,8DAA+DrB,CAAS,EACtF,aAAcgB,EACd,KAAMV,EACL,GAAGD,CAAA,CAAA,CAGV,EAgBMiB,EAAkD,CACtD,qBAAsB,oBACtB,qBAAsB,YACtB,kBAAmB,UACnB,kBAAmB,UACnB,mBAAoB,YACpB,gBAAiB,SACjB,eAAgB,OACl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,UAAU,oBAAA,CAAA,EAGZ7B,EAAAA,IAAC,MAAA,CAAI,UAAU,kFACZ,SAAA8B,CAAA,CACH,CAAA,EAEJ,CAEJ"}
|
|
@@ -1,48 +1,49 @@
|
|
|
1
|
-
import { jsx as e, jsxs as
|
|
1
|
+
import { jsx as e, jsxs as l } from "react/jsx-runtime";
|
|
2
2
|
import { useControllableState as C } from "@radix-ui/react-use-controllable-state";
|
|
3
3
|
import { WrenchIcon as y, ChevronDownIcon as w, XCircleIcon as g, CheckCircleIcon as h, CircleIcon as O, ClockIcon as v } from "lucide-react";
|
|
4
|
-
import { useRef as z, useState as I, useEffect as
|
|
4
|
+
import { useRef as z, useState as I, useEffect as x, useCallback as j, isValidElement as k } from "react";
|
|
5
5
|
import { Badge as E } from "../ui/badge.js";
|
|
6
|
+
import { Banner as A } from "../ui/banner.js";
|
|
6
7
|
import { CodeBlock as p } from "../ui/code-block.js";
|
|
7
|
-
import { Collapsible as
|
|
8
|
-
import { cn as
|
|
9
|
-
const
|
|
8
|
+
import { Collapsible as T, CollapsibleContent as R, CollapsibleTrigger as B } from "../ui/collapsible.js";
|
|
9
|
+
import { cn as i } from "../../lib/utils.js";
|
|
10
|
+
const D = 1e3, F = ({
|
|
10
11
|
className: o,
|
|
11
12
|
isStreaming: t = !1,
|
|
12
13
|
open: a,
|
|
13
|
-
onOpenChange:
|
|
14
|
+
onOpenChange: n,
|
|
14
15
|
defaultOpen: s,
|
|
15
16
|
...c
|
|
16
17
|
}) => {
|
|
17
|
-
const [
|
|
18
|
+
const [r, d] = C({
|
|
18
19
|
defaultProp: s ?? !0,
|
|
19
|
-
onChange:
|
|
20
|
+
onChange: n,
|
|
20
21
|
prop: a
|
|
21
|
-
}), m = z(t), [f,
|
|
22
|
-
|
|
22
|
+
}), m = z(t), [f, N] = I(!1);
|
|
23
|
+
x(() => {
|
|
23
24
|
t && (m.current = !0);
|
|
24
|
-
}, [t]),
|
|
25
|
-
if (m.current && !t &&
|
|
25
|
+
}, [t]), x(() => {
|
|
26
|
+
if (m.current && !t && r && !f) {
|
|
26
27
|
const u = setTimeout(() => {
|
|
27
|
-
d(!1),
|
|
28
|
-
},
|
|
28
|
+
d(!1), N(!0);
|
|
29
|
+
}, D);
|
|
29
30
|
return () => clearTimeout(u);
|
|
30
31
|
}
|
|
31
|
-
}, [t,
|
|
32
|
+
}, [t, r, d, f]);
|
|
32
33
|
const b = j(
|
|
33
34
|
(u) => d(u),
|
|
34
35
|
[d]
|
|
35
36
|
);
|
|
36
37
|
return /* @__PURE__ */ e(
|
|
37
|
-
|
|
38
|
+
T,
|
|
38
39
|
{
|
|
39
|
-
className:
|
|
40
|
+
className: i("group not-prose mb-4 w-full rounded-md border bg-background", o),
|
|
40
41
|
onOpenChange: b,
|
|
41
|
-
open:
|
|
42
|
+
open: r,
|
|
42
43
|
...c
|
|
43
44
|
}
|
|
44
45
|
);
|
|
45
|
-
},
|
|
46
|
+
}, L = {
|
|
46
47
|
"approval-requested": "Awaiting Approval",
|
|
47
48
|
"approval-responded": "Responded",
|
|
48
49
|
"input-available": "Running",
|
|
@@ -50,7 +51,7 @@ const B = 1e3, X = ({
|
|
|
50
51
|
"output-available": "Completed",
|
|
51
52
|
"output-denied": "Denied",
|
|
52
53
|
"output-error": "Error"
|
|
53
|
-
},
|
|
54
|
+
}, P = {
|
|
54
55
|
"approval-requested": /* @__PURE__ */ e(v, { className: "size-4 text-yellow-600" }),
|
|
55
56
|
"approval-responded": /* @__PURE__ */ e(h, { className: "size-4 text-blue-600" }),
|
|
56
57
|
"input-available": /* @__PURE__ */ e(v, { className: "size-4 animate-pulse" }),
|
|
@@ -58,31 +59,31 @@ const B = 1e3, X = ({
|
|
|
58
59
|
"output-available": /* @__PURE__ */ e(h, { className: "size-4 text-green-600" }),
|
|
59
60
|
"output-denied": /* @__PURE__ */ e(g, { className: "size-4 text-orange-600" }),
|
|
60
61
|
"output-error": /* @__PURE__ */ e(g, { className: "size-4 text-red-600" })
|
|
61
|
-
},
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
] }),
|
|
62
|
+
}, S = (o) => /* @__PURE__ */ l(E, { className: "gap-1.5 rounded-full text-xs", variant: "secondary", children: [
|
|
63
|
+
P[o],
|
|
64
|
+
L[o]
|
|
65
|
+
] }), G = ({
|
|
65
66
|
className: o,
|
|
66
67
|
title: t,
|
|
67
68
|
type: a,
|
|
68
|
-
state:
|
|
69
|
+
state: n,
|
|
69
70
|
toolName: s,
|
|
70
71
|
...c
|
|
71
72
|
}) => {
|
|
72
|
-
const
|
|
73
|
-
return /* @__PURE__ */
|
|
74
|
-
|
|
73
|
+
const r = a === "dynamic-tool" ? s : a.split("-").slice(1).join("-");
|
|
74
|
+
return /* @__PURE__ */ l(
|
|
75
|
+
B,
|
|
75
76
|
{
|
|
76
|
-
className:
|
|
77
|
+
className: i(
|
|
77
78
|
"flex w-full items-center justify-between gap-4 p-3",
|
|
78
79
|
o
|
|
79
80
|
),
|
|
80
81
|
...c,
|
|
81
82
|
children: [
|
|
82
|
-
/* @__PURE__ */
|
|
83
|
+
/* @__PURE__ */ l("div", { className: "flex items-center gap-2", children: [
|
|
83
84
|
/* @__PURE__ */ e(y, { className: "size-4 text-muted-foreground" }),
|
|
84
|
-
/* @__PURE__ */ e("span", { className: "font-medium text-sm", children: t ??
|
|
85
|
-
|
|
85
|
+
/* @__PURE__ */ e("span", { className: "font-medium text-sm", children: t ?? r }),
|
|
86
|
+
S(n)
|
|
86
87
|
] }),
|
|
87
88
|
/* @__PURE__ */ e(
|
|
88
89
|
w,
|
|
@@ -94,50 +95,45 @@ const B = 1e3, X = ({
|
|
|
94
95
|
]
|
|
95
96
|
}
|
|
96
97
|
);
|
|
97
|
-
},
|
|
98
|
+
}, K = ({ className: o, ...t }) => /* @__PURE__ */ e(
|
|
98
99
|
R,
|
|
99
100
|
{
|
|
100
|
-
className:
|
|
101
|
+
className: i(
|
|
101
102
|
"data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 space-y-4 p-4 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in",
|
|
102
103
|
o
|
|
103
104
|
),
|
|
104
105
|
...t
|
|
105
106
|
}
|
|
106
|
-
),
|
|
107
|
+
), M = ({ className: o, input: t, ...a }) => /* @__PURE__ */ l("div", { className: i("space-y-2 overflow-hidden", o), ...a, children: [
|
|
107
108
|
/* @__PURE__ */ e("h4", { className: "font-medium text-muted-foreground text-xs uppercase tracking-wide", children: "Parameters" }),
|
|
108
109
|
/* @__PURE__ */ e("div", { className: "rounded-md bg-muted/50", children: /* @__PURE__ */ e(p, { code: JSON.stringify(t, null, 2), language: "json" }) })
|
|
109
|
-
] }),
|
|
110
|
+
] }), Q = ({
|
|
110
111
|
className: o,
|
|
111
112
|
output: t,
|
|
112
113
|
errorText: a,
|
|
113
|
-
...
|
|
114
|
+
...n
|
|
114
115
|
}) => {
|
|
115
116
|
if (!(t || a))
|
|
116
117
|
return null;
|
|
117
118
|
let s = /* @__PURE__ */ e("div", { children: t });
|
|
118
|
-
return typeof t == "object" && !k(t) ? s = /* @__PURE__ */ e(p, { code: JSON.stringify(t, null, 2), language: "json" }) : typeof t == "string" && (s = /* @__PURE__ */ e(p, { code: t, language: "json" })), /* @__PURE__ */
|
|
119
|
+
return typeof t == "object" && !k(t) ? s = /* @__PURE__ */ e(p, { code: JSON.stringify(t, null, 2), language: "json" }) : typeof t == "string" && (s = /* @__PURE__ */ e(p, { code: t, language: "json" })), /* @__PURE__ */ l("div", { className: i("space-y-2", o), ...n, children: [
|
|
119
120
|
/* @__PURE__ */ e("h4", { className: "font-medium text-muted-foreground text-xs uppercase tracking-wide", children: a ? "Error" : "Result" }),
|
|
120
|
-
/* @__PURE__ */
|
|
121
|
-
|
|
121
|
+
a ? /* @__PURE__ */ e(
|
|
122
|
+
A,
|
|
122
123
|
{
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
),
|
|
127
|
-
children: [
|
|
128
|
-
a && /* @__PURE__ */ e("div", { children: a }),
|
|
129
|
-
s
|
|
130
|
-
]
|
|
124
|
+
variant: "destructive",
|
|
125
|
+
description: a,
|
|
126
|
+
className: "rounded-md text-xs"
|
|
131
127
|
}
|
|
132
|
-
)
|
|
128
|
+
) : /* @__PURE__ */ e("div", { className: "overflow-x-auto rounded-md bg-muted/50 text-foreground text-xs [&_table]:w-full", children: s })
|
|
133
129
|
] });
|
|
134
130
|
};
|
|
135
131
|
export {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
132
|
+
F as Tool,
|
|
133
|
+
K as ToolContent,
|
|
134
|
+
G as ToolHeader,
|
|
135
|
+
M as ToolInput,
|
|
136
|
+
Q as ToolOutput,
|
|
137
|
+
S as getStatusBadge
|
|
142
138
|
};
|
|
143
139
|
//# sourceMappingURL=tool.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool.js","sources":["../../../src/components/ai/tool.tsx"],"sourcesContent":["import { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport {\n CheckCircleIcon,\n ChevronDownIcon,\n CircleIcon,\n ClockIcon,\n WrenchIcon,\n XCircleIcon,\n} from \"lucide-react\";\nimport { isValidElement, useCallback, useEffect, useRef, useState } from \"react\";\n\n\nimport type { DynamicToolUIPart, ToolUIPart } from \"ai\";\nimport type { ComponentProps, ReactNode } from \"react\";\n\nimport { Badge } from \"@/components/ui/badge\";\nimport { CodeBlock } from \"@/components/ui/code-block\";\nimport {\n Collapsible,\n CollapsibleContent,\n CollapsibleTrigger,\n} from \"@/components/ui/collapsible\";\nimport { cn } from \"@/lib/utils\";\n\n\n\n\nconst AUTO_CLOSE_DELAY = 1000;\n\nexport type ToolProps = ComponentProps<typeof Collapsible> & {\n isStreaming?: boolean;\n};\n\nexport const Tool = ({\n className,\n isStreaming = false,\n open,\n onOpenChange,\n defaultOpen,\n ...props\n}: ToolProps) => {\n const [isOpen, setIsOpen] = useControllableState<boolean>({\n defaultProp: defaultOpen ?? true,\n onChange: onOpenChange,\n prop: open,\n });\n\n const hasEverStreamedRef = useRef(isStreaming);\n const [hasAutoClosed, setHasAutoClosed] = useState(false);\n\n useEffect(() => {\n if (isStreaming) hasEverStreamedRef.current = true;\n }, [isStreaming]);\n\n useEffect(() => {\n if (hasEverStreamedRef.current && !isStreaming && isOpen && !hasAutoClosed) {\n const timer = setTimeout(() => {\n setIsOpen(false);\n setHasAutoClosed(true);\n }, AUTO_CLOSE_DELAY);\n return () => clearTimeout(timer);\n }\n }, [isStreaming, isOpen, setIsOpen, hasAutoClosed]);\n\n const handleOpenChange = useCallback(\n (newOpen: boolean) => setIsOpen(newOpen),\n [setIsOpen]\n );\n\n return (\n <Collapsible\n className={cn(\"group not-prose mb-4 w-full rounded-md border bg-background\", className)}\n onOpenChange={handleOpenChange}\n open={isOpen}\n {...props}\n />\n );\n};\n\nexport type ToolPart = ToolUIPart | DynamicToolUIPart;\n\nexport type ToolHeaderProps = {\n title?: string;\n className?: string;\n} & (\n | { type: ToolUIPart[\"type\"]; state: ToolUIPart[\"state\"]; toolName?: never }\n | {\n type: DynamicToolUIPart[\"type\"];\n state: DynamicToolUIPart[\"state\"];\n toolName: string;\n }\n);\n\nconst statusLabels: Record<ToolPart[\"state\"], string> = {\n \"approval-requested\": \"Awaiting Approval\",\n \"approval-responded\": \"Responded\",\n \"input-available\": \"Running\",\n \"input-streaming\": \"Pending\",\n \"output-available\": \"Completed\",\n \"output-denied\": \"Denied\",\n \"output-error\": \"Error\",\n};\n\nconst statusIcons: Record<ToolPart[\"state\"], ReactNode> = {\n \"approval-requested\": <ClockIcon className=\"size-4 text-yellow-600\" />,\n \"approval-responded\": <CheckCircleIcon className=\"size-4 text-blue-600\" />,\n \"input-available\": <ClockIcon className=\"size-4 animate-pulse\" />,\n \"input-streaming\": <CircleIcon className=\"size-4\" />,\n \"output-available\": <CheckCircleIcon className=\"size-4 text-green-600\" />,\n \"output-denied\": <XCircleIcon className=\"size-4 text-orange-600\" />,\n \"output-error\": <XCircleIcon className=\"size-4 text-red-600\" />,\n};\n\nexport const getStatusBadge = (status: ToolPart[\"state\"]) => (\n <Badge className=\"gap-1.5 rounded-full text-xs\" variant=\"secondary\">\n {statusIcons[status]}\n {statusLabels[status]}\n </Badge>\n);\n\nexport const ToolHeader = ({\n className,\n title,\n type,\n state,\n toolName,\n ...props\n}: ToolHeaderProps) => {\n const derivedName =\n type === \"dynamic-tool\" ? toolName : type.split(\"-\").slice(1).join(\"-\");\n\n return (\n <CollapsibleTrigger\n className={cn(\n \"flex w-full items-center justify-between gap-4 p-3\",\n className\n )}\n {...props}\n >\n <div className=\"flex items-center gap-2\">\n <WrenchIcon className=\"size-4 text-muted-foreground\" />\n <span className=\"font-medium text-sm\">{title ?? derivedName}</span>\n {getStatusBadge(state)}\n </div>\n <ChevronDownIcon\n className=\"size-4 text-muted-foreground opacity-0 transition-all group-focus-within:opacity-100 group-hover:opacity-100 group-data-[state=open]:rotate-180 group-data-[state=open]:opacity-100\"\n data-slot=\"collapsible-chevron\"\n />\n </CollapsibleTrigger>\n );\n};\n\nexport type ToolContentProps = ComponentProps<typeof CollapsibleContent>;\n\nexport const ToolContent = ({ className, ...props }: ToolContentProps) => (\n <CollapsibleContent\n className={cn(\n \"data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 space-y-4 p-4 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in\",\n className\n )}\n {...props}\n />\n);\n\nexport type ToolInputProps = ComponentProps<\"div\"> & {\n input: ToolPart[\"input\"];\n};\n\nexport const ToolInput = ({ className, input, ...props }: ToolInputProps) => (\n <div className={cn(\"space-y-2 overflow-hidden\", className)} {...props}>\n <h4 className=\"font-medium text-muted-foreground text-xs uppercase tracking-wide\">\n Parameters\n </h4>\n <div className=\"rounded-md bg-muted/50\">\n <CodeBlock code={JSON.stringify(input, null, 2)} language=\"json\" />\n </div>\n </div>\n);\n\nexport type ToolOutputProps = ComponentProps<\"div\"> & {\n output: ToolPart[\"output\"];\n errorText: ToolPart[\"errorText\"];\n};\n\nexport const ToolOutput = ({\n className,\n output,\n errorText,\n ...props\n}: ToolOutputProps) => {\n if (!(output || errorText)) {\n return null;\n }\n\n let Output = <div>{output as ReactNode}</div>;\n\n if (typeof output === \"object\" && !isValidElement(output)) {\n Output = (\n <CodeBlock code={JSON.stringify(output, null, 2)} language=\"json\" />\n );\n } else if (typeof output === \"string\") {\n Output = <CodeBlock code={output} language=\"json\" />;\n }\n\n return (\n <div className={cn(\"space-y-2\", className)} {...props}>\n <h4 className=\"font-medium text-muted-foreground text-xs uppercase tracking-wide\">\n {errorText ? \"Error\" : \"Result\"}\n </h4>\n <div\n className={cn(\n \"overflow-x-auto rounded-md text-xs [&_table]:w-full\",\n errorText\n ? \"bg-destructive/10 text-destructive\"\n : \"bg-muted/50 text-foreground\"\n )}\n >\n {errorText && <div>{errorText}</div>}\n {Output}\n </div>\n </div>\n );\n};\n"],"names":["AUTO_CLOSE_DELAY","Tool","className","isStreaming","open","onOpenChange","defaultOpen","props","isOpen","setIsOpen","useControllableState","hasEverStreamedRef","useRef","hasAutoClosed","setHasAutoClosed","useState","useEffect","timer","handleOpenChange","useCallback","newOpen","jsx","Collapsible","cn","statusLabels","statusIcons","ClockIcon","CheckCircleIcon","CircleIcon","XCircleIcon","getStatusBadge","status","jsxs","Badge","ToolHeader","title","type","state","toolName","derivedName","CollapsibleTrigger","WrenchIcon","ChevronDownIcon","ToolContent","CollapsibleContent","ToolInput","input","CodeBlock","ToolOutput","output","errorText","Output","isValidElement"],"mappings":";;;;;;;;AA2BA,MAAMA,IAAmB,KAMZC,IAAO,CAAC;AAAA,EACnB,WAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,MAAAC;AAAA,EACA,cAAAC;AAAA,EACA,aAAAC;AAAA,EACA,GAAGC;AACL,MAAiB;AACf,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAA8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gBAAA7B,EAAC,SAAK,UAAA6B,EAAA,CAAU;AAAA,UAC7BC;AAAA,QAAA;AAAA,MAAA;AAAA,IAAA;AAAA,EACH,GACF;AAEJ;"}
|
|
1
|
+
{"version":3,"file":"tool.js","sources":["../../../src/components/ai/tool.tsx"],"sourcesContent":["import { useControllableState } from \"@radix-ui/react-use-controllable-state\";\nimport {\n CheckCircleIcon,\n ChevronDownIcon,\n CircleIcon,\n ClockIcon,\n WrenchIcon,\n XCircleIcon,\n} from \"lucide-react\";\nimport { isValidElement, useCallback, useEffect, useRef, useState } from \"react\";\n\n\nimport type { DynamicToolUIPart, ToolUIPart } from \"ai\";\nimport type { ComponentProps, ReactNode } from \"react\";\n\nimport { Badge } from \"@/components/ui/badge\";\nimport { Banner } from \"@/components/ui/banner\";\nimport { CodeBlock } from \"@/components/ui/code-block\";\nimport {\n Collapsible,\n CollapsibleContent,\n CollapsibleTrigger,\n} from \"@/components/ui/collapsible\";\nimport { cn } from \"@/lib/utils\";\n\n\n\n\nconst AUTO_CLOSE_DELAY = 1000;\n\nexport type ToolProps = ComponentProps<typeof Collapsible> & {\n isStreaming?: boolean;\n};\n\nexport const Tool = ({\n className,\n isStreaming = false,\n open,\n onOpenChange,\n defaultOpen,\n ...props\n}: ToolProps) => {\n const [isOpen, setIsOpen] = useControllableState<boolean>({\n defaultProp: defaultOpen ?? true,\n onChange: onOpenChange,\n prop: open,\n });\n\n const hasEverStreamedRef = useRef(isStreaming);\n const [hasAutoClosed, setHasAutoClosed] = useState(false);\n\n useEffect(() => {\n if (isStreaming) hasEverStreamedRef.current = true;\n }, [isStreaming]);\n\n useEffect(() => {\n if (hasEverStreamedRef.current && !isStreaming && isOpen && !hasAutoClosed) {\n const timer = setTimeout(() => {\n setIsOpen(false);\n setHasAutoClosed(true);\n }, AUTO_CLOSE_DELAY);\n return () => clearTimeout(timer);\n }\n }, [isStreaming, isOpen, setIsOpen, hasAutoClosed]);\n\n const handleOpenChange = useCallback(\n (newOpen: boolean) => setIsOpen(newOpen),\n [setIsOpen]\n );\n\n return (\n <Collapsible\n className={cn(\"group not-prose mb-4 w-full rounded-md border bg-background\", className)}\n onOpenChange={handleOpenChange}\n open={isOpen}\n {...props}\n />\n );\n};\n\nexport type ToolPart = ToolUIPart | DynamicToolUIPart;\n\nexport type ToolHeaderProps = {\n title?: string;\n className?: string;\n} & (\n | { type: ToolUIPart[\"type\"]; state: ToolUIPart[\"state\"]; toolName?: never }\n | {\n type: DynamicToolUIPart[\"type\"];\n state: DynamicToolUIPart[\"state\"];\n toolName: string;\n }\n);\n\nconst statusLabels: Record<ToolPart[\"state\"], string> = {\n \"approval-requested\": \"Awaiting Approval\",\n \"approval-responded\": \"Responded\",\n \"input-available\": \"Running\",\n \"input-streaming\": \"Pending\",\n \"output-available\": \"Completed\",\n \"output-denied\": \"Denied\",\n \"output-error\": \"Error\",\n};\n\nconst statusIcons: Record<ToolPart[\"state\"], ReactNode> = {\n \"approval-requested\": <ClockIcon className=\"size-4 text-yellow-600\" />,\n \"approval-responded\": <CheckCircleIcon className=\"size-4 text-blue-600\" />,\n \"input-available\": <ClockIcon className=\"size-4 animate-pulse\" />,\n \"input-streaming\": <CircleIcon className=\"size-4\" />,\n \"output-available\": <CheckCircleIcon className=\"size-4 text-green-600\" />,\n \"output-denied\": <XCircleIcon className=\"size-4 text-orange-600\" />,\n \"output-error\": <XCircleIcon className=\"size-4 text-red-600\" />,\n};\n\nexport const getStatusBadge = (status: ToolPart[\"state\"]) => (\n <Badge className=\"gap-1.5 rounded-full text-xs\" variant=\"secondary\">\n {statusIcons[status]}\n {statusLabels[status]}\n </Badge>\n);\n\nexport const ToolHeader = ({\n className,\n title,\n type,\n state,\n toolName,\n ...props\n}: ToolHeaderProps) => {\n const derivedName =\n type === \"dynamic-tool\" ? toolName : type.split(\"-\").slice(1).join(\"-\");\n\n return (\n <CollapsibleTrigger\n className={cn(\n \"flex w-full items-center justify-between gap-4 p-3\",\n className\n )}\n {...props}\n >\n <div className=\"flex items-center gap-2\">\n <WrenchIcon className=\"size-4 text-muted-foreground\" />\n <span className=\"font-medium text-sm\">{title ?? derivedName}</span>\n {getStatusBadge(state)}\n </div>\n <ChevronDownIcon\n className=\"size-4 text-muted-foreground opacity-0 transition-all group-focus-within:opacity-100 group-hover:opacity-100 group-data-[state=open]:rotate-180 group-data-[state=open]:opacity-100\"\n data-slot=\"collapsible-chevron\"\n />\n </CollapsibleTrigger>\n );\n};\n\nexport type ToolContentProps = ComponentProps<typeof CollapsibleContent>;\n\nexport const ToolContent = ({ className, ...props }: ToolContentProps) => (\n <CollapsibleContent\n className={cn(\n \"data-[state=closed]:fade-out-0 data-[state=closed]:slide-out-to-top-2 data-[state=open]:slide-in-from-top-2 space-y-4 p-4 text-popover-foreground outline-none data-[state=closed]:animate-out data-[state=open]:animate-in\",\n className\n )}\n {...props}\n />\n);\n\nexport type ToolInputProps = ComponentProps<\"div\"> & {\n input: ToolPart[\"input\"];\n};\n\nexport const ToolInput = ({ className, input, ...props }: ToolInputProps) => (\n <div className={cn(\"space-y-2 overflow-hidden\", className)} {...props}>\n <h4 className=\"font-medium text-muted-foreground text-xs uppercase tracking-wide\">\n Parameters\n </h4>\n <div className=\"rounded-md bg-muted/50\">\n <CodeBlock code={JSON.stringify(input, null, 2)} language=\"json\" />\n </div>\n </div>\n);\n\nexport type ToolOutputProps = ComponentProps<\"div\"> & {\n output: ToolPart[\"output\"];\n errorText: ToolPart[\"errorText\"];\n};\n\nexport const ToolOutput = ({\n className,\n output,\n errorText,\n ...props\n}: ToolOutputProps) => {\n if (!(output || errorText)) {\n return null;\n }\n\n let Output = <div>{output as ReactNode}</div>;\n\n if (typeof output === \"object\" && !isValidElement(output)) {\n Output = (\n <CodeBlock code={JSON.stringify(output, null, 2)} language=\"json\" />\n );\n } else if (typeof output === \"string\") {\n Output = <CodeBlock code={output} language=\"json\" />;\n }\n\n return (\n <div className={cn(\"space-y-2\", className)} {...props}>\n <h4 className=\"font-medium text-muted-foreground text-xs uppercase tracking-wide\">\n {errorText ? \"Error\" : \"Result\"}\n </h4>\n {errorText ? (\n <Banner\n variant=\"destructive\"\n description={errorText}\n className=\"rounded-md text-xs\"\n />\n ) : (\n <div className=\"overflow-x-auto rounded-md bg-muted/50 text-foreground text-xs [&_table]:w-full\">\n {Output}\n </div>\n )}\n </div>\n );\n};\n"],"names":["AUTO_CLOSE_DELAY","Tool","className","isStreaming","open","onOpenChange","defaultOpen","props","isOpen","setIsOpen","useControllableState","hasEverStreamedRef","useRef","hasAutoClosed","setHasAutoClosed","useState","useEffect","timer","handleOpenChange","useCallback","newOpen","jsx","Collapsible","cn","statusLabels","statusIcons","ClockIcon","CheckCircleIcon","CircleIcon","XCircleIcon","getStatusBadge","status","jsxs","Badge","ToolHeader","title","type","state","toolName","derivedName","CollapsibleTrigger","WrenchIcon","ChevronDownIcon","ToolContent","CollapsibleContent","ToolInput","input","CodeBlock","ToolOutput","output","errorText","Output","isValidElement","Banner"],"mappings":";;;;;;;;;AA4BA,MAAMA,IAAmB,KAMZC,IAAO,CAAC;AAAA,EACnB,WAAAC;AAAA,EACA,aAAAC,IAAc;AAAA,EACd,MAAAC;AAAA,EACA,cAAAC;AAAA,EACA,aAAAC;AAAA,EACA,GAAGC;AACL,MAAiB;AACf,QAAM,CAACC,GAAQC,CAAS,IAAIC,EAA8B;AAAA,IACxD,aAAaJ,KAAe;AAAA,IAC5B,UAAUD;AAAA,IACV,MAAMD;AAAA,EAAA,CACP,GAEKO,IAAqBC,EAAOT,CAAW,GACvC,CAACU,GAAeC,CAAgB,IAAIC,EAAS,EAAK;AAExD,EAAAC,EAAU,MAAM;AACd,IAAIb,QAAgC,UAAU;AAAA,EAChD,GAAG,CAACA,CAAW,CAAC,GAEhBa,EAAU,MAAM;AACd,QAAIL,EAAmB,WAAW,CAACR,KAAeK,KAAU,CAACK,GAAe;AAC1E,YAAMI,IAAQ,WAAW,MAAM;AAC7B,QAAAR,EAAU,EAAK,GACfK,EAAiB,EAAI;AAAA,MACvB,GAAG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AAG,UAAS,QAAO,EAAA,CACnE;AAAA,EAAA,CACF,GAQWE,IAAa,CAAC;AAAA,EACzB,WAAA9C;AAAA,EACA,QAAA+C;AAAA,EACA,WAAAC;AAAA,EACA,GAAG3C;AACL,MAAuB;AACrB,MAAI,EAAE0C,KAAUC;AACd,WAAO;AAGT,MAAIC,IAAS,gBAAA9B,EAAC,OAAA,EAAK,UAAA4B,EAAA,CAAoB;AAEvC,SAAI,OAAOA,KAAW,YAAY,CAACG,EAAeH,CAAM,IACtDE,IACE,gBAAA9B,EAAC0B,GAAA,EAAU,MAAM,KAAK,UAAUE,GAAQ,MAAM,CAAC,GAAG,UAAS,OAAA,CAAO,IAE3D,OAAOA,KAAW,aAC3BE,IAAS,gBAAA9B,EAAC0B,GAAA,EAAU,MAAME,GAAQ,UAAS,QAAO,IAIlD,gBAAAjB,EAAC,SAAI,WAAWT,EAAG,aAAarB,CAAS,GAAI,GAAGK,GAC9C,UAAA;AAAA,IAAA,gBAAAc,EAAC,MAAA,EAAG,WAAU,qEACX,UAAA6B,IAAY,UAAU,UACzB;AAAA,IACCA,IACC,gBAAA7B;AAAA,MAACgC;AAAA,MAAA;AAAA,QACC,SAAQ;AAAA,QACR,aAAaH;AAAA,QACb,WAAU;AAAA,MAAA;AAAA,IAAA,IAGZ,gBAAA7B,EAAC,OAAA,EAAI,WAAU,mFACZ,UAAA8B,EAAA,CACH;AAAA,EAAA,GAEJ;AAEJ;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("react");let n=null,t=null;function i(){return t??=Promise.resolve().then(()=>require("./streamdown-plugins.cjs")).then(e=>(n=e.streamdownPlugins,n)).catch(e=>{throw t=null,n=null,e}),t}function o(){const[e,r]=l.useState(n??void 0);return l.useEffect(()=>{if(e)return;let u=!1;return i().then(s=>{u||r(s)}),()=>{u=!0}},[e]),e}exports.useStreamdownPlugins=o;
|
|
2
|
+
//# sourceMappingURL=use-streamdown-plugins.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-streamdown-plugins.cjs","sources":["../../../src/components/ai/use-streamdown-plugins.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\nimport type { PluginConfig } from \"streamdown\";\n\n// Module-level cache so the lazy chunk is fetched once and later mounts get\n// the plugins synchronously on first render (no highlight flash).\nlet cachedPlugins: PluginConfig | null = null;\nlet pluginsPromise: Promise<PluginConfig> | null = null;\n\nfunction loadStreamdownPlugins(): Promise<PluginConfig> {\n pluginsPromise ??= import(\"./streamdown-plugins\")\n .then((mod) => {\n cachedPlugins = mod.streamdownPlugins;\n return cachedPlugins;\n })\n .catch((error) => {\n pluginsPromise = null;\n cachedPlugins = null;\n throw error;\n });\n return pluginsPromise;\n}\n\n/**\n * Lazily loads the streamdown plugin set (SW-2007). Markdown renders\n * immediately without plugins; code highlighting, math, and mermaid upgrade\n * in place once the lazy chunk arrives, keeping shiki/KaTeX/mermaid out of\n * the consumer's main bundle.\n */\nexport function useStreamdownPlugins(): PluginConfig | undefined {\n const [plugins, setPlugins] = useState<PluginConfig | undefined>(\n cachedPlugins ?? undefined,\n );\n\n useEffect(() => {\n if (plugins) return;\n let cancelled = false;\n void loadStreamdownPlugins().then((loaded) => {\n if (!cancelled) setPlugins(loaded);\n });\n return () => {\n cancelled = true;\n };\n }, [plugins]);\n\n return plugins;\n}\n"],"names":["cachedPlugins","pluginsPromise","loadStreamdownPlugins","mod","error","useStreamdownPlugins","plugins","setPlugins","useState","useEffect","cancelled","loaded"],"mappings":"yGAMA,IAAIA,EAAqC,KACrCC,EAA+C,KAEnD,SAASC,GAA+C,CACtD,OAAAD,IAAmB,QAAA,QAAA,EAAA,KAAA,IAAA,QAAO,0BAAsB,CAAA,EAC7C,KAAME,IACLH,EAAgBG,EAAI,kBACbH,EACR,EACA,MAAOI,GAAU,CAChB,MAAAH,EAAiB,KACjBD,EAAgB,KACVI,CACR,CAAC,EACIH,CACT,CAQO,SAASI,GAAiD,CAC/D,KAAM,CAACC,EAASC,CAAU,EAAIC,EAAAA,SAC5BR,GAAiB,MAAA,EAGnBS,OAAAA,EAAAA,UAAU,IAAM,CACd,GAAIH,EAAS,OACb,IAAII,EAAY,GAChB,OAAKR,EAAA,EAAwB,KAAMS,GAAW,CACvCD,GAAWH,EAAWI,CAAM,CACnC,CAAC,EACM,IAAM,CACXD,EAAY,EACd,CACF,EAAG,CAACJ,CAAO,CAAC,EAELA,CACT"}
|