UNPKG

permix

Version:

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

46 lines (45 loc) 1.65 kB
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 { JSX } from "solid-js"; //#region src/solid/components.d.ts /** * Provides Permix context to the Solid component tree. * * @link https://permix.letstri.dev/docs/integrations/solid */ declare function PermixProvider<D extends Definition>(props: { children: JSX.Element; permix: Permix<D>; }): JSX.Element; declare function PermixHydrate(props: { children: JSX.Element; state: DehydratedState<any>; }): JSX.Element; interface CheckProps<D extends Definition, P extends RulesPaths<D>> { path: P; data?: DataAtPath<D, P>[0]; children: JSX.Element; otherwise?: JSX.Element; reverse?: boolean; } interface PermixComponents<D extends Definition> { Check: <P extends RulesPaths<D>>(props: CheckProps<D, P>) => JSX.Element; } declare function createComponents<D extends Definition>(permix: Pick<Permix<D>, 'getRules' | 'check'>): PermixComponents<D>; //#endregion //#region src/solid/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 Solid component. * * @link https://permix.letstri.dev/docs/integrations/solid */ 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 };