UNPKG

@dlightjs/components

Version:

DLight components library

166 lines (154 loc) 4.64 kB
import { ContentProp, DLightViewComp, DLightViewLazy, DLightViewProp, Typed, CSSProperties } from '@dlightjs/dlight'; declare class Navigator { mode: "hash" | "history"; constructor(mode?: "hash" | "history"); hashTo(url: string): void; historyTo(url: string): void; to(url: string): void; } type LifecycleFunc = (to: RouteInfo, from: RouteInfo, baseUrl: string) => (boolean | void | string) | Promise<boolean | void | string>; type RouteInfo = { path: string; [key: string]: any; }; interface RouteOption { /** * @brief The component of the route, could be a dlight component class or a lazy component */ comp?: DLightViewComp | DLightViewLazy; /** * @brief The children of the route, either comp or children should be provided */ children?: DLightViewProp; /** * @brief The loading component(applied only when the route is a lazy component) */ loading?: DLightViewProp | DLightViewComp; /** * @brief The redirect path */ redirect?: string; /** * @brief The info of the route, will be passed to the lifecycle functions */ info?: Record<string, any>; } interface RouteGroupEnv { navigator?: Navigator; path?: string; _dl_router_baseUrl?: string; _dl_router_routesCollect?: (path: string, option: RouteOption) => void; } interface RouteGroupProps { /** * @brief The mode of the router, "hash" or "history" * @default "history" */ mode?: "hash" | "history"; /** * @brief The callback function when the path is updated */ onPathUpdate?: (path: string) => void; /** * @brief The loading component(applied only when the route is a lazy component) */ loading?: (View: any) => void; /** * @brief The guard function to check the route */ guard?: LifecycleFunc; /** * @brief The callback function after entering the route */ afterEnter?: LifecycleFunc; /** * @brief The callback function before leaving the route */ beforeLeave?: LifecycleFunc; } type RouteEnv = Omit<RouteGroupEnv, "_dl_router_routesCollect" | "_dl_router_baseUrl">; type RouteProps = { path?: ContentProp<string>; } & Omit<RouteOption, "children">; declare const _default$6: Typed<RouteGroupProps, object>; declare const _default$5: Typed<RouteProps, object>; interface LinkProps { /** * @brief The content of the link */ content?: ContentProp<string>; /** * @brief The path to navigate to */ to: string; /** * @brief The mode of navigation, will retrieved from the navigator if not provided */ mode?: "hash" | "history"; /** * @brief The style of the a tag */ style?: Record<string, string>; /** * @brief The class of the a tag */ class?: string; } declare const _default$4: Typed<LinkProps, object>; /** * @example * ```js * import { lazy } from "@dlightjs/components" * const MyComp = lazy(() => import("./MyComp.view")) * * import Loading from "./Loading.view" * const MyComp = lazy(() => import("./MyComp.view"), Loading) * ``` */ declare function lazy<T>(importFunc: () => Promise<{ default: T; }>, FallbackCls?: any): T; interface HStackProps { spacing?: number; alignment?: "top" | "bottom" | "center"; width?: string; height?: string; style?: CSSProperties; class?: string; } declare const _default$3: Typed<HStackProps, object>; interface VStackProps { spacing?: number; alignment?: "leading" | "tailing" | "center"; width?: string; height?: string; style?: CSSProperties; class?: string; } declare const _default$2: Typed<VStackProps, object>; interface ZStackProps { hAlignment?: "leading" | "center" | "tailing"; vAlignment?: "top" | "center" | "bottom"; width?: string; height?: string; style?: CSSProperties; class?: string; } declare class ZStack implements ZStackProps { hAlignment: ZStackProps["hAlignment"]; vAlignment: ZStackProps["vAlignment"]; width: string; height: string; style?: ZStackProps["style"]; class?: ZStackProps["class"]; children: DLightViewProp[]; justifyItems: string; alignItems: string; nodes: any[]; setStyles(nodes: any): void; didMount(): void; Body(): void; } declare const _default$1: Typed<ZStack, object>; declare const _default: Typed<object, object>; export { _default$3 as HStack, _default$4 as Link, Navigator, _default$5 as Route, RouteEnv, _default$6 as RouteGroup, _default as Spacer, _default$2 as VStack, _default$1 as ZStack, lazy };