@excentone/spfx-react
Version:
Contains custom ReactJs components and hooks intended to use when developing SharePoint Framework (SPFx) Web components.
42 lines (41 loc) • 1.21 kB
TypeScript
import { Dispatch } from "react";
import { ISPPageUrls } from "@excentone/spfx-core-lib";
import { Initializer } from "@excentone/spfx-utilities";
/**
* A string or a function delegate that returns a string containing the URL.
*/
export declare type GetUrl = Initializer<string>;
/**
* Options available for `goTo` function.
*/
export interface IGotoPageOptions {
/**
* The fallback url to load if the key is not present in the page url list.
*/
fallbackUrl?: GetUrl;
/**
* The callback to be executed if the
*/
fallbackAction?: Dispatch<ISPPageUrls>;
}
/**
* Options available for `usePageUrls`.
*/
export interface IPageUrlOptions extends IGotoPageOptions {
/**
* THe other URLs to be included in addition to the page urls from the SPFX web component configuration.
*/
otherUrls?: Record<string, GetUrl>;
}
/**
* The type returned by 'usePageUrls`.
*/
export declare type PageUrlsHook = {
/**
* Loads the url that matches the specified {@link key}.
* @param key The key of the url.
* @param fallbackOptions The options available.
* @returns void
*/
goTo: (key: string, fallbackOptions?: IGotoPageOptions) => void;
};