import { PERMISSIONS } from './constants'; import { StringifiedPermission } from './utils'; type PermissionKey = keyof typeof PERMISSIONS; type PermissionFn = Extract StringifiedPermission>; type PermissionArg = StringifiedPermission | PermissionFn; type PermissionsArguments = PermissionArg[] | Record; type ReturnRecord = { loading: boolean; active: boolean; }; type Result = T extends any[] ? ReturnRecord[] : { [K in keyof T]: ReturnRecord; }; /** * Hook that fetches and returns the loading/active status for one or more permission keys. * * @param {T} permissionKeys - Allow passing Array or Record * * - If you pass an array of permission values (e.g. `[PERMISSIONS.userCreate, PERMISSIONS.companySelectorView]`) * the hook returns an array of status objects in the same order. * * - If you pass an object to permission values * (e.g. `{ c: PERMISSIONS.userCreate, v: PERMISSIONS.companySelectorView }`), * the hook returns an object with the same keys, each mapping to its status object. * * @example * ```js * const [{ active, loading }] = usePermissions([ PERMISSIONS.userCreate ]); * ``` * * @example * ```js * const { canCreate: { active, loading } } = usePermissions({ * canCreate: PERMISSIONS.userCreate, * }); * ``` */ declare function usePermissions(permissionKeys: T): Result; export default usePermissions; //# sourceMappingURL=usePermissions.d.ts.map