import React from 'react'; import { Rules, Action, Role } from './type'; export interface AclProviderProps { rules: Rules; role: Array | Role; } export interface OptionArray extends Array { 0: Action; } export interface ContextValue { /** * 从一组规则中选择出允许的字段 * 例如 choose({[A]: 'foo', [B]: 'bar', '*': 'baz' }), 如果具备A和B权限,则返回['foo', 'bar'] * '*'表示通配模式 */ choose(options: { [action: string]: T; [actionInNumber: number]: T; }): T[]; /** * 重载方法 * 处理 [[A, 'foo'], ['*', 'baz', 'yep'], [B, 'bar']] 这样的数据格式 */ choose(options: Array>): T[]; /** * 是否具备指定的所有权限(全部满足) */ allowsAll(...actions: Action[]): boolean; /** * 是否具备指定的权限之一(只要满足其中一个权限) */ allowsSome(...actions: Action[]): boolean; /** * 是否是指定角色 */ is(...roles: Role[]): boolean; rules: Rules; role: Array; } export declare const Context: React.Context; export default class Provider extends React.Component { static getDerivedStateFromProps(props: AclProviderProps, state: ContextValue): { role: React.ReactText[]; rules: Rules; } | null; constructor(props: AclProviderProps); render(): JSX.Element; choose(options: { [action: string]: T; [actionInNumber: number]: T; }): T[]; choose(options: Array>): T[]; private allowsAll; private allowsSome; private is; }