diff --git a/AUDIT.md b/AUDIT.md new file mode 100644 index 000000000..e33c27342 --- /dev/null +++ b/AUDIT.md @@ -0,0 +1,535 @@ +# Custom Widgets Architecture Audit and North Star + +> Status: implemented in the current working tree; baseline retained below for traceability +> Evidence snapshot: `c5703e7e5` on PR #6304 +> Scope: built-in custom-widget displays, Custom JSX, network execution, authoring, preview, import/export, AI prompts, and MCP tools + +## Implementation outcome + +The migration described by this audit is implemented. `@homarr/custom-widgets` now owns the domain through explicit `core`, `jsx`, `runtime`, `server`, and `workbench` exports. API, Widgets, and Next.js retain only authorization, persistence, transport, board registration, navigation, and localized adapter concerns. + +Key outcomes: + +- One typed configuration and display-descriptor model drives schemas, defaults, form hydration, serialization, import/export, preview, examples, diagnostics, generated references, and AI prompts. +- Display-data extraction moved out of API and Widgets into the domain package; the former API-to-Widgets re-export chain no longer exists. +- The interpreter, shared security policy, registry, wrappers, named-request runtime, hardened executor, preview sessions, rate limits, and workbench UI have focused package-owned modules and tests. +- Runtime and workbench network behavior is injected through typed ports. The domain package has no dependency on API, Widgets, Next.js routes, notification infrastructure, or modal infrastructure. +- Public tRPC and MCP procedures are characterized, v2 and v3 import envelopes remain accepted, display-only v1 remains covered, and MCP offers iterative schema, validation, template read/write/patch, create/import/update, preview query, simulation, and journal tools. +- The AI prompt uses a multiline two-block authoring bundle, documents the `SubFetch` render-child contract, and is generated from the canonical registry and tested examples. +- Architecture enforcement currently scans 110 production modules for dependency direction, cycles, file budgets, dynamic loading, and untranslated JSX literals. Generated-reference drift and every Mantine export classification are test-enforced. +- The latest production build measured the largest Custom JSX route payload at 99,852 gzip bytes across two chunks, below the 768 KiB budget. + +Focused verification is green: 278 package tests, 35 API/MCP tests, 52 Widgets renderer tests, 7 E2E tests, affected typecheck, affected lint, docs build, production Next.js build, architecture checks, generated drift, and the bundle budget. The root `pnpm test` command is presently blocked on this workstation by unrelated Docker-backed integration suites timing out while the shared Docker daemon is under external load; no Custom Widget test failed in those runs. + +## Executive summary + +The feature has a strong security direction and a capable authoring experience, but its implementation has outgrown its current ownership model. PR #6304 changes 56 files with 13,206 additions. The primary feature directories contain 10,437 lines, spread across `@homarr/widgets`, `@homarr/api`, `@homarr/definitions`, `@homarr/validation`, and the Next.js management route. + +The main problem is not the absolute line count. It is that domain policy, transport, persistence, rendering, form state, compatibility, and documentation generation are interleaved across package boundaries. A change to one display type can require synchronized edits in schemas, form defaults, import conversion, preview extraction, runtime rendering, documentation, and AI instructions. Several of those paths use untyped records, duplicated conversion logic, or direct API dependencies. + +The north star is a single `@homarr/custom-widgets` domain package with explicit `core`, `jsx`, `runtime`, `server`, and `workbench` entry points. Existing applications and packages become thin adapters. The extraction must preserve public APIs, import formats, permission behavior, and the current UI while improving internal cohesion. + +This audit does not authorize a big-bang rewrite. The migration should be a sequence of behavior-preserving PRs, beginning with characterization tests and ending with enforced dependency and complexity budgets. + +## Measured baseline + +### Change footprint + +| Measure | Current value | +| ------------------------------- | ------------: | +| PR files changed | 56 | +| PR additions | 13,206 | +| PR deletions | 1,385 | +| Primary feature-directory lines | 10,437 | + +Generated component-reference JSON accounts for 2,491 added lines and is not treated as source complexity. + +### Largest production files + +| File | Lines | Responsibilities currently combined | +| ------------------------------------------------------------------------------- | ----: | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | +| `apps/nextjs/src/app/[locale]/manage/custom-widgets/_custom-widget-form.tsx` | 1,911 | Schema refinement, defaults, server-error mapping, form conversion, submission, preview state, focus management, display picker, connection fields, and every display-specific editor | +| `packages/api/src/router/custom-widget/custom-widget-router.ts` | 978 | CRUD, import/export, template patching, MCP descriptions, preview sessions, preview execution, journals, and action simulation/execution | +| `packages/widgets/src/custom-api/safe-jsx-interpreter.tsx` | 944 | AST model, parsing, environments, budgets, sanitization, expression evaluation, safe methods, callbacks, and React rendering | +| `apps/nextjs/src/app/[locale]/manage/custom-widgets/_custom-widget-preview.tsx` | 834 | Preview orchestration, error boundary, tabs, response tree, diagnostics, request journal, sample data, and renderer selection | +| `packages/widgets/src/custom-api/jsx-whitelist.ts` | 775 | Mantine imports, wrappers, icon mapping, runtime component map, registry filtering, data sanitization, and safe bindings | +| `packages/widgets/src/custom-api/jsx-sub-fetch.tsx` | 599 | Query rendering, render props, path display, action execution, buttons, toggles, refresh, notifications, and confirmations | + +These files exceed the proposed 300-line production-module target. The interpreter is a reasonable candidate for a documented 400-line exception after its independent policies, evaluators, and renderer are extracted. + +### Current ownership + +```mermaid +flowchart LR + D["@homarr/definitions
registry and examples"] + V["@homarr/validation
schemas and AST diagnostics"] + W["@homarr/widgets
renderers and interpreter"] + A["@homarr/api
CRUD, permissions, execution and MCP"] + N["Next.js route
workbench, preview and prompt"] + X["Docs
generated reference and guides"] + + N --> A + N --> V + N --> D + N --> W + W --> A + W --> D + A --> V + X --> D +``` + +The `@homarr/widgets → @homarr/api` edge is particularly costly. Runtime request components call the generated tRPC client directly, so moving the domain into a package that is also consumed by the API would create a dependency cycle unless request execution is inverted behind a typed port. + +## What is working well + +- Custom JSX v2 replaces raw runtime URLs and methods with named, typed requests. +- Board permissions, network scope, DNS validation, redirect policy, response limits, caching, concurrency, and action rules are server-enforced. +- The safe interpreter no longer treats an upstream JSX parser as a sandbox. +- Component metadata drives runtime classification, editor completion, docs generation, and part of the AI prompt. +- The workbench supports multiline JSX, diagnostics, real preview sizes, response inspection, request journals, import review, undo/redo, and paste-to-import. +- MCP exposes schema, validation, preview, journal, template read/write/patch, import, and update workflows without exposing stored secrets. +- Shared examples cover simple metrics, nested queries, charts, actions, and richer interactive layouts. + +The migration must preserve these capabilities. Package extraction is not a reason to weaken the security boundary or remove authoring features. + +## Findings + +### P1 — Domain ownership is fragmented + +Custom-widget behavior is implemented in five packages/applications. None of them is the clear source of truth for the complete lifecycle. `@homarr/definitions` owns component metadata and examples, `@homarr/validation` owns schemas and template diagnostics, `@homarr/widgets` owns runtime evaluation, `@homarr/api` owns network and persistence flows, and Next.js owns authoring transformations. + +Impact: + +- Maintainers must search unrelated packages to understand one behavior. +- Changes have a large synchronization surface and can drift silently. +- The domain cannot be tested or reused as a coherent unit. +- Package names describe infrastructure location rather than feature ownership. + +### P1 — Giant modules mix unrelated reasons to change + +The largest files are not merely long; they combine policy, orchestration, state, and presentation. The form contains all display editors. The router contains every management and preview procedure. The interpreter contains parsing through React emission. The request component file contains both query and mutation interaction models. + +Impact: + +- Reviews are broad and regression-prone. +- Unit-test seams are difficult to identify. +- Merge conflicts concentrate in a small number of files. +- Small feature changes require understanding thousands of lines of adjacent behavior. + +### P1 — Runtime code depends directly on the API client + +`packages/widgets/src/custom-api/component.tsx` and `jsx-sub-fetch.tsx` import `@homarr/api/client`. They also directly invoke notifications and confirmation modals. + +Impact: + +- The renderer cannot be used or tested without application infrastructure. +- A future `@homarr/custom-widgets` package would cycle with `@homarr/api` if both retained these imports. +- Preview and board runtime cannot share the same renderer through different request implementations without branching inside the components. + +Required direction: a runtime provider must receive typed query, action, confirmation, notification, and invalidation ports. The board and preview layers supply adapters. + +### P1 — Configuration transformations are duplicated + +Create defaults and builders live in the form, edit hydration lives in the edit page, and import hydration lives in `_custom-widget-import-utils.ts`. These paths independently translate between stored display configs and form values. They rely on display-type switches, record casts, and JSON text fields such as the request manifest. + +Impact: + +- Create, edit, paste replacement, import, export, and MCP can disagree. +- Adding a field requires updating multiple transforms. +- Round trips are difficult to prove lossless. + +Required direction: each display type supplies one typed descriptor containing schema, defaults, `toForm`, `fromForm`, preview projection, and migration behavior. + +### P1 — Type safety degrades at domain boundaries + +`Record`, `as never`, and `as unknown as` are frequent in form conversion, display extraction, preview state, imports, registry wrappers, and API parsing. Some casts are necessary at the interpreter/React boundary, but most domain-level casts indicate missing discriminated unions or validated adapters. + +Impact: + +- Invalid combinations survive until runtime. +- Refactors do not receive complete compiler guidance. +- Server and client transformations can diverge while continuing to compile. + +Required direction: parse unknown values once at ingress and use typed domain objects afterward. Unsafe casts must be isolated to named boundary modules and justified by tests. + +### P1 — Security policy is represented more than once + +The template validator and interpreter both parse JSX and maintain concepts such as blocked properties, blocked props, AST depth, and operation limits. Runtime component filtering adds another policy layer. + +The analyzer and interpreter have different jobs, so they should not be collapsed into one evaluator. They must, however, consume one immutable policy definition and shared AST normalization utilities. + +Impact: + +- A property can be rejected by one layer and missed by another. +- Security changes require parallel edits and duplicate tests. +- Diagnostics can describe behavior that differs from runtime enforcement. + +### P1 — The API router combines transport and application behavior + +The router owns tRPC metadata, Zod inputs, database writes, encryption, import/export, template revisions, preview execution, rate-limit acquisition, journal recording, and MCP documentation. + +Impact: + +- Domain logic is only testable through tRPC context setup. +- MCP and browser endpoints can accidentally implement different workflows. +- Framework-specific `TRPCError` values leak into lower-level executor and manifest code. + +Required direction: tRPC procedures authorize, load persistence models, call a domain service, and map domain errors. They do not implement request rendering, template patching, preview execution, or import conversion inline. + +### P2 — Metadata generation is only partially centralized + +The component registry and examples are shared, but runtime maps, wrappers, safe bindings, display-type metadata, AI prompt prose, form choices, and some docs remain separately assembled. The AI prompt is built inside a client button component. + +Impact: + +- Agent instructions can drift from validation and runtime behavior. +- Prompt generation requires UI and network context. +- Display types lack the same single-registry guarantee as JSX components. + +Required direction: prompt generation is a pure function in `core`, using the schema, display descriptors, component registry, and tested fixtures. The UI only fetches context and copies the result. + +### P2 — Compatibility behavior is mixed into primary flows + +V1 detection, migration warnings, legacy network diagnostics, v2 imports, v3 exports, and fallback display parsing are embedded beside current authoring/runtime logic. + +Impact: + +- Happy paths are harder to read. +- Legacy behavior can accidentally influence v2 code. +- Compatibility retirement has no obvious deletion boundary. + +Required direction: version detection and migrations live under `core/migrations`. Runtime and workbench receive a normalized current model plus explicit review state. + +### P2 — Test topology does not mirror the architecture + +Interpreter coverage is substantial, and request-executor/router tests exist, but tests are colocated under their current infrastructure owners instead of a feature package. A focused renderer run passed 52 tests during review, while the selected API suites failed before collecting tests because the root Vitest client environment rejected server-only environment access. + +Impact: + +- The complete feature cannot be verified with one package command. +- Server test failures can be configuration failures rather than behavioral failures. +- Form conversion and workbench orchestration have limited direct characterization coverage relative to their size. + +Required direction: the package owns focused test projects or environment-specific configs for core, DOM runtime/workbench, and Node server tests. API adapter tests remain in `@homarr/api`. + +### P2 — A small amount of user-facing copy bypasses translation + +Examples found during the snapshot include the raw-response tooltip and a default empty template message. Dynamic translation keys also require repeated `as never` casts, reducing translation-key safety. + +Impact: + +- Locale completeness gates are unreliable. +- Refactoring copy is harder than changing typed translation keys. + +Required direction: all package UI receives a typed message catalog or uses typed scoped translations. No visible fallback literals are allowed in production components. + +## North-star package + +```text +packages/custom-widgets/ +├── src/core/ +│ ├── config/ # discriminated display configurations and form models +│ ├── displays/ # typed display descriptors and built-in display metadata +│ ├── import/ # v2/v3 parsing, export, review, and authoring bundles +│ ├── migrations/ # v1 detection, normalization, and review requirements +│ ├── prompts/ # pure AI prompt generation +│ └── examples/ # typed fixtures shared by tests, docs, editor, and prompts +├── src/jsx/ +│ ├── ast/ # parser adapter, AST types, traversal, and normalization +│ ├── policy/ # blocked properties, props, URLs, and budgets +│ ├── analyzer/ # authoring diagnostics +│ ├── interpreter/ # expression and collection evaluation +│ ├── registry/ # component descriptors, wrappers, and export classification +│ └── bindings/ # branded safe helpers and sanitized data +├── src/runtime/ +│ ├── displays/ # built-in renderers +│ ├── jsx/ # Custom JSX renderer and error containment +│ ├── requests/ # SubFetch, actions, toggles, refresh, and state handling +│ └── provider/ # injected runtime capabilities +├── src/server/ +│ ├── network/ # hardened executor and destination policy +│ ├── requests/ # manifest resolution and parameter substitution +│ ├── limits/ # rate and concurrency limits +│ └── preview/ # sessions, simulation, and journals +└── src/workbench/ + ├── form/ # shared state and connection/display sections + ├── editor/ # CodeMirror and registry-driven diagnostics + ├── preview/ # widget, response, journal, and diagnostic views + └── import/ # clipboard parsing and review UI +``` + +Public exports are explicit: + +```json +{ + "exports": { + "./core": "./src/core/index.ts", + "./jsx": "./src/jsx/index.ts", + "./runtime": "./src/runtime/index.ts", + "./server": "./src/server/index.ts", + "./workbench": "./src/workbench/index.ts" + } +} +``` + +There is no broad root barrel. Internal folders cannot be imported by consumers. + +### Dependency rules + +```mermaid +flowchart LR + C["custom-widgets/core"] + J["custom-widgets/jsx"] + R["custom-widgets/runtime"] + S["custom-widgets/server"] + B["custom-widgets/workbench"] + API["@homarr/api adapter"] + W["@homarr/widgets adapter"] + N["Next.js route adapter"] + DOC["Docs generator"] + + J --> C + R --> C + R --> J + S --> C + B --> C + B --> R + API --> C + API --> S + W --> C + W --> R + N --> C + N --> B + DOC --> C + DOC --> J +``` + +Hard rules: + +1. `@homarr/custom-widgets` never imports `@homarr/api`, `@homarr/widgets`, or Next.js route modules. +2. `core` has no React, Mantine, tRPC, database, Redis, or browser dependency. +3. `jsx` has no API, persistence, Redis, notification, or modal dependency. +4. `runtime` performs no direct tRPC calls. It consumes `CustomWidgetRuntimePort`. +5. `workbench` performs no direct tRPC calls. It consumes `CustomWidgetWorkbenchPort` callbacks. +6. `server` has no tRPC or database-query dependency. API adapters load authorized records and map errors. +7. Cross-entry imports follow the arrows above; reverse imports fail CI. + +### Runtime ports + +The exact transport remains owned by adapters. The domain contract should cover behavior rather than tRPC details: + +```ts +interface CustomWidgetRuntimePort { + getData(input: { itemId: string; signal?: AbortSignal }): Promise; + query(input: NamedRequestInvocation & { signal?: AbortSignal }): Promise; + action(input: NamedRequestInvocation & { confirmed?: boolean }): Promise; + confirm(input: ActionConfirmation): Promise; + notify(input: RuntimeNotification): void; + invalidate(input: RuntimeInvalidation): Promise; +} +``` + +Board runtime and preview runtime implement the same port. Preview simulation is an adapter capability, not a conditional tRPC import inside `ActionButton`. + +### Display descriptors + +Every display type is represented once: + +```ts +interface CustomWidgetDisplayDescriptor { + type: CustomWidgetDisplayType; + configSchema: ZodType; + formSchema: ZodType; + createDefault(): TConfig; + toForm(config: TConfig): TForm; + fromForm(form: TForm): TConfig; + migrate(input: unknown): DisplayMigrationResult; + extract(response: unknown, config: TConfig): DisplayModel; + capabilities(config: TConfig): CustomWidgetCapability[]; +} +``` + +UI fields and renderer components may be registered in runtime/workbench companion maps keyed by the same typed display identifier. Domain descriptors remain serializable and framework-independent. + +## Developer-experience north star + +### Maintainers + +- Start at `packages/custom-widgets` for every feature behavior. +- Find one module per concept and one descriptor per display type. +- Add a display type without editing central switches in multiple packages. +- Run one package command for core, DOM, and server tests. +- Receive compile-time failures when a configuration field is not handled by forms, preview, migration, or export. +- Review PRs that move one domain boundary at a time. + +### Administrators and template authors + +- Preserve the current continuous form and live workbench. +- Keep preview usable before a live response exists through schema-valid defaults and editable sample data. +- Keep diagnostics actionable, localized, clickable, and consistent with runtime policy. +- Keep imports reviewable and secrets excluded. +- Keep query and action capabilities visible without noisy permanent warnings. + +### AI agents + +- Obtain schema, registry, limits, examples, and prompt rules from the same typed sources. +- Use readable multiline templates through authoring bundles and line-based template tools. +- Validate, preview, inspect journals, patch, and revalidate without rewriting unrelated configuration. +- Receive stable machine-actionable issue codes in addition to localized or human-readable messages. +- Never need to infer runtime behavior from UI-only prompt strings. + +## Fragmentation rules + +- Production modules target at most 300 lines, excluding generated files, fixtures, and type-only declarations. +- Algorithmic modules can reach 400 lines only with a file-level rationale and focused tests. +- A module has one primary reason to change; moving lines without separating policy from orchestration does not satisfy the target. +- React components do not contain schema definitions or persistence transforms. +- Routers do not contain reusable domain algorithms. +- Domain functions do not throw framework-specific errors. +- Unknown input is validated once. Parsed values are not carried as `Record` through internal layers. +- Compatibility code lives in versioned migration modules and has explicit removal criteria. +- Generated artifacts are reproducible and checked for drift, but excluded from line budgets. + +## Migration roadmap + +### PR 1 — Characterize contracts + +- Add round-trip tests for every display descriptor: default → form → config, stored config → form → config, and import → export. +- Add fixtures for v1 display-only, v1 network-review-required, v2 import, and v3 export. +- Add prompt snapshots sourced from the component registry and examples. +- Split Node and DOM Vitest projects so server suites collect and run reliably. +- Record bundle and render baselines before moving modules. + +Gate: all existing behavior is represented by tests, with no production moves yet. + +### PR 2 — Establish `core` + +- Create `@homarr/custom-widgets` and explicit exports. +- Move custom-widget schemas, typed configs, display descriptors, examples, import/export, migration, capability analysis, and prompt generation into `core`. +- Replace form/edit/import conversion duplication with descriptor calls. +- Temporarily re-export legacy imports from definitions and validation to keep consumers stable. + +Gate: create, edit, import, export, MCP validation, and AI prompt generation use the same domain contracts. + +### PR 3 — Extract JSX policy and interpreter + +- Move AST types, parser adapter, shared security policy, analyzer, evaluator, budgets, bindings, and registry into `jsx`. +- Separate evaluator modules by expression family and React emission. +- Generate diagnostics and runtime enforcement from the same policy constants. +- Keep the Mantine export-classification CI check. + +Gate: the security suite passes unchanged, analyzer/runtime policy drift tests pass, and no consumer imports JSX internals. + +### PR 4 — Extract runtime + +- Move built-in renderers, Custom JSX display, SubFetch, actions, toggles, refresh, and error containment into `runtime`. +- Introduce the runtime port and adapters for board and preview contexts. +- Remove direct imports of the API client, modals, and notifications from domain components. +- Split request components into query, action, toggle, refresh, feedback, and shared-state modules. + +Gate: board rendering and workbench preview use the same runtime components through different adapters; actions retain confirmation, rollback, invalidation, and permission behavior. + +### PR 5 — Extract server services + +- Move executor, manifests, network policy, limits, caching/single-flight, and preview-session logic into `server`. +- Replace `TRPCError` below the adapter with typed domain errors. +- Split API procedures into management, templates, preview, and runtime routers that delegate to package services. +- Keep authorization, database lookup, encryption, and tRPC/MCP metadata in `@homarr/api`. + +Gate: browser and MCP flows call the same services; request security tests run as Node package tests; public procedure names and inputs remain compatible. + +### PR 6 — Extract and fragment workbench + +- Move reusable editor, preview, response tree, import review, connection section, display picker, and display-specific fields into `workbench`. +- Introduce a workbench port for validate, preview, query, simulate action, journal, and save callbacks. +- Keep Next.js pages responsible only for routing, loading initial data, and constructing adapters. +- Replace the monolithic form with small sections and descriptor-driven display fields while preserving the continuous form, two-pane scrolling, autofocus, and mobile modes. + +Gate: no workbench source file exceeds the agreed budget, and create/edit/paste replacement share one state model. + +### PR 7 — Remove scaffolding and enforce boundaries + +- Remove compatibility re-exports and old implementations after all consumers move. +- Add CI checks for forbidden imports, dependency cycles, source-size budgets, untranslated literals, generated-artifact drift, component classification, and custom-JSX chunk size. +- Update contributor and architecture documentation with package entry points and extension recipes. + +Gate: old ownership paths contain only thin adapters or are deleted. + +## Verification strategy + +### Core + +- Every display descriptor accepts valid data and rejects mismatched configuration. +- All create/edit/import/export transformations are lossless where expected. +- V1/v2/v3 compatibility and review states are deterministic. +- Prompt output, authoring bundles, fixtures, docs data, and completion data are generated from shared sources. + +### JSX + +- Computed and Unicode-obfuscated reflective access remains blocked. +- Analyzer and interpreter share property, prop, URL, and budget policy. +- Own-property resolution, branded calls, callback accounting, and node/operation limits remain enforced. +- Every upstream Mantine export is classified and every enabled runtime component resolves. + +### Runtime and workbench + +- Query cancellation, stale results, retries, render children, action locks, DELETE confirmation, toggle rollback, and invalidation behave identically in preview and boards. +- Error boundaries isolate template and display failures. +- Empty, sample, stale, loading, failure, and success states are localized and accessible. +- Keyboard, focus, responsive, reduced-motion, and narrow-widget behavior remain covered. + +### Server and adapters + +- Board IDOR, permission levels, anonymous actions, named-request kinds, substitutions, DNS classes, redirects, headers, response limits, caching, and rate limits remain covered. +- Server tests run under an explicit Node environment rather than failing during client-environment initialization. +- MCP schemas and descriptions remain discoverable, stable, and absent from unsafe runtime procedures. + +### Required commands + +At the end of the migration, the package and repository must pass: + +```sh +pnpm --filter @homarr/custom-widgets test +pnpm test +pnpm test:e2e +pnpm turbo typecheck --affected +pnpm turbo lint --affected +pnpm turbo build --filter=@homarr/docs +pnpm check:custom-widget-bundle # after the Next.js production build +``` + +CI additionally checks dependency direction, cycles, file budgets, generated references, translations, and client bundle size. + +## Completion criteria + +- `@homarr/custom-widgets` owns every reusable custom-widget domain behavior. +- No circular dependencies exist. +- The package does not import `@homarr/api`, `@homarr/widgets`, or Next.js route modules. +- Runtime and workbench networking uses injected typed ports. +- One typed descriptor is the source of truth for each display type. +- One shared JSX policy drives authoring diagnostics and runtime enforcement. +- Create, edit, import, export, preview, MCP, and board runtime use the same typed transformations. +- Public tRPC/MCP names, import formats, stored configuration, and permission behavior remain compatible. +- V1 display-only migration and network-review states remain tested. +- Production modules satisfy the 300/400-line budgets. +- No untranslated user-facing strings remain. +- Core, JSX, runtime, server, workbench, integration, E2E, accessibility, docs, and bundle checks pass. +- A maintainer can locate a custom-widget behavior from the package structure without searching unrelated packages. + +## Explicit non-goals + +- Replacing Mantine or Homarr's visual language. +- Allowing arbitrary cross-origin requests. +- Replacing named requests with general JavaScript execution. +- Changing stored secrets or exposing them through export or MCP. +- Redesigning the current management UX during the package extraction. +- Removing compatibility formats before migration and review flows are proven. + +## Decision record + +- The package owns all Custom Widget behavior, not only Custom JSX. +- Security and correctness are hard constraints. +- Maintainer simplicity is the primary tie-breaker after those constraints. +- Current user and agent workflows are preserved during extraction. +- Generated artifacts do not count toward source-size budgets. +- Migration occurs through reviewable, behavior-preserving PRs rather than a single rewrite. diff --git a/apps/docs/docs/community/faq.mdx b/apps/docs/docs/community/faq.mdx index 465c7bbaf..55736cb33 100644 --- a/apps/docs/docs/community/faq.mdx +++ b/apps/docs/docs/community/faq.mdx @@ -5,43 +5,47 @@ tags: - Help --- -import Tabs from '@theme/Tabs'; -import TabItem from '@theme/TabItem'; +import Tabs from "@theme/Tabs"; +import TabItem from "@theme/TabItem"; ### Can I install Homarr on a Raspberry Pi? + Yes, Homarr is compatible with the architecture of the Raspberry Pi. Have a look in our installation guide on how to do so. ### I have a suggestion / idea for improvement or want to report a bug + You can report issues, suggestions, or ideas for improvements here. ### Can I use my own custom icons for apps? + Yes, check out our guide on how to add your custom icons. ### Some of my online icons are not working (anymore) + It seems the `cdn.jsdelivr.net` database of icon sometimes appear in the lists for DNS-Holes (PiHole, AdGuard Home...).
So make sure to manually whitelist this address. ### Can I add my own widgets? Do I need programming skills? -We have decided, not to support custom widgets, until Homarr is in a stable and highly polished state. -Enabling users to write their own widgets is easy at the first glance, but there are some major issues with it: -- There are mainly two options for adding plugins or custom widgets to Homarr. The first option is, to allow and inject custom code in Homarr. Apps like Nextcloud can do this easily, because they use the Runtime to render all components of the application (In reality, the process is still a bit more complicated). In contrast, Homarr is using Next.js - a framework that needs to be compiled in production. That means, that each time you would modify a custom widget or plugin, the app would have to be restarted. There are options to avoid this, but they are quite flakey and bring disadvantages in our experience. The second option is, to write widgets declaratively instead of imperatively. This way, we would be able to render and modify widgets without any restarting at all. However, we'd have to write our own interpreter for said declarative schema. This is totally possible, but requires a lot of planning and architecture design to function properly. The required work to implement either option is therefore quite substantial. -- Custom widgets would need to be able to request data, so they work properly. We use tRPC for this. Many APIs use different formats and we'd have to convert and read those. -- Using custom widgets, one could easily create harmful widgets, leak your personal data (potentially including your tokens) and trick your users. A proper implementation (eg. official plugin store, where we can ban harmful widgets from) would resolve this problem to a certain extent, but again requires additional work and time to be put in. +Yes. Administrators can create [Custom Widgets](/docs/management/custom-widgets) that read an HTTP API and render the response with a built-in display type. These display types require no programming. -If you still want to add a widget, please consider to contribute it directly to Homarr. For that, basic programming skills are required. Our [Developer Guides](/docs/advanced/development/getting-started) explain this even more detailed. +Custom JSX is available when you need a more specific layout or an interactive control. It uses a restricted declarative JSX interpreter with a classified Mantine component set. Network operations are declared as named, same-origin requests and are checked against board permissions on the server. It does not execute arbitrary JavaScript or expose browser `fetch`. + +You should be comfortable reading JSON and JSX to author complex templates. The management workbench includes examples, diagnostics, a component reference, API response inspection, and a prompt you can copy into an AI assistant. Always review imported templates and request capabilities before saving them. ### Is it secure to expose Homarr to the web? -Yes, since v0.14.0, we are confident that Homarr is secure enough to be exposed to the web. +Yes, since v0.14.0, we are confident that Homarr is secure enough to be exposed to the web. Make sure to enable the "allow anonymous access" [option in the settings](/docs/management/boards#access-control), if you want to allow people without an account to be able to see your dashboard (not edit) ### How do I open the console / log? + There are two different sources of information: + - console: This is your client (browser). It can tell us, if there is an issue on the client (crash, bug, ...). - log: This is your server. It will tell us, if there are issues with connections for the integrations, crashes and errors. -Both variants *can* contain personal data. It's recommended, that you don't post them publicly or remove personal data from it. +Both variants _can_ contain personal data. It's recommended, that you don't post them publicly or remove personal data from it. @@ -49,39 +53,45 @@ Both variants *can* contain personal data. It's recommended, that you don't post > Note: This will not work on most mobile browsers. Open your browser and ensure, that Homarr is your current tab. -Press ``CTRL`` + ``SHIFT`` + ``I`` on your keyboard. If this shortcut doesn't work, please use one of the alternatives: https://developer.chrome.com/docs/devtools/open/. -Click on ``Console`` in the new window, that opened. There, you should see white, orange and sometimes red messages. You can use the Windows Snip & Sketch tool (or your respective tool on Linux / MacOS) to screenshot those messages. +Press `CTRL` + `SHIFT` + `I` on your keyboard. If this shortcut doesn't work, please use one of the alternatives: https://developer.chrome.com/docs/devtools/open/. +Click on `Console` in the new window, that opened. There, you should see white, orange and sometimes red messages. You can use the Windows Snip & Sketch tool (or your respective tool on Linux / MacOS) to screenshot those messages. > Please never execute any commands in the console. Scammers are using the console to let you execute harmful commands. If you want to resolve an issue in Homarr, **you'll never have to execute any commands here** -This depends on your installation method. If you use Unraid, you can simply click on the App and on ``Log``. If you have a bare Docker install, use ``docker container logs homarr``. If you used a different name than ``homarr`` for your container, you need to replace said argument. Here is some additional information about the command: https://geekflare.com/check-docker-logs/. +This depends on your installation method. If you use Unraid, you can simply click on the App and on `Log`. If you have a bare Docker install, use `docker container logs homarr`. If you used a different name than `homarr` for your container, you need to replace said argument. Here is some additional information about the command: https://geekflare.com/check-docker-logs/. ### How do I post logs? + Please check [the section above](#how-do-i-open-the-console--log), on how to obtain logs. Logs should always be posted to https://pastebin.com/ or https://rentry.co/. ### Can I use Homarr at my company? + Yes, you can! But please consider a donation, if our work has been useful to you. ### I think I found a bug. What can I do? + If you think, that you found a bug, please create an issue here. ### Why can't I use my custom icons? + You need to restart the Homarr Docker container after adding icons. ### Why can't homarr see/ping containers running locally behind GluetunVPN? + This is because GluetunVPN, and many other docker VPN services, secure their VPN connections with strict firewalls. These firewalls often block access to local containers, even on the same docker network. The workaround for GluetunVPN is to add "- FIREWALL_OUTBOUND_SUBNETS=192.168.1.0/24" into the environmental variables of the docker compose file. If you are using a firewall on your system, you will need to add a rule that allows requests from ip's in the range of 192.168.xxx.xxx . If you are using UFW the command would be "sudo ufw allow from 192.168.0.0/16". Tip: If you are running your torrent client behind a VPN, and running Sonarr (or something similar) normally, make sure to open your torrent client's port in your firewall. If you don't, Sonarr will not be able to see it. Furthermore, use your machines IP (192.168.x.x) rather then 127.0.0.1 or localhost. ### Can I get in touch with you? + Yes, go here to get with us in touch. -
+
:::tip diff --git a/apps/docs/docs/management/custom-widgets/agent-authoring.mdx b/apps/docs/docs/management/custom-widgets/agent-authoring.mdx new file mode 100644 index 000000000..2121e1424 --- /dev/null +++ b/apps/docs/docs/management/custom-widgets/agent-authoring.mdx @@ -0,0 +1,26 @@ +--- +sidebar_label: AI and MCP authoring +--- + +# AI and MCP authoring + +Homarr exposes an iterative, validation-first workflow to authenticated administrators. Agents should continue until validation, preview, and diagnostics are clean; they must not invent inline network access. + +## Recommended loop + +1. Read `customWidget_schema` and the generated component/capability reference. +2. Read an existing definition with `customWidget_byId`, or create a v3 draft. +3. Call `customWidget_validate`; fix every issue using its exact path. +4. Call `customWidget_preview` for the base GET and retain the preview session ID. +5. Test each named query with `customWidget_previewQuery`. +6. Dry-run every action with `customWidget_simulatePreviewAction`. +7. Inspect `customWidget_previewJournal` for status, duration, and method coverage. +8. Revalidate, then call import/create or a focused update/patch operation. + +Stored secret values are never readable. Omitting secrets during an update preserves them. MCP actions are simulation-only; enabling live preview actions remains a browser-only administrator decision. + +## Template format + +Use multiline JSX when reading or patching templates. Prefer focused template read/write/patch tools over rewriting an escaped one-line JSON string. When a complete portable artifact is needed, use the authoring bundle placeholder plus a separate fenced JSX block. + +The AI prompt is generated from the same registry, examples, request rules, and limits as the validator. Agents should still trust validation output over prompt memory because the installed Homarr version is authoritative. diff --git a/apps/docs/docs/management/custom-widgets/architecture.mdx b/apps/docs/docs/management/custom-widgets/architecture.mdx new file mode 100644 index 000000000..508eef439 --- /dev/null +++ b/apps/docs/docs/management/custom-widgets/architecture.mdx @@ -0,0 +1,29 @@ +--- +sidebar_label: Maintainer architecture +--- + +# Maintainer architecture + +Reusable Custom Widget behavior belongs to `@homarr/custom-widgets`: + +- `core` owns schemas, descriptors, migrations, import/export, examples, diagnostics metadata, and prompt generation. +- `jsx` owns AST parsing, shared policy, interpreter, bindings, registry, wrappers, and analysis. +- `runtime` owns renderers and named-request controls through injected ports. +- `server` owns manifests, network execution, caching, limits, preview sessions, and typed domain errors. +- `workbench` owns form contracts, editor analysis, preview UI, response tree, and import review through injected ports. + +The API package retains persistence and board authorization adapters. Widgets retain board registration and runtime transport wiring. Next.js routes retain navigation and shells. The domain package must never import API, widgets, or route modules. + +## Add a display type + +Extend the typed descriptor and discriminated schema, defaults/hydration/serialization, renderer, workbench section, preview, import round-trip fixtures, docs, and translations. Create, edit, import, export, MCP, and preview must all use the same transform. + +## Add a JSX component + +Classify the upstream export, document safety mode and supported props, add a wrapper if behavior needs constraining, and update registry tests. CI fails when a Mantine upgrade introduces an unclassified export. + +## Change networking + +Implement policy below the framework-neutral server boundary and expose infrastructure through a typed port. Add tests for permissions, typed substitution, DNS classes, redirects, headers, timeouts, limits, redaction, cache behavior, and action non-retry semantics before wiring the tRPC adapter. + +Production files target 300 lines. Algorithmic AST/network modules may use a documented 400-line ceiling. Dependency-boundary, cycle, file-size, translation, generated-artifact, component-classification, focused unit, integration, E2E, accessibility, and docs-build gates protect the architecture. After a Next.js production build, `pnpm check:custom-widget-bundle` also enforces a 768 KiB gzip ceiling across the client chunks referenced by Custom JSX. diff --git a/apps/docs/docs/management/custom-widgets/authoring.mdx b/apps/docs/docs/management/custom-widgets/authoring.mdx new file mode 100644 index 000000000..ebe31288c --- /dev/null +++ b/apps/docs/docs/management/custom-widgets/authoring.mdx @@ -0,0 +1,36 @@ +--- +sidebar_label: Authoring workbench +--- + +# Authoring workbench + +The Custom Widget form is a continuous workflow: choose a display, configure the HTTP connection, configure the display, then test it in the adjacent preview. Each section stays visible so you can revisit earlier choices without losing context. + +## Choose a display + +The display grid is the first product decision. Built-in displays are best for common metrics, tables, statuses, and actions. Choose Custom JSX when the layout needs multiple Mantine components, conditional presentation, charts, dates, or named requests. + +Changing display type preserves shared connection fields and initializes safe display defaults. A Custom JSX template is never blank; new and migrated forms receive the tested starter fixture. + +## Test and preview + +The preview has four tabs: + +- **Widget** renders at compact, standard, or wide board-like sizes. +- **Response** uses a tree to inspect data, copy paths, and insert paths into JSX. The external-response action opens a temporary local blob and never publishes the response. +- **Request** shows the redacted base request, named capabilities, status, duration, and preview journal. +- **Diagnostics** shows template size, named requests, network scope, and blocking or advisory issues. + +Only GET base requests run automatically. Preview actions are simulated until an administrator explicitly enables live actions for the five-minute preview session. DELETE still requires confirmation. + +## Keyboard and clipboard + +The JSX and JSON editors support native Ctrl/Cmd+Z and redo, plus visible toolbar controls. Cursor position, character count, and the 50,000-character limit remain visible. + +On the list page, paste a complete v3 export with Ctrl+V or Command+V to import it as new. On an edit page, pasting opens a replacement review. Nothing is applied before the origin, methods, credential inheritance, and permissions are shown. + +For AI output, prefer the authoring bundle format: a JSON block containing `"template": "__HOMARR_TEMPLATE__"`, followed by a JSX block. This keeps multiline JSX readable and avoids JSON escape errors. + +## Save behavior + +Errors block save; warnings do not. Server validation runs again on every create or update. Leaving with dirty changes triggers protection. Secrets omitted during edit remain unchanged, and secrets are never exported. diff --git a/apps/docs/docs/management/custom-widgets/custom-jsx.mdx b/apps/docs/docs/management/custom-widgets/custom-jsx.mdx new file mode 100644 index 000000000..d00334b92 --- /dev/null +++ b/apps/docs/docs/management/custom-widgets/custom-jsx.mdx @@ -0,0 +1,49 @@ +--- +sidebar_label: Custom JSX language +--- + +# Custom JSX language + +Custom JSX is a declarative expression language, not browser JavaScript. Homarr parses an explicit AST subset and emits React elements from a classified component registry. Templates cannot access browser globals, native prototypes, constructors, refs, portals, raw event handlers, or direct `fetch`. + +## Data and rendering + +The base GET response is available as `data`. Safe member access, conditionals, arrays, object literals, and interpreter-created collection callbacks can compose displays: + +```jsx + + {data.services + .filter((service) => service.visible) + .map((service) => ( + + {service.name} + {service.status} + + ))} + +``` + +Properties are resolved own-only. Reflective names such as `constructor`, `prototype`, `__proto__`, `caller`, `callee`, `arguments`, `bind`, `call`, and `apply` are rejected even when computed or Unicode escaped. + +## Components and props + +Every Mantine export is classified as allowed, wrapped, or denied. The [generated component reference](./#component-reference) is authoritative. Props are allowlisted per component; unsupported props produce warnings and are ignored. Polymorphic roots, unsafe URLs, portals, positioning escapes, refs, and function props are stripped. + +`SubData` is a convenience for simple response paths. Prefer the render-child pattern for rich nested results: + +```jsx + + {(detail, meta) => ( + + {detail.name} + HTTP {meta.status} + + )} + +``` + +## Safe helpers and budgets + +Bindings include restricted conversion, string, array, object, JSON, math, URI, and pure date helpers. Native `Date` objects and native prototypes are not exposed. + +Templates are limited to 50,000 characters, 10,000 rendered nodes, and explicit AST-depth, operation, collection, and string budgets. Budget errors stop only the Custom JSX renderer and are contained by its error boundary. diff --git a/apps/docs/docs/management/custom-widgets/extension-recipes.mdx b/apps/docs/docs/management/custom-widgets/extension-recipes.mdx new file mode 100644 index 000000000..650963432 --- /dev/null +++ b/apps/docs/docs/management/custom-widgets/extension-recipes.mdx @@ -0,0 +1,66 @@ +--- +sidebar_label: Extension recipes +--- + +# Custom Widget extension recipes + +These recipes keep every authoring and runtime path on the same typed source of truth. Run `pnpm check:custom-widgets` after each structural change and add focused package tests before changing an adapter. + +## Add a built-in display type + +1. Add the discriminated configuration schema in `@homarr/custom-widgets/core`. +2. Add one descriptor with its icon, category, localized metadata keys, defaults, hydration, serialization, and validation. +3. Add the renderer to the runtime display map. It must consume normalized display data and injected actions only. +4. Add a bounded workbench section that edits the descriptor-owned form fields. +5. Add one fixture and assert create, edit, v2/v3 import, export, MCP, and preview round trips against it. +6. Add translation keys and update the display table in the user guide. + +Do not add route-specific conversion code. `buildDisplayFormValues` and `buildDisplayConfigFromFormValues` are the only form conversion boundary. + +## Add or update a JSX component + +1. Classify the Mantine export as `allowed`, `wrapped`, or `denied` in the component registry. Denied entries require a reason. +2. Declare supported props and subcomponents. Function props, refs, portals, polymorphic roots, and unsafe positioning stay denied unless a wrapper removes the unsafe behavior. +3. Implement wrappers in the JSX package and register them through the package runtime-component factory. +4. Add analyzer and renderer tests for accepted props, stripped props, reflective-property attacks, and the rendered-node budget. +5. Regenerate the docs reference and verify the editor completion and AI prompt include the same entry. + +The component-classification test must pass against the locked Mantine version. Never expose an upstream namespace or native prototype as a shortcut. + +## Add a named-request capability + +1. Extend the request schema and manifest renderer in `core` and `server` without accepting a raw runtime URL, method, header, or body. +2. Enforce permission, network scope, redirect, DNS, header, body, response, concurrency, and rate policies in the framework-neutral server service. +3. Expose infrastructure through a typed server port. Translate domain errors only in the API adapter. +4. Add the control to runtime through the injected request port. Queries use query semantics; actions require a gesture and use mutation semantics. +5. Add preview simulation and redacted-journal coverage. Live actions remain an explicit administrator-only browser choice. +6. Update MCP validation and simulation tools without exposing stored secrets or unrestricted action execution. + +Tests must prove actions are never mounted automatically, polled, retried, cached, or redirected. DELETE must retain full permission and confirmation. + +## Add a workbench feature + +1. Put reusable state, analysis, or presentation in `@homarr/custom-widgets/workbench`. +2. Receive localized messages and typed callbacks as props. The package cannot import the tRPC client, Next.js navigation, notifications, or Homarr widget adapters. +3. Keep the Next.js component as a transport and page-shell adapter. +4. Cover keyboard operation, focus order, reduced motion, 320/768/desktop layouts, dirty-state behavior, and error-boundary recovery. +5. Keep each production module below 300 lines and preserve the continuous two-pane form behavior. + +## Change examples or AI authoring + +Examples live as typed shared fixtures. Tests, snippets, documentation data, and the AI prompt consume those fixtures. AI output uses an authoring bundle: a JSON block with `__HOMARR_TEMPLATE__`, followed by a readable multiline JSX block. Do not require agents to escape an entire template into one JSON string. + +After changing a fixture, validate every example, render it, regenerate the component reference, and run the prompt snapshot tests. MCP agents must be able to read a widget, patch template lines with a revision, validate, preview named queries, simulate actions, inspect the journal, and update the definition without receiving secret values. + +## Required checks + +```bash +pnpm check:custom-widgets +pnpm test +pnpm test:e2e +pnpm turbo typecheck --affected +pnpm turbo lint --affected +pnpm turbo build --filter=@homarr/docs +``` + +Also run the component-classification, generated-reference drift, bundle-budget, accessibility, and focused package/API suites configured by the repository. A change is incomplete if any create, edit, import, export, MCP, preview, or board-runtime path uses a separate transform. diff --git a/apps/docs/docs/management/custom-widgets/index.mdx b/apps/docs/docs/management/custom-widgets/index.mdx index 0395253dc..decb337aa 100644 --- a/apps/docs/docs/management/custom-widgets/index.mdx +++ b/apps/docs/docs/management/custom-widgets/index.mdx @@ -6,203 +6,199 @@ tags: - JSX --- +import { CustomJsxComponentReference } from "@site/src/components/custom-jsx-component-reference"; + # Custom Widgets -:::warning +Custom widgets connect a dashboard item to an HTTP API without compiling a new Homarr widget. Administrators choose the endpoint and authentication, then use a built-in display type or a Custom JSX template to render the response. -Custom widgets are a new feature. Share feedback, ask questions, and discuss ideas in our [GitHub Discussions](https://github.com/homarr-labs/homarr/discussions/categories/custom-widgets). +## Guides + +- [Authoring workbench](./authoring): create, edit, preview, paste, undo, import, and export. +- [Custom JSX language](./custom-jsx): supported syntax, components, bindings, diagnostics, and limits. +- [Named requests and security](./requests-and-security): permissions, network scopes, request manifests, and server protections. +- [AI and MCP authoring](./agent-authoring): an iterative agent workflow that validates and previews before saving. +- [Compatibility and migration](./migration): v1/v2 JSX and v2/v3 import behavior. +- [Troubleshooting](./troubleshooting): common editor, preview, permission, and networking failures. +- [Maintainer architecture](./architecture): package boundaries, extension points, and required tests. +- [Extension recipes](./extension-recipes): step-by-step changes for displays, JSX components, requests, and workbench features. + +:::caution + +A custom widget can expose data or perform actions with the credentials configured for it. Import definitions only from sources you trust and review every network capability before using the widget on a shared board. ::: -Custom widgets allow you to fetch data from any HTTP API and display it on your Homarr dashboard. You define the API endpoint, authentication, and how the response should be rendered - no code compilation or server restart required. +## Create a widget -## Creating a Custom Widget +Open **Management → Custom Widgets**, select **Add**, and configure: -To create a custom widget, navigate to the **Custom Widgets** section in the management sidebar and click the **Add** button. Fill in the configuration: +- **Name, description, and icon**: identify the widget in management and the widget picker. +- **URL**: the full HTTP or HTTPS base endpoint. +- **Authentication**: none, bearer token, basic authentication, API-key header, or API-key query parameter. +- **Display type**: a built-in renderer or Custom JSX. -- **Name** - Display name shown in the widget picker and on the dashboard -- **Description** - Optional description shown in tooltips and management UI -- **Icon URL** - Optional URL to an icon image for the widget -- **URL** - The API endpoint to fetch data from (must include protocol, e.g. `https://api.example.com/stats`) -- **Authentication** - How the API request is authenticated: - - `none` - Public APIs with no authentication - - `bearer` - Bearer token authentication - - `basic` - HTTP Basic auth (username + password) - - `apiKeyHeader` - API key sent as a custom HTTP header - - `apiKeyQuery` - API key sent as a query parameter -- **Header Name** - Custom header or query parameter name for API key auth (e.g. `X-API-Key`) -- **HTTP Method** - `GET`, `POST`, `PUT`, `PATCH`, or `DELETE` -- **Request Body** - JSON string body for `POST`/`PUT`/`PATCH` requests -- **Display Type** - How the API response is rendered (see below) +Use **Test** to run the current GET request. The preview workbench separates the rendered widget, sanitized response tree, redacted request journal, and diagnostics. It marks sample data as stale whenever the connection or display configuration changes after a test. -## Display Types +Testing creates a five-minute, administrator-bound preview session for unsaved named queries. Action controls are simulated by default. An administrator can explicitly enable live actions for that session; DELETE still requires confirmation. -| Display Type | Description | Best For | -| -------------------- | ---------------------------------------------------- | ---------------------------------------- | -| **Single Value** | Extracts a single value with a label and unit | Metrics: temperature, uptime, user count | -| **Key Value** | Multiple labeled key-value pairs with optional units | System stats: CPU, memory, disk | -| **Table** | API array data rendered as a sortable table | Lists of items with columns | -| **Stat Grid** | Labeled values in colored stat cards | Counts: movies, series, albums | -| **Progress Bars** | Values as progress bars with percentages | Usage: disk, quota, capacity | -| **Status Indicator** | Green/red status dots for health checks | Service monitoring | -| **Count Grid** | Simple counts in a grid (no colors) | Library counts | -| **Raw** | Pretty-prints the raw JSON response | Debugging | -| **Action Button** | Clickable button executing the API request | Triggers: restart, clear cache | -| **Custom JSX** | Custom JSX template with Mantine v9 components | Full layout control | +## Display types -### AI-Powered JSX Generation +| Display type | Use it for | +| ---------------- | --------------------------------------------------------- | +| Single Value | One metric with a label and unit | +| Key Value | Several labeled values | +| Table | Arrays of records | +| Stat Grid | Compact colored metrics | +| Progress Bars | Capacity, quota, and completion | +| Status Indicator | Health and availability | +| Count Grid | Compact counters | +| Raw | Sanitized JSON inspection | +| Action Button | One explicit API action | +| Custom JSX | A declarative Mantine layout with optional named requests | -When editing or creating a custom widget with the **Custom JSX** display type, you'll find a **Copy Prompt** button. Clicking it copies a pre-formatted prompt describing your widget's name, API endpoint, and available Mantine components. Paste this into your preferred AI assistant (ChatGPT, Claude, Copilot, etc.) to generate a JSX template tailored to your data. +## Custom JSX workbench -
-Example: Pokédex widget using Custom JSX +The JSX editor provides syntax highlighting, formatting, undo/redo buttons and Ctrl/Cmd+Z shortcuts, a searchable component reference, character and cursor status, and diagnostics. Errors block saving; warnings identify behavior that still receives server-side validation. Templates can contain up to 50,000 characters and render up to 10,000 nodes. + +The template reads the base GET response from `data`: + +```jsx + + {data.name} + {data.status} + +``` + +The **Copy AI prompt** action is available on desktop and mobile. Its prompt, component list, and examples are generated from the same metadata used by the renderer, so the reference stays aligned with the installed Homarr version. + +### JSX API versions + +- **Version 2** is the default. Network access is declared in a named-request manifest and enforced by the server. +- **Version 1** remains available for display-only templates. Inline network components are disabled until the definition is reviewed and migrated. + +Definitions without `jsxApiVersion` are treated as version 1. Display-only templates can be migrated by selecting version 2 and saving an empty request list. + +## Named requests + +Version 2 templates never choose an arbitrary URL, method, header, or body at runtime. An administrator declares each allowed operation once, and the template references its `requestId` with typed parameters. ```json { - "$schema": "homarr-custom-widget-v2", - "name": "Pokédex", - "description": "Browseable Pokémon list", - "iconUrl": "https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/items/poke-ball.png", - "url": "https://pokeapi.co/api/v2/pokemon?limit=75", - "authType": "none", - "method": "GET", - "displayType": "customJsx", - "displayConfig": { - "type": "customJsx", - "template": "\n \n \n Pokédex\n \n \n \n \n {data.results.map((pokemon, i) =>\n \n \n \n \n \n #{i + 1}\n {pokemon.name}\n \n \n \n \n \n \n )}\n \n \n" - } + "type": "customJsx", + "jsxApiVersion": 2, + "networkScope": "public", + "template": "", + "requests": [ + { + "id": "service-detail", + "kind": "query", + "method": "GET", + "pathTemplate": "/api/services/{id}", + "parameters": { "id": "string" }, + "auth": "inherit", + "minimumBoardPermission": "view", + "cacheTtlSeconds": 30 + } + ] } ``` -
+Path placeholders use `{parameter}` and are URL-encoded by the server. JSON body placeholders use `{ "$param": "parameter" }` and preserve the declared string, number, or boolean type. -## Importing and Exporting +`SubData` remains available for simple paths. For richer nested output, pass an interpreter-created render child; it receives the response data and safe status metadata: -Custom widgets can be exported and imported as JSON files. To export, select the widget in the list and click the export button. To import, click the import button and paste the JSON. Secrets (API keys, passwords) are never included in exports and must be configured after import. +```jsx + + {(detail, meta) => ( + + {detail.status} + HTTP {meta.status} + + )} + +``` -The import format uses `"$schema": "homarr-custom-widget-v2"` to identify the widget version. +| Component | Request kind | Behavior | +| --------------- | ------------ | ------------------------------------------------------------- | +| `SubFetch` | `query` | Loads a named GET request automatically or manually | +| `ActionButton` | `action` | Runs a named POST, PUT, PATCH, or DELETE after a user gesture | +| `ToggleSwitch` | `action` | Passes declared on/off parameters and rolls back on failure | +| `RefreshButton` | None | Refreshes the parent GET response | -## Available Mantine Components for Custom JSX +Queries require board **view** permission. POST, PUT, and PATCH actions require **modify** by default. DELETE requires **full** permission and confirmation. Allowing viewers to execute a non-DELETE action requires explicit administrator approval. Anonymous viewers cannot execute actions. -When using the `customJsx` display type, your template has access to a whitelist of [Mantine v9](https://mantine.dev) components. Unrecognized components, event handlers, and dangerous tags are stripped for security. +### Network scopes -### Layout +| Scope | Allowed destinations | +| ---------- | ------------------------------------------------------------ | +| `public` | Public IP addresses only | +| `private` | Public addresses plus RFC1918 and IPv6 ULA private addresses | +| `loopback` | Public, private, and loopback addresses | -| Component | Doc | -| ------------------- | --------------------------------------------- | -| `Stack` | [docs](https://mantine.dev/core/stack) | -| `Group` | [docs](https://mantine.dev/core/group) | -| `Flex` | [docs](https://mantine.dev/core/flex) | -| `Grid` / `Grid.Col` | [docs](https://mantine.dev/core/grid) | -| `SimpleGrid` | [docs](https://mantine.dev/core/simple-grid) | -| `Center` | [docs](https://mantine.dev/core/center) | -| `Container` | [docs](https://mantine.dev/core/container) | -| `Space` | [docs](https://mantine.dev/core/space) | -| `AspectRatio` | [docs](https://mantine.dev/core/aspect-ratio) | +Link-local, cloud-metadata, unspecified, multicast, documentation, carrier-grade NAT, and IPv4-mapped bypass addresses remain blocked in every scope. -### Typography & Content +### Example with a named query -| Component | Doc | -| ----------------- | ------------------------------------------------- | -| `Text` | [docs](https://mantine.dev/core/text) | -| `Title` | [docs](https://mantine.dev/core/title) | -| `Code` | [docs](https://mantine.dev/core/code) | -| `Highlight` | [docs](https://mantine.dev/core/highlight) | -| `Mark` | [docs](https://mantine.dev/core/mark) | -| `Kbd` | [docs](https://mantine.dev/core/kbd) | -| `Blockquote` | [docs](https://mantine.dev/core/blockquote) | -| `Anchor` | [docs](https://mantine.dev/core/anchor) | -| `NumberFormatter` | [docs](https://mantine.dev/core/number-formatter) | +The editor and AI prompt include a shared Pokédex fixture that loads details only for the visible page. Its named request is equivalent to: -### Data Display +```json +{ + "id": "pokemon-detail", + "kind": "query", + "method": "GET", + "pathTemplate": "/api/v2/pokemon/{name}", + "parameters": { "name": "string" }, + "auth": "none", + "minimumBoardPermission": "view", + "cacheTtlSeconds": 300 +} +``` -| Component | Doc | -| ------------------------- | ------------------------------------------------- | -| `Badge` | [docs](https://mantine.dev/core/badge) | -| `Card` / `Card.Section` | [docs](https://mantine.dev/core/card) | -| `Paper` | [docs](https://mantine.dev/core/paper) | -| `Alert` | [docs](https://mantine.dev/core/alert) | -| `ThemeIcon` | [docs](https://mantine.dev/core/theme-icon) | -| `ColorSwatch` | [docs](https://mantine.dev/core/color-swatch) | -| `Avatar` / `Avatar.Group` | [docs](https://mantine.dev/core/avatar) | -| `Image` | [docs](https://mantine.dev/core/image) | -| `BackgroundImage` | [docs](https://mantine.dev/core/background-image) | -| `Indicator` | [docs](https://mantine.dev/core/indicator) | -| `Pill` | [docs](https://mantine.dev/core/pill) | -| `Spoiler` | [docs](https://mantine.dev/core/spoiler) | +## Agent authoring through MCP -### Tables +Administrators can use Homarr's MCP server to iterate on custom widgets without bypassing validation or network controls. A typical agent workflow is: -| Component | Doc | -| --------------------------------------- | -------------------------------------- | -| `Table` / `Table.Thead` / `Table.Tbody` | [docs](https://mantine.dev/core/table) | -| `Table.Tr` / `Table.Th` / `Table.Td` | [docs](https://mantine.dev/core/table) | +1. Call `customWidget_schema` to inspect the current import format. +2. Generate a complete `homarr-custom-widget-v3` draft. +3. Call `customWidget_validate` and correct every returned issue. +4. Call `customWidget_preview` to test the base GET request through Homarr's hardened executor. +5. Use `customWidget_previewQuery` for named queries and `customWidget_simulatePreviewAction` to verify action parameters without sending mutations. +6. Inspect `customWidget_previewJournal`, then validate again. +7. Call `customWidget_import`, or read an existing widget with `customWidget_byId` and apply a focused `customWidget_update`. -### Lists +MCP preview actions are simulation-only. Enabling live preview actions remains an explicit administrator choice in the browser workbench. Stored secret values are never returned by MCP; omit `secrets` when updating an existing widget to preserve them. -| Component | Doc | -| ---------------------------- | ----------------------------------------- | -| `List` / `List.Item` | [docs](https://mantine.dev/core/list) | -| `Timeline` / `Timeline.Item` | [docs](https://mantine.dev/core/timeline) | +## Component reference -### Feedback & Loading +Custom JSX exposes a classified subset of Mantine Core, Charts, Dates, and Homarr components. Allowed components render directly. Wrapped components receive safe props or read-only behavior. Denied components remain in the registry so dependency upgrades cannot silently expand the template surface. -| Component | Doc | -| ------------------------------- | ---------------------------------------------- | -| `Progress` / `Progress.Section` | [docs](https://mantine.dev/core/progress) | -| `RingProgress` | [docs](https://mantine.dev/core/ring-progress) | -| `Skeleton` | [docs](https://mantine.dev/core/skeleton) | -| `Loader` | [docs](https://mantine.dev/core/loader) | + -### Navigation & Overlay +This table and the searchable component list in the editor are generated from Homarr's runtime registry. -| Component | Doc | -| ------------------------------------------------------------------------ | -------------------------------------------- | -| `TabsContainer` / `TabPanel` | Custom interactive component | -| `Accordion` / `Accordion.Item` / `Accordion.Control` / `Accordion.Panel` | [docs](https://mantine.dev/core/accordion) | -| `ScrollArea` | [docs](https://mantine.dev/core/scroll-area) | -| `Tooltip` | [docs](https://mantine.dev/core/tooltip) | +Component props are filtered. Polymorphic roots, portals, refs, unsafe positioning, raw event handlers, and `dangerouslySetInnerHTML` are not exposed. Direct browser globals and direct `fetch` calls are unavailable, while ordinary text containing the word “fetch” is valid. -### Charts +Safe bindings include conversion helpers, a restricted `Math` and `JSON` surface, object and array helpers, URI encoding helpers, and pure date formatting helpers. Collection callbacks and rendered output are subject to interpreter budgets. -| Component | Doc | -| ---------------- | --------------------------------------------------- | -| `AreaChart` | [docs](https://mantine.dev/charts/area-chart) | -| `BarChart` | [docs](https://mantine.dev/charts/bar-chart) | -| `LineChart` | [docs](https://mantine.dev/charts/line-chart) | -| `DonutChart` | [docs](https://mantine.dev/charts/donut-chart) | -| `PieChart` | [docs](https://mantine.dev/charts/pie-chart) | -| `RadarChart` | [docs](https://mantine.dev/charts/radar-chart) | -| `RadialBarChart` | [docs](https://mantine.dev/charts/radial-bar-chart) | -| `Sparkline` | [docs](https://mantine.dev/charts/sparkline) | +## HTTP protections and limits -### Interactive Components +All base, preview, query, and action requests use the same server executor: -| Component | Description | -| --------------- | ---------------------------------------- | -| `PaginatedList` | Client-side pagination wrapper | -| `Collapsible` | Expandable/collapsible section | -| `StatBar` | Horizontal stat bar | -| `TypeBadge` | Type-styled badge | -| `Divider` | [docs](https://mantine.dev/core/divider) | +- Only HTTP and HTTPS are accepted. URL credentials and fragments are rejected. +- Named paths must stay on the base endpoint origin. +- DNS results are validated against the selected network scope and pinned for the request. +- Queries can follow up to three revalidated same-origin redirects. Actions do not follow redirects. +- Authorization, cookie, host, forwarding, proxy, content-length, and hop-by-hop headers cannot be supplied by a template. +- Request bodies are limited to 10 KiB. Decompressed responses are limited to 1 MiB, 32 JSON levels, and 50,000 JSON nodes. +- GET requests can be cached and deduplicated. Actions are never cached, polled, or retried automatically. -## Template Bindings +## Import and export -Your template receives: +New exports use `"$schema": "homarr-custom-widget-v3"`. Version 2 imports remain accepted. Secrets are never exported and must be entered again after import. -- `data` - The sanitized API response object. Access fields via `data.fieldName` or `data.results[0].name`. -- `String(v)` - Type-safe string conversion -- `Number(v)` - Type-safe number conversion -- `Boolean(v)` - Type-safe boolean conversion -- `Math` - Safe subset: `round`, `floor`, `ceil`, `abs`, `min`, `max`, `pow`, `sqrt`, `PI` -- `JSON.stringify(v)` - JSON serialization -- `Array.isArray(v)` - Array type check -- `Object.keys(v)`, `Object.values(v)`, `Object.entries(v)` - Object utilities +Review the base origin, network scope, named request methods, inherited authentication, and required permissions before saving an imported widget. A version 1 template that contains inline network components stays disabled until it is converted to named requests. -## Security Constraints +AI-generated Custom JSX can also be pasted as a Homarr authoring bundle: one fenced JSON block with `"template": "__HOMARR_TEMPLATE__"`, followed by one fenced JSX block containing the readable multiline template. Homarr combines the blocks before validation, avoiding JSON newline and quote escaping. Raw JSON imports remain supported. -- Event handlers (`onClick`, `onChange`, etc.) are stripped -- Dangerous HTML attributes (`dangerouslySetInnerHTML`) are stripped -- `script`, `iframe`, `object`, `embed`, `form`, `style`, `link`, `meta`, `base` tags are forbidden -- Template strings containing `eval`, `Function`, `import`, `require`, `globalThis`, `window`, `document`, `fetch` are rejected -- Anchor `href` attributes are validated to only allow `https://`, relative (`/`), and hash (`#`) URLs +On the custom-widget list, paste a complete export with Ctrl+V or Command+V to open the import review and create it as a new definition. On an edit page, the same shortcut opens a replacement review and fills the existing form after confirmation. Pasted definitions never include secrets. diff --git a/apps/docs/docs/management/custom-widgets/migration.mdx b/apps/docs/docs/management/custom-widgets/migration.mdx new file mode 100644 index 000000000..828845454 --- /dev/null +++ b/apps/docs/docs/management/custom-widgets/migration.mdx @@ -0,0 +1,19 @@ +--- +sidebar_label: Compatibility and migration +--- + +# Compatibility and migration + +Homarr preserves existing display definitions while moving network-enabled Custom JSX to the named-request model. + +## JSX API versions + +Missing `jsxApiVersion` means v1. Display-only v1 templates can be opened and saved as v2 with an empty request manifest. Inline `url`, `method`, `headers`, and body props are inert in v2. + +Static v1 network components can be converted by creating a named request and replacing inline capability props with `requestId` and typed `params`. Dynamic target construction requires an administrator to design an explicit path template and parameter list. Existing non-GET base definitions stop polling and show a network-review state. + +## Import versions + +Exports use `homarr-custom-widget-v3`; v2 imports remain accepted. Import migration normalizes display configuration, preserves v1 semantics, and never imports secret values. The review screen must be accepted before persistence. + +Test migration with the same base response and compare rendered output, query results, action simulation, permissions, and journal entries before enabling the migrated definition on shared boards. diff --git a/apps/docs/docs/management/custom-widgets/requests-and-security.mdx b/apps/docs/docs/management/custom-widgets/requests-and-security.mdx new file mode 100644 index 000000000..6afc34745 --- /dev/null +++ b/apps/docs/docs/management/custom-widgets/requests-and-security.mdx @@ -0,0 +1,32 @@ +--- +sidebar_label: Requests and security +--- + +# Named requests and security + +Custom JSX v2 uses a saved request manifest. Runtime components pass only a `requestId` and declared primitive parameters; they cannot change the URL, method, headers, authentication, or body shape. + +## Capability kinds + +`SubFetch` references a GET `query`. `ActionButton` and `ToggleSwitch` reference a POST, PUT, PATCH, or DELETE `action`. Base data is GET-only. Actions require an explicit gesture and are never polled, cached, retried automatically, or run on mount. + +Default board permissions are view for queries, modify for POST/PUT/PATCH, and full for DELETE. Viewer actions require explicit high-risk approval; anonymous users cannot execute actions. DELETE always requires confirmation. + +## Parameter substitution + +Path placeholders use `{name}` and are URL-encoded by the server. Runtime parameters must exactly match all declared names and types. JSON bodies substitute `{ "$param": "name" }` recursively and preserve string, number, or boolean types. + +## Network boundary + +Named paths stay on the base URL origin. HTTP and HTTPS are accepted; URL credentials and fragments are rejected. DNS answers are classified and pinned. Public, private, and loopback scopes progressively allow destinations, but link-local, metadata, unspecified, multicast, documentation, carrier-grade NAT, and IPv4-mapped addresses are always blocked. + +Queries may follow three revalidated same-origin redirects. Actions do not follow redirects. Credentials never cross origins. Reserved authentication, cookie, host, forwarding, proxy, content-length, security, and hop-by-hop headers cannot be declared. + +## Limits + +- Request body: 10 KiB UTF-8. +- Decompressed response: 1 MiB, 32 JSON levels, 50,000 JSON nodes. +- Per user/item: 60 queries, 10 actions, and 3 deletes per minute. +- Concurrency: 4 per user/item and 8 per definition. + +Successful GETs can use manifest cache TTLs and single-flight deduplication. Logs contain redacted origin/method/error metadata, never secrets, request bodies, or query values. diff --git a/apps/docs/docs/management/custom-widgets/troubleshooting.mdx b/apps/docs/docs/management/custom-widgets/troubleshooting.mdx new file mode 100644 index 000000000..0fd46a3d4 --- /dev/null +++ b/apps/docs/docs/management/custom-widgets/troubleshooting.mdx @@ -0,0 +1,33 @@ +--- +sidebar_label: Troubleshooting +--- + +# Troubleshooting + +## The preview says the template is required + +New Custom JSX forms always include the starter fixture. If an imported definition has an empty template, reopen its import review; malformed imports must be corrected rather than previewed as JSX. + +## A prop is ignored + +The diagnostics name the component and prop. Check the generated component reference. Unsupported props are intentionally removed; use a supported layout primitive or wrapper prop instead of polymorphic, portal, ref, positioning, or raw handler props. + +## A request does not run + +Confirm that the component kind matches the manifest: `SubFetch` needs a query; action controls need an action. Parameter names and primitive types must match exactly. Base requests and queries require GET. Actions only run from a gesture, and edit mode disables controls. + +## Network scope errors + +Resolve the hostname from the Homarr server environment. Select private or loopback scope only when required and understood. Link-local and metadata destinations cannot be enabled by any scope. Redirects must remain on the base origin. + +## Permission errors + +The placed board item is the authorization anchor. A definition ID alone cannot authorize credential use. Verify board view/modify/full access, explicit viewer-action approval, and that the caller is not anonymous. + +## Stale or failed preview data + +Connection, authentication, body, method, secret, or manifest changes mark samples stale. Run the GET test again. Background query failures keep prior content visible and offer retry; actions roll toggles back and show error feedback. + +## Import paste is ignored + +Paste a complete v2/v3 JSON export or authoring bundle while the list or edit page is focused. Ordinary text and partial JSON are ignored so normal typing is not intercepted. diff --git a/apps/docs/docs/management/mcp.mdx b/apps/docs/docs/management/mcp.mdx index 7c79d9a8d..aa1b5972c 100644 --- a/apps/docs/docs/management/mcp.mdx +++ b/apps/docs/docs/management/mcp.mdx @@ -73,13 +73,7 @@ Replace `` with your actual API key. Never commit API keys to vers "mcpServers": { "homarr": { "command": "npx", - "args": [ - "-y", - "mcp-remote", - "https://your-homarr-instance.com/api/mcp/mcp", - "--header", - "ApiKey:" - ] + "args": ["-y", "mcp-remote", "https://your-homarr-instance.com/api/mcp/mcp", "--header", "ApiKey:"] } } } @@ -126,25 +120,26 @@ curl -s -X POST \ Homarr exposes 50+ tools organized by namespace. Each tool is either a **query** (GET, read-only) or **mutation** (POST, write action). -| Namespace | Example Tools | Type | -| ------------------ | -------------------------------------------------------- | ---------- | -| `app` | List all apps, get app by ID, create/update/delete app | GET + POST | -| `apiKeys` | List API keys | GET | -| `beszel` | Systems status, alerts, historical system metrics | GET | -| `board` | List boards, get board by ID, create/update/delete board | GET + POST | -| `docker` | List containers, inspect container, start/stop/restart | GET + POST | -| `icon` | Search icons | GET | -| `info` | Server health, version info | GET | -| `integration` | List integrations, test connection, delete integration | GET + POST | -| `invite` | List invitations, delete invite | GET + POST | -| `calendar` | Calendar events from media servers | GET | -| `dnsHole` | DNS hole summary, toggle blocking | GET + POST | -| `downloads` | Active downloads, pause/resume/delete | GET + POST | -| `healthMonitoring` | Resource usage stats | GET | -| `patchmon` | Host patch and security update statistics | GET | -| `mediaRequests` | Approve/decline media requests | GET + POST | -| `mediaServer` | Media server sessions and stats | GET | -| `smartHome` | Execute automations, device states | GET + POST | +| Namespace | Example Tools | Type | +| ------------------ | --------------------------------------------------------- | ---------- | +| `app` | List all apps, get app by ID, create/update/delete app | GET + POST | +| `apiKeys` | List API keys | GET | +| `beszel` | Systems status, alerts, historical system metrics | GET | +| `board` | List boards, get board by ID, create/update/delete board | GET + POST | +| `docker` | List containers, inspect container, start/stop/restart | GET + POST | +| `icon` | Search icons | GET | +| `info` | Server health, version info | GET | +| `integration` | List integrations, test connection, delete integration | GET + POST | +| `invite` | List invitations, delete invite | GET + POST | +| `calendar` | Calendar events from media servers | GET | +| `customWidget` | Validate, preview, create, and iteratively update widgets | GET + POST | +| `dnsHole` | DNS hole summary, toggle blocking | GET + POST | +| `downloads` | Active downloads, pause/resume/delete | GET + POST | +| `healthMonitoring` | Resource usage stats | GET | +| `patchmon` | Host patch and security update statistics | GET | +| `mediaRequests` | Approve/decline media requests | GET + POST | +| `mediaServer` | Media server sessions and stats | GET | +| `smartHome` | Execute automations, device states | GET + POST | The tools table on the MCP tab is dynamically generated - it always reflects the latest available procedures from your Homarr instance. @@ -154,6 +149,8 @@ The tools table on the MCP tab is dynamically generated - it always reflects the - Tools inherit the permissions of the API key's owner - OAuth endpoints are rate-limited to prevent abuse - Tool execution errors are contained - a failing tool call does not crash the MCP server +- Custom-widget MCP actions are simulation-only; live preview actions must be enabled explicitly in the browser workbench +- Custom-widget secret values are never returned through MCP - All communication uses HTTPS (configure HTTP → HTTPS redirects on your reverse proxy) ## Use Cases @@ -165,3 +162,58 @@ The tools table on the MCP tab is dynamically generated - it always reflects the - **"How many users are on my Homarr instance?"** - AI lists all users (admin only) - **"Toggle Pi-hole blocking for 5 minutes"** - AI interacts with DNS controls - **"How are my servers doing?"** - AI fetches Beszel system stats including CPU, memory, disk, and alerts +- **"Build and refine a custom widget for this API"** - AI validates the draft, tests GET data and named queries, simulates actions, and creates or updates the widget + +## Custom Widget Workflow for AI Agents + +AI agents can create and iterate on custom widgets using these tools in sequence. + +:::tip Editing an existing widget? +Skip to step 5. Use `customWidget_byId` to fetch it and `customWidget_readTemplate` / `customWidget_writeTemplate` to edit its template directly. +::: + +### 1. Get the schema + +Call `customWidget_schema` to receive the JSON Schema for the `homarr-custom-widget-v3` format. This tells the agent what fields are required and their types. + +### 2. Draft and validate + +Build a widget JSON object and call `customWidget_validate` with it. The tool returns structured issues (path + message) so the agent can fix and re-validate until the draft is clean. + +### 3. Create the widget + +Call `customWidget_import` with the validated `homarr-custom-widget-v3` draft. This returns the new widget `id`. Use `customWidget_create` only when you intentionally need its lower-level creation input, including secret fields. + +### 4. Test with real data + +Call `customWidget_preview` with the widget's connection info. This makes a real GET request through Homarr's hardened executor and returns the sanitized response plus a preview session ID. + +For Custom JSX v2 widgets with named requests, use `customWidget_previewQuery` to test each named GET query, and `customWidget_simulatePreviewAction` to dry-run actions without network calls. + +### 5. Iterate on the template + +Use `customWidget_readTemplate` to get the current JSX template as plain text, then `customWidget_writeTemplate` to push updates. The write tool accepts either: + +- `template` — a single string (newlines as `\n`) +- `templateLines` — an array of strings (joined with newlines server-side, avoids `\n` escaping) + +Both options validate the template AST before saving. This avoids re-sending the full widget JSON for template-only edits. + +For small changes, prefer `customWidget_patchTemplate`. Pass the `revision` returned by `customWidget_readTemplate` and one or more line edits. Homarr rejects stale revisions, applies all edits atomically, and validates the complete template against its named request manifest before saving. + +### 6. Update non-template fields + +Call `customWidget_byId` to get the full widget, modify fields, and call `customWidget_update` with only the changed fields. + +### Available components in templates + +Custom JSX templates support 100+ Mantine components plus: + +- `` — 100+ curated Tabler icons by kebab-case name (e.g. `"player-play"`, `"alert-triangle"`) +- `` / `` / `` — network-capable components for named requests +- Array methods: `map`, `filter`, `find`, `findIndex`, `some`, `every`, `reduce`, `sort`, `slice`, `flat`, `reverse`, `at`, `pop`, `join`, `includes`, `indexOf` (note: `pop` returns last element without mutating) +- String methods: `toUpperCase`, `toLowerCase`, `trim`, `trimStart`, `trimEnd`, `slice`, `substring`, `includes`, `startsWith`, `endsWith`, `split`, `replace`, `replaceAll`, `repeat`, `padStart`, `padEnd`, `charAt`, `indexOf`, `lastIndexOf` + +:::note +All `customWidget_*` tools require admin-level API key permissions. The preview executor enforces rate limits (60 queries/min, 10 actions/min). +::: diff --git a/apps/docs/docs/widgets/custom-api/index.mdx b/apps/docs/docs/widgets/custom-api/index.mdx index 78d0bcbba..1f61f7aa4 100644 --- a/apps/docs/docs/widgets/custom-api/index.mdx +++ b/apps/docs/docs/widgets/custom-api/index.mdx @@ -1,29 +1,39 @@ --- -title: 'Custom API' -description: 'Displays data from a custom API endpoint using configurable display types and optional JSX templates.' +title: "Custom API" +description: "Displays data from an administrator-defined HTTP API using built-in renderers or safe Custom JSX." hide_title: true --- -import { WidgetHeader } from '@site/src/components/widgets/header'; -import { AddingWidget } from '@site/src/components/widgets/adding'; -import { customApiWidget } from '.'; +import { WidgetHeader } from "@site/src/components/widgets/header"; +import { AddingWidget } from "@site/src/components/widgets/adding"; +import { customApiWidget } from "."; + - +The Custom API widget displays an API definition created by an administrator in [Management → Custom Widgets](/docs/management/custom-widgets). A definition owns the endpoint, credentials, display configuration, and any named network capabilities used by Custom JSX. -This widget fetches data from a custom API endpoint defined in [Custom Widgets management](/docs/management/custom-widgets) and renders it using configurable display types. - -Custom API widgets are created and configured through the admin management page. Each widget definition specifies the API endpoint, authentication, display type, and refresh interval. - -See the [Custom Widgets documentation](/docs/management/custom-widgets) for full details on creating and configuring custom widgets. - -### Adding the widget +### Add the widget +Choose a custom-widget definition and a refresh interval. The board item stores only the selected definition and display options; credentials remain server-side. + :::note -Custom API widgets must first be created in **Management → Custom Widgets** before they appear in the widget picker. + +A definition must be enabled and available to the board before it appears in the widget picker. + ::: + +### Permissions and actions + +The base response and named query requests require permission to view the board. Named POST, PUT, and PATCH actions require permission to modify the board by default. DELETE requires full board permission and a confirmation. Anonymous viewers cannot execute actions. + +Interactive controls are disabled while the board is in edit mode. Actions run only after an explicit user gesture and are never triggered by mounting, refresh polling, or automatic retries. Authoring previews simulate actions unless an administrator explicitly enables live actions for the short-lived preview session. + +### Refresh behavior + +The refresh interval applies to the base GET response. A Custom JSX query can declare its own cache duration and can be refreshed manually. Named actions can invalidate the parent response or related named queries after they succeed. + +If the definition needs a non-GET base request, migrate it to a GET base response plus a named action. Existing non-GET Custom JSX definitions require review before network access is enabled. + +See [Custom Widgets management](/docs/management/custom-widgets) for the editor, display types, named-request manifest, network scopes, security limits, and migration guidance. diff --git a/apps/docs/src/components/custom-jsx-component-reference.tsx b/apps/docs/src/components/custom-jsx-component-reference.tsx new file mode 100644 index 000000000..af37a7105 --- /dev/null +++ b/apps/docs/src/components/custom-jsx-component-reference.tsx @@ -0,0 +1,66 @@ +import React from "react"; + +import customJsxComponentRegistry from "../generated/custom-jsx-components.json"; + +const enabledComponents = customJsxComponentRegistry.filter((component) => component.safety !== "denied"); +const deniedComponents = customJsxComponentRegistry.filter((component) => component.safety === "denied"); +const categories = [...new Set(enabledComponents.map((component) => component.category))]; + +export function CustomJsxComponentReference() { + return ( + <> +

Enabled and wrapped components

+ + + + + + + + + {categories.map((category) => ( + + + + + ))} + +
CategoryComponents
+ {category} + + {enabledComponents + .filter((component) => component.category === category) + .map((component) => ( + + + {component.name} + + {component.safety === "wrapped" && (wrapped)} + + ))} +
+ +

Denied components

+ + + + + + + + + {deniedComponents.map((component) => ( + + + + + ))} + +
ComponentReason
+ + {component.name} + + {component.reason}
+ + ); +} diff --git a/apps/docs/src/generated/custom-jsx-components.json b/apps/docs/src/generated/custom-jsx-components.json new file mode 100644 index 000000000..9103430ba --- /dev/null +++ b/apps/docs/src/generated/custom-jsx-components.json @@ -0,0 +1,2498 @@ +[ + { + "name": "Box", + "package": "@mantine/core", + "category": "layout", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/box/" + }, + { + "name": "Stack", + "package": "@mantine/core", + "category": "layout", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/stack/" + }, + { + "name": "Group", + "package": "@mantine/core", + "category": "layout", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/group/" + }, + { + "name": "Flex", + "package": "@mantine/core", + "category": "layout", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/flex/" + }, + { + "name": "Grid", + "package": "@mantine/core", + "category": "layout", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/grid/" + }, + { + "name": "Grid.Col", + "package": "@mantine/core", + "category": "layout", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/grid/" + }, + { + "name": "SimpleGrid", + "package": "@mantine/core", + "category": "layout", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/simple-grid/" + }, + { + "name": "Center", + "package": "@mantine/core", + "category": "layout", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/center/" + }, + { + "name": "Space", + "package": "@mantine/core", + "category": "layout", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/space/" + }, + { + "name": "Container", + "package": "@mantine/core", + "category": "layout", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/container/" + }, + { + "name": "AspectRatio", + "package": "@mantine/core", + "category": "layout", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/aspect-ratio/" + }, + { + "name": "ScrollArea", + "package": "@mantine/core", + "category": "layout", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/scroll-area/" + }, + { + "name": "Paper", + "package": "@mantine/core", + "category": "layout", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/paper/" + }, + { + "name": "Card", + "package": "@mantine/core", + "category": "layout", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/card/" + }, + { + "name": "Card.Section", + "package": "@mantine/core", + "category": "layout", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/card/" + }, + { + "name": "Divider", + "package": "@mantine/core", + "category": "layout", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/divider/" + }, + { + "name": "Fieldset", + "package": "@mantine/core", + "category": "layout", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/fieldset/" + }, + { + "name": "VisuallyHidden", + "package": "@mantine/core", + "category": "layout", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/visually-hidden/" + }, + { + "name": "Typography", + "package": "@mantine/core", + "category": "layout", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/typography/" + }, + { + "name": "FloatingIndicator", + "package": "@mantine/core", + "category": "layout", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/floating-indicator/" + }, + { + "name": "Text", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/text/" + }, + { + "name": "Title", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/title/" + }, + { + "name": "Code", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/code/" + }, + { + "name": "Highlight", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/highlight/" + }, + { + "name": "Mark", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/mark/" + }, + { + "name": "Kbd", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/kbd/" + }, + { + "name": "Blockquote", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/blockquote/" + }, + { + "name": "NumberFormatter", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/number-formatter/" + }, + { + "name": "Badge", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/badge/" + }, + { + "name": "ThemeIcon", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/theme-icon/" + }, + { + "name": "ColorSwatch", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/color-swatch/" + }, + { + "name": "Table", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/table/" + }, + { + "name": "Table.Thead", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/table/" + }, + { + "name": "Table.Tbody", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/table/" + }, + { + "name": "Table.Tfoot", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/table/" + }, + { + "name": "Table.Caption", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/table/" + }, + { + "name": "Table.Tr", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/table/" + }, + { + "name": "Table.Th", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/table/" + }, + { + "name": "Table.Td", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/table/" + }, + { + "name": "List", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/list/" + }, + { + "name": "List.Item", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/list/" + }, + { + "name": "Timeline", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/timeline/" + }, + { + "name": "Timeline.Item", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/timeline/" + }, + { + "name": "Indicator", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/indicator/" + }, + { + "name": "Pill", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/pill/" + }, + { + "name": "Image", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/image/" + }, + { + "name": "Avatar", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/avatar/" + }, + { + "name": "Avatar.Group", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/avatar/" + }, + { + "name": "BackgroundImage", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/background-image/" + }, + { + "name": "DataList", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/data-list/" + }, + { + "name": "DataList.Item", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/data-list/" + }, + { + "name": "DataList.ItemLabel", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/data-list/" + }, + { + "name": "DataList.ItemValue", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/data-list/" + }, + { + "name": "EmptyState", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/empty-state/" + }, + { + "name": "EmptyState.Indicator", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/empty-state/" + }, + { + "name": "EmptyState.Title", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/empty-state/" + }, + { + "name": "EmptyState.Description", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/empty-state/" + }, + { + "name": "EmptyState.Actions", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/empty-state/" + }, + { + "name": "Marquee", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/marquee/" + }, + { + "name": "RollingNumber", + "package": "@mantine/core", + "category": "content", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/rolling-number/" + }, + { + "name": "Alert", + "package": "@mantine/core", + "category": "feedback", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/alert/" + }, + { + "name": "Progress", + "package": "@mantine/core", + "category": "feedback", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/progress/" + }, + { + "name": "Progress.Section", + "package": "@mantine/core", + "category": "feedback", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/progress/" + }, + { + "name": "RingProgress", + "package": "@mantine/core", + "category": "feedback", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/ring-progress/" + }, + { + "name": "SemiCircleProgress", + "package": "@mantine/core", + "category": "feedback", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/semi-circle-progress/" + }, + { + "name": "Skeleton", + "package": "@mantine/core", + "category": "feedback", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/skeleton/" + }, + { + "name": "Loader", + "package": "@mantine/core", + "category": "feedback", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/loader/" + }, + { + "name": "Notification", + "package": "@mantine/core", + "category": "feedback", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/core/notification/" + }, + { + "name": "LoadingOverlay", + "package": "@mantine/core", + "category": "feedback", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/core/loading-overlay/" + }, + { + "name": "Overlay", + "package": "@mantine/core", + "category": "feedback", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/core/overlay/" + }, + { + "name": "Accordion", + "package": "@mantine/core", + "category": "navigation", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/accordion/" + }, + { + "name": "Accordion.Item", + "package": "@mantine/core", + "category": "navigation", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/accordion/" + }, + { + "name": "Accordion.Control", + "package": "@mantine/core", + "category": "navigation", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/accordion/" + }, + { + "name": "Accordion.Panel", + "package": "@mantine/core", + "category": "navigation", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/accordion/" + }, + { + "name": "Tabs", + "package": "@mantine/core", + "category": "navigation", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/tabs/" + }, + { + "name": "Tabs.List", + "package": "@mantine/core", + "category": "navigation", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/tabs/" + }, + { + "name": "Tabs.Tab", + "package": "@mantine/core", + "category": "navigation", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/tabs/" + }, + { + "name": "Tabs.Panel", + "package": "@mantine/core", + "category": "navigation", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/tabs/" + }, + { + "name": "Stepper.Step", + "package": "@mantine/core", + "category": "navigation", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/stepper/" + }, + { + "name": "HoverCard", + "package": "@mantine/core", + "category": "navigation", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/hover-card/" + }, + { + "name": "HoverCard.Target", + "package": "@mantine/core", + "category": "navigation", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/hover-card/" + }, + { + "name": "HoverCard.Dropdown", + "package": "@mantine/core", + "category": "navigation", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/hover-card/" + }, + { + "name": "Menu", + "package": "@mantine/core", + "category": "navigation", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/menu/" + }, + { + "name": "Menu.Target", + "package": "@mantine/core", + "category": "navigation", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/menu/" + }, + { + "name": "Menu.Dropdown", + "package": "@mantine/core", + "category": "navigation", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/menu/" + }, + { + "name": "Menu.Item", + "package": "@mantine/core", + "category": "navigation", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/menu/" + }, + { + "name": "Menu.Label", + "package": "@mantine/core", + "category": "navigation", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/menu/" + }, + { + "name": "Menu.Divider", + "package": "@mantine/core", + "category": "navigation", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/menu/" + }, + { + "name": "Tooltip", + "package": "@mantine/core", + "category": "navigation", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/tooltip/" + }, + { + "name": "Spoiler", + "package": "@mantine/core", + "category": "navigation", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/spoiler/" + }, + { + "name": "Collapse", + "package": "@mantine/core", + "category": "navigation", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/collapse/" + }, + { + "name": "Transition", + "package": "@mantine/core", + "category": "navigation", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/core/transition/" + }, + { + "name": "Anchor", + "package": "@mantine/core", + "category": "navigation", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/core/anchor/" + }, + { + "name": "NavLink", + "package": "@mantine/core", + "category": "navigation", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/core/nav-link/" + }, + { + "name": "Breadcrumbs", + "package": "@mantine/core", + "category": "navigation", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/core/breadcrumbs/" + }, + { + "name": "Stepper", + "package": "@mantine/core", + "category": "navigation", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/core/stepper/" + }, + { + "name": "Tree", + "package": "@mantine/core", + "category": "navigation", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/core/tree/" + }, + { + "name": "Button", + "package": "@mantine/core", + "category": "interaction", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/core/button/" + }, + { + "name": "ActionIcon", + "package": "@mantine/core", + "category": "interaction", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/core/action-icon/" + }, + { + "name": "Burger", + "package": "@mantine/core", + "category": "interaction", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/core/burger/" + }, + { + "name": "CloseButton", + "package": "@mantine/core", + "category": "interaction", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/core/close-button/" + }, + { + "name": "Chip", + "package": "@mantine/core", + "category": "interaction", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/core/chip/" + }, + { + "name": "Chip.Group", + "package": "@mantine/core", + "category": "interaction", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/core/chip/" + }, + { + "name": "CopyButton", + "package": "@mantine/core", + "category": "interaction", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/core/copy-button/" + }, + { + "name": "Pagination", + "package": "@mantine/core", + "category": "interaction", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/core/pagination/" + }, + { + "name": "Rating", + "package": "@mantine/core", + "category": "interaction", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/core/rating/" + }, + { + "name": "SegmentedControl", + "package": "@mantine/core", + "category": "interaction", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/core/segmented-control/" + }, + { + "name": "Slider", + "package": "@mantine/core", + "category": "interaction", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/core/slider/" + }, + { + "name": "Switch", + "package": "@mantine/core", + "category": "interaction", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/core/switch/" + }, + { + "name": "AreaChart", + "package": "@mantine/charts", + "category": "charts", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/charts/area-chart/" + }, + { + "name": "BarChart", + "package": "@mantine/charts", + "category": "charts", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/charts/bar-chart/" + }, + { + "name": "BarsList", + "package": "@mantine/charts", + "category": "charts", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/charts/bars-list/" + }, + { + "name": "BubbleChart", + "package": "@mantine/charts", + "category": "charts", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/charts/bubble-chart/" + }, + { + "name": "ChartLegend", + "package": "@mantine/charts", + "category": "charts", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/charts/chart-legend/" + }, + { + "name": "ChartTooltip", + "package": "@mantine/charts", + "category": "charts", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/charts/chart-tooltip/" + }, + { + "name": "CompositeChart", + "package": "@mantine/charts", + "category": "charts", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/charts/composite-chart/" + }, + { + "name": "DonutChart", + "package": "@mantine/charts", + "category": "charts", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/charts/donut-chart/" + }, + { + "name": "FunnelChart", + "package": "@mantine/charts", + "category": "charts", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/charts/funnel-chart/" + }, + { + "name": "Heatmap", + "package": "@mantine/charts", + "category": "charts", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/charts/heatmap/" + }, + { + "name": "LineChart", + "package": "@mantine/charts", + "category": "charts", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/charts/line-chart/" + }, + { + "name": "PieChart", + "package": "@mantine/charts", + "category": "charts", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/charts/pie-chart/" + }, + { + "name": "RadarChart", + "package": "@mantine/charts", + "category": "charts", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/charts/radar-chart/" + }, + { + "name": "RadialBarChart", + "package": "@mantine/charts", + "category": "charts", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/charts/radial-bar-chart/" + }, + { + "name": "SankeyChart", + "package": "@mantine/charts", + "category": "charts", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/charts/sankey-chart/" + }, + { + "name": "ScatterChart", + "package": "@mantine/charts", + "category": "charts", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/charts/scatter-chart/" + }, + { + "name": "Sparkline", + "package": "@mantine/charts", + "category": "charts", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/charts/sparkline/" + }, + { + "name": "Treemap", + "package": "@mantine/charts", + "category": "charts", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/charts/treemap/" + }, + { + "name": "Calendar", + "package": "@mantine/dates", + "category": "dates", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/dates/calendar/" + }, + { + "name": "MiniCalendar", + "package": "@mantine/dates", + "category": "dates", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/dates/mini-calendar/" + }, + { + "name": "DatePicker", + "package": "@mantine/dates", + "category": "dates", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/dates/date-picker/" + }, + { + "name": "Day", + "package": "@mantine/dates", + "category": "dates", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/dates/day/" + }, + { + "name": "WeekdaysRow", + "package": "@mantine/dates", + "category": "dates", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/dates/weekdays-row/" + }, + { + "name": "Month", + "package": "@mantine/dates", + "category": "dates", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/dates/month/" + }, + { + "name": "CalendarHeader", + "package": "@mantine/dates", + "category": "dates", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/dates/calendar-header/" + }, + { + "name": "YearPicker", + "package": "@mantine/dates", + "category": "dates", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/dates/year-picker/" + }, + { + "name": "MonthPicker", + "package": "@mantine/dates", + "category": "dates", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/dates/month-picker/" + }, + { + "name": "TimeGrid", + "package": "@mantine/dates", + "category": "dates", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/dates/time-grid/" + }, + { + "name": "PickerControl", + "package": "@mantine/dates", + "category": "dates", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/dates/picker-control/" + }, + { + "name": "YearsList", + "package": "@mantine/dates", + "category": "dates", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/dates/years-list/" + }, + { + "name": "MonthsList", + "package": "@mantine/dates", + "category": "dates", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/dates/months-list/" + }, + { + "name": "DecadeLevel", + "package": "@mantine/dates", + "category": "dates", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/dates/decade-level/" + }, + { + "name": "YearLevel", + "package": "@mantine/dates", + "category": "dates", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/dates/year-level/" + }, + { + "name": "MonthLevel", + "package": "@mantine/dates", + "category": "dates", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/dates/month-level/" + }, + { + "name": "LevelsGroup", + "package": "@mantine/dates", + "category": "dates", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/dates/levels-group/" + }, + { + "name": "DecadeLevelGroup", + "package": "@mantine/dates", + "category": "dates", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/dates/decade-level-group/" + }, + { + "name": "YearLevelGroup", + "package": "@mantine/dates", + "category": "dates", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/dates/year-level-group/" + }, + { + "name": "MonthLevelGroup", + "package": "@mantine/dates", + "category": "dates", + "safety": "wrapped", + "documentationUrl": "https://mantine.dev/dates/month-level-group/" + }, + { + "name": "TimeValue", + "package": "@mantine/dates", + "category": "dates", + "safety": "allowed", + "documentationUrl": "https://mantine.dev/dates/time-value/" + }, + { + "name": "PaginatedList", + "package": "@homarr/widgets", + "category": "interaction", + "safety": "allowed", + "documentationUrl": "https://homarr.dev/docs/management/custom-widgets/" + }, + { + "name": "TabsContainer", + "package": "@homarr/widgets", + "category": "interaction", + "safety": "allowed", + "documentationUrl": "https://homarr.dev/docs/management/custom-widgets/" + }, + { + "name": "TabPanel", + "package": "@homarr/widgets", + "category": "interaction", + "safety": "allowed", + "documentationUrl": "https://homarr.dev/docs/management/custom-widgets/" + }, + { + "name": "Collapsible", + "package": "@homarr/widgets", + "category": "interaction", + "safety": "allowed", + "documentationUrl": "https://homarr.dev/docs/management/custom-widgets/" + }, + { + "name": "StatBar", + "package": "@homarr/widgets", + "category": "interaction", + "safety": "allowed", + "documentationUrl": "https://homarr.dev/docs/management/custom-widgets/" + }, + { + "name": "TypeBadge", + "package": "@homarr/widgets", + "category": "interaction", + "safety": "allowed", + "documentationUrl": "https://homarr.dev/docs/management/custom-widgets/" + }, + { + "name": "SubFetch", + "package": "@homarr/widgets", + "category": "network", + "safety": "wrapped", + "documentationUrl": "https://homarr.dev/docs/management/custom-widgets/" + }, + { + "name": "SubData", + "package": "@homarr/widgets", + "category": "network", + "safety": "wrapped", + "documentationUrl": "https://homarr.dev/docs/management/custom-widgets/" + }, + { + "name": "ActionButton", + "package": "@homarr/widgets", + "category": "network", + "safety": "wrapped", + "documentationUrl": "https://homarr.dev/docs/management/custom-widgets/" + }, + { + "name": "ToggleSwitch", + "package": "@homarr/widgets", + "category": "network", + "safety": "wrapped", + "documentationUrl": "https://homarr.dev/docs/management/custom-widgets/" + }, + { + "name": "RefreshButton", + "package": "@homarr/widgets", + "category": "network", + "safety": "wrapped", + "documentationUrl": "https://homarr.dev/docs/management/custom-widgets/" + }, + { + "name": "TablerIcon", + "package": "@homarr/widgets", + "category": "content", + "safety": "wrapped", + "documentationUrl": "https://homarr.dev/docs/management/custom-widgets/" + }, + { + "name": "AppShell", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Escapes the widget layout or focus boundary", + "documentationUrl": "https://mantine.dev/core/app-shell/" + }, + { + "name": "Affix", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Escapes the widget layout or focus boundary", + "documentationUrl": "https://mantine.dev/core/affix/" + }, + { + "name": "ComboboxPopover", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Escapes the widget layout or focus boundary", + "documentationUrl": "https://mantine.dev/core/combobox-popover/" + }, + { + "name": "Dialog", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Escapes the widget layout or focus boundary", + "documentationUrl": "https://mantine.dev/core/dialog/" + }, + { + "name": "Drawer", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Escapes the widget layout or focus boundary", + "documentationUrl": "https://mantine.dev/core/drawer/" + }, + { + "name": "FloatingWindow", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Escapes the widget layout or focus boundary", + "documentationUrl": "https://mantine.dev/core/floating-window/" + }, + { + "name": "FocusTrap", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Escapes the widget layout or focus boundary", + "documentationUrl": "https://mantine.dev/core/focus-trap/" + }, + { + "name": "Menubar", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Escapes the widget layout or focus boundary", + "documentationUrl": "https://mantine.dev/core/menubar/" + }, + { + "name": "Modal", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Escapes the widget layout or focus boundary", + "documentationUrl": "https://mantine.dev/core/modal/" + }, + { + "name": "ModalBase", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Escapes the widget layout or focus boundary", + "documentationUrl": "https://mantine.dev/core/modal-base/" + }, + { + "name": "Portal", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Escapes the widget layout or focus boundary", + "documentationUrl": "https://mantine.dev/core/portal/" + }, + { + "name": "Popover", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Escapes the widget layout or focus boundary", + "documentationUrl": "https://mantine.dev/core/popover/" + }, + { + "name": "RemoveScroll", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Escapes the widget layout or focus boundary", + "documentationUrl": "https://mantine.dev/core/remove-scroll/" + }, + { + "name": "AngleSlider", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Arbitrary form controls are not connected to the declarative action model", + "documentationUrl": "https://mantine.dev/core/angle-slider/" + }, + { + "name": "Autocomplete", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Arbitrary form controls are not connected to the declarative action model", + "documentationUrl": "https://mantine.dev/core/autocomplete/" + }, + { + "name": "Checkbox", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Arbitrary form controls are not connected to the declarative action model", + "documentationUrl": "https://mantine.dev/core/checkbox/" + }, + { + "name": "ColorInput", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Arbitrary form controls are not connected to the declarative action model", + "documentationUrl": "https://mantine.dev/core/color-input/" + }, + { + "name": "ColorPicker", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Arbitrary form controls are not connected to the declarative action model", + "documentationUrl": "https://mantine.dev/core/color-picker/" + }, + { + "name": "Combobox", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Arbitrary form controls are not connected to the declarative action model", + "documentationUrl": "https://mantine.dev/core/combobox/" + }, + { + "name": "FileButton", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Arbitrary form controls are not connected to the declarative action model", + "documentationUrl": "https://mantine.dev/core/file-button/" + }, + { + "name": "FileInput", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Arbitrary form controls are not connected to the declarative action model", + "documentationUrl": "https://mantine.dev/core/file-input/" + }, + { + "name": "Input", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Arbitrary form controls are not connected to the declarative action model", + "documentationUrl": "https://mantine.dev/core/input/" + }, + { + "name": "InputBase", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Arbitrary form controls are not connected to the declarative action model", + "documentationUrl": "https://mantine.dev/core/input-base/" + }, + { + "name": "JsonInput", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Arbitrary form controls are not connected to the declarative action model", + "documentationUrl": "https://mantine.dev/core/json-input/" + }, + { + "name": "MaskInput", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Arbitrary form controls are not connected to the declarative action model", + "documentationUrl": "https://mantine.dev/core/mask-input/" + }, + { + "name": "MultiSelect", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Arbitrary form controls are not connected to the declarative action model", + "documentationUrl": "https://mantine.dev/core/multi-select/" + }, + { + "name": "NativeSelect", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Arbitrary form controls are not connected to the declarative action model", + "documentationUrl": "https://mantine.dev/core/native-select/" + }, + { + "name": "NumberInput", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Arbitrary form controls are not connected to the declarative action model", + "documentationUrl": "https://mantine.dev/core/number-input/" + }, + { + "name": "PasswordInput", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Arbitrary form controls are not connected to the declarative action model", + "documentationUrl": "https://mantine.dev/core/password-input/" + }, + { + "name": "PillsInput", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Arbitrary form controls are not connected to the declarative action model", + "documentationUrl": "https://mantine.dev/core/pills-input/" + }, + { + "name": "PinInput", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Arbitrary form controls are not connected to the declarative action model", + "documentationUrl": "https://mantine.dev/core/pin-input/" + }, + { + "name": "Radio", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Arbitrary form controls are not connected to the declarative action model", + "documentationUrl": "https://mantine.dev/core/radio/" + }, + { + "name": "Select", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Arbitrary form controls are not connected to the declarative action model", + "documentationUrl": "https://mantine.dev/core/select/" + }, + { + "name": "TagsInput", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Arbitrary form controls are not connected to the declarative action model", + "documentationUrl": "https://mantine.dev/core/tags-input/" + }, + { + "name": "Textarea", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Arbitrary form controls are not connected to the declarative action model", + "documentationUrl": "https://mantine.dev/core/textarea/" + }, + { + "name": "TextInput", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Arbitrary form controls are not connected to the declarative action model", + "documentationUrl": "https://mantine.dev/core/text-input/" + }, + { + "name": "TreeSelect", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Arbitrary form controls are not connected to the declarative action model", + "documentationUrl": "https://mantine.dev/core/tree-select/" + }, + { + "name": "UnstyledButton", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Arbitrary form controls are not connected to the declarative action model", + "documentationUrl": "https://mantine.dev/core/unstyled-button/" + }, + { + "name": "OverflowList", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Requires callback, document, or layout capabilities that are not exposed to templates", + "documentationUrl": "https://mantine.dev/core/overflow-list/" + }, + { + "name": "Scroller", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Requires callback, document, or layout capabilities that are not exposed to templates", + "documentationUrl": "https://mantine.dev/core/scroller/" + }, + { + "name": "Splitter", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Requires callback, document, or layout capabilities that are not exposed to templates", + "documentationUrl": "https://mantine.dev/core/splitter/" + }, + { + "name": "TableOfContents", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Requires callback, document, or layout capabilities that are not exposed to templates", + "documentationUrl": "https://mantine.dev/core/table-of-contents/" + }, + { + "name": "AccordionChevron", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/accordion-chevron/" + }, + { + "name": "ActionIconGroup", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/action-icon-group/" + }, + { + "name": "ActionIconGroupSection", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/action-icon-group-section/" + }, + { + "name": "AlphaSlider", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/alpha-slider/" + }, + { + "name": "AppShellAside", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/app-shell-aside/" + }, + { + "name": "AppShellFooter", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/app-shell-footer/" + }, + { + "name": "AppShellHeader", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/app-shell-header/" + }, + { + "name": "AppShellMain", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/app-shell-main/" + }, + { + "name": "AppShellNavbar", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/app-shell-navbar/" + }, + { + "name": "AppShellSection", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/app-shell-section/" + }, + { + "name": "ButtonGroup", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/button-group/" + }, + { + "name": "ButtonGroupSection", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/button-group-section/" + }, + { + "name": "CheckIcon", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/check-icon/" + }, + { + "name": "CheckboxCard", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/checkbox-card/" + }, + { + "name": "CheckboxGroup", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/checkbox-group/" + }, + { + "name": "CheckboxIndicator", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/checkbox-indicator/" + }, + { + "name": "CloseIcon", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/close-icon/" + }, + { + "name": "ColorSchemeScript", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/color-scheme-script/" + }, + { + "name": "ComboboxChevron", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/combobox-chevron/" + }, + { + "name": "ComboboxClearButton", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/combobox-clear-button/" + }, + { + "name": "ComboboxDropdown", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/combobox-dropdown/" + }, + { + "name": "ComboboxDropdownTarget", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/combobox-dropdown-target/" + }, + { + "name": "ComboboxEmpty", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/combobox-empty/" + }, + { + "name": "ComboboxEventsTarget", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/combobox-events-target/" + }, + { + "name": "ComboboxFooter", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/combobox-footer/" + }, + { + "name": "ComboboxGroup", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/combobox-group/" + }, + { + "name": "ComboboxHeader", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/combobox-header/" + }, + { + "name": "ComboboxHiddenInput", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/combobox-hidden-input/" + }, + { + "name": "ComboboxOption", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/combobox-option/" + }, + { + "name": "ComboboxOptions", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/combobox-options/" + }, + { + "name": "ComboboxPopoverTarget", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/combobox-popover-target/" + }, + { + "name": "ComboboxSearch", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/combobox-search/" + }, + { + "name": "ComboboxTarget", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/combobox-target/" + }, + { + "name": "DirectionProvider", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/direction-provider/" + }, + { + "name": "DrawerBody", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/drawer-body/" + }, + { + "name": "DrawerCloseButton", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/drawer-close-button/" + }, + { + "name": "DrawerContent", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/drawer-content/" + }, + { + "name": "DrawerHeader", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/drawer-header/" + }, + { + "name": "DrawerOverlay", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/drawer-overlay/" + }, + { + "name": "DrawerRoot", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/drawer-root/" + }, + { + "name": "DrawerStack", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/drawer-stack/" + }, + { + "name": "DrawerTitle", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/drawer-title/" + }, + { + "name": "FlatTreeNode", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/flat-tree-node/" + }, + { + "name": "FloatingArrow", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/floating-arrow/" + }, + { + "name": "FocusTrapInitialFocus", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/focus-trap-initial-focus/" + }, + { + "name": "HeadlessMantineProvider", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/headless-mantine-provider/" + }, + { + "name": "HoverCardGroup", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/hover-card-group/" + }, + { + "name": "HueSlider", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/hue-slider/" + }, + { + "name": "InlineStyles", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/inline-styles/" + }, + { + "name": "InputClearButton", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/input-clear-button/" + }, + { + "name": "InputClearSection", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/input-clear-section/" + }, + { + "name": "InputDescription", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/input-description/" + }, + { + "name": "InputError", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/input-error/" + }, + { + "name": "InputLabel", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/input-label/" + }, + { + "name": "InputPlaceholder", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/input-placeholder/" + }, + { + "name": "InputSuccess", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/input-success/" + }, + { + "name": "InputWrapper", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/input-wrapper/" + }, + { + "name": "MantineProvider", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/mantine-provider/" + }, + { + "name": "MantineThemeProvider", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/mantine-theme-provider/" + }, + { + "name": "MenuCheckboxGroup", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/menu-checkbox-group/" + }, + { + "name": "MenuCheckboxItem", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/menu-checkbox-item/" + }, + { + "name": "MenuContextMenu", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/menu-context-menu/" + }, + { + "name": "MenuRadioGroup", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/menu-radio-group/" + }, + { + "name": "MenuRadioItem", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/menu-radio-item/" + }, + { + "name": "MenuSearch", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/menu-search/" + }, + { + "name": "MenuSub", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/menu-sub/" + }, + { + "name": "MenuSubDropdown", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/menu-sub-dropdown/" + }, + { + "name": "MenuSubItem", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/menu-sub-item/" + }, + { + "name": "MenuSubTarget", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/menu-sub-target/" + }, + { + "name": "MenubarDropdown", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/menubar-dropdown/" + }, + { + "name": "MenubarMenu", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/menubar-menu/" + }, + { + "name": "MenubarTarget", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/menubar-target/" + }, + { + "name": "ModalBaseBody", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/modal-base-body/" + }, + { + "name": "ModalBaseCloseButton", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/modal-base-close-button/" + }, + { + "name": "ModalBaseContent", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/modal-base-content/" + }, + { + "name": "ModalBaseHeader", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/modal-base-header/" + }, + { + "name": "ModalBaseOverlay", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/modal-base-overlay/" + }, + { + "name": "ModalBaseTitle", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/modal-base-title/" + }, + { + "name": "ModalBody", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/modal-body/" + }, + { + "name": "ModalCloseButton", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/modal-close-button/" + }, + { + "name": "ModalContent", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/modal-content/" + }, + { + "name": "ModalHeader", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/modal-header/" + }, + { + "name": "ModalOverlay", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/modal-overlay/" + }, + { + "name": "ModalRoot", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/modal-root/" + }, + { + "name": "ModalStack", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/modal-stack/" + }, + { + "name": "ModalTitle", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/modal-title/" + }, + { + "name": "NativeScrollArea", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/native-scroll-area/" + }, + { + "name": "OptionalPortal", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/optional-portal/" + }, + { + "name": "OptionsDropdown", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/options-dropdown/" + }, + { + "name": "PaginationControl", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/pagination-control/" + }, + { + "name": "PaginationDots", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/pagination-dots/" + }, + { + "name": "PaginationFirst", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/pagination-first/" + }, + { + "name": "PaginationItems", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/pagination-items/" + }, + { + "name": "PaginationLabel", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/pagination-label/" + }, + { + "name": "PaginationLast", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/pagination-last/" + }, + { + "name": "PaginationNext", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/pagination-next/" + }, + { + "name": "PaginationPrevious", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/pagination-previous/" + }, + { + "name": "PaginationRoot", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/pagination-root/" + }, + { + "name": "PillGroup", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/pill-group/" + }, + { + "name": "PillsInputField", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/pills-input-field/" + }, + { + "name": "PopoverContextMenu", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/popover-context-menu/" + }, + { + "name": "PopoverDropdown", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/popover-dropdown/" + }, + { + "name": "PopoverTarget", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/popover-target/" + }, + { + "name": "ProgressLabel", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/progress-label/" + }, + { + "name": "ProgressRoot", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/progress-root/" + }, + { + "name": "RadioCard", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/radio-card/" + }, + { + "name": "RadioGroup", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/radio-group/" + }, + { + "name": "RadioIcon", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/radio-icon/" + }, + { + "name": "RadioIndicator", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/radio-indicator/" + }, + { + "name": "RangeSlider", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/range-slider/" + }, + { + "name": "ScrollAreaAutosize", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/scroll-area-autosize/" + }, + { + "name": "SplitterPane", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/splitter-pane/" + }, + { + "name": "StepperCompleted", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/stepper-completed/" + }, + { + "name": "SwitchGroup", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/switch-group/" + }, + { + "name": "TableScrollContainer", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/table-scroll-container/" + }, + { + "name": "TooltipFloating", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/tooltip-floating/" + }, + { + "name": "TooltipGroup", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/tooltip-group/" + }, + { + "name": "TreeSelectOption", + "package": "@mantine/core", + "category": "blocked", + "safety": "denied", + "reason": "Internal, provider, compound-control, form, portal, or document-level export outside the safe declarative surface", + "documentationUrl": "https://mantine.dev/core/tree-select-option/" + }, + { + "name": "AreaGradient", + "package": "@mantine/charts", + "category": "blocked", + "safety": "denied", + "reason": "Low-level chart implementation helper that is not a standalone declarative display component", + "documentationUrl": "https://mantine.dev/charts/area-gradient/" + }, + { + "name": "DatesProvider", + "package": "@mantine/dates", + "category": "blocked", + "safety": "denied", + "reason": "Input and provider components are outside the read-only template surface", + "documentationUrl": "https://mantine.dev/dates/dates-provider/" + }, + { + "name": "HiddenDatesInput", + "package": "@mantine/dates", + "category": "blocked", + "safety": "denied", + "reason": "Input and provider components are outside the read-only template surface", + "documentationUrl": "https://mantine.dev/dates/hidden-dates-input/" + }, + { + "name": "TimeInput", + "package": "@mantine/dates", + "category": "blocked", + "safety": "denied", + "reason": "Input and provider components are outside the read-only template surface", + "documentationUrl": "https://mantine.dev/dates/time-input/" + }, + { + "name": "TimePicker", + "package": "@mantine/dates", + "category": "blocked", + "safety": "denied", + "reason": "Input and provider components are outside the read-only template surface", + "documentationUrl": "https://mantine.dev/dates/time-picker/" + }, + { + "name": "PickerInputBase", + "package": "@mantine/dates", + "category": "blocked", + "safety": "denied", + "reason": "Input and provider components are outside the read-only template surface", + "documentationUrl": "https://mantine.dev/dates/picker-input-base/" + }, + { + "name": "DateInput", + "package": "@mantine/dates", + "category": "blocked", + "safety": "denied", + "reason": "Input and provider components are outside the read-only template surface", + "documentationUrl": "https://mantine.dev/dates/date-input/" + }, + { + "name": "DateTimePicker", + "package": "@mantine/dates", + "category": "blocked", + "safety": "denied", + "reason": "Input and provider components are outside the read-only template surface", + "documentationUrl": "https://mantine.dev/dates/date-time-picker/" + }, + { + "name": "InlineDateTimePicker", + "package": "@mantine/dates", + "category": "blocked", + "safety": "denied", + "reason": "Input and provider components are outside the read-only template surface", + "documentationUrl": "https://mantine.dev/dates/inline-date-time-picker/" + }, + { + "name": "YearPickerInput", + "package": "@mantine/dates", + "category": "blocked", + "safety": "denied", + "reason": "Input and provider components are outside the read-only template surface", + "documentationUrl": "https://mantine.dev/dates/year-picker-input/" + }, + { + "name": "MonthPickerInput", + "package": "@mantine/dates", + "category": "blocked", + "safety": "denied", + "reason": "Input and provider components are outside the read-only template surface", + "documentationUrl": "https://mantine.dev/dates/month-picker-input/" + }, + { + "name": "DatePickerInput", + "package": "@mantine/dates", + "category": "blocked", + "safety": "denied", + "reason": "Input and provider components are outside the read-only template surface", + "documentationUrl": "https://mantine.dev/dates/date-picker-input/" + } +] diff --git a/apps/nextjs/package.json b/apps/nextjs/package.json index 4a3e0dd3e..327306bc4 100644 --- a/apps/nextjs/package.json +++ b/apps/nextjs/package.json @@ -14,6 +14,12 @@ "with-env": "dotenv -e ../../.env --" }, "dependencies": { + "@codemirror/autocomplete": "catalog:", + "@codemirror/commands": "catalog:", + "@codemirror/lang-javascript": "catalog:", + "@codemirror/lang-json": "catalog:", + "@codemirror/lint": "catalog:", + "@codemirror/view": "catalog:", "@dnd-kit/core": "catalog:", "@dnd-kit/modifiers": "catalog:", "@dnd-kit/sortable": "catalog:", @@ -26,6 +32,7 @@ "@homarr/common": "workspace:^0.1.0", "@homarr/core": "workspace:^0.1.0", "@homarr/cron-job-status": "workspace:^0.1.0", + "@homarr/custom-widgets": "workspace:^0.1.0", "@homarr/db": "workspace:^0.1.0", "@homarr/definitions": "workspace:^0.1.0", "@homarr/docker": "workspace:^0.1.0", @@ -68,6 +75,7 @@ "@trpc/next": "catalog:", "@trpc/react-query": "catalog:", "@trpc/server": "catalog:", + "@uiw/react-codemirror": "catalog:", "@xterm/addon-canvas": "catalog:", "@xterm/addon-fit": "catalog:", "@xterm/xterm": "catalog:", diff --git a/apps/nextjs/src/app/[locale]/manage/custom-widgets/_beta-banner.tsx b/apps/nextjs/src/app/[locale]/manage/custom-widgets/_beta-banner.tsx index 6ac28cd7c..6a9ab18cc 100644 --- a/apps/nextjs/src/app/[locale]/manage/custom-widgets/_beta-banner.tsx +++ b/apps/nextjs/src/app/[locale]/manage/custom-widgets/_beta-banner.tsx @@ -1,18 +1,21 @@ +"use client"; + import { Alert, Anchor, Text } from "@mantine/core"; import { IconFlask } from "@tabler/icons-react"; +import { useScopedI18n } from "@homarr/translation/client"; const FEEDBACK_URL = "https://github.com/homarr-labs/homarr/discussions/categories/custom-widgets"; export function CustomWidgetBetaBanner() { + const t = useScopedI18n("customWidget.betaBanner"); return ( - }> + }> - This feature is experimental and will probably change a lot in the future. If you encounter bugs, wish it did - more, or find something confusing, then please complain to us as much as possible! Only feedback posted on the{" "} + {t("description")}{" "} - official discussion thread + {t("link")} {" "} - will be taken into account. Happy Hacking! + {t("closing")} ); diff --git a/apps/nextjs/src/app/[locale]/manage/custom-widgets/_code-editor-diagnostics.tsx b/apps/nextjs/src/app/[locale]/manage/custom-widgets/_code-editor-diagnostics.tsx new file mode 100644 index 000000000..0da12af38 --- /dev/null +++ b/apps/nextjs/src/app/[locale]/manage/custom-widgets/_code-editor-diagnostics.tsx @@ -0,0 +1,51 @@ +import type { EditorView } from "@codemirror/view"; +import { Alert, Stack, Text, UnstyledButton } from "@mantine/core"; +import { IconAlertTriangle } from "@tabler/icons-react"; + +import type { EditorDiagnostic } from "@homarr/custom-widgets/workbench"; + +import classes from "./_code-editor.module.css"; + +interface CodeEditorDiagnosticsProps { + diagnostics: EditorDiagnostic[]; + editorView: EditorView | null; + title: string; + formatDiagnostic: (diagnostic: EditorDiagnostic) => string; +} + +export function CodeEditorDiagnostics({ + diagnostics, + editorView, + title, + formatDiagnostic, +}: CodeEditorDiagnosticsProps) { + if (diagnostics.length === 0) return null; + return ( + + {diagnostics.map((diagnostic, index) => ( +
  • + { + if (!editorView || diagnostic.index === undefined) return; + const anchor = Math.min(diagnostic.index, editorView.state.doc.length); + editorView.dispatch({ selection: { anchor }, scrollIntoView: true }); + editorView.focus(); + }} + > + } + > + {formatDiagnostic(diagnostic)} + + +
  • + ))} +
    + ); +} diff --git a/apps/nextjs/src/app/[locale]/manage/custom-widgets/_code-editor.module.css b/apps/nextjs/src/app/[locale]/manage/custom-widgets/_code-editor.module.css new file mode 100644 index 000000000..d152dc61e --- /dev/null +++ b/apps/nextjs/src/app/[locale]/manage/custom-widgets/_code-editor.module.css @@ -0,0 +1,80 @@ +.root { + margin-top: 4px; + border: 1px solid light-dark(var(--mantine-color-gray-4), var(--mantine-color-dark-4)); + border-radius: var(--mantine-radius-sm); + background: light-dark(var(--mantine-color-white), var(--mantine-color-dark-7)); + overflow: hidden; +} + +.root:focus-within { + border-color: var(--mantine-primary-color-filled); + outline: 2px solid color-mix(in srgb, var(--mantine-primary-color-filled) 20%, transparent); + outline-offset: 1px; +} + +.toolbar, +.footer { + padding: 7px 10px; + background: light-dark(var(--mantine-color-gray-0), var(--mantine-color-dark-8)); +} + +.toolbar { + border-bottom: 1px solid light-dark(var(--mantine-color-gray-3), var(--mantine-color-dark-5)); +} + +.footer { + border-top: 1px solid light-dark(var(--mantine-color-gray-3), var(--mantine-color-dark-5)); +} + +.viewport { + max-height: min(62vh, 680px); + overflow: auto; +} + +.viewport :global(.cm-editor) { + background: light-dark(var(--mantine-color-white), var(--mantine-color-dark-7)); + color: light-dark(var(--mantine-color-black), var(--mantine-color-gray-0)); + font-family: "Fira Code", "SFMono-Regular", Consolas, monospace; + font-size: 12px; +} + +.viewport :global(.cm-editor.cm-focused) { + outline: none; +} + +.viewport :global(.cm-scroller) { + line-height: 1.65; + overflow: auto; +} + +.viewport :global(.cm-gutters) { + background: light-dark(var(--mantine-color-gray-0), var(--mantine-color-dark-8)); + border-color: light-dark(var(--mantine-color-gray-3), var(--mantine-color-dark-5)); +} + +.diagnosticButton { + min-height: 44px; + border-radius: var(--mantine-radius-sm); +} + +.diagnosticButton:focus-visible { + outline: 2px solid var(--mantine-primary-color-filled); + outline-offset: 2px; +} + +@media (max-width: 48em) { + .viewport { + max-height: 52vh; + } + + .toolbar, + .footer { + align-items: flex-start; + } +} + +@media (prefers-reduced-motion: reduce) { + .root { + scroll-behavior: auto; + } +} diff --git a/apps/nextjs/src/app/[locale]/manage/custom-widgets/_code-editor.tsx b/apps/nextjs/src/app/[locale]/manage/custom-widgets/_code-editor.tsx new file mode 100644 index 000000000..769b9940c --- /dev/null +++ b/apps/nextjs/src/app/[locale]/manage/custom-widgets/_code-editor.tsx @@ -0,0 +1,271 @@ +"use client"; + +import { useMemo, useState } from "react"; +import dynamic from "next/dynamic"; +import { autocompletion } from "@codemirror/autocomplete"; +import type { CompletionSource } from "@codemirror/autocomplete"; +import { redo, redoDepth, undo, undoDepth } from "@codemirror/commands"; +import { javascript } from "@codemirror/lang-javascript"; +import { json } from "@codemirror/lang-json"; +import { linter } from "@codemirror/lint"; +import { EditorView } from "@codemirror/view"; +import { Badge, Button, Group, Input, Loader, Text, useComputedColorScheme } from "@mantine/core"; +import { IconArrowBackUp, IconArrowForwardUp, IconCheck, IconCode, IconFileCode, IconWand } from "@tabler/icons-react"; +import { enabledCustomJsxComponents } from "@homarr/custom-widgets/core"; +import { ComponentReference } from "@homarr/custom-widgets/workbench"; +import type { EditorDiagnostic } from "@homarr/custom-widgets/workbench"; +import { useScopedI18n } from "@homarr/translation/client"; + +import { CodeEditorDiagnostics } from "./_code-editor-diagnostics"; +import classes from "./_code-editor.module.css"; + +const Editor = dynamic(() => import("@uiw/react-codemirror").then((module) => module.default), { + ssr: false, + loading: () => ( + + + + ), +}); + +const customJsxCompletionSource: CompletionSource = (context) => { + const word = context.matchBefore(/[A-Z][\w.]*/u); + if (!word && !context.explicit) return null; + return { + from: word?.from ?? context.pos, + options: enabledCustomJsxComponents.map((component) => ({ + label: component.name, + type: "class", + detail: `${component.category} · ${component.safety}`, + })), + }; +}; + +interface CodeEditorProps { + id: string; + value: string; + onChange: (value: string) => void; + label: string; + description?: string; + placeholder?: string; + language: "jsx" | "json"; + diagnostics?: EditorDiagnostic[]; + error?: React.ReactNode; + required?: boolean; + maxLength?: number; + starter?: string; +} + +export function CodeEditor({ + id, + value, + onChange, + label, + description, + placeholder, + language, + diagnostics = [], + error, + required, + maxLength, + starter, +}: CodeEditorProps) { + const t = useScopedI18n("customWidget.editor"); + const [cursor, setCursor] = useState({ line: 1, column: 1 }); + const [editorView, setEditorView] = useState(null); + const [historyDepth, setHistoryDepth] = useState({ undo: 0, redo: 0 }); + const colorScheme = useComputedColorScheme("light"); + const extensions = useMemo(() => { + const diagnosticsExtension = linter((view) => + diagnostics.map((diagnostic) => { + const from = Math.min(diagnostic.index ?? 0, view.state.doc.length); + return { + from, + to: Math.min(from + 1, view.state.doc.length), + severity: diagnostic.severity, + message: t(`diagnostics.${diagnostic.code}` as never, { value: diagnostic.value ?? "" } as never), + }; + }), + ); + const accessibilityExtension = EditorView.contentAttributes.of({ + id, + "aria-label": label, + }); + return language === "jsx" + ? [ + javascript({ jsx: true }), + autocompletion({ override: [customJsxCompletionSource] }), + diagnosticsExtension, + accessibilityExtension, + ] + : [json(), diagnosticsExtension, accessibilityExtension]; + }, [diagnostics, id, label, language, t]); + const errorCount = diagnostics.filter((diagnostic) => diagnostic.severity === "error").length; + const warningCount = diagnostics.length - errorCount; + + const formattedValue = useMemo(() => { + if (language === "json") { + try { + return `${JSON.stringify(JSON.parse(value) as unknown, null, 2)}\n`; + } catch { + return value; + } + } + return value + .replace(/\r\n?/gu, "\n") + .split("\n") + .map((line) => line.trimEnd()) + .join("\n") + .trim(); + }, [language, value]); + + return ( + +
    + + + + + {language === "jsx" ? t("language.jsx") : t("language.json")} + + + + + + {language === "jsx" && ( + t("componentReference.count", { count }), + }} + /> + )} + {starter && value.trim().length === 0 && ( + + )} + + + + +
    + { + if (!update.selectionSet && !update.docChanged) return; + const head = update.state.selection.main.head; + const line = update.state.doc.lineAt(head); + setCursor({ line: line.number, column: head - line.from + 1 }); + setHistoryDepth({ undo: undoDepth(update.state), redo: redoDepth(update.state) }); + }} + /> +
    + + + + {errorCount > 0 ? ( + + {t("status.errors", { count: errorCount })} + + ) : warningCount > 0 ? ( + + {t("status.warnings", { count: warningCount })} + + ) : ( + + + + {t("status.ready")} + + + )} + + {t("status.position", cursor)} + + + maxLength * 0.95 ? (value.length > maxLength ? "red" : "orange") : "dimmed"} + > + {maxLength + ? t("status.charactersWithLimit", { count: value.length, limit: maxLength }) + : t("status.characters", { count: value.length })} + + +
    + + + `${diagnostic.line ? `${t("diagnostics.line", { line: diagnostic.line })}: ` : ""}${t( + `diagnostics.${diagnostic.code}` as never, + { value: diagnostic.value ?? "" } as never, + )}` + } + /> +
    + ); +} diff --git a/apps/nextjs/src/app/[locale]/manage/custom-widgets/_copy-ai-prompt-button.tsx b/apps/nextjs/src/app/[locale]/manage/custom-widgets/_copy-ai-prompt-button.tsx index d78aafbab..a7ec2b06d 100644 --- a/apps/nextjs/src/app/[locale]/manage/custom-widgets/_copy-ai-prompt-button.tsx +++ b/apps/nextjs/src/app/[locale]/manage/custom-widgets/_copy-ai-prompt-button.tsx @@ -5,289 +5,10 @@ import { useDisclosure } from "@mantine/hooks"; import { IconCopy, IconSparkles } from "@tabler/icons-react"; import { clientApi } from "@homarr/api/client"; +import { buildCustomWidgetAiPrompt } from "@homarr/custom-widgets/core"; import { showErrorNotification, showSuccessNotification } from "@homarr/notifications"; import { useScopedI18n } from "@homarr/translation/client"; -const PROMPT_HEADER = `You are helping configure a Homarr custom widget. Homarr is a self-hosted dashboard that can display data from any API endpoint as a widget. - -## Your Task -Generate a valid JSON configuration for a Homarr custom widget based on the user's description and the API response below. If you need clarification, ask specific questions. - -## Output Format -- Output the JSON inside a \`\`\`json code block for syntax highlighting. If \`\`\`json is not supported, use a generic \`\`\` code block instead. -- Do NOT include any text before or after the JSON block unless you have clarifying questions. -- If your environment supports structured/JSON output mode, use it. - -## JSON Schema -The output must conform to this JSON Schema: - -`; - -const PROMPT_RULES = ` - -## Key Rules -- The \`displayConfig.type\` field MUST match the \`displayType\` field exactly -- All \`jsonPath\` fields use JSONPath syntax (e.g. \`$.data.count\`, \`$.items[*].name\`) -- The \`$schema\` field should be \`"homarr-custom-widget-v2"\` -- Do NOT include secrets/passwords in the output — those are configured separately in the UI -- \`url\` must be a full URL including protocol (e.g. \`https://...\`) -- For arrays of items, inspect the API response to find the correct paths - -## Display Type Guide -- \`singleValue\`: Show one prominent number/text (e.g. total count, status) -- \`keyValue\`: Show labeled pairs like "CPU: 45%" — use \`mappings\` array -- \`table\`: Show tabular data from an array — needs \`tablePath\` for the array and \`columns\` for headers -- \`statGrid\`: Grid of stat cards with optional colors — great for dashboards (e.g. "Movies: 38, Series: 63") -- \`progressBars\`: Visual progress bars with value/max — for storage, quotas, etc. -- \`statusIndicator\`: Green/red dots based on value matching — for service health checks -- \`countGrid\`: Simple grid of counts — like statGrid but simpler, no colors -- \`raw\`: Raw JSON display — for debugging or complex data -- \`actionButton\`: A button that triggers the API call on click — for POST/PUT actions -- \`customJsx\`: Custom JSX layout using whitelisted Mantine components — full creative control over presentation. Set \`displayConfig.template\` to a JSX string. Access API data via \`{data.fieldName}\` bindings (e.g. \`{data.name}\`, \`{data.items[0].title}\`). - -## Custom JSX (\`customJsx\`) — Available Mantine Components -When using \`customJsx\`, the template supports whitelisted Mantine UI components. These are React components from the Mantine v9 library. Use their props as documented below. - -### Layout Components -- **Stack** — Vertical flex container. Props: \`gap\` (xs|sm|md|lg|xl or number), \`align\` (stretch|center|flex-start|flex-end), \`justify\` -- **Group** — Horizontal flex container. Props: \`gap\`, \`justify\` (flex-start|center|space-between|space-around|flex-end), \`wrap\` (wrap|nowrap), \`grow\` (boolean) -- **Flex** — Generic flex container. Props: \`direction\` (row|column), \`gap\`, \`align\`, \`justify\`, \`wrap\` -- **Grid** + **Grid.Col** — CSS grid layout. Grid props: \`gutter\` (gap). Grid.Col props: \`span\` (1-12 or "auto"), \`offset\` -- **SimpleGrid** — Auto-column grid. Props: \`cols\` (number), \`spacing\`, \`verticalSpacing\` -- **Center** — Centers content. Props: \`inline\` (boolean) -- **Space** — Empty spacing. Props: \`h\` (height), \`w\` (width) -- **Container** — Max-width wrapper. Props: \`size\` (xs|sm|md|lg|xl), \`fluid\` (boolean) -- **AspectRatio** — Maintains aspect ratio. Props: \`ratio\` (number, e.g. 16/9) - -### Typography Components -- **Text** — Body text. Props: \`size\` (xs|sm|md|lg|xl), \`fw\` (font-weight number, e.g. 700), \`c\` (color: "dimmed"|"red"|"blue"|...), \`ta\` (text-align), \`tt\` (text-transform: "capitalize"|"uppercase"|"lowercase"), \`td\` (text-decoration), \`lineClamp\` (number), \`truncate\` (boolean), \`span\` (renders as span) -- **Title** — Heading. Props: \`order\` (1-6, maps to h1-h6), \`size\`, \`c\`, \`ta\`, \`tt\` -- **Code** — Inline code. Props: \`color\`, \`block\` (boolean for code block) -- **Highlight** — Text with highlighted substring. Props: \`highlight\` (string or string[]) -- **Mark** — Highlighted text background. Props: \`color\` -- **Kbd** — Keyboard key display -- **Blockquote** — Styled quote. Props: \`color\`, \`cite\`, \`icon\` -- **Anchor** — Link. Props: \`href\`, \`target\`, \`underline\` ("always"|"hover"|"never") -- **NumberFormatter** — Formatted number display. Props: \`value\` (number), \`prefix\` (e.g. "$"), \`suffix\` (e.g. "%"), \`thousandSeparator\` (boolean or string), \`decimalScale\` (number) - -### Data Display Components -- **Badge** — Label badge. Props: \`color\`, \`variant\` (filled|light|outline|dot|default), \`size\` (xs|sm|md|lg|xl), \`radius\`, \`tt\` -- **Card** + **Card.Section** — Content card. Card props: \`shadow\` (xs|sm|md|lg|xl), \`padding\`/\`p\`, \`radius\`, \`withBorder\` (boolean). Card.Section props: \`withBorder\`, \`inheritPadding\` -- **Paper** — Surface container. Props: \`shadow\`, \`p\`, \`radius\`, \`withBorder\` -- **Alert** — Notification box. Props: \`color\`, \`variant\` (filled|light|outline), \`title\`, \`icon\` -- **ThemeIcon** — Icon container. Props: \`color\`, \`variant\`, \`size\`, \`radius\` -- **ColorSwatch** — Color preview. Props: \`color\` (CSS color string) -- **Table** + **Table.Thead**, **Table.Tbody**, **Table.Tr**, **Table.Th**, **Table.Td** — HTML table. Table props: \`striped\` (boolean), \`withTableBorder\`, \`withColumnBorders\`, \`highlightOnHover\` -- **List** + **List.Item** — Ordered/unordered list. List props: \`type\` ("ordered"|"unordered"), \`icon\`, \`spacing\` -- **Timeline** + **Timeline.Item** — Vertical timeline. Timeline props: \`active\` (number), \`bulletSize\`. Item props: \`title\`, \`bullet\` -- **Accordion** + **.Item** + **.Control** + **.Panel** — Collapsible sections. Item props: \`value\` (string). Control: clickable header. Panel: content. -- **Indicator** — Dot indicator on content. Props: \`color\`, \`position\`, \`size\`, \`label\`, \`processing\` (boolean) -- **Pill** — Removable tag. Props: \`size\`, \`withRemoveButton\` -- **Spoiler** — Show more/less. Props: \`maxHeight\` (number), \`showLabel\`, \`hideLabel\` - -### Feedback Components -- **Progress** + **Progress.Section** — Progress bar. Progress props: \`value\` (0-100), \`color\`, \`size\`, \`radius\`, \`striped\`, \`animated\`. Section props: \`value\`, \`color\` -- **RingProgress** — Circular progress. Props: \`sections\` (array of {value, color}), \`size\`, \`thickness\`, \`label\` (ReactNode) -- **Skeleton** — Loading placeholder. Props: \`height\`, \`width\`, \`radius\`, \`visible\` (boolean) -- **Loader** — Spinner. Props: \`size\`, \`color\`, \`type\` (oval|bars|dots) - -### Media Components -- **Image** — Responsive image. Props: \`src\`, \`alt\`, \`w\` (width), \`h\` (height), \`radius\`, \`fit\` (cover|contain|fill) -- **Avatar** + **Avatar.Group** — User avatar. Props: \`src\`, \`alt\`, \`size\` (xs|sm|md|lg|xl or number), \`radius\` (sm|xl), \`color\` -- **BackgroundImage** — Background image container. Props: \`src\`, \`radius\` -- **Tooltip** — Hover tooltip. Props: \`label\` (string), \`position\` (top|bottom|left|right), \`withArrow\` -- **Divider** — Horizontal/vertical rule. Props: \`orientation\` (horizontal|vertical), \`label\`, \`labelPosition\`, \`size\` -- **ScrollArea** — Scrollable container. Props: \`h\` (height), \`type\` (auto|always|scroll|hover) - -### Charts (@mantine/charts) -- **AreaChart**, **BarChart**, **LineChart** — Props: \`data\` (array of objects), \`dataKey\` (x-axis key), \`series\` (array of {name, color}), \`h\` (height), \`curveType\` (for Area/Line) -- **DonutChart**, **PieChart** — Props: \`data\` (array of {name, value, color}), \`h\`, \`withLabels\`, \`withLabelsLine\` -- **RadarChart** — Props: \`data\`, \`dataKey\`, \`series\` -- **RadialBarChart** — Props: \`data\` (array of {name, value, color}), \`h\` -- **Sparkline** — Props: \`data\` (flat number array), \`h\`, \`w\`, \`color\`, \`curveType\` - -### Common Prop Patterns -- **Spacing/sizing:** Most components accept \`p\` (padding), \`m\` (margin), \`px\`/\`py\`/\`mx\`/\`my\`/\`pt\`/\`pb\`/\`pl\`/\`pr\`/\`mt\`/\`mb\`/\`ml\`/\`mr\` with values xs|sm|md|lg|xl or numbers -- **Colors:** Use Mantine color names: "red", "blue", "green", "orange", "violet", "pink", "cyan", "grape", "teal", "yellow", "lime", "indigo", "gray", "dark". Add shade suffix: "red.6", "blue.4" -- **Styles:** Use \`style={{...}}\` for inline CSS. E.g. \`style={{flex: 1, minWidth: 0}}\` -- **Conditional rendering:** Use ternaries: \`{condition ? Yes : No}\` -- **Responsive:** Most size/spacing props accept object: \`{{ base: "sm", md: "lg" }}\` - -### Interactive Components (built-in, state-managed) -These components manage their own internal state — they provide interactivity without event handlers: - -**PaginatedList** — Paginates its children with prev/next buttons. -Props: \`pageSize\` (number, default 6) -Usage: Wrap a \`.map()\` expression to paginate results. -\`\`\`jsx - - {data.results.map(item => - - {item.name} - - )} - -\`\`\` - -**TabsContainer + TabPanel** — Tabbed interface with automatic tab switching. -TabsContainer props: \`defaultTab\` (string, optional — defaults to first tab) -TabPanel props: \`value\` (string, required — unique tab ID), \`label\` (string, optional — tab display text) -\`\`\`jsx - - - {data.description} - - - Total: {data.count} - - -\`\`\` - -**Collapsible** — Expandable/collapsible section with a title. -Props: \`title\` (string, required), \`defaultOpen\` (boolean, default false) -\`\`\`jsx - - {data.details} - -\`\`\` - -**StatBar** — A horizontal stat bar with label/value (great for RPG-style stats, progress). -Props: \`value\` (number), \`max\` (number, default 100), \`label\` (string), \`color\` (Mantine color) -\`\`\`jsx - - -\`\`\` - -**TypeBadge** — A colored badge that maps common type names to colors (normal, fire, water, electric, grass, ice, fighting, poison, ground, flying, psychic, bug, rock, ghost, dragon, dark, steel, fairy). -Props: \`type\` (string), \`size\` (xs|sm|md|lg|xl, default sm) -\`\`\`jsx - - - - -\`\`\` - -**Available bindings in templates:** -- \`data\` — the full API response JSON object -- \`String(v)\`, \`Number(v)\`, \`Boolean(v)\` — type coercion helpers -- \`Math.round\`, \`Math.floor\`, \`Math.ceil\`, \`Math.abs\`, \`Math.min\`, \`Math.max\`, \`Math.pow\`, \`Math.sqrt\`, \`Math.PI\` -- \`JSON.stringify(v)\`, \`Array.isArray(v)\`, \`Object.keys(v)\`, \`Object.values(v)\`, \`Object.entries(v)\` -- Expression arrows for \`.map()\`, \`.filter()\`, \`.slice()\` — e.g. \`{data.items.map(item => {item.name})}\` -- Ternaries for conditionals — e.g. \`{data.count > 0 ? "active" : "idle"}\` - -**FORBIDDEN keywords (template will be rejected):** constructor, __proto__, eval, Function, import, require, globalThis, window, document, fetch - -**Chart data formats:** -- BarChart/LineChart/AreaChart: \`data={data.items}\` + \`dataKey="month"\` (x-axis key) + \`series={[{ name: "count", color: "blue" }]}\` where series \`name\` matches a numeric key in each data row -- DonutChart/PieChart: \`data={data.items}\` where each item is \`{ name: "Label", value: 42, color: "blue" }\` — NO dataKey or series -- Sparkline: \`data={[1,2,3]}\` — flat number array -- NumberFormatter: \`\` - -### Full Pokémon Card Example (demonstrating TypeBadge, StatBar, TabsContainer, Collapsible) -API: \`https://pokeapi.co/api/v2/pokemon/charizard\` -\`\`\`jsx - - - - - {data.name} - #{String(data.id).padStart(3, "0")} - - {data.types.map(t => )} - - - - - - - {data.stats.map(s => - 100 ? "green" : "red"} /> - )} - - - - - {data.abilities.map(a => - - {a.ability.name}{a.is_hidden ? " (hidden)" : ""} - - )} - - - - - - {data.moves.slice(0, 20).map(m => - {m.move.name} - )} - - - - - -\`\`\` - -### Paginated List Example -API: \`https://pokeapi.co/api/v2/pokemon?limit=50\` -\`\`\`jsx - - - Pokédex - {data.count} Pokémon - - - {data.results.map((pokemon, i) => - - - - - {pokemon.name} - #{String(i + 1)} - - - - )} - - -\`\`\` - -## API Response -`; - -const PROMPT_NO_RESPONSE = `Paste the raw JSON response from your API endpoint below: - -\`\`\`json -PASTE_YOUR_API_RESPONSE_HERE -\`\`\` -`; - -const PROMPT_FOOTER = ` -## Your Request -Describe what you want the widget to show: - -`; - -function buildAiPrompt( - jsonSchema: unknown, - rawResponse?: string | null, - currentConfig?: Record | null, -) { - const schemaStr = JSON.stringify(jsonSchema, null, 2); - const responseSection = rawResponse - ? `The API returned the following JSON:\n\n\`\`\`json\n${rawResponse}\n\`\`\`\n` - : PROMPT_NO_RESPONSE; - - const configSection = currentConfig - ? `\n## Current Widget Configuration\nThe widget is currently configured as follows. Use this as a starting point and modify based on the user's request:\n\n\`\`\`json\n${JSON.stringify(currentConfig, null, 2)}\n\`\`\`\n` - : ""; - - return PROMPT_HEADER + schemaStr + PROMPT_RULES + responseSection + configSection + PROMPT_FOOTER; -} - interface CopyAiPromptButtonProps { rawResponse?: string | null; currentConfig?: Record | null; @@ -300,9 +21,8 @@ export const CopyAiPromptButton = ({ rawResponse, currentConfig }: CopyAiPromptB const handleCopy = async () => { if (!schema) return; - const prompt = buildAiPrompt(schema, rawResponse, currentConfig); try { - await navigator.clipboard.writeText(prompt); + await navigator.clipboard.writeText(buildCustomWidgetAiPrompt(schema, rawResponse, currentConfig)); close(); showSuccessNotification({ title: t("action.copyAiPrompt"), message: t("notification.aiPromptCopied") }); } catch { @@ -314,6 +34,7 @@ export const CopyAiPromptButton = ({ rawResponse, currentConfig }: CopyAiPromptB diff --git a/apps/nextjs/src/app/[locale]/manage/custom-widgets/_custom-widget-actions.tsx b/apps/nextjs/src/app/[locale]/manage/custom-widgets/_custom-widget-actions.tsx index ec8ba59c9..264602d6d 100644 --- a/apps/nextjs/src/app/[locale]/manage/custom-widgets/_custom-widget-actions.tsx +++ b/apps/nextjs/src/app/[locale]/manage/custom-widgets/_custom-widget-actions.tsx @@ -1,19 +1,14 @@ "use client"; -import { useRef } from "react"; +import { useCallback, useEffect, useMemo, useRef, useState } from "react"; import { ActionIcon, Menu } from "@mantine/core"; -import { - IconCopy, - IconDots, - IconDownload, - IconToggleLeft, - IconToggleRight, - IconTrash, - IconUpload, -} from "@tabler/icons-react"; +import { useDisclosure } from "@mantine/hooks"; +import { IconCopy, IconDots, IconDownload, IconTrash, IconUpload } from "@tabler/icons-react"; import { clientApi } from "@homarr/api/client"; import { revalidatePathActionAsync } from "@homarr/common/client"; +import { getImportReview, parseCustomWidgetClipboard } from "@homarr/custom-widgets/core"; +import { ImportReviewDialog } from "@homarr/custom-widgets/workbench"; import { useConfirmModal } from "@homarr/modals"; import { showErrorNotification, showSuccessNotification } from "@homarr/notifications"; import { useScopedI18n } from "@homarr/translation/client"; @@ -33,28 +28,8 @@ export const CustomWidgetRowActions = ({ widget }: { widget: WidgetRef }) => { const { openConfirmModal } = useConfirmModal(); const deleteMutation = clientApi.customWidget.delete.useMutation(); const duplicateMutation = clientApi.customWidget.duplicate.useMutation(); - const toggleEnabledMutation = clientApi.customWidget.toggleEnabled.useMutation(); const utils = clientApi.useUtils(); - const handleToggleEnabled = () => { - toggleEnabledMutation.mutate( - { id: widget.id, enabled: !widget.enabled }, - { - onSuccess: () => { - void utils.customWidget.all.invalidate(); - void utils.widget.customApi.getData.invalidate({ definitionId: widget.id }); - void revalidatePathActionAsync("/manage/custom-widgets"); - }, - onError: () => { - showErrorNotification({ - title: widget.enabled ? t("action.disable") : t("action.enable"), - message: t("notification.toggleError"), - }); - }, - }, - ); - }; - const handleExport = async () => { try { const data = await utils.customWidget.export.fetch({ id: widget.id }); @@ -103,7 +78,7 @@ export const CustomWidgetRowActions = ({ widget }: { widget: WidgetRef }) => { message: t("notification.deleted", { name: widget.name }), }); void utils.customWidget.all.invalidate(); - void utils.widget.customApi.getData.invalidate({ definitionId: widget.id }); + void utils.widget.customApi.getData.invalidate(); void revalidatePathActionAsync("/manage/custom-widgets"); }, onError: () => { @@ -123,14 +98,6 @@ export const CustomWidgetRowActions = ({ widget }: { widget: WidgetRef }) => { - : } - disabled={toggleEnabledMutation.isPending} - > - {widget.enabled ? t("action.disable") : t("action.enable")} - - } @@ -158,9 +125,13 @@ export const CustomWidgetRowActions = ({ widget }: { widget: WidgetRef }) => { export const ImportCustomWidgetButton = () => { const t = useScopedI18n("customWidget"); const fileInputRef = useRef(null); + const [pendingImport, setPendingImport] = useState | null>(null); + const [reviewOpened, { open: openReview, close: closeReview }] = useDisclosure(false); const utils = clientApi.useUtils(); const importMutation = clientApi.customWidget.import.useMutation({ onSuccess: () => { + closeReview(); + setPendingImport(null); showSuccessNotification({ title: t("action.import"), message: t("notification.imported") }); void utils.customWidget.all.invalidate(); void revalidatePathActionAsync("/manage/custom-widgets"); @@ -169,23 +140,45 @@ export const ImportCustomWidgetButton = () => { showErrorNotification({ title: t("action.import"), message: t("notification.importError") }); }, }); + const review = useMemo(() => getImportReview(pendingImport), [pendingImport]); + const queueImport = useCallback( + (value: Record) => { + setPendingImport(value); + openReview(); + }, + [openReview], + ); + + useEffect(() => { + const handlePaste = (event: ClipboardEvent) => { + const target = event.target as HTMLElement | null; + if (target?.matches("input, textarea, [contenteditable='true']")) return; + const widget = parseCustomWidgetClipboard(event.clipboardData?.getData("text/plain") ?? ""); + if (!widget) return; + event.preventDefault(); + queueImport(widget); + }; + window.addEventListener("paste", handlePaste); + return () => window.removeEventListener("paste", handlePaste); + }, [queueImport]); const handleImport = (event: React.ChangeEvent) => { const file = event.target.files?.[0]; if (!file) return; const reader = new FileReader(); - reader.onload = (e) => { + reader.addEventListener("load", (e) => { try { - const json = JSON.parse(e.target?.result as string); - importMutation.mutate(json); + const widget = parseCustomWidgetClipboard(e.target?.result as string); + if (!widget) throw new Error("Invalid import"); + queueImport(widget); } catch { showErrorNotification({ title: t("action.import"), message: t("notification.importError") }); } - }; - reader.onerror = () => { + }); + reader.addEventListener("error", () => { showErrorNotification({ title: t("action.import"), message: t("notification.importError") }); - }; + }); reader.readAsText(file); event.target.value = ""; }; @@ -197,16 +190,39 @@ export const ImportCustomWidgetButton = () => { leftSection={} onClick={() => fileInputRef.current?.click()} loading={importMutation.isPending} + title={t("action.pasteImportHint")} > {t("action.import")} + pendingImport && importMutation.mutate(pendingImport as never)} + messages={{ + title: t("importReview.title"), + description: t("importReview.description"), + name: t("importReview.name"), + origin: t("importReview.origin"), + authentication: t("importReview.authentication"), + networkScope: t("importReview.networkScope"), + methods: t("importReview.methods"), + permissions: t("importReview.permissions"), + actionWarningTitle: t("importReview.actionWarning.title"), + actionWarningDescription: t("importReview.actionWarning.description"), + cancel: t("importReview.cancel"), + confirm: t("importReview.confirm"), + permission: (permission) => t(`preview.request.permission.${permission}` as never), + }} /> ); diff --git a/apps/nextjs/src/app/[locale]/manage/custom-widgets/_custom-widget-form-errors.ts b/apps/nextjs/src/app/[locale]/manage/custom-widgets/_custom-widget-form-errors.ts new file mode 100644 index 000000000..84c4e09be --- /dev/null +++ b/apps/nextjs/src/app/[locale]/manage/custom-widgets/_custom-widget-form-errors.ts @@ -0,0 +1,42 @@ +const serverToFormFieldMap: Record> = { + statGrid: { items: "statGridItems" }, + countGrid: { items: "countGridItems" }, + statusIndicator: { items: "statusItems" }, + progressBars: { bars: "progressBars" }, + keyValue: { mappings: "mappings" }, + table: { columns: "columns", tablePath: "tablePath" }, + singleValue: { jsonPath: "jsonPath", label: "label", unit: "unit" }, + raw: { jsonPath: "rawJsonPath" }, + actionButton: { buttonLabel: "buttonLabel" }, + customJsx: { template: "template", requests: "requestManifest", networkScope: "networkScope" }, +}; + +export function extractServerErrors(error: unknown, displayType: string): Record { + const errors: Record = {}; + const trpcError = error as { + data?: { zodError?: { fieldErrors?: Record } }; + message?: string; + }; + if (trpcError.data?.zodError?.fieldErrors) { + for (const [field, messages] of Object.entries(trpcError.data.zodError.fieldErrors)) { + if (messages?.[0]) errors[field] = messages[0]; + } + return errors; + } + try { + const issues = JSON.parse(trpcError.message ?? "[]") as Array<{ path: (string | number)[]; message: string }>; + const fieldMap = serverToFormFieldMap[displayType] ?? {}; + for (const issue of issues) { + const path = [...issue.path]; + if (path[0] === "displayConfig") { + path.shift(); + const serverField = String(path[0]); + path[0] = fieldMap[serverField] ?? serverField; + } + errors[path.join(".")] = issue.message; + } + } catch { + // Non-validation server errors are handled by the caller's notification. + } + return errors; +} diff --git a/apps/nextjs/src/app/[locale]/manage/custom-widgets/_custom-widget-form-sections.tsx b/apps/nextjs/src/app/[locale]/manage/custom-widgets/_custom-widget-form-sections.tsx new file mode 100644 index 000000000..7e8060998 --- /dev/null +++ b/apps/nextjs/src/app/[locale]/manage/custom-widgets/_custom-widget-form-sections.tsx @@ -0,0 +1,238 @@ +import type { RefObject } from "react"; +import { + Button, + Fieldset, + Group, + PasswordInput, + SegmentedControl, + Select, + Stack, + Text, + TextInput, + Textarea, + ThemeIcon, +} from "@mantine/core"; +import { IconCode, IconLayoutGrid, IconPlayerPlay } from "@tabler/icons-react"; +import { IconPicker } from "@homarr/forms-collection"; +import { CUSTOM_JSX_STARTER } from "@homarr/custom-widgets/core"; +import { + CUSTOM_WIDGET_AUTH_SECRET_FIELDS, + CUSTOM_WIDGET_AUTH_USES_HEADER_NAME, +} from "@homarr/custom-widgets/workbench"; + +import type { DisplayFieldsProps } from "./_display-field-types"; +import { DISPLAY_TYPE_ICONS, DisplayTypeFields, DisplayTypePicker } from "./_display-type-fields"; +import classes from "./_custom-widget-form.module.css"; + +interface SharedSectionProps extends DisplayFieldsProps { + sectionRef: RefObject; +} + +interface FormatSectionProps extends SharedSectionProps { + onContinue: () => void; +} + +export function FormatSection({ form, t, sectionRef, onContinue }: FormatSectionProps) { + return ( +
    + + + + + +
    + + +