import React from 'react'; import { FieldValues } from 'react-hook-form'; /** * Namespacing wrapper for widget settings forms. When a setting form renders * inside ``, any field declared inside * it gets `block..` prepended at the field-component layer. * * Convention preservation: existing widget setting components write field * names like ``. The scope adds * `block..` to produce the page-level form path * `block..settings.className`. On the standalone `widgetEdit` page no * scope is mounted, so the same component binds to `settings.className` * directly — matching the form's `{ name, status, settings: { ... } }` * default-values shape. * * Used in: * - Page-builder admin settings drawer — multiple widgets share one * parent `useForm` mounted at the editor level; each widget's settings * sub-form mounts inside its own scope. * - Standalone `widgetEdit` page — scope is omitted, fields use the * same bare names and the standalone form holds the values directly. */ export interface WidgetSettingsScopeValue { /** Path prefix to prepend to field names, including the trailing dot. */ pathPrefix: string; /** The widget instance UID this scope is bound to (for downstream consumers). */ uid: string; } export declare function WidgetSettingsScope({ uid, children }: { uid: string; children: React.ReactNode; }): React.ReactElement; /** Returns the active scope or null when no scope is mounted. */ export declare function useWidgetSettingsScope(): WidgetSettingsScopeValue | null; /** * Pure path-resolution helper. Exported separately so it can be unit-tested * without React render setup. `useScopedFieldName` is a thin wrapper that * sources the prefix from context. */ export declare function applyScopePrefix(pathPrefix: string | null | undefined, name: string): string; /** * Resolve a field name against the active scope. Returns the input unchanged * when no scope is mounted (e.g., the standalone `widgetEdit` page). Field * components call this once per render and pass the result to RHF's * `` / `register`. * * Idempotent if the input already starts with `pathPrefix` — useful in case * a field is rendered both directly and through nested scopes. */ export declare function useScopedFieldName(name: string): string; /** * Scope-aware drop-in for `useFormContext`. Returns the same form context, * but with `register`, `watch`, `setValue`, `unregister`, and `getValues` * auto-prefixed by the active `WidgetSettingsScope`. Outside a scope (the * standalone `widgetEdit` page) it behaves identically to `useFormContext`. * * Widget setting components that use `register/setValue/watch` directly * (without going through Field components) should swap their * `useFormContext` import for this hook so the same component participates * correctly in both surfaces. */ export declare function useScopedFormContext(): { register: import("react-hook-form").UseFormRegister; watch: import("react-hook-form").UseFormWatch; setValue: import("react-hook-form").UseFormSetValue; unregister: import("react-hook-form").UseFormUnregister; getValues: import("react-hook-form").UseFormGetValues; getFieldState: import("react-hook-form").UseFormGetFieldState; setError: import("react-hook-form").UseFormSetError; clearErrors: import("react-hook-form").UseFormClearErrors; trigger: import("react-hook-form").UseFormTrigger; formState: import("react-hook-form").FormState; resetField: import("react-hook-form").UseFormResetField; reset: import("react-hook-form").UseFormReset; handleSubmit: import("react-hook-form").UseFormHandleSubmit; control: import("react-hook-form").Control; setFocus: import("react-hook-form").UseFormSetFocus; subscribe: import("react-hook-form").UseFormSubscribe; };