permix
Version:
Permix is a lightweight, framework-agnostic, type-safe permissions management library for JavaScript applications on the client and server sides.
52 lines (51 loc) • 1.73 kB
text/typescript
import { A as Definition, C as Rules, S as DehydratedState, g as Permix, h as DataAtPath, l as CheckArgs, v as RulesPaths } from "../index-BYcbfVQ7.mjs";
import * as React from "react";
//#region src/react/components.d.ts
/**
* Provides Permix context to the React component tree.
*
* @link https://permix.letstri.dev/docs/integrations/react
*/
declare function PermixProvider<D extends Definition>({
children,
permix
}: {
children: React.ReactNode;
permix: Permix<D>;
}): import("react/jsx-runtime").JSX.Element;
declare function PermixHydrate({
children,
state
}: {
children: React.ReactNode;
state: DehydratedState<any>;
}): React.ReactNode;
interface CheckProps<D extends Definition, P extends RulesPaths<D>> {
path: P;
data?: DataAtPath<D, P>[0];
children: React.ReactNode;
otherwise?: React.ReactNode;
reverse?: boolean;
}
interface PermixComponents<D extends Definition> {
Check: <P extends RulesPaths<D>>(props: CheckProps<D, P>) => React.ReactNode;
}
declare function createComponents<D extends Definition>(permix: Pick<Permix<D>, 'getRules' | 'check'>): PermixComponents<D>;
//#endregion
//#region src/react/hooks.d.ts
interface PermixContext<T extends Definition> {
permix: Permix<T>;
isReady: boolean;
rules: Rules<T> | null;
}
/**
* Access Permix check and readiness state inside a React component.
*
* @link https://permix.letstri.dev/docs/integrations/react
*/
declare function usePermix<T extends Definition>(permix: Pick<Permix<T>, 'getRules' | 'check'>): {
check: (...args: CheckArgs<T>) => boolean;
isReady: boolean;
};
//#endregion
export { type CheckProps, type PermixComponents, type PermixContext, PermixHydrate, PermixProvider, createComponents, usePermix };