fix: 优化 configure.supports.events 的类型

This commit is contained in:
humphry.hy 2021-11-10 18:01:05 +08:00
parent a93fe0df71
commit f9734e8a7e
3 changed files with 25 additions and 14 deletions

View File

@ -7,6 +7,8 @@ import {
ObjectOf, ObjectOf,
ArrayOf, ArrayOf,
TransformedComponentMetadata, TransformedComponentMetadata,
ConfigureSupport,
OneOfType,
} from '@ali/lowcode-types'; } from '@ali/lowcode-types';
function propConfigToFieldConfig(propConfig: PropConfig): FieldConfig { function propConfigToFieldConfig(propConfig: PropConfig): FieldConfig {
@ -102,7 +104,7 @@ function propTypeToSetter(propType: PropType): SetterType {
isRequired, isRequired,
initialValue: (field: any) => { initialValue: (field: any) => {
const data: any = {}; const data: any = {};
items.forEach((item) => { items.forEach((item: any) => {
let initial = item.defaultValue; let initial = item.defaultValue;
if (initial == null && item.setter && typeof item.setter === 'object') { if (initial == null && item.setter && typeof item.setter === 'object') {
initial = (item.setter as any).initialValue; initial = (item.setter as any).initialValue;
@ -224,14 +226,14 @@ export default function (metadata: TransformedComponentMetadata): TransformedCom
name, name,
description, description,
}); });
(supports as any).events = supportedEvents; (supports as ConfigureSupport).events = supportedEvents;
} }
return; return;
} }
if (name === 'className' && (propType === 'string' || propType === 'any')) { if (name === 'className' && (propType === 'string' || propType === 'any')) {
if ((supports as any).className == null) { if ((supports as ConfigureSupport).className == null) {
(supports as any).className = true; (supports as ConfigureSupport).className = true;
} }
return; return;
} }

View File

@ -2,7 +2,7 @@ import { ReactNode, ComponentType, ReactElement } from 'react';
import { IconType } from './icon'; import { IconType } from './icon';
import { TipContent } from './tip'; import { TipContent } from './tip';
import { TitleContent } from './title'; import { TitleContent } from './title';
import { PropConfig } from './prop-config'; import { PropConfig, PropType } from './prop-config';
import { NpmInfo } from './npm'; import { NpmInfo } from './npm';
import { FieldConfig } from './field-config'; import { FieldConfig } from './field-config';
import { NodeSchema, NodeData, ComponentSchema } from './schema'; import { NodeSchema, NodeData, ComponentSchema } from './schema';
@ -105,11 +105,14 @@ export interface LiveTextEditingConfig {
onSaveContent?: (content: string, prop: any) => any; onSaveContent?: (content: string, prop: any) => any;
} }
export interface Configure { export type ConfigureSupportEvent = string | {
props?: FieldConfig[]; name: string;
component?: ComponentConfigure; propType?: PropType;
supports?: { description?: string;
events?: any[]; };
export type ConfigureSupport = {
events?: ConfigureSupportEvent[];
className?: boolean; className?: boolean;
style?: boolean; style?: boolean;
lifecycles?: any[]; lifecycles?: any[];
@ -117,6 +120,11 @@ export interface Configure {
loop?: boolean; loop?: boolean;
condition?: boolean; condition?: boolean;
}; };
export interface Configure {
props?: FieldConfig[];
component?: ComponentConfigure;
supports?: ConfigureSupport;
} }
export interface ActionContentObject { export interface ActionContentObject {

View File

@ -43,4 +43,5 @@ export interface PropConfig {
propType: PropType; propType: PropType;
description?: string; description?: string;
defaultValue?: any; defaultValue?: any;
setter?: any
} }