badmfck-presenter
Version:
Wrapper for react-router-dom
55 lines (54 loc) • 2.54 kB
TypeScript
import React from 'react';
import { Location } from "react-router-dom";
import Signal from "badmfck-signal";
export interface INavigationPoint {
name: string;
id: string;
path?: string;
sub?: INavigationPoint[];
page?: React.ReactElement;
selected?: boolean;
hidden?: boolean;
disabled?: boolean;
redirect?: string;
title?: string;
}
export interface INavigationParams<T = any> {
[key: string]: T;
}
export interface ICurrentNav<T = any> {
url: string;
path: INavigationPoint[];
current: INavigationPoint;
params?: INavigationParams<T>;
}
export declare const S_NAV_CHANGED: Signal<ICurrentNav<any>>;
export declare class Presenter {
static title: string;
private sitemap;
private currentNav;
private interceptor?;
private static instance?;
constructor();
static setupInterceptor(interceptor: (navigationPoint: string | INavigationPoint | null, currentNav: ICurrentNav | null, params?: INavigationParams) => Promise<boolean>): void;
setupNavigationTree(tree: INavigationPoint[]): void;
markUnselected(arr?: INavigationPoint[]): void;
static intercept(navigationPoint: string | INavigationPoint | null, params?: INavigationParams): Promise<boolean>;
static getRouter(Outfit: React.ReactElement, ErrorPage?: React.ReactElement, InnerErrorPage?: React.ReactElement): import("react-router/dist/development/instrumentation-Unc20tLk").n | null;
createRouterTree(menuID: string, ErrorPage: React.ReactElement): any;
getLinkTree(id: string, tree?: INavigationPoint[], result?: INavigationPoint[]): INavigationPoint[];
static setSiteMap(sitemap: INavigationPoint[]): void;
static changeNavigation(navpoint: INavigationPoint, params?: INavigationParams): void;
static getNavigationPointByID(id: string): INavigationPoint | null;
getMenuById(id: string, tree?: INavigationPoint[]): INavigationPoint | null;
static setInitialLocation(loc: Location): void;
}
export declare const useCurrentPath: () => ICurrentNav<any> | null;
export declare const useMenu: (id?: string) => INavigationPoint[] | null;
export declare const useCreateRouter: (sitemap: INavigationPoint[], Outfit: React.ReactElement, ErrorPage?: React.ReactElement) => any;
interface IUsePresenter {
navChange: (navigationPoint: string | INavigationPoint, params?: INavigationParams) => void;
navDisable: (navigationPoint: string | INavigationPoint, disable: boolean) => void;
}
export declare const usePresenter: () => IUsePresenter;
export {};