tempest-react-sdk 0.39.0 → 0.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_virtual/_rolldown/runtime.cjs +1 -1
- package/dist/access/access-control-context.cjs.map +1 -1
- package/dist/access/use-can.cjs.map +1 -1
- package/dist/app/AppProviders.cjs.map +1 -1
- package/dist/app/AppProviders.js.map +1 -1
- package/dist/audio/use-audio-recorder.cjs.map +1 -1
- package/dist/audio/use-audio.cjs.map +1 -1
- package/dist/audio/use-microphone.cjs.map +1 -1
- package/dist/auth/create-auth-store.cjs.map +1 -1
- package/dist/auth/lazy-with-retry.cjs.map +1 -1
- package/dist/auth/passkey.cjs.map +1 -1
- package/dist/auth/passkey.js.map +1 -1
- package/dist/auth/use-passkey.cjs.map +1 -1
- package/dist/br/BrazilMap.cjs +1 -1
- package/dist/br/BrazilMap.cjs.map +1 -1
- package/dist/br/BrazilMap.js +2 -2
- package/dist/br/BrazilMap.js.map +1 -1
- package/dist/br/BrazilStateCitySelect.cjs.map +1 -1
- package/dist/br/BrazilStateCitySelect.js.map +1 -1
- package/dist/br/BrazilStateMap.cjs +1 -1
- package/dist/br/BrazilStateMap.cjs.map +1 -1
- package/dist/br/BrazilStateMap.js +2 -2
- package/dist/br/BrazilStateMap.js.map +1 -1
- package/dist/br/MapLegend.cjs.map +1 -1
- package/dist/br/MapLegend.js.map +1 -1
- package/dist/br/MapMarkers.cjs.map +1 -1
- package/dist/br/MapMarkers.js.map +1 -1
- package/dist/br/MunicipalitySearch.cjs.map +1 -1
- package/dist/br/MunicipalitySearch.js.map +1 -1
- package/dist/br/PixQRCode.cjs.map +1 -1
- package/dist/br/PixQRCode.js.map +1 -1
- package/dist/br/use-map-hover.cjs.map +1 -1
- package/dist/br/use-map-zoom.cjs.map +1 -1
- package/dist/capture/media-recorder.cjs +1 -1
- package/dist/capture/media-recorder.js +2 -2
- package/dist/capture/use-barcode-scanner.cjs +1 -1
- package/dist/capture/use-barcode-scanner.cjs.map +1 -1
- package/dist/capture/use-barcode-scanner.js +2 -2
- package/dist/capture/use-barcode-scanner.js.map +1 -1
- package/dist/capture/use-screen-capture.cjs.map +1 -1
- package/dist/capture/use-speech-recognition.cjs.map +1 -1
- package/dist/capture/use-torch.cjs.map +1 -1
- package/dist/capture/use-video-recorder.cjs.map +1 -1
- package/dist/charts/AreaChart.cjs.map +1 -1
- package/dist/charts/AreaChart.js.map +1 -1
- package/dist/charts/BarChart.cjs.map +1 -1
- package/dist/charts/BarChart.js.map +1 -1
- package/dist/charts/LineChart.cjs.map +1 -1
- package/dist/charts/LineChart.js.map +1 -1
- package/dist/charts/PieChart.cjs.map +1 -1
- package/dist/charts/PieChart.js.map +1 -1
- package/dist/charts/RadarChart.cjs.map +1 -1
- package/dist/charts/RadarChart.js.map +1 -1
- package/dist/charts/use-chart-colors.cjs.map +1 -1
- package/dist/components/AIChat/AIChat.cjs.map +1 -1
- package/dist/components/AIChat/AIChat.js.map +1 -1
- package/dist/components/AIChat/AIChatComposer.cjs.map +1 -1
- package/dist/components/AIChat/AIChatComposer.js.map +1 -1
- package/dist/components/AIChat/AIChatTurn.cjs.map +1 -1
- package/dist/components/AIChat/AIChatTurn.js.map +1 -1
- package/dist/components/Accordion/Accordion.cjs.map +1 -1
- package/dist/components/Accordion/Accordion.js.map +1 -1
- package/dist/components/Alert/Alert.cjs.map +1 -1
- package/dist/components/Alert/Alert.js.map +1 -1
- package/dist/components/AppBar/AppBar.cjs.map +1 -1
- package/dist/components/AppBar/AppBar.js.map +1 -1
- package/dist/components/AppShell/AppShell.cjs.map +1 -1
- package/dist/components/AppShell/AppShell.js.map +1 -1
- package/dist/components/AudioPlayer/AudioPlayer.cjs.map +1 -1
- package/dist/components/AudioPlayer/AudioPlayer.js.map +1 -1
- package/dist/components/AudioRecorder/AudioRecorder.cjs.map +1 -1
- package/dist/components/AudioRecorder/AudioRecorder.js.map +1 -1
- package/dist/components/Avatar/Avatar.cjs.map +1 -1
- package/dist/components/Avatar/Avatar.js.map +1 -1
- package/dist/components/AvatarGroup/AvatarGroup.cjs.map +1 -1
- package/dist/components/AvatarGroup/AvatarGroup.js.map +1 -1
- package/dist/components/Badge/Badge.cjs.map +1 -1
- package/dist/components/Badge/Badge.js.map +1 -1
- package/dist/components/Banner/Banner.cjs.map +1 -1
- package/dist/components/Banner/Banner.js.map +1 -1
- package/dist/components/BarcodeScanner/BarcodeScanner.cjs.map +1 -1
- package/dist/components/BarcodeScanner/BarcodeScanner.js.map +1 -1
- package/dist/components/BottomNavigation/BottomNavigation.cjs.map +1 -1
- package/dist/components/BottomNavigation/BottomNavigation.js.map +1 -1
- package/dist/components/BottomSheet/BottomSheet.cjs.map +1 -1
- package/dist/components/BottomSheet/BottomSheet.js.map +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.cjs.map +1 -1
- package/dist/components/Breadcrumbs/Breadcrumbs.js.map +1 -1
- package/dist/components/Button/Button.cjs.map +1 -1
- package/dist/components/Button/Button.js.map +1 -1
- package/dist/components/Calendar/Calendar.cjs +1 -1
- package/dist/components/Calendar/Calendar.cjs.map +1 -1
- package/dist/components/Calendar/Calendar.js +38 -41
- package/dist/components/Calendar/Calendar.js.map +1 -1
- package/dist/components/Card/Card.cjs.map +1 -1
- package/dist/components/Card/Card.js.map +1 -1
- package/dist/components/Carousel/Carousel.cjs.map +1 -1
- package/dist/components/Carousel/Carousel.js.map +1 -1
- package/dist/components/Chat/Chat.cjs.map +1 -1
- package/dist/components/Chat/Chat.js.map +1 -1
- package/dist/components/Chat/ChatComposer.cjs.map +1 -1
- package/dist/components/Chat/ChatComposer.js.map +1 -1
- package/dist/components/Chat/chat-groups.cjs +1 -1
- package/dist/components/Chat/chat-groups.cjs.map +1 -1
- package/dist/components/Chat/chat-groups.js +2 -2
- package/dist/components/Chat/chat-groups.js.map +1 -1
- package/dist/components/Checkbox/Checkbox.cjs.map +1 -1
- package/dist/components/Checkbox/Checkbox.js.map +1 -1
- package/dist/components/ChipInput/ChipInput.cjs.map +1 -1
- package/dist/components/ChipInput/ChipInput.js.map +1 -1
- package/dist/components/ClickOutside/ClickOutside.cjs.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.cjs.map +1 -1
- package/dist/components/CodeBlock/CodeBlock.js.map +1 -1
- package/dist/components/Collapsible/Collapsible.cjs.map +1 -1
- package/dist/components/Collapsible/Collapsible.js.map +1 -1
- package/dist/components/Combobox/Combobox.cjs.map +1 -1
- package/dist/components/Combobox/Combobox.js.map +1 -1
- package/dist/components/Command/Command.cjs.map +1 -1
- package/dist/components/Command/Command.js.map +1 -1
- package/dist/components/ConfirmDialog/ConfirmDialog.cjs.map +1 -1
- package/dist/components/ConfirmDialog/ConfirmDialog.js.map +1 -1
- package/dist/components/ContextMenu/ContextMenu.cjs.map +1 -1
- package/dist/components/ContextMenu/ContextMenu.js.map +1 -1
- package/dist/components/CopyButton/CopyButton.cjs.map +1 -1
- package/dist/components/CopyButton/CopyButton.js.map +1 -1
- package/dist/components/DataList/DataList.cjs.map +1 -1
- package/dist/components/DataList/DataList.js.map +1 -1
- package/dist/components/DataTable/DataTable.cjs +1 -1
- package/dist/components/DataTable/DataTable.cjs.map +1 -1
- package/dist/components/DataTable/DataTable.js +2 -2
- package/dist/components/DataTable/DataTable.js.map +1 -1
- package/dist/components/DataTable/EditableCell.cjs.map +1 -1
- package/dist/components/DataTable/EditableCell.js.map +1 -1
- package/dist/components/DatePicker/DatePicker.cjs.map +1 -1
- package/dist/components/DateRangePicker/DateRangePicker.cjs.map +1 -1
- package/dist/components/DateRangePicker/DateRangePicker.js.map +1 -1
- package/dist/components/DescriptionList/DescriptionList.cjs.map +1 -1
- package/dist/components/DescriptionList/DescriptionList.js.map +1 -1
- package/dist/components/Divider/Divider.cjs.map +1 -1
- package/dist/components/Divider/Divider.js.map +1 -1
- package/dist/components/Drawer/Drawer.cjs.map +1 -1
- package/dist/components/Drawer/Drawer.js.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.cjs.map +1 -1
- package/dist/components/DropdownMenu/DropdownMenu.js.map +1 -1
- package/dist/components/Dropzone/Dropzone.cjs.map +1 -1
- package/dist/components/Dropzone/Dropzone.js.map +1 -1
- package/dist/components/EmptyState/EmptyState.cjs.map +1 -1
- package/dist/components/EmptyState/EmptyState.js.map +1 -1
- package/dist/components/ErrorState/ErrorState.cjs.map +1 -1
- package/dist/components/ErrorState/ErrorState.js.map +1 -1
- package/dist/components/FileUpload/FileUpload.cjs +1 -1
- package/dist/components/FileUpload/FileUpload.cjs.map +1 -1
- package/dist/components/FileUpload/FileUpload.js +1 -1
- package/dist/components/FileUpload/FileUpload.js.map +1 -1
- package/dist/components/FilterBar/FilterBar.cjs.map +1 -1
- package/dist/components/FilterBar/FilterBar.js.map +1 -1
- package/dist/components/FloatingActionButton/FloatingActionButton.cjs.map +1 -1
- package/dist/components/FloatingActionButton/FloatingActionButton.js.map +1 -1
- package/dist/components/Form/Form.cjs.map +1 -1
- package/dist/components/Form/Form.js.map +1 -1
- package/dist/components/HoverCard/HoverCard.cjs.map +1 -1
- package/dist/components/HoverCard/HoverCard.js.map +1 -1
- package/dist/components/Image/Image.cjs.map +1 -1
- package/dist/components/ImageCropper/ImageCropper.cjs +1 -1
- package/dist/components/ImageCropper/ImageCropper.cjs.map +1 -1
- package/dist/components/ImageCropper/ImageCropper.js +1 -1
- package/dist/components/ImageCropper/ImageCropper.js.map +1 -1
- package/dist/components/Input/Input.cjs.map +1 -1
- package/dist/components/Input/Input.js.map +1 -1
- package/dist/components/InstallBanner/InstallBanner.cjs.map +1 -1
- package/dist/components/InstallBanner/InstallBanner.js.map +1 -1
- package/dist/components/InstallButton/InstallButton.cjs.map +1 -1
- package/dist/components/InstallButton/InstallButton.js.map +1 -1
- package/dist/components/Kanban/Kanban.cjs.map +1 -1
- package/dist/components/Kanban/Kanban.js.map +1 -1
- package/dist/components/Label/Label.cjs.map +1 -1
- package/dist/components/Label/Label.js.map +1 -1
- package/dist/components/Lightbox/Lightbox.cjs.map +1 -1
- package/dist/components/Lightbox/Lightbox.js.map +1 -1
- package/dist/components/ListTile/ListTile.cjs.map +1 -1
- package/dist/components/ListTile/ListTile.js.map +1 -1
- package/dist/components/Markdown/Markdown.cjs +1 -1
- package/dist/components/Markdown/Markdown.cjs.map +1 -1
- package/dist/components/Markdown/Markdown.js +2 -2
- package/dist/components/Markdown/Markdown.js.map +1 -1
- package/dist/components/Masonry/Masonry.cjs.map +1 -1
- package/dist/components/Masonry/Masonry.js.map +1 -1
- package/dist/components/Menubar/Menubar.cjs.map +1 -1
- package/dist/components/Menubar/Menubar.js.map +1 -1
- package/dist/components/Modal/Modal.cjs.map +1 -1
- package/dist/components/Modal/Modal.js.map +1 -1
- package/dist/components/ModalsManager/ModalsManager.cjs.map +1 -1
- package/dist/components/ModalsManager/ModalsManager.js.map +1 -1
- package/dist/components/Money/Money.cjs.map +1 -1
- package/dist/components/Money/Money.js.map +1 -1
- package/dist/components/MultiSelect/MultiSelect.cjs.map +1 -1
- package/dist/components/MultiSelect/MultiSelect.js.map +1 -1
- package/dist/components/NProgress/NProgress.cjs.map +1 -1
- package/dist/components/Navbar/Navbar.cjs.map +1 -1
- package/dist/components/Navbar/Navbar.js.map +1 -1
- package/dist/components/NavigationMenu/NavigationMenu.cjs.map +1 -1
- package/dist/components/NavigationMenu/NavigationMenu.js.map +1 -1
- package/dist/components/NavigationRail/NavigationRail.cjs.map +1 -1
- package/dist/components/NavigationRail/NavigationRail.js.map +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.cjs.map +1 -1
- package/dist/components/NotificationCenter/NotificationCenter.js.map +1 -1
- package/dist/components/NotificationCenter/use-notification-inbox.cjs.map +1 -1
- package/dist/components/OfflineIndicator/OfflineIndicator.cjs.map +1 -1
- package/dist/components/OfflineIndicator/OfflineIndicator.js.map +1 -1
- package/dist/components/Page/Page.cjs.map +1 -1
- package/dist/components/Page/Page.js.map +1 -1
- package/dist/components/Pagination/Pagination.cjs.map +1 -1
- package/dist/components/Pagination/Pagination.js.map +1 -1
- package/dist/components/PasswordInput/PasswordInput.cjs.map +1 -1
- package/dist/components/PasswordInput/PasswordInput.js.map +1 -1
- package/dist/components/PinInput/PinInput.cjs.map +1 -1
- package/dist/components/PinInput/PinInput.js.map +1 -1
- package/dist/components/Popover/Popover.cjs.map +1 -1
- package/dist/components/Popover/Popover.js.map +1 -1
- package/dist/components/Portal/Portal.cjs.map +1 -1
- package/dist/components/Progress/Progress.cjs.map +1 -1
- package/dist/components/Progress/Progress.js.map +1 -1
- package/dist/components/QRCode/QRCode.cjs.map +1 -1
- package/dist/components/QRCode/QRCode.js.map +1 -1
- package/dist/components/Radio/Radio.cjs.map +1 -1
- package/dist/components/Radio/Radio.js.map +1 -1
- package/dist/components/RangeSlider/RangeSlider.cjs.map +1 -1
- package/dist/components/RangeSlider/RangeSlider.js.map +1 -1
- package/dist/components/RatingStars/RatingStars.cjs.map +1 -1
- package/dist/components/RatingStars/RatingStars.js.map +1 -1
- package/dist/components/RefreshIndicator/RefreshIndicator.cjs.map +1 -1
- package/dist/components/RefreshIndicator/RefreshIndicator.js.map +1 -1
- package/dist/components/RelativeTime/RelativeTime.cjs.map +1 -1
- package/dist/components/RelativeTime/RelativeTime.js.map +1 -1
- package/dist/components/Resizable/Resizable.cjs.map +1 -1
- package/dist/components/Resizable/Resizable.js.map +1 -1
- package/dist/components/Scheduler/Scheduler.cjs.map +1 -1
- package/dist/components/Scheduler/Scheduler.js.map +1 -1
- package/dist/components/ScrollArea/ScrollArea.cjs.map +1 -1
- package/dist/components/SearchBar/SearchBar.cjs.map +1 -1
- package/dist/components/SearchBar/SearchBar.js.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.cjs.map +1 -1
- package/dist/components/SegmentedControl/SegmentedControl.js.map +1 -1
- package/dist/components/Select/Select.cjs.map +1 -1
- package/dist/components/Select/Select.js.map +1 -1
- package/dist/components/Sidebar/Sidebar.cjs.map +1 -1
- package/dist/components/Sidebar/Sidebar.js.map +1 -1
- package/dist/components/SignaturePad/SignaturePad.cjs.map +1 -1
- package/dist/components/SignaturePad/SignaturePad.js.map +1 -1
- package/dist/components/Slider/Slider.cjs.map +1 -1
- package/dist/components/Slider/Slider.js.map +1 -1
- package/dist/components/Sparkline/Sparkline.cjs.map +1 -1
- package/dist/components/Sparkline/Sparkline.js.map +1 -1
- package/dist/components/Spinner/Spinner.cjs.map +1 -1
- package/dist/components/Spinner/Spinner.js.map +1 -1
- package/dist/components/Stat/Stat.cjs.map +1 -1
- package/dist/components/Stat/Stat.js.map +1 -1
- package/dist/components/Stepper/Stepper.cjs.map +1 -1
- package/dist/components/Stepper/Stepper.js.map +1 -1
- package/dist/components/StepperInput/StepperInput.cjs.map +1 -1
- package/dist/components/StepperInput/StepperInput.js.map +1 -1
- package/dist/components/Switch/Switch.cjs.map +1 -1
- package/dist/components/Switch/Switch.js.map +1 -1
- package/dist/components/SyncStatusBadge/SyncStatusBadge.cjs.map +1 -1
- package/dist/components/SyncStatusBadge/SyncStatusBadge.js.map +1 -1
- package/dist/components/Table/Table.cjs.map +1 -1
- package/dist/components/Table/Table.js.map +1 -1
- package/dist/components/Tabs/Tabs.cjs.map +1 -1
- package/dist/components/Tabs/Tabs.js.map +1 -1
- package/dist/components/Tag/Tag.cjs.map +1 -1
- package/dist/components/Tag/Tag.js.map +1 -1
- package/dist/components/Textarea/Textarea.cjs.map +1 -1
- package/dist/components/Textarea/Textarea.js.map +1 -1
- package/dist/components/TimePicker/TimePicker.cjs.map +1 -1
- package/dist/components/TimePicker/TimePicker.js.map +1 -1
- package/dist/components/Timeline/Timeline.cjs.map +1 -1
- package/dist/components/Timeline/Timeline.js.map +1 -1
- package/dist/components/Toast/ToastProvider.cjs.map +1 -1
- package/dist/components/Toast/ToastProvider.js.map +1 -1
- package/dist/components/Toggle/Toggle.cjs.map +1 -1
- package/dist/components/ToggleGroup/ToggleGroup.cjs.map +1 -1
- package/dist/components/ToggleGroup/ToggleGroup.js.map +1 -1
- package/dist/components/Tooltip/Tooltip.cjs.map +1 -1
- package/dist/components/Tooltip/Tooltip.js.map +1 -1
- package/dist/components/Tour/Tour.cjs.map +1 -1
- package/dist/components/Tour/Tour.js.map +1 -1
- package/dist/components/Transfer/Transfer.cjs.map +1 -1
- package/dist/components/Transfer/Transfer.js.map +1 -1
- package/dist/components/TreeView/TreeView.cjs +1 -1
- package/dist/components/TreeView/TreeView.cjs.map +1 -1
- package/dist/components/TreeView/TreeView.js +1 -4
- package/dist/components/TreeView/TreeView.js.map +1 -1
- package/dist/components/UpdatePrompt/UpdatePrompt.cjs.map +1 -1
- package/dist/components/UpdatePrompt/UpdatePrompt.js.map +1 -1
- package/dist/components/VirtualList/VirtualList.cjs.map +1 -1
- package/dist/components/VirtualList/VirtualList.js.map +1 -1
- package/dist/components/VirtualTable/VirtualTable.cjs.map +1 -1
- package/dist/components/VirtualTable/VirtualTable.js.map +1 -1
- package/dist/components/VisuallyHidden/VisuallyHidden.cjs.map +1 -1
- package/dist/components/Wizard/Wizard.cjs.map +1 -1
- package/dist/components/Wizard/Wizard.js.map +1 -1
- package/dist/data/data-provider-context.cjs.map +1 -1
- package/dist/data/use-resource.cjs.map +1 -1
- package/dist/editor/RichTextEditor.cjs.map +1 -1
- package/dist/editor/RichTextEditor.js.map +1 -1
- package/dist/error-boundary/use-error-handler.cjs.map +1 -1
- package/dist/feature-flags/FeatureFlagsProvider.cjs.map +1 -1
- package/dist/forms/FormField.cjs.map +1 -1
- package/dist/forms/masked-inputs.cjs +1 -1
- package/dist/forms/masked-inputs.cjs.map +1 -1
- package/dist/forms/masked-inputs.js +1 -1
- package/dist/forms/masked-inputs.js.map +1 -1
- package/dist/forms/use-viacep.cjs.map +1 -1
- package/dist/forms/use-zod-form.cjs.map +1 -1
- package/dist/forms/zod-resolver.cjs.map +1 -1
- package/dist/forms/zod-resolver.js.map +1 -1
- package/dist/geo/TrajectoryMap.cjs.map +1 -1
- package/dist/geo/TrajectoryMap.js.map +1 -1
- package/dist/geo/leaflet-map.cjs.map +1 -1
- package/dist/geo/leaflet-map.js.map +1 -1
- package/dist/geo/use-position-tracker.cjs.map +1 -1
- package/dist/hooks/use-announce.cjs.map +1 -1
- package/dist/hooks/use-async.cjs.map +1 -1
- package/dist/hooks/use-before-install-prompt.cjs.map +1 -1
- package/dist/hooks/use-breakpoint.cjs.map +1 -1
- package/dist/hooks/use-click-outside.cjs.map +1 -1
- package/dist/hooks/use-client-filter.cjs.map +1 -1
- package/dist/hooks/use-clipboard.cjs.map +1 -1
- package/dist/hooks/use-counter.cjs.map +1 -1
- package/dist/hooks/use-debounce.cjs.map +1 -1
- package/dist/hooks/use-deep-memo.cjs.map +1 -1
- package/dist/hooks/use-disclosure.cjs.map +1 -1
- package/dist/hooks/use-document-visibility.cjs.map +1 -1
- package/dist/hooks/use-event-listener.cjs.map +1 -1
- package/dist/hooks/use-geolocation.cjs.map +1 -1
- package/dist/hooks/use-hover.cjs.map +1 -1
- package/dist/hooks/use-idle.cjs.map +1 -1
- package/dist/hooks/use-install-prompt.cjs +1 -1
- package/dist/hooks/use-install-prompt.cjs.map +1 -1
- package/dist/hooks/use-install-prompt.js +1 -1
- package/dist/hooks/use-install-prompt.js.map +1 -1
- package/dist/hooks/use-intersection-observer.cjs.map +1 -1
- package/dist/hooks/use-interval.cjs.map +1 -1
- package/dist/hooks/use-is-first-render.cjs.map +1 -1
- package/dist/hooks/use-keyboard-shortcut.cjs +1 -1
- package/dist/hooks/use-keyboard-shortcut.cjs.map +1 -1
- package/dist/hooks/use-keyboard-shortcut.js +1 -1
- package/dist/hooks/use-keyboard-shortcut.js.map +1 -1
- package/dist/hooks/use-list-state.cjs.map +1 -1
- package/dist/hooks/use-local-storage.cjs.map +1 -1
- package/dist/hooks/use-long-press-handlers.cjs.map +1 -1
- package/dist/hooks/use-long-press.cjs.map +1 -1
- package/dist/hooks/use-map.cjs.map +1 -1
- package/dist/hooks/use-media-devices.cjs.map +1 -1
- package/dist/hooks/use-media-permission.cjs.map +1 -1
- package/dist/hooks/use-media-query.cjs.map +1 -1
- package/dist/hooks/use-object-url.cjs.map +1 -1
- package/dist/hooks/use-online.cjs.map +1 -1
- package/dist/hooks/use-pagination.cjs.map +1 -1
- package/dist/hooks/use-previous.cjs.map +1 -1
- package/dist/hooks/use-queue.cjs.map +1 -1
- package/dist/hooks/use-resize-observer.cjs.map +1 -1
- package/dist/hooks/use-scroll-overflow.cjs.map +1 -1
- package/dist/hooks/use-service-worker-update.cjs.map +1 -1
- package/dist/hooks/use-set.cjs.map +1 -1
- package/dist/hooks/use-sortable.cjs +1 -1
- package/dist/hooks/use-sortable.cjs.map +1 -1
- package/dist/hooks/use-sortable.js +0 -2
- package/dist/hooks/use-sortable.js.map +1 -1
- package/dist/hooks/use-stable-callback.cjs.map +1 -1
- package/dist/hooks/use-storage-estimate.cjs.map +1 -1
- package/dist/hooks/use-throttle.cjs.map +1 -1
- package/dist/hooks/use-timeout.cjs.map +1 -1
- package/dist/hooks/use-toggle.cjs.map +1 -1
- package/dist/hooks/use-window-size.cjs.map +1 -1
- package/dist/http/api-client.cjs +1 -1
- package/dist/http/api-client.cjs.map +1 -1
- package/dist/http/api-client.js +7 -5
- package/dist/http/api-client.js.map +1 -1
- package/dist/http/resumable-upload.cjs +1 -1
- package/dist/http/resumable-upload.cjs.map +1 -1
- package/dist/http/resumable-upload.js +1 -1
- package/dist/http/resumable-upload.js.map +1 -1
- package/dist/http/use-poll.cjs.map +1 -1
- package/dist/i18n/I18nProvider.cjs.map +1 -1
- package/dist/icons/Icon.cjs.map +1 -1
- package/dist/icons/IconProvider.cjs.map +1 -1
- package/dist/icons/icon-context.cjs.map +1 -1
- package/dist/icons/use-icon.cjs.map +1 -1
- package/dist/imaging/use-image-processing.cjs.map +1 -1
- package/dist/oauth/GoogleSignIn.cjs.map +1 -1
- package/dist/oauth/GoogleSignIn.js.map +1 -1
- package/dist/oauth/use-oauth-callback.cjs.map +1 -1
- package/dist/offline/use-offline-sync.cjs.map +1 -1
- package/dist/push/use-push-subscription.cjs.map +1 -1
- package/dist/query/QueryProvider.cjs.map +1 -1
- package/dist/query/constants.cjs +1 -1
- package/dist/query/constants.cjs.map +1 -1
- package/dist/query/constants.js +10 -10
- package/dist/query/constants.js.map +1 -1
- package/dist/query/create-query-keys.cjs +1 -1
- package/dist/query/create-query-keys.cjs.map +1 -1
- package/dist/query/create-query-keys.js +1 -1
- package/dist/query/create-query-keys.js.map +1 -1
- package/dist/query/offline-persistence.cjs.map +1 -1
- package/dist/query/use-cursor-query.cjs.map +1 -1
- package/dist/query/use-offline-mutation.cjs.map +1 -1
- package/dist/query/use-paginated-query.cjs.map +1 -1
- package/dist/router/AppRouter.cjs +1 -1
- package/dist/router/AppRouter.cjs.map +1 -1
- package/dist/router/AppRouter.js +7 -2
- package/dist/router/AppRouter.js.map +1 -1
- package/dist/sse/use-event-stream.cjs.map +1 -1
- package/dist/store/create-store.cjs.map +1 -1
- package/dist/tabular/use-tabular-predictor.cjs.map +1 -1
- package/dist/telemetry/TelemetryProvider.cjs.map +1 -1
- package/dist/tempest-react-sdk.d.ts +25 -26
- package/dist/theme/ThemeProvider.cjs.map +1 -1
- package/dist/theme/color.cjs +1 -1
- package/dist/theme/color.cjs.map +1 -1
- package/dist/theme/color.js +1 -1
- package/dist/theme/color.js.map +1 -1
- package/dist/utils/cn.cjs +1 -1
- package/dist/utils/cn.cjs.map +1 -1
- package/dist/utils/cn.js +1 -1
- package/dist/utils/cn.js.map +1 -1
- package/dist/utils/objects.cjs +1 -1
- package/dist/utils/objects.cjs.map +1 -1
- package/dist/utils/objects.js +1 -1
- package/dist/utils/objects.js.map +1 -1
- package/dist/utils/xlsx.cjs +1 -1
- package/dist/utils/xlsx.cjs.map +1 -1
- package/dist/utils/xlsx.js +3 -3
- package/dist/utils/xlsx.js.map +1 -1
- package/dist/vision/core/exceptions.cjs.map +1 -1
- package/dist/vision/core/exceptions.js.map +1 -1
- package/dist/vision/core/metadata.cjs +1 -1
- package/dist/vision/core/metadata.cjs.map +1 -1
- package/dist/vision/core/metadata.js +1 -1
- package/dist/vision/core/metadata.js.map +1 -1
- package/dist/vision/io/image.cjs +1 -1
- package/dist/vision/io/image.cjs.map +1 -1
- package/dist/vision/io/image.js +4 -2
- package/dist/vision/io/image.js.map +1 -1
- package/dist/vision/preprocess/image.cjs +1 -1
- package/dist/vision/preprocess/image.cjs.map +1 -1
- package/dist/vision/preprocess/image.js +4 -2
- package/dist/vision/preprocess/image.js.map +1 -1
- package/dist/vision/tasks/base.cjs +1 -1
- package/dist/vision/tasks/base.cjs.map +1 -1
- package/dist/vision/tasks/base.js +3 -1
- package/dist/vision/tasks/base.js.map +1 -1
- package/dist/vision/tasks/classifier.cjs +1 -1
- package/dist/vision/tasks/classifier.cjs.map +1 -1
- package/dist/vision/tasks/classifier.js +2 -2
- package/dist/vision/tasks/classifier.js.map +1 -1
- package/dist/vision/tasks/detectClassify.cjs +1 -1
- package/dist/vision/tasks/detectClassify.cjs.map +1 -1
- package/dist/vision/tasks/detectClassify.js +16 -15
- package/dist/vision/tasks/detectClassify.js.map +1 -1
- package/dist/vision/use-camera-stream.cjs.map +1 -1
- package/dist/vision/use-live-luminance.cjs.map +1 -1
- package/dist/vite/create-vite-config.cjs +1 -1
- package/dist/vite/create-vite-config.cjs.map +1 -1
- package/dist/vite/create-vite-config.js +3 -3
- package/dist/vite/create-vite-config.js.map +1 -1
- package/dist/vite/tempest-icons.cjs.map +1 -1
- package/dist/vite/tempest-pwa-dev-sw.cjs.map +1 -1
- package/dist/vite/tempest-pwa-icons.cjs.map +1 -1
- package/dist/ws/use-web-socket.cjs +1 -1
- package/dist/ws/use-web-socket.cjs.map +1 -1
- package/dist/ws/use-web-socket.js +5 -3
- package/dist/ws/use-web-socket.js.map +1 -1
- package/package.json +2 -2
- package/template/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-speech-recognition.cjs","names":[],"sources":["../../src/capture/use-speech-recognition.ts"],"sourcesContent":["/**\n * @tempest-limits file-lines, hook-lines — the Web Speech API restarts itself on\n * silence, reports interim and final results on the same event, and reports `no-\n * speech` as an error that is not one. The hook is that reconciliation plus the\n * continuous-mode restart loop, and its length is mostly the vendor quirks the\n * docstring warns about.\n */\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { useStableCallback } from \"@/hooks/use-stable-callback\";\n\n/** One reading of what was heard. */\nexport interface SpeechAlternativeLike {\n transcript: string;\n confidence?: number;\n}\n\n/** One recognised phrase, settled (`isFinal`) or still being revised. */\nexport interface SpeechResultLike {\n isFinal: boolean;\n length: number;\n [index: number]: SpeechAlternativeLike | undefined;\n}\n\n/** The growing list of phrases in a session. */\nexport interface SpeechResultListLike {\n length: number;\n [index: number]: SpeechResultLike | undefined;\n}\n\n/** The `result` event, reduced to what this hook reads. */\nexport interface SpeechRecognitionEventLike {\n /** Index of the first result that changed — everything before it is settled. */\n resultIndex: number;\n results: SpeechResultListLike;\n}\n\n/** The `error` event, reduced to what this hook reads. */\nexport interface SpeechRecognitionErrorEventLike {\n error: string;\n message?: string;\n}\n\n/**\n * The slice of the Web Speech `SpeechRecognition` object this SDK uses.\n *\n * Declared here rather than imported: TypeScript's DOM lib ships the *event* types but\n * not the constructor, because the API is still prefixed in Chromium and absent in\n * Firefox. Exported so a test — or a consumer wrapping a different engine — can hand in\n * something else.\n */\nexport interface SpeechRecognitionLike {\n lang: string;\n continuous: boolean;\n interimResults: boolean;\n maxAlternatives: number;\n start: () => void;\n stop: () => void;\n abort: () => void;\n onresult: ((event: SpeechRecognitionEventLike) => void) | null;\n onerror: ((event: SpeechRecognitionErrorEventLike) => void) | null;\n onend: (() => void) | null;\n onstart: (() => void) | null;\n}\n\n/** Classified reason recognition stopped or never started. */\nexport type SpeechErrorKind =\n | \"unsupported\"\n | \"not-allowed\"\n | \"no-speech\"\n | \"audio-capture\"\n | \"network\"\n | \"aborted\"\n | \"language-not-supported\"\n | \"unknown\";\n\n/** A classified speech error with a human-readable, English message. */\nexport interface SpeechError {\n kind: SpeechErrorKind;\n message: string;\n}\n\n/** Options for {@link useSpeechRecognition}. */\nexport interface UseSpeechRecognitionOptions {\n /** BCP-47 tag. Default `\"pt-BR\"`. */\n lang?: string;\n /**\n * Keep listening after the first phrase settles. Default `false`.\n *\n * Even with this on, the engine ends the session by itself after a stretch of\n * silence — that is a server-side timeout, not a bug — so watch `listening` rather\n * than assuming the microphone stays open.\n */\n continuous?: boolean;\n /** Publish the running guess as it changes. Default `true`. */\n interimResults?: boolean;\n /** How many readings per phrase to ask for. Default 1. */\n maxAlternatives?: number;\n /** Every update, settled or not. */\n onResult?: (result: { transcript: string; isFinal: boolean }) => void;\n /** Only the settled text of a phrase. The one to wire dictation to. */\n onFinal?: (transcript: string) => void;\n /** Classified failure. `no-speech` and `aborted` arrive here too — they are routine. */\n onError?: (error: SpeechError) => void;\n /** The session ended, for any reason. */\n onEnd?: () => void;\n /** Build the recogniser yourself — another engine, or a stub in a test. */\n factory?: () => SpeechRecognitionLike;\n}\n\n/** Value returned by {@link useSpeechRecognition}. */\nexport interface UseSpeechRecognitionResult {\n /** `false` in Firefox and in every browser that is not Chromium-based. */\n supported: boolean;\n /** Whether a session is open right now. */\n listening: boolean;\n /** Everything settled so far in this session. Cleared by `reset()`. */\n transcript: string;\n /** The running guess. Replaced on every event, empty once the phrase settles. */\n interim: string;\n /** Classified error, or `null`. */\n error: SpeechError | null;\n /** Open a session. No-op while already listening. */\n start: () => void;\n /** Close the session, keeping what was recognised. */\n stop: () => void;\n /** Close the session and throw the pending phrase away. */\n abort: () => void;\n /** Clear `transcript`, `interim` and `error`. Does not stop a session. */\n reset: () => void;\n}\n\n/** English messages for the `error` codes the spec defines. */\nconst MESSAGES: Record<SpeechErrorKind, string> = {\n unsupported: \"Speech recognition is not supported in this browser.\",\n \"not-allowed\": \"Microphone permission denied. Enable access in your browser settings.\",\n \"no-speech\": \"No speech was detected.\",\n \"audio-capture\": \"No microphone available on this device.\",\n network: \"The recognition service could not be reached.\",\n aborted: \"Recognition was cancelled.\",\n \"language-not-supported\": \"The recognition service does not support this language.\",\n unknown: \"Unexpected error during speech recognition.\",\n};\n\n/**\n * Map a spec `error` code to a kind an app can branch on.\n *\n * `service-not-allowed` collapses into `not-allowed` because the fix is the same from\n * the user's side, and `bad-grammar` into `unknown` because this hook never sets a\n * grammar, so seeing it means something outside our control went wrong.\n *\n * @param code - The `error` property of the event.\n * @returns The classified kind.\n */\nfunction classifySpeechError(code: string): SpeechErrorKind {\n switch (code) {\n case \"not-allowed\":\n case \"service-not-allowed\":\n return \"not-allowed\";\n case \"no-speech\":\n return \"no-speech\";\n case \"audio-capture\":\n return \"audio-capture\";\n case \"network\":\n return \"network\";\n case \"aborted\":\n return \"aborted\";\n case \"language-not-supported\":\n return \"language-not-supported\";\n default:\n return \"unknown\";\n }\n}\n\n/** The constructor, prefixed or not, or `null` where the API does not exist. */\nfunction speechRecognitionConstructor(): (new () => SpeechRecognitionLike) | null {\n const scope = globalThis as {\n SpeechRecognition?: unknown;\n webkitSpeechRecognition?: unknown;\n };\n const candidate = scope.SpeechRecognition ?? scope.webkitSpeechRecognition;\n return typeof candidate === \"function\" ? (candidate as new () => SpeechRecognitionLike) : null;\n}\n\n/** Whether this browser exposes the Web Speech recognition API at all. */\nexport function isSpeechRecognitionSupported(): boolean {\n return speechRecognitionConstructor() !== null;\n}\n\n/**\n * Dictate into your app with the Web Speech API — no dependency, no API key.\n *\n * ## Recognition is not local\n *\n * **Chromium streams the captured audio to a Google server to transcribe it.** Nothing\n * about the API says so, there is no setting that changes it, and it happens on every\n * `start()`. Anything the user says while a session is open leaves the device. Do not\n * put this on a field that takes clinical notes, credentials, or a client's financial\n * detail without telling them first — and if the data cannot leave your infrastructure,\n * this API is the wrong tool and a self-hosted model is the right one.\n *\n * ## What the states mean\n *\n * `transcript` accumulates the phrases the engine has **settled** on; `interim` is the\n * guess it is still revising and is replaced wholesale on every event, so rendering\n * `transcript + interim` gives the live caption effect and rendering `transcript` alone\n * gives the committed text. `no-speech` and `aborted` come through `onError` but are\n * routine — a user who pressed the button and said nothing is not a failure to report.\n *\n * There is deliberately **no auto-restart** when the engine ends a session on silence.\n * A restart loop is how an app ends up holding the microphone indefinitely — and, in\n * Chromium, streaming audio to a third party indefinitely. Show that listening stopped\n * and let the user press again.\n *\n * @param options - See {@link UseSpeechRecognitionOptions}.\n * @returns Session state, the transcript and the controls.\n *\n * @example\n * const speech = useSpeechRecognition({ onFinal: (text) => setPrompt(text) });\n * <button onClick={speech.listening ? speech.stop : speech.start}>\n * {speech.listening ? \"Parar\" : \"Ditar\"}\n * </button>\n * <p>{speech.transcript}{speech.interim}</p>\n */\nexport function useSpeechRecognition(\n options: UseSpeechRecognitionOptions = {},\n): UseSpeechRecognitionResult {\n const {\n lang = \"pt-BR\",\n continuous = false,\n interimResults = true,\n maxAlternatives = 1,\n onResult,\n onFinal,\n onError,\n onEnd,\n factory,\n } = options;\n\n const [supported] = useState(() => factory !== undefined || isSpeechRecognitionSupported());\n const [listening, setListening] = useState(false);\n const [transcript, setTranscript] = useState(\"\");\n const [interim, setInterim] = useState(\"\");\n const [error, setError] = useState<SpeechError | null>(null);\n\n const sessionRef = useRef<SpeechRecognitionLike | null>(null);\n\n const emitResult = useStableCallback((result: { transcript: string; isFinal: boolean }) =>\n onResult?.(result),\n );\n const emitFinal = useStableCallback((text: string) => onFinal?.(text));\n const emitEnd = useStableCallback(() => onEnd?.());\n const emitError = useStableCallback((failure: SpeechError) => {\n setError(failure);\n onError?.(failure);\n });\n\n const teardown = useCallback((): void => {\n const session = sessionRef.current;\n if (!session) return;\n session.onresult = null;\n session.onerror = null;\n session.onend = null;\n session.onstart = null;\n sessionRef.current = null;\n }, []);\n\n const start = useCallback((): void => {\n if (sessionRef.current) return;\n const build =\n factory ??\n (() => {\n const constructor = speechRecognitionConstructor();\n return constructor ? new constructor() : null;\n });\n const session = build();\n if (!session) {\n emitError({ kind: \"unsupported\", message: MESSAGES.unsupported });\n return;\n }\n\n session.lang = lang;\n session.continuous = continuous;\n session.interimResults = interimResults;\n session.maxAlternatives = maxAlternatives;\n\n /**\n * Fold one event into the two published strings.\n *\n * Only the results from `resultIndex` on are new; re-reading the whole list\n * would append phrases that are already in `transcript`. Settled text is\n * accumulated, unsettled text replaces the previous guess entirely — the engine\n * revises a phrase in place, so appending it would stutter the caption.\n */\n session.onresult = (event: SpeechRecognitionEventLike): void => {\n let settled = \"\";\n let pending = \"\";\n for (let index = event.resultIndex; index < event.results.length; index += 1) {\n const result = event.results[index];\n if (!result) continue;\n const text = result[0]?.transcript ?? \"\";\n if (result.isFinal) settled += text;\n else pending += text;\n }\n setInterim(pending);\n if (settled !== \"\") {\n setTranscript((previous) => previous + settled);\n emitFinal(settled);\n }\n emitResult({ transcript: settled !== \"\" ? settled : pending, isFinal: settled !== \"\" });\n };\n\n session.onerror = (event: SpeechRecognitionErrorEventLike): void => {\n const kind = classifySpeechError(event.error);\n emitError({ kind, message: event.message || MESSAGES[kind] });\n };\n\n session.onend = (): void => {\n setListening(false);\n setInterim(\"\");\n teardown();\n emitEnd();\n };\n\n session.onstart = (): void => setListening(true);\n\n setError(null);\n try {\n session.start();\n } catch (failure) {\n // Chromium throws `InvalidStateError` when a session is already running in\n // another component. Reporting it beats leaving a dead handle behind.\n emitError({\n kind: \"unknown\",\n message: failure instanceof Error ? failure.message : MESSAGES.unknown,\n });\n return;\n }\n sessionRef.current = session;\n setListening(true);\n }, [\n lang,\n continuous,\n interimResults,\n maxAlternatives,\n factory,\n emitResult,\n emitFinal,\n emitEnd,\n emitError,\n teardown,\n ]);\n\n const stop = useCallback((): void => {\n sessionRef.current?.stop();\n }, []);\n\n const abort = useCallback((): void => {\n sessionRef.current?.abort();\n }, []);\n\n const reset = useCallback((): void => {\n setTranscript(\"\");\n setInterim(\"\");\n setError(null);\n }, []);\n\n /**\n * Never leave a session open past unmount.\n *\n * `abort()` and not `stop()`: a component that is gone has nowhere to put a final\n * result, and `stop()` would keep the microphone — and the upstream connection —\n * alive while the engine finishes deciding what the last word was.\n */\n useEffect(\n () => () => {\n sessionRef.current?.abort();\n teardown();\n },\n [teardown],\n );\n\n return {\n supported,\n listening,\n transcript,\n interim,\n error,\n start,\n stop,\n abort,\n reset,\n };\n}\n"],"mappings":"2EAqIA,IAAM,EAA4C,CAC9C,YAAa,uDACb,cAAe,wEACf,YAAa,0BACb,gBAAiB,0CACjB,QAAS,gDACT,QAAS,6BACT,yBAA0B,0DAC1B,QAAS,6CACb,EAYA,SAAS,EAAoB,EAA+B,CACxD,OAAQ,EAAR,CACI,IAAK,cACL,IAAK,sBACD,MAAO,cACX,IAAK,YACD,MAAO,YACX,IAAK,gBACD,MAAO,gBACX,IAAK,UACD,MAAO,UACX,IAAK,UACD,MAAO,UACX,IAAK,yBACD,MAAO,yBACX,QACI,MAAO,SACf,CACJ,CAGA,SAAS,GAAyE,CAC9E,IAAM,EAAQ,WAIR,EAAY,EAAM,mBAAqB,EAAM,wBACnD,OAAO,OAAO,GAAc,WAAc,EAAgD,IAC9F,CAGA,SAAgB,GAAwC,CACpD,OAAO,EAA6B,IAAM,IAC9C,CAqCA,SAAgB,EACZ,EAAuC,CAAC,EACd,CAC1B,GAAM,CACF,OAAO,QACP,aAAa,GACb,iBAAiB,GACjB,kBAAkB,EAClB,WACA,UACA,UACA,QACA,WACA,EAEE,CAAC,IAAA,EAAA,EAAA,SAAA,KAA4B,IAAY,IAAA,IAAa,EAA6B,CAAC,EACpF,CAAC,EAAW,IAAA,EAAA,EAAA,SAAA,CAAyB,EAAK,EAC1C,CAAC,EAAY,IAAA,EAAA,EAAA,SAAA,CAA0B,EAAE,EACzC,CAAC,EAAS,IAAA,EAAA,EAAA,SAAA,CAAuB,EAAE,EACnC,CAAC,EAAO,IAAA,EAAA,EAAA,SAAA,CAAyC,IAAI,EAErD,GAAA,EAAA,EAAA,OAAA,CAAkD,IAAI,EAEtD,EAAa,EAAA,kBAAmB,GAClC,IAAW,CAAM,CACrB,EACM,EAAY,EAAA,kBAAmB,GAAiB,IAAU,CAAI,CAAC,EAC/D,EAAU,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ClB,EAAW,EAAE,EACb,EAAS,EACT,EAAQ,CACZ,EAEA,EAAQ,YAAsB,EAAa,EAAI,EAE/C,EAAS,IAAI,EACb,GAAI,CACA,EAAQ,MAAM,CAClB,OAAS,EAAS,CAGd,EAAU,CACN,KAAM,UACN,QAAS,aAAmB,MAAQ,EAAQ,QAAU,EAAS,OACnE,CAAC,EACD,MACJ,CACA,EAAW,QAAU,EACrB,EAAa,EAAI,CACrB,EAAG,CACC,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,EACA,CACJ,CAAC,EAEK,GAAA,EAAA,EAAA,YAAA,KAA+B,CACjC,EAAW,SAAS,KAAK,CAC7B,EAAG,CAAC,CAAC,EAEC,GAAA,EAAA,EAAA,YAAA,KAAgC,CAClC,EAAW,SAAS,MAAM,CAC9B,EAAG,CAAC,CAAC,EAEC,GAAA,EAAA,EAAA,YAAA,KAAgC,CAClC,EAAc,EAAE,EAChB,EAAW,EAAE,EACb,EAAS,IAAI,CACjB,EAAG,CAAC,CAAC,EAiBL,OARA,EAAA,EAAA,UAAA,SACgB,CACR,EAAW,SAAS,MAAM,EAC1B,EAAS,CACb,EACA,CAAC,CAAQ,CACb,EAEO,CACH,YACA,YACA,aACA,UACA,QACA,QACA,OACA,QACA,OACJ,CACJ"}
|
|
1
|
+
{"version":3,"file":"use-speech-recognition.cjs","names":[],"sources":["../../src/capture/use-speech-recognition.ts"],"sourcesContent":["/**\n * @tempest-limits file-lines, hook-lines — the Web Speech API restarts itself on\n * silence, reports interim and final results on the same event, and reports `no-\n * speech` as an error that is not one. The hook is that reconciliation plus the\n * continuous-mode restart loop, and its length is mostly the vendor quirks the\n * docstring warns about.\n */\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { useStableCallback } from \"@/hooks/use-stable-callback\";\n\n/** One reading of what was heard. */\nexport interface SpeechAlternativeLike {\n transcript: string;\n confidence?: number;\n}\n\n/** One recognised phrase, settled (`isFinal`) or still being revised. */\nexport interface SpeechResultLike {\n isFinal: boolean;\n length: number;\n [index: number]: SpeechAlternativeLike | undefined;\n}\n\n/** The growing list of phrases in a session. */\nexport interface SpeechResultListLike {\n length: number;\n [index: number]: SpeechResultLike | undefined;\n}\n\n/** The `result` event, reduced to what this hook reads. */\nexport interface SpeechRecognitionEventLike {\n /** Index of the first result that changed — everything before it is settled. */\n resultIndex: number;\n results: SpeechResultListLike;\n}\n\n/** The `error` event, reduced to what this hook reads. */\nexport interface SpeechRecognitionErrorEventLike {\n error: string;\n message?: string;\n}\n\n/**\n * The slice of the Web Speech `SpeechRecognition` object this SDK uses.\n *\n * Declared here rather than imported: TypeScript's DOM lib ships the *event* types but\n * not the constructor, because the API is still prefixed in Chromium and absent in\n * Firefox. Exported so a test — or a consumer wrapping a different engine — can hand in\n * something else.\n */\nexport interface SpeechRecognitionLike {\n lang: string;\n continuous: boolean;\n interimResults: boolean;\n maxAlternatives: number;\n start: () => void;\n stop: () => void;\n abort: () => void;\n onresult: ((event: SpeechRecognitionEventLike) => void) | null;\n onerror: ((event: SpeechRecognitionErrorEventLike) => void) | null;\n onend: (() => void) | null;\n onstart: (() => void) | null;\n}\n\n/** Classified reason recognition stopped or never started. */\nexport type SpeechErrorKind =\n | \"unsupported\"\n | \"not-allowed\"\n | \"no-speech\"\n | \"audio-capture\"\n | \"network\"\n | \"aborted\"\n | \"language-not-supported\"\n | \"unknown\";\n\n/** A classified speech error with a human-readable, English message. */\nexport interface SpeechError {\n kind: SpeechErrorKind;\n message: string;\n}\n\n/** Options for {@link useSpeechRecognition}. */\nexport interface UseSpeechRecognitionOptions {\n /** BCP-47 tag. Default `\"pt-BR\"`. */\n lang?: string;\n /**\n * Keep listening after the first phrase settles. Default `false`.\n *\n * Even with this on, the engine ends the session by itself after a stretch of\n * silence — that is a server-side timeout, not a bug — so watch `listening` rather\n * than assuming the microphone stays open.\n */\n continuous?: boolean;\n /** Publish the running guess as it changes. Default `true`. */\n interimResults?: boolean;\n /** How many readings per phrase to ask for. Default 1. */\n maxAlternatives?: number;\n /** Every update, settled or not. */\n onResult?: (result: { transcript: string; isFinal: boolean }) => void;\n /** Only the settled text of a phrase. The one to wire dictation to. */\n onFinal?: (transcript: string) => void;\n /** Classified failure. `no-speech` and `aborted` arrive here too — they are routine. */\n onError?: (error: SpeechError) => void;\n /** The session ended, for any reason. */\n onEnd?: () => void;\n /** Build the recogniser yourself — another engine, or a stub in a test. */\n factory?: () => SpeechRecognitionLike;\n}\n\n/** Value returned by {@link useSpeechRecognition}. */\nexport interface UseSpeechRecognitionResult {\n /** `false` in Firefox and in every browser that is not Chromium-based. */\n supported: boolean;\n /** Whether a session is open right now. */\n listening: boolean;\n /** Everything settled so far in this session. Cleared by `reset()`. */\n transcript: string;\n /** The running guess. Replaced on every event, empty once the phrase settles. */\n interim: string;\n /** Classified error, or `null`. */\n error: SpeechError | null;\n /** Open a session. No-op while already listening. */\n start: () => void;\n /** Close the session, keeping what was recognised. */\n stop: () => void;\n /** Close the session and throw the pending phrase away. */\n abort: () => void;\n /** Clear `transcript`, `interim` and `error`. Does not stop a session. */\n reset: () => void;\n}\n\n/** English messages for the `error` codes the spec defines. */\nconst MESSAGES: Record<SpeechErrorKind, string> = {\n unsupported: \"Speech recognition is not supported in this browser.\",\n \"not-allowed\": \"Microphone permission denied. Enable access in your browser settings.\",\n \"no-speech\": \"No speech was detected.\",\n \"audio-capture\": \"No microphone available on this device.\",\n network: \"The recognition service could not be reached.\",\n aborted: \"Recognition was cancelled.\",\n \"language-not-supported\": \"The recognition service does not support this language.\",\n unknown: \"Unexpected error during speech recognition.\",\n};\n\n/**\n * Map a spec `error` code to a kind an app can branch on.\n *\n * `service-not-allowed` collapses into `not-allowed` because the fix is the same from\n * the user's side, and `bad-grammar` into `unknown` because this hook never sets a\n * grammar, so seeing it means something outside our control went wrong.\n *\n * @param code - The `error` property of the event.\n * @returns The classified kind.\n */\nfunction classifySpeechError(code: string): SpeechErrorKind {\n switch (code) {\n case \"not-allowed\":\n case \"service-not-allowed\":\n return \"not-allowed\";\n case \"no-speech\":\n return \"no-speech\";\n case \"audio-capture\":\n return \"audio-capture\";\n case \"network\":\n return \"network\";\n case \"aborted\":\n return \"aborted\";\n case \"language-not-supported\":\n return \"language-not-supported\";\n default:\n return \"unknown\";\n }\n}\n\n/** The constructor, prefixed or not, or `null` where the API does not exist. */\nfunction speechRecognitionConstructor(): (new () => SpeechRecognitionLike) | null {\n const scope = globalThis as {\n SpeechRecognition?: unknown;\n webkitSpeechRecognition?: unknown;\n };\n const candidate = scope.SpeechRecognition ?? scope.webkitSpeechRecognition;\n return typeof candidate === \"function\" ? (candidate as new () => SpeechRecognitionLike) : null;\n}\n\n/** Whether this browser exposes the Web Speech recognition API at all. */\nexport function isSpeechRecognitionSupported(): boolean {\n return speechRecognitionConstructor() !== null;\n}\n\n/**\n * Dictate into your app with the Web Speech API — no dependency, no API key.\n *\n * ## Recognition is not local\n *\n * **Chromium streams the captured audio to a Google server to transcribe it.** Nothing\n * about the API says so, there is no setting that changes it, and it happens on every\n * `start()`. Anything the user says while a session is open leaves the device. Do not\n * put this on a field that takes clinical notes, credentials, or a client's financial\n * detail without telling them first — and if the data cannot leave your infrastructure,\n * this API is the wrong tool and a self-hosted model is the right one.\n *\n * ## What the states mean\n *\n * `transcript` accumulates the phrases the engine has **settled** on; `interim` is the\n * guess it is still revising and is replaced wholesale on every event, so rendering\n * `transcript + interim` gives the live caption effect and rendering `transcript` alone\n * gives the committed text. `no-speech` and `aborted` come through `onError` but are\n * routine — a user who pressed the button and said nothing is not a failure to report.\n *\n * There is deliberately **no auto-restart** when the engine ends a session on silence.\n * A restart loop is how an app ends up holding the microphone indefinitely — and, in\n * Chromium, streaming audio to a third party indefinitely. Show that listening stopped\n * and let the user press again.\n *\n * @param options - See {@link UseSpeechRecognitionOptions}.\n * @returns Session state, the transcript and the controls.\n *\n * @example\n * const speech = useSpeechRecognition({ onFinal: (text) => setPrompt(text) });\n * <button onClick={speech.listening ? speech.stop : speech.start}>\n * {speech.listening ? \"Parar\" : \"Ditar\"}\n * </button>\n * <p>{speech.transcript}{speech.interim}</p>\n */\nexport function useSpeechRecognition(\n options: UseSpeechRecognitionOptions = {},\n): UseSpeechRecognitionResult {\n const {\n lang = \"pt-BR\",\n continuous = false,\n interimResults = true,\n maxAlternatives = 1,\n onResult,\n onFinal,\n onError,\n onEnd,\n factory,\n } = options;\n\n const [supported] = useState(() => factory !== undefined || isSpeechRecognitionSupported());\n const [listening, setListening] = useState(false);\n const [transcript, setTranscript] = useState(\"\");\n const [interim, setInterim] = useState(\"\");\n const [error, setError] = useState<SpeechError | null>(null);\n\n const sessionRef = useRef<SpeechRecognitionLike | null>(null);\n\n const emitResult = useStableCallback((result: { transcript: string; isFinal: boolean }) =>\n onResult?.(result),\n );\n const emitFinal = useStableCallback((text: string) => onFinal?.(text));\n const emitEnd = useStableCallback(() => onEnd?.());\n const emitError = useStableCallback((failure: SpeechError) => {\n setError(failure);\n onError?.(failure);\n });\n\n const teardown = useCallback((): void => {\n const session = sessionRef.current;\n if (!session) return;\n session.onresult = null;\n session.onerror = null;\n session.onend = null;\n session.onstart = null;\n sessionRef.current = null;\n }, []);\n\n const start = useCallback((): void => {\n if (sessionRef.current) return;\n const build =\n factory ??\n (() => {\n const constructor = speechRecognitionConstructor();\n return constructor ? new constructor() : null;\n });\n const session = build();\n if (!session) {\n emitError({ kind: \"unsupported\", message: MESSAGES.unsupported });\n return;\n }\n\n session.lang = lang;\n session.continuous = continuous;\n session.interimResults = interimResults;\n session.maxAlternatives = maxAlternatives;\n\n /**\n * Fold one event into the two published strings.\n *\n * Only the results from `resultIndex` on are new; re-reading the whole list\n * would append phrases that are already in `transcript`. Settled text is\n * accumulated, unsettled text replaces the previous guess entirely — the engine\n * revises a phrase in place, so appending it would stutter the caption.\n */\n session.onresult = (event: SpeechRecognitionEventLike): void => {\n let settled = \"\";\n let pending = \"\";\n for (let index = event.resultIndex; index < event.results.length; index += 1) {\n const result = event.results[index];\n if (!result) continue;\n const text = result[0]?.transcript ?? \"\";\n if (result.isFinal) settled += text;\n else pending += text;\n }\n setInterim(pending);\n if (settled !== \"\") {\n setTranscript((previous) => previous + settled);\n emitFinal(settled);\n }\n emitResult({ transcript: settled !== \"\" ? settled : pending, isFinal: settled !== \"\" });\n };\n\n session.onerror = (event: SpeechRecognitionErrorEventLike): void => {\n const kind = classifySpeechError(event.error);\n emitError({ kind, message: event.message || MESSAGES[kind] });\n };\n\n session.onend = (): void => {\n setListening(false);\n setInterim(\"\");\n teardown();\n emitEnd();\n };\n\n session.onstart = (): void => setListening(true);\n\n setError(null);\n try {\n session.start();\n } catch (failure) {\n // Chromium throws `InvalidStateError` when a session is already running in\n // another component. Reporting it beats leaving a dead handle behind.\n emitError({\n kind: \"unknown\",\n message: failure instanceof Error ? failure.message : MESSAGES.unknown,\n });\n return;\n }\n sessionRef.current = session;\n setListening(true);\n }, [\n lang,\n continuous,\n interimResults,\n maxAlternatives,\n factory,\n emitResult,\n emitFinal,\n emitEnd,\n emitError,\n teardown,\n ]);\n\n const stop = useCallback((): void => {\n sessionRef.current?.stop();\n }, []);\n\n const abort = useCallback((): void => {\n sessionRef.current?.abort();\n }, []);\n\n const reset = useCallback((): void => {\n setTranscript(\"\");\n setInterim(\"\");\n setError(null);\n }, []);\n\n /**\n * Never leave a session open past unmount.\n *\n * `abort()` and not `stop()`: a component that is gone has nowhere to put a final\n * result, and `stop()` would keep the microphone — and the upstream connection —\n * alive while the engine finishes deciding what the last word was.\n */\n useEffect(\n () => () => {\n sessionRef.current?.abort();\n teardown();\n },\n [teardown],\n );\n\n return {\n supported,\n listening,\n transcript,\n interim,\n error,\n start,\n stop,\n abort,\n reset,\n };\n}\n"],"mappings":"2EAqIA,IAAM,EAA4C,CAC9C,YAAa,uDACb,cAAe,wEACf,YAAa,0BACb,gBAAiB,0CACjB,QAAS,gDACT,QAAS,6BACT,yBAA0B,0DAC1B,QAAS,6CACb,EAYA,SAAS,EAAoB,EAA+B,CACxD,OAAQ,EAAR,CACI,IAAK,cACL,IAAK,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EACA,CACJ,CAAC,EAEK,GAAA,EAAO,EAAA,YAAA,KAAwB,CACjC,EAAW,SAAS,KAAK,CAC7B,EAAG,CAAC,CAAC,EAEC,GAAA,EAAQ,EAAA,YAAA,KAAwB,CAClC,EAAW,SAAS,MAAM,CAC9B,EAAG,CAAC,CAAC,EAEC,GAAA,EAAQ,EAAA,YAAA,KAAwB,CAClC,EAAc,EAAE,EAChB,EAAW,EAAE,EACb,EAAS,IAAI,CACjB,EAAG,CAAC,CAAC,EAiBL,OARA,EAAA,EAAA,UAAA,SACgB,CACR,EAAW,SAAS,MAAM,EAC1B,EAAS,CACb,EACA,CAAC,CAAQ,CACb,EAEO,CACH,YACA,YACA,aACA,UACA,QACA,QACA,OACA,QACA,OACJ,CACJ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-torch.cjs","names":[],"sources":["../../src/capture/use-torch.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from \"react\";\n\n/**\n * `torch` is a real constrainable property in the Media Capture spec, but\n * TypeScript's `MediaTrackConstraintSet` does not list it, so the literal has to be\n * widened before `applyConstraints` will take it.\n */\ntype TorchConstraints = MediaTrackConstraints & {\n advanced?: Array<MediaTrackConstraintSet & { torch?: boolean }>;\n};\n\n/** `getCapabilities()` reports `torch` as a list of the values the lamp accepts. */\ntype TorchCapabilities = MediaTrackCapabilities & { torch?: readonly boolean[] };\n\n/** Value returned by {@link useTorch}. */\nexport interface UseTorchResult {\n /** Whether this track has a controllable lamp. `false` on every desktop webcam. */\n supported: boolean;\n /** Whether the lamp is on, as far as this hook knows. */\n on: boolean;\n /**\n * Turn the lamp on or off.\n *\n * @param next - `true` to light it up.\n * @returns `false` when the track refused — treat that as \"no torch\".\n */\n set: (next: boolean) => Promise<boolean>;\n /** Flip it. Same return contract as {@link UseTorchResult.set}. */\n toggle: () => Promise<boolean>;\n}\n\n/**\n * Drive the camera's LED torch on the video track of a stream.\n *\n * The lamp is not a device you can open — it is a **constraint on a live video\n * track**, so there is nothing to control until a camera stream exists, and it\n * disappears when that stream is released. That is also why `supported` can only be\n * answered after the track is live: the same code is `true` on an Android rear camera\n * and `false` on the front one of the same phone.\n *\n * Capability detection prefers `getCapabilities()` and falls back to\n * `getSettings()`, because Firefox implements neither the torch nor\n * `getCapabilities()` and Safari reports the setting without the capability. When\n * neither mentions `torch`, the hook reports `supported: false` instead of offering a\n * button that silently does nothing.\n *\n * @param stream - A live camera stream, or `null` before permission lands.\n * @returns Whether a lamp exists, its state, and setters.\n *\n * @example\n * const camera = useBarcodeScanner();\n * {camera.torch.supported && (\n * <button onClick={() => void camera.torch.toggle()}>Lanterna</button>\n * )}\n */\nexport function useTorch(stream: MediaStream | null): UseTorchResult {\n const [supported, setSupported] = useState(false);\n const [on, setOn] = useState(false);\n\n useEffect(() => {\n const track = stream?.getVideoTracks()[0] ?? null;\n if (!track) {\n setSupported(false);\n setOn(false);\n return;\n }\n const capabilities = (track.getCapabilities?.() ?? {}) as TorchCapabilities;\n const settings = track.getSettings();\n setSupported(capabilities.torch !== undefined || settings.torch !== undefined);\n setOn(settings.torch === true);\n }, [stream]);\n\n const set = useCallback(\n async (next: boolean): Promise<boolean> => {\n const track = stream?.getVideoTracks()[0] ?? null;\n if (!track) return false;\n try {\n await track.applyConstraints({\n advanced: [{ torch: next }],\n } as TorchConstraints);\n setOn(next);\n return true;\n } catch {\n // A track without a lamp rejects with `OverconstrainedError`. There is\n // nothing for the user to fix, and the honest report is \"no torch\".\n setSupported(false);\n setOn(false);\n return false;\n }\n },\n [stream],\n );\n\n const toggle = useCallback((): Promise<boolean> => set(!on), [set, on]);\n\n return { supported, on, set, toggle };\n}\n"],"mappings":"uBAuDA,SAAgB,EAAS,EAA4C,CACjE,GAAM,CAAC,EAAW,IAAA,
|
|
1
|
+
{"version":3,"file":"use-torch.cjs","names":[],"sources":["../../src/capture/use-torch.ts"],"sourcesContent":["import { useCallback, useEffect, useState } from \"react\";\n\n/**\n * `torch` is a real constrainable property in the Media Capture spec, but\n * TypeScript's `MediaTrackConstraintSet` does not list it, so the literal has to be\n * widened before `applyConstraints` will take it.\n */\ntype TorchConstraints = MediaTrackConstraints & {\n advanced?: Array<MediaTrackConstraintSet & { torch?: boolean }>;\n};\n\n/** `getCapabilities()` reports `torch` as a list of the values the lamp accepts. */\ntype TorchCapabilities = MediaTrackCapabilities & { torch?: readonly boolean[] };\n\n/** Value returned by {@link useTorch}. */\nexport interface UseTorchResult {\n /** Whether this track has a controllable lamp. `false` on every desktop webcam. */\n supported: boolean;\n /** Whether the lamp is on, as far as this hook knows. */\n on: boolean;\n /**\n * Turn the lamp on or off.\n *\n * @param next - `true` to light it up.\n * @returns `false` when the track refused — treat that as \"no torch\".\n */\n set: (next: boolean) => Promise<boolean>;\n /** Flip it. Same return contract as {@link UseTorchResult.set}. */\n toggle: () => Promise<boolean>;\n}\n\n/**\n * Drive the camera's LED torch on the video track of a stream.\n *\n * The lamp is not a device you can open — it is a **constraint on a live video\n * track**, so there is nothing to control until a camera stream exists, and it\n * disappears when that stream is released. That is also why `supported` can only be\n * answered after the track is live: the same code is `true` on an Android rear camera\n * and `false` on the front one of the same phone.\n *\n * Capability detection prefers `getCapabilities()` and falls back to\n * `getSettings()`, because Firefox implements neither the torch nor\n * `getCapabilities()` and Safari reports the setting without the capability. When\n * neither mentions `torch`, the hook reports `supported: false` instead of offering a\n * button that silently does nothing.\n *\n * @param stream - A live camera stream, or `null` before permission lands.\n * @returns Whether a lamp exists, its state, and setters.\n *\n * @example\n * const camera = useBarcodeScanner();\n * {camera.torch.supported && (\n * <button onClick={() => void camera.torch.toggle()}>Lanterna</button>\n * )}\n */\nexport function useTorch(stream: MediaStream | null): UseTorchResult {\n const [supported, setSupported] = useState(false);\n const [on, setOn] = useState(false);\n\n useEffect(() => {\n const track = stream?.getVideoTracks()[0] ?? null;\n if (!track) {\n setSupported(false);\n setOn(false);\n return;\n }\n const capabilities = (track.getCapabilities?.() ?? {}) as TorchCapabilities;\n const settings = track.getSettings();\n setSupported(capabilities.torch !== undefined || settings.torch !== undefined);\n setOn(settings.torch === true);\n }, [stream]);\n\n const set = useCallback(\n async (next: boolean): Promise<boolean> => {\n const track = stream?.getVideoTracks()[0] ?? null;\n if (!track) return false;\n try {\n await track.applyConstraints({\n advanced: [{ torch: next }],\n } as TorchConstraints);\n setOn(next);\n return true;\n } catch {\n // A track without a lamp rejects with `OverconstrainedError`. There is\n // nothing for the user to fix, and the honest report is \"no torch\".\n setSupported(false);\n setOn(false);\n return false;\n }\n },\n [stream],\n );\n\n const toggle = useCallback((): Promise<boolean> => set(!on), [set, on]);\n\n return { supported, on, set, toggle };\n}\n"],"mappings":"uBAuDA,SAAgB,EAAS,EAA4C,CACjE,GAAM,CAAC,EAAW,IAAA,EAAgB,EAAA,SAAA,CAAS,EAAK,EAC1C,CAAC,EAAI,IAAA,EAAS,EAAA,SAAA,CAAS,EAAK,GAElC,EAAA,EAAA,UAAA,KAAgB,CACZ,IAAM,EAAQ,GAAQ,eAAe,CAAC,CAAC,IAAM,KAC7C,GAAI,CAAC,EAAO,CACR,EAAa,EAAK,EAClB,EAAM,EAAK,EACX,MACJ,CACA,IAAM,EAAgB,EAAM,kBAAkB,GAAK,CAAC,EAC9C,EAAW,EAAM,YAAY,EACnC,EAAa,EAAa,QAAU,IAAA,IAAa,EAAS,QAAU,IAAA,EAAS,EAC7E,EAAM,EAAS,QAAU,EAAI,CACjC,EAAG,CAAC,CAAM,CAAC,EAEX,IAAM,GAAA,EAAM,EAAA,YAAA,CACR,KAAO,IAAoC,CACvC,IAAM,EAAQ,GAAQ,eAAe,CAAC,CAAC,IAAM,KAC7C,GAAI,CAAC,EAAO,MAAO,GACnB,GAAI,CAKA,OAJA,MAAM,EAAM,iBAAiB,CACzB,SAAU,CAAC,CAAE,MAAO,CAAK,CAAC,CAC9B,CAAqB,EACrB,EAAM,CAAI,EACH,EACX,MAAQ,CAKJ,OAFA,EAAa,EAAK,EAClB,EAAM,EAAK,EACJ,EACX,CACJ,EACA,CAAC,CAAM,CACX,EAIA,MAAO,CAAE,YAAW,KAAI,MAAK,QAAA,EAFd,EAAA,YAAA,KAAoC,EAAI,CAAC,CAAE,EAAG,CAAC,EAAK,CAAE,CAExC,CAAO,CACxC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-video-recorder.cjs","names":[],"sources":["../../src/capture/use-video-recorder.ts"],"sourcesContent":["/**\n * @tempest-limits hook-lines — the same lifecycle as the audio recorder —\n * permission, recorder, clock, auto-stop — over a stream that also carries video,\n * with the preview element to attach and release.\n */\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { useStableCallback } from \"@/hooks/use-stable-callback\";\n\nimport type { MediaRecorderHandle, MediaRecorderStatus } from \"./media-recorder\";\nimport {\n createVideoRecorder,\n type VideoRecorderOptions,\n type VideoRecording,\n} from \"./video-recorder\";\n\n/** Options for {@link useVideoRecorder}. */\nexport interface UseVideoRecorderOptions extends VideoRecorderOptions {\n /**\n * Stop automatically after this many milliseconds.\n *\n * Worth setting on anything user-facing, and more so than for audio: a minute of\n * 1080p at 2.5 Mbps is roughly 19 MB, so a recording left running by accident\n * fills memory an order of magnitude faster than a voice note does.\n */\n maxDurationMs?: number;\n /** Called once the recording is assembled, whether by `stop()` or `maxDurationMs`. */\n onRecorded?: (recording: VideoRecording) => void;\n /** How often the clock is published, in ms. Default 250. */\n tickMs?: number;\n}\n\n/** Value returned by {@link useVideoRecorder}. */\nexport interface UseVideoRecorderResult {\n status: MediaRecorderStatus;\n /** Recorded length so far, excluding paused time. */\n durationMs: number;\n /** The finished recording, or `null` before the first `stop()`. */\n recording: VideoRecording | null;\n /** Recorder-level error (encoder failure, share revoked mid-recording). */\n error: unknown;\n /** `false` when there is no stream yet, or the browser cannot record video. */\n ready: boolean;\n start: () => void;\n pause: () => void;\n resume: () => void;\n /** Stop and resolve with the recording. Also published on `recording`. */\n stop: () => Promise<VideoRecording | null>;\n /** Stop and throw the video away. */\n cancel: () => void;\n}\n\n/**\n * Record a video stream — from {@link useScreenCapture}, from a camera, or from a\n * canvas.\n *\n * Pass the stream in; the hook stays `ready: false` until there is one, so a page can\n * render the whole recorder UI before the user has picked a screen and simply have it\n * disabled.\n *\n * There is no level meter here, which is the one real difference from\n * `useAudioRecorder`: metering a screen share means opening an `AudioContext` on a\n * stream that usually has no audio track at all, and browsers cap the number of live\n * contexts. If you are recording a camera **and** want a level, run\n * `createLevelMeter` on the same stream yourself.\n *\n * The clock is published every `tickMs` (default 250 ms) rather than per frame: a\n * video recording UI shows `0:07`, and a hook that re-rendered its parent 60 times a\n * second to move a one-second counter would be the most expensive thing on the page.\n *\n * @param stream - The stream to record, or `null` while the picker is open.\n * @param options - See {@link UseVideoRecorderOptions}.\n *\n * @example\n * const screen = useScreenCapture();\n * const rec = useVideoRecorder(screen.stream, { maxDurationMs: 120_000 });\n * <button disabled={!rec.ready} onClick={rec.start}>Gravar tela</button>\n */\nexport function useVideoRecorder(\n stream: MediaStream | null,\n options: UseVideoRecorderOptions = {},\n): UseVideoRecorderResult {\n const {\n maxDurationMs,\n onRecorded,\n onChunk,\n onError,\n mimeType,\n videoBitsPerSecond,\n audioBitsPerSecond,\n timesliceMs,\n tickMs = 250,\n } = options;\n\n const [status, setStatus] = useState<MediaRecorderStatus>(\"idle\");\n const [durationMs, setDurationMs] = useState(0);\n const [recording, setRecording] = useState<VideoRecording | null>(null);\n const [error, setError] = useState<unknown>(null);\n const [ready, setReady] = useState(false);\n\n const recorderRef = useRef<MediaRecorderHandle | null>(null);\n\n const emitRecorded = useStableCallback((result: VideoRecording) => onRecorded?.(result));\n const emitChunk = useStableCallback((chunk: Blob) => onChunk?.(chunk));\n const emitError = useStableCallback((err: unknown) => {\n setError(err);\n onError?.(err);\n });\n\n /**\n * Build the recorder for a stream, and tear it down when the stream changes.\n *\n * Rebuilt per stream because `MediaRecorder` is bound to the stream it was\n * constructed with: a user who stops sharing and picks a different window hands us\n * a new `MediaStream`, and reusing the old recorder would keep recording a surface\n * that no longer exists. Same reason for a container or bitrate change — both are\n * constructor arguments.\n */\n useEffect(() => {\n if (!stream) {\n setReady(false);\n return;\n }\n let recorder: MediaRecorderHandle;\n try {\n recorder = createVideoRecorder(stream, {\n mimeType,\n videoBitsPerSecond,\n audioBitsPerSecond,\n timesliceMs,\n onChunk: emitChunk,\n onError: emitError,\n });\n } catch (err) {\n setError(err);\n setReady(false);\n return;\n }\n recorderRef.current = recorder;\n setReady(true);\n setStatus(\"idle\");\n\n return () => {\n if (recorder.status() === \"recording\" || recorder.status() === \"paused\") {\n recorder.cancel();\n }\n recorderRef.current = null;\n setReady(false);\n };\n }, [\n stream,\n mimeType,\n videoBitsPerSecond,\n audioBitsPerSecond,\n timesliceMs,\n emitChunk,\n emitError,\n ]);\n\n const stop = useCallback(async (): Promise<VideoRecording | null> => {\n const recorder = recorderRef.current;\n if (!recorder) return null;\n const current = recorder.status();\n if (current !== \"recording\" && current !== \"paused\") return null;\n const result = await recorder.stop();\n setStatus(\"stopped\");\n setDurationMs(result.durationMs);\n setRecording(result);\n emitRecorded(result);\n return result;\n }, [emitRecorded]);\n\n /**\n * Publish the clock while something is running, and enforce `maxDurationMs`.\n *\n * The cap is checked on the same tick rather than with a `setTimeout` armed at\n * `start()`, because a paused recording must not keep counting toward it — a\n * timeout would fire while the user is paused on a slide.\n */\n useEffect(() => {\n if (status !== \"recording\" && status !== \"paused\") return;\n const id = setInterval(() => {\n const recorder = recorderRef.current;\n if (!recorder) return;\n const elapsed = recorder.durationMs();\n setDurationMs(elapsed);\n if (maxDurationMs !== undefined && elapsed >= maxDurationMs) void stop();\n }, tickMs);\n return () => clearInterval(id);\n }, [status, tickMs, maxDurationMs, stop]);\n\n const start = useCallback((): void => {\n const recorder = recorderRef.current;\n if (!recorder) return;\n setRecording(null);\n setError(null);\n setDurationMs(0);\n recorder.start();\n setStatus(recorder.status());\n }, []);\n\n const pause = useCallback((): void => {\n const recorder = recorderRef.current;\n if (!recorder) return;\n recorder.pause();\n setDurationMs(recorder.durationMs());\n setStatus(recorder.status());\n }, []);\n\n const resume = useCallback((): void => {\n const recorder = recorderRef.current;\n if (!recorder) return;\n recorder.resume();\n setStatus(recorder.status());\n }, []);\n\n const cancel = useCallback((): void => {\n const recorder = recorderRef.current;\n if (!recorder) return;\n recorder.cancel();\n setStatus(\"idle\");\n setDurationMs(0);\n setRecording(null);\n }, []);\n\n return { status, durationMs, recording, error, ready, start, pause, resume, stop, cancel };\n}\n"],"mappings":"6GA8EA,SAAgB,EACZ,EACA,EAAmC,CAAC,EACd,CACtB,GAAM,CACF,gBACA,aACA,UACA,UACA,WACA,qBACA,qBACA,cACA,SAAS,KACT,EAEE,CAAC,EAAQ,IAAA,EAAA,EAAA,SAAA,CAA2C,MAAM,EAC1D,CAAC,EAAY,IAAA,EAAA,EAAA,SAAA,CAA0B,CAAC,EACxC,CAAC,EAAW,IAAA,EAAA,EAAA,SAAA,CAAgD,IAAI,EAChE,CAAC,EAAO,IAAA,EAAA,EAAA,SAAA,CAA8B,IAAI,EAC1C,CAAC,EAAO,IAAA,EAAA,EAAA,SAAA,CAAqB,EAAK,EAElC,GAAA,EAAA,EAAA,OAAA,CAAiD,IAAI,EAErD,EAAe,EAAA,kBAAmB,GAA2B,IAAa,CAAM,CAAC,EACjF,EAAY,EAAA,kBAAmB,GAAgB,IAAU,CAAK,CAAC,EAC/D,EAAY,EAAA,kBAAmB,GAAiB,CAClD,EAAS,CAAG,EACZ,IAAU,CAAG,CACjB,CAAC,GAWD,EAAA,EAAA,UAAA,KAAgB,CACZ,GAAI,CAAC,EAAQ,CACT,EAAS,EAAK,EACd,MACJ,CACA,IAAI,EACJ,GAAI,CACA,EAAW,EAAA,oBAAoB,EAAQ,CACnC,WACA,qBACA,qBACA,cACA,QAAS,EACT,QAAS,CACb,CAAC,CACL,OAAS,EAAK,CACV,EAAS,CAAG,EACZ,EAAS,EAAK,EACd,MACJ,CAKA,MAJA,GAAY,QAAU,EACtB,EAAS,EAAI,EACb,EAAU,MAAM,MAEH,EACL,EAA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,EAAO,QAAA,EAAA,EAAA,YAAA,KAhB7B,CACnC,IAAM,EAAW,EAAY,QACxB,IACL,EAAS,OAAO,EAChB,EAAU,EAAS,OAAO,CAAC,EAC/B,EAAG,CAAC,CAWgE,EAAQ,OAAM,QAAA,EAAA,EAAA,YAAA,KAT3C,CACnC,IAAM,EAAW,EAAY,QACxB,IACL,EAAS,OAAO,EAChB,EAAU,MAAM,EAChB,EAAc,CAAC,EACf,EAAa,IAAI,EACrB,EAAG,CAAC,CAE8E,CAAO,CAC7F"}
|
|
1
|
+
{"version":3,"file":"use-video-recorder.cjs","names":[],"sources":["../../src/capture/use-video-recorder.ts"],"sourcesContent":["/**\n * @tempest-limits hook-lines — the same lifecycle as the audio recorder —\n * permission, recorder, clock, auto-stop — over a stream that also carries video,\n * with the preview element to attach and release.\n */\nimport { useCallback, useEffect, useRef, useState } from \"react\";\n\nimport { useStableCallback } from \"@/hooks/use-stable-callback\";\n\nimport type { MediaRecorderHandle, MediaRecorderStatus } from \"./media-recorder\";\nimport {\n createVideoRecorder,\n type VideoRecorderOptions,\n type VideoRecording,\n} from \"./video-recorder\";\n\n/** Options for {@link useVideoRecorder}. */\nexport interface UseVideoRecorderOptions extends VideoRecorderOptions {\n /**\n * Stop automatically after this many milliseconds.\n *\n * Worth setting on anything user-facing, and more so than for audio: a minute of\n * 1080p at 2.5 Mbps is roughly 19 MB, so a recording left running by accident\n * fills memory an order of magnitude faster than a voice note does.\n */\n maxDurationMs?: number;\n /** Called once the recording is assembled, whether by `stop()` or `maxDurationMs`. */\n onRecorded?: (recording: VideoRecording) => void;\n /** How often the clock is published, in ms. Default 250. */\n tickMs?: number;\n}\n\n/** Value returned by {@link useVideoRecorder}. */\nexport interface UseVideoRecorderResult {\n status: MediaRecorderStatus;\n /** Recorded length so far, excluding paused time. */\n durationMs: number;\n /** The finished recording, or `null` before the first `stop()`. */\n recording: VideoRecording | null;\n /** Recorder-level error (encoder failure, share revoked mid-recording). */\n error: unknown;\n /** `false` when there is no stream yet, or the browser cannot record video. */\n ready: boolean;\n start: () => void;\n pause: () => void;\n resume: () => void;\n /** Stop and resolve with the recording. Also published on `recording`. */\n stop: () => Promise<VideoRecording | null>;\n /** Stop and throw the video away. */\n cancel: () => void;\n}\n\n/**\n * Record a video stream — from {@link useScreenCapture}, from a camera, or from a\n * canvas.\n *\n * Pass the stream in; the hook stays `ready: false` until there is one, so a page can\n * render the whole recorder UI before the user has picked a screen and simply have it\n * disabled.\n *\n * There is no level meter here, which is the one real difference from\n * `useAudioRecorder`: metering a screen share means opening an `AudioContext` on a\n * stream that usually has no audio track at all, and browsers cap the number of live\n * contexts. If you are recording a camera **and** want a level, run\n * `createLevelMeter` on the same stream yourself.\n *\n * The clock is published every `tickMs` (default 250 ms) rather than per frame: a\n * video recording UI shows `0:07`, and a hook that re-rendered its parent 60 times a\n * second to move a one-second counter would be the most expensive thing on the page.\n *\n * @param stream - The stream to record, or `null` while the picker is open.\n * @param options - See {@link UseVideoRecorderOptions}.\n *\n * @example\n * const screen = useScreenCapture();\n * const rec = useVideoRecorder(screen.stream, { maxDurationMs: 120_000 });\n * <button disabled={!rec.ready} onClick={rec.start}>Gravar tela</button>\n */\nexport function useVideoRecorder(\n stream: MediaStream | null,\n options: UseVideoRecorderOptions = {},\n): UseVideoRecorderResult {\n const {\n maxDurationMs,\n onRecorded,\n onChunk,\n onError,\n mimeType,\n videoBitsPerSecond,\n audioBitsPerSecond,\n timesliceMs,\n tickMs = 250,\n } = options;\n\n const [status, setStatus] = useState<MediaRecorderStatus>(\"idle\");\n const [durationMs, setDurationMs] = useState(0);\n const [recording, setRecording] = useState<VideoRecording | null>(null);\n const [error, setError] = useState<unknown>(null);\n const [ready, setReady] = useState(false);\n\n const recorderRef = useRef<MediaRecorderHandle | null>(null);\n\n const emitRecorded = useStableCallback((result: VideoRecording) => onRecorded?.(result));\n const emitChunk = useStableCallback((chunk: Blob) => onChunk?.(chunk));\n const emitError = useStableCallback((err: unknown) => {\n setError(err);\n onError?.(err);\n });\n\n /**\n * Build the recorder for a stream, and tear it down when the stream changes.\n *\n * Rebuilt per stream because `MediaRecorder` is bound to the stream it was\n * constructed with: a user who stops sharing and picks a different window hands us\n * a new `MediaStream`, and reusing the old recorder would keep recording a surface\n * that no longer exists. Same reason for a container or bitrate change — both are\n * constructor arguments.\n */\n useEffect(() => {\n if (!stream) {\n setReady(false);\n return;\n }\n let recorder: MediaRecorderHandle;\n try {\n recorder = createVideoRecorder(stream, {\n mimeType,\n videoBitsPerSecond,\n audioBitsPerSecond,\n timesliceMs,\n onChunk: emitChunk,\n onError: emitError,\n });\n } catch (err) {\n setError(err);\n setReady(false);\n return;\n }\n recorderRef.current = recorder;\n setReady(true);\n setStatus(\"idle\");\n\n return () => {\n if (recorder.status() === \"recording\" || recorder.status() === \"paused\") {\n recorder.cancel();\n }\n recorderRef.current = null;\n setReady(false);\n };\n }, [\n stream,\n mimeType,\n videoBitsPerSecond,\n audioBitsPerSecond,\n timesliceMs,\n emitChunk,\n emitError,\n ]);\n\n const stop = useCallback(async (): Promise<VideoRecording | null> => {\n const recorder = recorderRef.current;\n if (!recorder) return null;\n const current = recorder.status();\n if (current !== \"recording\" && current !== \"paused\") return null;\n const result = await recorder.stop();\n setStatus(\"stopped\");\n setDurationMs(result.durationMs);\n setRecording(result);\n emitRecorded(result);\n return result;\n }, [emitRecorded]);\n\n /**\n * Publish the clock while something is running, and enforce `maxDurationMs`.\n *\n * The cap is checked on the same tick rather than with a `setTimeout` armed at\n * `start()`, because a paused recording must not keep counting toward it — a\n * timeout would fire while the user is paused on a slide.\n */\n useEffect(() => {\n if (status !== \"recording\" && status !== \"paused\") return;\n const id = setInterval(() => {\n const recorder = recorderRef.current;\n if (!recorder) return;\n const elapsed = recorder.durationMs();\n setDurationMs(elapsed);\n if (maxDurationMs !== undefined && elapsed >= maxDurationMs) void stop();\n }, tickMs);\n return () => clearInterval(id);\n }, [status, tickMs, maxDurationMs, stop]);\n\n const start = useCallback((): void => {\n const recorder = recorderRef.current;\n if (!recorder) return;\n setRecording(null);\n setError(null);\n setDurationMs(0);\n recorder.start();\n setStatus(recorder.status());\n }, []);\n\n const pause = useCallback((): void => {\n const recorder = recorderRef.current;\n if (!recorder) return;\n recorder.pause();\n setDurationMs(recorder.durationMs());\n setStatus(recorder.status());\n }, []);\n\n const resume = useCallback((): void => {\n const recorder = recorderRef.current;\n if (!recorder) return;\n recorder.resume();\n setStatus(recorder.status());\n }, []);\n\n const cancel = useCallback((): void => {\n const recorder = recorderRef.current;\n if (!recorder) return;\n recorder.cancel();\n setStatus(\"idle\");\n setDurationMs(0);\n setRecording(null);\n }, []);\n\n return { status, durationMs, recording, error, ready, start, pause, resume, stop, cancel };\n}\n"],"mappings":"6GA8EA,SAAgB,EACZ,EACA,EAAmC,CAAC,EACd,CACtB,GAAM,CACF,gBACA,aACA,UACA,UACA,WACA,qBACA,qBACA,cACA,SAAS,KACT,EAEE,CAAC,EAAQ,IAAA,EAAa,EAAA,SAAA,CAA8B,MAAM,EAC1D,CAAC,EAAY,IAAA,EAAiB,EAAA,SAAA,CAAS,CAAC,EACxC,CAAC,EAAW,IAAA,EAAgB,EAAA,SAAA,CAAgC,IAAI,EAChE,CAAC,EAAO,IAAA,EAAY,EAAA,SAAA,CAAkB,IAAI,EAC1C,CAAC,EAAO,IAAA,EAAY,EAAA,SAAA,CAAS,EAAK,EAElC,GAAA,EAAc,EAAA,OAAA,CAAmC,IAAI,EAErD,EAAe,EAAA,kBAAmB,GAA2B,IAAa,CAAM,CAAC,EACjF,EAAY,EAAA,kBAAmB,GAAgB,IAAU,CAAK,CAAC,EAC/D,EAAY,EAAA,kBAAmB,GAAiB,CAClD,EAAS,CAAG,EACZ,IAAU,CAAG,CACjB,CAAC,GAWD,EAAA,EAAA,UAAA,KAAgB,CACZ,GAAI,CAAC,EAAQ,CACT,EAAS,EAAK,EACd,MACJ,CACA,IAAI,EACJ,GAAI,CACA,EAAW,EAAA,oBAAoB,EAAQ,CACnC,WACA,qBACA,qBACA,c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AAO,OAAA,EAxB/C,EAAA,YAAA,KAAwB,CAClC,IAAM,EAAW,EAAY,QACxB,IACL,EAAS,MAAM,EACf,EAAc,EAAS,WAAW,CAAC,EACnC,EAAU,EAAS,OAAO,CAAC,EAC/B,EAAG,CAAC,CAkByD,EAAO,QAAA,EAhBrD,EAAA,YAAA,KAAwB,CACnC,IAAM,EAAW,EAAY,QACxB,IACL,EAAS,OAAO,EAChB,EAAU,EAAS,OAAO,CAAC,EAC/B,EAAG,CAAC,CAWgE,EAAQ,OAAM,QAAA,EATnE,EAAA,YAAA,KAAwB,CACnC,IAAM,EAAW,EAAY,QACxB,IACL,EAAS,OAAO,EAChB,EAAU,MAAM,EAChB,EAAc,CAAC,EACf,EAAa,IAAI,EACrB,EAAG,CAAC,CAE8E,CAAO,CAC7F"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AreaChart.cjs","names":[],"sources":["../../src/charts/AreaChart.tsx"],"sourcesContent":["import {\n Area,\n AreaChart as RAreaChart,\n CartesianGrid,\n Legend,\n ResponsiveContainer,\n Tooltip,\n XAxis,\n YAxis,\n} from \"recharts\";\nimport { cn } from \"@/utils/cn\";\nimport { useChartColors } from \"./use-chart-colors\";\nimport { toTooltipFormatter } from \"./types\";\nimport type { CartesianChartProps } from \"./types\";\n\n/**\n * AreaChart — themed wrapper over recharts `AreaChart`.\n *\n * Plots one filled area per entry in `categories`, colored from `colors`\n * (cycling the `--tempest-chart-*` theme tokens by default). When `stack` is set, all\n * areas share a stackId. When `width` is provided the chart renders at that\n * fixed size without a ResponsiveContainer; otherwise it fills its parent.\n */\nexport function AreaChart({\n data,\n index,\n categories,\n colors,\n height = 300,\n width,\n stack = false,\n showLegend = true,\n showGrid = true,\n showTooltip = true,\n valueFormatter,\n className,\n}: CartesianChartProps) {\n const palette = useChartColors(colors);\n const stackId = stack ? \"stack\" : undefined;\n\n const chart = (\n <RAreaChart data={data} width={width} height={height}>\n {showGrid ? <CartesianGrid strokeDasharray=\"3 3\" /> : null}\n <XAxis dataKey={index} />\n <YAxis tickFormatter={valueFormatter} />\n {showTooltip ? <Tooltip formatter={toTooltipFormatter(valueFormatter)} /> : null}\n {showLegend ? <Legend /> : null}\n {categories.map((category, i) => {\n const color = palette[i % palette.length];\n return (\n <Area\n key={category}\n type=\"monotone\"\n dataKey={category}\n stackId={stackId}\n stroke={color}\n fill={color}\n fillOpacity={0.3}\n />\n );\n })}\n </RAreaChart>\n );\n\n return (\n <div className={cn(className)}>\n {width !== undefined ? (\n chart\n ) : (\n <ResponsiveContainer width=\"100%\" height={height}>\n {chart}\n </ResponsiveContainer>\n )}\n </div>\n );\n}\n"],"mappings":"yJAuBA,SAAgB,EAAU,CACtB,OACA,QACA,aACA,SACA,SAAS,IACT,QACA,QAAQ,GACR,aAAa,GACb,WAAW,GACX,cAAc,GACd,iBACA,aACoB,CACpB,IAAM,EAAU,EAAA,eAAe,CAAM,EAC/B,EAAU,EAAQ,QAAU,IAAA,GAE5B,GACF,EAAA,EAAA,KAAA,CAAC,EAAA,UAAD,CAAkB,OAAa,QAAe,
|
|
1
|
+
{"version":3,"file":"AreaChart.cjs","names":[],"sources":["../../src/charts/AreaChart.tsx"],"sourcesContent":["import {\n Area,\n AreaChart as RAreaChart,\n CartesianGrid,\n Legend,\n ResponsiveContainer,\n Tooltip,\n XAxis,\n YAxis,\n} from \"recharts\";\nimport { cn } from \"@/utils/cn\";\nimport { useChartColors } from \"./use-chart-colors\";\nimport { toTooltipFormatter } from \"./types\";\nimport type { CartesianChartProps } from \"./types\";\n\n/**\n * AreaChart — themed wrapper over recharts `AreaChart`.\n *\n * Plots one filled area per entry in `categories`, colored from `colors`\n * (cycling the `--tempest-chart-*` theme tokens by default). When `stack` is set, all\n * areas share a stackId. When `width` is provided the chart renders at that\n * fixed size without a ResponsiveContainer; otherwise it fills its parent.\n */\nexport function AreaChart({\n data,\n index,\n categories,\n colors,\n height = 300,\n width,\n stack = false,\n showLegend = true,\n showGrid = true,\n showTooltip = true,\n valueFormatter,\n className,\n}: CartesianChartProps) {\n const palette = useChartColors(colors);\n const stackId = stack ? \"stack\" : undefined;\n\n const chart = (\n <RAreaChart data={data} width={width} height={height}>\n {showGrid ? <CartesianGrid strokeDasharray=\"3 3\" /> : null}\n <XAxis dataKey={index} />\n <YAxis tickFormatter={valueFormatter} />\n {showTooltip ? <Tooltip formatter={toTooltipFormatter(valueFormatter)} /> : null}\n {showLegend ? <Legend /> : null}\n {categories.map((category, i) => {\n const color = palette[i % palette.length];\n return (\n <Area\n key={category}\n type=\"monotone\"\n dataKey={category}\n stackId={stackId}\n stroke={color}\n fill={color}\n fillOpacity={0.3}\n />\n );\n })}\n </RAreaChart>\n );\n\n return (\n <div className={cn(className)}>\n {width !== undefined ? (\n chart\n ) : (\n <ResponsiveContainer width=\"100%\" height={height}>\n {chart}\n </ResponsiveContainer>\n )}\n </div>\n );\n}\n"],"mappings":"yJAuBA,SAAgB,EAAU,CACtB,OACA,QACA,aACA,SACA,SAAS,IACT,QACA,QAAQ,GACR,aAAa,GACb,WAAW,GACX,cAAc,GACd,iBACA,aACoB,CACpB,IAAM,EAAU,EAAA,eAAe,CAAM,EAC/B,EAAU,EAAQ,QAAU,IAAA,GAE5B,GACF,EAAA,EAAA,KAAA,CAAC,EAAA,UAAD,CAAkB,OAAa,QAAe,SAA9C,SAAA,CACK,GAAW,EAAA,EAAA,IAAA,CAAC,EAAA,cAAD,CAAe,gBAAgB,KAAO,CAAA,EAAI,MACtD,EAAA,EAAA,IAAA,CAAC,EAAA,MAAD,CAAO,QAAS,CAAQ,CAAA,GACxB,EAAA,EAAA,IAAA,CAAC,EAAA,MAAD,CAAO,cAAe,CAAiB,CAAA,EACtC,GAAc,EAAA,EAAA,IAAA,CAAC,EAAA,QAAD,CAAS,UAAW,EAAA,mBAAmB,CAAc,CAAI,CAAA,EAAI,KAC3E,GAAa,EAAA,EAAA,IAAA,CAAC,EAAA,OAAD,CAAS,CAAA,EAAI,KAC1B,EAAW,KAAK,EAAU,IAAM,CAC7B,IAAM,EAAQ,EAAQ,EAAI,EAAQ,QAClC,OACI,EAAA,EAAA,IAAA,CAAC,EAAA,KAAD,CAEI,KAAK,WACL,QAAS,EACA,UACT,OAAQ,EACR,KAAM,EACN,YAAa,EAChB,EAPQ,CAOR,CAET,CAAC,CACO,IAGhB,OACI,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,UAAW,EAAA,GAAG,CAAS,EACvB,SAAA,IAAU,IAAA,IAGP,EAAA,EAAA,IAAA,CAAC,EAAA,oBAAD,CAAqB,MAAM,OAAe,SACrC,SAAA,CACgB,CAAA,EAJrB,CAMH,CAAA,CAEb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AreaChart.js","names":[],"sources":["../../src/charts/AreaChart.tsx"],"sourcesContent":["import {\n Area,\n AreaChart as RAreaChart,\n CartesianGrid,\n Legend,\n ResponsiveContainer,\n Tooltip,\n XAxis,\n YAxis,\n} from \"recharts\";\nimport { cn } from \"@/utils/cn\";\nimport { useChartColors } from \"./use-chart-colors\";\nimport { toTooltipFormatter } from \"./types\";\nimport type { CartesianChartProps } from \"./types\";\n\n/**\n * AreaChart — themed wrapper over recharts `AreaChart`.\n *\n * Plots one filled area per entry in `categories`, colored from `colors`\n * (cycling the `--tempest-chart-*` theme tokens by default). When `stack` is set, all\n * areas share a stackId. When `width` is provided the chart renders at that\n * fixed size without a ResponsiveContainer; otherwise it fills its parent.\n */\nexport function AreaChart({\n data,\n index,\n categories,\n colors,\n height = 300,\n width,\n stack = false,\n showLegend = true,\n showGrid = true,\n showTooltip = true,\n valueFormatter,\n className,\n}: CartesianChartProps) {\n const palette = useChartColors(colors);\n const stackId = stack ? \"stack\" : undefined;\n\n const chart = (\n <RAreaChart data={data} width={width} height={height}>\n {showGrid ? <CartesianGrid strokeDasharray=\"3 3\" /> : null}\n <XAxis dataKey={index} />\n <YAxis tickFormatter={valueFormatter} />\n {showTooltip ? <Tooltip formatter={toTooltipFormatter(valueFormatter)} /> : null}\n {showLegend ? <Legend /> : null}\n {categories.map((category, i) => {\n const color = palette[i % palette.length];\n return (\n <Area\n key={category}\n type=\"monotone\"\n dataKey={category}\n stackId={stackId}\n stroke={color}\n fill={color}\n fillOpacity={0.3}\n />\n );\n })}\n </RAreaChart>\n );\n\n return (\n <div className={cn(className)}>\n {width !== undefined ? (\n chart\n ) : (\n <ResponsiveContainer width=\"100%\" height={height}>\n {chart}\n </ResponsiveContainer>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;AAuBA,SAAgB,EAAU,EACtB,SACA,UACA,eACA,WACA,YAAS,KACT,UACA,WAAQ,IACR,gBAAa,IACb,cAAW,IACX,iBAAc,IACd,mBACA,gBACoB;CACpB,IAAM,IAAU,EAAe,CAAM,GAC/B,IAAU,IAAQ,UAAU,KAAA,GAE5B,IACF,kBAAC,GAAD;EAAkB;EAAa;EAAe;
|
|
1
|
+
{"version":3,"file":"AreaChart.js","names":[],"sources":["../../src/charts/AreaChart.tsx"],"sourcesContent":["import {\n Area,\n AreaChart as RAreaChart,\n CartesianGrid,\n Legend,\n ResponsiveContainer,\n Tooltip,\n XAxis,\n YAxis,\n} from \"recharts\";\nimport { cn } from \"@/utils/cn\";\nimport { useChartColors } from \"./use-chart-colors\";\nimport { toTooltipFormatter } from \"./types\";\nimport type { CartesianChartProps } from \"./types\";\n\n/**\n * AreaChart — themed wrapper over recharts `AreaChart`.\n *\n * Plots one filled area per entry in `categories`, colored from `colors`\n * (cycling the `--tempest-chart-*` theme tokens by default). When `stack` is set, all\n * areas share a stackId. When `width` is provided the chart renders at that\n * fixed size without a ResponsiveContainer; otherwise it fills its parent.\n */\nexport function AreaChart({\n data,\n index,\n categories,\n colors,\n height = 300,\n width,\n stack = false,\n showLegend = true,\n showGrid = true,\n showTooltip = true,\n valueFormatter,\n className,\n}: CartesianChartProps) {\n const palette = useChartColors(colors);\n const stackId = stack ? \"stack\" : undefined;\n\n const chart = (\n <RAreaChart data={data} width={width} height={height}>\n {showGrid ? <CartesianGrid strokeDasharray=\"3 3\" /> : null}\n <XAxis dataKey={index} />\n <YAxis tickFormatter={valueFormatter} />\n {showTooltip ? <Tooltip formatter={toTooltipFormatter(valueFormatter)} /> : null}\n {showLegend ? <Legend /> : null}\n {categories.map((category, i) => {\n const color = palette[i % palette.length];\n return (\n <Area\n key={category}\n type=\"monotone\"\n dataKey={category}\n stackId={stackId}\n stroke={color}\n fill={color}\n fillOpacity={0.3}\n />\n );\n })}\n </RAreaChart>\n );\n\n return (\n <div className={cn(className)}>\n {width !== undefined ? (\n chart\n ) : (\n <ResponsiveContainer width=\"100%\" height={height}>\n {chart}\n </ResponsiveContainer>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;AAuBA,SAAgB,EAAU,EACtB,SACA,UACA,eACA,WACA,YAAS,KACT,UACA,WAAQ,IACR,gBAAa,IACb,cAAW,IACX,iBAAc,IACd,mBACA,gBACoB;CACpB,IAAM,IAAU,EAAe,CAAM,GAC/B,IAAU,IAAQ,UAAU,KAAA,GAE5B,IACF,kBAAC,GAAD;EAAkB;EAAa;EAAe;EAA9C,UAAA;GACK,IAAW,kBAAC,GAAD,EAAe,iBAAgB,MAAO,CAAA,IAAI;GACtD,kBAAC,GAAD,EAAO,SAAS,EAAQ,CAAA;GACxB,kBAAC,GAAD,EAAO,eAAe,EAAiB,CAAA;GACtC,IAAc,kBAAC,GAAD,EAAS,WAAW,EAAmB,CAAc,EAAI,CAAA,IAAI;GAC3E,IAAa,kBAAC,GAAD,CAAS,CAAA,IAAI;GAC1B,EAAW,KAAK,GAAU,MAAM;IAC7B,IAAM,IAAQ,EAAQ,IAAI,EAAQ;IAClC,OACI,kBAAC,GAAD;KAEI,MAAK;KACL,SAAS;KACA;KACT,QAAQ;KACR,MAAM;KACN,aAAa;IAChB,GAPQ,CAOR;GAET,CAAC;EACO;;CAGhB,OACI,kBAAC,OAAD;EAAK,WAAW,EAAG,CAAS;EACvB,UAAA,MAAU,KAAA,IAGP,kBAAC,GAAD;GAAqB,OAAM;GAAe;GACrC,UAAA;EACgB,CAAA,IAJrB;CAMH,CAAA;AAEb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BarChart.cjs","names":[],"sources":["../../src/charts/BarChart.tsx"],"sourcesContent":["import {\n Bar,\n BarChart as RBarChart,\n CartesianGrid,\n Legend,\n ResponsiveContainer,\n Tooltip,\n XAxis,\n YAxis,\n} from \"recharts\";\nimport { cn } from \"@/utils/cn\";\nimport { useChartColors } from \"./use-chart-colors\";\nimport { toTooltipFormatter } from \"./types\";\nimport type { CartesianChartProps } from \"./types\";\n\n/**\n * BarChart — themed wrapper over recharts `BarChart`.\n *\n * Plots one bar series per entry in `categories`, colored from `colors`\n * (cycling the `--tempest-chart-*` theme tokens by default). When `stack` is set, all\n * bars share a stackId. When `width` is provided the chart renders at that\n * fixed size without a ResponsiveContainer; otherwise it fills its parent.\n */\nexport function BarChart({\n data,\n index,\n categories,\n colors,\n height = 300,\n width,\n stack = false,\n showLegend = true,\n showGrid = true,\n showTooltip = true,\n valueFormatter,\n className,\n}: CartesianChartProps) {\n const palette = useChartColors(colors);\n const stackId = stack ? \"stack\" : undefined;\n\n const chart = (\n <RBarChart data={data} width={width} height={height}>\n {showGrid ? <CartesianGrid strokeDasharray=\"3 3\" /> : null}\n <XAxis dataKey={index} />\n <YAxis tickFormatter={valueFormatter} />\n {showTooltip ? <Tooltip formatter={toTooltipFormatter(valueFormatter)} /> : null}\n {showLegend ? <Legend /> : null}\n {categories.map((category, i) => (\n <Bar\n key={category}\n dataKey={category}\n stackId={stackId}\n fill={palette[i % palette.length]}\n />\n ))}\n </RBarChart>\n );\n\n return (\n <div className={cn(className)}>\n {width !== undefined ? (\n chart\n ) : (\n <ResponsiveContainer width=\"100%\" height={height}>\n {chart}\n </ResponsiveContainer>\n )}\n </div>\n );\n}\n"],"mappings":"yJAuBA,SAAgB,EAAS,CACrB,OACA,QACA,aACA,SACA,SAAS,IACT,QACA,QAAQ,GACR,aAAa,GACb,WAAW,GACX,cAAc,GACd,iBACA,aACoB,CACpB,IAAM,EAAU,EAAA,eAAe,CAAM,EAC/B,EAAU,EAAQ,QAAU,IAAA,GAE5B,GACF,EAAA,EAAA,KAAA,CAAC,EAAA,SAAD,CAAiB,OAAa,QAAe,
|
|
1
|
+
{"version":3,"file":"BarChart.cjs","names":[],"sources":["../../src/charts/BarChart.tsx"],"sourcesContent":["import {\n Bar,\n BarChart as RBarChart,\n CartesianGrid,\n Legend,\n ResponsiveContainer,\n Tooltip,\n XAxis,\n YAxis,\n} from \"recharts\";\nimport { cn } from \"@/utils/cn\";\nimport { useChartColors } from \"./use-chart-colors\";\nimport { toTooltipFormatter } from \"./types\";\nimport type { CartesianChartProps } from \"./types\";\n\n/**\n * BarChart — themed wrapper over recharts `BarChart`.\n *\n * Plots one bar series per entry in `categories`, colored from `colors`\n * (cycling the `--tempest-chart-*` theme tokens by default). When `stack` is set, all\n * bars share a stackId. When `width` is provided the chart renders at that\n * fixed size without a ResponsiveContainer; otherwise it fills its parent.\n */\nexport function BarChart({\n data,\n index,\n categories,\n colors,\n height = 300,\n width,\n stack = false,\n showLegend = true,\n showGrid = true,\n showTooltip = true,\n valueFormatter,\n className,\n}: CartesianChartProps) {\n const palette = useChartColors(colors);\n const stackId = stack ? \"stack\" : undefined;\n\n const chart = (\n <RBarChart data={data} width={width} height={height}>\n {showGrid ? <CartesianGrid strokeDasharray=\"3 3\" /> : null}\n <XAxis dataKey={index} />\n <YAxis tickFormatter={valueFormatter} />\n {showTooltip ? <Tooltip formatter={toTooltipFormatter(valueFormatter)} /> : null}\n {showLegend ? <Legend /> : null}\n {categories.map((category, i) => (\n <Bar\n key={category}\n dataKey={category}\n stackId={stackId}\n fill={palette[i % palette.length]}\n />\n ))}\n </RBarChart>\n );\n\n return (\n <div className={cn(className)}>\n {width !== undefined ? (\n chart\n ) : (\n <ResponsiveContainer width=\"100%\" height={height}>\n {chart}\n </ResponsiveContainer>\n )}\n </div>\n );\n}\n"],"mappings":"yJAuBA,SAAgB,EAAS,CACrB,OACA,QACA,aACA,SACA,SAAS,IACT,QACA,QAAQ,GACR,aAAa,GACb,WAAW,GACX,cAAc,GACd,iBACA,aACoB,CACpB,IAAM,EAAU,EAAA,eAAe,CAAM,EAC/B,EAAU,EAAQ,QAAU,IAAA,GAE5B,GACF,EAAA,EAAA,KAAA,CAAC,EAAA,SAAD,CAAiB,OAAa,QAAe,SAA7C,SAAA,CACK,GAAW,EAAA,EAAA,IAAA,CAAC,EAAA,cAAD,CAAe,gBAAgB,KAAO,CAAA,EAAI,MACtD,EAAA,EAAA,IAAA,CAAC,EAAA,MAAD,CAAO,QAAS,CAAQ,CAAA,GACxB,EAAA,EAAA,IAAA,CAAC,EAAA,MAAD,CAAO,cAAe,CAAiB,CAAA,EACtC,GAAc,EAAA,EAAA,IAAA,CAAC,EAAA,QAAD,CAAS,UAAW,EAAA,mBAAmB,CAAc,CAAI,CAAA,EAAI,KAC3E,GAAa,EAAA,EAAA,IAAA,CAAC,EAAA,OAAD,CAAS,CAAA,EAAI,KAC1B,EAAW,KAAK,EAAU,KACvB,EAAA,EAAA,IAAA,CAAC,EAAA,IAAD,CAEI,QAAS,EACA,UACT,KAAM,EAAQ,EAAI,EAAQ,OAC7B,EAJQ,CAIR,CACJ,CACM,IAGf,OACI,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,UAAW,EAAA,GAAG,CAAS,EACvB,SAAA,IAAU,IAAA,IAGP,EAAA,EAAA,IAAA,CAAC,EAAA,oBAAD,CAAqB,MAAM,OAAe,SACrC,SAAA,CACgB,CAAA,EAJrB,CAMH,CAAA,CAEb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BarChart.js","names":[],"sources":["../../src/charts/BarChart.tsx"],"sourcesContent":["import {\n Bar,\n BarChart as RBarChart,\n CartesianGrid,\n Legend,\n ResponsiveContainer,\n Tooltip,\n XAxis,\n YAxis,\n} from \"recharts\";\nimport { cn } from \"@/utils/cn\";\nimport { useChartColors } from \"./use-chart-colors\";\nimport { toTooltipFormatter } from \"./types\";\nimport type { CartesianChartProps } from \"./types\";\n\n/**\n * BarChart — themed wrapper over recharts `BarChart`.\n *\n * Plots one bar series per entry in `categories`, colored from `colors`\n * (cycling the `--tempest-chart-*` theme tokens by default). When `stack` is set, all\n * bars share a stackId. When `width` is provided the chart renders at that\n * fixed size without a ResponsiveContainer; otherwise it fills its parent.\n */\nexport function BarChart({\n data,\n index,\n categories,\n colors,\n height = 300,\n width,\n stack = false,\n showLegend = true,\n showGrid = true,\n showTooltip = true,\n valueFormatter,\n className,\n}: CartesianChartProps) {\n const palette = useChartColors(colors);\n const stackId = stack ? \"stack\" : undefined;\n\n const chart = (\n <RBarChart data={data} width={width} height={height}>\n {showGrid ? <CartesianGrid strokeDasharray=\"3 3\" /> : null}\n <XAxis dataKey={index} />\n <YAxis tickFormatter={valueFormatter} />\n {showTooltip ? <Tooltip formatter={toTooltipFormatter(valueFormatter)} /> : null}\n {showLegend ? <Legend /> : null}\n {categories.map((category, i) => (\n <Bar\n key={category}\n dataKey={category}\n stackId={stackId}\n fill={palette[i % palette.length]}\n />\n ))}\n </RBarChart>\n );\n\n return (\n <div className={cn(className)}>\n {width !== undefined ? (\n chart\n ) : (\n <ResponsiveContainer width=\"100%\" height={height}>\n {chart}\n </ResponsiveContainer>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;AAuBA,SAAgB,EAAS,EACrB,SACA,UACA,eACA,WACA,YAAS,KACT,UACA,WAAQ,IACR,gBAAa,IACb,cAAW,IACX,iBAAc,IACd,mBACA,gBACoB;CACpB,IAAM,IAAU,EAAe,CAAM,GAC/B,IAAU,IAAQ,UAAU,KAAA,GAE5B,IACF,kBAAC,GAAD;EAAiB;EAAa;EAAe;
|
|
1
|
+
{"version":3,"file":"BarChart.js","names":[],"sources":["../../src/charts/BarChart.tsx"],"sourcesContent":["import {\n Bar,\n BarChart as RBarChart,\n CartesianGrid,\n Legend,\n ResponsiveContainer,\n Tooltip,\n XAxis,\n YAxis,\n} from \"recharts\";\nimport { cn } from \"@/utils/cn\";\nimport { useChartColors } from \"./use-chart-colors\";\nimport { toTooltipFormatter } from \"./types\";\nimport type { CartesianChartProps } from \"./types\";\n\n/**\n * BarChart — themed wrapper over recharts `BarChart`.\n *\n * Plots one bar series per entry in `categories`, colored from `colors`\n * (cycling the `--tempest-chart-*` theme tokens by default). When `stack` is set, all\n * bars share a stackId. When `width` is provided the chart renders at that\n * fixed size without a ResponsiveContainer; otherwise it fills its parent.\n */\nexport function BarChart({\n data,\n index,\n categories,\n colors,\n height = 300,\n width,\n stack = false,\n showLegend = true,\n showGrid = true,\n showTooltip = true,\n valueFormatter,\n className,\n}: CartesianChartProps) {\n const palette = useChartColors(colors);\n const stackId = stack ? \"stack\" : undefined;\n\n const chart = (\n <RBarChart data={data} width={width} height={height}>\n {showGrid ? <CartesianGrid strokeDasharray=\"3 3\" /> : null}\n <XAxis dataKey={index} />\n <YAxis tickFormatter={valueFormatter} />\n {showTooltip ? <Tooltip formatter={toTooltipFormatter(valueFormatter)} /> : null}\n {showLegend ? <Legend /> : null}\n {categories.map((category, i) => (\n <Bar\n key={category}\n dataKey={category}\n stackId={stackId}\n fill={palette[i % palette.length]}\n />\n ))}\n </RBarChart>\n );\n\n return (\n <div className={cn(className)}>\n {width !== undefined ? (\n chart\n ) : (\n <ResponsiveContainer width=\"100%\" height={height}>\n {chart}\n </ResponsiveContainer>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;AAuBA,SAAgB,EAAS,EACrB,SACA,UACA,eACA,WACA,YAAS,KACT,UACA,WAAQ,IACR,gBAAa,IACb,cAAW,IACX,iBAAc,IACd,mBACA,gBACoB;CACpB,IAAM,IAAU,EAAe,CAAM,GAC/B,IAAU,IAAQ,UAAU,KAAA,GAE5B,IACF,kBAAC,GAAD;EAAiB;EAAa;EAAe;EAA7C,UAAA;GACK,IAAW,kBAAC,GAAD,EAAe,iBAAgB,MAAO,CAAA,IAAI;GACtD,kBAAC,GAAD,EAAO,SAAS,EAAQ,CAAA;GACxB,kBAAC,GAAD,EAAO,eAAe,EAAiB,CAAA;GACtC,IAAc,kBAAC,GAAD,EAAS,WAAW,EAAmB,CAAc,EAAI,CAAA,IAAI;GAC3E,IAAa,kBAAC,GAAD,CAAS,CAAA,IAAI;GAC1B,EAAW,KAAK,GAAU,MACvB,kBAAC,GAAD;IAEI,SAAS;IACA;IACT,MAAM,EAAQ,IAAI,EAAQ;GAC7B,GAJQ,CAIR,CACJ;EACM;;CAGf,OACI,kBAAC,OAAD;EAAK,WAAW,EAAG,CAAS;EACvB,UAAA,MAAU,KAAA,IAGP,kBAAC,GAAD;GAAqB,OAAM;GAAe;GACrC,UAAA;EACgB,CAAA,IAJrB;CAMH,CAAA;AAEb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineChart.cjs","names":[],"sources":["../../src/charts/LineChart.tsx"],"sourcesContent":["import {\n CartesianGrid,\n Legend,\n Line,\n LineChart as RLineChart,\n ResponsiveContainer,\n Tooltip,\n XAxis,\n YAxis,\n} from \"recharts\";\nimport { cn } from \"@/utils/cn\";\nimport { useChartColors } from \"./use-chart-colors\";\nimport { toTooltipFormatter } from \"./types\";\nimport type { CartesianChartProps } from \"./types\";\n\n/**\n * LineChart — themed wrapper over recharts `LineChart`.\n *\n * Plots one line per entry in `categories`, colored from `colors` (cycling\n * the `--tempest-chart-*` theme tokens by default). `stack` is accepted for API parity\n * but does not visually stack lines. When `width` is provided the chart renders\n * at that fixed size without a ResponsiveContainer; otherwise it fills its\n * parent.\n */\nexport function LineChart({\n data,\n index,\n categories,\n colors,\n height = 300,\n width,\n showLegend = true,\n showGrid = true,\n showTooltip = true,\n valueFormatter,\n className,\n}: CartesianChartProps) {\n const palette = useChartColors(colors);\n const chart = (\n <RLineChart data={data} width={width} height={height}>\n {showGrid ? <CartesianGrid strokeDasharray=\"3 3\" /> : null}\n <XAxis dataKey={index} />\n <YAxis tickFormatter={valueFormatter} />\n {showTooltip ? <Tooltip formatter={toTooltipFormatter(valueFormatter)} /> : null}\n {showLegend ? <Legend /> : null}\n {categories.map((category, i) => (\n <Line\n key={category}\n type=\"monotone\"\n dataKey={category}\n stroke={palette[i % palette.length]}\n dot={false}\n />\n ))}\n </RLineChart>\n );\n\n return (\n <div className={cn(className)}>\n {width !== undefined ? (\n chart\n ) : (\n <ResponsiveContainer width=\"100%\" height={height}>\n {chart}\n </ResponsiveContainer>\n )}\n </div>\n );\n}\n"],"mappings":"yJAwBA,SAAgB,EAAU,CACtB,OACA,QACA,aACA,SACA,SAAS,IACT,QACA,aAAa,GACb,WAAW,GACX,cAAc,GACd,iBACA,aACoB,CACpB,IAAM,EAAU,EAAA,eAAe,CAAM,EAC/B,GACF,EAAA,EAAA,KAAA,CAAC,EAAA,UAAD,CAAkB,OAAa,QAAe,
|
|
1
|
+
{"version":3,"file":"LineChart.cjs","names":[],"sources":["../../src/charts/LineChart.tsx"],"sourcesContent":["import {\n CartesianGrid,\n Legend,\n Line,\n LineChart as RLineChart,\n ResponsiveContainer,\n Tooltip,\n XAxis,\n YAxis,\n} from \"recharts\";\nimport { cn } from \"@/utils/cn\";\nimport { useChartColors } from \"./use-chart-colors\";\nimport { toTooltipFormatter } from \"./types\";\nimport type { CartesianChartProps } from \"./types\";\n\n/**\n * LineChart — themed wrapper over recharts `LineChart`.\n *\n * Plots one line per entry in `categories`, colored from `colors` (cycling\n * the `--tempest-chart-*` theme tokens by default). `stack` is accepted for API parity\n * but does not visually stack lines. When `width` is provided the chart renders\n * at that fixed size without a ResponsiveContainer; otherwise it fills its\n * parent.\n */\nexport function LineChart({\n data,\n index,\n categories,\n colors,\n height = 300,\n width,\n showLegend = true,\n showGrid = true,\n showTooltip = true,\n valueFormatter,\n className,\n}: CartesianChartProps) {\n const palette = useChartColors(colors);\n const chart = (\n <RLineChart data={data} width={width} height={height}>\n {showGrid ? <CartesianGrid strokeDasharray=\"3 3\" /> : null}\n <XAxis dataKey={index} />\n <YAxis tickFormatter={valueFormatter} />\n {showTooltip ? <Tooltip formatter={toTooltipFormatter(valueFormatter)} /> : null}\n {showLegend ? <Legend /> : null}\n {categories.map((category, i) => (\n <Line\n key={category}\n type=\"monotone\"\n dataKey={category}\n stroke={palette[i % palette.length]}\n dot={false}\n />\n ))}\n </RLineChart>\n );\n\n return (\n <div className={cn(className)}>\n {width !== undefined ? (\n chart\n ) : (\n <ResponsiveContainer width=\"100%\" height={height}>\n {chart}\n </ResponsiveContainer>\n )}\n </div>\n );\n}\n"],"mappings":"yJAwBA,SAAgB,EAAU,CACtB,OACA,QACA,aACA,SACA,SAAS,IACT,QACA,aAAa,GACb,WAAW,GACX,cAAc,GACd,iBACA,aACoB,CACpB,IAAM,EAAU,EAAA,eAAe,CAAM,EAC/B,GACF,EAAA,EAAA,KAAA,CAAC,EAAA,UAAD,CAAkB,OAAa,QAAe,SAA9C,SAAA,CACK,GAAW,EAAA,EAAA,IAAA,CAAC,EAAA,cAAD,CAAe,gBAAgB,KAAO,CAAA,EAAI,MACtD,EAAA,EAAA,IAAA,CAAC,EAAA,MAAD,CAAO,QAAS,CAAQ,CAAA,GACxB,EAAA,EAAA,IAAA,CAAC,EAAA,MAAD,CAAO,cAAe,CAAiB,CAAA,EACtC,GAAc,EAAA,EAAA,IAAA,CAAC,EAAA,QAAD,CAAS,UAAW,EAAA,mBAAmB,CAAc,CAAI,CAAA,EAAI,KAC3E,GAAa,EAAA,EAAA,IAAA,CAAC,EAAA,OAAD,CAAS,CAAA,EAAI,KAC1B,EAAW,KAAK,EAAU,KACvB,EAAA,EAAA,IAAA,CAAC,EAAA,KAAD,CAEI,KAAK,WACL,QAAS,EACT,OAAQ,EAAQ,EAAI,EAAQ,QAC5B,IAAK,EACR,EALQ,CAKR,CACJ,CACO,IAGhB,OACI,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,UAAW,EAAA,GAAG,CAAS,EACvB,SAAA,IAAU,IAAA,IAGP,EAAA,EAAA,IAAA,CAAC,EAAA,oBAAD,CAAqB,MAAM,OAAe,SACrC,SAAA,CACgB,CAAA,EAJrB,CAMH,CAAA,CAEb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"LineChart.js","names":[],"sources":["../../src/charts/LineChart.tsx"],"sourcesContent":["import {\n CartesianGrid,\n Legend,\n Line,\n LineChart as RLineChart,\n ResponsiveContainer,\n Tooltip,\n XAxis,\n YAxis,\n} from \"recharts\";\nimport { cn } from \"@/utils/cn\";\nimport { useChartColors } from \"./use-chart-colors\";\nimport { toTooltipFormatter } from \"./types\";\nimport type { CartesianChartProps } from \"./types\";\n\n/**\n * LineChart — themed wrapper over recharts `LineChart`.\n *\n * Plots one line per entry in `categories`, colored from `colors` (cycling\n * the `--tempest-chart-*` theme tokens by default). `stack` is accepted for API parity\n * but does not visually stack lines. When `width` is provided the chart renders\n * at that fixed size without a ResponsiveContainer; otherwise it fills its\n * parent.\n */\nexport function LineChart({\n data,\n index,\n categories,\n colors,\n height = 300,\n width,\n showLegend = true,\n showGrid = true,\n showTooltip = true,\n valueFormatter,\n className,\n}: CartesianChartProps) {\n const palette = useChartColors(colors);\n const chart = (\n <RLineChart data={data} width={width} height={height}>\n {showGrid ? <CartesianGrid strokeDasharray=\"3 3\" /> : null}\n <XAxis dataKey={index} />\n <YAxis tickFormatter={valueFormatter} />\n {showTooltip ? <Tooltip formatter={toTooltipFormatter(valueFormatter)} /> : null}\n {showLegend ? <Legend /> : null}\n {categories.map((category, i) => (\n <Line\n key={category}\n type=\"monotone\"\n dataKey={category}\n stroke={palette[i % palette.length]}\n dot={false}\n />\n ))}\n </RLineChart>\n );\n\n return (\n <div className={cn(className)}>\n {width !== undefined ? (\n chart\n ) : (\n <ResponsiveContainer width=\"100%\" height={height}>\n {chart}\n </ResponsiveContainer>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;AAwBA,SAAgB,EAAU,EACtB,SACA,UACA,eACA,WACA,YAAS,KACT,UACA,gBAAa,IACb,cAAW,IACX,iBAAc,IACd,mBACA,gBACoB;CACpB,IAAM,IAAU,EAAe,CAAM,GAC/B,IACF,kBAAC,GAAD;EAAkB;EAAa;EAAe;
|
|
1
|
+
{"version":3,"file":"LineChart.js","names":[],"sources":["../../src/charts/LineChart.tsx"],"sourcesContent":["import {\n CartesianGrid,\n Legend,\n Line,\n LineChart as RLineChart,\n ResponsiveContainer,\n Tooltip,\n XAxis,\n YAxis,\n} from \"recharts\";\nimport { cn } from \"@/utils/cn\";\nimport { useChartColors } from \"./use-chart-colors\";\nimport { toTooltipFormatter } from \"./types\";\nimport type { CartesianChartProps } from \"./types\";\n\n/**\n * LineChart — themed wrapper over recharts `LineChart`.\n *\n * Plots one line per entry in `categories`, colored from `colors` (cycling\n * the `--tempest-chart-*` theme tokens by default). `stack` is accepted for API parity\n * but does not visually stack lines. When `width` is provided the chart renders\n * at that fixed size without a ResponsiveContainer; otherwise it fills its\n * parent.\n */\nexport function LineChart({\n data,\n index,\n categories,\n colors,\n height = 300,\n width,\n showLegend = true,\n showGrid = true,\n showTooltip = true,\n valueFormatter,\n className,\n}: CartesianChartProps) {\n const palette = useChartColors(colors);\n const chart = (\n <RLineChart data={data} width={width} height={height}>\n {showGrid ? <CartesianGrid strokeDasharray=\"3 3\" /> : null}\n <XAxis dataKey={index} />\n <YAxis tickFormatter={valueFormatter} />\n {showTooltip ? <Tooltip formatter={toTooltipFormatter(valueFormatter)} /> : null}\n {showLegend ? <Legend /> : null}\n {categories.map((category, i) => (\n <Line\n key={category}\n type=\"monotone\"\n dataKey={category}\n stroke={palette[i % palette.length]}\n dot={false}\n />\n ))}\n </RLineChart>\n );\n\n return (\n <div className={cn(className)}>\n {width !== undefined ? (\n chart\n ) : (\n <ResponsiveContainer width=\"100%\" height={height}>\n {chart}\n </ResponsiveContainer>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;AAwBA,SAAgB,EAAU,EACtB,SACA,UACA,eACA,WACA,YAAS,KACT,UACA,gBAAa,IACb,cAAW,IACX,iBAAc,IACd,mBACA,gBACoB;CACpB,IAAM,IAAU,EAAe,CAAM,GAC/B,IACF,kBAAC,GAAD;EAAkB;EAAa;EAAe;EAA9C,UAAA;GACK,IAAW,kBAAC,GAAD,EAAe,iBAAgB,MAAO,CAAA,IAAI;GACtD,kBAAC,GAAD,EAAO,SAAS,EAAQ,CAAA;GACxB,kBAAC,GAAD,EAAO,eAAe,EAAiB,CAAA;GACtC,IAAc,kBAAC,GAAD,EAAS,WAAW,EAAmB,CAAc,EAAI,CAAA,IAAI;GAC3E,IAAa,kBAAC,GAAD,CAAS,CAAA,IAAI;GAC1B,EAAW,KAAK,GAAU,MACvB,kBAAC,GAAD;IAEI,MAAK;IACL,SAAS;IACT,QAAQ,EAAQ,IAAI,EAAQ;IAC5B,KAAK;GACR,GALQ,CAKR,CACJ;EACO;;CAGhB,OACI,kBAAC,OAAD;EAAK,WAAW,EAAG,CAAS;EACvB,UAAA,MAAU,KAAA,IAGP,kBAAC,GAAD;GAAqB,OAAM;GAAe;GACrC,UAAA;EACgB,CAAA,IAJrB;CAMH,CAAA;AAEb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PieChart.cjs","names":[],"sources":["../../src/charts/PieChart.tsx"],"sourcesContent":["import { Cell, Legend, Pie, PieChart as RPieChart, ResponsiveContainer, Tooltip } from \"recharts\";\nimport { cn } from \"@/utils/cn\";\nimport { useChartColors } from \"./use-chart-colors\";\nimport { toTooltipFormatter } from \"./types\";\nimport type { PieChartProps } from \"./types\";\n\n/**\n * PieChart — themed wrapper over recharts `PieChart`.\n *\n * Renders one slice per row, reading the numeric value from `category` and the\n * label from `index`. Each slice is colored from `colors` (cycling\n * the `--tempest-chart-*` theme tokens by default). When `donut` is set the pie gets a\n * non-zero inner radius. When `width` is provided the chart renders at that\n * fixed size without a ResponsiveContainer; otherwise it fills its parent.\n */\nexport function PieChart({\n data,\n category,\n index,\n colors,\n height = 300,\n width,\n donut = false,\n showLegend = true,\n showTooltip = true,\n valueFormatter,\n className,\n}: PieChartProps) {\n const palette = useChartColors(colors);\n const chart = (\n <RPieChart width={width} height={height}>\n {showTooltip ? <Tooltip formatter={toTooltipFormatter(valueFormatter)} /> : null}\n {showLegend ? <Legend /> : null}\n <Pie\n data={data}\n dataKey={category}\n nameKey={index}\n innerRadius={donut ? \"60%\" : 0}\n outerRadius=\"80%\"\n >\n {data.map((row, i) => (\n <Cell key={`${String(row[index])}-${i}`} fill={palette[i % palette.length]} />\n ))}\n </Pie>\n </RPieChart>\n );\n\n return (\n <div className={cn(className)}>\n {width !== undefined ? (\n chart\n ) : (\n <ResponsiveContainer width=\"100%\" height={height}>\n {chart}\n </ResponsiveContainer>\n )}\n </div>\n );\n}\n"],"mappings":"yJAeA,SAAgB,EAAS,CACrB,OACA,WACA,QACA,SACA,SAAS,IACT,QACA,QAAQ,GACR,aAAa,GACb,cAAc,GACd,iBACA,aACc,CACd,IAAM,EAAU,EAAA,eAAe,CAAM,EAC/B,GACF,EAAA,EAAA,KAAA,CAAC,EAAA,SAAD,CAAkB,QAAe,
|
|
1
|
+
{"version":3,"file":"PieChart.cjs","names":[],"sources":["../../src/charts/PieChart.tsx"],"sourcesContent":["import { Cell, Legend, Pie, PieChart as RPieChart, ResponsiveContainer, Tooltip } from \"recharts\";\nimport { cn } from \"@/utils/cn\";\nimport { useChartColors } from \"./use-chart-colors\";\nimport { toTooltipFormatter } from \"./types\";\nimport type { PieChartProps } from \"./types\";\n\n/**\n * PieChart — themed wrapper over recharts `PieChart`.\n *\n * Renders one slice per row, reading the numeric value from `category` and the\n * label from `index`. Each slice is colored from `colors` (cycling\n * the `--tempest-chart-*` theme tokens by default). When `donut` is set the pie gets a\n * non-zero inner radius. When `width` is provided the chart renders at that\n * fixed size without a ResponsiveContainer; otherwise it fills its parent.\n */\nexport function PieChart({\n data,\n category,\n index,\n colors,\n height = 300,\n width,\n donut = false,\n showLegend = true,\n showTooltip = true,\n valueFormatter,\n className,\n}: PieChartProps) {\n const palette = useChartColors(colors);\n const chart = (\n <RPieChart width={width} height={height}>\n {showTooltip ? <Tooltip formatter={toTooltipFormatter(valueFormatter)} /> : null}\n {showLegend ? <Legend /> : null}\n <Pie\n data={data}\n dataKey={category}\n nameKey={index}\n innerRadius={donut ? \"60%\" : 0}\n outerRadius=\"80%\"\n >\n {data.map((row, i) => (\n <Cell key={`${String(row[index])}-${i}`} fill={palette[i % palette.length]} />\n ))}\n </Pie>\n </RPieChart>\n );\n\n return (\n <div className={cn(className)}>\n {width !== undefined ? (\n chart\n ) : (\n <ResponsiveContainer width=\"100%\" height={height}>\n {chart}\n </ResponsiveContainer>\n )}\n </div>\n );\n}\n"],"mappings":"yJAeA,SAAgB,EAAS,CACrB,OACA,WACA,QACA,SACA,SAAS,IACT,QACA,QAAQ,GACR,aAAa,GACb,cAAc,GACd,iBACA,aACc,CACd,IAAM,EAAU,EAAA,eAAe,CAAM,EAC/B,GACF,EAAA,EAAA,KAAA,CAAC,EAAA,SAAD,CAAkB,QAAe,SAAjC,SAAA,CACK,GAAc,EAAA,EAAA,IAAA,CAAC,EAAA,QAAD,CAAS,UAAW,EAAA,mBAAmB,CAAc,CAAI,CAAA,EAAI,KAC3E,GAAa,EAAA,EAAA,IAAA,CAAC,EAAA,OAAD,CAAS,CAAA,EAAI,MAC3B,EAAA,EAAA,IAAA,CAAC,EAAA,IAAD,CACU,OACN,QAAS,EACT,QAAS,EACT,YAAa,EAAQ,MAAQ,EAC7B,YAAY,MAEX,SAAA,EAAK,KAAK,EAAK,KACZ,EAAA,EAAA,IAAA,CAAC,EAAA,KAAD,CAAyC,KAAM,EAAQ,EAAI,EAAQ,OAAU,EAAlE,GAAG,OAAO,EAAI,EAAM,EAAE,GAAG,GAAyC,CAChF,CACA,CAAA,CACE,IAGf,OACI,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,UAAW,EAAA,GAAG,CAAS,EACvB,SAAA,IAAU,IAAA,IAGP,EAAA,EAAA,IAAA,CAAC,EAAA,oBAAD,CAAqB,MAAM,OAAe,SACrC,SAAA,CACgB,CAAA,EAJrB,CAMH,CAAA,CAEb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PieChart.js","names":[],"sources":["../../src/charts/PieChart.tsx"],"sourcesContent":["import { Cell, Legend, Pie, PieChart as RPieChart, ResponsiveContainer, Tooltip } from \"recharts\";\nimport { cn } from \"@/utils/cn\";\nimport { useChartColors } from \"./use-chart-colors\";\nimport { toTooltipFormatter } from \"./types\";\nimport type { PieChartProps } from \"./types\";\n\n/**\n * PieChart — themed wrapper over recharts `PieChart`.\n *\n * Renders one slice per row, reading the numeric value from `category` and the\n * label from `index`. Each slice is colored from `colors` (cycling\n * the `--tempest-chart-*` theme tokens by default). When `donut` is set the pie gets a\n * non-zero inner radius. When `width` is provided the chart renders at that\n * fixed size without a ResponsiveContainer; otherwise it fills its parent.\n */\nexport function PieChart({\n data,\n category,\n index,\n colors,\n height = 300,\n width,\n donut = false,\n showLegend = true,\n showTooltip = true,\n valueFormatter,\n className,\n}: PieChartProps) {\n const palette = useChartColors(colors);\n const chart = (\n <RPieChart width={width} height={height}>\n {showTooltip ? <Tooltip formatter={toTooltipFormatter(valueFormatter)} /> : null}\n {showLegend ? <Legend /> : null}\n <Pie\n data={data}\n dataKey={category}\n nameKey={index}\n innerRadius={donut ? \"60%\" : 0}\n outerRadius=\"80%\"\n >\n {data.map((row, i) => (\n <Cell key={`${String(row[index])}-${i}`} fill={palette[i % palette.length]} />\n ))}\n </Pie>\n </RPieChart>\n );\n\n return (\n <div className={cn(className)}>\n {width !== undefined ? (\n chart\n ) : (\n <ResponsiveContainer width=\"100%\" height={height}>\n {chart}\n </ResponsiveContainer>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;AAeA,SAAgB,EAAS,EACrB,SACA,aACA,UACA,WACA,YAAS,KACT,UACA,WAAQ,IACR,gBAAa,IACb,iBAAc,IACd,mBACA,gBACc;CACd,IAAM,IAAU,EAAe,CAAM,GAC/B,IACF,kBAAC,GAAD;EAAkB;EAAe;
|
|
1
|
+
{"version":3,"file":"PieChart.js","names":[],"sources":["../../src/charts/PieChart.tsx"],"sourcesContent":["import { Cell, Legend, Pie, PieChart as RPieChart, ResponsiveContainer, Tooltip } from \"recharts\";\nimport { cn } from \"@/utils/cn\";\nimport { useChartColors } from \"./use-chart-colors\";\nimport { toTooltipFormatter } from \"./types\";\nimport type { PieChartProps } from \"./types\";\n\n/**\n * PieChart — themed wrapper over recharts `PieChart`.\n *\n * Renders one slice per row, reading the numeric value from `category` and the\n * label from `index`. Each slice is colored from `colors` (cycling\n * the `--tempest-chart-*` theme tokens by default). When `donut` is set the pie gets a\n * non-zero inner radius. When `width` is provided the chart renders at that\n * fixed size without a ResponsiveContainer; otherwise it fills its parent.\n */\nexport function PieChart({\n data,\n category,\n index,\n colors,\n height = 300,\n width,\n donut = false,\n showLegend = true,\n showTooltip = true,\n valueFormatter,\n className,\n}: PieChartProps) {\n const palette = useChartColors(colors);\n const chart = (\n <RPieChart width={width} height={height}>\n {showTooltip ? <Tooltip formatter={toTooltipFormatter(valueFormatter)} /> : null}\n {showLegend ? <Legend /> : null}\n <Pie\n data={data}\n dataKey={category}\n nameKey={index}\n innerRadius={donut ? \"60%\" : 0}\n outerRadius=\"80%\"\n >\n {data.map((row, i) => (\n <Cell key={`${String(row[index])}-${i}`} fill={palette[i % palette.length]} />\n ))}\n </Pie>\n </RPieChart>\n );\n\n return (\n <div className={cn(className)}>\n {width !== undefined ? (\n chart\n ) : (\n <ResponsiveContainer width=\"100%\" height={height}>\n {chart}\n </ResponsiveContainer>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;AAeA,SAAgB,EAAS,EACrB,SACA,aACA,UACA,WACA,YAAS,KACT,UACA,WAAQ,IACR,gBAAa,IACb,iBAAc,IACd,mBACA,gBACc;CACd,IAAM,IAAU,EAAe,CAAM,GAC/B,IACF,kBAAC,GAAD;EAAkB;EAAe;EAAjC,UAAA;GACK,IAAc,kBAAC,GAAD,EAAS,WAAW,EAAmB,CAAc,EAAI,CAAA,IAAI;GAC3E,IAAa,kBAAC,GAAD,CAAS,CAAA,IAAI;GAC3B,kBAAC,GAAD;IACU;IACN,SAAS;IACT,SAAS;IACT,aAAa,IAAQ,QAAQ;IAC7B,aAAY;IAEX,UAAA,EAAK,KAAK,GAAK,MACZ,kBAAC,GAAD,EAAyC,MAAM,EAAQ,IAAI,EAAQ,QAAU,GAAlE,GAAG,OAAO,EAAI,EAAM,EAAE,GAAG,GAAyC,CAChF;GACA,CAAA;EACE;;CAGf,OACI,kBAAC,OAAD;EAAK,WAAW,EAAG,CAAS;EACvB,UAAA,MAAU,KAAA,IAGP,kBAAC,GAAD;GAAqB,OAAM;GAAe;GACrC,UAAA;EACgB,CAAA,IAJrB;CAMH,CAAA;AAEb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadarChart.cjs","names":[],"sources":["../../src/charts/RadarChart.tsx"],"sourcesContent":["import {\n Legend,\n PolarAngleAxis,\n PolarGrid,\n PolarRadiusAxis,\n RadarChart as RRadarChart,\n Radar,\n ResponsiveContainer,\n Tooltip,\n} from \"recharts\";\nimport { cn } from \"@/utils/cn\";\nimport { useChartColors } from \"./use-chart-colors\";\nimport { toTooltipFormatter } from \"./types\";\nimport type { CartesianChartProps } from \"./types\";\n\n/**\n * RadarChart — themed wrapper over recharts `RadarChart`.\n *\n * Plots one radar polygon per entry in `categories`, colored from `colors`\n * (cycling the `--tempest-chart-*` theme tokens by default). `index` drives the angle\n * axis. When `width` is provided the chart renders at that fixed size without a\n * ResponsiveContainer; otherwise it fills its parent.\n */\nexport function RadarChart({\n data,\n index,\n categories,\n colors,\n height = 300,\n width,\n showLegend = true,\n showTooltip = true,\n valueFormatter,\n className,\n}: CartesianChartProps) {\n const palette = useChartColors(colors);\n const chart = (\n <RRadarChart data={data} width={width} height={height}>\n <PolarGrid />\n <PolarAngleAxis dataKey={index} />\n <PolarRadiusAxis />\n {showTooltip ? <Tooltip formatter={toTooltipFormatter(valueFormatter)} /> : null}\n {showLegend ? <Legend /> : null}\n {categories.map((category, i) => {\n const color = palette[i % palette.length];\n return (\n <Radar\n key={category}\n dataKey={category}\n stroke={color}\n fill={color}\n fillOpacity={0.3}\n />\n );\n })}\n </RRadarChart>\n );\n\n return (\n <div className={cn(className)}>\n {width !== undefined ? (\n chart\n ) : (\n <ResponsiveContainer width=\"100%\" height={height}>\n {chart}\n </ResponsiveContainer>\n )}\n </div>\n );\n}\n"],"mappings":"yJAuBA,SAAgB,EAAW,CACvB,OACA,QACA,aACA,SACA,SAAS,IACT,QACA,aAAa,GACb,cAAc,GACd,iBACA,aACoB,CACpB,IAAM,EAAU,EAAA,eAAe,CAAM,EAC/B,GACF,EAAA,EAAA,KAAA,CAAC,EAAA,WAAD,CAAmB,OAAa,QAAe,
|
|
1
|
+
{"version":3,"file":"RadarChart.cjs","names":[],"sources":["../../src/charts/RadarChart.tsx"],"sourcesContent":["import {\n Legend,\n PolarAngleAxis,\n PolarGrid,\n PolarRadiusAxis,\n RadarChart as RRadarChart,\n Radar,\n ResponsiveContainer,\n Tooltip,\n} from \"recharts\";\nimport { cn } from \"@/utils/cn\";\nimport { useChartColors } from \"./use-chart-colors\";\nimport { toTooltipFormatter } from \"./types\";\nimport type { CartesianChartProps } from \"./types\";\n\n/**\n * RadarChart — themed wrapper over recharts `RadarChart`.\n *\n * Plots one radar polygon per entry in `categories`, colored from `colors`\n * (cycling the `--tempest-chart-*` theme tokens by default). `index` drives the angle\n * axis. When `width` is provided the chart renders at that fixed size without a\n * ResponsiveContainer; otherwise it fills its parent.\n */\nexport function RadarChart({\n data,\n index,\n categories,\n colors,\n height = 300,\n width,\n showLegend = true,\n showTooltip = true,\n valueFormatter,\n className,\n}: CartesianChartProps) {\n const palette = useChartColors(colors);\n const chart = (\n <RRadarChart data={data} width={width} height={height}>\n <PolarGrid />\n <PolarAngleAxis dataKey={index} />\n <PolarRadiusAxis />\n {showTooltip ? <Tooltip formatter={toTooltipFormatter(valueFormatter)} /> : null}\n {showLegend ? <Legend /> : null}\n {categories.map((category, i) => {\n const color = palette[i % palette.length];\n return (\n <Radar\n key={category}\n dataKey={category}\n stroke={color}\n fill={color}\n fillOpacity={0.3}\n />\n );\n })}\n </RRadarChart>\n );\n\n return (\n <div className={cn(className)}>\n {width !== undefined ? (\n chart\n ) : (\n <ResponsiveContainer width=\"100%\" height={height}>\n {chart}\n </ResponsiveContainer>\n )}\n </div>\n );\n}\n"],"mappings":"yJAuBA,SAAgB,EAAW,CACvB,OACA,QACA,aACA,SACA,SAAS,IACT,QACA,aAAa,GACb,cAAc,GACd,iBACA,aACoB,CACpB,IAAM,EAAU,EAAA,eAAe,CAAM,EAC/B,GACF,EAAA,EAAA,KAAA,CAAC,EAAA,WAAD,CAAmB,OAAa,QAAe,SAA/C,SAAA,EACI,EAAA,EAAA,IAAA,CAAC,EAAA,UAAD,CAAY,CAAA,GACZ,EAAA,EAAA,IAAA,CAAC,EAAA,eAAD,CAAgB,QAAS,CAAQ,CAAA,GACjC,EAAA,EAAA,IAAA,CAAC,EAAA,gBAAD,CAAkB,CAAA,EACjB,GAAc,EAAA,EAAA,IAAA,CAAC,EAAA,QAAD,CAAS,UAAW,EAAA,mBAAmB,CAAc,CAAI,CAAA,EAAI,KAC3E,GAAa,EAAA,EAAA,IAAA,CAAC,EAAA,OAAD,CAAS,CAAA,EAAI,KAC1B,EAAW,KAAK,EAAU,IAAM,CAC7B,IAAM,EAAQ,EAAQ,EAAI,EAAQ,QAClC,OACI,EAAA,EAAA,IAAA,CAAC,EAAA,MAAD,CAEI,QAAS,EACT,OAAQ,EACR,KAAM,EACN,YAAa,EAChB,EALQ,CAKR,CAET,CAAC,CACQ,IAGjB,OACI,EAAA,EAAA,IAAA,CAAC,MAAD,CAAK,UAAW,EAAA,GAAG,CAAS,EACvB,SAAA,IAAU,IAAA,IAGP,EAAA,EAAA,IAAA,CAAC,EAAA,oBAAD,CAAqB,MAAM,OAAe,SACrC,SAAA,CACgB,CAAA,EAJrB,CAMH,CAAA,CAEb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RadarChart.js","names":[],"sources":["../../src/charts/RadarChart.tsx"],"sourcesContent":["import {\n Legend,\n PolarAngleAxis,\n PolarGrid,\n PolarRadiusAxis,\n RadarChart as RRadarChart,\n Radar,\n ResponsiveContainer,\n Tooltip,\n} from \"recharts\";\nimport { cn } from \"@/utils/cn\";\nimport { useChartColors } from \"./use-chart-colors\";\nimport { toTooltipFormatter } from \"./types\";\nimport type { CartesianChartProps } from \"./types\";\n\n/**\n * RadarChart — themed wrapper over recharts `RadarChart`.\n *\n * Plots one radar polygon per entry in `categories`, colored from `colors`\n * (cycling the `--tempest-chart-*` theme tokens by default). `index` drives the angle\n * axis. When `width` is provided the chart renders at that fixed size without a\n * ResponsiveContainer; otherwise it fills its parent.\n */\nexport function RadarChart({\n data,\n index,\n categories,\n colors,\n height = 300,\n width,\n showLegend = true,\n showTooltip = true,\n valueFormatter,\n className,\n}: CartesianChartProps) {\n const palette = useChartColors(colors);\n const chart = (\n <RRadarChart data={data} width={width} height={height}>\n <PolarGrid />\n <PolarAngleAxis dataKey={index} />\n <PolarRadiusAxis />\n {showTooltip ? <Tooltip formatter={toTooltipFormatter(valueFormatter)} /> : null}\n {showLegend ? <Legend /> : null}\n {categories.map((category, i) => {\n const color = palette[i % palette.length];\n return (\n <Radar\n key={category}\n dataKey={category}\n stroke={color}\n fill={color}\n fillOpacity={0.3}\n />\n );\n })}\n </RRadarChart>\n );\n\n return (\n <div className={cn(className)}>\n {width !== undefined ? (\n chart\n ) : (\n <ResponsiveContainer width=\"100%\" height={height}>\n {chart}\n </ResponsiveContainer>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;AAuBA,SAAgB,EAAW,EACvB,SACA,UACA,eACA,WACA,YAAS,KACT,UACA,gBAAa,IACb,iBAAc,IACd,mBACA,gBACoB;CACpB,IAAM,IAAU,EAAe,CAAM,GAC/B,IACF,kBAAC,GAAD;EAAmB;EAAa;EAAe;
|
|
1
|
+
{"version":3,"file":"RadarChart.js","names":[],"sources":["../../src/charts/RadarChart.tsx"],"sourcesContent":["import {\n Legend,\n PolarAngleAxis,\n PolarGrid,\n PolarRadiusAxis,\n RadarChart as RRadarChart,\n Radar,\n ResponsiveContainer,\n Tooltip,\n} from \"recharts\";\nimport { cn } from \"@/utils/cn\";\nimport { useChartColors } from \"./use-chart-colors\";\nimport { toTooltipFormatter } from \"./types\";\nimport type { CartesianChartProps } from \"./types\";\n\n/**\n * RadarChart — themed wrapper over recharts `RadarChart`.\n *\n * Plots one radar polygon per entry in `categories`, colored from `colors`\n * (cycling the `--tempest-chart-*` theme tokens by default). `index` drives the angle\n * axis. When `width` is provided the chart renders at that fixed size without a\n * ResponsiveContainer; otherwise it fills its parent.\n */\nexport function RadarChart({\n data,\n index,\n categories,\n colors,\n height = 300,\n width,\n showLegend = true,\n showTooltip = true,\n valueFormatter,\n className,\n}: CartesianChartProps) {\n const palette = useChartColors(colors);\n const chart = (\n <RRadarChart data={data} width={width} height={height}>\n <PolarGrid />\n <PolarAngleAxis dataKey={index} />\n <PolarRadiusAxis />\n {showTooltip ? <Tooltip formatter={toTooltipFormatter(valueFormatter)} /> : null}\n {showLegend ? <Legend /> : null}\n {categories.map((category, i) => {\n const color = palette[i % palette.length];\n return (\n <Radar\n key={category}\n dataKey={category}\n stroke={color}\n fill={color}\n fillOpacity={0.3}\n />\n );\n })}\n </RRadarChart>\n );\n\n return (\n <div className={cn(className)}>\n {width !== undefined ? (\n chart\n ) : (\n <ResponsiveContainer width=\"100%\" height={height}>\n {chart}\n </ResponsiveContainer>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;AAuBA,SAAgB,EAAW,EACvB,SACA,UACA,eACA,WACA,YAAS,KACT,UACA,gBAAa,IACb,iBAAc,IACd,mBACA,gBACoB;CACpB,IAAM,IAAU,EAAe,CAAM,GAC/B,IACF,kBAAC,GAAD;EAAmB;EAAa;EAAe;EAA/C,UAAA;GACI,kBAAC,GAAD,CAAY,CAAA;GACZ,kBAAC,GAAD,EAAgB,SAAS,EAAQ,CAAA;GACjC,kBAAC,GAAD,CAAkB,CAAA;GACjB,IAAc,kBAAC,GAAD,EAAS,WAAW,EAAmB,CAAc,EAAI,CAAA,IAAI;GAC3E,IAAa,kBAAC,GAAD,CAAS,CAAA,IAAI;GAC1B,EAAW,KAAK,GAAU,MAAM;IAC7B,IAAM,IAAQ,EAAQ,IAAI,EAAQ;IAClC,OACI,kBAAC,GAAD;KAEI,SAAS;KACT,QAAQ;KACR,MAAM;KACN,aAAa;IAChB,GALQ,CAKR;GAET,CAAC;EACQ;;CAGjB,OACI,kBAAC,OAAD;EAAK,WAAW,EAAG,CAAS;EACvB,UAAA,MAAU,KAAA,IAGP,kBAAC,GAAD;GAAqB,OAAM;GAAe;GACrC,UAAA;EACgB,CAAA,IAJrB;CAMH,CAAA;AAEb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-chart-colors.cjs","names":[],"sources":["../../src/charts/use-chart-colors.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\nimport { resolveChartColors } from \"./palette\";\n\n/**\n * Theme-aware series colors for a chart.\n *\n * Resolves the `--tempest-chart-*` tokens on mount and again whenever the theme\n * attribute flips, so switching to dark re-colors the series instead of leaving\n * light-theme colors on a dark canvas. Passing `explicit` short-circuits the\n * whole thing — an explicit `colors` prop always wins and no observer is set up.\n *\n * @param explicit - Colors passed by the caller. When present, returned as-is.\n * @param element - Element to resolve tokens against. Default `<html>`.\n * @returns Colors in cycle order.\n *\n * @example\n * ```tsx\n * function Sales({ data }: { data: ChartDatum[] }) {\n * const colors = useChartColors();\n * return <BarChart data={data} colors={colors} />;\n * }\n * ```\n */\nexport function useChartColors(explicit?: string[], element?: Element | null): string[] {\n const [resolved, setResolved] = useState<string[]>(() =>\n explicit ? explicit : resolveChartColors(element),\n );\n\n useEffect(() => {\n if (explicit) return;\n if (typeof window === \"undefined\" || typeof MutationObserver === \"undefined\") return;\n\n const target = element ?? document.documentElement;\n if (!target) return;\n\n const sync = (): void => setResolved(resolveChartColors(target));\n sync();\n\n const roots = new Set<Element>([target]);\n const documentRoot = target.ownerDocument?.documentElement;\n if (documentRoot) roots.add(documentRoot);\n\n const observer = new MutationObserver(sync);\n for (const root of roots) {\n observer.observe(root, {\n attributes: true,\n attributeFilter: [\"data-tempest-theme\", \"class\", \"style\"],\n });\n }\n\n return () => observer.disconnect();\n }, [explicit, element]);\n\n return explicit ?? resolved;\n}\n"],"mappings":"wDAwBA,SAAgB,EAAe,EAAqB,EAAoC,CACpF,GAAM,CAAC,EAAU,IAAA,
|
|
1
|
+
{"version":3,"file":"use-chart-colors.cjs","names":[],"sources":["../../src/charts/use-chart-colors.ts"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\nimport { resolveChartColors } from \"./palette\";\n\n/**\n * Theme-aware series colors for a chart.\n *\n * Resolves the `--tempest-chart-*` tokens on mount and again whenever the theme\n * attribute flips, so switching to dark re-colors the series instead of leaving\n * light-theme colors on a dark canvas. Passing `explicit` short-circuits the\n * whole thing — an explicit `colors` prop always wins and no observer is set up.\n *\n * @param explicit - Colors passed by the caller. When present, returned as-is.\n * @param element - Element to resolve tokens against. Default `<html>`.\n * @returns Colors in cycle order.\n *\n * @example\n * ```tsx\n * function Sales({ data }: { data: ChartDatum[] }) {\n * const colors = useChartColors();\n * return <BarChart data={data} colors={colors} />;\n * }\n * ```\n */\nexport function useChartColors(explicit?: string[], element?: Element | null): string[] {\n const [resolved, setResolved] = useState<string[]>(() =>\n explicit ? explicit : resolveChartColors(element),\n );\n\n useEffect(() => {\n if (explicit) return;\n if (typeof window === \"undefined\" || typeof MutationObserver === \"undefined\") return;\n\n const target = element ?? document.documentElement;\n if (!target) return;\n\n const sync = (): void => setResolved(resolveChartColors(target));\n sync();\n\n const roots = new Set<Element>([target]);\n const documentRoot = target.ownerDocument?.documentElement;\n if (documentRoot) roots.add(documentRoot);\n\n const observer = new MutationObserver(sync);\n for (const root of roots) {\n observer.observe(root, {\n attributes: true,\n attributeFilter: [\"data-tempest-theme\", \"class\", \"style\"],\n });\n }\n\n return () => observer.disconnect();\n }, [explicit, element]);\n\n return explicit ?? resolved;\n}\n"],"mappings":"wDAwBA,SAAgB,EAAe,EAAqB,EAAoC,CACpF,GAAM,CAAC,EAAU,IAAA,EAAe,EAAA,SAAA,KAC5B,GAAsB,EAAA,mBAAmB,CAAO,CACpD,EA2BA,OAzBA,EAAA,EAAA,UAAA,KAAgB,CAEZ,GADI,GACA,OAAO,OAAW,KAAe,OAAO,iBAAqB,IAAa,OAE9E,IAAM,EAAS,GAAW,SAAS,gBACnC,GAAI,CAAC,EAAQ,OAEb,IAAM,MAAmB,EAAY,EAAA,mBAAmB,CAAM,CAAC,EAC/D,EAAK,EAEL,IAAM,EAAQ,IAAI,IAAa,CAAC,CAAM,CAAC,EACjC,EAAe,EAAO,eAAe,gBACvC,GAAc,EAAM,IAAI,CAAY,EAExC,IAAM,EAAW,IAAI,iBAAiB,CAAI,EAC1C,IAAK,IAAM,KAAQ,EACf,EAAS,QAAQ,EAAM,CACnB,WAAY,GACZ,gBAAiB,CAAC,qBAAsB,QAAS,OAAO,CAC5D,CAAC,EAGL,UAAa,EAAS,WAAW,CACrC,EAAG,CAAC,EAAU,CAAO,CAAC,EAEf,GAAY,CACvB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AIChat.cjs","names":[],"sources":["../../../src/components/AIChat/AIChat.tsx"],"sourcesContent":["/**\n * @tempest-limits file-lines, props-count, function-lines — the widest surface in\n * the SDK on purpose: it is a whole chat page, and its 25 props are four groups —\n * the transcript (messages, votes, pending, showSystem), the turn actions an app has\n * to own (onSend, onStop, onRegenerate, onEditSubmit, onFeedback, onRetry,\n * onSendError), render slots (renderAvatar, renderContent, header, emptyState,\n * suggestions, composerActions, composerFooter) and composer settings (composerRef,\n * composerDisabled, maxRows, placeholder, locale, defaultReasoningOpen,\n * showLineNumbers). The parts already are separate components — AIChatTurn and\n * AIChatComposer are exported — and this is the assembly whose entire job is to\n * accept the union of their configuration.\n */\nimport { ArrowDown } from \"lucide-react\";\nimport {\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n type Ref,\n} from \"react\";\n\nimport { useAnnounce } from \"@/hooks/use-announce\";\nimport { cn } from \"@/utils/cn\";\n\nimport { EmptyState } from \"../EmptyState\";\nimport {\n aiChatStrings,\n isGenerating,\n lastAssistantId,\n tailSignature,\n visibleTurns,\n type AIChatMessage,\n type AIChatVote,\n} from \"./ai-chat-turns\";\nimport { AIChatComposer, type AIChatComposerHandle } from \"./AIChatComposer\";\nimport { AIChatTurn } from \"./AIChatTurn\";\nimport styles from \"./AIChat.module.css\";\n\n/** DOM attributes this component redefines. */\ntype OverriddenDomProps = \"children\" | \"onSubmit\";\n\nexport interface AIChatProps extends Omit<HTMLAttributes<HTMLDivElement>, OverriddenDomProps> {\n /** The transcript, **oldest first**. Never reordered by the component. */\n messages: readonly AIChatMessage[];\n /** Renders the composer when given. Receives the trimmed prompt. */\n onSend?: (text: string) => void | Promise<void>;\n /** Abort the turn in flight. Shows the stop button while generating. */\n onStop?: () => void;\n /** Ask again for the newest assistant turn. */\n onRegenerate?: (message: AIChatMessage) => void;\n /** Re-submit an edited user turn. The app decides what to drop after it. */\n onEditSubmit?: (message: AIChatMessage, text: string) => void | Promise<void>;\n /** Rating on an assistant turn. */\n onFeedback?: (message: AIChatMessage, vote: AIChatVote) => void;\n /** Retry a turn that carries an `error`. */\n onRetry?: (message: AIChatMessage) => void;\n /**\n * The request is out and nothing has arrived yet.\n *\n * Distinct from a turn with `streaming: true`: apps that only push a message\n * once the first token lands need somewhere to say \"we asked\", and without it the\n * screen is frozen for however long the model takes to start.\n */\n pending?: boolean;\n /** Prompts offered on an empty transcript. Clicking one sends it. */\n suggestions?: readonly string[];\n /** Avatar for a turn — an `<Avatar>`, an `<Icon>`, a logo. */\n renderAvatar?: (message: AIChatMessage) => ReactNode;\n /** Render a body yourself — a tool-call card, a chart, a citation list. */\n renderContent?: (message: AIChatMessage) => ReactNode;\n /** Ratings to show as pressed, by message id. Omit to keep them local. */\n votes?: Readonly<Record<string, AIChatVote>>;\n /** Rendered above the transcript, inside the panel. */\n header?: ReactNode;\n /** Shown when there are no turns and no suggestions. */\n emptyState?: ReactNode;\n /** Show `\"system\"` turns. Default `false`. */\n showSystem?: boolean;\n /** Reasoning blocks start expanded. Default `false`. */\n defaultReasoningOpen?: boolean;\n /** Show line numbers in fenced code. Default `false`. */\n showLineNumbers?: boolean;\n /** Locale for labels. Default `\"pt-BR\"`. */\n locale?: \"pt-BR\" | \"en\";\n /** Placeholder for the composer. */\n placeholder?: string;\n /** Extra controls inside the composer, before the send button. */\n composerActions?: ReactNode;\n /**\n * Reach the composer imperatively — `focus()`, `getValue()`, `setValue()`.\n *\n * What makes dictation (or a slash-command menu, or \"edit and resend\") possible\n * without this component knowing anything about them: pair it with\n * `composerActions` and the button you put in the composer can write into the\n * field. Speech recognition is **not** wired in here on purpose — it would make\n * every consumer of `AIChat` pay for an API that streams audio to a third party.\n */\n composerRef?: Ref<AIChatComposerHandle>;\n /** Under the composer field — token count, model name, a disclaimer. */\n composerFooter?: ReactNode;\n /** Disable the composer — no credits, conversation archived, offline. */\n composerDisabled?: boolean;\n /** Largest height the composer grows to, in lines. Default 8. */\n maxRows?: number;\n /**\n * Called when `onSend` **or** `onEditSubmit` rejects. The draft stays in the field\n * either way.\n */\n onSendError?: (error: unknown) => void;\n}\n\n/** How close to the bottom still counts as \"reading the newest turn\", in pixels. */\nconst BOTTOM_SLACK = 48;\n\n/**\n * A conversation with a model: role-based turns, Markdown answers, a reasoning\n * block, a streaming caret, per-turn actions and a composer that turns into a stop\n * button while a turn is generating.\n *\n * This is the shape ChatGPT, Claude and DeepSeek converged on, and it is a different\n * component from {@link Chat}, not a variant of it. A human thread is addressed by\n * author and cares about delivery state; a model transcript is addressed by role,\n * has no delivery state at all, and needs three things a human thread never does —\n * partial output, reasoning separate from the answer, and re-asking.\n *\n * Presentational and controlled, like the rest of the SDK: it takes a list and emits\n * intent (`onSend`, `onStop`, `onRegenerate`, `onEditSubmit`, `onFeedback`). The\n * transport stays with the app, because \"how do I stream from my backend\" has a\n * different answer per provider — the SDK's `createEventStream` covers SSE, `fetch`\n * with a `ReadableStream` covers the rest, and either way the app owns the\n * `AbortController` it hands to `onStop`.\n *\n * @example\n * <AIChat\n * messages={turns}\n * pending={pending}\n * onSend={(text) => ask(text)}\n * onStop={() => controller.current?.abort()}\n * onRegenerate={(turn) => reask(turn)}\n * onFeedback={(turn, vote) => track(\"answer_rated\", { id: turn.id, vote })}\n * suggestions={[\"Resuma o último relatório\", \"Quais pedidos atrasaram?\"]}\n * />\n */\nexport function AIChat({\n messages,\n onSend,\n onStop,\n onRegenerate,\n onEditSubmit,\n onFeedback,\n onRetry,\n pending = false,\n suggestions = [],\n renderAvatar,\n renderContent,\n votes,\n header,\n emptyState,\n showSystem = false,\n defaultReasoningOpen = false,\n showLineNumbers = false,\n locale = \"pt-BR\",\n placeholder,\n composerActions,\n composerRef,\n composerFooter,\n composerDisabled,\n maxRows,\n onSendError,\n className,\n ...rest\n}: AIChatProps) {\n const strings = aiChatStrings(locale);\n const turns = visibleTurns({ messages, showSystem });\n const generating = pending || isGenerating(messages);\n const newestAssistant = lastAssistantId(messages);\n const signature = tailSignature(messages);\n\n const composer = useRef<AIChatComposerHandle | null>(null);\n const thread = useRef<HTMLDivElement | null>(null);\n const stuckToBottom = useRef(true);\n const wasGenerating = useRef(false);\n const [atBottom, setAtBottom] = useState(true);\n const announce = useAnnounce();\n\n /**\n * Remember whether the reader is at the bottom, before the next tokens land.\n *\n * A transcript that always scrolls to the newest text yanks somebody out of the\n * answer they were re-reading — and with a streaming answer that would happen\n * dozens of times per second. So the jump only happens when they were already at\n * the bottom. The slack covers a partially visible last line.\n */\n const trackPosition = (): void => {\n const node = thread.current;\n if (!node) return;\n const next = node.scrollHeight - node.scrollTop - node.clientHeight < BOTTOM_SLACK;\n stuckToBottom.current = next;\n setAtBottom(next);\n };\n\n const jumpToLatest = (): void => {\n const node = thread.current;\n if (!node) return;\n stuckToBottom.current = true;\n setAtBottom(true);\n node.scrollTop = node.scrollHeight;\n };\n\n useLayoutEffect(() => {\n const node = thread.current;\n if (!node || !stuckToBottom.current) return;\n node.scrollTop = node.scrollHeight;\n }, [signature, pending]);\n\n useEffect(() => {\n const node = thread.current;\n if (!node) return;\n node.scrollTop = node.scrollHeight;\n // Mount lands on the newest turn; from then on `trackPosition` decides.\n }, []);\n\n /**\n * Announce the start and the end of a generation, and nothing in between.\n *\n * The transcript is a `role=\"log\"` **without** `aria-live`: a live region over\n * streaming text makes a screen reader read the answer again on every token,\n * which is unusable. The two moments that matter are announced here instead —\n * through the shared `useAnnounce` region rather than a private one, so a page\n * holding a chat plus a table plus toasts still has exactly one live region per\n * politeness — and the finished answer is read from the log at the reader's own\n * pace.\n */\n useEffect(() => {\n if (generating) {\n announce(strings.generating);\n wasGenerating.current = true;\n return;\n }\n if (wasGenerating.current) {\n announce(strings.done);\n wasGenerating.current = false;\n }\n }, [generating, strings.generating, strings.done, announce]);\n\n const showSuggestions = turns.length === 0 && suggestions.length > 0 && onSend !== undefined;\n const detached = !atBottom && turns.length > 0;\n\n return (\n <div className={cn(styles.panel, className)} {...rest}>\n {header && <header className={styles.header}>{header}</header>}\n\n <div className={styles.threadWrapper}>\n <div\n ref={thread}\n className={styles.thread}\n onScroll={trackPosition}\n role=\"log\"\n tabIndex={0}\n aria-label={strings.thread}\n >\n {turns.length === 0 && !showSuggestions\n ? (emptyState ?? (\n <EmptyState title={strings.empty} description={strings.emptyHint} />\n ))\n : turns.map((message) => (\n <AIChatTurn\n key={message.id}\n message={message}\n locale={locale}\n canRegenerate={\n message.id === newestAssistant && message.streaming !== true\n }\n onRegenerate={onRegenerate}\n onFeedback={onFeedback}\n onEditSubmit={onEditSubmit}\n onEditError={onSendError}\n onRetry={onRetry}\n renderAvatar={renderAvatar}\n renderContent={renderContent}\n vote={votes?.[message.id]}\n defaultReasoningOpen={defaultReasoningOpen}\n showLineNumbers={showLineNumbers}\n />\n ))}\n\n {showSuggestions && (\n <div className={styles.suggestions}>\n <p className={styles.suggestionsTitle}>{strings.emptyHint}</p>\n {suggestions.map((suggestion) => (\n <button\n key={suggestion}\n type=\"button\"\n className={styles.suggestion}\n onClick={() => void onSend?.(suggestion)}\n >\n {suggestion}\n </button>\n ))}\n </div>\n )}\n\n {pending && !isGenerating(messages) && (\n <p className={styles.thinking}>\n <span className={styles.dots} aria-hidden=\"true\">\n <span />\n <span />\n <span />\n </span>\n {strings.thinking}\n </p>\n )}\n </div>\n\n {detached && (\n <button\n type=\"button\"\n className={styles.jump}\n onClick={jumpToLatest}\n aria-label={strings.jumpToLatest}\n title={strings.jumpToLatest}\n >\n <ArrowDown size={16} aria-hidden />\n </button>\n )}\n </div>\n\n {onSend && (\n <AIChatComposer\n ref={composerRef ?? composer}\n onSend={onSend}\n onStop={onStop}\n generating={generating}\n locale={locale}\n placeholder={placeholder}\n actions={composerActions}\n footer={composerFooter}\n disabled={composerDisabled}\n maxRows={maxRows}\n onError={onSendError}\n />\n )}\n </div>\n );\n}\n"],"mappings":"4UAkHA,IAAM,EAAe,GA+BrB,SAAgB,EAAO,CACnB,WACA,SACA,SACA,eACA,eACA,aACA,UACA,UAAU,GACV,cAAc,CAAC,EACf,eACA,gBACA,QACA,SACA,aACA,aAAa,GACb,uBAAuB,GACvB,kBAAkB,GAClB,SAAS,QACT,cACA,kBACA,cACA,iBACA,mBACA,UACA,cACA,YACA,GAAG,GACS,CACZ,IAAM,EAAU,EAAA,cAAc,CAAM,EAC9B,EAAQ,EAAA,aAAa,CAAE,WAAU,YAAW,CAAC,EAC7C,EAAa,GAAW,EAAA,aAAa,CAAQ,EAC7C,EAAkB,EAAA,gBAAgB,CAAQ,EAC1C,EAAY,EAAA,cAAc,CAAQ,EAElC,GAAA,EAAA,EAAA,OAAA,CAA+C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,IACL,EAAQ,QACV,GAEN,IAEJ,IACG,EAAA,EAAA,IAAA,CAAC,SAAD,CACI,KAAK,SACL,UAAW,EAAA,QAAO,KAClB,QAAS,EACT,aAAY,EAAQ,aACpB,MAAO,EAAQ,uBAEf,EAAA,EAAA,IAAA,CAAC,EAAA,UAAD,CAAW,KAAM,GAAI,cAAA,EAAa,CAAA,CAC9B,CAAA,CAEX,IAEJ,IACG,EAAA,EAAA,IAAA,CAAC,EAAA,eAAD,CACI,IAAK,GAAe,EACZ,SACA,SACI,aACJ,SACK,cACb,QAAS,EACT,OAAQ,EACR,SAAU,EACD,UACT,QAAS,CACZ,CAAA,CAEJ,GAEb"}
|
|
1
|
+
{"version":3,"file":"AIChat.cjs","names":[],"sources":["../../../src/components/AIChat/AIChat.tsx"],"sourcesContent":["/**\n * @tempest-limits file-lines, props-count, function-lines — the widest surface in\n * the SDK on purpose: it is a whole chat page, and its 25 props are four groups —\n * the transcript (messages, votes, pending, showSystem), the turn actions an app has\n * to own (onSend, onStop, onRegenerate, onEditSubmit, onFeedback, onRetry,\n * onSendError), render slots (renderAvatar, renderContent, header, emptyState,\n * suggestions, composerActions, composerFooter) and composer settings (composerRef,\n * composerDisabled, maxRows, placeholder, locale, defaultReasoningOpen,\n * showLineNumbers). The parts already are separate components — AIChatTurn and\n * AIChatComposer are exported — and this is the assembly whose entire job is to\n * accept the union of their configuration.\n */\nimport { ArrowDown } from \"lucide-react\";\nimport {\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n type Ref,\n} from \"react\";\n\nimport { useAnnounce } from \"@/hooks/use-announce\";\nimport { cn } from \"@/utils/cn\";\n\nimport { EmptyState } from \"../EmptyState\";\nimport {\n aiChatStrings,\n isGenerating,\n lastAssistantId,\n tailSignature,\n visibleTurns,\n type AIChatMessage,\n type AIChatVote,\n} from \"./ai-chat-turns\";\nimport { AIChatComposer, type AIChatComposerHandle } from \"./AIChatComposer\";\nimport { AIChatTurn } from \"./AIChatTurn\";\nimport styles from \"./AIChat.module.css\";\n\n/** DOM attributes this component redefines. */\ntype OverriddenDomProps = \"children\" | \"onSubmit\";\n\nexport interface AIChatProps extends Omit<HTMLAttributes<HTMLDivElement>, OverriddenDomProps> {\n /** The transcript, **oldest first**. Never reordered by the component. */\n messages: readonly AIChatMessage[];\n /** Renders the composer when given. Receives the trimmed prompt. */\n onSend?: (text: string) => void | Promise<void>;\n /** Abort the turn in flight. Shows the stop button while generating. */\n onStop?: () => void;\n /** Ask again for the newest assistant turn. */\n onRegenerate?: (message: AIChatMessage) => void;\n /** Re-submit an edited user turn. The app decides what to drop after it. */\n onEditSubmit?: (message: AIChatMessage, text: string) => void | Promise<void>;\n /** Rating on an assistant turn. */\n onFeedback?: (message: AIChatMessage, vote: AIChatVote) => void;\n /** Retry a turn that carries an `error`. */\n onRetry?: (message: AIChatMessage) => void;\n /**\n * The request is out and nothing has arrived yet.\n *\n * Distinct from a turn with `streaming: true`: apps that only push a message\n * once the first token lands need somewhere to say \"we asked\", and without it the\n * screen is frozen for however long the model takes to start.\n */\n pending?: boolean;\n /** Prompts offered on an empty transcript. Clicking one sends it. */\n suggestions?: readonly string[];\n /** Avatar for a turn — an `<Avatar>`, an `<Icon>`, a logo. */\n renderAvatar?: (message: AIChatMessage) => ReactNode;\n /** Render a body yourself — a tool-call card, a chart, a citation list. */\n renderContent?: (message: AIChatMessage) => ReactNode;\n /** Ratings to show as pressed, by message id. Omit to keep them local. */\n votes?: Readonly<Record<string, AIChatVote>>;\n /** Rendered above the transcript, inside the panel. */\n header?: ReactNode;\n /** Shown when there are no turns and no suggestions. */\n emptyState?: ReactNode;\n /** Show `\"system\"` turns. Default `false`. */\n showSystem?: boolean;\n /** Reasoning blocks start expanded. Default `false`. */\n defaultReasoningOpen?: boolean;\n /** Show line numbers in fenced code. Default `false`. */\n showLineNumbers?: boolean;\n /** Locale for labels. Default `\"pt-BR\"`. */\n locale?: \"pt-BR\" | \"en\";\n /** Placeholder for the composer. */\n placeholder?: string;\n /** Extra controls inside the composer, before the send button. */\n composerActions?: ReactNode;\n /**\n * Reach the composer imperatively — `focus()`, `getValue()`, `setValue()`.\n *\n * What makes dictation (or a slash-command menu, or \"edit and resend\") possible\n * without this component knowing anything about them: pair it with\n * `composerActions` and the button you put in the composer can write into the\n * field. Speech recognition is **not** wired in here on purpose — it would make\n * every consumer of `AIChat` pay for an API that streams audio to a third party.\n */\n composerRef?: Ref<AIChatComposerHandle>;\n /** Under the composer field — token count, model name, a disclaimer. */\n composerFooter?: ReactNode;\n /** Disable the composer — no credits, conversation archived, offline. */\n composerDisabled?: boolean;\n /** Largest height the composer grows to, in lines. Default 8. */\n maxRows?: number;\n /**\n * Called when `onSend` **or** `onEditSubmit` rejects. The draft stays in the field\n * either way.\n */\n onSendError?: (error: unknown) => void;\n}\n\n/** How close to the bottom still counts as \"reading the newest turn\", in pixels. */\nconst BOTTOM_SLACK = 48;\n\n/**\n * A conversation with a model: role-based turns, Markdown answers, a reasoning\n * block, a streaming caret, per-turn actions and a composer that turns into a stop\n * button while a turn is generating.\n *\n * This is the shape ChatGPT, Claude and DeepSeek converged on, and it is a different\n * component from {@link Chat}, not a variant of it. A human thread is addressed by\n * author and cares about delivery state; a model transcript is addressed by role,\n * has no delivery state at all, and needs three things a human thread never does —\n * partial output, reasoning separate from the answer, and re-asking.\n *\n * Presentational and controlled, like the rest of the SDK: it takes a list and emits\n * intent (`onSend`, `onStop`, `onRegenerate`, `onEditSubmit`, `onFeedback`). The\n * transport stays with the app, because \"how do I stream from my backend\" has a\n * different answer per provider — the SDK's `createEventStream` covers SSE, `fetch`\n * with a `ReadableStream` covers the rest, and either way the app owns the\n * `AbortController` it hands to `onStop`.\n *\n * @example\n * <AIChat\n * messages={turns}\n * pending={pending}\n * onSend={(text) => ask(text)}\n * onStop={() => controller.current?.abort()}\n * onRegenerate={(turn) => reask(turn)}\n * onFeedback={(turn, vote) => track(\"answer_rated\", { id: turn.id, vote })}\n * suggestions={[\"Resuma o último relatório\", \"Quais pedidos atrasaram?\"]}\n * />\n */\nexport function AIChat({\n messages,\n onSend,\n onStop,\n onRegenerate,\n onEditSubmit,\n onFeedback,\n onRetry,\n pending = false,\n suggestions = [],\n renderAvatar,\n renderContent,\n votes,\n header,\n emptyState,\n showSystem = false,\n defaultReasoningOpen = false,\n showLineNumbers = false,\n locale = \"pt-BR\",\n placeholder,\n composerActions,\n composerRef,\n composerFooter,\n composerDisabled,\n maxRows,\n onSendError,\n className,\n ...rest\n}: AIChatProps) {\n const strings = aiChatStrings(locale);\n const turns = visibleTurns({ messages, showSystem });\n const generating = pending || isGenerating(messages);\n const newestAssistant = lastAssistantId(messages);\n const signature = tailSignature(messages);\n\n const composer = useRef<AIChatComposerHandle | null>(null);\n const thread = useRef<HTMLDivElement | null>(null);\n const stuckToBottom = useRef(true);\n const wasGenerating = useRef(false);\n const [atBottom, setAtBottom] = useState(true);\n const announce = useAnnounce();\n\n /**\n * Remember whether the reader is at the bottom, before the next tokens land.\n *\n * A transcript that always scrolls to the newest text yanks somebody out of the\n * answer they were re-reading — and with a streaming answer that would happen\n * dozens of times per second. So the jump only happens when they were already at\n * the bottom. The slack covers a partially visible last line.\n */\n const trackPosition = (): void => {\n const node = thread.current;\n if (!node) return;\n const next = node.scrollHeight - node.scrollTop - node.clientHeight < BOTTOM_SLACK;\n stuckToBottom.current = next;\n setAtBottom(next);\n };\n\n const jumpToLatest = (): void => {\n const node = thread.current;\n if (!node) return;\n stuckToBottom.current = true;\n setAtBottom(true);\n node.scrollTop = node.scrollHeight;\n };\n\n useLayoutEffect(() => {\n const node = thread.current;\n if (!node || !stuckToBottom.current) return;\n node.scrollTop = node.scrollHeight;\n }, [signature, pending]);\n\n useEffect(() => {\n const node = thread.current;\n if (!node) return;\n node.scrollTop = node.scrollHeight;\n // Mount lands on the newest turn; from then on `trackPosition` decides.\n }, []);\n\n /**\n * Announce the start and the end of a generation, and nothing in between.\n *\n * The transcript is a `role=\"log\"` **without** `aria-live`: a live region over\n * streaming text makes a screen reader read the answer again on every token,\n * which is unusable. The two moments that matter are announced here instead —\n * through the shared `useAnnounce` region rather than a private one, so a page\n * holding a chat plus a table plus toasts still has exactly one live region per\n * politeness — and the finished answer is read from the log at the reader's own\n * pace.\n */\n useEffect(() => {\n if (generating) {\n announce(strings.generating);\n wasGenerating.current = true;\n return;\n }\n if (wasGenerating.current) {\n announce(strings.done);\n wasGenerating.current = false;\n }\n }, [generating, strings.generating, strings.done, announce]);\n\n const showSuggestions = turns.length === 0 && suggestions.length > 0 && onSend !== undefined;\n const detached = !atBottom && turns.length > 0;\n\n return (\n <div className={cn(styles.panel, className)} {...rest}>\n {header && <header className={styles.header}>{header}</header>}\n\n <div className={styles.threadWrapper}>\n <div\n ref={thread}\n className={styles.thread}\n onScroll={trackPosition}\n role=\"log\"\n tabIndex={0}\n aria-label={strings.thread}\n >\n {turns.length === 0 && !showSuggestions\n ? (emptyState ?? (\n <EmptyState title={strings.empty} description={strings.emptyHint} />\n ))\n : turns.map((message) => (\n <AIChatTurn\n key={message.id}\n message={message}\n locale={locale}\n canRegenerate={\n message.id === newestAssistant && message.streaming !== true\n }\n onRegenerate={onRegenerate}\n onFeedback={onFeedback}\n onEditSubmit={onEditSubmit}\n onEditError={onSendError}\n onRetry={onRetry}\n renderAvatar={renderAvatar}\n renderContent={renderContent}\n vote={votes?.[message.id]}\n defaultReasoningOpen={defaultReasoningOpen}\n showLineNumbers={showLineNumbers}\n />\n ))}\n\n {showSuggestions && (\n <div className={styles.suggestions}>\n <p className={styles.suggestionsTitle}>{strings.emptyHint}</p>\n {suggestions.map((suggestion) => (\n <button\n key={suggestion}\n type=\"button\"\n className={styles.suggestion}\n onClick={() => void onSend?.(suggestion)}\n >\n {suggestion}\n </button>\n ))}\n </div>\n )}\n\n {pending && !isGenerating(messages) && (\n <p className={styles.thinking}>\n <span className={styles.dots} aria-hidden=\"true\">\n <span />\n <span />\n <span />\n </span>\n {strings.thinking}\n </p>\n )}\n </div>\n\n {detached && (\n <button\n type=\"button\"\n className={styles.jump}\n onClick={jumpToLatest}\n aria-label={strings.jumpToLatest}\n title={strings.jumpToLatest}\n >\n <ArrowDown size={16} aria-hidden />\n </button>\n )}\n </div>\n\n {onSend && (\n <AIChatComposer\n ref={composerRef ?? composer}\n onSend={onSend}\n onStop={onStop}\n generating={generating}\n locale={locale}\n placeholder={placeholder}\n actions={composerActions}\n footer={composerFooter}\n disabled={composerDisabled}\n maxRows={maxRows}\n onError={onSendError}\n />\n )}\n </div>\n );\n}\n"],"mappings":"4UAkHA,IAAM,EAAe,GA+BrB,SAAgB,EAAO,CACnB,WACA,SACA,SACA,eACA,eACA,aACA,UACA,UAAU,GACV,cAAc,CAAC,EACf,eACA,gBACA,QACA,SACA,aACA,aAAa,GACb,uBAAuB,GACvB,kBAAkB,GAClB,SAAS,QACT,cACA,kBACA,cACA,iBACA,mBACA,UACA,cACA,YACA,GAAG,GACS,CACZ,IAAM,EAAU,EAAA,cAAc,CAAM,EAC9B,EAAQ,EAAA,aAAa,CAAE,WAAU,YAAW,CAAC,EAC7C,EAAa,GAAW,EAAA,aAAa,CAAQ,EAC7C,EAAkB,EAAA,gBAAgB,CAAQ,EAC1C,EAAY,EAAA,cAAc,CAAQ,EAElC,GAAA,EAAW,EAAA,OAAA,CAAoC,IAAI,EACnD,GAAA,EAAS,EAAA,OAAA,CAA8B,IAAI,EAC3C,GAAA,EAAgB,EAAA,OAAA,CAAO,EAAI,EAC3B,GAAA,EAAgB,EAAA,OAAA,CAAO,EAAK,EAC5B,CAAC,EAAU,IAAA,EAAe,EAAA,SAAA,CAAS,EAAI,EACvC,EAAW,EAAA,YAAY,EAUvB,MAA4B,CAC9B,IAAM,EAAO,EAAO,QACpB,GAAI,CAAC,EAAM,OACX,IAAM,EAAO,EAAK,aAAe,EAAK,UAAY,EAAK,aAAe,EACtE,EAAc,QAAU,EACxB,EAAY,CAAI,CACpB,EAEM,MAA2B,CAC7B,IAAM,EAAO,EAAO,QACf,IACL,EAAc,QAA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,EACR,SAAU,EACD,UACT,QAAS,CACZ,CAAA,CAEJ,GAEb"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AIChat.js","names":[],"sources":["../../../src/components/AIChat/AIChat.tsx"],"sourcesContent":["/**\n * @tempest-limits file-lines, props-count, function-lines — the widest surface in\n * the SDK on purpose: it is a whole chat page, and its 25 props are four groups —\n * the transcript (messages, votes, pending, showSystem), the turn actions an app has\n * to own (onSend, onStop, onRegenerate, onEditSubmit, onFeedback, onRetry,\n * onSendError), render slots (renderAvatar, renderContent, header, emptyState,\n * suggestions, composerActions, composerFooter) and composer settings (composerRef,\n * composerDisabled, maxRows, placeholder, locale, defaultReasoningOpen,\n * showLineNumbers). The parts already are separate components — AIChatTurn and\n * AIChatComposer are exported — and this is the assembly whose entire job is to\n * accept the union of their configuration.\n */\nimport { ArrowDown } from \"lucide-react\";\nimport {\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n type Ref,\n} from \"react\";\n\nimport { useAnnounce } from \"@/hooks/use-announce\";\nimport { cn } from \"@/utils/cn\";\n\nimport { EmptyState } from \"../EmptyState\";\nimport {\n aiChatStrings,\n isGenerating,\n lastAssistantId,\n tailSignature,\n visibleTurns,\n type AIChatMessage,\n type AIChatVote,\n} from \"./ai-chat-turns\";\nimport { AIChatComposer, type AIChatComposerHandle } from \"./AIChatComposer\";\nimport { AIChatTurn } from \"./AIChatTurn\";\nimport styles from \"./AIChat.module.css\";\n\n/** DOM attributes this component redefines. */\ntype OverriddenDomProps = \"children\" | \"onSubmit\";\n\nexport interface AIChatProps extends Omit<HTMLAttributes<HTMLDivElement>, OverriddenDomProps> {\n /** The transcript, **oldest first**. Never reordered by the component. */\n messages: readonly AIChatMessage[];\n /** Renders the composer when given. Receives the trimmed prompt. */\n onSend?: (text: string) => void | Promise<void>;\n /** Abort the turn in flight. Shows the stop button while generating. */\n onStop?: () => void;\n /** Ask again for the newest assistant turn. */\n onRegenerate?: (message: AIChatMessage) => void;\n /** Re-submit an edited user turn. The app decides what to drop after it. */\n onEditSubmit?: (message: AIChatMessage, text: string) => void | Promise<void>;\n /** Rating on an assistant turn. */\n onFeedback?: (message: AIChatMessage, vote: AIChatVote) => void;\n /** Retry a turn that carries an `error`. */\n onRetry?: (message: AIChatMessage) => void;\n /**\n * The request is out and nothing has arrived yet.\n *\n * Distinct from a turn with `streaming: true`: apps that only push a message\n * once the first token lands need somewhere to say \"we asked\", and without it the\n * screen is frozen for however long the model takes to start.\n */\n pending?: boolean;\n /** Prompts offered on an empty transcript. Clicking one sends it. */\n suggestions?: readonly string[];\n /** Avatar for a turn — an `<Avatar>`, an `<Icon>`, a logo. */\n renderAvatar?: (message: AIChatMessage) => ReactNode;\n /** Render a body yourself — a tool-call card, a chart, a citation list. */\n renderContent?: (message: AIChatMessage) => ReactNode;\n /** Ratings to show as pressed, by message id. Omit to keep them local. */\n votes?: Readonly<Record<string, AIChatVote>>;\n /** Rendered above the transcript, inside the panel. */\n header?: ReactNode;\n /** Shown when there are no turns and no suggestions. */\n emptyState?: ReactNode;\n /** Show `\"system\"` turns. Default `false`. */\n showSystem?: boolean;\n /** Reasoning blocks start expanded. Default `false`. */\n defaultReasoningOpen?: boolean;\n /** Show line numbers in fenced code. Default `false`. */\n showLineNumbers?: boolean;\n /** Locale for labels. Default `\"pt-BR\"`. */\n locale?: \"pt-BR\" | \"en\";\n /** Placeholder for the composer. */\n placeholder?: string;\n /** Extra controls inside the composer, before the send button. */\n composerActions?: ReactNode;\n /**\n * Reach the composer imperatively — `focus()`, `getValue()`, `setValue()`.\n *\n * What makes dictation (or a slash-command menu, or \"edit and resend\") possible\n * without this component knowing anything about them: pair it with\n * `composerActions` and the button you put in the composer can write into the\n * field. Speech recognition is **not** wired in here on purpose — it would make\n * every consumer of `AIChat` pay for an API that streams audio to a third party.\n */\n composerRef?: Ref<AIChatComposerHandle>;\n /** Under the composer field — token count, model name, a disclaimer. */\n composerFooter?: ReactNode;\n /** Disable the composer — no credits, conversation archived, offline. */\n composerDisabled?: boolean;\n /** Largest height the composer grows to, in lines. Default 8. */\n maxRows?: number;\n /**\n * Called when `onSend` **or** `onEditSubmit` rejects. The draft stays in the field\n * either way.\n */\n onSendError?: (error: unknown) => void;\n}\n\n/** How close to the bottom still counts as \"reading the newest turn\", in pixels. */\nconst BOTTOM_SLACK = 48;\n\n/**\n * A conversation with a model: role-based turns, Markdown answers, a reasoning\n * block, a streaming caret, per-turn actions and a composer that turns into a stop\n * button while a turn is generating.\n *\n * This is the shape ChatGPT, Claude and DeepSeek converged on, and it is a different\n * component from {@link Chat}, not a variant of it. A human thread is addressed by\n * author and cares about delivery state; a model transcript is addressed by role,\n * has no delivery state at all, and needs three things a human thread never does —\n * partial output, reasoning separate from the answer, and re-asking.\n *\n * Presentational and controlled, like the rest of the SDK: it takes a list and emits\n * intent (`onSend`, `onStop`, `onRegenerate`, `onEditSubmit`, `onFeedback`). The\n * transport stays with the app, because \"how do I stream from my backend\" has a\n * different answer per provider — the SDK's `createEventStream` covers SSE, `fetch`\n * with a `ReadableStream` covers the rest, and either way the app owns the\n * `AbortController` it hands to `onStop`.\n *\n * @example\n * <AIChat\n * messages={turns}\n * pending={pending}\n * onSend={(text) => ask(text)}\n * onStop={() => controller.current?.abort()}\n * onRegenerate={(turn) => reask(turn)}\n * onFeedback={(turn, vote) => track(\"answer_rated\", { id: turn.id, vote })}\n * suggestions={[\"Resuma o último relatório\", \"Quais pedidos atrasaram?\"]}\n * />\n */\nexport function AIChat({\n messages,\n onSend,\n onStop,\n onRegenerate,\n onEditSubmit,\n onFeedback,\n onRetry,\n pending = false,\n suggestions = [],\n renderAvatar,\n renderContent,\n votes,\n header,\n emptyState,\n showSystem = false,\n defaultReasoningOpen = false,\n showLineNumbers = false,\n locale = \"pt-BR\",\n placeholder,\n composerActions,\n composerRef,\n composerFooter,\n composerDisabled,\n maxRows,\n onSendError,\n className,\n ...rest\n}: AIChatProps) {\n const strings = aiChatStrings(locale);\n const turns = visibleTurns({ messages, showSystem });\n const generating = pending || isGenerating(messages);\n const newestAssistant = lastAssistantId(messages);\n const signature = tailSignature(messages);\n\n const composer = useRef<AIChatComposerHandle | null>(null);\n const thread = useRef<HTMLDivElement | null>(null);\n const stuckToBottom = useRef(true);\n const wasGenerating = useRef(false);\n const [atBottom, setAtBottom] = useState(true);\n const announce = useAnnounce();\n\n /**\n * Remember whether the reader is at the bottom, before the next tokens land.\n *\n * A transcript that always scrolls to the newest text yanks somebody out of the\n * answer they were re-reading — and with a streaming answer that would happen\n * dozens of times per second. So the jump only happens when they were already at\n * the bottom. The slack covers a partially visible last line.\n */\n const trackPosition = (): void => {\n const node = thread.current;\n if (!node) return;\n const next = node.scrollHeight - node.scrollTop - node.clientHeight < BOTTOM_SLACK;\n stuckToBottom.current = next;\n setAtBottom(next);\n };\n\n const jumpToLatest = (): void => {\n const node = thread.current;\n if (!node) return;\n stuckToBottom.current = true;\n setAtBottom(true);\n node.scrollTop = node.scrollHeight;\n };\n\n useLayoutEffect(() => {\n const node = thread.current;\n if (!node || !stuckToBottom.current) return;\n node.scrollTop = node.scrollHeight;\n }, [signature, pending]);\n\n useEffect(() => {\n const node = thread.current;\n if (!node) return;\n node.scrollTop = node.scrollHeight;\n // Mount lands on the newest turn; from then on `trackPosition` decides.\n }, []);\n\n /**\n * Announce the start and the end of a generation, and nothing in between.\n *\n * The transcript is a `role=\"log\"` **without** `aria-live`: a live region over\n * streaming text makes a screen reader read the answer again on every token,\n * which is unusable. The two moments that matter are announced here instead —\n * through the shared `useAnnounce` region rather than a private one, so a page\n * holding a chat plus a table plus toasts still has exactly one live region per\n * politeness — and the finished answer is read from the log at the reader's own\n * pace.\n */\n useEffect(() => {\n if (generating) {\n announce(strings.generating);\n wasGenerating.current = true;\n return;\n }\n if (wasGenerating.current) {\n announce(strings.done);\n wasGenerating.current = false;\n }\n }, [generating, strings.generating, strings.done, announce]);\n\n const showSuggestions = turns.length === 0 && suggestions.length > 0 && onSend !== undefined;\n const detached = !atBottom && turns.length > 0;\n\n return (\n <div className={cn(styles.panel, className)} {...rest}>\n {header && <header className={styles.header}>{header}</header>}\n\n <div className={styles.threadWrapper}>\n <div\n ref={thread}\n className={styles.thread}\n onScroll={trackPosition}\n role=\"log\"\n tabIndex={0}\n aria-label={strings.thread}\n >\n {turns.length === 0 && !showSuggestions\n ? (emptyState ?? (\n <EmptyState title={strings.empty} description={strings.emptyHint} />\n ))\n : turns.map((message) => (\n <AIChatTurn\n key={message.id}\n message={message}\n locale={locale}\n canRegenerate={\n message.id === newestAssistant && message.streaming !== true\n }\n onRegenerate={onRegenerate}\n onFeedback={onFeedback}\n onEditSubmit={onEditSubmit}\n onEditError={onSendError}\n onRetry={onRetry}\n renderAvatar={renderAvatar}\n renderContent={renderContent}\n vote={votes?.[message.id]}\n defaultReasoningOpen={defaultReasoningOpen}\n showLineNumbers={showLineNumbers}\n />\n ))}\n\n {showSuggestions && (\n <div className={styles.suggestions}>\n <p className={styles.suggestionsTitle}>{strings.emptyHint}</p>\n {suggestions.map((suggestion) => (\n <button\n key={suggestion}\n type=\"button\"\n className={styles.suggestion}\n onClick={() => void onSend?.(suggestion)}\n >\n {suggestion}\n </button>\n ))}\n </div>\n )}\n\n {pending && !isGenerating(messages) && (\n <p className={styles.thinking}>\n <span className={styles.dots} aria-hidden=\"true\">\n <span />\n <span />\n <span />\n </span>\n {strings.thinking}\n </p>\n )}\n </div>\n\n {detached && (\n <button\n type=\"button\"\n className={styles.jump}\n onClick={jumpToLatest}\n aria-label={strings.jumpToLatest}\n title={strings.jumpToLatest}\n >\n <ArrowDown size={16} aria-hidden />\n </button>\n )}\n </div>\n\n {onSend && (\n <AIChatComposer\n ref={composerRef ?? composer}\n onSend={onSend}\n onStop={onStop}\n generating={generating}\n locale={locale}\n placeholder={placeholder}\n actions={composerActions}\n footer={composerFooter}\n disabled={composerDisabled}\n maxRows={maxRows}\n onError={onSendError}\n />\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;A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EAAQ,QACV;;KAEN;QAEJ,MACG,kBAAC,UAAD;KACI,MAAK;KACL,WAAW,EAAO;KAClB,SAAS;KACT,cAAY,EAAQ;KACpB,OAAO,EAAQ;eAEf,kBAAC,GAAD;MAAW,MAAM;MAAI,eAAA;KAAa,CAAA;IAC9B,CAAA,CAEX;;GAEJ,KACG,kBAAC,GAAD;IACI,KAAK,KAAe;IACZ;IACA;IACI;IACJ;IACK;IACb,SAAS;IACT,QAAQ;IACR,UAAU;IACD;IACT,SAAS;GACZ,CAAA;EAEJ;;AAEb"}
|
|
1
|
+
{"version":3,"file":"AIChat.js","names":[],"sources":["../../../src/components/AIChat/AIChat.tsx"],"sourcesContent":["/**\n * @tempest-limits file-lines, props-count, function-lines — the widest surface in\n * the SDK on purpose: it is a whole chat page, and its 25 props are four groups —\n * the transcript (messages, votes, pending, showSystem), the turn actions an app has\n * to own (onSend, onStop, onRegenerate, onEditSubmit, onFeedback, onRetry,\n * onSendError), render slots (renderAvatar, renderContent, header, emptyState,\n * suggestions, composerActions, composerFooter) and composer settings (composerRef,\n * composerDisabled, maxRows, placeholder, locale, defaultReasoningOpen,\n * showLineNumbers). The parts already are separate components — AIChatTurn and\n * AIChatComposer are exported — and this is the assembly whose entire job is to\n * accept the union of their configuration.\n */\nimport { ArrowDown } from \"lucide-react\";\nimport {\n useEffect,\n useLayoutEffect,\n useRef,\n useState,\n type HTMLAttributes,\n type ReactNode,\n type Ref,\n} from \"react\";\n\nimport { useAnnounce } from \"@/hooks/use-announce\";\nimport { cn } from \"@/utils/cn\";\n\nimport { EmptyState } from \"../EmptyState\";\nimport {\n aiChatStrings,\n isGenerating,\n lastAssistantId,\n tailSignature,\n visibleTurns,\n type AIChatMessage,\n type AIChatVote,\n} from \"./ai-chat-turns\";\nimport { AIChatComposer, type AIChatComposerHandle } from \"./AIChatComposer\";\nimport { AIChatTurn } from \"./AIChatTurn\";\nimport styles from \"./AIChat.module.css\";\n\n/** DOM attributes this component redefines. */\ntype OverriddenDomProps = \"children\" | \"onSubmit\";\n\nexport interface AIChatProps extends Omit<HTMLAttributes<HTMLDivElement>, OverriddenDomProps> {\n /** The transcript, **oldest first**. Never reordered by the component. */\n messages: readonly AIChatMessage[];\n /** Renders the composer when given. Receives the trimmed prompt. */\n onSend?: (text: string) => void | Promise<void>;\n /** Abort the turn in flight. Shows the stop button while generating. */\n onStop?: () => void;\n /** Ask again for the newest assistant turn. */\n onRegenerate?: (message: AIChatMessage) => void;\n /** Re-submit an edited user turn. The app decides what to drop after it. */\n onEditSubmit?: (message: AIChatMessage, text: string) => void | Promise<void>;\n /** Rating on an assistant turn. */\n onFeedback?: (message: AIChatMessage, vote: AIChatVote) => void;\n /** Retry a turn that carries an `error`. */\n onRetry?: (message: AIChatMessage) => void;\n /**\n * The request is out and nothing has arrived yet.\n *\n * Distinct from a turn with `streaming: true`: apps that only push a message\n * once the first token lands need somewhere to say \"we asked\", and without it the\n * screen is frozen for however long the model takes to start.\n */\n pending?: boolean;\n /** Prompts offered on an empty transcript. Clicking one sends it. */\n suggestions?: readonly string[];\n /** Avatar for a turn — an `<Avatar>`, an `<Icon>`, a logo. */\n renderAvatar?: (message: AIChatMessage) => ReactNode;\n /** Render a body yourself — a tool-call card, a chart, a citation list. */\n renderContent?: (message: AIChatMessage) => ReactNode;\n /** Ratings to show as pressed, by message id. Omit to keep them local. */\n votes?: Readonly<Record<string, AIChatVote>>;\n /** Rendered above the transcript, inside the panel. */\n header?: ReactNode;\n /** Shown when there are no turns and no suggestions. */\n emptyState?: ReactNode;\n /** Show `\"system\"` turns. Default `false`. */\n showSystem?: boolean;\n /** Reasoning blocks start expanded. Default `false`. */\n defaultReasoningOpen?: boolean;\n /** Show line numbers in fenced code. Default `false`. */\n showLineNumbers?: boolean;\n /** Locale for labels. Default `\"pt-BR\"`. */\n locale?: \"pt-BR\" | \"en\";\n /** Placeholder for the composer. */\n placeholder?: string;\n /** Extra controls inside the composer, before the send button. */\n composerActions?: ReactNode;\n /**\n * Reach the composer imperatively — `focus()`, `getValue()`, `setValue()`.\n *\n * What makes dictation (or a slash-command menu, or \"edit and resend\") possible\n * without this component knowing anything about them: pair it with\n * `composerActions` and the button you put in the composer can write into the\n * field. Speech recognition is **not** wired in here on purpose — it would make\n * every consumer of `AIChat` pay for an API that streams audio to a third party.\n */\n composerRef?: Ref<AIChatComposerHandle>;\n /** Under the composer field — token count, model name, a disclaimer. */\n composerFooter?: ReactNode;\n /** Disable the composer — no credits, conversation archived, offline. */\n composerDisabled?: boolean;\n /** Largest height the composer grows to, in lines. Default 8. */\n maxRows?: number;\n /**\n * Called when `onSend` **or** `onEditSubmit` rejects. The draft stays in the field\n * either way.\n */\n onSendError?: (error: unknown) => void;\n}\n\n/** How close to the bottom still counts as \"reading the newest turn\", in pixels. */\nconst BOTTOM_SLACK = 48;\n\n/**\n * A conversation with a model: role-based turns, Markdown answers, a reasoning\n * block, a streaming caret, per-turn actions and a composer that turns into a stop\n * button while a turn is generating.\n *\n * This is the shape ChatGPT, Claude and DeepSeek converged on, and it is a different\n * component from {@link Chat}, not a variant of it. A human thread is addressed by\n * author and cares about delivery state; a model transcript is addressed by role,\n * has no delivery state at all, and needs three things a human thread never does —\n * partial output, reasoning separate from the answer, and re-asking.\n *\n * Presentational and controlled, like the rest of the SDK: it takes a list and emits\n * intent (`onSend`, `onStop`, `onRegenerate`, `onEditSubmit`, `onFeedback`). The\n * transport stays with the app, because \"how do I stream from my backend\" has a\n * different answer per provider — the SDK's `createEventStream` covers SSE, `fetch`\n * with a `ReadableStream` covers the rest, and either way the app owns the\n * `AbortController` it hands to `onStop`.\n *\n * @example\n * <AIChat\n * messages={turns}\n * pending={pending}\n * onSend={(text) => ask(text)}\n * onStop={() => controller.current?.abort()}\n * onRegenerate={(turn) => reask(turn)}\n * onFeedback={(turn, vote) => track(\"answer_rated\", { id: turn.id, vote })}\n * suggestions={[\"Resuma o último relatório\", \"Quais pedidos atrasaram?\"]}\n * />\n */\nexport function AIChat({\n messages,\n onSend,\n onStop,\n onRegenerate,\n onEditSubmit,\n onFeedback,\n onRetry,\n pending = false,\n suggestions = [],\n renderAvatar,\n renderContent,\n votes,\n header,\n emptyState,\n showSystem = false,\n defaultReasoningOpen = false,\n showLineNumbers = false,\n locale = \"pt-BR\",\n placeholder,\n composerActions,\n composerRef,\n composerFooter,\n composerDisabled,\n maxRows,\n onSendError,\n className,\n ...rest\n}: AIChatProps) {\n const strings = aiChatStrings(locale);\n const turns = visibleTurns({ messages, showSystem });\n const generating = pending || isGenerating(messages);\n const newestAssistant = lastAssistantId(messages);\n const signature = tailSignature(messages);\n\n const composer = useRef<AIChatComposerHandle | null>(null);\n const thread = useRef<HTMLDivElement | null>(null);\n const stuckToBottom = useRef(true);\n const wasGenerating = useRef(false);\n const [atBottom, setAtBottom] = useState(true);\n const announce = useAnnounce();\n\n /**\n * Remember whether the reader is at the bottom, before the next tokens land.\n *\n * A transcript that always scrolls to the newest text yanks somebody out of the\n * answer they were re-reading — and with a streaming answer that would happen\n * dozens of times per second. So the jump only happens when they were already at\n * the bottom. The slack covers a partially visible last line.\n */\n const trackPosition = (): void => {\n const node = thread.current;\n if (!node) return;\n const next = node.scrollHeight - node.scrollTop - node.clientHeight < BOTTOM_SLACK;\n stuckToBottom.current = next;\n setAtBottom(next);\n };\n\n const jumpToLatest = (): void => {\n const node = thread.current;\n if (!node) return;\n stuckToBottom.current = true;\n setAtBottom(true);\n node.scrollTop = node.scrollHeight;\n };\n\n useLayoutEffect(() => {\n const node = thread.current;\n if (!node || !stuckToBottom.current) return;\n node.scrollTop = node.scrollHeight;\n }, [signature, pending]);\n\n useEffect(() => {\n const node = thread.current;\n if (!node) return;\n node.scrollTop = node.scrollHeight;\n // Mount lands on the newest turn; from then on `trackPosition` decides.\n }, []);\n\n /**\n * Announce the start and the end of a generation, and nothing in between.\n *\n * The transcript is a `role=\"log\"` **without** `aria-live`: a live region over\n * streaming text makes a screen reader read the answer again on every token,\n * which is unusable. The two moments that matter are announced here instead —\n * through the shared `useAnnounce` region rather than a private one, so a page\n * holding a chat plus a table plus toasts still has exactly one live region per\n * politeness — and the finished answer is read from the log at the reader's own\n * pace.\n */\n useEffect(() => {\n if (generating) {\n announce(strings.generating);\n wasGenerating.current = true;\n return;\n }\n if (wasGenerating.current) {\n announce(strings.done);\n wasGenerating.current = false;\n }\n }, [generating, strings.generating, strings.done, announce]);\n\n const showSuggestions = turns.length === 0 && suggestions.length > 0 && onSend !== undefined;\n const detached = !atBottom && turns.length > 0;\n\n return (\n <div className={cn(styles.panel, className)} {...rest}>\n {header && <header className={styles.header}>{header}</header>}\n\n <div className={styles.threadWrapper}>\n <div\n ref={thread}\n className={styles.thread}\n onScroll={trackPosition}\n role=\"log\"\n tabIndex={0}\n aria-label={strings.thread}\n >\n {turns.length === 0 && !showSuggestions\n ? (emptyState ?? (\n <EmptyState title={strings.empty} description={strings.emptyHint} />\n ))\n : turns.map((message) => (\n <AIChatTurn\n key={message.id}\n message={message}\n locale={locale}\n canRegenerate={\n message.id === newestAssistant && message.streaming !== true\n }\n onRegenerate={onRegenerate}\n onFeedback={onFeedback}\n onEditSubmit={onEditSubmit}\n onEditError={onSendError}\n onRetry={onRetry}\n renderAvatar={renderAvatar}\n renderContent={renderContent}\n vote={votes?.[message.id]}\n defaultReasoningOpen={defaultReasoningOpen}\n showLineNumbers={showLineNumbers}\n />\n ))}\n\n {showSuggestions && (\n <div className={styles.suggestions}>\n <p className={styles.suggestionsTitle}>{strings.emptyHint}</p>\n {suggestions.map((suggestion) => (\n <button\n key={suggestion}\n type=\"button\"\n className={styles.suggestion}\n onClick={() => void onSend?.(suggestion)}\n >\n {suggestion}\n </button>\n ))}\n </div>\n )}\n\n {pending && !isGenerating(messages) && (\n <p className={styles.thinking}>\n <span className={styles.dots} aria-hidden=\"true\">\n <span />\n <span />\n <span />\n </span>\n {strings.thinking}\n </p>\n )}\n </div>\n\n {detached && (\n <button\n type=\"button\"\n className={styles.jump}\n onClick={jumpToLatest}\n aria-label={strings.jumpToLatest}\n title={strings.jumpToLatest}\n >\n <ArrowDown size={16} aria-hidden />\n </button>\n )}\n </div>\n\n {onSend && (\n <AIChatComposer\n ref={composerRef ?? composer}\n onSend={onSend}\n onStop={onStop}\n generating={generating}\n locale={locale}\n placeholder={placeholder}\n actions={composerActions}\n footer={composerFooter}\n disabled={composerDisabled}\n maxRows={maxRows}\n onError={onSendError}\n />\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;AAkHA,IAAM,IAAe;AA+BrB,SAAgB,EAAO,EACnB,aACA,WACA,WACA,kBACA,kBACA,gBACA,YACA,aAAU,IACV,iBAAc,CAAC,GACf,iBACA,kBACA,UACA,WACA,eACA,gBAAa,IACb,0BAAuB,IACvB,qBAAkB,IAClB,YAAS,SACT,gBACA,oBACA,gBACA,mBACA,sBACA,YACA,gBACA,cACA,GAAG,KACS;CACZ,IAAM,IAAU,EAAc,CAAM,GAC9B,IAAQ,EAAa;EAAE;EAAU;CAAW,CAAC,GAC7C,IAAa,KAAW,EAAa,CAAQ,GAC7C,IAAkB,EAAgB,CAAQ,GAC1C,IAAY,EAAc,CAAQ,GAElC,IAAW,EAAoC,IAAI,GACnD,IAAS,EAA8B,IAAI,GAC3C,IAAgB,EAAO,EAAI,GAC3B,IAAgB,EAAO,EAAK,GAC5B,CAAC,IAAU,KAAe,EAAS,EAAI,GACvC,IAAW,EAAY,GAUvB,WAA4B;EAC9B,IAAM,IAAO,EAAO;EACpB,IAAI,CAAC,GAAM;EACX,IAAM,IAAO,EAAK,eAAe,EAAK,YAAY,EAAK,eAAe;EAEtE,AADA,EAAc,UAAU,GACxB,EAAY,CAAI;CACpB,GAEM,WAA2B;EAC7B,IAAM,IAAO,EAAO;EACf,MACL,EAAc,UAAU,IACxB,EAAY,EAAI,GAChB,EAAK,YAAY,EAAK;CAC1B;CA0BA,AAxBA,QAAsB;EAClB,IAAM,IAAO,EAAO;EAChB,CAAC,KAAQ,CAAC,EAAc,YAC5B,EAAK,YAAY,EAAK;CAC1B,GAAG,CAAC,G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