UNPKG

permix

Version:

Permix is a lightweight, framework-agnostic, type-safe permissions management library for JavaScript applications on the client and server sides.

44 lines (40 loc) 1.77 kB
import { P as PermixDefinition, a as Permix, f as CheckFunctionObject, b as PermixStateJSON, h as CheckFunctionParams, e as PermixRules } from '../shared/permix.CuefdCK4.js'; import * as React from 'react'; /** * Provider that provides the Permix context to your React components. * * @link https://permix.letstri.dev/docs/integrations/react */ declare function PermixProvider<Permissions extends PermixDefinition>({ children, permix, }: { children: React.ReactNode; permix: Permix<Permissions>; }): React.JSX.Element; declare function PermixHydrate({ children, state }: { children: React.ReactNode; state: PermixStateJSON<any>; }): React.ReactNode; type CheckProps<Permissions extends PermixDefinition, K extends keyof Permissions> = CheckFunctionObject<Permissions, K> & { children: React.ReactNode; otherwise?: React.ReactNode; reverse?: boolean; }; interface PermixComponents<Permissions extends PermixDefinition> { Check: <K extends keyof Permissions>(props: CheckProps<Permissions, K>) => React.ReactNode; } declare function createComponents<Permissions extends PermixDefinition>(permix: Permix<Permissions>): PermixComponents<Permissions>; interface PermixContext<T extends PermixDefinition> { permix: Permix<T>; isReady: boolean; rules: PermixRules<T>; } /** * Hook that provides the Permix reactive methods to your React components. * * @link https://permix.letstri.dev/docs/integrations/react */ declare function usePermix<T extends PermixDefinition>(permix: Permix<T>): { check: <K extends keyof T>(...args: CheckFunctionParams<T, K>) => boolean; isReady: boolean; }; export { PermixHydrate, PermixProvider, createComponents, usePermix }; export type { CheckProps, PermixComponents, PermixContext };