captureFormValues function exported

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

Metrics

LOC: 32 Complexity: 14 Params: 0

Signature

captureFormValues(): : Promise<Record<string, string>>

Summary

Captures current form values and returns them as a map

Architecture violations

View all

  • [warning] max-cyclomatic-complexity: 'captureFormValues' has cyclomatic complexity 14 (max 10)

Source Code

export async function captureFormValues(): Promise<Record<string, string>> {
  const { fields } = await detectAllFieldsAsync();
  const values: Record<string, string> = {};

  for (const field of fields) {
    const el = field.element;
    const key = field.id || field.name || field.selector;

    // if this field came from a custom adapter try to extract its value
    if (field.adapterName) {
      const custom = extractCustomComponentValue(field);
      if (custom !== null) {
        values[key] = custom;
        continue;
      }
    }

    if (el instanceof HTMLSelectElement) {
      values[key] = el.value;
    } else if (el instanceof HTMLInputElement) {
      if (el.type === "checkbox" || el.type === "radio") {
        values[key] = el.checked ? "true" : "false";
      } else {
        values[key] = el.value;
      }
    } else {
      values[key] = (el as HTMLTextAreaElement).value;
    }
  }

  return values;
}

Dependencies (Outgoing)

graph LR captureFormValues["captureFormValues"] detectAllFieldsAsync["detectAllFieldsAsync"] extractCustomComponentValue["extractCustomComponentValue"] captureFormValues -->|calls| detectAllFieldsAsync captureFormValues -->|calls| extractCustomComponentValue style captureFormValues fill:#dbeafe,stroke:#2563eb,stroke-width:2px click captureFormValues "6a3156502a77636f.html" click detectAllFieldsAsync "1b422b3353cdbe22.html" click extractCustomComponentValue "e6339fe1023108e6.html"

Impact (Incoming)

graph LR captureFormValues["captureFormValues"] FillableElement["FillableElement"] makeInput["makeInput"] FillableElement -->|uses| captureFormValues makeInput -->|uses| captureFormValues style captureFormValues fill:#dbeafe,stroke:#2563eb,stroke-width:2px click captureFormValues "6a3156502a77636f.html" click FillableElement "2ecf5aaac3f668a8.html" click makeInput "3b463c3c3297bb7c.html"
SourceType
FillableElement uses
makeInput uses