CustomComponentAdapter interface presentation exported

Last updated: 2026-03-04T23:21:38.378Z

Metrics

LOC: 44 Complexity: 1 Params: 0

Signature

interface CustomComponentAdapter

Source Code

export interface CustomComponentAdapter {
  /** Unique adapter name — stored in FormField.adapterName for fill-time lookup. */
  readonly name: AdapterName;

  /**
   * CSS selector that matches the component's root/wrapper element.
   * Used by the adapter registry to batch-query the DOM.
   */
  readonly selector: string;

  /**
   * Checks whether a DOM element actually belongs to this adapter.
   * Called after querySelectorAll(selector) to filter false positives.
   * Return `true` to claim the element for this adapter.
   */
  matches(element: HTMLElement): boolean;

  /**
   * Converts a matched wrapper element into a FormField stub.
   * Must set: element, selector, category, fieldType (as "unknown"),
   * and any relevant DOM metadata (label, options, placeholder, etc.).
   *
   * Classification is done downstream by the DetectionPipeline.
   */
  buildField(wrapper: HTMLElement): FormField;

  /**
   * Applies a value to the custom component.
   * Must trigger the component's own change events so frameworks (React, Vue, etc.)
   * pick up the change.
   *
   * Returns `true` if the value was successfully applied, `false` otherwise.
   * May be async for components that need to wait for dropdowns/panels to render.
   */
  fill(wrapper: HTMLElement, value: string): boolean | Promise<boolean>;

  /**
   * (Optional) Reads the current value from the custom component wrapper.
   * This is used when the user requests "Save form" so we can capture the
   * actual value instead of treating the wrapper as a generic <div>.
   * Returning `null` indicates the adapter cannot extract a value.
   */
  extractValue?(wrapper: HTMLElement): string | null;
}

Members

Name Kind Visibility Status Signature
matches method - matches(element: HTMLElement): : boolean
buildField method - buildField(wrapper: HTMLElement): : FormField
fill method - fill(wrapper: HTMLElement, value: string): : boolean | Promise<boolean>
extractValue method - extractValue(wrapper: HTMLElement): : string | null

No outgoing dependencies.

Impact (Incoming)

graph LR CustomComponentAdapter["CustomComponentAdapter"] getAdapterMap["getAdapterMap"] makeAdapter["makeAdapter"] matches["matches"] getAdapterMap -->|uses| CustomComponentAdapter makeAdapter -->|uses| CustomComponentAdapter matches -->|uses| CustomComponentAdapter matches -->|uses| CustomComponentAdapter matches -->|uses| CustomComponentAdapter matches -->|uses| CustomComponentAdapter matches -->|uses| CustomComponentAdapter matches -->|uses| CustomComponentAdapter matches -->|uses| CustomComponentAdapter matches -->|uses| CustomComponentAdapter matches -->|uses| CustomComponentAdapter matches -->|uses| CustomComponentAdapter matches -->|uses| CustomComponentAdapter matches -->|uses| CustomComponentAdapter matches -->|uses| CustomComponentAdapter matches -->|uses| CustomComponentAdapter style CustomComponentAdapter fill:#dbeafe,stroke:#2563eb,stroke-width:2px click CustomComponentAdapter "dc86c1894fa368f3.html" click getAdapterMap "9972c116451a41d5.html" click makeAdapter "7cbe03be6bdb4b2d.html" click matches "19835198bf6ff31b.html"
SourceType
getAdapterMap uses
makeAdapter uses
matches uses
matches uses
matches uses
matches uses
matches uses
matches uses
matches uses
matches uses
matches uses
matches uses
matches uses
matches uses
matches uses
matches uses