@jmruthers/pace-core 0.5.74 → 0.5.76
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/dist/DataTable-4GAVPIEG.js +120 -0
- package/dist/{PublicLoadingSpinner-DLpF5bbs.d.ts → PublicLoadingSpinner-BiNER8F5.d.ts} +30 -19
- package/dist/RBACService-C4udt_Zp.d.ts +528 -0
- package/dist/{UnifiedAuthProvider-K4NRGXL4.js → UnifiedAuthProvider-3NKDOSOK.js} +6 -4
- package/dist/UnifiedAuthProvider-Bj6YCf7c.d.ts +113 -0
- package/dist/chunk-5F3NDPJV.js +232 -0
- package/dist/chunk-5F3NDPJV.js.map +1 -0
- package/dist/chunk-A4FUBC7B.js +17 -0
- package/dist/chunk-A4FUBC7B.js.map +1 -0
- package/dist/{chunk-SMJZMKYN.js → chunk-A6HBIY5P.js} +2 -11
- package/dist/{chunk-SMJZMKYN.js.map → chunk-A6HBIY5P.js.map} +1 -1
- package/dist/{chunk-LVQ26TCN.js → chunk-AFGTSUAD.js} +43 -127
- package/dist/chunk-AFGTSUAD.js.map +1 -0
- package/dist/{chunk-BKVGJVUR.js → chunk-K34IM5CT.js} +497 -33
- package/dist/chunk-K34IM5CT.js.map +1 -0
- package/dist/{chunk-UJMCGBLS.js → chunk-KHJS6VIA.js} +203 -41
- package/dist/chunk-KHJS6VIA.js.map +1 -0
- package/dist/{chunk-ORSMVXO2.js → chunk-KK73ZB4E.js} +9 -14
- package/dist/chunk-KK73ZB4E.js.map +1 -0
- package/dist/{chunk-VKOCWWVY.js → chunk-L3RV2ALE.js} +1 -6
- package/dist/{chunk-VKOCWWVY.js.map → chunk-L3RV2ALE.js.map} +1 -1
- package/dist/chunk-LW7MMEAQ.js +59 -0
- package/dist/chunk-LW7MMEAQ.js.map +1 -0
- package/dist/{chunk-IHMMNKNA.js → chunk-M5IWZRBT.js} +5118 -1864
- package/dist/chunk-M5IWZRBT.js.map +1 -0
- package/dist/{chunk-DG5Z55HH.js → chunk-NTNILOBC.js} +7 -9
- package/dist/chunk-NTNILOBC.js.map +1 -0
- package/dist/chunk-PYUXFQJ3.js +11 -0
- package/dist/chunk-PYUXFQJ3.js.map +1 -0
- package/dist/chunk-URUTVZ7N.js +27 -0
- package/dist/chunk-URUTVZ7N.js.map +1 -0
- package/dist/chunk-WN6XJWOS.js +2468 -0
- package/dist/chunk-WN6XJWOS.js.map +1 -0
- package/dist/{chunk-3SP4P7NS.js → chunk-XLZ7U46Z.js} +59 -1
- package/dist/chunk-XLZ7U46Z.js.map +1 -0
- package/dist/{chunk-H2TNUICK.js → chunk-Y6TXWPJO.js} +50 -50
- package/dist/chunk-Y6TXWPJO.js.map +1 -0
- package/dist/{chunk-YNUBMSMV.js → chunk-YCKPEMJA.js} +186 -263
- package/dist/chunk-YCKPEMJA.js.map +1 -0
- package/dist/components.d.ts +4 -5
- package/dist/components.js +35 -41
- package/dist/components.js.map +1 -1
- package/dist/hooks.d.ts +20 -43
- package/dist/hooks.js +13 -12
- package/dist/hooks.js.map +1 -1
- package/dist/index.d.ts +156 -10
- package/dist/index.js +193 -96
- package/dist/index.js.map +1 -1
- package/dist/{organisation-t-vvQC3g.d.ts → organisation-BtshODVF.d.ts} +4 -3
- package/dist/providers.d.ts +27 -38
- package/dist/providers.js +33 -23
- package/dist/rbac/index.d.ts +114 -5
- package/dist/rbac/index.js +15 -15
- package/dist/styles/index.js +2 -2
- package/dist/theming/runtime.js +1 -3
- package/dist/types.d.ts +3 -3
- package/dist/types.js +1 -1
- package/dist/types.js.map +1 -1
- package/dist/{unified-CMPjE_fv.d.ts → unified-CM7T0aTK.d.ts} +1 -1
- package/dist/useInactivityTracker-MRUU55XI.js +10 -0
- package/dist/{usePublicRouteParams-Ua1Vz-HG.d.ts → usePublicRouteParams-B-CumWRc.d.ts} +3 -3
- package/dist/utils.js +7 -9
- package/dist/utils.js.map +1 -1
- package/dist/validation.d.ts +1 -1
- package/docs/TERMINOLOGY.md +231 -0
- package/docs/api/classes/ColumnFactory.md +1 -1
- package/docs/api/classes/ErrorBoundary.md +1 -1
- package/docs/api/classes/InvalidScopeError.md +1 -1
- package/docs/api/classes/MissingUserContextError.md +1 -1
- package/docs/api/classes/OrganisationContextRequiredError.md +1 -1
- package/docs/api/classes/PermissionDeniedError.md +1 -1
- package/docs/api/classes/PublicErrorBoundary.md +1 -1
- package/docs/api/classes/RBACAuditManager.md +1 -1
- package/docs/api/classes/RBACCache.md +1 -1
- package/docs/api/classes/RBACEngine.md +1 -1
- package/docs/api/classes/RBACError.md +1 -1
- package/docs/api/classes/RBACNotInitializedError.md +1 -1
- package/docs/api/classes/SecureSupabaseClient.md +1 -1
- package/docs/api/classes/StorageUtils.md +1 -1
- package/docs/api/enums/FileCategory.md +1 -1
- package/docs/api/interfaces/AggregateConfig.md +1 -1
- package/docs/api/interfaces/ButtonProps.md +3 -3
- package/docs/api/interfaces/CardProps.md +2 -2
- package/docs/api/interfaces/ColorPalette.md +1 -1
- package/docs/api/interfaces/ColorShade.md +1 -1
- package/docs/api/interfaces/DataAccessRecord.md +1 -1
- package/docs/api/interfaces/DataTableAction.md +1 -1
- package/docs/api/interfaces/DataTableColumn.md +1 -1
- package/docs/api/interfaces/DataTableProps.md +1 -1
- package/docs/api/interfaces/DataTableToolbarButton.md +1 -1
- package/docs/api/interfaces/EmptyStateConfig.md +1 -1
- package/docs/api/interfaces/EnhancedNavigationMenuProps.md +1 -1
- package/docs/api/interfaces/EventLogoProps.md +2 -2
- package/docs/api/interfaces/FileDisplayProps.md +1 -1
- package/docs/api/interfaces/FileMetadata.md +1 -1
- package/docs/api/interfaces/FileReference.md +1 -1
- package/docs/api/interfaces/FileSizeLimits.md +1 -1
- package/docs/api/interfaces/FileUploadOptions.md +1 -1
- package/docs/api/interfaces/FileUploadProps.md +1 -1
- package/docs/api/interfaces/FooterProps.md +1 -1
- package/docs/api/interfaces/InactivityWarningModalProps.md +1 -1
- package/docs/api/interfaces/InputProps.md +2 -2
- package/docs/api/interfaces/LabelProps.md +1 -1
- package/docs/api/interfaces/LoginFormProps.md +1 -1
- package/docs/api/interfaces/NavigationAccessRecord.md +1 -1
- package/docs/api/interfaces/NavigationContextType.md +1 -1
- package/docs/api/interfaces/NavigationGuardProps.md +1 -1
- package/docs/api/interfaces/NavigationItem.md +1 -1
- package/docs/api/interfaces/NavigationMenuProps.md +1 -1
- package/docs/api/interfaces/NavigationProviderProps.md +1 -1
- package/docs/api/interfaces/Organisation.md +1 -1
- package/docs/api/interfaces/OrganisationContextType.md +28 -17
- package/docs/api/interfaces/OrganisationMembership.md +1 -1
- package/docs/api/interfaces/OrganisationProviderProps.md +2 -2
- package/docs/api/interfaces/OrganisationSecurityError.md +1 -1
- package/docs/api/interfaces/PaceAppLayoutProps.md +1 -1
- package/docs/api/interfaces/PaceLoginPageProps.md +1 -1
- package/docs/api/interfaces/PageAccessRecord.md +1 -1
- package/docs/api/interfaces/PagePermissionContextType.md +1 -1
- package/docs/api/interfaces/PagePermissionGuardProps.md +1 -1
- package/docs/api/interfaces/PagePermissionProviderProps.md +1 -1
- package/docs/api/interfaces/PaletteData.md +1 -1
- package/docs/api/interfaces/PermissionEnforcerProps.md +1 -1
- package/docs/api/interfaces/PublicErrorBoundaryProps.md +1 -1
- package/docs/api/interfaces/PublicErrorBoundaryState.md +1 -1
- package/docs/api/interfaces/PublicLoadingSpinnerProps.md +2 -2
- package/docs/api/interfaces/PublicPageFooterProps.md +1 -1
- package/docs/api/interfaces/PublicPageHeaderProps.md +1 -1
- package/docs/api/interfaces/PublicPageLayoutProps.md +1 -1
- package/docs/api/interfaces/RBACConfig.md +1 -1
- package/docs/api/interfaces/RBACContextType.md +5 -11
- package/docs/api/interfaces/RBACLogger.md +1 -1
- package/docs/api/interfaces/RBACProviderProps.md +1 -1
- package/docs/api/interfaces/RoleBasedRouterContextType.md +1 -1
- package/docs/api/interfaces/RoleBasedRouterProps.md +1 -1
- package/docs/api/interfaces/RouteAccessRecord.md +1 -1
- package/docs/api/interfaces/RouteConfig.md +1 -1
- package/docs/api/interfaces/SecureDataContextType.md +1 -1
- package/docs/api/interfaces/SecureDataProviderProps.md +1 -1
- package/docs/api/interfaces/StorageConfig.md +1 -1
- package/docs/api/interfaces/StorageFileInfo.md +1 -1
- package/docs/api/interfaces/StorageFileMetadata.md +1 -1
- package/docs/api/interfaces/StorageListOptions.md +1 -1
- package/docs/api/interfaces/StorageListResult.md +1 -1
- package/docs/api/interfaces/StorageUploadOptions.md +1 -1
- package/docs/api/interfaces/StorageUploadResult.md +1 -1
- package/docs/api/interfaces/StorageUrlOptions.md +1 -1
- package/docs/api/interfaces/StyleImport.md +1 -1
- package/docs/api/interfaces/SwitchProps.md +1 -1
- package/docs/api/interfaces/ToastActionElement.md +1 -1
- package/docs/api/interfaces/ToastProps.md +1 -1
- package/docs/api/interfaces/UnifiedAuthContextType.md +524 -440
- package/docs/api/interfaces/UnifiedAuthProviderProps.md +14 -14
- package/docs/api/interfaces/UseInactivityTrackerOptions.md +1 -1
- package/docs/api/interfaces/UseInactivityTrackerReturn.md +1 -1
- package/docs/api/interfaces/UsePublicEventLogoOptions.md +1 -1
- package/docs/api/interfaces/UsePublicEventLogoReturn.md +1 -1
- package/docs/api/interfaces/UsePublicEventOptions.md +1 -1
- package/docs/api/interfaces/UsePublicEventReturn.md +1 -1
- package/docs/api/interfaces/UsePublicRouteParamsReturn.md +1 -1
- package/docs/api/interfaces/UseResolvedScopeOptions.md +47 -0
- package/docs/api/interfaces/UseResolvedScopeReturn.md +47 -0
- package/docs/api/interfaces/UserEventAccess.md +11 -11
- package/docs/api/interfaces/UserMenuProps.md +1 -1
- package/docs/api/interfaces/UserProfile.md +1 -1
- package/docs/api/modules.md +234 -61
- package/docs/api-reference/providers.md +26 -7
- package/docs/architecture/services.md +30 -32
- package/docs/best-practices/README.md +20 -0
- package/docs/best-practices/accessibility.md +566 -0
- package/docs/best-practices/performance-expansion.md +473 -0
- package/docs/breaking-changes.md +2 -5
- package/docs/core-concepts/authentication.md +15 -7
- package/docs/documentation-index.md +1 -1
- package/docs/documentation-templates.md +539 -0
- package/docs/getting-started/quick-start.md +16 -66
- package/docs/implementation-guides/component-styling.md +410 -0
- package/docs/implementation-guides/data-tables.md +1 -1
- package/docs/migration/service-architecture.md +121 -260
- package/docs/rbac/README-rbac-rls-integration.md +48 -38
- package/docs/style-guide.md +39 -0
- package/{src/rbac/examples → examples/RBAC}/CompleteRBACExample.tsx +3 -2
- package/{src/rbac/examples → examples/RBAC}/EventBasedApp.tsx +5 -4
- package/{src/components/examples → examples/RBAC}/PermissionExample.tsx +7 -6
- package/examples/RBAC/__tests__/PermissionExample.test.tsx +150 -0
- package/examples/RBAC/index.ts +13 -0
- package/examples/README.md +37 -0
- package/examples/index.ts +22 -0
- package/{src/examples → examples/public-pages}/CorrectPublicPageImplementation.tsx +1 -1
- package/{src/examples → examples/public-pages}/PublicEventPage.tsx +1 -1
- package/{src/examples → examples/public-pages}/PublicPageApp.tsx +1 -1
- package/{src/examples → examples/public-pages}/PublicPageUsageExample.tsx +1 -1
- package/examples/public-pages/__tests__/PublicPageUsageExample.test.tsx +159 -0
- package/examples/public-pages/index.ts +14 -0
- package/package.json +22 -18
- package/src/__tests__/TEST_GUIDE_CURSOR.md +940 -9
- package/src/__tests__/helpers/README.md +255 -0
- package/src/__tests__/helpers/index.ts +62 -0
- package/src/__tests__/helpers/supabaseMock.ts +75 -5
- package/src/__tests__/rbac/PagePermissionGuard.test.tsx +6 -8
- package/src/components/DataTable/__tests__/DataTable.default-state.test.tsx +17 -6
- package/src/components/DataTable/__tests__/DataTableCore.test.tsx +73 -9
- package/src/components/DataTable/components/DataTableCore.tsx +280 -475
- package/src/components/DataTable/components/UnifiedTableBody.tsx +120 -153
- package/src/components/DataTable/components/__tests__/COVERAGE_NOTE.md +55 -0
- package/src/components/DataTable/components/index.ts +1 -2
- package/src/components/DataTable/context/__tests__/DataTableContext.test.tsx +208 -275
- package/src/components/DataTable/core/__tests__/ColumnFactory.test.ts +254 -0
- package/src/components/DataTable/core/index.ts +1 -8
- package/src/components/DataTable/examples/__tests__/HierarchicalExample.test.tsx +45 -0
- package/src/components/DataTable/examples/__tests__/PerformanceExample.test.tsx +117 -0
- package/src/components/DataTable/hooks/__tests__/useColumnOrderPersistence.test.ts +525 -0
- package/src/components/DataTable/hooks/__tests__/useColumnReordering.test.ts +570 -0
- package/src/components/DataTable/hooks/__tests__/useHierarchicalState.test.ts +214 -0
- package/src/components/DataTable/hooks/__tests__/useTableColumns.test.ts +224 -0
- package/src/components/DataTable/hooks/index.ts +6 -0
- package/src/components/DataTable/hooks/useColumnReordering.ts +1 -0
- package/src/components/DataTable/hooks/useDataTablePermissions.ts +149 -0
- package/src/components/DataTable/hooks/useDataTableState.ts +12 -6
- package/src/components/DataTable/hooks/useHierarchicalState.ts +26 -8
- package/src/components/DataTable/hooks/useTableColumns.ts +153 -0
- package/src/components/DataTable/index.ts +1 -9
- package/src/components/DataTable/utils/__tests__/COVERAGE_NOTE.md +89 -0
- package/src/components/DataTable/utils/__tests__/exportUtils.test.ts +3 -6
- package/src/components/DataTable/utils/__tests__/flexibleImport.test.ts +462 -0
- package/src/components/DataTable/utils/__tests__/hierarchicalSorting.test.ts +247 -0
- package/src/components/DataTable/utils/__tests__/hierarchicalUtils.test.ts +8 -6
- package/src/components/DataTable/utils/__tests__/performanceUtils.test.ts +466 -0
- package/src/components/DataTable/utils/__tests__/rowUtils.test.ts +265 -0
- package/src/components/DataTable/utils/errorHandling.ts +52 -460
- package/src/components/DataTable/utils/exportUtils.ts +46 -15
- package/src/components/DataTable/utils/hierarchicalSorting.ts +50 -3
- package/src/components/DataTable/utils/hierarchicalUtils.ts +167 -34
- package/src/components/DataTable/utils/index.ts +5 -0
- package/src/components/DataTable/utils/rowUtils.ts +68 -0
- package/src/components/Dialog/examples/__tests__/HtmlDialogExample.test.tsx +71 -0
- package/src/components/Dialog/examples/__tests__/SimpleHtmlTest.test.tsx +122 -0
- package/src/components/EventSelector/EventSelector.test.tsx +672 -0
- package/src/components/EventSelector/EventSelector.tsx +1 -1
- package/src/components/Header/Header.test.tsx +35 -1
- package/src/components/Header/Header.tsx +3 -1
- package/src/components/Label/__tests__/Label.test.tsx +434 -0
- package/src/components/OrganisationSelector/OrganisationSelector.tsx +3 -3
- package/src/components/PaceAppLayout/__tests__/PaceAppLayout.rbac.test.tsx +24 -4
- package/src/components/PaceLoginPage/PaceLoginPage.test.tsx +3 -2
- package/src/components/PublicLayout/__tests__/PublicPageContextChecker.test.tsx +190 -0
- package/src/components/PublicLayout/__tests__/PublicPageDebugger.test.tsx +185 -0
- package/src/components/PublicLayout/__tests__/PublicPageProvider.test.tsx +313 -0
- package/src/components/Select/Select.test.tsx +143 -120
- package/src/components/Select/Select.tsx +47 -212
- package/src/components/Select/hooks.ts +36 -1
- package/src/components/Select/index.ts +2 -1
- package/src/hooks/__tests__/useFocusManagement.unit.test.ts +220 -0
- package/src/hooks/__tests__/useIsMobile.unit.test.ts +117 -0
- package/src/hooks/__tests__/useKeyboardShortcuts.unit.test.ts +295 -0
- package/src/hooks/__tests__/useOrganisationSecurity.unit.test.tsx +29 -19
- package/src/hooks/__tests__/useRBAC.unit.test.ts +7 -3
- package/src/hooks/__tests__/useSecureDataAccess.unit.test.tsx +115 -19
- package/src/hooks/services/__tests__/useServiceHooks.test.tsx +137 -0
- package/src/hooks/useEventTheme.test.ts +350 -0
- package/src/hooks/useEventTheme.ts +1 -1
- package/src/hooks/useEvents.ts +61 -0
- package/src/hooks/useOrganisationSecurity.test.ts +4 -4
- package/src/hooks/useOrganisationSecurity.ts +2 -2
- package/src/hooks/useOrganisations.ts +64 -0
- package/src/hooks/useSecureDataAccess.test.ts +37 -30
- package/src/hooks/useSecureDataAccess.ts +2 -2
- package/src/index.ts +18 -3
- package/src/providers/AuthProvider.tsx +8 -292
- package/src/providers/EventProvider.tsx +15 -425
- package/src/providers/InactivityProvider.tsx +8 -231
- package/src/providers/OrganisationProvider.test.simple.tsx +3 -2
- package/src/providers/OrganisationProvider.tsx +11 -890
- package/src/providers/UnifiedAuthProvider.tsx +8 -320
- package/src/providers/__tests__/AuthProvider.test.tsx +18 -17
- package/src/providers/__tests__/EventProvider.test.tsx +253 -2
- package/src/providers/__tests__/InactivityProvider.test-helper.tsx +65 -0
- package/src/providers/__tests__/InactivityProvider.test.tsx +46 -114
- package/src/providers/__tests__/OrganisationProvider.test.tsx +313 -3
- package/src/providers/__tests__/ProviderLifecycle.test.tsx +341 -0
- package/src/providers/__tests__/UnifiedAuthProvider.test.tsx +383 -2
- package/src/providers/index.ts +8 -7
- package/src/providers/services/EventServiceProvider.tsx +3 -0
- package/src/providers/services/UnifiedAuthProvider.tsx +3 -0
- package/src/rbac/hooks/__tests__/usePermissions.integration.test.ts +437 -0
- package/src/rbac/hooks/index.ts +2 -0
- package/src/rbac/hooks/usePermissions.test.ts +296 -0
- package/src/rbac/hooks/useRBAC.test.ts +9 -5
- package/src/rbac/hooks/useRBAC.ts +3 -3
- package/src/rbac/hooks/useResolvedScope.ts +232 -0
- package/src/rbac/providers/__tests__/RBACProvider.integration.test.tsx +688 -0
- package/src/rbac/providers/__tests__/RBACProvider.test.tsx +507 -0
- package/src/services/AuthService.ts +19 -4
- package/src/services/__tests__/AuthService.test.ts +288 -0
- package/src/services/__tests__/InactivityService.lifecycle.test.ts +411 -0
- package/src/services/__tests__/OrganisationService.pagination.test.ts +375 -0
- package/src/styles/core.css +2 -0
- package/src/types/__tests__/README.md +114 -0
- package/src/types/__tests__/guards.test.ts +246 -0
- package/src/types/__tests__/validation.test.ts +731 -0
- package/src/types/guards.ts +1 -0
- package/src/types/organisation.ts +3 -2
- package/src/utils/__tests__/file-reference.test.ts +383 -0
- package/src/utils/__tests__/performanceBenchmark.test.ts +175 -0
- package/src/utils/appNameResolver.test.ts +54 -0
- package/src/validation/__tests__/csrf.unit.test.ts +63 -0
- package/src/validation/__tests__/passwordSchema.unit.test.ts +105 -0
- package/src/validation/__tests__/sanitization.unit.test.ts +250 -0
- package/src/validation/__tests__/schemaUtils.unit.test.ts +451 -0
- package/src/validation/__tests__/user.unit.test.ts +440 -0
- package/dist/DataTable-2QR5TER5.js +0 -102
- package/dist/RBACProvider-BO4ilsQB.d.ts +0 -63
- package/dist/UnifiedAuthProvider-D02AMXgO.d.ts +0 -103
- package/dist/chunk-3SP4P7NS.js.map +0 -1
- package/dist/chunk-B5LK25HV.js +0 -953
- package/dist/chunk-B5LK25HV.js.map +0 -1
- package/dist/chunk-BKVGJVUR.js.map +0 -1
- package/dist/chunk-C5Q5LRU5.js +0 -5691
- package/dist/chunk-C5Q5LRU5.js.map +0 -1
- package/dist/chunk-CDDYJCYU.js +0 -79
- package/dist/chunk-CDDYJCYU.js.map +0 -1
- package/dist/chunk-DG5Z55HH.js.map +0 -1
- package/dist/chunk-H2TNUICK.js.map +0 -1
- package/dist/chunk-IHMMNKNA.js.map +0 -1
- package/dist/chunk-LVQ26TCN.js.map +0 -1
- package/dist/chunk-ORSMVXO2.js.map +0 -1
- package/dist/chunk-TYHR5X4W.js +0 -33
- package/dist/chunk-TYHR5X4W.js.map +0 -1
- package/dist/chunk-UJMCGBLS.js.map +0 -1
- package/dist/chunk-V6BHACCH.js +0 -17
- package/dist/chunk-V6BHACCH.js.map +0 -1
- package/dist/chunk-YNUBMSMV.js.map +0 -1
- package/dist/eventContext-BBA42P6G.js +0 -14
- package/dist/rbac/cli/policy-manager.js +0 -278
- package/dist/rbac/cli/policy-manager.js.map +0 -1
- package/docs/api/interfaces/EventContextType.md +0 -96
- package/docs/api/interfaces/EventProviderProps.md +0 -19
- package/docs/documentation-style-checklist.md +0 -294
- package/src/components/DataTable/components/DataTableBody.tsx +0 -488
- package/src/components/DataTable/components/DraggableColumnHeader.tsx +0 -144
- package/src/components/DataTable/components/VirtualizedDataTable.tsx +0 -515
- package/src/components/DataTable/core/ActionManager.ts +0 -235
- package/src/components/DataTable/core/ColumnManager.ts +0 -205
- package/src/components/DataTable/core/DataManager.ts +0 -188
- package/src/components/DataTable/core/DataTableContext.tsx +0 -181
- package/src/components/DataTable/core/LocalDataAdapter.ts +0 -264
- package/src/components/DataTable/core/PluginRegistry.ts +0 -229
- package/src/components/DataTable/core/StateManager.ts +0 -311
- package/src/components/DataTable/core/__tests__/ActionManager.test.ts +0 -634
- package/src/components/DataTable/core/__tests__/DataManager.test.ts +0 -519
- package/src/components/DataTable/core/__tests__/StateManager.test.ts +0 -714
- package/src/components/DataTable/core/interfaces.ts +0 -338
- package/src/components/DataTable/utils/debugTools.ts +0 -583
- package/src/components/Select/Select.bug-test.tsx +0 -69
- package/src/components/Select/Select.refactored.tsx +0 -497
- package/src/providers/OrganisationProvider.test.tsx +0 -164
- package/src/providers/UnifiedAuthProvider.test.tsx +0 -124
- package/src/providers/__tests__/AuthProvider.test.tsx.backup +0 -771
- package/src/providers/__tests__/EventProvider.test.tsx.backup +0 -824
- package/src/providers/__tests__/OrganisationProvider.test.tsx.backup +0 -820
- package/src/providers/__tests__/UnifiedAuthProvider.test.tsx.backup +0 -911
- package/src/providers/__tests__/UnifiedAuthProvider.test.tsx.backup2 +0 -166
- package/src/rbac/cli/__tests__/policy-manager.test.ts +0 -339
- package/src/rbac/cli/policy-manager.ts +0 -443
- package/dist/{DataTable-2QR5TER5.js.map → DataTable-4GAVPIEG.js.map} +0 -0
- package/dist/{UnifiedAuthProvider-K4NRGXL4.js.map → UnifiedAuthProvider-3NKDOSOK.js.map} +0 -0
- package/dist/{eventContext-BBA42P6G.js.map → useInactivityTracker-MRUU55XI.js.map} +0 -0
- package/dist/{validation-PM_iOaTI.d.ts → validation-D8VcbTzC.d.ts} +2 -2
- /package/src/utils/{appNameResolver.test.ts.backup → appNameResolver.test 2.ts} +0 -0
|
@@ -1,235 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file DataTable Action Manager
|
|
3
|
-
* @package @jmruthers/pace-core
|
|
4
|
-
* @module Components/DataTable/Architecture/Managers
|
|
5
|
-
* @since 0.3.0
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type { ActionManager } from './interfaces';
|
|
9
|
-
import type { DataTableAction, DataRecord } from '../types';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Action manager implementation following SRP
|
|
13
|
-
* Responsible only for action operations
|
|
14
|
-
*/
|
|
15
|
-
export class ActionManagerImpl<TData extends DataRecord> implements ActionManager<TData> {
|
|
16
|
-
private actions: DataTableAction<TData>[] = [];
|
|
17
|
-
private actionMap = new Map<string, DataTableAction<TData>>();
|
|
18
|
-
|
|
19
|
-
constructor(initialActions: DataTableAction<TData>[] = []) {
|
|
20
|
-
this.setActions(initialActions);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Get all actions
|
|
25
|
-
*/
|
|
26
|
-
getActions(): DataTableAction<TData>[] {
|
|
27
|
-
return [...this.actions];
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/**
|
|
31
|
-
* Add a new action
|
|
32
|
-
*/
|
|
33
|
-
addAction(action: DataTableAction<TData>): void {
|
|
34
|
-
const actionId = this.getActionId(action);
|
|
35
|
-
|
|
36
|
-
// Remove existing action with same ID if it exists
|
|
37
|
-
this.removeAction(actionId);
|
|
38
|
-
|
|
39
|
-
// Add new action
|
|
40
|
-
this.actions.push(action);
|
|
41
|
-
this.actionMap.set(actionId, action);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Remove an action by ID
|
|
46
|
-
*/
|
|
47
|
-
removeAction(id: string): void {
|
|
48
|
-
const index = this.actions.findIndex(action => this.getActionId(action) === id);
|
|
49
|
-
if (index !== -1) {
|
|
50
|
-
this.actions.splice(index, 1);
|
|
51
|
-
this.actionMap.delete(id);
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Update an existing action
|
|
57
|
-
*/
|
|
58
|
-
updateAction(id: string, updates: Partial<DataTableAction<TData>>): void {
|
|
59
|
-
const existingAction = this.actionMap.get(id);
|
|
60
|
-
if (!existingAction) {
|
|
61
|
-
throw new Error(`Action with ID "${id}" not found`);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
const updatedAction = { ...existingAction, ...updates };
|
|
65
|
-
const index = this.actions.findIndex(action => this.getActionId(action) === id);
|
|
66
|
-
|
|
67
|
-
if (index !== -1) {
|
|
68
|
-
this.actions[index] = updatedAction;
|
|
69
|
-
this.actionMap.set(id, updatedAction);
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
* Get action by ID
|
|
75
|
-
*/
|
|
76
|
-
getAction(id: string): DataTableAction<TData> | undefined {
|
|
77
|
-
return this.actionMap.get(id);
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Check if action exists
|
|
82
|
-
*/
|
|
83
|
-
hasAction(id: string): boolean {
|
|
84
|
-
return this.actionMap.has(id);
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Get action IDs
|
|
89
|
-
*/
|
|
90
|
-
getActionIds(): string[] {
|
|
91
|
-
return Array.from(this.actionMap.keys());
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* Get enabled actions
|
|
96
|
-
*/
|
|
97
|
-
getEnabledActions(): DataTableAction<TData>[] {
|
|
98
|
-
return this.actions.filter(action => {
|
|
99
|
-
if (!action.disabled) return true;
|
|
100
|
-
if (typeof action.disabled === 'function') {
|
|
101
|
-
// For function-based disabled, we need a row to check against
|
|
102
|
-
// Since we don't have a specific row here, we'll create a mock row
|
|
103
|
-
// This is not ideal but allows the method to work
|
|
104
|
-
const mockRow = {} as TData;
|
|
105
|
-
return !action.disabled(mockRow);
|
|
106
|
-
}
|
|
107
|
-
return !action.disabled;
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Get actions by variant
|
|
113
|
-
*/
|
|
114
|
-
getActionsByVariant(variant: DataTableAction<TData>['variant']): DataTableAction<TData>[] {
|
|
115
|
-
return this.actions.filter(action => action.variant === variant);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
/**
|
|
119
|
-
* Get destructive actions
|
|
120
|
-
*/
|
|
121
|
-
getDestructiveActions(): DataTableAction<TData>[] {
|
|
122
|
-
return this.getActionsByVariant('destructive');
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Get primary actions
|
|
127
|
-
*/
|
|
128
|
-
getPrimaryActions(): DataTableAction<TData>[] {
|
|
129
|
-
return this.getActionsByVariant('default');
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Get secondary actions
|
|
134
|
-
*/
|
|
135
|
-
getSecondaryActions(): DataTableAction<TData>[] {
|
|
136
|
-
return this.getActionsByVariant('secondary');
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Set all actions at once
|
|
141
|
-
*/
|
|
142
|
-
setActions(actions: DataTableAction<TData>[]): void {
|
|
143
|
-
this.actions = [...actions];
|
|
144
|
-
this.actionMap.clear();
|
|
145
|
-
|
|
146
|
-
actions.forEach(action => {
|
|
147
|
-
const id = this.getActionId(action);
|
|
148
|
-
this.actionMap.set(id, action);
|
|
149
|
-
});
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Clear all actions
|
|
154
|
-
*/
|
|
155
|
-
clearActions(): void {
|
|
156
|
-
this.actions = [];
|
|
157
|
-
this.actionMap.clear();
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Get action count
|
|
162
|
-
*/
|
|
163
|
-
getActionCount(): number {
|
|
164
|
-
return this.actions.length;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Get action by index
|
|
169
|
-
*/
|
|
170
|
-
getActionByIndex(index: number): DataTableAction<TData> | undefined {
|
|
171
|
-
return this.actions[index];
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Get action index by ID
|
|
176
|
-
*/
|
|
177
|
-
getActionIndex(id: string): number {
|
|
178
|
-
return this.actions.findIndex(action => this.getActionId(action) === id);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Move action to new position
|
|
183
|
-
*/
|
|
184
|
-
moveAction(id: string, newIndex: number): void {
|
|
185
|
-
const currentIndex = this.getActionIndex(id);
|
|
186
|
-
if (currentIndex === -1) {
|
|
187
|
-
throw new Error(`Action with ID "${id}" not found`);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
if (newIndex < 0 || newIndex >= this.actions.length) {
|
|
191
|
-
throw new Error(`Invalid index: ${newIndex}`);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
const action = this.actions[currentIndex];
|
|
195
|
-
this.actions.splice(currentIndex, 1);
|
|
196
|
-
this.actions.splice(newIndex, 0, action);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Execute an action
|
|
201
|
-
*/
|
|
202
|
-
executeAction(id: string, row: TData): void {
|
|
203
|
-
const action = this.actionMap.get(id);
|
|
204
|
-
if (!action) {
|
|
205
|
-
throw new Error(`Action with ID "${id}" not found`);
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
if (action.disabled && typeof action.disabled === 'function' && action.disabled(row)) {
|
|
209
|
-
throw new Error(`Action "${id}" is disabled for this row`);
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
action.onClick(row);
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
/**
|
|
216
|
-
* Check if action is disabled for a specific row
|
|
217
|
-
*/
|
|
218
|
-
isActionDisabled(id: string, row: TData): boolean {
|
|
219
|
-
const action = this.actionMap.get(id);
|
|
220
|
-
if (!action) return true;
|
|
221
|
-
|
|
222
|
-
if (typeof action.disabled === 'function') {
|
|
223
|
-
return action.disabled(row);
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
return !!action.disabled;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
/**
|
|
230
|
-
* Get action ID from action definition
|
|
231
|
-
*/
|
|
232
|
-
private getActionId(action: DataTableAction<TData>): string {
|
|
233
|
-
return action.testId || action.label.toLowerCase().replace(/\s+/g, '-') || `action-${Math.random().toString(36).substr(2, 9)}`;
|
|
234
|
-
}
|
|
235
|
-
}
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file DataTable Column Manager
|
|
3
|
-
* @package @jmruthers/pace-core
|
|
4
|
-
* @module Components/DataTable/Architecture/Managers
|
|
5
|
-
* @since 0.3.0
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type { ColumnManager } from './interfaces';
|
|
9
|
-
import type { ColumnDef } from '@tanstack/react-table';
|
|
10
|
-
import type { DataRecord } from '../types';
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
* Column manager implementation following SRP
|
|
14
|
-
* Responsible only for column operations
|
|
15
|
-
*/
|
|
16
|
-
export class ColumnManagerImpl<TData extends DataRecord> implements ColumnManager<TData> {
|
|
17
|
-
private columns: ColumnDef<TData>[] = [];
|
|
18
|
-
private columnMap = new Map<string, ColumnDef<TData>>();
|
|
19
|
-
|
|
20
|
-
constructor(initialColumns: ColumnDef<TData>[] = []) {
|
|
21
|
-
this.setColumns(initialColumns);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Get all columns
|
|
26
|
-
*/
|
|
27
|
-
getColumns(): ColumnDef<TData>[] {
|
|
28
|
-
return [...this.columns];
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Add a new column
|
|
33
|
-
*/
|
|
34
|
-
addColumn(column: ColumnDef<TData>): void {
|
|
35
|
-
const columnId = this.getColumnId(column);
|
|
36
|
-
|
|
37
|
-
// Remove existing column with same ID if it exists
|
|
38
|
-
this.removeColumn(columnId);
|
|
39
|
-
|
|
40
|
-
// Add new column
|
|
41
|
-
this.columns.push(column);
|
|
42
|
-
this.columnMap.set(columnId, column);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Remove a column by ID
|
|
47
|
-
*/
|
|
48
|
-
removeColumn(id: string): void {
|
|
49
|
-
const index = this.columns.findIndex(col => this.getColumnId(col) === id);
|
|
50
|
-
if (index !== -1) {
|
|
51
|
-
this.columns.splice(index, 1);
|
|
52
|
-
this.columnMap.delete(id);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Update an existing column
|
|
58
|
-
*/
|
|
59
|
-
updateColumn(id: string, updates: Partial<ColumnDef<TData>>): void {
|
|
60
|
-
const existingColumn = this.columnMap.get(id);
|
|
61
|
-
if (!existingColumn) {
|
|
62
|
-
throw new Error(`Column with ID "${id}" not found`);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
const updatedColumn = { ...existingColumn, ...updates } as ColumnDef<TData>;
|
|
66
|
-
const index = this.columns.findIndex(col => this.getColumnId(col) === id);
|
|
67
|
-
|
|
68
|
-
if (index !== -1) {
|
|
69
|
-
this.columns[index] = updatedColumn;
|
|
70
|
-
this.columnMap.set(id, updatedColumn);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Get a specific column by ID
|
|
76
|
-
*/
|
|
77
|
-
getColumn(id: string): ColumnDef<TData> | undefined {
|
|
78
|
-
return this.columnMap.get(id);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Check if a column exists
|
|
83
|
-
*/
|
|
84
|
-
hasColumn(id: string): boolean {
|
|
85
|
-
return this.columnMap.has(id);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Get column IDs
|
|
90
|
-
*/
|
|
91
|
-
getColumnIds(): string[] {
|
|
92
|
-
return Array.from(this.columnMap.keys());
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Get visible columns
|
|
97
|
-
*/
|
|
98
|
-
getVisibleColumns(): ColumnDef<TData>[] {
|
|
99
|
-
return this.columns.filter(column => {
|
|
100
|
-
const id = this.getColumnId(column);
|
|
101
|
-
return column.enableHiding !== false;
|
|
102
|
-
});
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* Get sortable columns
|
|
107
|
-
*/
|
|
108
|
-
getSortableColumns(): ColumnDef<TData>[] {
|
|
109
|
-
return this.columns.filter(column => column.enableSorting === true);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* Get filterable columns
|
|
114
|
-
*/
|
|
115
|
-
getFilterableColumns(): ColumnDef<TData>[] {
|
|
116
|
-
return this.columns.filter(column => column.enableColumnFilter === true);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Get groupable columns
|
|
121
|
-
*/
|
|
122
|
-
getGroupableColumns(): ColumnDef<TData>[] {
|
|
123
|
-
return this.columns.filter(column => column.enableGrouping === true);
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Set all columns at once
|
|
128
|
-
*/
|
|
129
|
-
setColumns(columns: ColumnDef<TData>[]): void {
|
|
130
|
-
this.columns = [...columns];
|
|
131
|
-
this.columnMap.clear();
|
|
132
|
-
|
|
133
|
-
columns.forEach(column => {
|
|
134
|
-
const id = this.getColumnId(column);
|
|
135
|
-
this.columnMap.set(id, column);
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Clear all columns
|
|
141
|
-
*/
|
|
142
|
-
clearColumns(): void {
|
|
143
|
-
this.columns = [];
|
|
144
|
-
this.columnMap.clear();
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Get column count
|
|
149
|
-
*/
|
|
150
|
-
getColumnCount(): number {
|
|
151
|
-
return this.columns.length;
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
/**
|
|
155
|
-
* Get column by index
|
|
156
|
-
*/
|
|
157
|
-
getColumnByIndex(index: number): ColumnDef<TData> | undefined {
|
|
158
|
-
return this.columns[index];
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Get column index by ID
|
|
163
|
-
*/
|
|
164
|
-
getColumnIndex(id: string): number {
|
|
165
|
-
return this.columns.findIndex(col => this.getColumnId(col) === id);
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
/**
|
|
169
|
-
* Move column to new position
|
|
170
|
-
*/
|
|
171
|
-
moveColumn(id: string, newIndex: number): void {
|
|
172
|
-
const currentIndex = this.getColumnIndex(id);
|
|
173
|
-
if (currentIndex === -1) {
|
|
174
|
-
throw new Error(`Column with ID "${id}" not found`);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (newIndex < 0 || newIndex >= this.columns.length) {
|
|
178
|
-
throw new Error(`Invalid index: ${newIndex}`);
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
const column = this.columns[currentIndex];
|
|
182
|
-
this.columns.splice(currentIndex, 1);
|
|
183
|
-
this.columns.splice(newIndex, 0, column);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
/**
|
|
187
|
-
* Get column ID from column definition
|
|
188
|
-
*/
|
|
189
|
-
private getColumnId(column: ColumnDef<TData>): string {
|
|
190
|
-
// Handle different column types
|
|
191
|
-
if ('id' in column && column.id) {
|
|
192
|
-
return column.id;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
if ('accessorKey' in column && column.accessorKey) {
|
|
196
|
-
return String(column.accessorKey);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
if ('accessorFn' in column && typeof column.accessorFn === 'function') {
|
|
200
|
-
return `fn-${Math.random().toString(36).substr(2, 9)}`;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
return `fn-${Math.random().toString(36).substr(2, 9)}`;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
@@ -1,188 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file DataTable Data Manager
|
|
3
|
-
* @package @jmruthers/pace-core
|
|
4
|
-
* @module Components/DataTable/Architecture/Managers
|
|
5
|
-
* @since 0.3.0
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import type { DataTableDataManager, DataAdapter, FetchOptions } from './interfaces';
|
|
9
|
-
import type { DataRecord } from '../types';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Data manager implementation following SRP
|
|
13
|
-
* Responsible only for data operations
|
|
14
|
-
*/
|
|
15
|
-
export class DataManager<TData extends DataRecord> implements DataTableDataManager<TData> {
|
|
16
|
-
private data: TData[] = [];
|
|
17
|
-
private _isLoading = false;
|
|
18
|
-
private error: Error | null = null;
|
|
19
|
-
private adapter: DataAdapter<TData>;
|
|
20
|
-
private cache = new Map<string, { data: TData[]; timestamp: number }>();
|
|
21
|
-
private cacheTimeout: number;
|
|
22
|
-
|
|
23
|
-
constructor(adapter: DataAdapter<TData>, cacheTimeout = 5 * 60 * 1000) {
|
|
24
|
-
this.adapter = adapter;
|
|
25
|
-
this.cacheTimeout = cacheTimeout;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Get current data
|
|
30
|
-
*/
|
|
31
|
-
getData(): TData[] {
|
|
32
|
-
return this.data;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Update a data item
|
|
37
|
-
*/
|
|
38
|
-
async updateData(id: string, data: Partial<TData>): Promise<void> {
|
|
39
|
-
try {
|
|
40
|
-
this.setLoading(true);
|
|
41
|
-
this.setError(null);
|
|
42
|
-
|
|
43
|
-
await this.adapter.updateData(id, data);
|
|
44
|
-
|
|
45
|
-
// Update local data
|
|
46
|
-
const index = this.data.findIndex(item => this.getRowId(item) === id);
|
|
47
|
-
if (index !== -1) {
|
|
48
|
-
this.data[index] = { ...this.data[index], ...data };
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
this.clearCache();
|
|
52
|
-
} catch (error) {
|
|
53
|
-
this.setError(error as Error);
|
|
54
|
-
throw error;
|
|
55
|
-
} finally {
|
|
56
|
-
this.setLoading(false);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Delete a data item
|
|
62
|
-
*/
|
|
63
|
-
async deleteData(id: string): Promise<void> {
|
|
64
|
-
try {
|
|
65
|
-
this.setLoading(true);
|
|
66
|
-
this.setError(null);
|
|
67
|
-
|
|
68
|
-
await this.adapter.deleteData(id);
|
|
69
|
-
|
|
70
|
-
// Remove from local data
|
|
71
|
-
this.data = this.data.filter(item => this.getRowId(item) !== id);
|
|
72
|
-
|
|
73
|
-
this.clearCache();
|
|
74
|
-
} catch (error) {
|
|
75
|
-
this.setError(error as Error);
|
|
76
|
-
throw error;
|
|
77
|
-
} finally {
|
|
78
|
-
this.setLoading(false);
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
/**
|
|
83
|
-
* Create a new data item
|
|
84
|
-
*/
|
|
85
|
-
async createData(data: Partial<TData>): Promise<TData> {
|
|
86
|
-
try {
|
|
87
|
-
this.setLoading(true);
|
|
88
|
-
this.setError(null);
|
|
89
|
-
|
|
90
|
-
const newItem = await this.adapter.createData(data);
|
|
91
|
-
|
|
92
|
-
// Add to local data
|
|
93
|
-
this.data.push(newItem);
|
|
94
|
-
|
|
95
|
-
this.clearCache();
|
|
96
|
-
return newItem;
|
|
97
|
-
} catch (error) {
|
|
98
|
-
this.setError(error as Error);
|
|
99
|
-
throw error;
|
|
100
|
-
} finally {
|
|
101
|
-
this.setLoading(false);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Get cached data if available
|
|
108
|
-
*/
|
|
109
|
-
async getCachedData(cacheKey: string): Promise<TData[] | null> {
|
|
110
|
-
const cached = this.cache.get(cacheKey);
|
|
111
|
-
if (!cached) return null;
|
|
112
|
-
|
|
113
|
-
const isExpired = Date.now() - cached.timestamp > this.cacheTimeout;
|
|
114
|
-
if (isExpired) {
|
|
115
|
-
this.cache.delete(cacheKey);
|
|
116
|
-
return null;
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
return cached.data;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* Set cached data
|
|
124
|
-
*/
|
|
125
|
-
setCachedData(cacheKey: string, data: TData[]): void {
|
|
126
|
-
this.cache.set(cacheKey, {
|
|
127
|
-
data,
|
|
128
|
-
timestamp: Date.now(),
|
|
129
|
-
});
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Clear all cached data
|
|
134
|
-
*/
|
|
135
|
-
clearCache(): void {
|
|
136
|
-
this.cache.clear();
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Check if currently loading
|
|
141
|
-
*/
|
|
142
|
-
isLoading(): boolean {
|
|
143
|
-
return this._isLoading;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
/**
|
|
147
|
-
* Get current error
|
|
148
|
-
*/
|
|
149
|
-
getError(): Error | null {
|
|
150
|
-
return this.error;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
/**
|
|
154
|
-
* Set loading state
|
|
155
|
-
*/
|
|
156
|
-
private setLoading(loading: boolean): void {
|
|
157
|
-
this._isLoading = loading;
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Set error state
|
|
162
|
-
*/
|
|
163
|
-
private setError(error: Error | null): void {
|
|
164
|
-
this.error = error;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Get row ID from data item
|
|
169
|
-
*/
|
|
170
|
-
private getRowId(item: TData): string {
|
|
171
|
-
return (item as any).id || (item as any).key || JSON.stringify(item);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Set adapter
|
|
176
|
-
*/
|
|
177
|
-
setAdapter(adapter: DataAdapter<TData>): void {
|
|
178
|
-
this.adapter = adapter;
|
|
179
|
-
this.clearCache();
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/**
|
|
183
|
-
* Get adapter
|
|
184
|
-
*/
|
|
185
|
-
getAdapter(): DataAdapter<TData> {
|
|
186
|
-
return this.adapter;
|
|
187
|
-
}
|
|
188
|
-
}
|