import type { HomarrCustomWidgetV2Input } from "./custom-jsx-schema"; export interface CustomJsxExample { id: string; title: string; description: string; widget: HomarrCustomWidgetV2Input; } export const CUSTOM_JSX_STARTER = ` Service status {status.status?.loading ? : status.status?.error ? {status.status.error} : {data.status?.online ? "Online" : "Offline"}} `; export const CUSTOM_WIDGET_STARTER: HomarrCustomWidgetV2Input = { $schema: "homarr-custom-widget-v2", name: "New custom widget", description: "", sources: { default: { name: "API", baseUrl: "https://example.com", networkScope: "public", auth: "none" } }, requests: { status: { path: "/api/status" } }, options: {}, template: CUSTOM_JSX_STARTER, }; export const customJsxExamples: readonly CustomJsxExample[] = [ { id: "service-dashboard", title: "Service dashboard", description: "A polished responsive dashboard with clear loading and error states.", widget: { $schema: "homarr-custom-widget-v2", name: "Service dashboard", sources: { default: { name: "Service API", baseUrl: "https://example.com", networkScope: "public", auth: "none" }, }, requests: { overview: { path: "/api/overview", cacheSeconds: 30 } }, options: {}, template: ` System overviewLive service health {status.overview?.loading ? : status.overview?.error ? {status.overview.error} : {(data.overview?.services ?? []).map(service => {service.name}{service.online ? "Online" : "Offline"}{service.latency ?? "—"} ms)}} `, }, }, { id: "search-and-action", title: "Search and action", description: "A temporary search input, manual query, and explicit mutation.", widget: { $schema: "homarr-custom-widget-v2", name: "Series search", sources: { default: { name: "Media API", baseUrl: "https://example.com", networkScope: "private", auth: { type: "apiKeyHeader", name: "X-Api-Key" }, }, }, requests: { search: { path: "/api/series/search", trigger: "manual", query: { term: { $param: "query" } } }, monitor: { kind: "action", method: "POST", path: "/api/series/{param:id}/monitor", confirmation: "Monitor this series?", }, }, options: {}, template: ` {(results) => {(results ?? []).map(series => {series.title}{series.year ?? "Unknown year"}Monitor)}} `, }, }, ];