@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,475 @@
|
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { useToast } from '../../context';
|
|
3
|
+
import { getNestedValue } from '../utils';
|
|
4
|
+
// Default Spring Boot response mapping
|
|
5
|
+
export const springBootMapping = {
|
|
6
|
+
responseType: 'spring-boot',
|
|
7
|
+
data: 'content',
|
|
8
|
+
total: 'totalElements',
|
|
9
|
+
page: 'number',
|
|
10
|
+
pageSize: 'size',
|
|
11
|
+
defaultValues: {
|
|
12
|
+
data: [],
|
|
13
|
+
total: 0,
|
|
14
|
+
page: 0,
|
|
15
|
+
pageSize: 10,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
// array response query parameter configuration
|
|
19
|
+
export const arrayResponseMapping = {
|
|
20
|
+
responseType: 'default', // Indicates a non-Spring Boot response
|
|
21
|
+
data: '', // Path to the data array (empty string means the response itself is the data)
|
|
22
|
+
total: '', // Path to the total count (not applicable for plain arrays)
|
|
23
|
+
page: '', // Path to the current page number (not applicable for plain arrays)
|
|
24
|
+
pageSize: '', // Path to the page size (not applicable for plain arrays)
|
|
25
|
+
defaultValues: {
|
|
26
|
+
data: [], // Default data if the response is invalid
|
|
27
|
+
total: 0, // Default total count
|
|
28
|
+
page: 0, // Default page number
|
|
29
|
+
pageSize: 10, // Default page size
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
// Default query parameter configuration
|
|
33
|
+
const defaultQueryConfig = {
|
|
34
|
+
pagination: {
|
|
35
|
+
transform: (page, size) => ({
|
|
36
|
+
page: page.toString(),
|
|
37
|
+
size: size.toString(),
|
|
38
|
+
}),
|
|
39
|
+
},
|
|
40
|
+
sorting: {
|
|
41
|
+
transform: (sortBy, sortDir) => ({
|
|
42
|
+
sort: `${sortBy},${sortDir}`,
|
|
43
|
+
}),
|
|
44
|
+
},
|
|
45
|
+
filtering: {
|
|
46
|
+
searchParam: 'name',
|
|
47
|
+
filterFormat: 'flat',
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
/**
|
|
51
|
+
* Custom hook for managing table data with pagination, sorting, and filtering.
|
|
52
|
+
* Supports both client-side and server-side operations.
|
|
53
|
+
*
|
|
54
|
+
* @template T - The type of data items in the table. Must extend `BaseEntity`.
|
|
55
|
+
*
|
|
56
|
+
* @param {UsePagamioTableProps<T>} props - Configuration options for the hook.
|
|
57
|
+
* @param {Function} [props.fetchData] - Function to fetch data from the API (required for server-side operations).
|
|
58
|
+
* @param {T[]} [props.data] - Initial data for client-side operations.
|
|
59
|
+
* @param {CoreTableColumnDef<T>[]} props.columns - Column definitions for the table.
|
|
60
|
+
* @param {Record<string, string>} [props.defaultFilters] - Initial filter values.
|
|
61
|
+
* @param {ResponseMapping} [props.responseMapping] - Configuration for mapping API response structure.
|
|
62
|
+
* @param {QueryParamConfig} [props.queryParamConfig] - Configuration for query parameter formatting.
|
|
63
|
+
* @param {Object} [props.pagination] - Pagination configuration.
|
|
64
|
+
* @param {boolean} [props.pagination.enabled] - Whether pagination is enabled.
|
|
65
|
+
* @param {'client' | 'server'} [props.pagination.mode] - Pagination mode ('client' or 'server').
|
|
66
|
+
* @param {number} [props.pagination.pageSize] - Default page size.
|
|
67
|
+
* @param {Object} [props.filtering] - Filtering configuration.
|
|
68
|
+
* @param {boolean} [props.filtering.enabled] - Whether filtering is enabled.
|
|
69
|
+
* @param {'client' | 'server'} [props.filtering.mode] - Filtering mode ('client' or 'server').
|
|
70
|
+
* @param {Object} [props.sorting] - Sorting configuration.
|
|
71
|
+
* @param {boolean} [props.sorting.enabled] - Whether sorting is enabled.
|
|
72
|
+
* @param {'client' | 'server'} [props.sorting.mode] - Sorting mode ('client' or 'server').
|
|
73
|
+
*
|
|
74
|
+
* @returns {Object} - Table state and utility functions.
|
|
75
|
+
* @returns {T[]} data - The processed and paginated data.
|
|
76
|
+
* @returns {number} totalItems - Total number of items (for server-side pagination).
|
|
77
|
+
* @returns {boolean} loading - Whether data is being fetched.
|
|
78
|
+
* @returns {string | null} error - Error message, if any.
|
|
79
|
+
* @returns {number} currentPage - Current page index.
|
|
80
|
+
* @returns {number} itemsPerPage - Number of items per page.
|
|
81
|
+
* @returns {string} searchQuery - Current search query.
|
|
82
|
+
* @returns {Record<string, string>} appliedFilters - Currently applied filters.
|
|
83
|
+
* @returns {Record<string, string>} selectedFilters - Currently selected filters.
|
|
84
|
+
* @returns {SortConfig} sortConfig - Current sorting configuration.
|
|
85
|
+
* @returns {CoreTableColumnDef<T>[]} columns - Column definitions.
|
|
86
|
+
* @returns {Function} handleApplyFilters - Function to apply filters.
|
|
87
|
+
* @returns {Function} handlePageChange - Function to change the current page.
|
|
88
|
+
* @returns {Function} handlePaginationChange - Function to change pagination settings.
|
|
89
|
+
* @returns {Function} setSearchQuery - Function to update the search query.
|
|
90
|
+
* @returns {Function} setCurrentPage - Function to update the current page.
|
|
91
|
+
* @returns {Function} setItemsPerPage - Function to update the items per page.
|
|
92
|
+
* @returns {Function} handleFilterChange - Function to update filters.
|
|
93
|
+
* @returns {Function} handleSort - Function to update sorting.
|
|
94
|
+
* @returns {Function} handleClearFilters - Function to clear all filters.
|
|
95
|
+
* @returns {Function} refresh - Function to manually refresh the table data.
|
|
96
|
+
*/
|
|
97
|
+
export const usePagamioTable = ({ fetchData, data: clientData, columns, defaultFilters = {}, responseMapping = springBootMapping, queryParamConfig = defaultQueryConfig, pagination = { enabled: true, mode: 'client' }, filtering = {
|
|
98
|
+
enabled: true,
|
|
99
|
+
mode: 'client',
|
|
100
|
+
searchMode: 'server',
|
|
101
|
+
}, sorting = { enabled: true, mode: 'client' }, }) => {
|
|
102
|
+
const [data, setData] = useState([]);
|
|
103
|
+
const [loading, setLoading] = useState(true);
|
|
104
|
+
const [currentPage, setCurrentPage] = useState(pagination.pageIndex ?? 0);
|
|
105
|
+
const [itemsPerPage, setItemsPerPage] = useState(pagination.pageSize ?? 10);
|
|
106
|
+
const [searchQuery, setSearchQuery] = useState('');
|
|
107
|
+
const [filters, setFilters] = useState(defaultFilters);
|
|
108
|
+
const [appliedFilters, setAppliedFilters] = useState(defaultFilters);
|
|
109
|
+
const [sortConfig, setSortConfig] = useState({});
|
|
110
|
+
const [totalItems, setTotalItems] = useState(clientData?.length ?? 0);
|
|
111
|
+
const [error, setError] = useState(null);
|
|
112
|
+
const { addToast } = useToast();
|
|
113
|
+
const fetchController = useRef(null);
|
|
114
|
+
const fetchDataRef = useRef(fetchData);
|
|
115
|
+
const queryConfigRef = useRef(queryParamConfig);
|
|
116
|
+
const searchMode = useMemo(() => filtering?.searchMode ?? filtering?.mode ?? 'client', [filtering?.searchMode, filtering?.mode]);
|
|
117
|
+
useEffect(() => {
|
|
118
|
+
fetchDataRef.current = fetchData;
|
|
119
|
+
}, [fetchData]);
|
|
120
|
+
useEffect(() => {
|
|
121
|
+
queryConfigRef.current = queryParamConfig;
|
|
122
|
+
}, [queryParamConfig]);
|
|
123
|
+
const allModesAreClient = useCallback(() => {
|
|
124
|
+
return (filtering.mode !== 'server' &&
|
|
125
|
+
pagination.mode !== 'server' &&
|
|
126
|
+
sorting.mode !== 'server' &&
|
|
127
|
+
searchMode !== 'server');
|
|
128
|
+
}, [filtering.mode, pagination.mode, sorting.mode, searchMode]);
|
|
129
|
+
const processResponse = useCallback((response) => {
|
|
130
|
+
const dataPath = responseMapping.data ?? springBootMapping.data;
|
|
131
|
+
const totalPath = responseMapping.total ?? springBootMapping.total;
|
|
132
|
+
const pagePath = responseMapping.page ?? springBootMapping.page;
|
|
133
|
+
const pageSizePath = responseMapping.pageSize ?? springBootMapping.pageSize;
|
|
134
|
+
const extractedData = dataPath ? getNestedValue(response, dataPath) : response;
|
|
135
|
+
const extractedTotal = totalPath ? getNestedValue(response, totalPath) : response?.length;
|
|
136
|
+
const extractedPage = pagePath ? getNestedValue(response, pagePath) : 0;
|
|
137
|
+
const extractedPageSize = pageSizePath ? getNestedValue(response, pageSizePath) : 10;
|
|
138
|
+
return {
|
|
139
|
+
data: extractedData ?? responseMapping.defaultValues?.data ?? [],
|
|
140
|
+
total: extractedTotal ?? responseMapping.defaultValues?.total ?? 0,
|
|
141
|
+
page: extractedPage ?? responseMapping.defaultValues?.page ?? 0,
|
|
142
|
+
pageSize: extractedPageSize ?? responseMapping.defaultValues?.pageSize ?? 10,
|
|
143
|
+
};
|
|
144
|
+
}, [responseMapping]);
|
|
145
|
+
// Helper function to add pagination parameters
|
|
146
|
+
const addPaginationParams = (queryParams, config, currentPage, itemsPerPage) => {
|
|
147
|
+
if (config?.pagination?.transform) {
|
|
148
|
+
Object.assign(queryParams, config.pagination.transform(currentPage, itemsPerPage));
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
queryParams[config?.pagination?.pageParam ?? 'page'] = currentPage.toString();
|
|
152
|
+
queryParams[config?.pagination?.sizeParam ?? 'size'] = itemsPerPage.toString();
|
|
153
|
+
}
|
|
154
|
+
};
|
|
155
|
+
// Helper function to add sorting parameters
|
|
156
|
+
const addSortingParams = (queryParams, config, sortConfig) => {
|
|
157
|
+
if (config?.sorting?.transform) {
|
|
158
|
+
Object.assign(queryParams, config.sorting.transform(sortConfig.sortBy, sortConfig.sortDir ?? 'asc'));
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
queryParams[config?.sorting?.sortByParam ?? 'sortBy'] = sortConfig.sortBy;
|
|
162
|
+
queryParams[config?.sorting?.sortDirParam ?? 'sortDir'] = sortConfig.sortDir ?? 'asc';
|
|
163
|
+
}
|
|
164
|
+
};
|
|
165
|
+
// Helper function to add filtering parameters
|
|
166
|
+
const addFilteringParams = (queryParams, config, appliedFilters, searchMode) => {
|
|
167
|
+
const { searchParam, filterFormat, filterPrefix, transform } = config?.filtering ?? {};
|
|
168
|
+
if (transform) {
|
|
169
|
+
Object.assign(queryParams, transform(appliedFilters));
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (appliedFilters.search && searchParam && searchMode === 'server') {
|
|
173
|
+
queryParams[searchParam] = appliedFilters.search;
|
|
174
|
+
}
|
|
175
|
+
const format = filterFormat ?? 'bracket';
|
|
176
|
+
const prefix = filterPrefix ?? 'filter';
|
|
177
|
+
Object.entries(appliedFilters).forEach(([key, value]) => {
|
|
178
|
+
if (value && value !== 'all' && key !== 'search') {
|
|
179
|
+
switch (format) {
|
|
180
|
+
case 'bracket':
|
|
181
|
+
queryParams[`filters[${key}]`] = value;
|
|
182
|
+
break;
|
|
183
|
+
case 'flat':
|
|
184
|
+
queryParams[key] = value;
|
|
185
|
+
break;
|
|
186
|
+
case 'prefix':
|
|
187
|
+
queryParams[`${prefix}_${key}`] = value;
|
|
188
|
+
break;
|
|
189
|
+
default:
|
|
190
|
+
queryParams[`filters[${key}]`] = value;
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
});
|
|
194
|
+
};
|
|
195
|
+
// Main function to build query parameters
|
|
196
|
+
const buildQueryParams = useCallback(() => {
|
|
197
|
+
const queryParams = {};
|
|
198
|
+
const config = queryConfigRef.current;
|
|
199
|
+
if (pagination.mode === 'server') {
|
|
200
|
+
addPaginationParams(queryParams, config, currentPage, itemsPerPage);
|
|
201
|
+
}
|
|
202
|
+
if (sorting.mode === 'server' && sortConfig.sortBy) {
|
|
203
|
+
addSortingParams(queryParams, config, sortConfig);
|
|
204
|
+
}
|
|
205
|
+
if (filtering.mode === 'server' && Object.keys(appliedFilters).length > 0) {
|
|
206
|
+
addFilteringParams(queryParams, config, appliedFilters, searchMode);
|
|
207
|
+
}
|
|
208
|
+
return queryParams;
|
|
209
|
+
}, [
|
|
210
|
+
currentPage,
|
|
211
|
+
itemsPerPage,
|
|
212
|
+
sortConfig,
|
|
213
|
+
appliedFilters,
|
|
214
|
+
filtering.mode,
|
|
215
|
+
pagination.mode,
|
|
216
|
+
sorting.mode,
|
|
217
|
+
searchMode,
|
|
218
|
+
]);
|
|
219
|
+
// Helper function to update state with processed data
|
|
220
|
+
const updateState = useCallback((processed) => {
|
|
221
|
+
setData(processed.data);
|
|
222
|
+
setTotalItems(processed.total);
|
|
223
|
+
if (pagination.mode === 'server') {
|
|
224
|
+
if (processed.page !== undefined && processed.page !== currentPage) {
|
|
225
|
+
setCurrentPage(processed.page);
|
|
226
|
+
}
|
|
227
|
+
if (processed.pageSize !== undefined && processed.pageSize !== itemsPerPage) {
|
|
228
|
+
setItemsPerPage(processed.pageSize);
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}, [pagination.mode, currentPage, itemsPerPage]);
|
|
232
|
+
// Helper function to handle errors
|
|
233
|
+
const handleError = useCallback((err) => {
|
|
234
|
+
if (err.name !== 'AbortError') {
|
|
235
|
+
setError(err instanceof Error ? err.message : 'Unknown error');
|
|
236
|
+
addToast({
|
|
237
|
+
variant: 'error',
|
|
238
|
+
title: 'Error',
|
|
239
|
+
message: err instanceof Error ? err.message : 'Failed to fetch data',
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
}, [addToast]);
|
|
243
|
+
const fetchTableData = useCallback(async () => {
|
|
244
|
+
// Early exit if fetchData is not provided and clientData is not available
|
|
245
|
+
if (!fetchDataRef.current && clientData) {
|
|
246
|
+
setLoading(false);
|
|
247
|
+
return;
|
|
248
|
+
}
|
|
249
|
+
// If all modes are client and clientData is provided, use it directly
|
|
250
|
+
if (allModesAreClient() && clientData) {
|
|
251
|
+
setData(clientData);
|
|
252
|
+
setTotalItems(clientData.length);
|
|
253
|
+
setLoading(false);
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
try {
|
|
257
|
+
setLoading(true);
|
|
258
|
+
setError(null);
|
|
259
|
+
// Abort previous request if it exists
|
|
260
|
+
if (fetchController.current) {
|
|
261
|
+
fetchController.current.abort();
|
|
262
|
+
}
|
|
263
|
+
fetchController.current = new AbortController();
|
|
264
|
+
// Build query parameters
|
|
265
|
+
const queryParams = buildQueryParams();
|
|
266
|
+
// Fetch data from the API
|
|
267
|
+
if (!fetchDataRef.current) {
|
|
268
|
+
throw new Error('fetchData function is not defined');
|
|
269
|
+
}
|
|
270
|
+
const response = await fetchDataRef.current(queryParams, fetchController.current.signal);
|
|
271
|
+
// Only process the response if the request wasn't aborted
|
|
272
|
+
if (!fetchController.current.signal.aborted) {
|
|
273
|
+
const processed = processResponse(response);
|
|
274
|
+
updateState(processed);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
catch (err) {
|
|
278
|
+
if (err.name !== 'AbortError') {
|
|
279
|
+
handleError(err);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
finally {
|
|
283
|
+
// Only set loading to false if the request wasn't aborted
|
|
284
|
+
if (!fetchController.current?.signal.aborted) {
|
|
285
|
+
setLoading(false);
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}, [allModesAreClient, buildQueryParams, processResponse, updateState, handleError, clientData]);
|
|
289
|
+
// Process data for client-side operations
|
|
290
|
+
const processedData = useMemo(() => {
|
|
291
|
+
let processed = [...data];
|
|
292
|
+
if (searchMode === 'client' && searchQuery) {
|
|
293
|
+
const query = searchQuery.toLowerCase();
|
|
294
|
+
processed = processed.filter((item) => Object.values(item).some((value) => value?.toString().toLowerCase().includes(query)));
|
|
295
|
+
}
|
|
296
|
+
if (filtering.mode === 'client' && Object.keys(appliedFilters).length > 0) {
|
|
297
|
+
processed = processed.filter((item) => Object.entries(appliedFilters).every(([key, value]) => key === 'search' || !value || value === 'all' || item[key]?.toString() === value));
|
|
298
|
+
}
|
|
299
|
+
if (sorting.mode === 'client' && sortConfig.sortBy) {
|
|
300
|
+
processed.sort((a, b) => {
|
|
301
|
+
const aValue = a[sortConfig.sortBy];
|
|
302
|
+
const bValue = b[sortConfig.sortBy];
|
|
303
|
+
const sortMultiplier = sortConfig.sortDir === 'asc' ? 1 : -1;
|
|
304
|
+
return aValue < bValue ? -sortMultiplier : sortMultiplier;
|
|
305
|
+
});
|
|
306
|
+
}
|
|
307
|
+
return processed;
|
|
308
|
+
}, [data, searchQuery, appliedFilters, sortConfig, filtering.mode, sorting.mode, searchMode]);
|
|
309
|
+
// ✅ Update totalItems reactively based on processed data length in client mode
|
|
310
|
+
useEffect(() => {
|
|
311
|
+
if (filtering.mode === 'client' || searchMode === 'client') {
|
|
312
|
+
setTotalItems(processedData.length);
|
|
313
|
+
}
|
|
314
|
+
}, [processedData.length, filtering.mode, searchMode]);
|
|
315
|
+
const paginatedData = useMemo(() => {
|
|
316
|
+
if (pagination.mode === 'client' && pagination.enabled) {
|
|
317
|
+
const start = currentPage * itemsPerPage;
|
|
318
|
+
return processedData.slice(start, start + itemsPerPage);
|
|
319
|
+
}
|
|
320
|
+
return processedData;
|
|
321
|
+
}, [processedData, currentPage, itemsPerPage, pagination.mode, pagination.enabled]);
|
|
322
|
+
// Filter change handler
|
|
323
|
+
const handleFilterChange = useCallback((columnKey, value) => {
|
|
324
|
+
setFilters((prev) => ({ ...prev, [columnKey]: value }));
|
|
325
|
+
}, []);
|
|
326
|
+
// Sort handler
|
|
327
|
+
const handleSort = useCallback((sortBy, sortDir) => {
|
|
328
|
+
setSortConfig({ sortBy, sortDir });
|
|
329
|
+
}, []);
|
|
330
|
+
// Clear filters handler
|
|
331
|
+
const handleClearFilters = useCallback(() => {
|
|
332
|
+
setSearchQuery('');
|
|
333
|
+
setFilters(defaultFilters);
|
|
334
|
+
setAppliedFilters(defaultFilters);
|
|
335
|
+
}, [defaultFilters]);
|
|
336
|
+
const handleApplyFilters = useCallback(() => {
|
|
337
|
+
const newAppliedFilters = {
|
|
338
|
+
...filters,
|
|
339
|
+
search: searchQuery,
|
|
340
|
+
};
|
|
341
|
+
// Only update if filters have actually changed
|
|
342
|
+
const filtersChanged = JSON.stringify(newAppliedFilters) !== JSON.stringify(appliedFilters);
|
|
343
|
+
if (!filtersChanged) {
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
// Use functional update to ensure we're working with the latest state
|
|
347
|
+
setAppliedFilters((prev) => {
|
|
348
|
+
// Only update if filters have actually changed
|
|
349
|
+
if (JSON.stringify(prev) !== JSON.stringify(newAppliedFilters)) {
|
|
350
|
+
return newAppliedFilters;
|
|
351
|
+
}
|
|
352
|
+
return prev;
|
|
353
|
+
});
|
|
354
|
+
// Reset to first page when filters change
|
|
355
|
+
setCurrentPage(0);
|
|
356
|
+
}, [searchQuery, filters, appliedFilters]);
|
|
357
|
+
const handlePageChange = useCallback((newPage) => {
|
|
358
|
+
setCurrentPage(newPage);
|
|
359
|
+
}, [currentPage]);
|
|
360
|
+
const handlePaginationChange = useCallback((newPageIndex, newPageSize) => {
|
|
361
|
+
setCurrentPage(newPageIndex);
|
|
362
|
+
setItemsPerPage(newPageSize);
|
|
363
|
+
}, [currentPage, itemsPerPage]);
|
|
364
|
+
// Main data fetching effect
|
|
365
|
+
useEffect(() => {
|
|
366
|
+
// If all modes are client and clientData is provided, use it directly
|
|
367
|
+
if (allModesAreClient() && clientData) {
|
|
368
|
+
setData(clientData);
|
|
369
|
+
setTotalItems(clientData.length);
|
|
370
|
+
setLoading(false);
|
|
371
|
+
return;
|
|
372
|
+
}
|
|
373
|
+
// Call the async function
|
|
374
|
+
fetchTableData().then(() => setLoading(false));
|
|
375
|
+
}, [currentPage, itemsPerPage, appliedFilters, sortConfig, filtering.mode, pagination.mode, sorting.mode]);
|
|
376
|
+
useEffect(() => {
|
|
377
|
+
return () => {
|
|
378
|
+
if (fetchController.current) {
|
|
379
|
+
fetchController.current.abort();
|
|
380
|
+
}
|
|
381
|
+
};
|
|
382
|
+
}, []);
|
|
383
|
+
// Return a memoized value to prevent unnecessary re-renders
|
|
384
|
+
return useMemo(() => ({
|
|
385
|
+
data: paginatedData,
|
|
386
|
+
totalItems,
|
|
387
|
+
loading,
|
|
388
|
+
error,
|
|
389
|
+
currentPage,
|
|
390
|
+
itemsPerPage,
|
|
391
|
+
searchQuery,
|
|
392
|
+
selectedFilters: filters,
|
|
393
|
+
appliedFilters,
|
|
394
|
+
sortConfig,
|
|
395
|
+
columns,
|
|
396
|
+
handleApplyFilters,
|
|
397
|
+
handlePageChange,
|
|
398
|
+
handlePaginationChange,
|
|
399
|
+
setSearchQuery,
|
|
400
|
+
setCurrentPage,
|
|
401
|
+
setItemsPerPage,
|
|
402
|
+
setAppliedFilters,
|
|
403
|
+
handleFilterChange,
|
|
404
|
+
handleSort,
|
|
405
|
+
handleClearFilters,
|
|
406
|
+
refresh: fetchTableData,
|
|
407
|
+
}), [
|
|
408
|
+
paginatedData,
|
|
409
|
+
totalItems,
|
|
410
|
+
loading,
|
|
411
|
+
error,
|
|
412
|
+
currentPage,
|
|
413
|
+
itemsPerPage,
|
|
414
|
+
searchQuery,
|
|
415
|
+
filters,
|
|
416
|
+
appliedFilters,
|
|
417
|
+
sortConfig,
|
|
418
|
+
columns,
|
|
419
|
+
setAppliedFilters,
|
|
420
|
+
handleApplyFilters,
|
|
421
|
+
handlePageChange,
|
|
422
|
+
handlePaginationChange,
|
|
423
|
+
handleFilterChange,
|
|
424
|
+
handleSort,
|
|
425
|
+
handleClearFilters,
|
|
426
|
+
fetchTableData,
|
|
427
|
+
]);
|
|
428
|
+
};
|
|
429
|
+
/**
|
|
430
|
+
* Example usage of the `usePagamioTable` hook.
|
|
431
|
+
*
|
|
432
|
+
* @example
|
|
433
|
+
* const table = usePagamioTable<Product>({
|
|
434
|
+
* fetchData: fetchProducts,
|
|
435
|
+
* columns: columns as unknown as CoreTableColumnDef<Product>[],
|
|
436
|
+
* defaultFilters: initialFilters,
|
|
437
|
+
* pagination: { enabled: true, mode: "server" },
|
|
438
|
+
* filtering: { enabled: true, mode: "server" },
|
|
439
|
+
* queryParamConfig: {
|
|
440
|
+
* filtering: { searchParam: "name", filterFormat: "flat" },
|
|
441
|
+
* },
|
|
442
|
+
* });
|
|
443
|
+
*
|
|
444
|
+
* // Render the table
|
|
445
|
+
* return (
|
|
446
|
+
* <CoreTable
|
|
447
|
+
* columns={table.columns}
|
|
448
|
+
* data={table.data}
|
|
449
|
+
* pagination={{
|
|
450
|
+
* enabled: true,
|
|
451
|
+
* pageIndex: table.currentPage,
|
|
452
|
+
* pageSize: table.itemsPerPage,
|
|
453
|
+
* itemsPerPage: table.itemsPerPage,
|
|
454
|
+
* itemsPerPageOptions: [10, 25, 50],
|
|
455
|
+
* onPageChange: table.handlePageChange,
|
|
456
|
+
* onPaginationChange: table.handlePaginationChange,
|
|
457
|
+
* }}
|
|
458
|
+
* filtering={{
|
|
459
|
+
* filters: filters,
|
|
460
|
+
* appliedFilters: table.selectedFilters,
|
|
461
|
+
* onTableFilter: table.handleFilterChange,
|
|
462
|
+
* }}
|
|
463
|
+
* sorting={{
|
|
464
|
+
* sortConfig: table.sortConfig,
|
|
465
|
+
* onSort: table.handleSort,
|
|
466
|
+
* }}
|
|
467
|
+
* search={{
|
|
468
|
+
* enabled: true,
|
|
469
|
+
* searchQuery: table.searchQuery,
|
|
470
|
+
* onSearch: (e) => table.setSearchQuery(e.target.value),
|
|
471
|
+
* }}
|
|
472
|
+
* onClearFilters={table.handleClearFilters}
|
|
473
|
+
* />
|
|
474
|
+
* );
|
|
475
|
+
*/
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
interface UseSessionTimerOptions {
|
|
2
|
+
onSessionExpired?: () => void;
|
|
3
|
+
onSessionRefreshed?: () => void;
|
|
4
|
+
onRefreshError?: (error: Error) => void;
|
|
5
|
+
expiryThreshold?: number;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Hook to manage session expiration and refresh logic.
|
|
9
|
+
* Tracks the session's remaining time and provides functionality to refresh the session or handle expiration.
|
|
10
|
+
*
|
|
11
|
+
* @param options - Configuration options for the session timer.
|
|
12
|
+
* @param options.onSessionExpired - Callback invoked when the session expires.
|
|
13
|
+
* @param options.onSessionRefreshed - Callback invoked when the session is successfully refreshed.
|
|
14
|
+
* @param options.onRefreshError - Callback invoked when an error occurs during session refresh.
|
|
15
|
+
* @param options.expiryThreshold - Time in milliseconds before session expiry to show the modal (default: 60000ms or 60s).
|
|
16
|
+
*
|
|
17
|
+
* @returns An object containing:
|
|
18
|
+
* - `showModal`: Boolean indicating whether the session expiry modal should be shown.
|
|
19
|
+
* - `countdown`: The remaining time in seconds before session expiry.
|
|
20
|
+
* - `loading`: Boolean indicating whether a session refresh is in progress.
|
|
21
|
+
* - `modalDismissed`: Boolean indicating whether the modal has been dismissed.
|
|
22
|
+
* - `handleCloseModal`: Function to close the session expiry modal.
|
|
23
|
+
* - `handleRefreshToken`: Function to refresh the session token.
|
|
24
|
+
*/
|
|
25
|
+
export declare function useSessionTimer({ onSessionExpired, onSessionRefreshed, onRefreshError, expiryThreshold, }?: UseSessionTimerOptions): {
|
|
26
|
+
showModal: boolean;
|
|
27
|
+
countdown: number;
|
|
28
|
+
loading: boolean;
|
|
29
|
+
modalDismissed: boolean;
|
|
30
|
+
handleCloseModal: () => void;
|
|
31
|
+
handleRefreshToken: () => Promise<void>;
|
|
32
|
+
};
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { useAuth } from '../../auth';
|
|
3
|
+
/**
|
|
4
|
+
* Hook to manage session expiration and refresh logic.
|
|
5
|
+
* Tracks the session's remaining time and provides functionality to refresh the session or handle expiration.
|
|
6
|
+
*
|
|
7
|
+
* @param options - Configuration options for the session timer.
|
|
8
|
+
* @param options.onSessionExpired - Callback invoked when the session expires.
|
|
9
|
+
* @param options.onSessionRefreshed - Callback invoked when the session is successfully refreshed.
|
|
10
|
+
* @param options.onRefreshError - Callback invoked when an error occurs during session refresh.
|
|
11
|
+
* @param options.expiryThreshold - Time in milliseconds before session expiry to show the modal (default: 60000ms or 60s).
|
|
12
|
+
*
|
|
13
|
+
* @returns An object containing:
|
|
14
|
+
* - `showModal`: Boolean indicating whether the session expiry modal should be shown.
|
|
15
|
+
* - `countdown`: The remaining time in seconds before session expiry.
|
|
16
|
+
* - `loading`: Boolean indicating whether a session refresh is in progress.
|
|
17
|
+
* - `modalDismissed`: Boolean indicating whether the modal has been dismissed.
|
|
18
|
+
* - `handleCloseModal`: Function to close the session expiry modal.
|
|
19
|
+
* - `handleRefreshToken`: Function to refresh the session token.
|
|
20
|
+
*/
|
|
21
|
+
export function useSessionTimer({ onSessionExpired, onSessionRefreshed, onRefreshError, expiryThreshold = 60000, } = {}) {
|
|
22
|
+
const { logout, authService } = useAuth();
|
|
23
|
+
const [showModal, setShowModal] = useState(false);
|
|
24
|
+
const [modalDismissed, setModalDismissed] = useState(false);
|
|
25
|
+
const [countdown, setCountdown] = useState(60);
|
|
26
|
+
const [loading, setLoading] = useState(false);
|
|
27
|
+
const intervalRef = useRef(null);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
const expiresAt = authService.getAccessTokenExpiry();
|
|
30
|
+
if (!expiresAt)
|
|
31
|
+
return;
|
|
32
|
+
intervalRef.current = setInterval(() => {
|
|
33
|
+
const timeRemaining = expiresAt - Date.now();
|
|
34
|
+
if (timeRemaining <= 0) {
|
|
35
|
+
setModalDismissed(true);
|
|
36
|
+
setShowModal(false);
|
|
37
|
+
logout();
|
|
38
|
+
onSessionExpired?.();
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
if (timeRemaining <= expiryThreshold) {
|
|
42
|
+
if (!modalDismissed) {
|
|
43
|
+
setShowModal(true);
|
|
44
|
+
setCountdown(Math.ceil(timeRemaining / 1000));
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
setShowModal(false);
|
|
49
|
+
}
|
|
50
|
+
}, 1000);
|
|
51
|
+
return () => {
|
|
52
|
+
if (intervalRef.current) {
|
|
53
|
+
clearInterval(intervalRef.current);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}, [authService, logout, modalDismissed, expiryThreshold, onSessionExpired]);
|
|
57
|
+
/**
|
|
58
|
+
* Closes the session expiry modal and marks it as dismissed.
|
|
59
|
+
*/
|
|
60
|
+
const handleCloseModal = useCallback(() => {
|
|
61
|
+
setShowModal(false);
|
|
62
|
+
setModalDismissed(true);
|
|
63
|
+
}, []);
|
|
64
|
+
/**
|
|
65
|
+
* Refreshes the session token.
|
|
66
|
+
* Handles success and error cases, and updates the loading state.
|
|
67
|
+
*/
|
|
68
|
+
const handleRefreshToken = useCallback(async () => {
|
|
69
|
+
try {
|
|
70
|
+
setLoading(true);
|
|
71
|
+
handleCloseModal();
|
|
72
|
+
const success = await authService.refreshTokens();
|
|
73
|
+
if (success) {
|
|
74
|
+
onSessionRefreshed?.();
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
throw new Error('Failed to refresh session');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
const errorMessage = error instanceof Error ? error.message : 'Error refreshing session';
|
|
82
|
+
onRefreshError?.(new Error(errorMessage));
|
|
83
|
+
}
|
|
84
|
+
finally {
|
|
85
|
+
setLoading(false);
|
|
86
|
+
}
|
|
87
|
+
}, [authService, handleCloseModal, onSessionRefreshed, onRefreshError]);
|
|
88
|
+
return {
|
|
89
|
+
showModal,
|
|
90
|
+
countdown,
|
|
91
|
+
loading,
|
|
92
|
+
modalDismissed,
|
|
93
|
+
handleCloseModal,
|
|
94
|
+
handleRefreshToken,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './api';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './api';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a URL segment is an identifier (UUID, numeric ID, or long slug).
|
|
3
|
+
* @param segment - The URL path segment to check
|
|
4
|
+
* @returns True if the segment matches any of these patterns:
|
|
5
|
+
* - UUID format (e.g., '123e4567-e89b-12d3-a456-426614174000')
|
|
6
|
+
* - Numeric ID (e.g., '123')
|
|
7
|
+
* - Alphanumeric slug 30 characters or longer (for compatibility)
|
|
8
|
+
*/
|
|
9
|
+
export declare const isUUIDorID: (segment: string) => boolean;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if a URL segment is an identifier (UUID, numeric ID, or long slug).
|
|
3
|
+
* @param segment - The URL path segment to check
|
|
4
|
+
* @returns True if the segment matches any of these patterns:
|
|
5
|
+
* - UUID format (e.g., '123e4567-e89b-12d3-a456-426614174000')
|
|
6
|
+
* - Numeric ID (e.g., '123')
|
|
7
|
+
* - Alphanumeric slug 30 characters or longer (for compatibility)
|
|
8
|
+
*/
|
|
9
|
+
export const isUUIDorID = (segment) => {
|
|
10
|
+
const uuidPattern = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
11
|
+
const idPattern = /^\d+$/;
|
|
12
|
+
const slugPattern = /^[A-Za-z0-9_-]+$/;
|
|
13
|
+
if (uuidPattern.test(segment))
|
|
14
|
+
return true;
|
|
15
|
+
if (idPattern.test(segment))
|
|
16
|
+
return true;
|
|
17
|
+
// Use 30+ characters for better compatibility between apps
|
|
18
|
+
// This avoids treating route segments as IDs while still catching long identifiers
|
|
19
|
+
return slugPattern.test(segment) && segment.length >= 30;
|
|
20
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const isDefaultFilterValue: (value: unknown, key?: string) => boolean;
|
|
2
|
+
export declare const hasFilterChanges: (selectedFilters: Record<string, unknown>, appliedFilters: Record<string, unknown>) => boolean;
|
|
3
|
+
export declare const hasSelectedFilterChanges: (selectedFilters: Record<string, unknown>, appliedFilters: Record<string, unknown>) => boolean;
|
|
4
|
+
export declare const hasActiveFilters: (filters: Record<string, unknown>) => boolean;
|
|
5
|
+
export declare const hasAppliedFilters: (filters: Record<string, unknown>) => boolean;
|