import { JSXElement } from 'solid-js'; import { Tag } from '@malloydata/malloy-tag'; import { Field, NestField, NestCell, FieldType, Cell } from '../data_tree'; import { RenderMetadata, GetResultMetadataOptions } from '../component/render-result-metadata'; import { JSONSchemaObject } from './json-schema-types'; export interface RenderProps { dataColumn: Cell; field: Field; customProps?: Record; } export interface RendererValidationSpec { readonly renderer: string; readonly ownedPaths?: string[][]; readonly childOwnedPaths?: string[][]; } interface BaseRenderPluginInstance { readonly name: string; readonly field: Field; readonly sizingStrategy: 'fixed' | 'fill'; getMetadata(): TMetadata; processData?(field: NestField, cell: NestCell): void; beforeRender?(metadata: RenderMetadata, options: GetResultMetadataOptions): void; getStyleOverrides?(): Record; } export interface SolidJSRenderPluginInstance extends BaseRenderPluginInstance { readonly renderMode: 'solidjs'; renderComponent(props: RenderProps): JSXElement; } export interface DOMRenderPluginInstance extends BaseRenderPluginInstance { readonly renderMode: 'dom'; renderToDOM(container: HTMLElement, props: RenderProps): void; cleanup?(container: HTMLElement): void; } export type RenderPluginInstance = SolidJSRenderPluginInstance | DOMRenderPluginInstance; export interface CoreVizPluginMethods { getSchema(): JSONSchemaObject; getSettings(): Record; getDefaultSettings(): Record; settingsToTag(settings: Record): Tag; } export type CoreVizPluginInstance = SolidJSRenderPluginInstance & CoreVizPluginMethods; export interface RenderPluginFactory { readonly name: string; /** * IMPORTANT: Declare the tags this renderer OWNS, not every tag it might * ever read. * * Own a tag here if this renderer is the authority for its meaning: * - the tag is only meaningful when this renderer is active * - this renderer is responsible for validating it * - this renderer should suppress "unknown render tag" warnings for it * * This applies to: * - tags on the renderer field itself * - context-sensitive tags on child fields * * Do NOT declare globally meaningful field tags just because this renderer * happens to read them during implementation. Examples: `label`, `hidden`, * `description`, `column`. * * Rule: * - if the tag would be meaningless without this renderer, declare it here * - if the tag is meaningful independently of this renderer, do not * * Think in terms of semantic ownership, not literal runtime reads. */ getValidationSpec?(): RendererValidationSpec; matches(field: Field, fieldTag: Tag, fieldType: FieldType): boolean; create(field: Field, pluginOptions?: unknown, modelTag?: Tag): TInstance; } export declare function isCoreVizPluginInstance(plugin: RenderPluginInstance): plugin is CoreVizPluginInstance; export {};