@jmruthers/pace-core 0.5.6 → 0.5.8

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.
Files changed (135) hide show
  1. package/CHANGELOG.md +2 -0
  2. package/README.md +15 -0
  3. package/dist/{DataTable-ltTFXHS3.d.ts → DataTable-32L3DDeG.d.ts} +1 -1
  4. package/dist/{DataTable-BEMN72L5.js → DataTable-JGPARO3S.js} +3 -3
  5. package/dist/{chunk-QVYBYGT2.js → chunk-5T3GRWJA.js} +6 -1
  6. package/dist/{chunk-QVYBYGT2.js.map → chunk-5T3GRWJA.js.map} +1 -1
  7. package/dist/{chunk-5SIXIV7R.js → chunk-ATGEP5Q4.js} +4 -4
  8. package/dist/chunk-ATGEP5Q4.js.map +1 -0
  9. package/dist/{chunk-SFGUMWEE.js → chunk-UG2XCAYK.js} +12 -11
  10. package/dist/chunk-UG2XCAYK.js.map +1 -0
  11. package/dist/{chunk-4EIBJ6DF.js → chunk-UNSHUXIB.js} +2 -2
  12. package/dist/components.d.ts +2 -2
  13. package/dist/components.js +3 -3
  14. package/dist/hooks.d.ts +1 -1
  15. package/dist/index.d.ts +2 -2
  16. package/dist/index.js +4 -4
  17. package/dist/rbac/index.js +2 -2
  18. package/dist/{types-BRDU7N6w.d.ts → types-CczCVCDt.d.ts} +11 -4
  19. package/dist/utils.d.ts +2 -2
  20. package/dist/utils.js +1 -1
  21. package/docs/api/README.md +15 -0
  22. package/docs/api/classes/ErrorBoundary.md +1 -1
  23. package/docs/api/classes/InvalidScopeError.md +1 -1
  24. package/docs/api/classes/MissingUserContextError.md +1 -1
  25. package/docs/api/classes/OrganisationContextRequiredError.md +1 -1
  26. package/docs/api/classes/PermissionDeniedError.md +1 -1
  27. package/docs/api/classes/PublicErrorBoundary.md +1 -1
  28. package/docs/api/classes/RBACAuditManager.md +1 -1
  29. package/docs/api/classes/RBACCache.md +1 -1
  30. package/docs/api/classes/RBACEngine.md +1 -1
  31. package/docs/api/classes/RBACError.md +1 -1
  32. package/docs/api/classes/RBACNotInitializedError.md +1 -1
  33. package/docs/api/classes/SecureSupabaseClient.md +1 -1
  34. package/docs/api/interfaces/AggregateConfig.md +1 -1
  35. package/docs/api/interfaces/ButtonProps.md +1 -1
  36. package/docs/api/interfaces/CardProps.md +1 -1
  37. package/docs/api/interfaces/ColorPalette.md +1 -1
  38. package/docs/api/interfaces/ColorShade.md +1 -1
  39. package/docs/api/interfaces/DataAccessRecord.md +1 -1
  40. package/docs/api/interfaces/DataTableAction.md +1 -1
  41. package/docs/api/interfaces/DataTableColumn.md +1 -1
  42. package/docs/api/interfaces/DataTableProps.md +34 -34
  43. package/docs/api/interfaces/DataTableToolbarButton.md +1 -1
  44. package/docs/api/interfaces/EmptyStateConfig.md +1 -1
  45. package/docs/api/interfaces/EnhancedNavigationMenuProps.md +1 -1
  46. package/docs/api/interfaces/EventContextType.md +1 -1
  47. package/docs/api/interfaces/EventLogoProps.md +1 -1
  48. package/docs/api/interfaces/EventProviderProps.md +1 -1
  49. package/docs/api/interfaces/FileSizeLimits.md +1 -1
  50. package/docs/api/interfaces/FileUploadProps.md +1 -1
  51. package/docs/api/interfaces/FooterProps.md +1 -1
  52. package/docs/api/interfaces/InactivityWarningModalProps.md +1 -1
  53. package/docs/api/interfaces/InputProps.md +1 -1
  54. package/docs/api/interfaces/LabelProps.md +1 -1
  55. package/docs/api/interfaces/LoginFormProps.md +1 -1
  56. package/docs/api/interfaces/NavigationAccessRecord.md +1 -1
  57. package/docs/api/interfaces/NavigationContextType.md +1 -1
  58. package/docs/api/interfaces/NavigationGuardProps.md +1 -1
  59. package/docs/api/interfaces/NavigationItem.md +1 -1
  60. package/docs/api/interfaces/NavigationMenuProps.md +1 -1
  61. package/docs/api/interfaces/NavigationProviderProps.md +1 -1
  62. package/docs/api/interfaces/Organisation.md +1 -1
  63. package/docs/api/interfaces/OrganisationContextType.md +1 -1
  64. package/docs/api/interfaces/OrganisationMembership.md +1 -1
  65. package/docs/api/interfaces/OrganisationProviderProps.md +1 -1
  66. package/docs/api/interfaces/OrganisationSecurityError.md +1 -1
  67. package/docs/api/interfaces/PaceAppLayoutProps.md +1 -1
  68. package/docs/api/interfaces/PaceLoginPageProps.md +1 -1
  69. package/docs/api/interfaces/PageAccessRecord.md +1 -1
  70. package/docs/api/interfaces/PagePermissionContextType.md +1 -1
  71. package/docs/api/interfaces/PagePermissionGuardProps.md +1 -1
  72. package/docs/api/interfaces/PagePermissionProviderProps.md +1 -1
  73. package/docs/api/interfaces/PaletteData.md +1 -1
  74. package/docs/api/interfaces/PermissionEnforcerProps.md +1 -1
  75. package/docs/api/interfaces/PublicErrorBoundaryProps.md +1 -1
  76. package/docs/api/interfaces/PublicErrorBoundaryState.md +1 -1
  77. package/docs/api/interfaces/PublicLoadingSpinnerProps.md +1 -1
  78. package/docs/api/interfaces/PublicPageFooterProps.md +1 -1
  79. package/docs/api/interfaces/PublicPageHeaderProps.md +1 -1
  80. package/docs/api/interfaces/PublicPageLayoutProps.md +1 -1
  81. package/docs/api/interfaces/RBACConfig.md +1 -1
  82. package/docs/api/interfaces/RBACContextType.md +1 -1
  83. package/docs/api/interfaces/RBACLogger.md +1 -1
  84. package/docs/api/interfaces/RBACProviderProps.md +1 -1
  85. package/docs/api/interfaces/RoleBasedRouterContextType.md +1 -1
  86. package/docs/api/interfaces/RoleBasedRouterProps.md +1 -1
  87. package/docs/api/interfaces/RouteAccessRecord.md +1 -1
  88. package/docs/api/interfaces/RouteConfig.md +1 -1
  89. package/docs/api/interfaces/SecureDataContextType.md +1 -1
  90. package/docs/api/interfaces/SecureDataProviderProps.md +1 -1
  91. package/docs/api/interfaces/StorageConfig.md +1 -1
  92. package/docs/api/interfaces/StorageFileInfo.md +1 -1
  93. package/docs/api/interfaces/StorageFileMetadata.md +1 -1
  94. package/docs/api/interfaces/StorageListOptions.md +1 -1
  95. package/docs/api/interfaces/StorageListResult.md +1 -1
  96. package/docs/api/interfaces/StorageUploadOptions.md +1 -1
  97. package/docs/api/interfaces/StorageUploadResult.md +1 -1
  98. package/docs/api/interfaces/StorageUrlOptions.md +1 -1
  99. package/docs/api/interfaces/StyleImport.md +1 -1
  100. package/docs/api/interfaces/ToastActionElement.md +1 -1
  101. package/docs/api/interfaces/ToastProps.md +1 -1
  102. package/docs/api/interfaces/UnifiedAuthContextType.md +1 -1
  103. package/docs/api/interfaces/UnifiedAuthProviderProps.md +1 -1
  104. package/docs/api/interfaces/UseInactivityTrackerOptions.md +1 -1
  105. package/docs/api/interfaces/UseInactivityTrackerReturn.md +1 -1
  106. package/docs/api/interfaces/UsePublicEventLogoOptions.md +1 -1
  107. package/docs/api/interfaces/UsePublicEventLogoReturn.md +1 -1
  108. package/docs/api/interfaces/UsePublicEventOptions.md +1 -1
  109. package/docs/api/interfaces/UsePublicEventReturn.md +1 -1
  110. package/docs/api/interfaces/UsePublicRouteParamsReturn.md +1 -1
  111. package/docs/api/interfaces/UserEventAccess.md +1 -1
  112. package/docs/api/interfaces/UserMenuProps.md +1 -1
  113. package/docs/api/interfaces/UserProfile.md +1 -1
  114. package/docs/api/modules.md +8 -8
  115. package/docs/implementation-guides/datatable-rbac-usage.md +286 -0
  116. package/package.json +1 -1
  117. package/src/components/DataTable/DataTable.tsx +0 -5
  118. package/src/components/DataTable/__tests__/DataTable.hooks.test.tsx +0 -1
  119. package/src/components/DataTable/components/ActionButtons.tsx +1 -2
  120. package/src/components/DataTable/components/DataTableCore.tsx +12 -11
  121. package/src/components/DataTable/components/UnifiedTableBody.tsx +2 -4
  122. package/src/components/DataTable/examples/HierarchicalActionsExample.tsx +1 -1
  123. package/src/components/DataTable/examples/HierarchicalExample.tsx +3 -3
  124. package/src/components/DataTable/examples/InitialPageSizeExample.tsx +3 -3
  125. package/src/components/DataTable/examples/PerformanceExample.tsx +3 -3
  126. package/src/components/DataTable/types.ts +12 -7
  127. package/src/rbac/components/PagePermissionGuard.tsx +2 -2
  128. package/src/rbac/hooks/useCan.test.ts +3 -9
  129. package/src/rbac/hooks/usePermissions.ts +7 -0
  130. package/src/rbac/hooks/useRBAC.test.ts +0 -8
  131. package/dist/chunk-5SIXIV7R.js.map +0 -1
  132. package/dist/chunk-SFGUMWEE.js.map +0 -1
  133. package/src/components/DataTable/__tests__/DataTable.hooks.test 2.tsx +0 -191
  134. /package/dist/{DataTable-BEMN72L5.js.map → DataTable-JGPARO3S.js.map} +0 -0
  135. /package/dist/{chunk-4EIBJ6DF.js.map → chunk-UNSHUXIB.js.map} +0 -0
@@ -1,191 +0,0 @@
1
- /**
2
- * @file DataTable Hooks Violation Test
3
- * @package @jmruthers/pace-core
4
- * @module Components/DataTable/__tests__
5
- * @since 0.5.4
6
- *
7
- * Test to verify that the DataTable component doesn't cause React Hooks violations.
8
- */
9
-
10
- import React from 'react';
11
- import { render, screen } from '@testing-library/react';
12
- import { DataTable } from '../DataTable';
13
- import type { DataTableColumn } from '../types';
14
-
15
- // Mock the required providers
16
- const MockUnifiedAuthProvider = ({ children }: { children: React.ReactNode }) => {
17
- return (
18
- <div data-testid="mock-auth-provider">
19
- {children}
20
- </div>
21
- );
22
- };
23
-
24
- // Mock the useUnifiedAuth hook
25
- const mockUseUnifiedAuth = {
26
- user: {
27
- id: 'test-user',
28
- user_metadata: {
29
- organisationId: 'test-org',
30
- eventId: 'test-event',
31
- appId: 'test-app'
32
- }
33
- },
34
- isAuthenticated: true,
35
- isLoading: false,
36
- error: null
37
- };
38
-
39
- // Mock the useCan hook
40
- const mockUseCan = {
41
- can: true,
42
- isLoading: false,
43
- error: null
44
- };
45
-
46
- // Mock all the required modules
47
- vi.mock('../../../providers/UnifiedAuthProvider', () => ({
48
- useUnifiedAuth: () => mockUseUnifiedAuth
49
- }));
50
-
51
- vi.mock('../../../rbac/hooks', () => ({
52
- useCan: () => mockUseCan
53
- }));
54
-
55
- vi.mock('../components/DataTableCore', () => ({
56
- DataTableCore: ({ children, ...props }: any) => (
57
- <div data-testid="datatable-core" {...props}>
58
- {children}
59
- </div>
60
- )
61
- }));
62
-
63
- vi.mock('../components/DataTableErrorBoundary', () => ({
64
- DataTableErrorBoundary: ({ children }: { children: React.ReactNode }) => (
65
- <div data-testid="error-boundary">{children}</div>
66
- )
67
- }));
68
-
69
- describe('DataTable Hooks Violation Test', () => {
70
- const mockData = [
71
- { id: '1', name: 'Item 1', value: 100 },
72
- { id: '2', name: 'Item 2', value: 200 }
73
- ];
74
-
75
- const mockColumns: DataTableColumn<typeof mockData[0]>[] = [
76
- { accessorKey: 'id', header: 'ID' },
77
- { accessorKey: 'name', header: 'Name' },
78
- { accessorKey: 'value', header: 'Value' }
79
- ];
80
-
81
- const mockFeatures = {
82
- search: true,
83
- pagination: true,
84
- sorting: true,
85
- filtering: true,
86
- import: true,
87
- export: true,
88
- selection: true,
89
- creation: true,
90
- editing: true,
91
- deletion: true,
92
- deleteSelected: true,
93
- grouping: true,
94
- columnVisibility: true,
95
- columnReordering: true,
96
- hierarchical: false
97
- };
98
-
99
- const mockRBAC = {
100
- resource: 'test-resource',
101
- pageId: 'test-page'
102
- };
103
-
104
- it('should render without React Hooks violations', () => {
105
- // This test will fail if there are React Hooks violations
106
- expect(() => {
107
- render(
108
- <MockUnifiedAuthProvider>
109
- <DataTable
110
- data={mockData}
111
- columns={mockColumns}
112
- rbac={mockRBAC}
113
- features={mockFeatures}
114
- getRowId={(row) => row.id}
115
- />
116
- </MockUnifiedAuthProvider>
117
- );
118
- }).not.toThrow();
119
- });
120
-
121
- it('should render DataTable with all required props', () => {
122
- render(
123
- <MockUnifiedAuthProvider>
124
- <DataTable
125
- data={mockData}
126
- columns={mockColumns}
127
- rbac={mockRBAC}
128
- features={mockFeatures}
129
- getRowId={(row) => row.id}
130
- />
131
- </MockUnifiedAuthProvider>
132
- );
133
-
134
- expect(screen.getByTestId('datatable-core')).toBeInTheDocument();
135
- });
136
-
137
- it('should handle multiple re-renders without hooks violations', () => {
138
- const { rerender } = render(
139
- <MockUnifiedAuthProvider>
140
- <DataTable
141
- data={mockData}
142
- columns={mockColumns}
143
- rbac={mockRBAC}
144
- features={mockFeatures}
145
- getRowId={(row) => row.id}
146
- />
147
- </MockUnifiedAuthProvider>
148
- );
149
-
150
- // Re-render with different data
151
- const newData = [
152
- { id: '3', name: 'Item 3', value: 300 },
153
- { id: '4', name: 'Item 4', value: 400 }
154
- ];
155
-
156
- expect(() => {
157
- rerender(
158
- <MockUnifiedAuthProvider>
159
- <DataTable
160
- data={newData}
161
- columns={mockColumns}
162
- rbac={mockRBAC}
163
- features={mockFeatures}
164
- getRowId={(row) => row.id}
165
- />
166
- </MockUnifiedAuthProvider>
167
- );
168
- }).not.toThrow();
169
-
170
- // Re-render with different features
171
- const newFeatures = {
172
- ...mockFeatures,
173
- search: false,
174
- pagination: false
175
- };
176
-
177
- expect(() => {
178
- rerender(
179
- <MockUnifiedAuthProvider>
180
- <DataTable
181
- data={newData}
182
- columns={mockColumns}
183
- rbac={mockRBAC}
184
- features={newFeatures}
185
- getRowId={(row) => row.id}
186
- />
187
- </MockUnifiedAuthProvider>
188
- );
189
- }).not.toThrow();
190
- });
191
- });