@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,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
interface BaseDrawerProps {
|
|
3
|
+
title: string;
|
|
4
|
+
isOpen: boolean;
|
|
5
|
+
marginTop?: string;
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
}
|
|
9
|
+
declare const BaseDrawer: React.FC<BaseDrawerProps>;
|
|
10
|
+
export default BaseDrawer;
|
|
11
|
+
export type { BaseDrawerProps };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Drawer } from 'flowbite-react';
|
|
3
|
+
const BaseDrawer = ({ title, isOpen, marginTop = '0px', onClose, children }) => {
|
|
4
|
+
return (_jsxs(Drawer, { open: isOpen, onClose: onClose, backdrop: false, position: "right", className: "flex flex-col px-0 bg-customGray-5 border-l-2 border-gray-100 w-full md:w-[420px]", style: {
|
|
5
|
+
marginTop,
|
|
6
|
+
height: `calc(100vh - ${marginTop})`,
|
|
7
|
+
paddingTop: '0px',
|
|
8
|
+
}, children: [_jsxs("div", { className: "sticky top-0 flex items-center h-12 border-b", style: { zIndex: 100 }, children: [_jsx("div", { className: "flex items-center justify-start pl-6 h-full bg-customGray-25 py-5", style: { width: '88%' }, children: _jsx("h2", { className: "text-lg font-semibold text-black truncate", children: title }) }), _jsx("button", { type: "button", className: "hover:text-gray-500 hover:bg-customGray-15", onClick: onClose, style: { width: '12%', backgroundColor: 'white', height: '3rem' }, children: "x" })] }), children] }));
|
|
9
|
+
};
|
|
10
|
+
export default BaseDrawer;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { DependentFieldUpdate, Field, SelectOption, ValidationRule } from '../../form-engine';
|
|
3
|
+
interface DrawerContentProps {
|
|
4
|
+
fields: Field[];
|
|
5
|
+
onSubmit: (data: any) => Promise<void>;
|
|
6
|
+
initialValues?: any;
|
|
7
|
+
isOpen?: boolean;
|
|
8
|
+
cancelButtonText?: string;
|
|
9
|
+
submitButtonText?: string;
|
|
10
|
+
children?: React.ReactNode;
|
|
11
|
+
showForm?: boolean;
|
|
12
|
+
showDrawerButtons?: boolean;
|
|
13
|
+
handleCloseDrawer: () => void;
|
|
14
|
+
onFieldUpdate?: Record<string, DependentFieldUpdate[]>;
|
|
15
|
+
onFieldChange?: (fieldName: string, value: any) => void;
|
|
16
|
+
updateFieldOptions?: (field: string, options: Array<SelectOption | string>) => void;
|
|
17
|
+
updateFieldLabel?: (fieldName: string, newLabelName: string) => void;
|
|
18
|
+
setFieldHidden?: (fieldName: string, hidden: boolean) => void;
|
|
19
|
+
addField?: (fields: Field) => void;
|
|
20
|
+
updateFieldValidation?: (fieldName: string, newValidation: ValidationRule) => void;
|
|
21
|
+
processInitialFieldUpdates?: (getValues: (name?: string) => any) => Promise<void>;
|
|
22
|
+
processingDependencyRef?: React.MutableRefObject<boolean>;
|
|
23
|
+
pendingUpdatesRef?: React.MutableRefObject<Map<string, any>>;
|
|
24
|
+
persistenceKey?: string;
|
|
25
|
+
}
|
|
26
|
+
declare const DrawerContent: React.FC<DrawerContentProps>;
|
|
27
|
+
export default DrawerContent;
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useForm } from 'react-hook-form';
|
|
3
|
+
import { useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { Button, NotificationModal } from '../../components';
|
|
5
|
+
import { FieldWrapper } from '../../form-engine';
|
|
6
|
+
import { useFormPersistence } from '../../form-engine/hooks/useFormPersistence';
|
|
7
|
+
const DrawerContent = ({ fields, onSubmit, isOpen, initialValues, submitButtonText = 'Submit', cancelButtonText = 'Cancel', showForm = true, showDrawerButtons = true, handleCloseDrawer, onFieldUpdate, onFieldChange, children, updateFieldOptions, updateFieldLabel, setFieldHidden, addField, updateFieldValidation, processInitialFieldUpdates, processingDependencyRef, pendingUpdatesRef, persistenceKey, }) => {
|
|
8
|
+
const { saveFormData, restoreFormData, clearPersistedData, hasPersistedData } = useFormPersistence(persistenceKey);
|
|
9
|
+
// Determine initial values: initialValues take precedence over persisted data
|
|
10
|
+
// This ensures that when editing different items, the form shows the correct item's data
|
|
11
|
+
const getEffectiveInitialValues = () => {
|
|
12
|
+
// If initialValues are provided, use them
|
|
13
|
+
if (initialValues && Object.keys(initialValues).length > 0) {
|
|
14
|
+
return initialValues;
|
|
15
|
+
}
|
|
16
|
+
// Otherwise, check for persisted data
|
|
17
|
+
if (persistenceKey && hasPersistedData()) {
|
|
18
|
+
const persistedData = restoreFormData();
|
|
19
|
+
if (persistedData) {
|
|
20
|
+
return persistedData;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
return initialValues || {};
|
|
24
|
+
};
|
|
25
|
+
const { control, handleSubmit, watch, setValue, clearErrors, formState: { errors, isSubmitting }, reset, getValues, } = useForm({ mode: 'onBlur', defaultValues: getEffectiveInitialValues() });
|
|
26
|
+
const [pendingUpdateCount, setPendingUpdateCount] = useState(0);
|
|
27
|
+
const [submitError, setSubmitError] = useState(null);
|
|
28
|
+
const [showCancelConfirmModal, setShowCancelConfirmModal] = useState(false);
|
|
29
|
+
const fieldChangeRef = useRef(new Set());
|
|
30
|
+
const initialLoadPerformedRef = useRef(false);
|
|
31
|
+
const password = watch('password');
|
|
32
|
+
const allFields = watch();
|
|
33
|
+
// Function to check if there are unsaved changes
|
|
34
|
+
const checkUnsavedChanges = () => {
|
|
35
|
+
if (!allFields || Object.keys(allFields).length === 0)
|
|
36
|
+
return false;
|
|
37
|
+
const originalInitialValues = initialValues || {};
|
|
38
|
+
return Object.keys(allFields).some((key) => {
|
|
39
|
+
const currentValue = allFields[key];
|
|
40
|
+
const originalValue = originalInitialValues[key];
|
|
41
|
+
// Handle different value types
|
|
42
|
+
if (currentValue === originalValue)
|
|
43
|
+
return false;
|
|
44
|
+
if (currentValue === '' && (originalValue === null || originalValue === undefined))
|
|
45
|
+
return false;
|
|
46
|
+
if ((currentValue === null || currentValue === undefined) && originalValue === '')
|
|
47
|
+
return false;
|
|
48
|
+
return true;
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
// Save form data when fields change (for persistence)
|
|
52
|
+
useEffect(() => {
|
|
53
|
+
if (persistenceKey && allFields && Object.keys(allFields).length > 0) {
|
|
54
|
+
// Only save if there are actual field values (not just empty object)
|
|
55
|
+
const hasValues = Object.values(allFields).some((value) => value !== undefined && value !== null && value !== '');
|
|
56
|
+
if (hasValues) {
|
|
57
|
+
saveFormData(allFields, true);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}, [allFields, persistenceKey, saveFormData]);
|
|
61
|
+
// Process initial field updates once when drawer opens
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
if (isOpen && !initialLoadPerformedRef.current && processInitialFieldUpdates) {
|
|
64
|
+
const initializeFields = async () => {
|
|
65
|
+
await processInitialFieldUpdates(getValues);
|
|
66
|
+
initialLoadPerformedRef.current = true;
|
|
67
|
+
};
|
|
68
|
+
initializeFields();
|
|
69
|
+
}
|
|
70
|
+
// Reset initialization flag when drawer closes
|
|
71
|
+
if (!isOpen) {
|
|
72
|
+
initialLoadPerformedRef.current = false;
|
|
73
|
+
fieldChangeRef.current.clear();
|
|
74
|
+
}
|
|
75
|
+
}, [isOpen, processInitialFieldUpdates]);
|
|
76
|
+
const handleFormSubmit = async (data) => {
|
|
77
|
+
setSubmitError(null);
|
|
78
|
+
try {
|
|
79
|
+
const visibleFieldsData = Object.fromEntries(Object.entries(data).filter(([key]) => !fields.find((field) => field.name === key && field.isHidden)));
|
|
80
|
+
await onSubmit(visibleFieldsData);
|
|
81
|
+
// Clear persisted data on successful submission
|
|
82
|
+
if (persistenceKey) {
|
|
83
|
+
clearPersistedData();
|
|
84
|
+
}
|
|
85
|
+
// Close drawer after successful submission
|
|
86
|
+
handleCloseDrawer();
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
setSubmitError(error instanceof Error ? error.message : 'An error occurred');
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
// Reset form when drawer closes
|
|
93
|
+
useEffect(() => {
|
|
94
|
+
if (!isOpen) {
|
|
95
|
+
reset();
|
|
96
|
+
// Clear persisted data when drawer closes to prevent stale data on next open
|
|
97
|
+
if (persistenceKey) {
|
|
98
|
+
clearPersistedData();
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}, [isOpen, reset, persistenceKey, clearPersistedData]);
|
|
102
|
+
// Reset form when initialValues change
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
if (isOpen && initialValues) {
|
|
105
|
+
reset(initialValues);
|
|
106
|
+
}
|
|
107
|
+
}, [initialValues, isOpen, reset]);
|
|
108
|
+
const handleCancel = () => {
|
|
109
|
+
if (checkUnsavedChanges()) {
|
|
110
|
+
setShowCancelConfirmModal(true);
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
// No changes detected, just close the drawer directly
|
|
114
|
+
handleCloseDrawer();
|
|
115
|
+
}
|
|
116
|
+
};
|
|
117
|
+
const handleDiscardChanges = () => {
|
|
118
|
+
// Clear persisted data when explicitly discarding changes
|
|
119
|
+
if (persistenceKey) {
|
|
120
|
+
clearPersistedData();
|
|
121
|
+
}
|
|
122
|
+
setShowCancelConfirmModal(false);
|
|
123
|
+
handleCloseDrawer();
|
|
124
|
+
};
|
|
125
|
+
const handleSaveAndClose = () => {
|
|
126
|
+
// Just close the drawer without submitting - the form data is already persisted
|
|
127
|
+
setShowCancelConfirmModal(false);
|
|
128
|
+
handleCloseDrawer();
|
|
129
|
+
};
|
|
130
|
+
const handleContinueEditing = () => {
|
|
131
|
+
setShowCancelConfirmModal(false);
|
|
132
|
+
};
|
|
133
|
+
// Helper function to process dependency validations
|
|
134
|
+
const processDependencyValidation = (field) => {
|
|
135
|
+
if (!field.validation?.dependency) {
|
|
136
|
+
return field.validation;
|
|
137
|
+
}
|
|
138
|
+
const dependencies = Array.isArray(field.validation.dependency)
|
|
139
|
+
? field.validation.dependency
|
|
140
|
+
: [field.validation.dependency];
|
|
141
|
+
let finalValidation = { ...field.validation };
|
|
142
|
+
delete finalValidation.dependency;
|
|
143
|
+
// Apply each dependency validation if its condition is met
|
|
144
|
+
for (const dep of dependencies) {
|
|
145
|
+
const dependencyValue = watch(dep.field);
|
|
146
|
+
if (dep.condition(dependencyValue)) {
|
|
147
|
+
finalValidation = { ...finalValidation, ...dep.validationToApply };
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return {
|
|
151
|
+
...finalValidation,
|
|
152
|
+
validate: field.name === 'confirmPassword'
|
|
153
|
+
? (value) => value === password || 'Passwords do not match'
|
|
154
|
+
: finalValidation.validate,
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
// Helper function to apply a single update result
|
|
158
|
+
const applyUpdateResult = (result) => {
|
|
159
|
+
if (!result)
|
|
160
|
+
return;
|
|
161
|
+
const { field, options, value, label, hideField, fieldInnitialData } = result;
|
|
162
|
+
// Apply each possible update type if needed
|
|
163
|
+
if (options !== undefined && updateFieldOptions) {
|
|
164
|
+
updateFieldOptions(field, options);
|
|
165
|
+
}
|
|
166
|
+
if (value !== undefined && setValue) {
|
|
167
|
+
setValue(field, value);
|
|
168
|
+
}
|
|
169
|
+
if (label !== undefined && updateFieldLabel) {
|
|
170
|
+
updateFieldLabel(field, label);
|
|
171
|
+
}
|
|
172
|
+
if (hideField !== undefined && setFieldHidden) {
|
|
173
|
+
setFieldHidden(field, hideField);
|
|
174
|
+
if (hideField && setValue) {
|
|
175
|
+
setValue(field, undefined);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
if (fieldInnitialData && addField) {
|
|
179
|
+
addField(fieldInnitialData);
|
|
180
|
+
}
|
|
181
|
+
if (clearErrors) {
|
|
182
|
+
clearErrors(field);
|
|
183
|
+
}
|
|
184
|
+
};
|
|
185
|
+
// Helper function to process updates for a single field
|
|
186
|
+
const processFieldUpdates = async (fieldName, value) => {
|
|
187
|
+
if (!onFieldUpdate?.[fieldName])
|
|
188
|
+
return;
|
|
189
|
+
const updates = onFieldUpdate[fieldName];
|
|
190
|
+
for (const update of updates) {
|
|
191
|
+
try {
|
|
192
|
+
const result = await update.action(value, false);
|
|
193
|
+
applyUpdateResult(result);
|
|
194
|
+
}
|
|
195
|
+
catch (error) {
|
|
196
|
+
console.error(`Error processing update for ${fieldName}:`, error);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
// Main function with reduced complexity
|
|
201
|
+
const processPendingUpdates = async () => {
|
|
202
|
+
// Early return if conditions aren't met
|
|
203
|
+
if (!pendingUpdatesRef || !processingDependencyRef || processingDependencyRef.current) {
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
processingDependencyRef.current = true;
|
|
207
|
+
try {
|
|
208
|
+
const pendingUpdates = pendingUpdatesRef.current;
|
|
209
|
+
if (pendingUpdates.size === 0)
|
|
210
|
+
return;
|
|
211
|
+
// Process all pending updates
|
|
212
|
+
const updatePromises = Array.from(pendingUpdates.entries()).map(([fieldName, value]) => processFieldUpdates(fieldName, value));
|
|
213
|
+
await Promise.all(updatePromises);
|
|
214
|
+
pendingUpdatesRef.current.clear();
|
|
215
|
+
}
|
|
216
|
+
finally {
|
|
217
|
+
processingDependencyRef.current = false;
|
|
218
|
+
}
|
|
219
|
+
};
|
|
220
|
+
// Process pending updates when needed
|
|
221
|
+
useEffect(() => {
|
|
222
|
+
if (pendingUpdatesRef?.current?.size && pendingUpdatesRef?.current?.size > 0) {
|
|
223
|
+
processPendingUpdates().then();
|
|
224
|
+
}
|
|
225
|
+
}, [pendingUpdateCount]);
|
|
226
|
+
return (_jsxs(_Fragment, { children: [showForm && (_jsxs("form", { className: "grid grid-cols-12 gap-2 align-middle mb-6 border-gray-400 px-6 py-5", onSubmit: handleSubmit(handleFormSubmit), children: [fields?.map((field) => (_jsx(FieldWrapper, { field: {
|
|
227
|
+
...field,
|
|
228
|
+
validation: processDependencyValidation(field),
|
|
229
|
+
}, control: control, errors: errors, layout: "vertical", onFieldUpdate: onFieldUpdate, onFieldChange: onFieldChange, updateFieldOptions: updateFieldOptions, updateFieldLabel: updateFieldLabel, setFieldHidden: setFieldHidden, addField: addField, setValue: setValue, clearErrors: clearErrors, getValues: getValues, pendingUpdatesRef: pendingUpdatesRef, notifyPendingUpdate: () => setPendingUpdateCount((prev) => prev + 1), processingDependencyRef: processingDependencyRef, fieldChangeRef: fieldChangeRef }, field.name))), isSubmitting && _jsx("span", { children: "Submitting..." }), submitError && _jsx("p", { className: "text-red-500", children: submitError })] })), children, showDrawerButtons && (_jsxs("div", { className: "flex border-t bg-white", style: {
|
|
230
|
+
height: '50px',
|
|
231
|
+
position: 'fixed',
|
|
232
|
+
bottom: 0,
|
|
233
|
+
zIndex: 100,
|
|
234
|
+
width: '420px',
|
|
235
|
+
}, children: [_jsx(Button, { variant: "outline-primary", className: "w-full flex-1 h-full rounded-none", disabled: isSubmitting, onClick: handleCancel, children: cancelButtonText }), _jsx(Button, { variant: "primary", className: "flex-1 h-full rounded-none", disabled: isSubmitting, onClick: handleSubmit(handleFormSubmit), children: submitButtonText })] })), _jsx(NotificationModal, { show: showCancelConfirmModal, onClose: handleContinueEditing, title: "Unsaved Changes", message: "You have unsaved changes. What would you like to do?", variant: "warning", showConfirmButton: false, showCancelButton: false, size: "lg", children: _jsxs("div", { className: "flex gap-2 flex-wrap", children: [_jsx(Button, { variant: "primary", onClick: handleSaveAndClose, children: "Save & Close" }), _jsx(Button, { variant: "outline", onClick: handleDiscardChanges, children: "Discard Changes" }), _jsx(Button, { variant: "outline", onClick: handleContinueEditing, children: "Continue Editing" })] }) })] }));
|
|
236
|
+
};
|
|
237
|
+
export default DrawerContent;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { DependentFieldUpdate, Field } from '../form-engine';
|
|
3
|
+
interface FormEngineDrawerProps {
|
|
4
|
+
title: string;
|
|
5
|
+
isOpen: boolean;
|
|
6
|
+
showForm?: boolean;
|
|
7
|
+
showDrawerButtons?: boolean;
|
|
8
|
+
cancelButtonText?: string;
|
|
9
|
+
submitButtonText?: string;
|
|
10
|
+
marginTop?: string;
|
|
11
|
+
children?: React.ReactNode;
|
|
12
|
+
fields: Field[];
|
|
13
|
+
initialValues?: any;
|
|
14
|
+
onSubmit: (data: any) => Promise<void>;
|
|
15
|
+
onClose: () => void;
|
|
16
|
+
onFieldUpdate?: Record<string, DependentFieldUpdate[]>;
|
|
17
|
+
onFieldChange?: (fieldName: string, value: any) => void;
|
|
18
|
+
persistenceKey?: string;
|
|
19
|
+
}
|
|
20
|
+
declare const FormEngineDrawer: React.FC<FormEngineDrawerProps>;
|
|
21
|
+
export default FormEngineDrawer;
|
|
22
|
+
export type { FormEngineDrawerProps, DependentFieldUpdate };
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useRef, useState } from 'react';
|
|
3
|
+
import BaseDrawer from './components/BaseDrawer';
|
|
4
|
+
import DrawerContent from './components/DrawerContent';
|
|
5
|
+
const FormEngineDrawer = ({ title, cancelButtonText = 'Cancel', submitButtonText = 'Submit', showForm = true, showDrawerButtons = true, isOpen, fields: initialFields, initialValues, children, marginTop = '0px', onClose, onSubmit, onFieldUpdate, onFieldChange, persistenceKey, }) => {
|
|
6
|
+
const [fields, setFields] = useState(initialFields);
|
|
7
|
+
const initializedRef = useRef(false);
|
|
8
|
+
const processingDependencyRef = useRef(false);
|
|
9
|
+
const pendingUpdatesRef = useRef(new Map());
|
|
10
|
+
// Update fields when initialFields changes while preserving values
|
|
11
|
+
useEffect(() => {
|
|
12
|
+
setFields((prevFields) => {
|
|
13
|
+
const existingFieldsMap = new Map(prevFields.map((field) => [field.name, field]));
|
|
14
|
+
return initialFields.map((newField) => {
|
|
15
|
+
const existingField = existingFieldsMap.get(newField.name);
|
|
16
|
+
if (existingField) {
|
|
17
|
+
return {
|
|
18
|
+
...existingField,
|
|
19
|
+
...newField,
|
|
20
|
+
options: existingField.options || newField.options,
|
|
21
|
+
label: existingField.label || newField.label,
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return newField;
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}, [initialFields]);
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
if (isOpen) {
|
|
30
|
+
document.body.classList.add('overflow-hidden');
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
document.body.classList.remove('overflow-hidden');
|
|
34
|
+
// Reset initialization flag when drawer closes
|
|
35
|
+
initializedRef.current = false;
|
|
36
|
+
// Clear pending updates to prevent stale state
|
|
37
|
+
pendingUpdatesRef.current.clear();
|
|
38
|
+
// Reset fields to initial state when drawer closes
|
|
39
|
+
setFields(initialFields);
|
|
40
|
+
}
|
|
41
|
+
return () => {
|
|
42
|
+
document.body.classList.remove('overflow-hidden');
|
|
43
|
+
};
|
|
44
|
+
}, [isOpen, initialFields]);
|
|
45
|
+
const setFieldHidden = (fieldName, hidden) => {
|
|
46
|
+
setFields((currentFields) => currentFields.map((field) => (field.name === fieldName ? { ...field, isHidden: hidden } : field)));
|
|
47
|
+
};
|
|
48
|
+
const updateFieldLabel = (fieldName, newLabelName) => {
|
|
49
|
+
setFields((currentFields) => currentFields.map((field) => (field.name === fieldName ? { ...field, label: newLabelName } : field)));
|
|
50
|
+
};
|
|
51
|
+
const updateFieldOptions = (fieldName, newOptions) => {
|
|
52
|
+
setFields((currentFields) => currentFields.map((field) => (field.name === fieldName ? { ...field, options: newOptions } : field)));
|
|
53
|
+
};
|
|
54
|
+
const updateFieldValidation = (fieldName, newValidation) => {
|
|
55
|
+
setFields((currentFields) => currentFields.map((field) => field.name === fieldName
|
|
56
|
+
? {
|
|
57
|
+
...field,
|
|
58
|
+
validation: {
|
|
59
|
+
...(field.validation ?? {}),
|
|
60
|
+
...newValidation,
|
|
61
|
+
},
|
|
62
|
+
}
|
|
63
|
+
: field));
|
|
64
|
+
};
|
|
65
|
+
const addField = (field) => {
|
|
66
|
+
const isFieldAlreadyAdded = fields.some((f) => f.name === field.name);
|
|
67
|
+
if (isFieldAlreadyAdded) {
|
|
68
|
+
updateFieldLabel(field.name, field.label);
|
|
69
|
+
if (field.options) {
|
|
70
|
+
updateFieldOptions(field.name, field.options);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
else {
|
|
74
|
+
setFields((currentFields) => [...currentFields, field]);
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
// Helper function to check if a value is valid for processing
|
|
78
|
+
const isValidValue = (value) => {
|
|
79
|
+
return value !== undefined && value !== null && value !== '';
|
|
80
|
+
};
|
|
81
|
+
// Helper function to apply field updates based on the result
|
|
82
|
+
const applyFieldUpdate = (result) => {
|
|
83
|
+
if (!result)
|
|
84
|
+
return;
|
|
85
|
+
// Apply field modifications based on result
|
|
86
|
+
if (result.hideField !== undefined && setFieldHidden) {
|
|
87
|
+
setFieldHidden(result.field, result.hideField);
|
|
88
|
+
}
|
|
89
|
+
if (result.options !== undefined && updateFieldOptions) {
|
|
90
|
+
updateFieldOptions(result.field, result.options);
|
|
91
|
+
}
|
|
92
|
+
if (result.label !== undefined && updateFieldLabel) {
|
|
93
|
+
updateFieldLabel(result.field, result.label);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
// Process a single field's updates
|
|
97
|
+
const processFieldUpdate = async (fieldName, updates, value) => {
|
|
98
|
+
for (const update of updates) {
|
|
99
|
+
try {
|
|
100
|
+
const result = await update.action(value, true);
|
|
101
|
+
applyFieldUpdate(result);
|
|
102
|
+
}
|
|
103
|
+
catch (error) {
|
|
104
|
+
console.error(`Error processing initial dependency for ${fieldName}:`, error);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
// Main function with reduced complexity
|
|
109
|
+
const processInitialFieldUpdates = async (getValues) => {
|
|
110
|
+
// Early return if conditions aren't met
|
|
111
|
+
if (!onFieldUpdate || initializedRef.current || processingDependencyRef.current)
|
|
112
|
+
return;
|
|
113
|
+
processingDependencyRef.current = true;
|
|
114
|
+
try {
|
|
115
|
+
const processedFields = new Set();
|
|
116
|
+
for (const [fieldName, updates] of Object.entries(onFieldUpdate)) {
|
|
117
|
+
if (processedFields.has(fieldName))
|
|
118
|
+
continue;
|
|
119
|
+
const currentValue = getValues(fieldName);
|
|
120
|
+
if (!isValidValue(currentValue))
|
|
121
|
+
continue;
|
|
122
|
+
await processFieldUpdate(fieldName, updates, currentValue);
|
|
123
|
+
processedFields.add(fieldName);
|
|
124
|
+
}
|
|
125
|
+
initializedRef.current = true;
|
|
126
|
+
}
|
|
127
|
+
finally {
|
|
128
|
+
processingDependencyRef.current = false;
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
return (_jsx(BaseDrawer, { title: title, isOpen: isOpen, marginTop: marginTop, onClose: onClose, children: _jsx(DrawerContent, { isOpen: isOpen, fields: fields, onSubmit: onSubmit, handleCloseDrawer: onClose, initialValues: initialValues, showForm: showForm, showDrawerButtons: showDrawerButtons, cancelButtonText: cancelButtonText, submitButtonText: submitButtonText, onFieldUpdate: onFieldUpdate, onFieldChange: onFieldChange, updateFieldOptions: updateFieldOptions, updateFieldLabel: updateFieldLabel, setFieldHidden: setFieldHidden, addField: addField, updateFieldValidation: updateFieldValidation, processInitialFieldUpdates: processInitialFieldUpdates, processingDependencyRef: processingDependencyRef, pendingUpdatesRef: pendingUpdatesRef, persistenceKey: persistenceKey, children: children }, `${persistenceKey}-${isOpen ? 'open' : 'closed'}`) }));
|
|
132
|
+
};
|
|
133
|
+
export default FormEngineDrawer;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { type MRT_ColumnDef } from 'mantine-react-table';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
export type ExtraOption = {
|
|
4
|
+
value: string;
|
|
5
|
+
label: React.ReactNode;
|
|
6
|
+
onClick: () => void;
|
|
7
|
+
};
|
|
8
|
+
interface ThemeColors {
|
|
9
|
+
primary: {
|
|
10
|
+
500: string;
|
|
11
|
+
600: string;
|
|
12
|
+
700: string;
|
|
13
|
+
};
|
|
14
|
+
core: {
|
|
15
|
+
primary: string;
|
|
16
|
+
secondary: string;
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
interface PdfExportOptions {
|
|
20
|
+
title?: string;
|
|
21
|
+
subtitle?: string;
|
|
22
|
+
colors?: ThemeColors;
|
|
23
|
+
logo?: {
|
|
24
|
+
url: string;
|
|
25
|
+
width?: number;
|
|
26
|
+
height?: number;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
interface XlsxExportOptions {
|
|
30
|
+
title?: string;
|
|
31
|
+
subtitle?: string;
|
|
32
|
+
colors?: ThemeColors;
|
|
33
|
+
sheetName?: string;
|
|
34
|
+
includeTimestamp?: boolean;
|
|
35
|
+
autoFitColumns?: boolean;
|
|
36
|
+
}
|
|
37
|
+
interface CsvExportOptions {
|
|
38
|
+
title?: string;
|
|
39
|
+
includeTimestamp?: boolean;
|
|
40
|
+
includeHeaders?: boolean;
|
|
41
|
+
delimiter?: string;
|
|
42
|
+
filename?: string;
|
|
43
|
+
}
|
|
44
|
+
type ExportDropdownProps<T extends Record<string, any>> = {
|
|
45
|
+
data: T[];
|
|
46
|
+
columns: MRT_ColumnDef<T>[];
|
|
47
|
+
containerClassName?: string;
|
|
48
|
+
buttonClassName?: string;
|
|
49
|
+
extraOptions?: ExtraOption[];
|
|
50
|
+
pdfOptions?: PdfExportOptions;
|
|
51
|
+
xlsxOptions?: XlsxExportOptions;
|
|
52
|
+
csvOptions?: CsvExportOptions;
|
|
53
|
+
exportAll?: boolean;
|
|
54
|
+
fetchData?: (params?: Record<string, string>) => Promise<T[]>;
|
|
55
|
+
};
|
|
56
|
+
declare const ExportDropdown: <T extends Record<string, any>>({ data, columns, containerClassName, buttonClassName, extraOptions, pdfOptions, xlsxOptions, csvOptions, exportAll, fetchData, }: ExportDropdownProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
57
|
+
export default ExportDropdown;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { Stack } from '@mantine/core';
|
|
3
|
+
import { Checkbox, Label } from 'flowbite-react';
|
|
4
|
+
import { useEffect, useRef, useState } from 'react';
|
|
5
|
+
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../../components';
|
|
6
|
+
import { exportToCsv, exportToPdf, exportToXlsx } from './exportUtils';
|
|
7
|
+
const ExportDropdown = ({ data, columns, containerClassName, buttonClassName, extraOptions = [], pdfOptions, xlsxOptions, csvOptions, exportAll = false, fetchData, }) => {
|
|
8
|
+
const [popoverOpened, setPopoverOpened] = useState(false);
|
|
9
|
+
const [exportType, setExportType] = useState(null);
|
|
10
|
+
const [excludedColumns, setExcludedColumns] = useState(['action']);
|
|
11
|
+
const [isExporting, setIsExporting] = useState(false);
|
|
12
|
+
const [exportAllData, setExportAllData] = useState(false);
|
|
13
|
+
const popoverRef = useRef(null);
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
const handleClickOutside = (event) => {
|
|
16
|
+
if (popoverRef.current && !popoverRef.current.contains(event.target)) {
|
|
17
|
+
setPopoverOpened(false);
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
document.addEventListener('mousedown', handleClickOutside);
|
|
21
|
+
return () => {
|
|
22
|
+
document.removeEventListener('mousedown', handleClickOutside);
|
|
23
|
+
};
|
|
24
|
+
}, []);
|
|
25
|
+
const exportOptions = [
|
|
26
|
+
{ value: 'csv', label: 'Export as CSV' },
|
|
27
|
+
{ value: 'xlsx', label: 'Export as XLSX' },
|
|
28
|
+
{ value: 'pdf', label: 'Export as PDF' },
|
|
29
|
+
];
|
|
30
|
+
const handleCheckboxChange = (columnKey, checked) => {
|
|
31
|
+
setExcludedColumns((prev) => (checked ? [...prev, columnKey] : prev.filter((key) => key !== columnKey)));
|
|
32
|
+
};
|
|
33
|
+
const getIncludedColumns = () => {
|
|
34
|
+
return columns.filter((col) => !excludedColumns.includes(col.accessorKey));
|
|
35
|
+
};
|
|
36
|
+
const handleContinue = async () => {
|
|
37
|
+
const includedColumns = getIncludedColumns();
|
|
38
|
+
setIsExporting(true);
|
|
39
|
+
try {
|
|
40
|
+
let exportData = data;
|
|
41
|
+
// If exportAll is checked and fetchData function is provided, fetch all data
|
|
42
|
+
if (exportAllData && fetchData) {
|
|
43
|
+
exportData = await fetchData({ exportAll: 'true' });
|
|
44
|
+
}
|
|
45
|
+
if (exportType === 'csv') {
|
|
46
|
+
exportToCsv(exportData, includedColumns, csvOptions);
|
|
47
|
+
}
|
|
48
|
+
else if (exportType === 'xlsx') {
|
|
49
|
+
exportToXlsx(exportData, includedColumns, xlsxOptions);
|
|
50
|
+
}
|
|
51
|
+
else if (exportType === 'pdf') {
|
|
52
|
+
// Pass PDF options with enhanced configuration
|
|
53
|
+
await exportToPdf(exportData, includedColumns, {
|
|
54
|
+
title: pdfOptions?.title || 'Data Export',
|
|
55
|
+
subtitle: pdfOptions?.subtitle,
|
|
56
|
+
colors: pdfOptions?.colors,
|
|
57
|
+
logo: pdfOptions?.logo,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
console.error('Export failed:', error);
|
|
63
|
+
}
|
|
64
|
+
finally {
|
|
65
|
+
setIsExporting(false);
|
|
66
|
+
setPopoverOpened(false);
|
|
67
|
+
setExportType(null);
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
const handleExportChange = (type) => {
|
|
71
|
+
if (!type || type === 'none') {
|
|
72
|
+
setExportType(null);
|
|
73
|
+
setPopoverOpened(false);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
// Check if type is an extraOption
|
|
77
|
+
const extra = extraOptions.find((opt) => opt.value === type);
|
|
78
|
+
if (extra) {
|
|
79
|
+
extra.onClick();
|
|
80
|
+
setPopoverOpened(false);
|
|
81
|
+
setExportType(null);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
setExportType(type);
|
|
85
|
+
setPopoverOpened(type !== exportType);
|
|
86
|
+
};
|
|
87
|
+
return (_jsxs("div", { className: `w-40 ${containerClassName ?? ''}`, children: [_jsxs(Select, { value: exportType ?? 'none', onValueChange: (value) => handleExportChange(value === 'none' ? null : value), children: [_jsx(SelectTrigger, { className: `w-full ${buttonClassName ?? ''}`, children: _jsx(SelectValue, { placeholder: "Export Data" }) }), _jsxs(SelectContent, { children: [_jsx(SelectItem, { value: "none", children: _jsx("span", { className: "text-gray-500", children: "Export Data As" }) }, "reset"), exportOptions.map((option) => (_jsx(SelectItem, { value: option.value, children: option.label }, option.value))), extraOptions.map((option) => (_jsx(SelectItem, { value: option.value, children: option.label }, option.value)))] })] }, "export-dropdown"), popoverOpened && (_jsxs("div", { ref: popoverRef, className: "mt-2 bg-white rounded-md shadow-lg p-4 z-50 absolute w-45", children: [_jsx("div", { className: "text-sm text-gray-500 pb-3", children: "Uncheck to exclude column from export" }), _jsxs("div", { className: "mb-4 p-3 bg-gray-50 rounded-md", children: [_jsxs("div", { className: "flex items-center gap-x-2", children: [_jsx(Checkbox, { id: "export-all-data", checked: exportAllData, onChange: (event) => setExportAllData(event.currentTarget.checked), className: "checked:!bg-primary-500 checked:!border-primary-500" }), _jsx(Label, { htmlFor: "export-all-data", className: "text-sm font-medium", children: "Export all data" })] }), _jsx("p", { className: "text-xs text-gray-500 mt-1 ml-6", children: "This will fetch all records for the table" })] }), _jsx(Stack, { children: columns.map((col) => {
|
|
88
|
+
if (col.accessorKey !== 'action') {
|
|
89
|
+
return (_jsxs("div", { className: "flex items-center gap-x-2", children: [_jsx(Checkbox, { id: col.header, checked: !excludedColumns.includes(col.accessorKey), onChange: (event) => handleCheckboxChange(col.accessorKey, !event.currentTarget.checked), className: "checked:!bg-primary-500 checked:!border-primary-500" }), _jsx(Label, { htmlFor: "rememberMe", children: col.header })] }, col.accessorKey));
|
|
90
|
+
}
|
|
91
|
+
}) }), _jsx("button", { className: `w-full mt-4 px-4 py-2 rounded-md text-white flex items-center justify-center
|
|
92
|
+
${getIncludedColumns().length === 0 || isExporting
|
|
93
|
+
? 'bg-gray-300 cursor-not-allowed'
|
|
94
|
+
: 'bg-primary-500 hover:bg-primary-600'}`, onClick: handleContinue, disabled: getIncludedColumns().length === 0 || isExporting, children: isExporting ? (_jsxs(_Fragment, { children: [_jsxs("svg", { className: "animate-spin -ml-1 mr-2 h-4 w-4 text-white", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", children: [_jsx("circle", { className: "opacity-25", cx: "12", cy: "12", r: "10", stroke: "currentColor", strokeWidth: "4" }), _jsx("path", { className: "opacity-75", fill: "currentColor", d: "M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" })] }), "Exporting..."] })) : ('Continue') })] }))] }));
|
|
95
|
+
};
|
|
96
|
+
export default ExportDropdown;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { type MRT_Row, type MRT_TableInstance } from 'mantine-react-table';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import type { CoreTableColumnDef, SortConfig } from './types';
|
|
4
|
+
type CoreTableProps<T extends {
|
|
5
|
+
id: string | number;
|
|
6
|
+
}> = {
|
|
7
|
+
columns: CoreTableColumnDef<T>[];
|
|
8
|
+
isLoading?: boolean;
|
|
9
|
+
data: T[];
|
|
10
|
+
sortable?: boolean;
|
|
11
|
+
multiSorting: boolean;
|
|
12
|
+
sortConfig?: SortConfig | null;
|
|
13
|
+
onSort?: (sortKey: string, sortDirection: 'asc' | 'desc') => void;
|
|
14
|
+
setSortBy?: (sortKey: string) => void;
|
|
15
|
+
setSortDir?: (sortDir: string) => void;
|
|
16
|
+
selectable?: boolean;
|
|
17
|
+
selectedRows?: (string | number)[];
|
|
18
|
+
onSelectRow?: (id: string | number) => void;
|
|
19
|
+
onSelectAll?: (selected: boolean) => void;
|
|
20
|
+
enablePagination?: boolean;
|
|
21
|
+
enableGlobalFilters?: boolean;
|
|
22
|
+
enableManualSorting?: boolean;
|
|
23
|
+
enableManualPagination?: boolean;
|
|
24
|
+
expandable?: boolean;
|
|
25
|
+
onRowClick?: (row: T) => void;
|
|
26
|
+
rowClassName?: string;
|
|
27
|
+
renderExpandableComponent?: (props: {
|
|
28
|
+
row: MRT_Row<T>;
|
|
29
|
+
table: MRT_TableInstance<T>;
|
|
30
|
+
}) => React.ReactNode;
|
|
31
|
+
pagination?: {
|
|
32
|
+
enabled: boolean;
|
|
33
|
+
pageIndex: number;
|
|
34
|
+
pageSize: number;
|
|
35
|
+
itemsPerPage: number;
|
|
36
|
+
itemsPerPageOptions?: number[];
|
|
37
|
+
onPageChange: (page: number) => void;
|
|
38
|
+
onPaginationChange: (index: number, size: number) => void;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
declare const CoreTable: <T extends {
|
|
42
|
+
id: string | number;
|
|
43
|
+
}>({ columns, isLoading, data, sortable, sortConfig, onSort, selectable, selectedRows, onSelectRow, onSelectAll, enablePagination, expandable, renderExpandableComponent, pagination, enableGlobalFilters, enableManualSorting, enableManualPagination, multiSorting, setSortBy, setSortDir, onRowClick, rowClassName, ...props }: CoreTableProps<T>) => import("react/jsx-runtime").JSX.Element;
|
|
44
|
+
export default CoreTable;
|