type RemoveOn = S extends `on${infer R}` ? Uncapitalize : never; export type CamelCaseToKebabCase = S extends `${infer F}${infer R}` ? F extends Lowercase ? `${F}${CamelCaseToKebabCase}` : `-${Lowercase}${CamelCaseToKebabCase}` : Lowercase; export type KebabCaseToCamelCase = S extends `${infer F}-${infer R}` ? `${F}${Capitalize>}` : Capitalize; export const camelCaseToKebabCase = (value: string): string => { return ( (value[0] ?? "").toLowerCase() + value.slice(1).replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`) ); }; export type JsxPropNameToEventName = CamelCaseToKebabCase< RemoveOn >; export const jsxPropNameToEventName = (value: `on${string}`): string => { if (value.startsWith("on:")) { return value.slice(3); } else { return camelCaseToKebabCase(value.slice(2)); } }; export type EventNameToJsxProp = `on${Capitalize>}`;