@theredhead — Frontend Library - v1.0.0
    Preparing search index...

    Function inferFilterFields

    • Infers FilterFieldDefinitions from a sample data row and optional column metadata.

      1. Keys — taken from columns (if provided), otherwise from Object.keys(sampleRow).
      2. Labels — use the column's headerText when available, otherwise humanise the key (firstName"First Name").
      3. Types — determined by inspecting the sample row value via sniffFieldType.

      Type Parameters

      • T extends Record<string, unknown>

        The row object type.

      Parameters

      • sampleRow: T

        A representative data row (typically the first).

      • Optionalcolumns: readonly ColumnMeta[]

        Optional array of column metadata to constrain and label the fields.

      Returns FilterFieldDefinition<T>[]

      An array of inferred filter field definitions.

      const fields = inferFilterFields(
      { name: "Alice", age: 30, joined: "2024-01-15" },
      );
      // → [
      // { key: "name", label: "Name", type: "string" },
      // { key: "age", label: "Age", type: "number" },
      // { key: "joined", label: "Joined", type: "date" },
      // ]