@difizen/mana-core
Version:
35 lines • 1.59 kB
TypeScript
import type { Contribution } from '@difizen/mana-syringe';
import { Syringe } from '@difizen/mana-syringe';
import type { JSONSchemaType } from 'ajv';
import type React from 'react';
import { ApplicationContribution } from '../application';
import type { ConfigurationNode } from './configuration-protocol';
export declare function notFalse(x: number | false): x is number;
export declare const ConfigurationRenderContribution: Syringe.DefinedToken;
export interface RenderProps<T = any> {
label: string | undefined;
value: T;
onChange: (value: T) => void;
schema: JSONSchemaType<T>;
}
export interface ConfigurationRender<T = any> {
/**
* false 不处理;
* number 表示优先级
*/
canHandle: (configuration: ConfigurationNode<T>) => false | number;
component: React.ComponentType<RenderProps<T>>;
}
export interface ConfigurationRenderContribution {
registerConfigurationRenders: () => ConfigurationRender[];
}
export declare class ConfigurationRenderRegistry implements ApplicationContribution {
protected renders: ConfigurationRender[];
protected providers: Contribution.Provider<ConfigurationRenderContribution>;
constructor(providers: Contribution.Provider<ConfigurationRenderContribution>);
onStart(): Promise<void>;
protected setupRenderContribution(): Promise<void>;
registerConfigurationRender(render: ConfigurationRender): void;
getConfigurationRender<T>(configuration: ConfigurationNode<T>): React.ComponentType<RenderProps<T>> | null;
}
//# sourceMappingURL=configuration-render-registry.d.ts.map