import { DomProps as CoreDomProps } from '@object-ui/core'; /** * The RUNTIME EXECUTOR of the "DOM pass-through" section of * {@link FieldWidgetComponentProps} (objectui#3291). * * ## The defect * * Field widgets forwarded their leftover props to a control with a bare * spread — `const { inputType, ...domProps } = props as any; `. Whatever a host handed the widget therefore became a DOM * attribute. Measured on `origin/main`, a real form + a real widget: * * ``` * * ``` * * The `[object Object]` this issue is named for is an authored field-config * key being `String()`-ed onto an attribute. React 19 does not warn: an * all-lowercase unknown attribute is passed through in complete silence, which * is why this survived so long. * * ## Why a whitelist, and not a list of keys to drop * * The biggest leak source is not any NAMED renderer prop — it is the open tail * of author-supplied keys. The form renderer destructures a fixed set of known * keys and forwards `...fieldProps` verbatim * (`components/src/renderers/form/form.tsx`), and `SchemaRenderer` is wider * still: it spreads the whole authored node as props and has no strip layer at * all, so on the SDUI path a widget's own spread is the ONLY line of defence. * * A blacklist enumerating today's renderer-only keys (`error`, `emptyHint`, * `dataSource`, `dependentValues`, `dependsOn`, `options`, `inputType`, …) * would pass every one of the canaries above and would not stop the next * authored key either. Only "keep the known-safe set, drop the rest" closes * it, which is what this function does. * * ## Declared = enforced * * {@link FieldWidgetComponentProps} already DECLARES the closed set of keys a * widget may receive, and {@link FieldWidgetDomProps} names the subset that may * legitimately reach a DOM element (objectui#3221). Until now that was a * type-level claim a widget could violate at runtime simply by spreading. This * function is that declaration's executable form, and TWO compile-time * assertions below bind them in both directions — forwarding an undeclared key * and declaring an unforwarded DOM key are each a compile error. Neither * direction can drift silently. * * ## Deliberately NOT forwarded * * `role` and other HTML global attributes are absent because the contract does * not declare them. They reached the DOM before this change only through the * open spread. If a field node should be able to author one, DECLARE it on * `FieldWidgetComponentProps` first and add it here — do not reopen the spread * (AGENTS.md #0.1: fix the contract, never widen the consumer). * * ## Where the mechanism lives now, and why the key list stayed here * * objectui#4425 phase 2 promoted this whitelist to the SDUI widget contract * generally, so the MECHANISM — filter by a declared key list plus the `aria-*` * / `data-*` open families — moved to `@object-ui/core` * (`utils/dom-props.ts`, `pickDomProps`), where every plugin package can reach * it without depending on `@object-ui/fields` (the objectui#4409 * dependency-direction method: `plugin-chatbot` declares `@object-ui/core` and * does not declare this package). * * The KEY LIST did not move, because it is not the same list. Measured on * objectui#4431: * * - `name` and `disabled` are here and NOT in the SDUI set: both are legal * only on form controls, which is what every widget in this package renders * and what `FieldWidgetComponentProps` declares. `name` on the `
= CoreDomProps
; /** * Keep only what may legitimately become a DOM attribute, and drop everything * else — renderer plumbing, and any extra key an author put on the field * config or SDUI node. * * Replaces the bare `{...props}` spread in every field widget that renders a * host element: * * ```tsx * // before — forwards whatever it was handed * const { inputType, ...domProps } = props as any; * return ; * * // after * return ; * ``` * * Semantic props a widget INTERPRETS (`value`, `onChange`, `field`, * `readonly`, `error`, …) are read from `props` as before; this function only * governs what gets spread. */ export declare function toDomProps
(props: P): DomProps
; export {};