Normalise a framework useId()-style value into a DOM-id-safe prefix.
Framework useId implementations often return values containing : or
other characters that are invalid in CSS selectors. This function replaces
any run of non-alphanumeric characters with a single hyphen and trims
leading/trailing hyphens.
Throws when the sanitised result is empty so callers receive an actionable
error rather than a silent empty-string id.
Normalise a framework
useId()-style value into a DOM-id-safe prefix. FrameworkuseIdimplementations often return values containing:or other characters that are invalid in CSS selectors. This function replaces any run of non-alphanumeric characters with a single hyphen and trims leading/trailing hyphens.Throws when the sanitised result is empty so callers receive an actionable error rather than a silent empty-string id.