@tracktor/design-system 3.8.0 → 3.9.0
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
|
+
import { PermissionCheckMode } from '../../../hooks/usePermission';
|
|
2
3
|
export interface HasPermissionProps {
|
|
3
4
|
/**
|
|
4
5
|
* Permissions name or array of permission names
|
|
@@ -16,6 +17,12 @@ export interface HasPermissionProps {
|
|
|
16
17
|
* Additional permissions to check with combined context permissions
|
|
17
18
|
*/
|
|
18
19
|
additionalPermissions?: string[];
|
|
20
|
+
/**
|
|
21
|
+
* Operator to use when checking multiple permissions:
|
|
22
|
+
* - "or": User must have at least one of the permissions (default)
|
|
23
|
+
* - "and": User must have all permissions
|
|
24
|
+
*/
|
|
25
|
+
permissionCheckMode?: PermissionCheckMode;
|
|
19
26
|
}
|
|
20
|
-
export declare const HasPermission: ({ children, fallback, name, additionalPermissions }: HasPermissionProps) => ReactNode;
|
|
27
|
+
export declare const HasPermission: ({ children, fallback, name, additionalPermissions, permissionCheckMode, }: HasPermissionProps) => ReactNode;
|
|
21
28
|
export default HasPermission;
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
export type PermissionCheckMode = "or" | "and";
|
|
2
|
+
export declare const DEFAULT_PERMISSION_CHECK_MODE: PermissionCheckMode;
|
|
1
3
|
/**
|
|
2
4
|
* Hook to check permission
|
|
3
5
|
*/
|
|
4
6
|
declare const usePermission: () => {
|
|
5
7
|
appendPermissions: (name: string) => void;
|
|
6
8
|
disabledPermissions: string[] | undefined;
|
|
7
|
-
hasPermission: (name: string | string[], additionalPermissions?: string[]) => boolean;
|
|
9
|
+
hasPermission: (name: string | string[], additionalPermissions?: string[], permissionCheckMode?: PermissionCheckMode) => boolean;
|
|
8
10
|
permissions: string[] | undefined;
|
|
9
11
|
setPermissions: import('react').Dispatch<import('react').SetStateAction<string[] | undefined>>;
|
|
10
12
|
};
|