@jmruthers/pace-core 0.5.6 → 0.5.7
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-ltTFXHS3.d.ts → DataTable-32L3DDeG.d.ts} +1 -1
- package/dist/{DataTable-BEMN72L5.js → DataTable-MZKEENPY.js} +2 -2
- package/dist/{chunk-SFGUMWEE.js → chunk-2VSQSO5Z.js} +11 -10
- package/dist/chunk-2VSQSO5Z.js.map +1 -0
- package/dist/{chunk-4EIBJ6DF.js → chunk-Y2LJQ7QE.js} +2 -2
- package/dist/components.d.ts +2 -2
- package/dist/components.js +2 -2
- package/dist/hooks.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{types-BRDU7N6w.d.ts → types-CczCVCDt.d.ts} +11 -4
- package/dist/utils.d.ts +2 -2
- package/dist/utils.js +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/interfaces/AggregateConfig.md +1 -1
- package/docs/api/interfaces/ButtonProps.md +1 -1
- package/docs/api/interfaces/CardProps.md +1 -1
- 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 +34 -34
- 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/EventContextType.md +1 -1
- package/docs/api/interfaces/EventLogoProps.md +1 -1
- package/docs/api/interfaces/EventProviderProps.md +1 -1
- package/docs/api/interfaces/FileSizeLimits.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 +1 -1
- 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 +1 -1
- package/docs/api/interfaces/OrganisationMembership.md +1 -1
- package/docs/api/interfaces/OrganisationProviderProps.md +1 -1
- 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 +1 -1
- 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 +1 -1
- 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/ToastActionElement.md +1 -1
- package/docs/api/interfaces/ToastProps.md +1 -1
- package/docs/api/interfaces/UnifiedAuthContextType.md +1 -1
- package/docs/api/interfaces/UnifiedAuthProviderProps.md +1 -1
- 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/UserEventAccess.md +1 -1
- package/docs/api/interfaces/UserMenuProps.md +1 -1
- package/docs/api/interfaces/UserProfile.md +1 -1
- package/docs/api/modules.md +3 -3
- package/docs/implementation-guides/datatable-rbac-usage.md +286 -0
- package/package.json +1 -1
- package/src/components/DataTable/DataTable.tsx +0 -5
- package/src/components/DataTable/__tests__/DataTable.hooks.test.tsx +0 -1
- package/src/components/DataTable/components/ActionButtons.tsx +1 -2
- package/src/components/DataTable/components/DataTableCore.tsx +12 -11
- package/src/components/DataTable/components/UnifiedTableBody.tsx +2 -4
- package/src/components/DataTable/examples/HierarchicalActionsExample.tsx +1 -1
- package/src/components/DataTable/examples/HierarchicalExample.tsx +3 -3
- package/src/components/DataTable/examples/InitialPageSizeExample.tsx +3 -3
- package/src/components/DataTable/examples/PerformanceExample.tsx +3 -3
- package/src/components/DataTable/types.ts +12 -7
- package/src/rbac/hooks/useRBAC.test.ts +0 -8
- package/dist/chunk-SFGUMWEE.js.map +0 -1
- package/src/components/DataTable/__tests__/DataTable.hooks.test 2.tsx +0 -191
- /package/dist/{DataTable-BEMN72L5.js.map → DataTable-MZKEENPY.js.map} +0 -0
- /package/dist/{chunk-4EIBJ6DF.js.map → chunk-Y2LJQ7QE.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
|
-
});
|
|
File without changes
|
|
File without changes
|