@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,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Role-Based Access Control (RBAC) types
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Configuration mapping roles to permissions
|
|
6
|
+
*/
|
|
7
|
+
export interface RBACConfig<P> {
|
|
8
|
+
[role: string]: P[];
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Generic user interface that can be extended by specific applications.
|
|
12
|
+
* Optionally supports multiple roles via the `roleNames` property.
|
|
13
|
+
*/
|
|
14
|
+
export interface RBACUser {
|
|
15
|
+
[key: string]: unknown;
|
|
16
|
+
roleNames?: string[];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* RBAC configuration options.
|
|
20
|
+
* Supports both single-role and multi-role users.
|
|
21
|
+
*/
|
|
22
|
+
export interface RBACOptions<P, U extends RBACUser = RBACUser> {
|
|
23
|
+
/**
|
|
24
|
+
* Configuration mapping roles to permissions
|
|
25
|
+
*/
|
|
26
|
+
rbacConfig: RBACConfig<P>;
|
|
27
|
+
/**
|
|
28
|
+
* The permission value that represents "ALL permissions"
|
|
29
|
+
*/
|
|
30
|
+
allPermissionValue: P;
|
|
31
|
+
/**
|
|
32
|
+
* Array of all available permissions
|
|
33
|
+
*/
|
|
34
|
+
allPermissions: P[];
|
|
35
|
+
/**
|
|
36
|
+
* The key in the user object that contains the role(s) - can be a string or array of strings
|
|
37
|
+
*/
|
|
38
|
+
roleKey?: keyof U;
|
|
39
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { RBACOptions, RBACUser } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Initialize the RBAC system with configuration
|
|
4
|
+
* @param options - RBAC configuration options
|
|
5
|
+
*/
|
|
6
|
+
export declare const initializeRBAC: <P, U extends RBACUser = RBACUser>(options: RBACOptions<P, U>) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Check if a user has a specific permission
|
|
9
|
+
* @param user - The user object to check permissions for
|
|
10
|
+
* @param permission - The permission to check
|
|
11
|
+
* @returns boolean indicating if the user has the permission
|
|
12
|
+
*/
|
|
13
|
+
export declare const hasPermission: <P, U extends RBACUser = RBACUser>(user: U | null, permission: P) => boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Check if a user has any of the specified permissions
|
|
16
|
+
* @param user - The user object to check permissions for
|
|
17
|
+
* @param permissions - Array of permissions to check
|
|
18
|
+
* @returns boolean indicating if the user has any of the permissions
|
|
19
|
+
*/
|
|
20
|
+
export declare const hasAnyPermission: <P, U extends RBACUser = RBACUser>(user: U | null, permissions: P[]) => boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Check if a user has all of the specified permissions
|
|
23
|
+
* @param user - The user object to check permissions for
|
|
24
|
+
* @param permissions - Array of permissions to check
|
|
25
|
+
* @returns boolean indicating if the user has all of the permissions
|
|
26
|
+
*/
|
|
27
|
+
export declare const hasAllPermissions: <P, U extends RBACUser = RBACUser>(user: U | null, permissions: P[]) => boolean;
|
|
28
|
+
/**
|
|
29
|
+
* Get all permissions for a user (union of all roles' permissions)
|
|
30
|
+
* @param user - The user object to get permissions for
|
|
31
|
+
* @returns Array of permissions the user has
|
|
32
|
+
*/
|
|
33
|
+
export declare const getUserPermissions: <P, U extends RBACUser = RBACUser>(user: U | null) => P[];
|
|
34
|
+
/**
|
|
35
|
+
* Check if a user has a specific role (matches any of their roles)
|
|
36
|
+
* @param user - The user object to check role for
|
|
37
|
+
* @param roleName - The role name to check against
|
|
38
|
+
* @returns boolean indicating if the user has the specified role
|
|
39
|
+
*/
|
|
40
|
+
export declare const hasRole: <U extends RBACUser = RBACUser>(user: U | null, roleName: string) => boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Check if a user has access to IQ Retail
|
|
43
|
+
*/
|
|
44
|
+
export declare const hasIQRetailAccess: <P, U extends RBACUser = RBACUser>(user: U | null) => boolean;
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { RBACConfigStore } from './store';
|
|
2
|
+
/**
|
|
3
|
+
* Get user roles from the user object
|
|
4
|
+
* @param user - The user object
|
|
5
|
+
* @param roleKey - The key for role(s) - can be string or array of strings
|
|
6
|
+
* @returns Array of roles
|
|
7
|
+
*/
|
|
8
|
+
function getUserRoles(user, roleKey) {
|
|
9
|
+
if (roleKey && user[roleKey]) {
|
|
10
|
+
const val = user[roleKey];
|
|
11
|
+
return Array.isArray(val) ? val : [val];
|
|
12
|
+
}
|
|
13
|
+
return [];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Initialize the RBAC system with configuration
|
|
17
|
+
* @param options - RBAC configuration options
|
|
18
|
+
*/
|
|
19
|
+
export const initializeRBAC = (options) => {
|
|
20
|
+
const store = RBACConfigStore.getInstance();
|
|
21
|
+
store.initialize(options);
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Check if a user has a specific permission
|
|
25
|
+
* @param user - The user object to check permissions for
|
|
26
|
+
* @param permission - The permission to check
|
|
27
|
+
* @returns boolean indicating if the user has the permission
|
|
28
|
+
*/
|
|
29
|
+
export const hasPermission = (user, permission) => {
|
|
30
|
+
if (!user)
|
|
31
|
+
return false;
|
|
32
|
+
const store = RBACConfigStore.getInstance();
|
|
33
|
+
const { rbacConfig, allPermissionValue, roleKey } = store.options;
|
|
34
|
+
const roles = getUserRoles(user, roleKey);
|
|
35
|
+
if (!roles.length)
|
|
36
|
+
return false;
|
|
37
|
+
for (const role of roles) {
|
|
38
|
+
const rolePermissions = rbacConfig[role];
|
|
39
|
+
if (!rolePermissions)
|
|
40
|
+
continue;
|
|
41
|
+
if (rolePermissions.includes(allPermissionValue) || rolePermissions.includes(permission)) {
|
|
42
|
+
return true;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return false;
|
|
46
|
+
};
|
|
47
|
+
/**
|
|
48
|
+
* Check if a user has any of the specified permissions
|
|
49
|
+
* @param user - The user object to check permissions for
|
|
50
|
+
* @param permissions - Array of permissions to check
|
|
51
|
+
* @returns boolean indicating if the user has any of the permissions
|
|
52
|
+
*/
|
|
53
|
+
export const hasAnyPermission = (user, permissions) => {
|
|
54
|
+
return permissions.some((permission) => hasPermission(user, permission));
|
|
55
|
+
};
|
|
56
|
+
/**
|
|
57
|
+
* Check if a user has all of the specified permissions
|
|
58
|
+
* @param user - The user object to check permissions for
|
|
59
|
+
* @param permissions - Array of permissions to check
|
|
60
|
+
* @returns boolean indicating if the user has all of the permissions
|
|
61
|
+
*/
|
|
62
|
+
export const hasAllPermissions = (user, permissions) => {
|
|
63
|
+
return permissions.every((permission) => hasPermission(user, permission));
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Get all permissions for a user (union of all roles' permissions)
|
|
67
|
+
* @param user - The user object to get permissions for
|
|
68
|
+
* @returns Array of permissions the user has
|
|
69
|
+
*/
|
|
70
|
+
export const getUserPermissions = (user) => {
|
|
71
|
+
if (!user)
|
|
72
|
+
return [];
|
|
73
|
+
const store = RBACConfigStore.getInstance();
|
|
74
|
+
const { rbacConfig, allPermissionValue, allPermissions, roleKey } = store.options;
|
|
75
|
+
const roles = getUserRoles(user, roleKey);
|
|
76
|
+
if (!roles.length)
|
|
77
|
+
return [];
|
|
78
|
+
let permissionsSet = new Set();
|
|
79
|
+
for (const role of roles) {
|
|
80
|
+
const rolePermissions = rbacConfig[role];
|
|
81
|
+
if (!rolePermissions)
|
|
82
|
+
continue;
|
|
83
|
+
if (rolePermissions.includes(allPermissionValue)) {
|
|
84
|
+
// If any role has ALL, return all permissions
|
|
85
|
+
return allPermissions;
|
|
86
|
+
}
|
|
87
|
+
rolePermissions.forEach((perm) => permissionsSet.add(perm));
|
|
88
|
+
}
|
|
89
|
+
return Array.from(permissionsSet);
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* Check if a user has a specific role (matches any of their roles)
|
|
93
|
+
* @param user - The user object to check role for
|
|
94
|
+
* @param roleName - The role name to check against
|
|
95
|
+
* @returns boolean indicating if the user has the specified role
|
|
96
|
+
*/
|
|
97
|
+
export const hasRole = (user, roleName) => {
|
|
98
|
+
if (!user)
|
|
99
|
+
return false;
|
|
100
|
+
const store = RBACConfigStore.getInstance();
|
|
101
|
+
const { roleKey } = store.options;
|
|
102
|
+
const roles = getUserRoles(user, roleKey);
|
|
103
|
+
if (!roles.length)
|
|
104
|
+
return false;
|
|
105
|
+
return roles.includes(roleName);
|
|
106
|
+
};
|
|
107
|
+
/**
|
|
108
|
+
* Check if a user has access to IQ Retail
|
|
109
|
+
*/
|
|
110
|
+
export const hasIQRetailAccess = (user) => {
|
|
111
|
+
if (!user)
|
|
112
|
+
return false;
|
|
113
|
+
// Check permission
|
|
114
|
+
const hasPerm = hasPermission(user, 'export:iqretail');
|
|
115
|
+
// Check user-level flag
|
|
116
|
+
return hasPerm && !!user.hasIQRetailAccess;
|
|
117
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
// Old provider
|
|
2
|
+
import { useFormEngineDrawer, useMultiFormEngineDrawer } from '../../context';
|
|
3
|
+
// New provider
|
|
4
|
+
/**
|
|
5
|
+
* A unified hook to check if any drawer is open (from either the old or new provider).
|
|
6
|
+
*/
|
|
7
|
+
export const useAnyDrawerOpen = () => {
|
|
8
|
+
try {
|
|
9
|
+
const { isOpen: isOldDrawerOpen } = useFormEngineDrawer(); // Check old provider
|
|
10
|
+
const { isAnyDrawerOpen } = useMultiFormEngineDrawer(); // Check new provider
|
|
11
|
+
return isOldDrawerOpen || isAnyDrawerOpen();
|
|
12
|
+
}
|
|
13
|
+
catch (error) {
|
|
14
|
+
// If the old provider is not available, only check the new provider
|
|
15
|
+
const { isAnyDrawerOpen } = useMultiFormEngineDrawer();
|
|
16
|
+
return isAnyDrawerOpen();
|
|
17
|
+
}
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
export function useContainerWidth() {
|
|
3
|
+
const containerRef = useRef(null);
|
|
4
|
+
const [containerWidth, setContainerWidth] = useState(0);
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
const updateWidth = () => {
|
|
7
|
+
if (containerRef.current) {
|
|
8
|
+
setContainerWidth(containerRef.current.offsetWidth);
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
// Measure once on mount
|
|
12
|
+
updateWidth();
|
|
13
|
+
// Re-measure on window resize
|
|
14
|
+
window.addEventListener('resize', updateWidth);
|
|
15
|
+
return () => window.removeEventListener('resize', updateWidth);
|
|
16
|
+
}, []);
|
|
17
|
+
return [containerRef, containerWidth];
|
|
18
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface UploadResponse {
|
|
2
|
+
uploadURL: string;
|
|
3
|
+
publicURL: string;
|
|
4
|
+
}
|
|
5
|
+
export interface UseImageUploadProps {
|
|
6
|
+
project: 'vas' | 'stocklink' | 'events';
|
|
7
|
+
env: 'dev' | 'uat' | 'prod';
|
|
8
|
+
endpoint?: string;
|
|
9
|
+
}
|
|
10
|
+
export declare const useImageUpload: ({ project, env, endpoint, }: UseImageUploadProps) => {
|
|
11
|
+
getPresignedUrl: (fileName: string, contentType: string) => Promise<UploadResponse>;
|
|
12
|
+
uploadFile: (file: File) => Promise<string>;
|
|
13
|
+
isLoading: boolean;
|
|
14
|
+
error: Error | null;
|
|
15
|
+
};
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
|
+
import { generateSecureRandomString, uploadFileWithXHR } from '../utils/functionHelper';
|
|
3
|
+
export const useImageUpload = ({ project, env, endpoint = process.env.NEXT_PUBLIC_UPLOAD_URL_ENDPOINT ||
|
|
4
|
+
'https://faas-ams3-2a2df116.doserverless.co/api/v1/web/fn-2c9f1cfc-1296-4367-89d8-12409763dae6/default/upload-url', }) => {
|
|
5
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
6
|
+
const [error, setError] = useState(null);
|
|
7
|
+
const getPresignedUrl = useCallback(async (fileName, contentType) => {
|
|
8
|
+
setIsLoading(true);
|
|
9
|
+
setError(null);
|
|
10
|
+
try {
|
|
11
|
+
const response = await fetch(endpoint, {
|
|
12
|
+
method: 'POST',
|
|
13
|
+
headers: {
|
|
14
|
+
'Content-Type': 'application/json',
|
|
15
|
+
},
|
|
16
|
+
body: JSON.stringify({
|
|
17
|
+
project,
|
|
18
|
+
env,
|
|
19
|
+
fileName,
|
|
20
|
+
contentType,
|
|
21
|
+
}),
|
|
22
|
+
});
|
|
23
|
+
if (!response.ok) {
|
|
24
|
+
throw new Error(`Failed to get upload URL: ${response.statusText}`);
|
|
25
|
+
}
|
|
26
|
+
// --- FIX: unwrap .data if present ---
|
|
27
|
+
const json = await response.json();
|
|
28
|
+
const data = json.data || json;
|
|
29
|
+
return {
|
|
30
|
+
uploadURL: data.uploadURL,
|
|
31
|
+
publicURL: data.publicURL,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
catch (err) {
|
|
35
|
+
const error = err instanceof Error ? err : new Error('Failed to get upload URL');
|
|
36
|
+
setError(error);
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
finally {
|
|
40
|
+
setIsLoading(false);
|
|
41
|
+
}
|
|
42
|
+
}, [project, env, endpoint]);
|
|
43
|
+
const uploadFile = useCallback(async (file) => {
|
|
44
|
+
const timestamp = Date.now();
|
|
45
|
+
const randomString = generateSecureRandomString();
|
|
46
|
+
const extension = file.name.split('.').pop() || 'jpg';
|
|
47
|
+
const fileName = `${timestamp}_${randomString}.${extension}`;
|
|
48
|
+
try {
|
|
49
|
+
const { uploadURL, publicURL } = await getPresignedUrl(fileName, file.type);
|
|
50
|
+
// Use shared helper for XHR upload
|
|
51
|
+
await uploadFileWithXHR(uploadURL, file);
|
|
52
|
+
return publicURL;
|
|
53
|
+
}
|
|
54
|
+
catch (err) {
|
|
55
|
+
const error = err instanceof Error ? err : new Error('Upload failed');
|
|
56
|
+
setError(error);
|
|
57
|
+
throw error;
|
|
58
|
+
}
|
|
59
|
+
}, [getPresignedUrl, generateSecureRandomString]);
|
|
60
|
+
return {
|
|
61
|
+
getPresignedUrl,
|
|
62
|
+
uploadFile,
|
|
63
|
+
isLoading,
|
|
64
|
+
error,
|
|
65
|
+
};
|
|
66
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { useMantineTheme } from '@mantine/core';
|
|
2
|
+
import { useMediaQuery } from '@mantine/hooks';
|
|
3
|
+
export function useMediaQueries() {
|
|
4
|
+
const theme = useMantineTheme();
|
|
5
|
+
function convertToPx(value) {
|
|
6
|
+
const breakpointRegex = /^([\d.]+)(em|rem|px)$/;
|
|
7
|
+
const match = breakpointRegex.exec(value);
|
|
8
|
+
if (!match) {
|
|
9
|
+
console.error(`Unsupported unit in breakpoint value: "${value}"`);
|
|
10
|
+
return NaN;
|
|
11
|
+
}
|
|
12
|
+
const [, numericValue, unit] = match;
|
|
13
|
+
const num = parseFloat(numericValue);
|
|
14
|
+
switch (unit) {
|
|
15
|
+
case 'px':
|
|
16
|
+
return num;
|
|
17
|
+
case 'em':
|
|
18
|
+
case 'rem':
|
|
19
|
+
return num * 16;
|
|
20
|
+
default:
|
|
21
|
+
console.error(`Unsupported unit: "${unit}"`);
|
|
22
|
+
return NaN;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
const xsPx = convertToPx(theme.breakpoints.xs);
|
|
26
|
+
const smPx = convertToPx(theme.breakpoints.sm);
|
|
27
|
+
const isXs = useMediaQuery(`(max-width: ${xsPx - 1}px)`);
|
|
28
|
+
const isSm = useMediaQuery(`(min-width: ${xsPx}px) and (max-width: ${smPx - 1}px)`);
|
|
29
|
+
const isMd = useMediaQuery(`(min-width: ${smPx}px)`);
|
|
30
|
+
return {
|
|
31
|
+
isXs,
|
|
32
|
+
isSm,
|
|
33
|
+
isMd,
|
|
34
|
+
};
|
|
35
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import type { QueryParamConfig, ResponseMapping } from '../../api';
|
|
2
|
+
import type { BaseEntity, CoreTableColumnDef, SortConfig } from '../../pagamio-table/data-table/types';
|
|
3
|
+
/**
|
|
4
|
+
* Props interface for usePagamioTable hook
|
|
5
|
+
*/
|
|
6
|
+
export interface UsePagamioTableProps<T extends BaseEntity> {
|
|
7
|
+
/** Function to fetch data from the API */
|
|
8
|
+
fetchData?: (query?: Record<string, string>, signal?: AbortSignal) => Promise<any>;
|
|
9
|
+
/** Data for client-side operations */
|
|
10
|
+
data?: T[];
|
|
11
|
+
/** Table column definitions */
|
|
12
|
+
columns: CoreTableColumnDef<T>[];
|
|
13
|
+
/** Initial filter values */
|
|
14
|
+
defaultFilters?: Record<string, string>;
|
|
15
|
+
/** Configuration for response structure mapping */
|
|
16
|
+
responseMapping?: ResponseMapping;
|
|
17
|
+
/** Configuration for query parameter formatting */
|
|
18
|
+
queryParamConfig?: QueryParamConfig;
|
|
19
|
+
/** Pagination configuration */
|
|
20
|
+
pagination?: {
|
|
21
|
+
enabled: boolean;
|
|
22
|
+
mode: 'client' | 'server';
|
|
23
|
+
pageSize?: number;
|
|
24
|
+
pageIndex?: number;
|
|
25
|
+
};
|
|
26
|
+
/** Filtering configuration */
|
|
27
|
+
filtering?: {
|
|
28
|
+
enabled: boolean;
|
|
29
|
+
mode: 'client' | 'server';
|
|
30
|
+
searchMode?: 'client' | 'server';
|
|
31
|
+
};
|
|
32
|
+
/** Sorting configuration */
|
|
33
|
+
sorting?: {
|
|
34
|
+
enabled: boolean;
|
|
35
|
+
mode: 'client' | 'server';
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
interface UsePagamioTableReturn<T extends BaseEntity> {
|
|
39
|
+
data: T[];
|
|
40
|
+
totalItems: number;
|
|
41
|
+
loading: boolean;
|
|
42
|
+
error: string | null;
|
|
43
|
+
currentPage: number;
|
|
44
|
+
itemsPerPage: number;
|
|
45
|
+
searchQuery: string;
|
|
46
|
+
selectedFilters: Record<string, string>;
|
|
47
|
+
appliedFilters: Record<string, string>;
|
|
48
|
+
sortConfig: SortConfig;
|
|
49
|
+
columns: CoreTableColumnDef<T>[];
|
|
50
|
+
handleApplyFilters: () => void;
|
|
51
|
+
handlePageChange: (newPage: number) => void;
|
|
52
|
+
handlePaginationChange: (newPageIndex: number, newPageSize: number) => void;
|
|
53
|
+
setSearchQuery: (query: string) => void;
|
|
54
|
+
setCurrentPage: (page: number) => void;
|
|
55
|
+
setItemsPerPage: (size: number) => void;
|
|
56
|
+
handleFilterChange: (columnKey: string, value: string) => void;
|
|
57
|
+
handleSort: (sortBy: string, sortDir: 'asc' | 'desc') => void;
|
|
58
|
+
handleClearFilters: () => void;
|
|
59
|
+
refresh: () => void;
|
|
60
|
+
}
|
|
61
|
+
export declare const springBootMapping: ResponseMapping;
|
|
62
|
+
export declare const arrayResponseMapping: ResponseMapping;
|
|
63
|
+
/**
|
|
64
|
+
* Custom hook for managing table data with pagination, sorting, and filtering.
|
|
65
|
+
* Supports both client-side and server-side operations.
|
|
66
|
+
*
|
|
67
|
+
* @template T - The type of data items in the table. Must extend `BaseEntity`.
|
|
68
|
+
*
|
|
69
|
+
* @param {UsePagamioTableProps<T>} props - Configuration options for the hook.
|
|
70
|
+
* @param {Function} [props.fetchData] - Function to fetch data from the API (required for server-side operations).
|
|
71
|
+
* @param {T[]} [props.data] - Initial data for client-side operations.
|
|
72
|
+
* @param {CoreTableColumnDef<T>[]} props.columns - Column definitions for the table.
|
|
73
|
+
* @param {Record<string, string>} [props.defaultFilters] - Initial filter values.
|
|
74
|
+
* @param {ResponseMapping} [props.responseMapping] - Configuration for mapping API response structure.
|
|
75
|
+
* @param {QueryParamConfig} [props.queryParamConfig] - Configuration for query parameter formatting.
|
|
76
|
+
* @param {Object} [props.pagination] - Pagination configuration.
|
|
77
|
+
* @param {boolean} [props.pagination.enabled] - Whether pagination is enabled.
|
|
78
|
+
* @param {'client' | 'server'} [props.pagination.mode] - Pagination mode ('client' or 'server').
|
|
79
|
+
* @param {number} [props.pagination.pageSize] - Default page size.
|
|
80
|
+
* @param {Object} [props.filtering] - Filtering configuration.
|
|
81
|
+
* @param {boolean} [props.filtering.enabled] - Whether filtering is enabled.
|
|
82
|
+
* @param {'client' | 'server'} [props.filtering.mode] - Filtering mode ('client' or 'server').
|
|
83
|
+
* @param {Object} [props.sorting] - Sorting configuration.
|
|
84
|
+
* @param {boolean} [props.sorting.enabled] - Whether sorting is enabled.
|
|
85
|
+
* @param {'client' | 'server'} [props.sorting.mode] - Sorting mode ('client' or 'server').
|
|
86
|
+
*
|
|
87
|
+
* @returns {Object} - Table state and utility functions.
|
|
88
|
+
* @returns {T[]} data - The processed and paginated data.
|
|
89
|
+
* @returns {number} totalItems - Total number of items (for server-side pagination).
|
|
90
|
+
* @returns {boolean} loading - Whether data is being fetched.
|
|
91
|
+
* @returns {string | null} error - Error message, if any.
|
|
92
|
+
* @returns {number} currentPage - Current page index.
|
|
93
|
+
* @returns {number} itemsPerPage - Number of items per page.
|
|
94
|
+
* @returns {string} searchQuery - Current search query.
|
|
95
|
+
* @returns {Record<string, string>} appliedFilters - Currently applied filters.
|
|
96
|
+
* @returns {Record<string, string>} selectedFilters - Currently selected filters.
|
|
97
|
+
* @returns {SortConfig} sortConfig - Current sorting configuration.
|
|
98
|
+
* @returns {CoreTableColumnDef<T>[]} columns - Column definitions.
|
|
99
|
+
* @returns {Function} handleApplyFilters - Function to apply filters.
|
|
100
|
+
* @returns {Function} handlePageChange - Function to change the current page.
|
|
101
|
+
* @returns {Function} handlePaginationChange - Function to change pagination settings.
|
|
102
|
+
* @returns {Function} setSearchQuery - Function to update the search query.
|
|
103
|
+
* @returns {Function} setCurrentPage - Function to update the current page.
|
|
104
|
+
* @returns {Function} setItemsPerPage - Function to update the items per page.
|
|
105
|
+
* @returns {Function} handleFilterChange - Function to update filters.
|
|
106
|
+
* @returns {Function} handleSort - Function to update sorting.
|
|
107
|
+
* @returns {Function} handleClearFilters - Function to clear all filters.
|
|
108
|
+
* @returns {Function} refresh - Function to manually refresh the table data.
|
|
109
|
+
*/
|
|
110
|
+
export declare const usePagamioTable: <T extends BaseEntity>({ fetchData, data: clientData, columns, defaultFilters, responseMapping, queryParamConfig, pagination, filtering, sorting, }: UsePagamioTableProps<T>) => UsePagamioTableReturn<T>;
|
|
111
|
+
export {};
|
|
112
|
+
/**
|
|
113
|
+
* Example usage of the `usePagamioTable` hook.
|
|
114
|
+
*
|
|
115
|
+
* @example
|
|
116
|
+
* const table = usePagamioTable<Product>({
|
|
117
|
+
* fetchData: fetchProducts,
|
|
118
|
+
* columns: columns as unknown as CoreTableColumnDef<Product>[],
|
|
119
|
+
* defaultFilters: initialFilters,
|
|
120
|
+
* pagination: { enabled: true, mode: "server" },
|
|
121
|
+
* filtering: { enabled: true, mode: "server" },
|
|
122
|
+
* queryParamConfig: {
|
|
123
|
+
* filtering: { searchParam: "name", filterFormat: "flat" },
|
|
124
|
+
* },
|
|
125
|
+
* });
|
|
126
|
+
*
|
|
127
|
+
* // Render the table
|
|
128
|
+
* return (
|
|
129
|
+
* <CoreTable
|
|
130
|
+
* columns={table.columns}
|
|
131
|
+
* data={table.data}
|
|
132
|
+
* pagination={{
|
|
133
|
+
* enabled: true,
|
|
134
|
+
* pageIndex: table.currentPage,
|
|
135
|
+
* pageSize: table.itemsPerPage,
|
|
136
|
+
* itemsPerPage: table.itemsPerPage,
|
|
137
|
+
* itemsPerPageOptions: [10, 25, 50],
|
|
138
|
+
* onPageChange: table.handlePageChange,
|
|
139
|
+
* onPaginationChange: table.handlePaginationChange,
|
|
140
|
+
* }}
|
|
141
|
+
* filtering={{
|
|
142
|
+
* filters: filters,
|
|
143
|
+
* appliedFilters: table.selectedFilters,
|
|
144
|
+
* onTableFilter: table.handleFilterChange,
|
|
145
|
+
* }}
|
|
146
|
+
* sorting={{
|
|
147
|
+
* sortConfig: table.sortConfig,
|
|
148
|
+
* onSort: table.handleSort,
|
|
149
|
+
* }}
|
|
150
|
+
* search={{
|
|
151
|
+
* enabled: true,
|
|
152
|
+
* searchQuery: table.searchQuery,
|
|
153
|
+
* onSearch: (e) => table.setSearchQuery(e.target.value),
|
|
154
|
+
* }}
|
|
155
|
+
* onClearFilters={table.handleClearFilters}
|
|
156
|
+
* />
|
|
157
|
+
* );
|
|
158
|
+
*/
|