34 lines
842 B
TypeScript
34 lines
842 B
TypeScript
import type { IframeWidgetNode } from '../schema';
|
|
|
|
/**
|
|
* goView iframe option shape varies across versions.
|
|
* Keep it permissive and normalize the common fields.
|
|
*/
|
|
export interface GoViewIframeOption {
|
|
dataset?: string;
|
|
src?: string;
|
|
url?: string;
|
|
borderRadius?: number;
|
|
}
|
|
|
|
/**
|
|
* Back-compat alias (older code used "LegacyIframeOption").
|
|
*/
|
|
export type LegacyIframeOption = GoViewIframeOption;
|
|
|
|
function pickSrc(option: GoViewIframeOption): string {
|
|
return option.dataset ?? option.src ?? option.url ?? '';
|
|
}
|
|
|
|
export function convertGoViewIframeOptionToNodeProps(option: GoViewIframeOption): IframeWidgetNode['props'] {
|
|
return {
|
|
src: pickSrc(option),
|
|
borderRadius: option.borderRadius,
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Back-compat export.
|
|
*/
|
|
export const convertLegacyIframeOptionToNodeProps = convertGoViewIframeOptionToNodeProps;
|