/** * Serializes an arbitrary value to a string. Used where a prop accepts * `any` (radio values, select values, etc.) but the DOM needs a string — * e.g. a hidden ``. * * - `null`/`undefined` serialize to the empty string. * - Strings pass through untouched (no JSON quoting). * - Everything else goes through `JSON.stringify`, falling back to * `String(value)` for cyclic or otherwise non-stringifiable input. */ export function serializeValue(value: unknown): string { if (value == null) { return ""; } if (typeof value === "string") { return value; } try { return JSON.stringify(value); } catch { return String(value); } }