@pagamio/frontend-commons-lib 0.8.175 → 0.8.183
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/lib/api/client.d.ts +88 -0
- package/lib/api/client.js +339 -0
- package/lib/api/context.d.ts +112 -0
- package/lib/api/context.js +105 -0
- package/lib/api/index.d.ts +4 -0
- package/lib/api/index.js +4 -0
- package/lib/api/swr.d.ts +46 -0
- package/lib/api/swr.js +124 -0
- package/lib/api/types.d.ts +145 -0
- package/lib/api/types.js +10 -0
- package/lib/auth/authenticators/AuthenticatorFactory.d.ts +25 -0
- package/lib/auth/authenticators/AuthenticatorFactory.js +32 -0
- package/lib/auth/authenticators/index.d.ts +7 -0
- package/lib/auth/authenticators/index.js +7 -0
- package/lib/auth/authenticators/processors/DefaultAuthenticatorProcessor.d.ts +21 -0
- package/lib/auth/authenticators/processors/DefaultAuthenticatorProcessor.js +26 -0
- package/lib/auth/authenticators/processors/StrapiAuthenticatorProcessor.d.ts +74 -0
- package/lib/auth/authenticators/processors/StrapiAuthenticatorProcessor.js +99 -0
- package/lib/auth/authenticators/types.d.ts +26 -0
- package/lib/auth/authenticators/types.js +9 -0
- package/lib/auth/components/AppBanner.d.ts +7 -0
- package/lib/auth/components/AppBanner.js +9 -0
- package/lib/auth/components/AuthCard.d.ts +8 -0
- package/lib/auth/components/AuthCard.js +14 -0
- package/lib/auth/components/AuthFormUtils.d.ts +58 -0
- package/lib/auth/components/AuthFormUtils.js +52 -0
- package/lib/auth/components/AuthPageLayout.d.ts +45 -0
- package/lib/auth/components/AuthPageLayout.js +12 -0
- package/lib/auth/components/ChangePasswordPage.d.ts +12 -0
- package/lib/auth/components/ChangePasswordPage.js +59 -0
- package/lib/auth/components/CustomerRegistrationPage.d.ts +50 -0
- package/lib/auth/components/CustomerRegistrationPage.js +140 -0
- package/lib/auth/components/ForgotPasswordPage.d.ts +38 -0
- package/lib/auth/components/ForgotPasswordPage.js +76 -0
- package/lib/auth/components/LoginPage.d.ts +73 -0
- package/lib/auth/components/LoginPage.js +115 -0
- package/lib/auth/components/LogoutButton.d.ts +30 -0
- package/lib/auth/components/LogoutButton.js +47 -0
- package/lib/auth/components/ResetPasswordPage.d.ts +42 -0
- package/lib/auth/components/ResetPasswordPage.js +88 -0
- package/lib/auth/components/hooks/useChangeUserPassword.d.ts +26 -0
- package/lib/auth/components/hooks/useChangeUserPassword.js +63 -0
- package/lib/auth/components/index.d.ts +8 -0
- package/lib/auth/components/index.js +7 -0
- package/lib/auth/context/AuthContext.d.ts +65 -0
- package/lib/auth/context/AuthContext.js +150 -0
- package/lib/auth/context/index.d.ts +1 -0
- package/lib/auth/context/index.js +1 -0
- package/lib/auth/index.d.ts +7 -0
- package/lib/auth/index.js +7 -0
- package/lib/auth/services/AuthService.d.ts +230 -0
- package/lib/auth/services/AuthService.js +475 -0
- package/lib/auth/services/LogoutService.d.ts +27 -0
- package/lib/auth/services/LogoutService.js +98 -0
- package/lib/auth/services/index.d.ts +2 -0
- package/lib/auth/services/index.js +2 -0
- package/lib/auth/shared/index.d.ts +1 -0
- package/lib/auth/shared/index.js +1 -0
- package/lib/auth/shared/layout/AuthPageLayout.d.ts +10 -0
- package/lib/auth/shared/layout/AuthPageLayout.js +16 -0
- package/lib/auth/shared/layout/index.d.ts +1 -0
- package/lib/auth/shared/layout/index.js +1 -0
- package/lib/auth/types/auth.types.d.ts +234 -0
- package/lib/auth/types/auth.types.js +14 -0
- package/lib/auth/types/index.d.ts +1 -0
- package/lib/auth/types/index.js +1 -0
- package/lib/auth/utils/TokenManager.d.ts +43 -0
- package/lib/auth/utils/TokenManager.js +171 -0
- package/lib/auth/utils/Transformers.d.ts +158 -0
- package/lib/auth/utils/Transformers.js +263 -0
- package/lib/auth/utils/errorDetection.d.ts +22 -0
- package/lib/auth/utils/errorDetection.js +190 -0
- package/lib/auth/utils/index.d.ts +3 -0
- package/lib/auth/utils/index.js +3 -0
- package/lib/components/charts/LineGraph.d.ts +15 -0
- package/lib/components/charts/LineGraph.js +131 -0
- package/lib/components/icons/Icon.d.ts +8 -0
- package/lib/components/icons/Icon.js +13 -0
- package/lib/components/icons/index.d.ts +2 -0
- package/lib/components/icons/index.js +2 -0
- package/lib/components/icons/types.d.ts +26 -0
- package/lib/components/icons/types.js +33 -0
- package/lib/components/index.d.ts +3 -0
- package/lib/components/index.js +3 -0
- package/lib/components/layout/AppLayout.d.ts +34 -0
- package/lib/components/layout/AppLayout.js +19 -0
- package/lib/components/layout/AuthPageLayout.d.ts +13 -0
- package/lib/components/layout/AuthPageLayout.js +15 -0
- package/lib/components/layout/BreadcrumbNav.d.ts +2 -0
- package/lib/components/layout/BreadcrumbNav.js +10 -0
- package/lib/components/layout/LayoutContent.d.ts +6 -0
- package/lib/components/layout/LayoutContent.js +10 -0
- package/lib/components/layout/Navbar.d.ts +106 -0
- package/lib/components/layout/Navbar.js +66 -0
- package/lib/components/layout/PageHeader.d.ts +8 -0
- package/lib/components/layout/PageHeader.js +7 -0
- package/lib/components/layout/SessionExpiryModal.d.ts +10 -0
- package/lib/components/layout/SessionExpiryModal.js +9 -0
- package/lib/components/layout/Sidebar.d.ts +6 -0
- package/lib/components/layout/Sidebar.js +87 -0
- package/lib/components/layout/VerticalTabsLayout.d.ts +12 -0
- package/lib/components/layout/VerticalTabsLayout.js +14 -0
- package/lib/components/layout/index.d.ts +9 -0
- package/lib/components/layout/index.js +9 -0
- package/lib/components/ui/Avatar.d.ts +6 -0
- package/lib/components/ui/Avatar.js +11 -0
- package/lib/components/ui/AvatarIcon.d.ts +4 -0
- package/lib/components/ui/AvatarIcon.js +6 -0
- package/lib/components/ui/Button.d.ts +14 -0
- package/lib/components/ui/Button.js +30 -0
- package/lib/components/ui/Calendar.d.ts +9 -0
- package/lib/components/ui/Calendar.js +35 -0
- package/lib/components/ui/Card.d.ts +16 -0
- package/lib/components/ui/Card.js +6 -0
- package/lib/components/ui/Chart.d.ts +2 -0
- package/lib/components/ui/Chart.js +16 -0
- package/lib/components/ui/Checkbox.d.ts +4 -0
- package/lib/components/ui/Checkbox.js +8 -0
- package/lib/components/ui/Command.d.ts +80 -0
- package/lib/components/ui/Command.js +28 -0
- package/lib/components/ui/ContainedTab.d.ts +21 -0
- package/lib/components/ui/ContainedTab.js +37 -0
- package/lib/components/ui/DateFormat.d.ts +6 -0
- package/lib/components/ui/DateFormat.js +8 -0
- package/lib/components/ui/DatePicker.d.ts +14 -0
- package/lib/components/ui/DatePicker.js +91 -0
- package/lib/components/ui/DateRangeModal.d.ts +38 -0
- package/lib/components/ui/DateRangeModal.js +89 -0
- package/lib/components/ui/DetailsCard.d.ts +16 -0
- package/lib/components/ui/DetailsCard.js +14 -0
- package/lib/components/ui/DetailsPage.d.ts +36 -0
- package/lib/components/ui/DetailsPage.js +50 -0
- package/lib/components/ui/Dialog.d.ts +19 -0
- package/lib/components/ui/Dialog.js +22 -0
- package/lib/components/ui/EmptyState.d.ts +6 -0
- package/lib/components/ui/EmptyState.js +6 -0
- package/lib/components/ui/FilterComponent.d.ts +30 -0
- package/lib/components/ui/FilterComponent.js +80 -0
- package/lib/components/ui/FilterList.d.ts +52 -0
- package/lib/components/ui/FilterList.js +62 -0
- package/lib/components/ui/FilterSection.d.ts +31 -0
- package/lib/components/ui/FilterSection.js +21 -0
- package/lib/components/ui/FilterWrapper.d.ts +6 -0
- package/lib/components/ui/FilterWrapper.js +7 -0
- package/lib/components/ui/Form.d.ts +23 -0
- package/lib/components/ui/Form.js +62 -0
- package/lib/components/ui/HoverableValue.d.ts +7 -0
- package/lib/components/ui/HoverableValue.js +8 -0
- package/lib/components/ui/IconButton.d.ts +10 -0
- package/lib/components/ui/IconButton.js +10 -0
- package/lib/components/ui/ImageComponent.d.ts +8 -0
- package/lib/components/ui/ImageComponent.js +5 -0
- package/lib/components/ui/ImageUploader.d.ts +17 -0
- package/lib/components/ui/ImageUploader.js +144 -0
- package/lib/components/ui/Input.d.ts +4 -0
- package/lib/components/ui/Input.js +8 -0
- package/lib/components/ui/Label.d.ts +5 -0
- package/lib/components/ui/Label.js +9 -0
- package/lib/components/ui/Loader.d.ts +10 -0
- package/lib/components/ui/Loader.js +7 -0
- package/lib/components/ui/Modal.d.ts +72 -0
- package/lib/components/ui/Modal.js +31 -0
- package/lib/components/ui/MultiSelect.d.ts +16 -0
- package/lib/components/ui/MultiSelect.js +59 -0
- package/lib/components/ui/NotificationModal.d.ts +18 -0
- package/lib/components/ui/NotificationModal.js +40 -0
- package/lib/components/ui/PhoneInput.d.ts +12 -0
- package/lib/components/ui/PhoneInput.js +58 -0
- package/lib/components/ui/Popover.d.ts +7 -0
- package/lib/components/ui/Popover.js +10 -0
- package/lib/components/ui/Progress.d.ts +7 -0
- package/lib/components/ui/Progress.js +7 -0
- package/lib/components/ui/Radio.d.ts +5 -0
- package/lib/components/ui/Radio.js +14 -0
- package/lib/components/ui/RangeDatePicker.d.ts +78 -0
- package/lib/components/ui/RangeDatePicker.js +68 -0
- package/lib/components/ui/Select.d.ts +13 -0
- package/lib/components/ui/Select.js +57 -0
- package/lib/components/ui/Separator.d.ts +4 -0
- package/lib/components/ui/Separator.js +7 -0
- package/lib/components/ui/Sheet.d.ts +26 -0
- package/lib/components/ui/Sheet.js +37 -0
- package/lib/components/ui/StatusCell.d.ts +9 -0
- package/lib/components/ui/StatusCell.js +6 -0
- package/lib/components/ui/Switch.d.ts +10 -0
- package/lib/components/ui/Switch.js +22 -0
- package/lib/components/ui/Tab.d.ts +15 -0
- package/lib/components/ui/Tab.js +13 -0
- package/lib/components/ui/TableDownload.d.ts +11 -0
- package/lib/components/ui/TableDownload.js +82 -0
- package/lib/components/ui/TailwindIndicator.d.ts +1 -0
- package/lib/components/ui/TailwindIndicator.js +6 -0
- package/lib/components/ui/TextField.d.ts +60 -0
- package/lib/components/ui/TextField.js +42 -0
- package/lib/components/ui/Textarea.d.ts +5 -0
- package/lib/components/ui/Textarea.js +8 -0
- package/lib/components/ui/Toast.d.ts +12 -0
- package/lib/components/ui/Toast.js +25 -0
- package/lib/components/ui/UploadField.d.ts +15 -0
- package/lib/components/ui/UploadField.js +45 -0
- package/lib/components/ui/VerticalTab.d.ts +16 -0
- package/lib/components/ui/VerticalTab.js +13 -0
- package/lib/components/ui/index.d.ts +49 -0
- package/lib/components/ui/index.js +47 -0
- package/lib/context/BreadcrumbContext.d.ts +28 -0
- package/lib/context/BreadcrumbContext.js +238 -0
- package/lib/context/FormEngineDrawerProvider.d.ts +21 -0
- package/lib/context/FormEngineDrawerProvider.js +38 -0
- package/lib/context/MultiFormEngineDrawerProvider.d.ts +25 -0
- package/lib/context/MultiFormEngineDrawerProvider.js +89 -0
- package/lib/context/SidebarContext.d.ts +65 -0
- package/lib/context/SidebarContext.js +47 -0
- package/lib/context/ToastContext.d.ts +17 -0
- package/lib/context/ToastContext.js +29 -0
- package/lib/context/index.d.ts +5 -0
- package/lib/context/index.js +5 -0
- package/lib/dashboard-visuals/components/BaseChart.d.ts +55 -0
- package/lib/dashboard-visuals/components/BaseChart.js +201 -0
- package/lib/dashboard-visuals/components/CardWrapper.d.ts +10 -0
- package/lib/dashboard-visuals/components/CardWrapper.js +13 -0
- package/lib/dashboard-visuals/components/ChartDetailsModal.d.ts +57 -0
- package/lib/dashboard-visuals/components/ChartDetailsModal.js +27 -0
- package/lib/dashboard-visuals/components/ChartDetailsModalWrapper.d.ts +29 -0
- package/lib/dashboard-visuals/components/ChartDetailsModalWrapper.js +4 -0
- package/lib/dashboard-visuals/components/ChartFormatter.d.ts +22 -0
- package/lib/dashboard-visuals/components/ChartFormatter.js +46 -0
- package/lib/dashboard-visuals/components/ChartWrapper.d.ts +11 -0
- package/lib/dashboard-visuals/components/ChartWrapper.js +14 -0
- package/lib/dashboard-visuals/components/DashboardFilter.d.ts +8 -0
- package/lib/dashboard-visuals/components/DashboardFilter.js +17 -0
- package/lib/dashboard-visuals/components/DataTable.d.ts +3 -0
- package/lib/dashboard-visuals/components/DataTable.js +57 -0
- package/lib/dashboard-visuals/components/EmptyState.d.ts +6 -0
- package/lib/dashboard-visuals/components/EmptyState.js +6 -0
- package/lib/dashboard-visuals/components/ErrorState.d.ts +7 -0
- package/lib/dashboard-visuals/components/ErrorState.js +5 -0
- package/lib/dashboard-visuals/components/FilterComponentSkeleton.d.ts +3 -0
- package/lib/dashboard-visuals/components/FilterComponentSkeleton.js +11 -0
- package/lib/dashboard-visuals/components/Pagination.d.ts +10 -0
- package/lib/dashboard-visuals/components/Pagination.js +7 -0
- package/lib/dashboard-visuals/components/Switch.d.ts +8 -0
- package/lib/dashboard-visuals/components/Switch.js +10 -0
- package/lib/dashboard-visuals/components/TileSkeleton.d.ts +2 -0
- package/lib/dashboard-visuals/components/TileSkeleton.js +5 -0
- package/lib/dashboard-visuals/components/molecules/Analytics.d.ts +11 -0
- package/lib/dashboard-visuals/components/molecules/Analytics.js +9 -0
- package/lib/dashboard-visuals/components/molecules/DataGrid.d.ts +15 -0
- package/lib/dashboard-visuals/components/molecules/DataGrid.js +124 -0
- package/lib/dashboard-visuals/components/molecules/NoChartData.d.ts +6 -0
- package/lib/dashboard-visuals/components/molecules/NoChartData.js +6 -0
- package/lib/dashboard-visuals/components/molecules/VisualChart.d.ts +16 -0
- package/lib/dashboard-visuals/components/molecules/VisualChart.js +8 -0
- package/lib/dashboard-visuals/components/types.d.ts +62 -0
- package/lib/dashboard-visuals/components/types.js +1 -0
- package/lib/dashboard-visuals/hooks/useChartData.d.ts +15 -0
- package/lib/dashboard-visuals/hooks/useChartData.js +82 -0
- package/lib/dashboard-visuals/hooks/useTooltipFormatter.d.ts +13 -0
- package/lib/dashboard-visuals/hooks/useTooltipFormatter.js +10 -0
- package/lib/dashboard-visuals/index.d.ts +39 -0
- package/lib/dashboard-visuals/index.js +168 -0
- package/lib/dashboard-visuals/types/index.d.ts +83 -0
- package/lib/dashboard-visuals/types/index.js +1 -0
- package/lib/dashboard-visuals/types/metricDetailData.d.ts +25 -0
- package/lib/dashboard-visuals/types/metricDetailData.js +1 -0
- package/lib/dashboard-visuals/utils/api.d.ts +5 -0
- package/lib/dashboard-visuals/utils/api.js +6 -0
- package/lib/dashboard-visuals/utils/chartOptions.d.ts +481 -0
- package/lib/dashboard-visuals/utils/chartOptions.js +393 -0
- package/lib/dashboard-visuals/utils/chunkArray.d.ts +1 -0
- package/lib/dashboard-visuals/utils/chunkArray.js +7 -0
- package/lib/dashboard-visuals/utils/defaultColors.d.ts +1 -0
- package/lib/dashboard-visuals/utils/defaultColors.js +1 -0
- package/lib/dashboard-visuals/utils/formatUtil.d.ts +203 -0
- package/lib/dashboard-visuals/utils/formatUtil.js +472 -0
- package/lib/dashboard-visuals/utils/gridUtil.d.ts +11 -0
- package/lib/dashboard-visuals/utils/gridUtil.js +32 -0
- package/lib/dashboard-visuals/utils/index.d.ts +6 -0
- package/lib/dashboard-visuals/utils/index.js +6 -0
- package/lib/dashboard-visuals/utils/tooltipUtils.d.ts +11 -0
- package/lib/dashboard-visuals/utils/tooltipUtils.js +180 -0
- package/lib/dashboard-visuals/visualRegistry.d.ts +4 -0
- package/lib/dashboard-visuals/visualRegistry.js +41 -0
- package/lib/dashboard-visuals/visuals/BarChart.d.ts +58 -0
- package/lib/dashboard-visuals/visuals/BarChart.js +95 -0
- package/lib/dashboard-visuals/visuals/BarLineHybridChart.d.ts +33 -0
- package/lib/dashboard-visuals/visuals/BarLineHybridChart.js +60 -0
- package/lib/dashboard-visuals/visuals/BubbleChart.d.ts +25 -0
- package/lib/dashboard-visuals/visuals/BubbleChart.js +101 -0
- package/lib/dashboard-visuals/visuals/DistributionChart.d.ts +11 -0
- package/lib/dashboard-visuals/visuals/DistributionChart.js +48 -0
- package/lib/dashboard-visuals/visuals/DonutChart.d.ts +50 -0
- package/lib/dashboard-visuals/visuals/DonutChart.js +105 -0
- package/lib/dashboard-visuals/visuals/GaugeChart.d.ts +32 -0
- package/lib/dashboard-visuals/visuals/GaugeChart.js +53 -0
- package/lib/dashboard-visuals/visuals/GroupedBarChart.d.ts +47 -0
- package/lib/dashboard-visuals/visuals/GroupedBarChart.js +131 -0
- package/lib/dashboard-visuals/visuals/HeatmapChart.d.ts +79 -0
- package/lib/dashboard-visuals/visuals/HeatmapChart.js +146 -0
- package/lib/dashboard-visuals/visuals/HorizontalBarChart.d.ts +50 -0
- package/lib/dashboard-visuals/visuals/HorizontalBarChart.js +131 -0
- package/lib/dashboard-visuals/visuals/ItemPerformanceCard.d.ts +30 -0
- package/lib/dashboard-visuals/visuals/ItemPerformanceCard.js +31 -0
- package/lib/dashboard-visuals/visuals/LineChart.d.ts +56 -0
- package/lib/dashboard-visuals/visuals/LineChart.js +80 -0
- package/lib/dashboard-visuals/visuals/LineGraph.d.ts +50 -0
- package/lib/dashboard-visuals/visuals/LineGraph.js +189 -0
- package/lib/dashboard-visuals/visuals/MetricSummaryCard.d.ts +14 -0
- package/lib/dashboard-visuals/visuals/MetricSummaryCard.js +8 -0
- package/lib/dashboard-visuals/visuals/MultiGaugeChart.d.ts +39 -0
- package/lib/dashboard-visuals/visuals/MultiGaugeChart.js +119 -0
- package/lib/dashboard-visuals/visuals/PieChart.d.ts +59 -0
- package/lib/dashboard-visuals/visuals/PieChart.js +194 -0
- package/lib/dashboard-visuals/visuals/SelectedEventTile.d.ts +14 -0
- package/lib/dashboard-visuals/visuals/SelectedEventTile.js +35 -0
- package/lib/dashboard-visuals/visuals/SpeedometerChart.d.ts +53 -0
- package/lib/dashboard-visuals/visuals/SpeedometerChart.js +94 -0
- package/lib/dashboard-visuals/visuals/Table.d.ts +26 -0
- package/lib/dashboard-visuals/visuals/Table.js +113 -0
- package/lib/dashboard-visuals/visuals/Tile.d.ts +16 -0
- package/lib/dashboard-visuals/visuals/Tile.js +16 -0
- package/lib/dashboard-visuals/visuals/TreeMap.d.ts +25 -0
- package/lib/dashboard-visuals/visuals/TreeMap.js +45 -0
- package/lib/dashboard-visuals/visuals/WaterfallChart.d.ts +52 -0
- package/lib/dashboard-visuals/visuals/WaterfallChart.js +266 -0
- package/lib/form-engine/Form.d.ts +4 -0
- package/lib/form-engine/Form.js +14 -0
- package/lib/form-engine/FormEngine.d.ts +3 -0
- package/lib/form-engine/FormEngine.js +121 -0
- package/lib/form-engine/components/FieldWrapper.d.ts +18 -0
- package/lib/form-engine/components/FieldWrapper.js +63 -0
- package/lib/form-engine/components/index.d.ts +2 -0
- package/lib/form-engine/components/index.js +2 -0
- package/lib/form-engine/components/inputs/card-expiry-input/CardExpiryInput.d.ts +16 -0
- package/lib/form-engine/components/inputs/card-expiry-input/CardExpiryInput.js +48 -0
- package/lib/form-engine/components/inputs/checkbox-input/CheckboxInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/checkbox-input/CheckboxInput.js +5 -0
- package/lib/form-engine/components/inputs/credit-card-input/CreditCardInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/credit-card-input/CreditCardInput.js +82 -0
- package/lib/form-engine/components/inputs/date-input/DateInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/date-input/DateInput.js +7 -0
- package/lib/form-engine/components/inputs/date-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/date-input/index.js +1 -0
- package/lib/form-engine/components/inputs/email-input/EmailInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/email-input/EmailInput.js +5 -0
- package/lib/form-engine/components/inputs/email-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/email-input/index.js +1 -0
- package/lib/form-engine/components/inputs/index.d.ts +13 -0
- package/lib/form-engine/components/inputs/index.js +13 -0
- package/lib/form-engine/components/inputs/label-input/LabelInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/label-input/LabelInput.js +7 -0
- package/lib/form-engine/components/inputs/label-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/label-input/index.js +1 -0
- package/lib/form-engine/components/inputs/multi-select-input/MultiSelectInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/multi-select-input/MultiSelectInput.js +5 -0
- package/lib/form-engine/components/inputs/number-input/NumberInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/number-input/NumberInput.js +5 -0
- package/lib/form-engine/components/inputs/number-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/number-input/index.js +1 -0
- package/lib/form-engine/components/inputs/password-input/PasswordInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/password-input/PasswordInput.js +9 -0
- package/lib/form-engine/components/inputs/password-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/password-input/index.js +1 -0
- package/lib/form-engine/components/inputs/radio-button/RadioInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/radio-button/RadioInput.js +6 -0
- package/lib/form-engine/components/inputs/radio-button/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/radio-button/index.js +1 -0
- package/lib/form-engine/components/inputs/select/SelectInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/select/SelectInput.js +6 -0
- package/lib/form-engine/components/inputs/select/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/select/index.js +1 -0
- package/lib/form-engine/components/inputs/textarea-input/TextareaInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/textarea-input/TextareaInput.js +5 -0
- package/lib/form-engine/components/inputs/textarea-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/textarea-input/index.js +1 -0
- package/lib/form-engine/components/inputs/time-input/TimeInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/time-input/TimeInput.js +5 -0
- package/lib/form-engine/components/inputs/time-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/time-input/index.js +1 -0
- package/lib/form-engine/components/inputs/toggle-switch-input/ToggleSwitchInput.d.ts +4 -0
- package/lib/form-engine/components/inputs/toggle-switch-input/ToggleSwitchInput.js +7 -0
- package/lib/form-engine/components/inputs/toggle-switch-input/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/toggle-switch-input/index.js +1 -0
- package/lib/form-engine/components/inputs/upload-field/UploadFieldForm.d.ts +4 -0
- package/lib/form-engine/components/inputs/upload-field/UploadFieldForm.js +59 -0
- package/lib/form-engine/components/inputs/upload-field/index.d.ts +1 -0
- package/lib/form-engine/components/inputs/upload-field/index.js +1 -0
- package/lib/form-engine/hooks/useFormPersistence.d.ts +11 -0
- package/lib/form-engine/hooks/useFormPersistence.js +46 -0
- package/lib/form-engine/index.d.ts +5 -0
- package/lib/form-engine/index.js +5 -0
- package/lib/form-engine/registry/RegisterComponents.d.ts +1 -0
- package/lib/form-engine/registry/RegisterComponents.js +35 -0
- package/lib/form-engine/registry/Registry.d.ts +5 -0
- package/lib/form-engine/registry/Registry.js +13 -0
- package/lib/form-engine/registry/index.d.ts +2 -0
- package/lib/form-engine/registry/index.js +2 -0
- package/lib/form-engine/types/index.d.ts +311 -0
- package/lib/form-engine/types/index.js +1 -0
- package/lib/helpers/index.d.ts +2 -0
- package/lib/helpers/index.js +2 -0
- package/lib/helpers/utils.d.ts +37 -0
- package/lib/helpers/utils.js +77 -0
- package/lib/helpers/validations.d.ts +80 -0
- package/lib/helpers/validations.js +39 -0
- package/lib/index.d.ts +21 -0
- package/lib/index.js +30 -0
- package/lib/mocks/mockApiRequestsConfig.d.ts +2 -0
- package/lib/mocks/mockApiRequestsConfig.js +343 -0
- package/lib/pagamio-drawer/TopUpWalletDrawer/TopUpWalletContent.d.ts +14 -0
- package/lib/pagamio-drawer/TopUpWalletDrawer/TopUpWalletContent.js +40 -0
- package/lib/pagamio-drawer/TopUpWalletDrawer/index.d.ts +11 -0
- package/lib/pagamio-drawer/TopUpWalletDrawer/index.js +7 -0
- package/lib/pagamio-drawer/components/BaseDrawer.d.ts +11 -0
- package/lib/pagamio-drawer/components/BaseDrawer.js +10 -0
- package/lib/pagamio-drawer/components/DrawerContent.d.ts +27 -0
- package/lib/pagamio-drawer/components/DrawerContent.js +237 -0
- package/lib/pagamio-drawer/index.d.ts +22 -0
- package/lib/pagamio-drawer/index.js +133 -0
- package/lib/pagamio-table/data-table/ExportButton.d.ts +57 -0
- package/lib/pagamio-table/data-table/ExportButton.js +96 -0
- package/lib/pagamio-table/data-table/MantineCoreTable.d.ts +44 -0
- package/lib/pagamio-table/data-table/MantineCoreTable.js +129 -0
- package/lib/pagamio-table/data-table/Pagination.d.ts +10 -0
- package/lib/pagamio-table/data-table/Pagination.js +5 -0
- package/lib/pagamio-table/data-table/TableDownload.d.ts +8 -0
- package/lib/pagamio-table/data-table/TableDownload.js +81 -0
- package/lib/pagamio-table/data-table/TableToolbar.d.ts +3 -0
- package/lib/pagamio-table/data-table/TableToolbar.js +16 -0
- package/lib/pagamio-table/data-table/exportUtils.d.ts +42 -0
- package/lib/pagamio-table/data-table/exportUtils.js +782 -0
- package/lib/pagamio-table/data-table/index.d.ts +5 -0
- package/lib/pagamio-table/data-table/index.js +11 -0
- package/lib/pagamio-table/data-table/pdfExportUtils.d.ts +111 -0
- package/lib/pagamio-table/data-table/pdfExportUtils.js +113 -0
- package/lib/pagamio-table/data-table/types.d.ts +169 -0
- package/lib/pagamio-table/data-table/types.js +1 -0
- package/lib/pagamio-table/index.d.ts +4 -0
- package/lib/pagamio-table/index.js +4 -0
- package/lib/pagamio-table/utils/functionHelper.d.ts +12 -0
- package/lib/pagamio-table/utils/functionHelper.js +24 -0
- package/lib/pagamio-table/utils/index.d.ts +1 -0
- package/lib/pagamio-table/utils/index.js +1 -0
- package/lib/rbac/hooks.d.ts +39 -0
- package/lib/rbac/hooks.js +51 -0
- package/lib/rbac/index.d.ts +8 -0
- package/lib/rbac/index.js +11 -0
- package/lib/rbac/store.d.ts +24 -0
- package/lib/rbac/store.js +37 -0
- package/lib/rbac/types.d.ts +39 -0
- package/lib/rbac/types.js +4 -0
- package/lib/rbac/utils.d.ts +44 -0
- package/lib/rbac/utils.js +117 -0
- package/lib/shared/constants/index.d.ts +2 -0
- package/lib/shared/constants/index.js +2 -0
- package/lib/shared/hooks/index.d.ts +4 -0
- package/lib/shared/hooks/index.js +4 -0
- package/lib/shared/hooks/useAnyDrawerOpen.d.ts +4 -0
- package/lib/shared/hooks/useAnyDrawerOpen.js +18 -0
- package/lib/shared/hooks/useContainerWidth.d.ts +2 -0
- package/lib/shared/hooks/useContainerWidth.js +18 -0
- package/lib/shared/hooks/useImageUpload.d.ts +15 -0
- package/lib/shared/hooks/useImageUpload.js +66 -0
- package/lib/shared/hooks/useMediaQueries.d.ts +5 -0
- package/lib/shared/hooks/useMediaQueries.js +35 -0
- package/lib/shared/hooks/usePagamioTable.d.ts +158 -0
- package/lib/shared/hooks/usePagamioTable.js +475 -0
- package/lib/shared/hooks/useSessionTimer.d.ts +33 -0
- package/lib/shared/hooks/useSessionTimer.js +96 -0
- package/lib/shared/index.d.ts +4 -0
- package/lib/shared/index.js +4 -0
- package/lib/shared/types/index.d.ts +1 -0
- package/lib/shared/types/index.js +1 -0
- package/lib/shared/url/index.d.ts +9 -0
- package/lib/shared/url/index.js +20 -0
- package/lib/shared/utils/filterUtils.d.ts +5 -0
- package/lib/shared/utils/filterUtils.js +31 -0
- package/lib/shared/utils/functionHelper.d.ts +27 -0
- package/lib/shared/utils/functionHelper.js +124 -0
- package/lib/shared/utils/index.d.ts +2 -0
- package/lib/shared/utils/index.js +2 -0
- package/lib/shared/utils/localStorage.d.ts +53 -0
- package/lib/shared/utils/localStorage.js +139 -0
- package/lib/styles.css +6247 -0
- package/lib/translations/components/LocaleSwitcher.d.ts +7 -0
- package/lib/translations/components/LocaleSwitcher.js +18 -0
- package/lib/translations/components/index.d.ts +1 -0
- package/lib/translations/components/index.js +1 -0
- package/lib/translations/context/TranslationContext.d.ts +5 -0
- package/lib/translations/context/TranslationContext.js +151 -0
- package/lib/translations/context/index.d.ts +1 -0
- package/lib/translations/context/index.js +1 -0
- package/lib/translations/hooks/index.d.ts +2 -0
- package/lib/translations/hooks/index.js +2 -0
- package/lib/translations/hooks/useLibTranslations.d.ts +7 -0
- package/lib/translations/hooks/useLibTranslations.js +46 -0
- package/lib/translations/hooks/useTranslation.d.ts +7 -0
- package/lib/translations/hooks/useTranslation.js +11 -0
- package/lib/translations/index.d.ts +91 -0
- package/lib/translations/index.js +11 -0
- package/lib/translations/locales/en.json +21 -0
- package/lib/translations/locales/es.json +21 -0
- package/lib/translations/locales/fr.json +21 -0
- package/lib/translations/locales/pt.json +21 -0
- package/lib/translations/types/index.d.ts +24 -0
- package/lib/translations/types/index.js +1 -0
- package/lib/translations/utils/index.d.ts +6 -0
- package/lib/translations/utils/index.js +25 -0
- package/package.json +9 -1
|
@@ -0,0 +1,472 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A generic utility to build x-axis values and series data for a stacked bar chart in ECharts.
|
|
3
|
+
*
|
|
4
|
+
* @param data - An array of objects of any shape (T).
|
|
5
|
+
* @param xAxisDataValueKey - The string key in each object representing x-axis data (e.g. "channel", "status").
|
|
6
|
+
* @param seriesDataNameKey - The string key in each object representing the series name (e.g. "productName").
|
|
7
|
+
* @param seriesDataValueKey - The string key in each object representing the numeric value (e.g. "amount").
|
|
8
|
+
*
|
|
9
|
+
* @returns An object containing:
|
|
10
|
+
* - xAxisValues: A string[] of unique x-axis values (in order).
|
|
11
|
+
* - seriesData: An array of SeriesItem (with "name", "type", "stack", and the numeric data array).
|
|
12
|
+
*/
|
|
13
|
+
export function getBarChartData(data, xAxisDataValueKey, seriesDataNameKey, seriesDataValueKey) {
|
|
14
|
+
// 1. Extract unique x-axis values (in order of appearance).
|
|
15
|
+
const xAxis = [];
|
|
16
|
+
for (const item of data) {
|
|
17
|
+
const xVal = String(item[xAxisDataValueKey] ?? '');
|
|
18
|
+
if (!xAxis.includes(xVal)) {
|
|
19
|
+
xAxis.push(xVal);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
// 2. Extract unique series names (in order of appearance).
|
|
23
|
+
const seriesNames = [];
|
|
24
|
+
for (const item of data) {
|
|
25
|
+
const seriesName = String(item[seriesDataNameKey] ?? '');
|
|
26
|
+
if (!seriesNames.includes(seriesName)) {
|
|
27
|
+
seriesNames.push(seriesName);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
// 3. Create a mapping: seriesName -> number[] (index matches xAxis order).
|
|
31
|
+
const productAmountMap = {};
|
|
32
|
+
seriesNames.forEach((name) => {
|
|
33
|
+
productAmountMap[name] = Array(xAxis.length).fill(0);
|
|
34
|
+
});
|
|
35
|
+
// 4. Populate the mapping using the data.
|
|
36
|
+
for (const item of data) {
|
|
37
|
+
const xVal = String(item[xAxisDataValueKey] ?? '');
|
|
38
|
+
const seriesName = String(item[seriesDataNameKey] ?? '');
|
|
39
|
+
const amount = Number(item[seriesDataValueKey] ?? 0);
|
|
40
|
+
const xIndex = xAxis.indexOf(xVal);
|
|
41
|
+
if (xIndex !== -1 && productAmountMap[seriesName]) {
|
|
42
|
+
productAmountMap[seriesName][xIndex] = amount;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
// 5. Construct the series data array for ECharts.
|
|
46
|
+
const seriesData = seriesNames.map((name) => ({
|
|
47
|
+
name,
|
|
48
|
+
type: 'bar',
|
|
49
|
+
stack: 'total',
|
|
50
|
+
data: productAmountMap[name],
|
|
51
|
+
}));
|
|
52
|
+
return {
|
|
53
|
+
xAxisValues: xAxis,
|
|
54
|
+
seriesData,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Flattens your data (if it happens to be an array of arrays)
|
|
59
|
+
* and maps it into an xAxis array of names and a seriesData
|
|
60
|
+
* array of { name, value } objects.
|
|
61
|
+
*
|
|
62
|
+
* @param data The raw data from the backend, e.g. [ [ { amount: 60, productName: 'Electronics' }, ... ] ]
|
|
63
|
+
* If data is just a single array (e.g. [ { amount: 60, productName: 'Electronics' }, ... ]),
|
|
64
|
+
* this function will still work (no harm in calling `flat()`).
|
|
65
|
+
* @param nameKey The key in each object that maps to the category name (used in xAxis and the `name` field).
|
|
66
|
+
* @param valueKey The key in each object that maps to the numeric value (used in `value`).
|
|
67
|
+
*
|
|
68
|
+
* @returns An object containing:
|
|
69
|
+
* - xAxis: string[] (e.g. ["Electronics", "Fashion", "Home & Garden"])
|
|
70
|
+
* - seriesData: Array<{ name: string; value: number }>
|
|
71
|
+
* (e.g. [{ name: "Electronics", value: 60 }, ...])
|
|
72
|
+
*/
|
|
73
|
+
export function getPieChartData(data, // can be an array of objects OR an array of arrays of objects
|
|
74
|
+
nameKey, // e.g. 'productName'
|
|
75
|
+
valueKey, // e.g. 'amount'
|
|
76
|
+
otherKey) {
|
|
77
|
+
// Flatten in case the response is nested, e.g. [ [ { ...}, { ...} ] ]
|
|
78
|
+
const flattened = Array.isArray(data[0]) ? data.flat() : data;
|
|
79
|
+
const getOtherKeyValue = (item) => {
|
|
80
|
+
let result = 0;
|
|
81
|
+
if (otherKey) {
|
|
82
|
+
let convertedValue;
|
|
83
|
+
if (typeof item[otherKey] === 'number') {
|
|
84
|
+
convertedValue = Number(item[otherKey]);
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
convertedValue = String(item[otherKey]);
|
|
88
|
+
}
|
|
89
|
+
result = convertedValue;
|
|
90
|
+
}
|
|
91
|
+
return result;
|
|
92
|
+
};
|
|
93
|
+
// Build xAxis and seriesData
|
|
94
|
+
const xAxis = flattened.map((item) => String(item[nameKey]));
|
|
95
|
+
const seriesData = flattened.map((item) => ({
|
|
96
|
+
name: String(item[nameKey]),
|
|
97
|
+
value: Number(item[valueKey]) || 0,
|
|
98
|
+
otherValue: getOtherKeyValue(item),
|
|
99
|
+
}));
|
|
100
|
+
return { xAxis, seriesData };
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Flattens your data (if it happens to be an array of arrays)
|
|
104
|
+
* and maps it into an xAxis array of names and a seriesData
|
|
105
|
+
* array of { name, value } objects.
|
|
106
|
+
*
|
|
107
|
+
* @param data The raw data from the backend, e.g. [ [ { amount: 60, productName: 'Electronics' }, ... ] ]
|
|
108
|
+
* If data is just a single array (e.g. [ { amount: 60, productName: 'Electronics' }, ... ]),
|
|
109
|
+
* this function will still work (no harm in calling `flat()`).
|
|
110
|
+
* @param nameKey The key in each object that maps to the category name (used in xAxis and the `name` field).
|
|
111
|
+
* @param valueKey The key in each object that maps to the numeric value (used in `value`).
|
|
112
|
+
*
|
|
113
|
+
* @returns An object containing:
|
|
114
|
+
* - seriesData: Array<{ name: string; value: number }>
|
|
115
|
+
* (e.g. [{ name: "Electronics", value: 60 }, ...])
|
|
116
|
+
*/
|
|
117
|
+
export function getSeriesData(data, // can be an array of objects OR an array of arrays of objects
|
|
118
|
+
nameKey, // e.g. 'productName'
|
|
119
|
+
valueKey) {
|
|
120
|
+
// Flatten in case the response is nested, e.g. [ [ { ...}, { ...} ] ]
|
|
121
|
+
const flattened = Array.isArray(data[0]) ? data.flat() : data;
|
|
122
|
+
// Build seriesData
|
|
123
|
+
const seriesData = flattened.map((item) => ({
|
|
124
|
+
name: String(item[nameKey]),
|
|
125
|
+
value: Number(item[valueKey]) || 0,
|
|
126
|
+
}));
|
|
127
|
+
return { seriesData };
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Flattens your data (if it happens to be an array of arrays)
|
|
131
|
+
* and maps it into a select options array. Handles null/undefined values safely.
|
|
132
|
+
*
|
|
133
|
+
* @param data The raw data from the backend.
|
|
134
|
+
* @param labelKey The key in each object that maps to the label in the options.
|
|
135
|
+
* @param valueKey Optional key for the value in the options. If not provided, labelKey will be used for both label and value.
|
|
136
|
+
* @returns An object containing optionsData array with { label, value } pairs.
|
|
137
|
+
*/
|
|
138
|
+
export function getFilterOptionsData(data, labelKey, valueKey) {
|
|
139
|
+
// Handle empty or null data
|
|
140
|
+
if (!data || !data.length) {
|
|
141
|
+
return { optionsData: [] };
|
|
142
|
+
}
|
|
143
|
+
// Flatten in case the response is nested, e.g. [ [ { ...}, { ...} ] ]
|
|
144
|
+
const flattened = Array.isArray(data[0]) ? data.flat() : data;
|
|
145
|
+
// Use a Set to track unique labels and values
|
|
146
|
+
const uniqueLabels = new Set();
|
|
147
|
+
const uniqueValues = new Set();
|
|
148
|
+
// Build optionsData, ensuring uniqueness and handling null values
|
|
149
|
+
const optionsData = flattened.reduce((acc, item) => {
|
|
150
|
+
// Skip null/undefined items
|
|
151
|
+
if (!item)
|
|
152
|
+
return acc;
|
|
153
|
+
const rawLabelValue = item[labelKey];
|
|
154
|
+
// Skip if the labelKey value is null/undefined
|
|
155
|
+
if (rawLabelValue == null)
|
|
156
|
+
return acc;
|
|
157
|
+
const label = String(rawLabelValue);
|
|
158
|
+
const value = valueKey && item[valueKey] != null ? String(item[valueKey]) : label;
|
|
159
|
+
// Check if the label or value is already in the Set
|
|
160
|
+
if (!uniqueLabels.has(label) && !uniqueValues.has(value)) {
|
|
161
|
+
uniqueLabels.add(label);
|
|
162
|
+
uniqueValues.add(value);
|
|
163
|
+
acc.push({ label, value });
|
|
164
|
+
}
|
|
165
|
+
return acc;
|
|
166
|
+
}, []);
|
|
167
|
+
return { optionsData };
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Flattens your data (if it happens to be an array of arrays)
|
|
171
|
+
* and maps it into a select options array.
|
|
172
|
+
*/
|
|
173
|
+
export function generateSelectOptions(data, labelKey, valueKey) {
|
|
174
|
+
// Flatten in case the response is nested, e.g. [ [ { ...}, { ...} ] ]
|
|
175
|
+
const flattened = Array.isArray(data[0]) ? data.flat() : data;
|
|
176
|
+
// Use a Set to track unique labels and values
|
|
177
|
+
const uniqueLabels = new Set();
|
|
178
|
+
const uniqueValues = new Set();
|
|
179
|
+
// Build optionsData, ensuring uniqueness
|
|
180
|
+
const optionsData = flattened.reduce((acc, item) => {
|
|
181
|
+
const label = String(item[labelKey]);
|
|
182
|
+
const value = String(item[valueKey]);
|
|
183
|
+
// Check if the label or value is already in the Set
|
|
184
|
+
if (!uniqueLabels.has(label) && !uniqueValues.has(value)) {
|
|
185
|
+
uniqueLabels.add(label);
|
|
186
|
+
uniqueValues.add(value);
|
|
187
|
+
acc.push({ label, value });
|
|
188
|
+
}
|
|
189
|
+
return acc;
|
|
190
|
+
}, []);
|
|
191
|
+
return { optionsData };
|
|
192
|
+
}
|
|
193
|
+
export const formatValue = (value, format, options) => {
|
|
194
|
+
if (format === 'currency') {
|
|
195
|
+
const currency = options?.currency || 'ZAR';
|
|
196
|
+
const locale = options?.locale || 'en-ZA';
|
|
197
|
+
return new Intl.NumberFormat(locale, {
|
|
198
|
+
style: 'currency',
|
|
199
|
+
currency,
|
|
200
|
+
}).format(value);
|
|
201
|
+
}
|
|
202
|
+
// Default formatting for numbers
|
|
203
|
+
return value.toString();
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* Standardized date formatting function for the entire application.
|
|
207
|
+
* Formats dates to a consistent locale-specific format.
|
|
208
|
+
*
|
|
209
|
+
* @param date - Date string, Date object, or null/undefined
|
|
210
|
+
* @param options - Optional formatting options
|
|
211
|
+
* @returns Formatted date string or fallback value
|
|
212
|
+
*/
|
|
213
|
+
export const formatDate = (date, options) => {
|
|
214
|
+
const { locale = 'en-US', fallback = 'N/A', includeTime = false } = options || {};
|
|
215
|
+
if (!date)
|
|
216
|
+
return fallback;
|
|
217
|
+
try {
|
|
218
|
+
const dateObj = typeof date === 'string' ? new Date(date) : date;
|
|
219
|
+
if (Number.isNaN(dateObj.getTime())) {
|
|
220
|
+
console.warn('Invalid date provided to formatDate:', date);
|
|
221
|
+
return fallback;
|
|
222
|
+
}
|
|
223
|
+
if (includeTime) {
|
|
224
|
+
return dateObj.toLocaleDateString(locale, {
|
|
225
|
+
year: 'numeric',
|
|
226
|
+
month: '2-digit',
|
|
227
|
+
day: '2-digit',
|
|
228
|
+
hour: '2-digit',
|
|
229
|
+
minute: '2-digit',
|
|
230
|
+
second: '2-digit',
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
return dateObj.toLocaleDateString(locale, {
|
|
234
|
+
year: 'numeric',
|
|
235
|
+
month: '2-digit',
|
|
236
|
+
day: '2-digit',
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
catch (error) {
|
|
240
|
+
console.error('Error formatting date:', error);
|
|
241
|
+
return fallback;
|
|
242
|
+
}
|
|
243
|
+
};
|
|
244
|
+
/**
|
|
245
|
+
* Formats a date range as a string.
|
|
246
|
+
*
|
|
247
|
+
* @param startDate - Start date
|
|
248
|
+
* @param endDate - End date
|
|
249
|
+
* @param options - Optional formatting options
|
|
250
|
+
* @returns Formatted date range string
|
|
251
|
+
*/
|
|
252
|
+
export const formatDateRange = (startDate, endDate, options) => {
|
|
253
|
+
const { separator = ' - ', fallback = 'N/A' } = options || {};
|
|
254
|
+
const formattedStart = formatDate(startDate, options);
|
|
255
|
+
const formattedEnd = formatDate(endDate, options);
|
|
256
|
+
if (formattedStart === (options?.fallback || 'N/A') || formattedEnd === (options?.fallback || 'N/A')) {
|
|
257
|
+
return fallback;
|
|
258
|
+
}
|
|
259
|
+
return `${formattedStart}${separator}${formattedEnd}`;
|
|
260
|
+
};
|
|
261
|
+
/**
|
|
262
|
+
* Truncates long IDs to show first N and last N characters with a separator.
|
|
263
|
+
*
|
|
264
|
+
* @param id - ID string, number, or null/undefined
|
|
265
|
+
* @param options - Optional truncation options
|
|
266
|
+
* @returns Truncated ID string or fallback value
|
|
267
|
+
*/
|
|
268
|
+
export const truncateId = (id, options) => {
|
|
269
|
+
const { startChars = 5, endChars = 5, separator = '…', minLength = 10, fallback = '' } = options || {};
|
|
270
|
+
// Handle null, undefined, or empty values
|
|
271
|
+
if (id === null || id === undefined || id === '') {
|
|
272
|
+
return fallback;
|
|
273
|
+
}
|
|
274
|
+
// Convert to string if it's a number
|
|
275
|
+
const value = String(id);
|
|
276
|
+
// Return as-is if shorter than minimum length
|
|
277
|
+
if (value.length <= minLength) {
|
|
278
|
+
return value;
|
|
279
|
+
}
|
|
280
|
+
// Truncate if longer than minimum length
|
|
281
|
+
return `${value.slice(0, startChars)}${separator}${value.slice(-endChars)}`;
|
|
282
|
+
};
|
|
283
|
+
export const transformColumns = (columns) => {
|
|
284
|
+
return columns.map((col) => ({
|
|
285
|
+
accessorKey: col.accessor,
|
|
286
|
+
header: col.header,
|
|
287
|
+
enableCopy: col.enableCopy,
|
|
288
|
+
formattedCellElement: col.formattedCellElement ? col.formattedCellElement : undefined,
|
|
289
|
+
}));
|
|
290
|
+
};
|
|
291
|
+
/**
|
|
292
|
+
* Formats an array of objects into DataPoint format required for Distribution Chart
|
|
293
|
+
* @param data Array of objects to format
|
|
294
|
+
* @param valueKey Key in the object to use as the value
|
|
295
|
+
* @param nameKey Key in the object to use as the name
|
|
296
|
+
* @returns Array of DataPoint objects
|
|
297
|
+
*/
|
|
298
|
+
export function formatToDataPoints(data, valueKey, nameKey) {
|
|
299
|
+
return data.map((item) => ({
|
|
300
|
+
value: Number(item[valueKey]) || 0, // Convert to number, default to 0 if invalid
|
|
301
|
+
name: String(item[nameKey] || ''), // Convert to string, default to empty string if undefined
|
|
302
|
+
}));
|
|
303
|
+
}
|
|
304
|
+
export const formatDonutChartData = (data, nameKey, valueKey) => {
|
|
305
|
+
if (!data?.length)
|
|
306
|
+
return { legendData: [], seriesData: [] };
|
|
307
|
+
// Extract the legend data (product names)
|
|
308
|
+
const legendData = data.map((item) => item[nameKey]);
|
|
309
|
+
// Format series data for the donut chart
|
|
310
|
+
const seriesData = data.map((item) => {
|
|
311
|
+
const dataPoint = {
|
|
312
|
+
name: item[nameKey],
|
|
313
|
+
value: item[valueKey],
|
|
314
|
+
};
|
|
315
|
+
return dataPoint;
|
|
316
|
+
});
|
|
317
|
+
return { legendData, seriesData };
|
|
318
|
+
};
|
|
319
|
+
/**
|
|
320
|
+
* Transforms flat data into heatmap format with proper axis categories and data matrix.
|
|
321
|
+
*
|
|
322
|
+
* @param data - Array of objects containing the data
|
|
323
|
+
* @param xAxisKey - Key for x-axis categories (e.g., 'region', 'dayOfWeek')
|
|
324
|
+
* @param yAxisKey - Key for y-axis categories (e.g., 'product', 'hour')
|
|
325
|
+
* @param valueKey - Key for the numeric values to be displayed as heat intensity
|
|
326
|
+
* @returns Object with xAxis categories, yAxis categories, and heatmap data matrix
|
|
327
|
+
*/
|
|
328
|
+
export function getHeatmapData(data, xAxisKey, yAxisKey, valueKey) {
|
|
329
|
+
if (!data?.length) {
|
|
330
|
+
return { xAxis: [], yAxis: [], data: [] };
|
|
331
|
+
}
|
|
332
|
+
// Extract unique categories for both axes
|
|
333
|
+
const xAxisCategories = Array.from(new Set(data.map((item) => String(item[xAxisKey] || ''))));
|
|
334
|
+
const yAxisCategories = Array.from(new Set(data.map((item) => String(item[yAxisKey] || ''))));
|
|
335
|
+
// Create heatmap data matrix: [xIndex, yIndex, value]
|
|
336
|
+
const heatmapData = data.map((item) => {
|
|
337
|
+
const xIndex = xAxisCategories.indexOf(String(item[xAxisKey] || ''));
|
|
338
|
+
const yIndex = yAxisCategories.indexOf(String(item[yAxisKey] || ''));
|
|
339
|
+
const value = Number(item[valueKey]) || 0;
|
|
340
|
+
return [xIndex, yIndex, value];
|
|
341
|
+
});
|
|
342
|
+
return {
|
|
343
|
+
xAxis: xAxisCategories,
|
|
344
|
+
yAxis: yAxisCategories,
|
|
345
|
+
data: heatmapData,
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Calculates the week number of the year for a given date.
|
|
350
|
+
* @param date - The date to calculate the week number for
|
|
351
|
+
* @returns The week number as a string (e.g., "Week 1")
|
|
352
|
+
*/
|
|
353
|
+
function calculateWeekNumber(date) {
|
|
354
|
+
const startOfYear = new Date(date.getFullYear(), 0, 1);
|
|
355
|
+
const weekNumber = Math.ceil(((date.getTime() - startOfYear.getTime()) / (1000 * 60 * 60 * 24) + startOfYear.getDay() + 1) / 7);
|
|
356
|
+
return `Week ${weekNumber}`;
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Determines the value to use based on the valueKey type.
|
|
360
|
+
* @param item - The data item
|
|
361
|
+
* @param valueKey - The key to extract value from
|
|
362
|
+
* @returns The computed value (1 for counting, or actual value)
|
|
363
|
+
*/
|
|
364
|
+
function determineValue(item, valueKey) {
|
|
365
|
+
return valueKey === 'transactionId' || valueKey === 'id' ? 1 : Number(item[valueKey]) || 1;
|
|
366
|
+
}
|
|
367
|
+
/**
|
|
368
|
+
* Processes a single data item to extract date information.
|
|
369
|
+
* @param item - The data item to process
|
|
370
|
+
* @param dateKey - The key for the date field
|
|
371
|
+
* @param valueKey - The key for the value field
|
|
372
|
+
* @returns Processed date information or null if invalid date
|
|
373
|
+
*/
|
|
374
|
+
function processDataItem(item, dateKey, valueKey) {
|
|
375
|
+
const dateStr = String(item[dateKey] || '');
|
|
376
|
+
const date = new Date(dateStr);
|
|
377
|
+
if (Number.isNaN(date.getTime())) {
|
|
378
|
+
return null;
|
|
379
|
+
}
|
|
380
|
+
const dayOfWeek = date.toLocaleDateString('en-US', { weekday: 'long' });
|
|
381
|
+
const weekOfYear = calculateWeekNumber(date);
|
|
382
|
+
const key = date.toISOString().split('T')[0]; // YYYY-MM-DD format
|
|
383
|
+
const value = determineValue(item, valueKey);
|
|
384
|
+
return { key, dayOfWeek, weekOfYear, value };
|
|
385
|
+
}
|
|
386
|
+
/**
|
|
387
|
+
* Generates the final heatmap data matrix from processed date data.
|
|
388
|
+
* @param dataByDate - Map of processed date data
|
|
389
|
+
* @param daysOfWeek - Array of day names
|
|
390
|
+
* @param allWeeks - Array of week names
|
|
391
|
+
* @returns Heatmap data matrix
|
|
392
|
+
*/
|
|
393
|
+
function generateHeatmapMatrix(dataByDate, daysOfWeek, allWeeks) {
|
|
394
|
+
const heatmapData = [];
|
|
395
|
+
for (let weekIndex = 0; weekIndex < allWeeks.length; weekIndex++) {
|
|
396
|
+
const week = allWeeks[weekIndex];
|
|
397
|
+
for (let dayIndex = 0; dayIndex < daysOfWeek.length; dayIndex++) {
|
|
398
|
+
const day = daysOfWeek[dayIndex];
|
|
399
|
+
const matchingEntry = Array.from(dataByDate.values()).find((entry) => entry.dayOfWeek === day && entry.weekOfYear === week);
|
|
400
|
+
heatmapData.push([dayIndex, weekIndex, matchingEntry ? matchingEntry.value : 0]);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
return heatmapData;
|
|
404
|
+
}
|
|
405
|
+
/**
|
|
406
|
+
* Transforms date-based data into a day-of-week vs week heatmap format.
|
|
407
|
+
* Generic utility that can be used for any date field and value combination.
|
|
408
|
+
*
|
|
409
|
+
* This function supports two calling patterns:
|
|
410
|
+
* 1. Direct usage: createDayWeekHeatmapData(data, dateKey, valueKey)
|
|
411
|
+
* 2. HeatmapChart adapter: createDayWeekHeatmapData(data, xAxisKey, yAxisKey, valueKey)
|
|
412
|
+
* - In this case, yAxisKey is used as the date field, xAxisKey is ignored
|
|
413
|
+
*
|
|
414
|
+
* @param data - Array of objects containing date and value data
|
|
415
|
+
* @param dateKeyOrXAxisKey - Key for the date field, or xAxisKey (ignored in 4-param version)
|
|
416
|
+
* @param valueKeyOrYAxisKey - Key for values, or yAxisKey (used as date field in 4-param version)
|
|
417
|
+
* @param optionalValueKey - Optional valueKey (used in 4-param version)
|
|
418
|
+
* @returns Object with day-of-week x-axis, week y-axis, and heatmap data matrix
|
|
419
|
+
*/
|
|
420
|
+
export function createDayWeekHeatmapData(data, dateKeyOrXAxisKey, valueKeyOrYAxisKey, optionalValueKey) {
|
|
421
|
+
// Handle both function signatures
|
|
422
|
+
let dateKey;
|
|
423
|
+
let valueKey;
|
|
424
|
+
if (optionalValueKey) {
|
|
425
|
+
// 4-parameter version: (data, xAxisKey, yAxisKey, valueKey)
|
|
426
|
+
// For date-based heatmaps, yAxisKey is the date field, xAxisKey is ignored
|
|
427
|
+
dateKey = valueKeyOrYAxisKey;
|
|
428
|
+
valueKey = optionalValueKey;
|
|
429
|
+
}
|
|
430
|
+
else {
|
|
431
|
+
// 3-parameter version: (data, dateKey, valueKey)
|
|
432
|
+
dateKey = dateKeyOrXAxisKey;
|
|
433
|
+
valueKey = valueKeyOrYAxisKey;
|
|
434
|
+
}
|
|
435
|
+
if (!data?.length) {
|
|
436
|
+
return { xAxis: [], yAxis: [], data: [] };
|
|
437
|
+
}
|
|
438
|
+
const dataByDate = new Map();
|
|
439
|
+
// Process the data to group by date and extract day/week info
|
|
440
|
+
for (const item of data) {
|
|
441
|
+
const processedItem = processDataItem(item, dateKey, valueKey);
|
|
442
|
+
if (!processedItem)
|
|
443
|
+
continue;
|
|
444
|
+
const { key, dayOfWeek, weekOfYear, value } = processedItem;
|
|
445
|
+
const existingEntry = dataByDate.get(key);
|
|
446
|
+
if (existingEntry) {
|
|
447
|
+
existingEntry.value += 1;
|
|
448
|
+
}
|
|
449
|
+
else {
|
|
450
|
+
dataByDate.set(key, {
|
|
451
|
+
dayOfWeek,
|
|
452
|
+
weekOfYear,
|
|
453
|
+
value,
|
|
454
|
+
originalDate: key,
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
// Generate complete day and week ranges
|
|
459
|
+
const daysOfWeek = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'];
|
|
460
|
+
const allWeeks = Array.from(new Set(Array.from(dataByDate.values()).map((d) => d.weekOfYear))).sort((a, b) => {
|
|
461
|
+
const weekA = Number.parseInt(a.replace('Week ', ''), 10);
|
|
462
|
+
const weekB = Number.parseInt(b.replace('Week ', ''), 10);
|
|
463
|
+
return weekA - weekB;
|
|
464
|
+
});
|
|
465
|
+
// Create complete heatmap data with zeros for missing combinations
|
|
466
|
+
const heatmapData = generateHeatmapMatrix(dataByDate, daysOfWeek, allWeeks);
|
|
467
|
+
return {
|
|
468
|
+
xAxis: daysOfWeek,
|
|
469
|
+
yAxis: allWeeks,
|
|
470
|
+
data: heatmapData,
|
|
471
|
+
};
|
|
472
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface GridColProps {
|
|
2
|
+
span: number;
|
|
3
|
+
offset: number;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* Determines the span and offset for Grid.Col based on the number of visuals in a row.
|
|
7
|
+
*
|
|
8
|
+
* @param numVisuals - Number of visuals in the current row.
|
|
9
|
+
* @returns An object containing `span` and `offset` values.
|
|
10
|
+
*/
|
|
11
|
+
export declare const getGridColProps: (numVisuals: number, visualIdx: number) => GridColProps;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Determines the span and offset for Grid.Col based on the number of visuals in a row.
|
|
3
|
+
*
|
|
4
|
+
* @param numVisuals - Number of visuals in the current row.
|
|
5
|
+
* @returns An object containing `span` and `offset` values.
|
|
6
|
+
*/
|
|
7
|
+
export const getGridColProps = (numVisuals, visualIdx) => {
|
|
8
|
+
let span;
|
|
9
|
+
let offset = 0;
|
|
10
|
+
switch (numVisuals) {
|
|
11
|
+
case 1:
|
|
12
|
+
span = 12; // 100%
|
|
13
|
+
offset = 0;
|
|
14
|
+
break;
|
|
15
|
+
case 2:
|
|
16
|
+
span = 6; // Each 50%
|
|
17
|
+
break;
|
|
18
|
+
case 3:
|
|
19
|
+
span = 4; // Each ~33.33%
|
|
20
|
+
break;
|
|
21
|
+
case 4:
|
|
22
|
+
span = 3; // Each 25%
|
|
23
|
+
break;
|
|
24
|
+
default:
|
|
25
|
+
span = 3; // Default to 25% for rows with >4 visuals
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
if (numVisuals === 1 && visualIdx === 0) {
|
|
29
|
+
return { span, offset };
|
|
30
|
+
}
|
|
31
|
+
return { span, offset: 0 };
|
|
32
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { MetricData, TooltipField } from '../types';
|
|
2
|
+
export declare const processTooltipFields: (tooltipAdditionalFields: (string | TooltipField)[]) => {
|
|
3
|
+
toolTipkey: string;
|
|
4
|
+
valueKey: string;
|
|
5
|
+
nameKey: string;
|
|
6
|
+
label: string;
|
|
7
|
+
suffix: string;
|
|
8
|
+
format: string;
|
|
9
|
+
formatter: (value: any, currency?: string, displaySymbol?: string) => string;
|
|
10
|
+
}[];
|
|
11
|
+
export declare const createTooltipFormatter: (format: string, tooltipTitle: string, tooltipUnit: string, processedTooltipFields: ReturnType<typeof processTooltipFields>, metricData: MetricData[], currency?: string, displaySymbol?: string) => (params: any) => string;
|