import { DecafAppConfig, DecafAppController, DecafContextType } from '@decafhub/decaf-react'; import 'antd/dist/reset.css'; import { ThemeConfig } from 'antd/es/config-provider/context'; import React from 'react'; import { RouteObject } from 'react-router-dom'; import { BreadcrumbItem } from '../components/Breadcrumb'; import { CommandPaletteOptions } from '../components/CommandPalette'; import { DecafMenuItem, UserProfileDropdownItem } from '../types'; /** * DECAF Web appliaction route type. */ export type DecafRoute = Omit & { /** Define breadcrumbs for this route. * * @param data It is the return value of the `loader` function. * @returns A breadcrumb item. * * Example: * ```ts * { crumb: (data?: MyRecord) => ({ title: data?.title, href: `/details/${data?.id}` }) } * // or * { crumb: () => ({ title: "My Page", href: `/my-page` }) } * ``` */ crumb?: (data?: any) => BreadcrumbItem; /** When true, removes paddings from the content area. */ fullScreen?: boolean; /** The extra content to be rendered in the top right corner of the page. */ extras?: React.ReactNode; /** Child routes. */ children?: DecafRoute[]; }; /** * DECAF Web application route items builder. */ export type DecafRouteItemsBuilder = (context: DecafContextType) => DecafRoute[]; /** * DECAF Web application menu items builder. */ export type DecafMenuItemsBuilder = (context: DecafContextType) => DecafMenuItem[]; /** * DECAF Web application user profile dropdown items builder. */ export type DecafUserProfileDropdownItemsBuilder = (context: DecafContextType) => UserProfileDropdownItem[]; /** * DECAF Web application properties. */ export interface DecafWebappProps { /** * DECAF application name. */ appName: string; /** * DECAF application description. */ appDescription?: string; /** * DECAF application configuration. */ config?: DecafAppConfig; /** * DECAF application controller. */ controller?: DecafAppController; /** * The theme of the app. * * Defaults to `dark`. */ theme?: 'dark' | 'light'; /** * The theme config of the app. * * This will be merged with the default theme config (dark or light). * * See https://ant.design/docs/react/customize-theme */ themeConfig?: ThemeConfig; /** * Builds a collection of DECAF route items. * * About page and 404 page will be added automatically. * * See https://reactrouter.com/en/main/routers/create-browser-router#routes */ buildRouteItems: DecafRouteItemsBuilder; /** * Builds a collection of DECAF menu items. * * About page will be added automatically. */ buildMenuItems: DecafMenuItemsBuilder; /** * The extra content to show on the about page. */ buildAboutPageContent?: (context: DecafContextType) => React.ReactNode; /** * Command palette (Ctrl+K / Cmd+K) configuration. * * - **omit** (or `undefined`): the palette is enabled and lists every * actionable item from `buildMenuItems(context)`. A small `Ctrl+K` pill * appears in the header (≥ `lg` breakpoint) for discoverability. The * global hotkey works on every screen size. * - **`false`**: the feature is fully disabled — no header indicator, no * global hotkey listener, no modal mounted. * - **`CommandPaletteOptions`**: enabled with consumer customisation. Use * `extraItems` to append a few static entries, or `buildItems` to * filter / reorder / replace the list. See `CommandPaletteOptions` for * the full pipeline (defaults → extraItems → buildItems). * * @example * // Add an external docs link. * * * @example * // Hide admin items for non-privileged users. * * ctx.me.privileged ? items : items.filter((i) => !i.to?.startsWith('/admin')), * }} /> * * @example * // Disable entirely. * */ commandPalette?: false | CommandPaletteOptions; /** * Builds extra items to inject into the user profile dropdown. * * Items are placed between the built-in entries (me, Settings, About, and the * privileged "Open Maestro" link) and the logout block. Use this to add * app-specific shortcuts (e.g. links to internal dashboards or admin tools). * * The builder receives the DECAF context, so visibility can be gated on * `ctx.me.privileged` or any other context field by filtering the returned * array — there is no separate `visible` callback. * * Reserved keys (must not be reused): `me`, `settings`, `about`, `maestro`, * `divider-1`, `logout`, `logout-all`. * * @example * buildUserProfileDropdownItems: (ctx) => * ctx.me.privileged * ? [{ key: 'admin', label: 'Admin Console', href: '/admin', icon: }] * : [] */ buildUserProfileDropdownItems?: DecafUserProfileDropdownItemsBuilder; /** * Custom element to render when a route loader throws or a route renders an * error. * * When provided, replaces the library default (`PageRouteError`) at the root * route's `errorElement`. The element is mounted inside the standard * `DecafLayout` + `Page` chrome — render only the error body, not the shell. * * The default already unwraps axios / Apollo / Response throws, surfaces the * server message, and offers Retry / Go home plus a collapsible technical * details panel. Only override if you need a fully custom error UX. * * @example * } /> */ errorElement?: React.ReactNode; /** * Controls when the default error page renders the collapsible "Technical * details" panel — raw HTTP response body, request URL/method, and (for * non-HTTP errors) the JS error stack. Useful for support tickets but * potentially sensitive in production. * * - `'always'`: always render the panel. * - `'dev-only'` (default): render only when `process.env.NODE_ENV !== 'production'`. * - `'never'`: never render. * * Has no effect when `errorElement` is overridden — the consumer's element * decides what to render. */ errorDetails?: 'always' | 'dev-only' | 'never'; } export declare function DecafWebapp(props: DecafWebappProps): React.JSX.Element; /** * Auxiliary DECAF Webapp component. */ export declare function DecafWebappInternal(props: DecafWebappProps): React.JSX.Element; export declare function compileRoutes(props: DecafWebappProps, context: DecafContextType, routes: DecafRoute[]): { element: React.JSX.Element; path: string; children: RouteObject[]; errorElement: React.JSX.Element; }[]; export declare function decafRouteToReactRoute(route: DecafRoute): RouteObject; //# sourceMappingURL=index.d.ts.map