Issue #3590655: Fix entityReferenceAutocomplete transform for Canvas form state format
Canvas's formStateToObject() produces delta-keyed objects like
{ "0": { target_id: "Label (5)" } } rather than plain arrays. The
previous single-mode path short-circuited on !Array.isArray(value)
and returned the object unchanged, so firstRecord → mainProperty
could not extract target_id — the entity ID was always null and
nothing was ever saved to the backend.
Introduce toRecordsArray() which normalises both delta-keyed objects (via Object.values()) and plain arrays, then apply it consistently in both single and multi (tags) mode. In multi mode, fall back to returning the raw target_id string when no IDs can be extracted (partial input during typing) so the autocomplete display is preserved.