Skip to content

walkVariantValue

walkVariantValue(props): unknown

Defined in: packages/core/src/fields/variant/utils.ts:163

Resolves a variant() value’s active member and walks each of the member’s reachable sub-fields through a caller-supplied recursive walker — the shared dispatch fields/blocks/utils.ts’s cloneNestedBlockIds, documents/cloneDocumentForDuplicate.ts’s regenerateNestedIds, and fields/array/utils.ts’s backfillFieldValue all delegate to for a variant()-typed field, instead of each re-deriving the same discriminated/primitive active-member lookup. Discriminated mode resolves the member by the stored discriminator key; primitive mode resolves it by classifyVariantValueKind, mirroring the admin form’s own active-member lookup.

VariantField

The variant() field definition describing props.value’s shape.

(props) => unknown

The caller’s own per-field walker, invoked once per reachable sub-field key present in props.value (discriminated mode) or once with the whole value and the resolved member’s own field definition (primitive mode).

unknown

The current value at props.field’s path.

unknown

props.value unchanged if no member resolves (discriminated: no match for the stored discriminator key; primitive: no member’s kind matches the value’s own); otherwise a new value with every reachable sub-field walked through props.recurse.