@stackcraftmx/calcita 0.23.0 → 0.26.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/README.md +127 -22
- package/cli/projectFiles.js +5 -3
- package/cli/templates/project/README.md.tpl +28 -0
- package/cli/templates/project/public/manifest.webmanifest.tpl +6 -6
- package/cli/templates/project/src/app/AppProviders.jsx.tpl +9 -4
- package/cli/templates/project/src/app/appRouter.jsx.tpl +4 -2
- package/cli/templates/project/src/app/appSettings.js.tpl +14 -0
- package/cli/templates/project/src/core/AppLogo.jsx.tpl +3 -1
- package/cli/templates/project/src/core/index.js.tpl +1 -0
- package/cli/templates/project/src/core/publicPaths.js.tpl +24 -0
- package/cli/templates/project/vite.config.js.tpl +27 -1
- package/dist/DataTable/AuditTrailTable.js +5 -3
- package/dist/DataTable/AuditTrailTable.js.map +1 -1
- package/dist/DataTable/ColumnFilters/MultiSelectColumnFilter.js +2 -1
- package/dist/DataTable/ColumnFilters/MultiSelectColumnFilter.js.map +1 -1
- package/dist/DataTable/EmptyState.js +2 -2
- package/dist/DataTable/EmptyState.js.map +1 -1
- package/dist/DataTable/FilterChips.js +2 -2
- package/dist/DataTable/FilterChips.js.map +1 -1
- package/dist/DataTable/GoToPage.js +4 -3
- package/dist/DataTable/GoToPage.js.map +1 -1
- package/dist/DataTable/ServerTable.js +153 -83
- package/dist/DataTable/ServerTable.js.map +1 -1
- package/dist/DataTable/rowSelection.js +61 -0
- package/dist/DataTable/rowSelection.js.map +1 -0
- package/dist/access/PermissionMatrix.js +3 -2
- package/dist/access/PermissionMatrix.js.map +1 -1
- package/dist/account/AccountSecuritySection.js +2 -2
- package/dist/account/AccountSecuritySection.js.map +1 -1
- package/dist/account/ForgotPasswordScreen.js +5 -4
- package/dist/account/ForgotPasswordScreen.js.map +1 -1
- package/dist/account/ProfileScreen.js +39 -13
- package/dist/account/ProfileScreen.js.map +1 -1
- package/dist/account/ResetPasswordScreen.js +3 -2
- package/dist/account/ResetPasswordScreen.js.map +1 -1
- package/dist/account/SignInScreen.js +7 -6
- package/dist/account/SignInScreen.js.map +1 -1
- package/dist/account/accountConnector.js.map +1 -1
- package/dist/account/restAccountConnector.js +2 -1
- package/dist/account/restAccountConnector.js.map +1 -1
- package/dist/adapters/reactRouterRoutes.js +7 -6
- package/dist/adapters/reactRouterRoutes.js.map +1 -1
- package/dist/api/createApiClient.js +40 -5
- package/dist/api/createApiClient.js.map +1 -1
- package/dist/appShell/AccountMenu.js +15 -23
- package/dist/appShell/AccountMenu.js.map +1 -1
- package/dist/appShell/AppLayout.js +42 -15
- package/dist/appShell/AppLayout.js.map +1 -1
- package/dist/appShell/AppearanceSettings.js +29 -6
- package/dist/appShell/AppearanceSettings.js.map +1 -1
- package/dist/appShell/AuthLayout.js +2 -0
- package/dist/appShell/AuthLayout.js.map +1 -1
- package/dist/appShell/BarActionButton.js +3 -3
- package/dist/appShell/BarActionButton.js.map +1 -1
- package/dist/appShell/BarActions.js +19 -8
- package/dist/appShell/BarActions.js.map +1 -1
- package/dist/appShell/BarCapsule.js +19 -4
- package/dist/appShell/BarCapsule.js.map +1 -1
- package/dist/appShell/BarSearch.js +92 -0
- package/dist/appShell/BarSearch.js.map +1 -0
- package/dist/appShell/HeaderTools.js +4 -2
- package/dist/appShell/HeaderTools.js.map +1 -1
- package/dist/appShell/MenuLinks.js +36 -0
- package/dist/appShell/MenuLinks.js.map +1 -0
- package/dist/appShell/MobileTabBar.js +6 -4
- package/dist/appShell/MobileTabBar.js.map +1 -1
- package/dist/appShell/SettingsMenu.js +10 -5
- package/dist/appShell/SettingsMenu.js.map +1 -1
- package/dist/appShell/SideMenu.js +5 -3
- package/dist/appShell/SideMenu.js.map +1 -1
- package/dist/appShell/SideMenuEntry.js +3 -3
- package/dist/appShell/SideMenuEntry.js.map +1 -1
- package/dist/appShell/SubmenuActionsMenu.js +3 -4
- package/dist/appShell/SubmenuActionsMenu.js.map +1 -1
- package/dist/appShell/TopMenu.js +5 -6
- package/dist/appShell/TopMenu.js.map +1 -1
- package/dist/appShell/Wordmark.js +11 -0
- package/dist/appShell/Wordmark.js.map +1 -0
- package/dist/appShell/menuItemText.js +4 -0
- package/dist/appShell/menuItemText.js.map +1 -1
- package/dist/appShell/shellSizes.js +2 -0
- package/dist/appShell/shellSizes.js.map +1 -1
- package/dist/auth/PasswordChecklist.js +2 -2
- package/dist/auth/PasswordChecklist.js.map +1 -1
- package/dist/calendar/EventCalendar.js +16 -5
- package/dist/calendar/EventCalendar.js.map +1 -1
- package/dist/calendar/EventDetails.js +74 -0
- package/dist/calendar/EventDetails.js.map +1 -0
- package/dist/calendar/calendarEvents.js +31 -0
- package/dist/calendar/calendarEvents.js.map +1 -0
- package/dist/calendar.js +8 -1
- package/dist/calendar.js.map +1 -1
- package/dist/charts.js +10 -1
- package/dist/charts.js.map +1 -1
- package/dist/datePickers/DateInput.js +3 -2
- package/dist/datePickers/DateInput.js.map +1 -1
- package/dist/downloads/DownloadManager.js +14 -20
- package/dist/downloads/DownloadManager.js.map +1 -1
- package/dist/downloads/downloadQueue.js +4 -2
- package/dist/downloads/downloadQueue.js.map +1 -1
- package/dist/downloads/downloadsMachine.js +4 -1
- package/dist/downloads/downloadsMachine.js.map +1 -1
- package/dist/downloads/fileTypes.js +22 -0
- package/dist/downloads/fileTypes.js.map +1 -0
- package/dist/feedback/ConfirmDialog.js +3 -2
- package/dist/feedback/ConfirmDialog.js.map +1 -1
- package/dist/feedback/ModalWaiting.js +2 -2
- package/dist/feedback/ModalWaiting.js.map +1 -1
- package/dist/feedback/NewBuildNotice.js +2 -2
- package/dist/feedback/NewBuildNotice.js.map +1 -1
- package/dist/filepond/FileDropzone.js +5 -3
- package/dist/filepond/FileDropzone.js.map +1 -1
- package/dist/formatting.js +171 -143
- package/dist/formatting.js.map +1 -1
- package/dist/forms/FormWizard.js +18 -45
- package/dist/forms/FormWizard.js.map +1 -1
- package/dist/forms/auth/ChangePasswordForm.js +5 -4
- package/dist/forms/auth/ChangePasswordForm.js.map +1 -1
- package/dist/forms/auth/ForgotPasswordForm.js +2 -2
- package/dist/forms/auth/ForgotPasswordForm.js.map +1 -1
- package/dist/forms/auth/SignInForm.js +2 -2
- package/dist/forms/auth/SignInForm.js.map +1 -1
- package/dist/forms/security/SecondStepForm.js +2 -2
- package/dist/forms/security/SecondStepForm.js.map +1 -1
- package/dist/forms/security/TwoStepVerificationCard.js +8 -6
- package/dist/forms/security/TwoStepVerificationCard.js.map +1 -1
- package/dist/hookForm/FormWizard.js +59 -0
- package/dist/hookForm/FormWizard.js.map +1 -0
- package/dist/inbox/InboxLayout.js +44 -8
- package/dist/inbox/InboxLayout.js.map +1 -1
- package/dist/inbox/MessageList.js +71 -21
- package/dist/inbox/MessageList.js.map +1 -1
- package/dist/inbox/MessageView.js +80 -29
- package/dist/inbox/MessageView.js.map +1 -1
- package/dist/inbox/inboxDates.js +4 -3
- package/dist/inbox/inboxDates.js.map +1 -1
- package/dist/index.js +163 -136
- package/dist/index.js.map +1 -1
- package/dist/inputs/CatalogInput.js +8 -4
- package/dist/inputs/CatalogInput.js.map +1 -1
- package/dist/inputs/ColorInput.js +3 -2
- package/dist/inputs/ColorInput.js.map +1 -1
- package/dist/inputs/FormSection.js +3 -3
- package/dist/inputs/FormSection.js.map +1 -1
- package/dist/inputs/NumberInput.js +3 -2
- package/dist/inputs/NumberInput.js.map +1 -1
- package/dist/inputs/SelectInput.js +29 -11
- package/dist/inputs/SelectInput.js.map +1 -1
- package/dist/inputs/TextInput.js +6 -2
- package/dist/inputs/TextInput.js.map +1 -1
- package/dist/inputs/WizardLayout.js +54 -0
- package/dist/inputs/WizardLayout.js.map +1 -0
- package/dist/kanban/KanbanBoard.js +239 -14
- package/dist/kanban/KanbanBoard.js.map +1 -1
- package/dist/kanban/kanbanCards.js +19 -0
- package/dist/kanban/kanbanCards.js.map +1 -0
- package/dist/kanban.js +7 -1
- package/dist/kanban.js.map +1 -1
- package/dist/locales/en.js +74 -1
- package/dist/locales/en.js.map +1 -1
- package/dist/locales/es.js +74 -1
- package/dist/locales/es.js.map +1 -1
- package/dist/maps/MapView.js +28 -8
- package/dist/maps/MapView.js.map +1 -1
- package/dist/navigation/appMenu.js +13 -1
- package/dist/navigation/appMenu.js.map +1 -1
- package/dist/observability/logger.js +18 -0
- package/dist/observability/logger.js.map +1 -1
- package/dist/observability/usePublishedBuildWatch.js +4 -3
- package/dist/observability/usePublishedBuildWatch.js.map +1 -1
- package/dist/pwa/InstallAppSetting.js +6 -5
- package/dist/pwa/InstallAppSetting.js.map +1 -1
- package/dist/pwa/InstallInstructionsDialog.js +2 -2
- package/dist/pwa/InstallInstructionsDialog.js.map +1 -1
- package/dist/pwa/InstallPromptBanner.js +15 -9
- package/dist/pwa/InstallPromptBanner.js.map +1 -1
- package/dist/pwa/useInstallPrompt.js +2 -1
- package/dist/pwa/useInstallPrompt.js.map +1 -1
- package/dist/react-hook-form.js +6 -4
- package/dist/react-hook-form.js.map +1 -1
- package/dist/security/ActivityLog.js +4 -3
- package/dist/security/ActivityLog.js.map +1 -1
- package/dist/security/RecoveryCodesDialog.js +4 -3
- package/dist/security/RecoveryCodesDialog.js.map +1 -1
- package/dist/security/SessionsCard.js +8 -6
- package/dist/security/SessionsCard.js.map +1 -1
- package/dist/table.js +2 -0
- package/dist/table.js.map +1 -1
- package/dist/theme/components/MuiAppBar.js +6 -5
- package/dist/theme/components/MuiAppBar.js.map +1 -1
- package/dist/theme/components/MuiDialog.js +13 -0
- package/dist/theme/components/MuiDialog.js.map +1 -0
- package/dist/theme/components/glassComponents.js +32 -31
- package/dist/theme/components/glassComponents.js.map +1 -1
- package/dist/theme/components/minimalComponents.js +8 -4
- package/dist/theme/components/minimalComponents.js.map +1 -1
- package/dist/theme/createToolkitTheme.js.map +1 -1
- package/dist/theme/glassSurface.js +36 -38
- package/dist/theme/glassSurface.js.map +1 -1
- package/dist/theme/lightDarkStyles.js +48 -0
- package/dist/theme/lightDarkStyles.js.map +1 -0
- package/dist/theme/toolkitComponents.js +2 -0
- package/dist/theme/toolkitComponents.js.map +1 -1
- package/dist/toolkit/ComponentTexts.js +13 -0
- package/dist/toolkit/ComponentTexts.js.map +1 -0
- package/dist/toolkit/ToolkitProvider.js +36 -28
- package/dist/toolkit/ToolkitProvider.js.map +1 -1
- package/dist/toolkit/browserNavigation.js +19 -20
- package/dist/toolkit/browserNavigation.js.map +1 -1
- package/dist/toolkit/componentTextsContext.js +15 -0
- package/dist/toolkit/componentTextsContext.js.map +1 -0
- package/dist/toolkit/hashNavigation.js +40 -0
- package/dist/toolkit/hashNavigation.js.map +1 -0
- package/dist/toolkit/navigationPaths.js +49 -0
- package/dist/toolkit/navigationPaths.js.map +1 -0
- package/dist/toolkit/toolkitSettings.js +24 -4
- package/dist/toolkit/toolkitSettings.js.map +1 -1
- package/dist/toolkit/useFormatters.js +12 -0
- package/dist/toolkit/useFormatters.js.map +1 -0
- package/dist/toolkit/useToolkitTranslation.js +11 -7
- package/dist/toolkit/useToolkitTranslation.js.map +1 -1
- package/dist/types/DataTable/AuditTrailTable.d.ts +3 -1
- package/dist/types/DataTable/EmptyState.d.ts +7 -2
- package/dist/types/DataTable/FilterChips.d.ts +3 -1
- package/dist/types/DataTable/GoToPage.d.ts +7 -2
- package/dist/types/DataTable/SelectionBar.d.ts +32 -0
- package/dist/types/DataTable/ServerTable.d.ts +64 -3
- package/dist/types/DataTable/index.d.ts +1 -1
- package/dist/types/DataTable/rowSelection.d.ts +113 -0
- package/dist/types/access/PermissionMatrix.d.ts +3 -1
- package/dist/types/account/AccountSecuritySection.d.ts +3 -1
- package/dist/types/account/ForgotPasswordScreen.d.ts +3 -1
- package/dist/types/account/ProfileScreen.d.ts +31 -1
- package/dist/types/account/ResetPasswordScreen.d.ts +3 -1
- package/dist/types/account/SignInScreen.d.ts +3 -1
- package/dist/types/account/accountConnector.d.ts +7 -2
- package/dist/types/adapters/reactRouterRoutes.d.ts +14 -2
- package/dist/types/api/createApiClient.d.ts +46 -1
- package/dist/types/appShell/AppLayout.d.ts +15 -1
- package/dist/types/appShell/AppearanceSettings.d.ts +8 -1
- package/dist/types/appShell/BarActionButton.d.ts +2 -2
- package/dist/types/appShell/BarActions.d.ts +6 -1
- package/dist/types/appShell/BarCapsule.d.ts +8 -0
- package/dist/types/appShell/BarSearch.d.ts +24 -0
- package/dist/types/appShell/MenuLinks.d.ts +17 -0
- package/dist/types/appShell/MobileTabBar.d.ts +4 -1
- package/dist/types/appShell/SettingsMenu.d.ts +3 -1
- package/dist/types/appShell/SideMenu.d.ts +3 -1
- package/dist/types/appShell/Wordmark.d.ts +6 -0
- package/dist/types/appShell/menuItemText.d.ts +16 -0
- package/dist/types/appShell/shellSizes.d.ts +1 -0
- package/dist/types/auth/PasswordChecklist.d.ts +3 -1
- package/dist/types/calendar/EventCalendar.d.ts +18 -1
- package/dist/types/calendar/EventDetails.d.ts +36 -0
- package/dist/types/calendar/calendarEvents.d.ts +27 -0
- package/dist/types/calendar.d.ts +2 -0
- package/dist/types/charts.d.ts +4 -0
- package/dist/types/datePickers/DateInput.d.ts +3 -1
- package/dist/types/downloads/DownloadManager.d.ts +7 -1
- package/dist/types/downloads/downloadQueue.d.ts +8 -3
- package/dist/types/downloads/fileTypes.d.ts +39 -0
- package/dist/types/downloads/index.d.ts +1 -0
- package/dist/types/feedback/ConfirmDialog.d.ts +3 -1
- package/dist/types/feedback/ModalWaiting.d.ts +7 -2
- package/dist/types/feedback/NewBuildNotice.d.ts +3 -1
- package/dist/types/filepond/FileDropzone.d.ts +3 -1
- package/dist/types/formatting.d.ts +45 -90
- package/dist/types/forms/FormWizard.d.ts +3 -1
- package/dist/types/forms/auth/ChangePasswordForm.d.ts +3 -1
- package/dist/types/forms/auth/ForgotPasswordForm.d.ts +3 -1
- package/dist/types/forms/auth/SignInForm.d.ts +3 -1
- package/dist/types/forms/security/SecondStepForm.d.ts +3 -1
- package/dist/types/forms/security/TwoStepVerificationCard.d.ts +3 -1
- package/dist/types/hookForm/FormWizard.d.ts +22 -0
- package/dist/types/inbox/InboxLayout.d.ts +14 -2
- package/dist/types/inbox/MessageList.d.ts +30 -5
- package/dist/types/inbox/MessageView.d.ts +35 -3
- package/dist/types/inbox/inboxDates.d.ts +6 -1
- package/dist/types/index.d.ts +15 -8
- package/dist/types/inputs/CatalogInput.d.ts +9 -5
- package/dist/types/inputs/ColorInput.d.ts +3 -1
- package/dist/types/inputs/FormSection.d.ts +2 -2
- package/dist/types/inputs/NumberInput.d.ts +3 -1
- package/dist/types/inputs/SelectInput.d.ts +9 -5
- package/dist/types/inputs/TextInput.d.ts +3 -1
- package/dist/types/inputs/WizardLayout.d.ts +34 -0
- package/dist/types/kanban/KanbanBoard.d.ts +61 -6
- package/dist/types/kanban/kanbanCards.d.ts +22 -0
- package/dist/types/kanban.d.ts +1 -0
- package/dist/types/locales/en.d.ts +77 -0
- package/dist/types/locales/es.d.ts +77 -0
- package/dist/types/maps/MapView.d.ts +12 -3
- package/dist/types/navigation/appMenu.d.ts +8 -0
- package/dist/types/observability/logger.d.ts +13 -0
- package/dist/types/observability/usePublishedBuildWatch.d.ts +3 -1
- package/dist/types/pwa/InstallAppSetting.d.ts +7 -1
- package/dist/types/pwa/InstallInstructionsDialog.d.ts +3 -1
- package/dist/types/pwa/InstallPromptBanner.d.ts +10 -1
- package/dist/types/pwa/useInstallPrompt.d.ts +3 -2
- package/dist/types/react-hook-form.d.ts +1 -0
- package/dist/types/security/ActivityLog.d.ts +3 -1
- package/dist/types/security/RecoveryCodesDialog.d.ts +6 -1
- package/dist/types/security/SessionsCard.d.ts +3 -1
- package/dist/types/table.d.ts +3 -1
- package/dist/types/theme/components/MuiAppBar.d.ts +3 -1
- package/dist/types/theme/components/MuiDialog.d.ts +9 -0
- package/dist/types/theme/components/glassComponents.d.ts +5 -0
- package/dist/types/theme/lightDarkStyles.d.ts +8 -0
- package/dist/types/toolkit/ComponentTexts.d.ts +11 -0
- package/dist/types/toolkit/ToolkitProvider.d.ts +18 -2
- package/dist/types/toolkit/browserNavigation.d.ts +23 -28
- package/dist/types/toolkit/componentTextsContext.d.ts +20 -0
- package/dist/types/toolkit/hashNavigation.d.ts +12 -0
- package/dist/types/toolkit/navigationPaths.d.ts +43 -0
- package/dist/types/toolkit/toolkitSettings.d.ts +49 -4
- package/dist/types/toolkit/useFormatters.d.ts +6 -0
- package/dist/types/toolkit/useToolkitTranslation.d.ts +2 -1
- package/dist/types/ui/actions/ActionsMenu.d.ts +20 -0
- package/dist/types/ui/actions/CopyButton.d.ts +3 -1
- package/dist/types/ui/actions/DownloadMenu.d.ts +8 -3
- package/dist/types/ui/actions/SecretField.d.ts +5 -1
- package/dist/types/ui/actions/SelectionActions.d.ts +39 -0
- package/dist/types/ui/filters/DateRangeFilter.d.ts +3 -1
- package/dist/types/ui/filters/QuickFilters.d.ts +3 -1
- package/dist/types/ui/index.d.ts +1 -1
- package/dist/types/ui/labels/tagOf.d.ts +13 -0
- package/dist/types/ui/layout/CollapsibleSection.d.ts +4 -1
- package/dist/types/ui/layout/ContentDialog.d.ts +3 -1
- package/dist/types/ui/layout/ErrorPage.d.ts +14 -1
- package/dist/types/ui/layout/FullPageLoader.d.ts +7 -1
- package/dist/types/ui/layout/PageHeading.d.ts +3 -1
- package/dist/types/ui/metrics/BarList.d.ts +7 -1
- package/dist/types/ui/metrics/CalendarHeatmap.d.ts +7 -1
- package/dist/types/ui/metrics/ChartTooltip.d.ts +9 -3
- package/dist/types/ui/metrics/ColumnChart.d.ts +23 -11
- package/dist/types/ui/metrics/LineChart.d.ts +41 -0
- package/dist/types/ui/metrics/MetricCard.d.ts +9 -1
- package/dist/types/ui/metrics/TableToggle.d.ts +9 -2
- package/dist/types/ui/metrics/chartParts.d.ts +112 -0
- package/dist/types/ui/navigation/BackButton.d.ts +3 -1
- package/dist/types/ui/navigation/ColorSchemeToggle.d.ts +8 -2
- package/dist/types/ui/navigation/FontSizeToggle.d.ts +7 -2
- package/dist/types/ui/navigation/LanguageToggle.d.ts +8 -3
- package/dist/types/ui/navigation/PageBreadcrumbs.d.ts +5 -2
- package/dist/types/ui/timeline/GroupedTimeline.d.ts +4 -1
- package/dist/types/upload/FileDropzone.d.ts +3 -1
- package/dist/ui/actions/ActionsMenu.js +51 -0
- package/dist/ui/actions/ActionsMenu.js.map +1 -0
- package/dist/ui/actions/CopyButton.js +2 -2
- package/dist/ui/actions/CopyButton.js.map +1 -1
- package/dist/ui/actions/DownloadMenu.js +11 -12
- package/dist/ui/actions/DownloadMenu.js.map +1 -1
- package/dist/ui/actions/SecretField.js +8 -4
- package/dist/ui/actions/SecretField.js.map +1 -1
- package/dist/ui/actions/SelectionActions.js +142 -0
- package/dist/ui/actions/SelectionActions.js.map +1 -0
- package/dist/ui/filters/DateRangeFilter.js +4 -3
- package/dist/ui/filters/DateRangeFilter.js.map +1 -1
- package/dist/ui/filters/QuickFilters.js +2 -2
- package/dist/ui/filters/QuickFilters.js.map +1 -1
- package/dist/ui/labels/tagOf.js +7 -0
- package/dist/ui/labels/tagOf.js.map +1 -0
- package/dist/ui/layout/CollapsibleSection.js +6 -2
- package/dist/ui/layout/CollapsibleSection.js.map +1 -1
- package/dist/ui/layout/ContentDialog.js +2 -2
- package/dist/ui/layout/ContentDialog.js.map +1 -1
- package/dist/ui/layout/ErrorPage.js +21 -7
- package/dist/ui/layout/ErrorPage.js.map +1 -1
- package/dist/ui/layout/FullPageLoader.js +2 -2
- package/dist/ui/layout/FullPageLoader.js.map +1 -1
- package/dist/ui/layout/PageHeading.js +2 -2
- package/dist/ui/layout/PageHeading.js.map +1 -1
- package/dist/ui/metrics/BarList.js +18 -13
- package/dist/ui/metrics/BarList.js.map +1 -1
- package/dist/ui/metrics/CalendarHeatmap.js +11 -6
- package/dist/ui/metrics/CalendarHeatmap.js.map +1 -1
- package/dist/ui/metrics/ChartTooltip.js +1 -1
- package/dist/ui/metrics/ChartTooltip.js.map +1 -1
- package/dist/ui/metrics/ColumnChart.js +59 -63
- package/dist/ui/metrics/ColumnChart.js.map +1 -1
- package/dist/ui/metrics/LineChart.js +117 -0
- package/dist/ui/metrics/LineChart.js.map +1 -0
- package/dist/ui/metrics/MetricCard.js +41 -8
- package/dist/ui/metrics/MetricCard.js.map +1 -1
- package/dist/ui/metrics/TableToggle.js +4 -2
- package/dist/ui/metrics/TableToggle.js.map +1 -1
- package/dist/ui/metrics/chartParts.js +93 -0
- package/dist/ui/metrics/chartParts.js.map +1 -0
- package/dist/ui/navigation/BackButton.js +2 -2
- package/dist/ui/navigation/BackButton.js.map +1 -1
- package/dist/ui/navigation/ColorSchemeToggle.js +6 -3
- package/dist/ui/navigation/ColorSchemeToggle.js.map +1 -1
- package/dist/ui/navigation/FontSizeToggle.js +3 -2
- package/dist/ui/navigation/FontSizeToggle.js.map +1 -1
- package/dist/ui/navigation/LanguageToggle.js +40 -19
- package/dist/ui/navigation/LanguageToggle.js.map +1 -1
- package/dist/ui/navigation/PageBreadcrumbs.js +2 -2
- package/dist/ui/navigation/PageBreadcrumbs.js.map +1 -1
- package/dist/ui/timeline/GroupedTimeline.js +10 -8
- package/dist/ui/timeline/GroupedTimeline.js.map +1 -1
- package/dist/upload/FileDropzone.js +5 -3
- package/dist/upload/FileDropzone.js.map +1 -1
- package/package.json +16 -7
|
@@ -8,28 +8,33 @@ import TableCell from "@mui/material/TableCell";
|
|
|
8
8
|
import TableRow from "@mui/material/TableRow";
|
|
9
9
|
import Typography from "@mui/material/Typography";
|
|
10
10
|
import { ResponsiveContainer, BarChart, XAxis, YAxis, Tooltip, Bar, LabelList } from "recharts";
|
|
11
|
-
import {
|
|
11
|
+
import { useFormatters } from "../../toolkit/useFormatters.js";
|
|
12
12
|
import ChartTooltip from "./ChartTooltip.js";
|
|
13
|
-
import TableToggle from "./TableToggle.js";
|
|
13
|
+
import TableToggle, { CHART_VIEW } from "./TableToggle.js";
|
|
14
14
|
import { BAR_MIN_POINT_SIZE, barLabelValueOf } from "./barListLabels.js";
|
|
15
|
+
import { useChartColors } from "./chartParts.js";
|
|
15
16
|
const ROW_HEIGHT_PIXELS = 36;
|
|
16
|
-
|
|
17
|
-
const MUTED_COLOR = "var(--mui-palette-text-secondary)";
|
|
18
|
-
function ValueLabel({ x, y, width, height, value }) {
|
|
17
|
+
function ValueLabel({ x, y, width, height, value, colors, formatNumber }) {
|
|
19
18
|
return /* @__PURE__ */ jsxs("text", { x: x + width + 8, y: y + height / 2, dominantBaseline: "central", fontSize: 13, children: [
|
|
20
|
-
/* @__PURE__ */ jsx("tspan", { fill:
|
|
21
|
-
value.detail && /* @__PURE__ */ jsx("tspan", { fill:
|
|
19
|
+
/* @__PURE__ */ jsx("tspan", { fill: colors.text, fontWeight: 600, children: formatNumber(value.value) }),
|
|
20
|
+
value.detail && /* @__PURE__ */ jsx("tspan", { fill: colors.muted, fontSize: 12, children: ` ${value.detail}` })
|
|
22
21
|
] });
|
|
23
22
|
}
|
|
24
|
-
function BarList({ items, onSelect, emptyLabel, tone = "primary" }) {
|
|
25
|
-
const [asTable, setAsTable] = useState(
|
|
23
|
+
function BarList({ items, onSelect, emptyLabel, tone = "primary", texts, defaultView = CHART_VIEW.chart, onViewChange }) {
|
|
24
|
+
const [asTable, setAsTable] = useState(defaultView === CHART_VIEW.table);
|
|
25
|
+
const toggleView = () => {
|
|
26
|
+
setAsTable(!asTable);
|
|
27
|
+
onViewChange?.(asTable ? CHART_VIEW.chart : CHART_VIEW.table);
|
|
28
|
+
};
|
|
29
|
+
const colors = useChartColors();
|
|
30
|
+
const { formatNumber } = useFormatters();
|
|
26
31
|
if (!items.length) {
|
|
27
32
|
return /* @__PURE__ */ jsx(Typography, { variant: "body2", color: "text.secondary", children: emptyLabel });
|
|
28
33
|
}
|
|
29
34
|
const labelWidth = Math.min(220, 16 + Math.max(...items.map((item) => String(item.label ?? "").length)) * 7);
|
|
30
35
|
const longestValue = Math.max(...items.map((item) => `${formatNumber(item.value)} ${item.detail ?? ""}`.length));
|
|
31
36
|
return /* @__PURE__ */ jsxs(Box, { children: [
|
|
32
|
-
/* @__PURE__ */ jsx(TableToggle, { asTable, onToggle:
|
|
37
|
+
/* @__PURE__ */ jsx(TableToggle, { asTable, onToggle: toggleView, texts }),
|
|
33
38
|
asTable ? /* @__PURE__ */ jsx(Table, { size: "small", children: /* @__PURE__ */ jsx(TableBody, { children: items.map((item) => /* @__PURE__ */ jsxs(
|
|
34
39
|
TableRow,
|
|
35
40
|
{
|
|
@@ -56,13 +61,13 @@ function BarList({ items, onSelect, emptyLabel, tone = "primary" }) {
|
|
|
56
61
|
width: labelWidth,
|
|
57
62
|
tickLine: false,
|
|
58
63
|
axisLine: false,
|
|
59
|
-
tick: { fill:
|
|
64
|
+
tick: { fill: colors.text, fontSize: 13 }
|
|
60
65
|
}
|
|
61
66
|
),
|
|
62
67
|
/* @__PURE__ */ jsx(
|
|
63
68
|
Tooltip,
|
|
64
69
|
{
|
|
65
|
-
cursor: { fill:
|
|
70
|
+
cursor: { fill: colors.hover },
|
|
66
71
|
content: /* @__PURE__ */ jsx(ChartTooltip, { render: (item) => item.tooltip ?? `${item.label}: ${formatNumber(item.value)}` })
|
|
67
72
|
}
|
|
68
73
|
),
|
|
@@ -77,7 +82,7 @@ function BarList({ items, onSelect, emptyLabel, tone = "primary" }) {
|
|
|
77
82
|
minPointSize: BAR_MIN_POINT_SIZE,
|
|
78
83
|
cursor: onSelect ? "pointer" : "default",
|
|
79
84
|
onClick: onSelect ? (entry) => onSelect(entry.payload) : void 0,
|
|
80
|
-
children: /* @__PURE__ */ jsx(LabelList, { valueAccessor: barLabelValueOf, content: (labelProps) => /* @__PURE__ */ jsx(ValueLabel, { ...labelProps }) })
|
|
85
|
+
children: /* @__PURE__ */ jsx(LabelList, { valueAccessor: barLabelValueOf, content: (labelProps) => /* @__PURE__ */ jsx(ValueLabel, { ...labelProps, colors, formatNumber }) })
|
|
81
86
|
}
|
|
82
87
|
)
|
|
83
88
|
] }) }) })
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BarList.js","sources":["../../../src/ui/metrics/BarList.jsx"],"sourcesContent":["// Barras horizontales de UNA serie con su nombre a la izquierda y su valor en la punta (ventas por producto,\n// cuentas por organización), dibujadas con Recharts.\n//\n// Horizontales porque los nombres son largos (\"Empresa / Área de ventas\"): se leen completos sin rotarlos. Una serie → un\n// color (el del tono, vía currentColor: los atributos SVG no leen var(...) pero sí currentColor); el valor va en tinta,\n// nunca del color de la barra; y cada barra puede llevar a la pantalla que la explica.\n//\n// OJO: el número y el detalle de la punta salen del renglón de la barra (barListLabels.js), nunca de items[index]: Recharts\n// descarta las barras de ancho 0 y renumera las etiquetas, y el detalle se corría al renglón de arriba.\n//\n// Genérico del paquete: function (regla de la casa).\nimport {useState} from 'react';\nimport Box from '@mui/material/Box';\nimport Table from '@mui/material/Table';\nimport TableBody from '@mui/material/TableBody';\nimport TableCell from '@mui/material/TableCell';\nimport TableRow from '@mui/material/TableRow';\nimport Typography from '@mui/material/Typography';\nimport {Bar, BarChart, LabelList, ResponsiveContainer, Tooltip, XAxis, YAxis} from 'recharts';\n\nimport {
|
|
1
|
+
{"version":3,"file":"BarList.js","sources":["../../../src/ui/metrics/BarList.jsx"],"sourcesContent":["// Barras horizontales de UNA serie con su nombre a la izquierda y su valor en la punta (ventas por producto,\n// cuentas por organización), dibujadas con Recharts.\n//\n// Horizontales porque los nombres son largos (\"Empresa / Área de ventas\"): se leen completos sin rotarlos. Una serie → un\n// color (el del tono, vía currentColor: los atributos SVG no leen var(...) pero sí currentColor); el valor va en tinta,\n// nunca del color de la barra; y cada barra puede llevar a la pantalla que la explica.\n//\n// OJO: el número y el detalle de la punta salen del renglón de la barra (barListLabels.js), nunca de items[index]: Recharts\n// descarta las barras de ancho 0 y renumera las etiquetas, y el detalle se corría al renglón de arriba.\n//\n// Genérico del paquete: function (regla de la casa).\nimport {useState} from 'react';\nimport Box from '@mui/material/Box';\nimport Table from '@mui/material/Table';\nimport TableBody from '@mui/material/TableBody';\nimport TableCell from '@mui/material/TableCell';\nimport TableRow from '@mui/material/TableRow';\nimport Typography from '@mui/material/Typography';\nimport {Bar, BarChart, LabelList, ResponsiveContainer, Tooltip, XAxis, YAxis} from 'recharts';\n\nimport {useFormatters} from '@/toolkit/useFormatters.js';\nimport ChartTooltip from '@/ui/metrics/ChartTooltip.jsx';\nimport TableToggle, {CHART_VIEW} from '@/ui/metrics/TableToggle.jsx';\nimport {BAR_MIN_POINT_SIZE, barLabelValueOf} from '@/ui/metrics/barListLabels.js';\nimport {useChartColors} from '@/ui/metrics/chartParts.jsx';\n\nconst ROW_HEIGHT_PIXELS = 36;\n\n/**\n * El valor en la punta: el número fuerte y el detalle (\"de 8\") tenue; value es {value, detail} de barLabelValueOf. colors y\n * formatNumber: los de useChartColors y useFormatters (los da BarList: este pedazo lo pinta recharts por su cuenta).\n */\nfunction ValueLabel({x, y, width, height, value, colors, formatNumber}) {\n return (\n <text x={x + width + 8} y={y + height / 2} dominantBaseline=\"central\" fontSize={13}>\n <tspan fill={colors.text} fontWeight={600}>{formatNumber(value.value)}</tspan>\n {value.detail && <tspan fill={colors.muted} fontSize={12}>{` ${value.detail}`}</tspan>}\n </text>\n );\n}\n\n/**\n * @param {object} props\n * @param {Array<{key: string, label: string, value: number, detail?: string, tooltip?: string}>} props.items\n * @param {(item: any) => void} [props.onSelect] recibe el renglón de items que se picó\n * @param {string} props.emptyLabel ya traducido\n * @param {'primary'|'success'|'warning'|'error'|'info'} [props.tone]\n * @param {'chart'|'table'} [props.defaultView] cómo se ve al abrir (CHART_VIEW); por omisión dibujada\n * @param {(view: 'chart'|'table') => void} [props.onViewChange] la persona cambió a la tabla o a la gráfica\n * @param {object} [props.texts] los textos que cambian, con la forma de `common` en los textos del paquete\n */\nexport default function BarList({items, onSelect, emptyLabel, tone = 'primary', texts, defaultView = CHART_VIEW.chart, onViewChange}) {\n const [asTable, setAsTable] = useState(defaultView === CHART_VIEW.table);\n const toggleView = () => {\n setAsTable(!asTable);\n onViewChange?.(asTable ? CHART_VIEW.chart : CHART_VIEW.table);\n };\n const colors = useChartColors();\n const {formatNumber} = useFormatters();\n\n // guard clause: sin datos se dice, no se pinta un eje vacío\n if (!items.length) {\n return <Typography variant=\"body2\" color=\"text.secondary\">{emptyLabel}</Typography>;\n }\n\n // lo más largo de la etiqueta decide el ancho del eje: sin esto el nombre se corta o sobra medio contenedor\n // OJO: String(... ?? '') porque un renglón sin nombre (catálogo dado de baja) tumbaba toda la gráfica\n // OJO: 220 px de tope. Con 160 se cortaban etiquetas largas («Cuenta pendiente de activar») sin puntos suspensivos\n // ni forma de leerlas; el tooltip de la barra sigue mostrando el texto completo\n const labelWidth = Math.min(220, 16 + Math.max(...items.map((item) => String(item.label ?? '').length)) * 7);\n const longestValue = Math.max(...items.map((item) => `${formatNumber(item.value)} ${item.detail ?? ''}`.length));\n\n return (\n <Box>\n <TableToggle asTable={asTable} onToggle={toggleView} texts={texts} />\n {asTable ? (\n <Table size=\"small\">\n <TableBody>\n {items.map((item) => (\n <TableRow key={item.key} hover={Boolean(onSelect)} onClick={onSelect ? () => onSelect(item) : undefined}\n sx={{cursor: onSelect ? 'pointer' : 'default'}}>\n <TableCell>{item.label}</TableCell>\n <TableCell align=\"right\">{formatNumber(item.value)} {item.detail}</TableCell>\n </TableRow>\n ))}\n </TableBody>\n </Table>\n ) : (\n <Box sx={{height: items.length * ROW_HEIGHT_PIXELS, color: `${tone}.main`}}>\n <ResponsiveContainer width=\"100%\" height=\"100%\">\n <BarChart data={items} layout=\"vertical\" margin={{top: 0, bottom: 0, left: 0, right: 16 + longestValue * 7}}>\n {/* OJO: con todo en 0 el dominio [0, 0] manda el 0 a la MITAD del eje (escala degenerada de d3) y la\n barra de 1 px con su «0 de 2» saldría a medio renglón; el tope mínimo de 1 lo deja en el origen */}\n <XAxis type=\"number\" hide domain={[0, (dataMax) => Math.max(dataMax, 1)]} />\n <YAxis type=\"category\" dataKey=\"label\" width={labelWidth} tickLine={false} axisLine={false}\n tick={{fill: colors.text, fontSize: 13}} />\n <Tooltip cursor={{fill: colors.hover}}\n content={<ChartTooltip render={(item) => item.tooltip ?? `${item.label}: ${formatNumber(item.value)}`} />} />\n <Bar dataKey=\"value\" fill=\"currentColor\" maxBarSize={16} radius={[0, 4, 4, 0]} isAnimationActive={false}\n minPointSize={BAR_MIN_POINT_SIZE} cursor={onSelect ? 'pointer' : 'default'}\n onClick={onSelect ? (entry) => onSelect(entry.payload) : undefined}>\n {/* OJO: SIN dataKey; con dataKey LabelList ignora valueAccessor y regresa el índice corrido */}\n <LabelList valueAccessor={barLabelValueOf} content={(labelProps) => <ValueLabel {...labelProps} colors={colors} formatNumber={formatNumber} />} />\n </Bar>\n </BarChart>\n </ResponsiveContainer>\n </Box>\n )}\n </Box>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AA0BA,MAAM,oBAAoB;AAM1B,SAAS,WAAW,EAAC,GAAG,GAAG,OAAO,QAAQ,OAAO,QAAQ,gBAAe;AACpE,SACI,qBAAC,QAAA,EAAK,GAAG,IAAI,QAAQ,GAAG,GAAG,IAAI,SAAS,GAAG,kBAAiB,WAAU,UAAU,IAC5E,UAAA;AAAA,IAAA,oBAAC,SAAA,EAAM,MAAM,OAAO,MAAM,YAAY,KAAM,UAAA,aAAa,MAAM,KAAK,EAAA,CAAE;AAAA,IACrE,MAAM,UAAU,oBAAC,SAAA,EAAM,MAAM,OAAO,OAAO,UAAU,IAAK,UAAA,IAAI,MAAM,MAAM,GAAA,CAAG;AAAA,EAAA,GAClF;AAER;AAYA,SAAwB,QAAQ,EAAC,OAAO,UAAU,YAAY,OAAO,WAAW,OAAO,cAAc,WAAW,OAAO,aAAA,GAAe;AAClI,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,gBAAgB,WAAW,KAAK;AACvE,QAAM,aAAa,MAAM;AACrB,eAAW,CAAC,OAAO;AACnB,mBAAe,UAAU,WAAW,QAAQ,WAAW,KAAK;AAAA,EAChE;AACA,QAAM,SAAS,eAAA;AACf,QAAM,EAAC,aAAA,IAAgB,cAAA;AAGvB,MAAI,CAAC,MAAM,QAAQ;AACf,+BAA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AAAA,MAAA,oBAAC,OAAA,EAAM,MAAK,UAAS,MAAI,MAAC,QAAQ,CAAC,GAAG,CAAC,YAAY,KAAK,IAAI,SAAS,CAAC,CAAC,GAAG;AAAA,MAC1E;AAAA,QAAC;AAAA,QAAA;AAAA,UAAM,MAAK;AAAA,UAAW,SAAQ;AAAA,UAAQ,OAAO;AAAA,UAAY,UAAU;AAAA,UAAO,UAAU;AAAA,UAC9E,MAAM,EAAC,MAAM,OAAO,MAAM,UAAU,GAAA;AAAA,QAAE;AAAA,MAAA;AAAA,MAC7C;AAAA,QAAC;AAAA,QAAA;AAAA,UAAQ,QAAQ,EAAC,MAAM,OAAO,MAAA;AAAA,UACtB,SAAS,oBAAC,cAAA,EAAa,QAAQ,CAAC,SAAS,KAAK,WAAW,GAAG,KAAK,KAAK,KAAK,aAAa,KAAK,KAAK,CAAC,GAAA,CAAI;AAAA,QAAA;AAAA,MAAA;AAAA,MAChH;AAAA,QAAC;AAAA,QAAA;AAAA,UAAI,SAAQ;AAAA,UAAQ,MAAK;AAAA,UAAe,YAAY;AAAA,UAAI,QAAQ,CAAC,GAAG,GAAG,GAAG,CAAC;AAAA,UAAG,mBAAmB;AAAA,UAC7F,cAAc;AAAA,UAAoB,QAAQ,WAAW,YAAY;AAAA,UACjE,SAAS,WAAW,CAAC,UAAU,SAAS,MAAM,OAAO,IAAI;AAAA,UAE1D,UAAA,oBAAC,WAAA,EAAU,eAAe,iBAAiB,SAAS,CAAC,eAAe,oBAAC,YAAA,EAAY,GAAG,YAAY,QAAgB,cAA4B,EAAA,CAAI;AAAA,QAAA;AAAA,MAAA;AAAA,IACpJ,EAAA,CACJ,GACJ,EAAA,CACJ;AAAA,EAAA,GAER;AAER;"}
|
|
@@ -11,9 +11,9 @@ import TableHead from "@mui/material/TableHead";
|
|
|
11
11
|
import TableRow from "@mui/material/TableRow";
|
|
12
12
|
import Tooltip from "@mui/material/Tooltip";
|
|
13
13
|
import Typography from "@mui/material/Typography";
|
|
14
|
-
import {
|
|
14
|
+
import { useFormatters } from "../../toolkit/useFormatters.js";
|
|
15
15
|
import { calendarWeeksOf, levelOf, HEATMAP_LEVELS } from "./heatmapScale.js";
|
|
16
|
-
import TableToggle from "./TableToggle.js";
|
|
16
|
+
import TableToggle, { CHART_VIEW } from "./TableToggle.js";
|
|
17
17
|
const CELL_PIXELS = { xs: 12, md: 16 };
|
|
18
18
|
const GAP_PIXELS = 3;
|
|
19
19
|
const LABELED_WEEKDAYS = /* @__PURE__ */ new Set([1, 3, 5]);
|
|
@@ -25,15 +25,20 @@ function levelFill(theme, tone, level) {
|
|
|
25
25
|
}
|
|
26
26
|
return `color-mix(in srgb, ${palette[tone].main} ${LEVEL_TONE_PERCENT[level]}%, transparent)`;
|
|
27
27
|
}
|
|
28
|
-
function CalendarHeatmap({ startsOn, endsOn, days, ariaLabel, valueLabel, describeValue, summary, emptyLabel, tone = "primary" }) {
|
|
29
|
-
const { t } = useToolkitTranslation("common");
|
|
30
|
-
const
|
|
28
|
+
function CalendarHeatmap({ startsOn, endsOn, days, ariaLabel, valueLabel, describeValue, summary, emptyLabel, tone = "primary", texts, defaultView = CHART_VIEW.chart, onViewChange }) {
|
|
29
|
+
const { t } = useToolkitTranslation("common", texts);
|
|
30
|
+
const { formatDate, formatMonthShortName, formatNumber, formatWeekdayShortName } = useFormatters();
|
|
31
|
+
const [asTable, setAsTable] = useState(defaultView === CHART_VIEW.table);
|
|
32
|
+
const toggleView = () => {
|
|
33
|
+
setAsTable(!asTable);
|
|
34
|
+
onViewChange?.(asTable ? CHART_VIEW.chart : CHART_VIEW.table);
|
|
35
|
+
};
|
|
31
36
|
const { weeks, monthMarks, thresholds } = useMemo(() => calendarWeeksOf({ startsOn, endsOn, days }), [startsOn, endsOn, days]);
|
|
32
37
|
const activeDays = days.filter((day) => day.value > 0);
|
|
33
38
|
return /* @__PURE__ */ jsxs(Box, { children: [
|
|
34
39
|
/* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 2, sx: { justifyContent: "space-between", alignItems: "center", mb: 1 }, children: [
|
|
35
40
|
/* @__PURE__ */ jsx(Typography, { variant: "body2", color: "text.secondary", children: activeDays.length ? summary : emptyLabel }),
|
|
36
|
-
/* @__PURE__ */ jsx(Box, { sx: { flexShrink: 0 }, children: /* @__PURE__ */ jsx(TableToggle, { asTable, onToggle:
|
|
41
|
+
/* @__PURE__ */ jsx(Box, { sx: { flexShrink: 0 }, children: /* @__PURE__ */ jsx(TableToggle, { asTable, onToggle: toggleView, texts }) })
|
|
37
42
|
] }),
|
|
38
43
|
asTable ? /* @__PURE__ */ jsx(Box, { sx: { maxHeight: 260, overflowY: "auto" }, children: /* @__PURE__ */ jsxs(Table, { size: "small", "aria-label": ariaLabel, children: [
|
|
39
44
|
/* @__PURE__ */ jsx(TableHead, { children: /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CalendarHeatmap.js","sources":["../../../src/ui/metrics/CalendarHeatmap.jsx"],"sourcesContent":["// Calendario de actividad: un cuadro por día, semanas en columnas (el de GitHub).\n//\n// Sirve para ver RITMO de un vistazo: qué días llegan cargas, si hubo semanas muertas, si la actividad crece. Las\n// reglas de visualización:\n// - es MAGNITUD, así que va un solo tono de claro a oscuro (el del tono que se pida), en cuatro niveles más \"sin\n// actividad\". Nunca un arcoíris. Se arma con color-mix sobre el color del tema (su variable CSS si el tema las usa),\n// sin hexadecimales: en modo oscuro los mismos niveles se ven sobre su propia superficie;\n// - los niveles se cortan por CUARTILES de los días con actividad (heatmapScale.js), no por valores fijos;\n// - leyenda \"Menos → Más\", tooltip por día con el número exacto (el color solo nunca dice cuánto) y VISTA DE TABLA\n// (para lector de pantalla, para quien no distingue el tono y para copiar los números).\n//\n// Sin librería a propósito: el Heatmap de MUI X Charts es de la edición Pro, que pide licencia.\n//\n// Textos por props y del paquete, y fechas con los formatos del paquete.\n//\n// Genérico del paquete: function (regla de la casa).\nimport {useMemo, useState} from 'react';\nimport {useToolkitTranslation} from '@/toolkit/useToolkitTranslation.js';\nimport Box from '@mui/material/Box';\nimport Stack from '@mui/material/Stack';\nimport Table from '@mui/material/Table';\nimport TableBody from '@mui/material/TableBody';\nimport TableCell from '@mui/material/TableCell';\nimport TableHead from '@mui/material/TableHead';\nimport TableRow from '@mui/material/TableRow';\nimport Tooltip from '@mui/material/Tooltip';\nimport Typography from '@mui/material/Typography';\n\nimport {formatDate, formatMonthShortName, formatNumber, formatWeekdayShortName} from '@/formatting.js';\nimport {HEATMAP_LEVELS, calendarWeeksOf, levelOf} from '@/ui/metrics/heatmapScale.js';\nimport TableToggle from '@/ui/metrics/TableToggle.jsx';\n\n// cuadros de 12 px en teléfono (el calendario se desliza) y de 16 px desde md, donde el panel ocupa todo el ancho\nconst CELL_PIXELS = {xs: 12, md: 16};\nconst GAP_PIXELS = 3;\n// solo lunes, miércoles y viernes llevan rótulo: los siete encimados no se leen a 12 px\nconst LABELED_WEEKDAYS = new Set([1, 3, 5]);\n// porcentaje del tono en cada nivel; el nivel 0 es el gris de \"hover\" del tema\nconst LEVEL_TONE_PERCENT = {1: 30, 2: 55, 3: 78, 4: 100};\n\n/**\n * Relleno de un nivel con los colores del tema.\n *\n * @param {object} theme tema de MUI (con o sin variables CSS)\n * @param {string} tone primary, info, success...\n * @param {number} level 0 a 4\n * @returns {string} color CSS\n */\nfunction levelFill(theme, tone, level) {\n // un tema con variables CSS las trae en theme.vars; el tema por omisión de MUI, solo en theme.palette\n const {palette} = theme.vars ?? theme;\n if (level === 0) {\n return palette.action.hover;\n }\n return `color-mix(in srgb, ${palette[tone].main} ${LEVEL_TONE_PERCENT[level]}%, transparent)`;\n}\n\n/**\n * @param {object} props\n * @param {string} props.startsOn primer día del rango (\"2025-09-16\"), fecha de calendario\n * @param {string} props.endsOn último día del rango (\"2026-09-15\")\n * @param {Array<{date: string, value: number, detail?: string}>} props.days solo los días con actividad; el resto vale\n * 0\n * @param {string} props.ariaLabel qué muestra el calendario, ya traducido\n * @param {string} props.valueLabel encabezado de la columna de valor en la tabla (\"Registros leídos\")\n * @param {(value: number) => string} props.describeValue el valor en palabras para el tooltip (\"120 registros leídos\")\n * @param {import('react').ReactNode} [props.summary] renglón de resumen arriba del calendario\n * @param {string} [props.emptyLabel] qué decir si ningún día tiene actividad\n * @param {'primary'|'info'|'success'|'warning'|'error'} [props.tone]\n */\nexport default function CalendarHeatmap({startsOn, endsOn, days, ariaLabel, valueLabel, describeValue, summary, emptyLabel, tone = 'primary'}) {\n const {t} = useToolkitTranslation('common');\n const [asTable, setAsTable] = useState(false);\n\n const {weeks, monthMarks, thresholds} = useMemo(() => calendarWeeksOf({startsOn, endsOn, days}), [startsOn, endsOn, days]);\n const activeDays = days.filter((day) => day.value > 0);\n\n return (\n <Box>\n <Stack direction=\"row\" spacing={2} sx={{justifyContent: 'space-between', alignItems: 'center', mb: 1}}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {activeDays.length ? summary : emptyLabel}\n </Typography>\n <Box sx={{flexShrink: 0}}>\n <TableToggle asTable={asTable} onToggle={() => setAsTable((current) => !current)} />\n </Box>\n </Stack>\n\n {asTable ? (\n <Box sx={{maxHeight: 260, overflowY: 'auto'}}>\n <Table size=\"small\" aria-label={ariaLabel}>\n <TableHead>\n <TableRow>\n <TableCell>{t('charts.day')}</TableCell>\n <TableCell align=\"right\">{valueLabel}</TableCell>\n <TableCell />\n </TableRow>\n </TableHead>\n <TableBody>\n {[...activeDays].reverse().map((day) => (\n <TableRow key={day.date}>\n <TableCell sx={{whiteSpace: 'nowrap'}}>{formatDate(day.date)}</TableCell>\n <TableCell align=\"right\" sx={{fontVariantNumeric: 'tabular-nums'}}>{formatNumber(day.value)}</TableCell>\n <TableCell sx={{color: 'text.secondary'}}>{day.detail}</TableCell>\n </TableRow>\n ))}\n </TableBody>\n </Table>\n </Box>\n ) : (\n // el calendario no se encoge: en pantallas angostas se desliza y arranca mostrando lo más reciente\n <Box sx={{overflowX: 'auto', pb: 0.5}}\n ref={(node) => {\n if (node) {\n node.scrollLeft = node.scrollWidth;\n }\n }}>\n <Box role=\"img\" aria-label={ariaLabel}\n sx={{\n display: 'inline-grid',\n gridTemplateColumns: {\n xs: `auto repeat(${weeks.length}, ${CELL_PIXELS.xs}px)`,\n md: `auto repeat(${weeks.length}, ${CELL_PIXELS.md}px)`,\n },\n columnGap: `${GAP_PIXELS}px`,\n rowGap: `${GAP_PIXELS}px`,\n alignItems: 'center',\n }}>\n <Box />\n {monthMarks.map((month, column) => (\n <Typography key={`month-${column}`} variant=\"caption\" color=\"text.secondary\"\n sx={{fontSize: 10, lineHeight: 1, whiteSpace: 'nowrap', overflow: 'visible', width: CELL_PIXELS}}>\n {month ? formatMonthShortName(month) : ''}\n </Typography>\n ))}\n {[1, 2, 3, 4, 5, 6, 7].map((isoWeekday) => (\n <Box key={`weekday-${isoWeekday}`} sx={{display: 'contents'}}>\n <Typography variant=\"caption\" color=\"text.secondary\"\n sx={{fontSize: 10, lineHeight: {xs: `${CELL_PIXELS.xs}px`, md: `${CELL_PIXELS.md}px`}, pr: 0.75}}>\n {LABELED_WEEKDAYS.has(isoWeekday) ? formatWeekdayShortName(isoWeekday) : ''}\n </Typography>\n {weeks.map((week, column) => {\n const day = week[isoWeekday - 1];\n if (!day) {\n return <Box key={`outside-${column}-${isoWeekday}`} />;\n }\n const level = levelOf(day.value, thresholds);\n return (\n <Tooltip key={day.date} arrow disableInteractive\n title={`${formatDate(day.date)}: ${describeValue(day.value)}${day.detail ? ` · ${day.detail}` : ''}`}>\n <Box sx={(theme) => ({width: CELL_PIXELS, height: CELL_PIXELS, borderRadius: '3px', bgcolor: levelFill(theme, tone, level)})} />\n </Tooltip>\n );\n })}\n </Box>\n ))}\n </Box>\n </Box>\n )}\n\n {!asTable && (\n <Stack direction=\"row\" spacing={0.5} sx={{alignItems: 'center', justifyContent: 'flex-end', mt: 1}} aria-hidden=\"true\">\n <Typography variant=\"caption\" color=\"text.secondary\" sx={{mr: 0.5}}>{t('charts.less')}</Typography>\n {HEATMAP_LEVELS.map((level) => (\n <Box key={level} sx={(theme) => ({width: CELL_PIXELS, height: CELL_PIXELS, borderRadius: '3px', bgcolor: levelFill(theme, tone, level)})} />\n ))}\n <Typography variant=\"caption\" color=\"text.secondary\" sx={{ml: 0.5}}>{t('charts.more')}</Typography>\n </Stack>\n )}\n </Box>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAiCA,MAAM,cAAc,EAAC,IAAI,IAAI,IAAI,GAAA;AACjC,MAAM,aAAa;AAEnB,MAAM,mBAAmB,oBAAI,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC;AAE1C,MAAM,qBAAqB,EAAC,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAA;AAUpD,SAAS,UAAU,OAAO,MAAM,OAAO;AAEnC,QAAM,EAAC,QAAA,IAAW,MAAM,QAAQ;AAChC,MAAI,UAAU,GAAG;AACb,WAAO,QAAQ,OAAO;AAAA,EAC1B;AACA,SAAO,sBAAsB,QAAQ,IAAI,EAAE,IAAI,IAAI,mBAAmB,KAAK,CAAC;AAChF;AAeA,SAAwB,gBAAgB,EAAC,UAAU,QAAQ,MAAM,WAAW,YAAY,eAAe,SAAS,YAAY,OAAO,UAAA,GAAY;AAC3I,QAAM,EAAC,EAAA,IAAK,sBAAsB,QAAQ;AAC1C,QAAM,CAAC,SAAS,UAAU,IAAI,SAAS,KAAK;AAE5C,QAAM,EAAC,OAAO,YAAY,eAAc,QAAQ,MAAM,gBAAgB,EAAC,UAAU,QAAQ,MAAK,GAAG,CAAC,UAAU,QAAQ,IAAI,CAAC;AACzH,QAAM,aAAa,KAAK,OAAO,CAAC,QAAQ,IAAI,QAAQ,CAAC;AAErD,8BACK,KAAA,EACG,UAAA;AAAA,IAAA,qBAAC,OAAA,EAAM,WAAU,OAAM,SAAS,GAAG,IAAI,EAAC,gBAAgB,iBAAiB,YAAY,UAAU,IAAI,KAC/F,UAAA;AAAA,MAAA,oBAAC,YAAA,EAAW,SAAQ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AAA,EAAA,CAC1F;AAAA,EAAA,GAER;AAER;"}
|
|
1
|
+
{"version":3,"file":"CalendarHeatmap.js","sources":["../../../src/ui/metrics/CalendarHeatmap.jsx"],"sourcesContent":["// Calendario de actividad: un cuadro por día, semanas en columnas (el de GitHub).\n//\n// Sirve para ver RITMO de un vistazo: qué días llegan cargas, si hubo semanas muertas, si la actividad crece. Las\n// reglas de visualización:\n// - es MAGNITUD, así que va un solo tono de claro a oscuro (el del tono que se pida), en cuatro niveles más \"sin\n// actividad\". Nunca un arcoíris. Se arma con color-mix sobre el color del tema (su variable CSS si el tema las usa),\n// sin hexadecimales: en modo oscuro los mismos niveles se ven sobre su propia superficie;\n// - los niveles se cortan por CUARTILES de los días con actividad (heatmapScale.js), no por valores fijos;\n// - leyenda \"Menos → Más\", tooltip por día con el número exacto (el color solo nunca dice cuánto) y VISTA DE TABLA\n// (para lector de pantalla, para quien no distingue el tono y para copiar los números).\n//\n// Sin librería a propósito: el Heatmap de MUI X Charts es de la edición Pro, que pide licencia.\n//\n// Textos por props y del paquete, y fechas con los formatos del paquete.\n//\n// Genérico del paquete: function (regla de la casa).\nimport {useMemo, useState} from 'react';\nimport {useToolkitTranslation} from '@/toolkit/useToolkitTranslation.js';\nimport Box from '@mui/material/Box';\nimport Stack from '@mui/material/Stack';\nimport Table from '@mui/material/Table';\nimport TableBody from '@mui/material/TableBody';\nimport TableCell from '@mui/material/TableCell';\nimport TableHead from '@mui/material/TableHead';\nimport TableRow from '@mui/material/TableRow';\nimport Tooltip from '@mui/material/Tooltip';\nimport Typography from '@mui/material/Typography';\n\nimport {useFormatters} from '@/toolkit/useFormatters.js';\nimport {HEATMAP_LEVELS, calendarWeeksOf, levelOf} from '@/ui/metrics/heatmapScale.js';\nimport TableToggle, {CHART_VIEW} from '@/ui/metrics/TableToggle.jsx';\n\n// cuadros de 12 px en teléfono (el calendario se desliza) y de 16 px desde md, donde el panel ocupa todo el ancho\nconst CELL_PIXELS = {xs: 12, md: 16};\nconst GAP_PIXELS = 3;\n// solo lunes, miércoles y viernes llevan rótulo: los siete encimados no se leen a 12 px\nconst LABELED_WEEKDAYS = new Set([1, 3, 5]);\n// porcentaje del tono en cada nivel; el nivel 0 es el gris de \"hover\" del tema\nconst LEVEL_TONE_PERCENT = {1: 30, 2: 55, 3: 78, 4: 100};\n\n/**\n * Relleno de un nivel con los colores del tema.\n *\n * @param {object} theme tema de MUI (con o sin variables CSS)\n * @param {string} tone primary, info, success...\n * @param {number} level 0 a 4\n * @returns {string} color CSS\n */\nfunction levelFill(theme, tone, level) {\n // un tema con variables CSS las trae en theme.vars; el tema por omisión de MUI, solo en theme.palette\n const {palette} = theme.vars ?? theme;\n if (level === 0) {\n return palette.action.hover;\n }\n return `color-mix(in srgb, ${palette[tone].main} ${LEVEL_TONE_PERCENT[level]}%, transparent)`;\n}\n\n/**\n * @param {object} props\n * @param {string} props.startsOn primer día del rango (\"2025-09-16\"), fecha de calendario\n * @param {string} props.endsOn último día del rango (\"2026-09-15\")\n * @param {Array<{date: string, value: number, detail?: string}>} props.days solo los días con actividad; el resto vale\n * 0\n * @param {string} props.ariaLabel qué muestra el calendario, ya traducido\n * @param {string} props.valueLabel encabezado de la columna de valor en la tabla (\"Registros leídos\")\n * @param {(value: number) => string} props.describeValue el valor en palabras para el tooltip (\"120 registros leídos\")\n * @param {import('react').ReactNode} [props.summary] renglón de resumen arriba del calendario\n * @param {string} [props.emptyLabel] qué decir si ningún día tiene actividad\n * @param {'primary'|'info'|'success'|'warning'|'error'} [props.tone]\n * @param {'chart'|'table'} [props.defaultView] cómo se ve al abrir (CHART_VIEW); por omisión dibujada\n * @param {(view: 'chart'|'table') => void} [props.onViewChange] la persona cambió a la tabla o a la gráfica\n * @param {object} [props.texts] los textos que cambian, con la forma de `common` en los textos del paquete\n */\nexport default function CalendarHeatmap({startsOn, endsOn, days, ariaLabel, valueLabel, describeValue, summary, emptyLabel, tone = 'primary', texts, defaultView = CHART_VIEW.chart, onViewChange}) {\n const {t} = useToolkitTranslation('common', texts);\n const {formatDate, formatMonthShortName, formatNumber, formatWeekdayShortName} = useFormatters();\n const [asTable, setAsTable] = useState(defaultView === CHART_VIEW.table);\n const toggleView = () => {\n setAsTable(!asTable);\n onViewChange?.(asTable ? CHART_VIEW.chart : CHART_VIEW.table);\n };\n\n const {weeks, monthMarks, thresholds} = useMemo(() => calendarWeeksOf({startsOn, endsOn, days}), [startsOn, endsOn, days]);\n const activeDays = days.filter((day) => day.value > 0);\n\n return (\n <Box>\n <Stack direction=\"row\" spacing={2} sx={{justifyContent: 'space-between', alignItems: 'center', mb: 1}}>\n <Typography variant=\"body2\" color=\"text.secondary\">\n {activeDays.length ? summary : emptyLabel}\n </Typography>\n <Box sx={{flexShrink: 0}}>\n <TableToggle asTable={asTable} onToggle={toggleView} texts={texts} />\n </Box>\n </Stack>\n\n {asTable ? (\n <Box sx={{maxHeight: 260, overflowY: 'auto'}}>\n <Table size=\"small\" aria-label={ariaLabel}>\n <TableHead>\n <TableRow>\n <TableCell>{t('charts.day')}</TableCell>\n <TableCell align=\"right\">{valueLabel}</TableCell>\n <TableCell />\n </TableRow>\n </TableHead>\n <TableBody>\n {[...activeDays].reverse().map((day) => (\n <TableRow key={day.date}>\n <TableCell sx={{whiteSpace: 'nowrap'}}>{formatDate(day.date)}</TableCell>\n <TableCell align=\"right\" sx={{fontVariantNumeric: 'tabular-nums'}}>{formatNumber(day.value)}</TableCell>\n <TableCell sx={{color: 'text.secondary'}}>{day.detail}</TableCell>\n </TableRow>\n ))}\n </TableBody>\n </Table>\n </Box>\n ) : (\n // el calendario no se encoge: en pantallas angostas se desliza y arranca mostrando lo más reciente\n <Box sx={{overflowX: 'auto', pb: 0.5}}\n ref={(node) => {\n if (node) {\n node.scrollLeft = node.scrollWidth;\n }\n }}>\n <Box role=\"img\" aria-label={ariaLabel}\n sx={{\n display: 'inline-grid',\n gridTemplateColumns: {\n xs: `auto repeat(${weeks.length}, ${CELL_PIXELS.xs}px)`,\n md: `auto repeat(${weeks.length}, ${CELL_PIXELS.md}px)`,\n },\n columnGap: `${GAP_PIXELS}px`,\n rowGap: `${GAP_PIXELS}px`,\n alignItems: 'center',\n }}>\n <Box />\n {monthMarks.map((month, column) => (\n <Typography key={`month-${column}`} variant=\"caption\" color=\"text.secondary\"\n sx={{fontSize: 10, lineHeight: 1, whiteSpace: 'nowrap', overflow: 'visible', width: CELL_PIXELS}}>\n {month ? formatMonthShortName(month) : ''}\n </Typography>\n ))}\n {[1, 2, 3, 4, 5, 6, 7].map((isoWeekday) => (\n <Box key={`weekday-${isoWeekday}`} sx={{display: 'contents'}}>\n <Typography variant=\"caption\" color=\"text.secondary\"\n sx={{fontSize: 10, lineHeight: {xs: `${CELL_PIXELS.xs}px`, md: `${CELL_PIXELS.md}px`}, pr: 0.75}}>\n {LABELED_WEEKDAYS.has(isoWeekday) ? formatWeekdayShortName(isoWeekday) : ''}\n </Typography>\n {weeks.map((week, column) => {\n const day = week[isoWeekday - 1];\n if (!day) {\n return <Box key={`outside-${column}-${isoWeekday}`} />;\n }\n const level = levelOf(day.value, thresholds);\n return (\n <Tooltip key={day.date} arrow disableInteractive\n title={`${formatDate(day.date)}: ${describeValue(day.value)}${day.detail ? ` · ${day.detail}` : ''}`}>\n <Box sx={(theme) => ({width: CELL_PIXELS, height: CELL_PIXELS, borderRadius: '3px', bgcolor: levelFill(theme, tone, level)})} />\n </Tooltip>\n );\n })}\n </Box>\n ))}\n </Box>\n </Box>\n )}\n\n {!asTable && (\n <Stack direction=\"row\" spacing={0.5} sx={{alignItems: 'center', justifyContent: 'flex-end', mt: 1}} aria-hidden=\"true\">\n <Typography variant=\"caption\" color=\"text.secondary\" sx={{mr: 0.5}}>{t('charts.less')}</Typography>\n {HEATMAP_LEVELS.map((level) => (\n <Box key={level} sx={(theme) => ({width: CELL_PIXELS, height: CELL_PIXELS, borderRadius: '3px', bgcolor: levelFill(theme, tone, level)})} />\n ))}\n <Typography variant=\"caption\" color=\"text.secondary\" sx={{ml: 0.5}}>{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,CAAE;AAAA,IAAA,EAAA,CAC1F;AAAA,EAAA,GAER;AAER;"}
|
|
@@ -8,7 +8,7 @@ function ChartTooltip({ active, payload, render }) {
|
|
|
8
8
|
if (!active || !payload?.length) {
|
|
9
9
|
return null;
|
|
10
10
|
}
|
|
11
|
-
return /* @__PURE__ */ jsx(Paper, { elevation: 3, sx: [{ px: 1.5, py: 1, pointerEvents: "none" }, (theme) => isGlassTheme(theme) ? glassStylesOf(theme, { opacity: CHART_TOOLTIP_OPACITY }) : {}], children: /* @__PURE__ */ jsx(Typography, { variant: "body2", children: render(payload[0].payload) }) });
|
|
11
|
+
return /* @__PURE__ */ jsx(Paper, { elevation: 3, sx: [{ px: 1.5, py: 1, pointerEvents: "none" }, (theme) => isGlassTheme(theme) ? glassStylesOf(theme, { opacity: CHART_TOOLTIP_OPACITY }) : {}], children: /* @__PURE__ */ jsx(Typography, { variant: "body2", component: "div", children: render(payload[0].payload) }) });
|
|
12
12
|
}
|
|
13
13
|
export {
|
|
14
14
|
ChartTooltip as default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ChartTooltip.js","sources":["../../../src/ui/metrics/ChartTooltip.jsx"],"sourcesContent":["// El tooltip de las gráficas de Recharts con el look de la app
|
|
1
|
+
{"version":3,"file":"ChartTooltip.js","sources":["../../../src/ui/metrics/ChartTooltip.jsx"],"sourcesContent":["// El tooltip de las gráficas de Recharts con el look de la app. Se exporta para las gráficas propias del proyecto con\n// recharts (una de pastel, una de área): <Tooltip content={<ChartTooltip render={(row) => …} />} />.\n//\n// El de Recharts trae su propio estilo (fondo blanco, borde gris); este usa el Paper del tema y habla igual que los\n// tooltips del resto de la app (y se voltea solo cuando llegue el modo oscuro). Con el vidrio del tema\n// (createToolkitTheme({glass: true})) es de vidrio: flota sobre la gráfica.\n//\n// Genérico del paquete: function (regla de la casa).\nimport Paper from '@mui/material/Paper';\nimport Typography from '@mui/material/Typography';\n\nimport {glassStylesOf, isGlassTheme} from '@/theme/glassSurface.js';\n\n// el vidrio del cuadrito, casi opaco (el material «grueso»): es para leer una cifra encima de la gráfica; con el vidrio de\n// los controles (60 %) se veía la barra de atrás a través del texto (lo reportaron)\nconst CHART_TOOLTIP_OPACITY = 0.92;\n\n/**\n * @param {{active?: boolean, payload?: Array<{payload: any}>, render: (item: any) => import('react').ReactNode}} props\n * active y payload los pone recharts; render recibe el renglón de data del punto o la columna\n */\nexport default function ChartTooltip({active, payload, render}) {\n // guard clause: Recharts lo monta siempre; solo se pinta sobre una barra\n if (!active || !payload?.length) {\n return null;\n }\n return (\n <Paper elevation={3} sx={[{px: 1.5, py: 1, pointerEvents: 'none'}, (theme) => (isGlassTheme(theme) ? glassStylesOf(theme, {opacity: CHART_TOOLTIP_OPACITY}) : {})]}>\n {/* div: el globo puede llevar varios renglones (una serie por renglón) */}\n <Typography variant=\"body2\" component=\"div\">{render(payload[0].payload)}</Typography>\n </Paper>\n );\n}\n"],"names":[],"mappings":";;;;;AAeA,MAAM,wBAAwB;AAM9B,SAAwB,aAAa,EAAC,QAAQ,SAAS,UAAS;AAE5D,MAAI,CAAC,UAAU,CAAC,SAAS,QAAQ;AAC7B,WAAO;AAAA,EACX;AACA,6BACK,OAAA,EAAM,WAAW,GAAG,IAAI,CAAC,EAAC,IAAI,KAAK,IAAI,GAAG,eAAe,UAAS,CAAC,UAAW,aAAa,KAAK,IAAI,cAAc,OAAO,EAAC,SAAS,sBAAA,CAAsB,IAAI,EAAG,GAE7J,UAAA,oBAAC,YAAA,EAAW,SAAQ,SAAQ,WAAU,OAAO,UAAA,OAAO,QAAQ,CAAC,EAAE,OAAO,GAAE,GAC5E;AAER;"}
|
|
@@ -1,66 +1,66 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useState } from "react";
|
|
4
4
|
import Box from "@mui/material/Box";
|
|
5
|
-
import Table from "@mui/material/Table";
|
|
6
|
-
import TableBody from "@mui/material/TableBody";
|
|
7
|
-
import TableCell from "@mui/material/TableCell";
|
|
8
|
-
import TableHead from "@mui/material/TableHead";
|
|
9
|
-
import TableRow from "@mui/material/TableRow";
|
|
10
5
|
import Typography from "@mui/material/Typography";
|
|
11
6
|
import { ResponsiveContainer, BarChart, CartesianGrid, XAxis, YAxis, Tooltip, ReferenceLine, Bar } from "recharts";
|
|
12
|
-
import {
|
|
7
|
+
import { useFormatters } from "../../toolkit/useFormatters.js";
|
|
8
|
+
import { useToolkitTranslation } from "../../toolkit/useToolkitTranslation.js";
|
|
13
9
|
import ChartTooltip from "./ChartTooltip.js";
|
|
14
|
-
import TableToggle from "./TableToggle.js";
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const AXIS_TEXT = { fill: AXIS_COLOR, fontSize: AXIS_FONT_PIXELS };
|
|
18
|
-
const AXIS_MINIMUM_WIDTH_PIXELS = 48;
|
|
19
|
-
const AXIS_PADDING_PIXELS = 16;
|
|
20
|
-
const AXIS_CHARACTER_PIXELS = 7;
|
|
21
|
-
const AXIS_EXTRA_CHARACTERS = 1;
|
|
22
|
-
const REFERENCE_SWATCH_PIXELS = 20;
|
|
23
|
-
function valueAxisWidthOf(highestValue, formatValue) {
|
|
24
|
-
const longestLabel = formatValue(highestValue).length + AXIS_EXTRA_CHARACTERS;
|
|
25
|
-
return Math.max(AXIS_MINIMUM_WIDTH_PIXELS, AXIS_PADDING_PIXELS + longestLabel * AXIS_CHARACTER_PIXELS);
|
|
26
|
-
}
|
|
10
|
+
import TableToggle, { CHART_VIEW } from "./TableToggle.js";
|
|
11
|
+
import { useChartColors, resolvedSeriesOf, highestValueOf, ChartTable, valueAxisWidthOf, ChartLegend, ReferenceCaption } from "./chartParts.js";
|
|
12
|
+
const SINGLE_SERIES_KEY = "value";
|
|
27
13
|
function ColumnChart({
|
|
28
14
|
data,
|
|
29
15
|
periodLabel,
|
|
30
16
|
valueLabel,
|
|
17
|
+
series,
|
|
31
18
|
ariaLabel,
|
|
32
19
|
emptyLabel,
|
|
33
20
|
height = 220,
|
|
34
21
|
tone = "primary",
|
|
35
22
|
onSelect,
|
|
36
|
-
formatValue
|
|
37
|
-
referenceLine
|
|
23
|
+
formatValue: formatValueProp,
|
|
24
|
+
referenceLine,
|
|
25
|
+
renderTooltip,
|
|
26
|
+
texts,
|
|
27
|
+
defaultView = CHART_VIEW.chart,
|
|
28
|
+
onViewChange
|
|
38
29
|
}) {
|
|
39
|
-
const
|
|
30
|
+
const { t } = useToolkitTranslation("common", texts);
|
|
31
|
+
const { formatNumber } = useFormatters();
|
|
32
|
+
const formatValue = formatValueProp ?? formatNumber;
|
|
33
|
+
const [asTable, setAsTable] = useState(defaultView === CHART_VIEW.table);
|
|
34
|
+
const toggleView = () => {
|
|
35
|
+
setAsTable(!asTable);
|
|
36
|
+
onViewChange?.(asTable ? CHART_VIEW.chart : CHART_VIEW.table);
|
|
37
|
+
};
|
|
38
|
+
const isSingleSeries = !series?.length;
|
|
39
|
+
const colors = useChartColors();
|
|
40
|
+
const drawnSeries = resolvedSeriesOf(isSingleSeries ? [{ key: SINGLE_SERIES_KEY, label: valueLabel, tone }] : series, colors.palette);
|
|
40
41
|
if (!data.length) {
|
|
41
42
|
return /* @__PURE__ */ jsx(Typography, { variant: "body2", color: "text.secondary", children: emptyLabel });
|
|
42
43
|
}
|
|
43
|
-
const highestValue =
|
|
44
|
+
const highestValue = highestValueOf(data, drawnSeries, referenceLine);
|
|
45
|
+
const tooltipOf = renderTooltip ?? ((row) => isSingleSeries ? row.tooltip ?? `${row.label}: ${formatValue(row.value)}` : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
46
|
+
/* @__PURE__ */ jsx("strong", { children: row.label }),
|
|
47
|
+
drawnSeries.map((item) => /* @__PURE__ */ jsxs(Box, { children: [
|
|
48
|
+
item.label,
|
|
49
|
+
": ",
|
|
50
|
+
formatValue(row[item.key])
|
|
51
|
+
] }, item.key))
|
|
52
|
+
] }));
|
|
44
53
|
return /* @__PURE__ */ jsxs(Box, { children: [
|
|
45
|
-
/* @__PURE__ */ jsx(TableToggle, { asTable, onToggle:
|
|
46
|
-
asTable ? /* @__PURE__ */ jsx(Box, { sx: {
|
|
47
|
-
/* @__PURE__ */ jsx(
|
|
48
|
-
/* @__PURE__ */ jsx(TableCell, { children: periodLabel }),
|
|
49
|
-
/* @__PURE__ */ jsx(TableCell, { align: "right", children: valueLabel })
|
|
50
|
-
] }) }),
|
|
51
|
-
/* @__PURE__ */ jsx(TableBody, { children: data.map((item) => /* @__PURE__ */ jsxs(TableRow, { children: [
|
|
52
|
-
/* @__PURE__ */ jsx(TableCell, { children: item.label }),
|
|
53
|
-
/* @__PURE__ */ jsx(TableCell, { align: "right", children: formatValue(item.value) })
|
|
54
|
-
] }, item.key)) })
|
|
55
|
-
] }) }) : /* @__PURE__ */ jsx(Box, { role: "img", "aria-label": ariaLabel, sx: { height, color: `${tone}.main` }, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(BarChart, { data, margin: { top: 8, right: 8, bottom: 0, left: -8 }, barCategoryGap: 4, children: [
|
|
56
|
-
/* @__PURE__ */ jsx(CartesianGrid, { vertical: false, stroke: "var(--mui-palette-divider)" }),
|
|
54
|
+
/* @__PURE__ */ jsx(TableToggle, { asTable, onToggle: toggleView, texts }),
|
|
55
|
+
asTable ? /* @__PURE__ */ jsx(ChartTable, { data, series: drawnSeries, periodLabel, formatValue, height }) : /* @__PURE__ */ jsx(Box, { role: "img", "aria-label": ariaLabel, sx: { height, color: `${tone}.main` }, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(BarChart, { data, margin: { top: 8, right: 8, bottom: 0, left: -8 }, barCategoryGap: 4, children: [
|
|
56
|
+
/* @__PURE__ */ jsx(CartesianGrid, { vertical: false, stroke: colors.grid }),
|
|
57
57
|
/* @__PURE__ */ jsx(
|
|
58
58
|
XAxis,
|
|
59
59
|
{
|
|
60
60
|
dataKey: "label",
|
|
61
|
-
tick:
|
|
61
|
+
tick: colors.axisText,
|
|
62
62
|
tickLine: false,
|
|
63
|
-
axisLine: { stroke:
|
|
63
|
+
axisLine: { stroke: colors.grid },
|
|
64
64
|
interval: "preserveStartEnd",
|
|
65
65
|
minTickGap: 12
|
|
66
66
|
}
|
|
@@ -69,39 +69,35 @@ function ColumnChart({
|
|
|
69
69
|
YAxis,
|
|
70
70
|
{
|
|
71
71
|
allowDecimals: false,
|
|
72
|
-
tick:
|
|
72
|
+
tick: colors.axisText,
|
|
73
73
|
tickLine: false,
|
|
74
74
|
axisLine: false,
|
|
75
75
|
width: valueAxisWidthOf(highestValue, formatValue),
|
|
76
76
|
tickFormatter: (value) => formatValue(value)
|
|
77
77
|
}
|
|
78
78
|
),
|
|
79
|
-
/* @__PURE__ */ jsx(
|
|
80
|
-
Tooltip,
|
|
81
|
-
{
|
|
82
|
-
cursor: { fill: "var(--mui-palette-action-hover)" },
|
|
83
|
-
content: /* @__PURE__ */ jsx(ChartTooltip, { render: (item) => item.tooltip ?? `${item.label}: ${formatValue(item.value)}` })
|
|
84
|
-
}
|
|
85
|
-
),
|
|
79
|
+
/* @__PURE__ */ jsx(Tooltip, { cursor: { fill: colors.hover }, content: /* @__PURE__ */ jsx(ChartTooltip, { render: tooltipOf }) }),
|
|
86
80
|
referenceLine && // extendDomain: si la referencia queda arriba de todas las columnas, el eje crece hasta ella
|
|
87
|
-
/* @__PURE__ */ jsx(ReferenceLine, { y: referenceLine.value, ifOverflow: "extendDomain", stroke:
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
81
|
+
/* @__PURE__ */ jsx(ReferenceLine, { y: referenceLine.value, ifOverflow: "extendDomain", stroke: colors.axis, strokeDasharray: "4 4" }),
|
|
82
|
+
drawnSeries.map((item) => (
|
|
83
|
+
// una serie: currentColor (el tono de la caja); varias: el color de cada una
|
|
84
|
+
/* @__PURE__ */ jsx(
|
|
85
|
+
Bar,
|
|
86
|
+
{
|
|
87
|
+
dataKey: item.key,
|
|
88
|
+
fill: isSingleSeries ? "currentColor" : item.color,
|
|
89
|
+
maxBarSize: 28,
|
|
90
|
+
radius: [4, 4, 0, 0],
|
|
91
|
+
isAnimationActive: false,
|
|
92
|
+
cursor: onSelect ? "pointer" : "default",
|
|
93
|
+
onClick: onSelect ? (entry) => onSelect(entry.payload, item.key) : void 0
|
|
94
|
+
},
|
|
95
|
+
item.key
|
|
96
|
+
)
|
|
97
|
+
))
|
|
100
98
|
] }) }) }),
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
/* @__PURE__ */ jsx(Typography, { variant: "caption", color: "text.secondary", children: referenceLine.label })
|
|
104
|
-
] })
|
|
99
|
+
/* @__PURE__ */ jsx(ChartLegend, { series: drawnSeries, ariaLabel: t("charts.legend") }),
|
|
100
|
+
/* @__PURE__ */ jsx(ReferenceCaption, { referenceLine })
|
|
105
101
|
] });
|
|
106
102
|
}
|
|
107
103
|
export {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ColumnChart.js","sources":["../../../src/ui/metrics/ColumnChart.jsx"],"sourcesContent":["// Columnas de UNA serie a lo largo del tiempo (p. ej. registros leídos por mes), dibujadas con Recharts.\n//\n// Recharts y no SVG a mano: ejes, escalas, rótulos que no se encimen y el tooltip ya los resolvió la librería. Lo que se\n// decide aquí son las reglas de visualización:\n// - una serie → un color (el del tono vía currentColor) y SIN leyenda: el título ya dice qué es;\n// - columnas de 28 px como máximo, punta redondeada, base cuadrada;\n// - rejilla horizontal de 1 px, sólida y recesiva; el texto de los ejes en tinta secundaria;\n// - tooltip por columna y VISTA DE TABLA;\n// - una línea de referencia opcional (p. ej. la meta), punteada y en tinta secundaria: se lee sin competir con las\n// columnas, y el eje crece lo necesario para que siempre se vea. Su rótulo va debajo de la gráfica y no sobre la\n// línea, donde se encimaba con la columna del último mes; así también lo lee quien ve la tabla.\n//\n// El valor se escribe con formatValue (por omisión, número con separador de miles): con él una serie puede ir en\n// porcentaje. El eje mide lo que mide su número más largo, para que «2,500,000» no salga cortado.\n//\n// Genérico del paquete: function (regla de la casa).\nimport {useState} from 'react';\nimport Box from '@mui/material/Box';\nimport Table from '@mui/material/Table';\nimport TableBody from '@mui/material/TableBody';\nimport TableCell from '@mui/material/TableCell';\nimport TableHead from '@mui/material/TableHead';\nimport TableRow from '@mui/material/TableRow';\nimport Typography from '@mui/material/Typography';\nimport {Bar, BarChart, CartesianGrid, ReferenceLine, ResponsiveContainer, Tooltip, XAxis, YAxis} from 'recharts';\n\nimport {formatNumber} from '@/formatting.js';\nimport ChartTooltip from '@/ui/metrics/ChartTooltip.jsx';\nimport TableToggle from '@/ui/metrics/TableToggle.jsx';\n\nconst AXIS_COLOR = 'var(--mui-palette-text-secondary)';\nconst AXIS_FONT_PIXELS = 12;\nconst AXIS_TEXT = {fill: AXIS_COLOR, fontSize: AXIS_FONT_PIXELS};\n// ancho del eje de valores: nunca menos que esto, más lo que pida su número más largo\nconst AXIS_MINIMUM_WIDTH_PIXELS = 48;\nconst AXIS_PADDING_PIXELS = 16;\n// ancho aproximado de un carácter del eje a 12 px\nconst AXIS_CHARACTER_PIXELS = 7;\n// la marca más alta del eje suele pasar del valor más alto y puede llevar un carácter más (999,999 → 1,000,000)\nconst AXIS_EXTRA_CHARACTERS = 1;\n// largo de la muestra punteada que acompaña al rótulo de la línea de referencia\nconst REFERENCE_SWATCH_PIXELS = 20;\n\n/**\n * Ancho del eje de valores para que quepa su número más largo.\n *\n * @param {number} highestValue el valor más alto que se dibuja\n * @param {(value: number) => string} formatValue cómo se escribe un valor\n * @returns {number} pixeles\n */\nfunction valueAxisWidthOf(highestValue, formatValue) {\n const longestLabel = formatValue(highestValue).length + AXIS_EXTRA_CHARACTERS;\n return Math.max(AXIS_MINIMUM_WIDTH_PIXELS, AXIS_PADDING_PIXELS + longestLabel * AXIS_CHARACTER_PIXELS);\n}\n\n/**\n * @param {object} props\n * @param {Array<{key: string, value: number, label: string, tooltip?: string}>} props.data\n * @param {string} props.periodLabel encabezado de la primera columna de la tabla («Mes»), ya traducido\n * @param {string} props.valueLabel cómo se llama lo que se cuenta, ya traducido\n * @param {string} props.ariaLabel\n * @param {string} props.emptyLabel\n * @param {number} [props.height]\n * @param {'primary'|'success'|'warning'|'error'|'info'} [props.tone]\n * @param {(item: any) => void} [props.onSelect] recibe el renglón de data que se picó\n * @param {(value: number) => string} [props.formatValue] cómo se escribe un valor (en el eje, en la tabla y en el\n * tooltip)\n * @param {{value: number, label: string}} [props.referenceLine] línea de referencia con su rótulo ya traducido («Meta:\n * 10 %»)\n */\nexport default function ColumnChart({\n data, periodLabel, valueLabel, ariaLabel, emptyLabel, height = 220, tone = 'primary', onSelect, formatValue = formatNumber, referenceLine,\n}) {\n const [asTable, setAsTable] = useState(false);\n\n // guard clause: sin datos se dice, no se pinta un eje vacío\n if (!data.length) {\n return <Typography variant=\"body2\" color=\"text.secondary\">{emptyLabel}</Typography>;\n }\n\n // el valor más alto que se dibuja (el de las columnas o el de la línea de referencia) decide el ancho del eje\n const highestValue = Math.max(...data.map((item) => item.value), referenceLine?.value ?? 0);\n\n return (\n <Box>\n <TableToggle asTable={asTable} onToggle={() => setAsTable((current) => !current)} />\n {asTable ? (\n <Box sx={{maxHeight: height, overflowY: 'auto'}}>\n <Table size=\"small\">\n <TableHead>\n <TableRow><TableCell>{periodLabel}</TableCell><TableCell align=\"right\">{valueLabel}</TableCell></TableRow>\n </TableHead>\n <TableBody>\n {data.map((item) => (\n <TableRow key={item.key}>\n <TableCell>{item.label}</TableCell>\n <TableCell align=\"right\">{formatValue(item.value)}</TableCell>\n </TableRow>\n ))}\n </TableBody>\n </Table>\n </Box>\n ) : (\n <Box role=\"img\" aria-label={ariaLabel} sx={{height, color: `${tone}.main`}}>\n <ResponsiveContainer width=\"100%\" height=\"100%\">\n <BarChart data={data} margin={{top: 8, right: 8, bottom: 0, left: -8}} barCategoryGap={4}>\n <CartesianGrid vertical={false} stroke=\"var(--mui-palette-divider)\" />\n <XAxis dataKey=\"label\" tick={AXIS_TEXT} tickLine={false} axisLine={{stroke: 'var(--mui-palette-divider)'}}\n interval=\"preserveStartEnd\" minTickGap={12} />\n <YAxis allowDecimals={false} tick={AXIS_TEXT} tickLine={false} axisLine={false}\n width={valueAxisWidthOf(highestValue, formatValue)} tickFormatter={(value) => formatValue(value)} />\n <Tooltip cursor={{fill: 'var(--mui-palette-action-hover)'}}\n content={<ChartTooltip render={(item) => item.tooltip ?? `${item.label}: ${formatValue(item.value)}`} />} />\n {referenceLine && (\n // extendDomain: si la referencia queda arriba de todas las columnas, el eje crece hasta ella\n <ReferenceLine y={referenceLine.value} ifOverflow=\"extendDomain\" stroke={AXIS_COLOR} strokeDasharray=\"4 4\" />\n )}\n <Bar dataKey=\"value\" fill=\"currentColor\" maxBarSize={28} radius={[4, 4, 0, 0]} isAnimationActive={false}\n cursor={onSelect ? 'pointer' : 'default'} onClick={onSelect ? (entry) => onSelect(entry.payload) : undefined} />\n </BarChart>\n </ResponsiveContainer>\n </Box>\n )}\n {referenceLine && (\n <Box sx={{display: 'flex', alignItems: 'center', justifyContent: 'flex-end', gap: 0.75, mt: 0.5}}>\n <Box aria-hidden=\"true\" sx={{width: REFERENCE_SWATCH_PIXELS, borderTop: '2px dashed', borderColor: 'text.secondary'}} />\n <Typography variant=\"caption\" color=\"text.secondary\">{referenceLine.label}</Typography>\n </Box>\n )}\n </Box>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AA8BA,MAAM,aAAa;AACnB,MAAM,mBAAmB;AACzB,MAAM,YAAY,EAAC,MAAM,YAAY,UAAU,iBAAA;AAE/C,MAAM,4BAA4B;AAClC,MAAM,sBAAsB;AAE5B,MAAM,wBAAwB;AAE9B,MAAM,wBAAwB;AAE9B,MAAM,0BAA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AAG,CAAC;AAAA,UAAG,mBAAmB;AAAA,UAC7F,QAAQ,WAAW,YAAY;AAAA,UAAW,SAAS,WAAW,CAAC,UAAU,SAAS,MAAM,OAAO,IAAI;AAAA,QAAA;AAAA,MAAA;AAAA,IAAW,EAAA,CACvH,GACJ,GACJ;AAAA,IAEH,iBACG,qBAAC,KAAA,EAAI,IAAI,EAAC,SAAS,QAAQ,YAAY,UAAU,gBAAgB,YAAY,KAAK,MAAM,IAAI,OACxF,UAAA;AAAA,MAAA,oBAAC,KAAA,EAAI,eAAY,QAAO,IAAI,EAAC,OAAO,yBAAyB,WAAW,cAAc,aAAa,iBAAA,EAAgB,CAAG;AAAA,0BACrH,YAAA,EAAW,SAAQ,WAAU,OAAM,kBAAkB,wBAAc,MAAA,CAAM;AAAA,IAAA,EAAA,CAC9E;AAAA,EAAA,GAER;AAER;"}
|
|
1
|
+
{"version":3,"file":"ColumnChart.js","sources":["../../../src/ui/metrics/ColumnChart.jsx"],"sourcesContent":["// Columnas a lo largo del tiempo (p. ej. registros leídos por mes), dibujadas con Recharts: una serie (data con `value`) o\n// varias agrupadas por periodo (`series`, cada una con su llave en data: ventas y devoluciones por mes).\n//\n// Recharts y no SVG a mano: ejes, escalas, rótulos que no se encimen y el tooltip ya los resolvió la librería. Lo que se\n// decide aquí son las reglas de visualización:\n// - una serie → un color (el del tono vía currentColor) y SIN leyenda: el título ya dice qué es; varias → cada una su color\n// y leyenda abajo (chartParts.jsx, lo que comparte con LineChart);\n// - columnas de 28 px como máximo, punta redondeada, base cuadrada;\n// - rejilla horizontal de 1 px, sólida y recesiva; el texto de los ejes en tinta secundaria;\n// - tooltip por columna y VISTA DE TABLA;\n// - una línea de referencia opcional (p. ej. la meta), punteada y en tinta secundaria: se lee sin competir con las\n// columnas, y el eje crece lo necesario para que siempre se vea. Su rótulo va debajo de la gráfica y no sobre la\n// línea, donde se encimaba con la columna del último mes; así también lo lee quien ve la tabla.\n//\n// El valor se escribe con formatValue (por omisión, número con separador de miles): con él una serie puede ir en\n// porcentaje. El eje mide lo que mide su número más largo, para que «2,500,000» no salga cortado.\n//\n// Genérico del paquete: function (regla de la casa).\nimport {useState} from 'react';\nimport Box from '@mui/material/Box';\nimport Typography from '@mui/material/Typography';\nimport {Bar, BarChart, CartesianGrid, ReferenceLine, ResponsiveContainer, Tooltip, XAxis, YAxis} from 'recharts';\n\nimport {useFormatters} from '@/toolkit/useFormatters.js';\nimport {useToolkitTranslation} from '@/toolkit/useToolkitTranslation.js';\nimport ChartTooltip from '@/ui/metrics/ChartTooltip.jsx';\nimport TableToggle, {CHART_VIEW} from '@/ui/metrics/TableToggle.jsx';\nimport {\n ChartLegend, ChartTable, ReferenceCaption, highestValueOf, resolvedSeriesOf, useChartColors, valueAxisWidthOf,\n} from '@/ui/metrics/chartParts.jsx';\n\n// la llave del valor cuando la gráfica es de una sola serie\nconst SINGLE_SERIES_KEY = 'value';\n\n/**\n * @param {object} props\n * @param {Array<Record<string, any>>} props.data un renglón por periodo: {key, label, value, tooltip?} con una serie, o\n * {key, label, [llave de cada serie]: número} con varias\n * @param {string} props.periodLabel encabezado de la primera columna de la tabla («Mes»), ya traducido\n * @param {string} [props.valueLabel] cómo se llama lo que se cuenta, ya traducido (una serie)\n * @param {Array<{key: string, label: string, tone?: 'primary'|'secondary'|'success'|'warning'|'error'|'info'}>} [props.series]\n * varias series agrupadas: la llave de cada una en data, su nombre ya traducido y su color (por omisión, en orden)\n * @param {string} props.ariaLabel\n * @param {string} props.emptyLabel\n * @param {number} [props.height]\n * @param {'primary'|'success'|'warning'|'error'|'info'} [props.tone] el color de una sola serie\n * @param {(item: any, seriesKey: string) => void} [props.onSelect] recibe el renglón de data que se picó y la serie\n * @param {(value: number) => string} [props.formatValue] cómo se escribe un valor (en el eje, en la tabla y en el\n * tooltip)\n * @param {{value: number, label: string}} [props.referenceLine] línea de referencia con su rótulo ya traducido («Meta:\n * 10 %»)\n * @param {(row: any) => import('react').ReactNode} [props.renderTooltip] lo que dice el globo de un periodo; por omisión su\n * nombre y el valor de cada serie\n * @param {'chart'|'table'} [props.defaultView] cómo se ve al abrir (CHART_VIEW); por omisión dibujada\n * @param {(view: 'chart'|'table') => void} [props.onViewChange] la persona cambió a la tabla o a la gráfica\n * @param {object} [props.texts] los textos que cambian, con la forma de `common`: {charts: {viewAsTable, viewAsChart, legend}}\n */\nexport default function ColumnChart({\n data, periodLabel, valueLabel, series, ariaLabel, emptyLabel, height = 220, tone = 'primary', onSelect, formatValue: formatValueProp,\n referenceLine, renderTooltip, texts, defaultView = CHART_VIEW.chart, onViewChange,\n}) {\n const {t} = useToolkitTranslation('common', texts);\n const {formatNumber} = useFormatters();\n const formatValue = formatValueProp ?? formatNumber;\n const [asTable, setAsTable] = useState(defaultView === CHART_VIEW.table);\n const toggleView = () => {\n setAsTable(!asTable);\n onViewChange?.(asTable ? CHART_VIEW.chart : CHART_VIEW.table);\n };\n const isSingleSeries = !series?.length;\n const colors = useChartColors();\n const drawnSeries = resolvedSeriesOf(isSingleSeries ? [{key: SINGLE_SERIES_KEY, label: valueLabel, tone}] : series, colors.palette);\n\n // guard clause: sin datos se dice, no se pinta un eje vacío\n if (!data.length) {\n return <Typography variant=\"body2\" color=\"text.secondary\">{emptyLabel}</Typography>;\n }\n\n // el valor más alto que se dibuja (el de las columnas o el de la línea de referencia) decide el ancho del eje\n const highestValue = highestValueOf(data, drawnSeries, referenceLine);\n const tooltipOf = renderTooltip ?? ((row) => (isSingleSeries\n ? row.tooltip ?? `${row.label}: ${formatValue(row.value)}`\n : (\n <>\n <strong>{row.label}</strong>\n {drawnSeries.map((item) => <Box key={item.key}>{item.label}: {formatValue(row[item.key])}</Box>)}\n </>\n )));\n\n return (\n <Box>\n <TableToggle asTable={asTable} onToggle={toggleView} texts={texts} />\n {asTable ? (\n <ChartTable data={data} series={drawnSeries} periodLabel={periodLabel} formatValue={formatValue} height={height} />\n ) : (\n <Box role=\"img\" aria-label={ariaLabel} sx={{height, color: `${tone}.main`}}>\n <ResponsiveContainer width=\"100%\" height=\"100%\">\n <BarChart data={data} margin={{top: 8, right: 8, bottom: 0, left: -8}} barCategoryGap={4}>\n <CartesianGrid vertical={false} stroke={colors.grid} />\n <XAxis dataKey=\"label\" tick={colors.axisText} tickLine={false} axisLine={{stroke: colors.grid}}\n interval=\"preserveStartEnd\" minTickGap={12} />\n <YAxis allowDecimals={false} tick={colors.axisText} tickLine={false} axisLine={false}\n width={valueAxisWidthOf(highestValue, formatValue)} tickFormatter={(value) => formatValue(value)} />\n <Tooltip cursor={{fill: colors.hover}} content={<ChartTooltip render={tooltipOf} />} />\n {referenceLine && (\n // extendDomain: si la referencia queda arriba de todas las columnas, el eje crece hasta ella\n <ReferenceLine y={referenceLine.value} ifOverflow=\"extendDomain\" stroke={colors.axis} strokeDasharray=\"4 4\" />\n )}\n {drawnSeries.map((item) => (\n // una serie: currentColor (el tono de la caja); varias: el color de cada una\n <Bar key={item.key} dataKey={item.key} fill={isSingleSeries ? 'currentColor' : item.color} maxBarSize={28}\n radius={[4, 4, 0, 0]} isAnimationActive={false} cursor={onSelect ? 'pointer' : 'default'}\n onClick={onSelect ? (entry) => onSelect(entry.payload, item.key) : undefined} />\n ))}\n </BarChart>\n </ResponsiveContainer>\n </Box>\n )}\n <ChartLegend series={drawnSeries} ariaLabel={t('charts.legend')} />\n <ReferenceCaption referenceLine={referenceLine} />\n </Box>\n );\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAgCA,MAAM,oBAAoB;AAyB1B,SAAwB,YAAY;AAAA,EAChC;AAAA,EAAM;AAAA,EAAa;AAAA,EAAY;AAAA,EAAQ;AAAA,EAAW;AAAA,EAAY,SAAS;AAAA,EAAK,OAAO;AAAA,EAAW;AAAA,EAAU,aAAa;AAAA,EACrH;AAAA,EAAe;AAAA,EAAe;AAAA,EAAO,cAAc,WAAW;AAAA,EAAO;AACzE,GAAG;AACC,QAAM,EAAC,EAAA,IAAK,sBAAsB,UAAU,KAAK;AACjD,QAAM,EAAC,aAAA,IAAgB,c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A,wBAEH,aAAA,EAAY,QAAQ,aAAa,WAAW,EAAE,eAAe,GAAG;AAAA,IACjE,oBAAC,oBAAiB,cAAA,CAA8B;AAAA,EAAA,GACpD;AAER;"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { useState } from "react";
|
|
4
|
+
import Box from "@mui/material/Box";
|
|
5
|
+
import Typography from "@mui/material/Typography";
|
|
6
|
+
import { ResponsiveContainer, LineChart as LineChart$1, CartesianGrid, XAxis, YAxis, Tooltip, ReferenceLine, Line } from "recharts";
|
|
7
|
+
import { useFormatters } from "../../toolkit/useFormatters.js";
|
|
8
|
+
import { useToolkitTranslation } from "../../toolkit/useToolkitTranslation.js";
|
|
9
|
+
import ChartTooltip from "./ChartTooltip.js";
|
|
10
|
+
import TableToggle, { CHART_VIEW } from "./TableToggle.js";
|
|
11
|
+
import { useChartColors, resolvedSeriesOf, highestValueOf, ChartTable, valueAxisWidthOf, ChartLegend, ReferenceCaption } from "./chartParts.js";
|
|
12
|
+
const LINE_WIDTH_PIXELS = 2;
|
|
13
|
+
const DOT_RADIUS_PIXELS = 3;
|
|
14
|
+
const ACTIVE_DOT_RADIUS_PIXELS = 5;
|
|
15
|
+
function LineChart({
|
|
16
|
+
data,
|
|
17
|
+
series,
|
|
18
|
+
periodLabel,
|
|
19
|
+
ariaLabel,
|
|
20
|
+
emptyLabel,
|
|
21
|
+
height = 220,
|
|
22
|
+
formatValue: formatValueProp,
|
|
23
|
+
referenceLine,
|
|
24
|
+
onSelect,
|
|
25
|
+
renderTooltip,
|
|
26
|
+
texts,
|
|
27
|
+
defaultView = CHART_VIEW.chart,
|
|
28
|
+
onViewChange
|
|
29
|
+
}) {
|
|
30
|
+
const { t } = useToolkitTranslation("common", texts);
|
|
31
|
+
const { formatNumber } = useFormatters();
|
|
32
|
+
const formatValue = formatValueProp ?? formatNumber;
|
|
33
|
+
const [asTable, setAsTable] = useState(defaultView === CHART_VIEW.table);
|
|
34
|
+
const toggleView = () => {
|
|
35
|
+
setAsTable(!asTable);
|
|
36
|
+
onViewChange?.(asTable ? CHART_VIEW.chart : CHART_VIEW.table);
|
|
37
|
+
};
|
|
38
|
+
const colors = useChartColors();
|
|
39
|
+
const drawnSeries = resolvedSeriesOf(series, colors.palette);
|
|
40
|
+
if (!data.length) {
|
|
41
|
+
return /* @__PURE__ */ jsx(Typography, { variant: "body2", color: "text.secondary", children: emptyLabel });
|
|
42
|
+
}
|
|
43
|
+
const highestValue = highestValueOf(data, drawnSeries, referenceLine);
|
|
44
|
+
const selectPeriodAt = (activeIndex) => {
|
|
45
|
+
const row = data[Number(activeIndex)];
|
|
46
|
+
if (row) {
|
|
47
|
+
onSelect(row);
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const tooltipOf = renderTooltip ?? ((row) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
51
|
+
/* @__PURE__ */ jsx("strong", { children: row.label }),
|
|
52
|
+
drawnSeries.map((item) => /* @__PURE__ */ jsxs(Box, { children: [
|
|
53
|
+
item.label,
|
|
54
|
+
": ",
|
|
55
|
+
formatValue(row[item.key])
|
|
56
|
+
] }, item.key))
|
|
57
|
+
] }));
|
|
58
|
+
return /* @__PURE__ */ jsxs(Box, { children: [
|
|
59
|
+
/* @__PURE__ */ jsx(TableToggle, { asTable, onToggle: toggleView, texts }),
|
|
60
|
+
asTable ? /* @__PURE__ */ jsx(ChartTable, { data, series: drawnSeries, periodLabel, formatValue, height }) : /* @__PURE__ */ jsx(Box, { role: "img", "aria-label": ariaLabel, sx: { height }, children: /* @__PURE__ */ jsx(ResponsiveContainer, { width: "100%", height: "100%", children: /* @__PURE__ */ jsxs(
|
|
61
|
+
LineChart$1,
|
|
62
|
+
{
|
|
63
|
+
data,
|
|
64
|
+
margin: { top: 8, right: 12, bottom: 0, left: -8 },
|
|
65
|
+
onClick: onSelect ? (state) => selectPeriodAt(state?.activeIndex) : void 0,
|
|
66
|
+
children: [
|
|
67
|
+
/* @__PURE__ */ jsx(CartesianGrid, { vertical: false, stroke: colors.grid }),
|
|
68
|
+
/* @__PURE__ */ jsx(
|
|
69
|
+
XAxis,
|
|
70
|
+
{
|
|
71
|
+
dataKey: "label",
|
|
72
|
+
tick: colors.axisText,
|
|
73
|
+
tickLine: false,
|
|
74
|
+
axisLine: { stroke: colors.grid },
|
|
75
|
+
interval: "preserveStartEnd",
|
|
76
|
+
minTickGap: 12
|
|
77
|
+
}
|
|
78
|
+
),
|
|
79
|
+
/* @__PURE__ */ jsx(
|
|
80
|
+
YAxis,
|
|
81
|
+
{
|
|
82
|
+
allowDecimals: false,
|
|
83
|
+
tick: colors.axisText,
|
|
84
|
+
tickLine: false,
|
|
85
|
+
axisLine: false,
|
|
86
|
+
width: valueAxisWidthOf(highestValue, formatValue),
|
|
87
|
+
tickFormatter: (value) => formatValue(value)
|
|
88
|
+
}
|
|
89
|
+
),
|
|
90
|
+
/* @__PURE__ */ jsx(Tooltip, { cursor: { stroke: colors.grid }, content: /* @__PURE__ */ jsx(ChartTooltip, { render: tooltipOf }) }),
|
|
91
|
+
referenceLine && /* @__PURE__ */ jsx(ReferenceLine, { y: referenceLine.value, ifOverflow: "extendDomain", stroke: colors.axis, strokeDasharray: "4 4" }),
|
|
92
|
+
drawnSeries.map((item) => /* @__PURE__ */ jsx(
|
|
93
|
+
Line,
|
|
94
|
+
{
|
|
95
|
+
type: "monotone",
|
|
96
|
+
dataKey: item.key,
|
|
97
|
+
name: item.label,
|
|
98
|
+
stroke: item.color,
|
|
99
|
+
strokeWidth: LINE_WIDTH_PIXELS,
|
|
100
|
+
strokeDasharray: item.dash,
|
|
101
|
+
isAnimationActive: false,
|
|
102
|
+
dot: { r: DOT_RADIUS_PIXELS, fill: item.color, strokeWidth: 0 },
|
|
103
|
+
activeDot: { r: ACTIVE_DOT_RADIUS_PIXELS, cursor: onSelect ? "pointer" : "default" }
|
|
104
|
+
},
|
|
105
|
+
item.key
|
|
106
|
+
))
|
|
107
|
+
]
|
|
108
|
+
}
|
|
109
|
+
) }) }),
|
|
110
|
+
/* @__PURE__ */ jsx(ChartLegend, { series: drawnSeries, showsDash: true, ariaLabel: t("charts.legend") }),
|
|
111
|
+
/* @__PURE__ */ jsx(ReferenceCaption, { referenceLine })
|
|
112
|
+
] });
|
|
113
|
+
}
|
|
114
|
+
export {
|
|
115
|
+
LineChart as default
|
|
116
|
+
};
|
|
117
|
+
//# sourceMappingURL=LineChart.js.map
|