import { KV, KVU, Mapping } from 'ts-toolset'; import { IPosition, IDimension } from '../common/range'; import { IIdentity, ISchemaNode, IComponentEntity, ISchemaData, ITreeData } from './base'; //============= syntax ============= /** 变量绑定的值 */ export interface IVariableBingValue extends IIdentity { /** 变量是否只读 */ readOnly?: boolean; /** 变量绑定的值 */ value: any; } /** 变量 */ export interface IVariableEntity extends IIdentity { /** 变量类型 */ type?: string; /** 变量值 */ value: any; } /** 函数步骤 */ export interface IFunctionStepEntity { /** 操作类型,赋值、函数 */ type: string; /** 表达式 - 左边 */ left: string; /** 表达式 - 右边 */ right?: string; } /** 函数流程 */ export interface IFunctionFlowEntity extends IIdentity { /** 步骤集合 */ steps: IFunctionStepEntity[]; } //============= html ============= /** Html组件布局数据 */ export interface IHtmlLayoutEntity { /** 距离根结点坐标 */ rootPosition: IPosition; /** 父节距离根结点点坐标 */ parentPosition: IPosition, /** 节点距离父节点坐标 */ position: IPosition; /** 布局所占宽高 */ dimension: IDimension; /** 标识该节点是否有外部节点 */ // hasOutside?: boolean; /** 是否在外部,有的slot在包裹组件外部,有的在内部 */ // outsides: string[]; } /** 样式实体 */ export interface IStyleRuleEntity extends IIdentity { /** 选择器 */ selector: string; /** 样式规则,default, hover, active, focus */ rules: KV; /** 是否禁用 */ disabled: boolean; } /** 动效 */ export interface IMotionEntity extends IIdentity { /** 时长 */ duration: number; /** 延迟 */ delay: number; /** 重复次数 */ repeat: number; /** 缓动函数 */ funcName: string; } /** 事件动作参数 */ export interface IEventActionEntity extends IIdentity { /** 动作对应的参数 */ actionParams: any; } /** 事件 */ export interface IEventDataEntity extends IIdentity { /** 动作 */ action: IEventActionEntity; /** 是否禁用 */ disabled: boolean; } /** 组件样式数据 * @description editingStyle 和 editingClassName、editingClassState 是互斥的 */ export interface ICssDataEntity { /** 处于编辑的样式名 */ editingClassName?: string; /** 处于编辑的样式状态 */ editingClassStates?: KV; /** 处于编辑的样式对象 */ editingStyle?: string; /** 样式名集合 */ classNames?: string[]; /** 行内样式 */ styles?: KV; } /** 语法数据 */ export interface ISyntaxDataEntity extends IIdentity { /** 绑定的变量 */ variable?: IVariableDataEntity; /** 语法配置 */ config?: any } /** 变量数据 */ export interface IVariableDataEntity extends IIdentity { // 变量取值来源,default, template, current scope?: string; /** 读取数据的路径,没有默认取 key */ readPath?: string[]; /** 绑定的属性 */ bindPath: string[]; /** 转换规则 * @description 内置转换规则 key,或者函数字符串 function{...} */ convert?: string; } /** 组件插槽路径配置 */ export interface IHtmlSlotPathConfig { /** */ key: string; /** 类型 */ type: string; } /** 组件插槽配置 */ export interface IHtmlSlotEntity extends IIdentity { /** 插槽绑定路径 */ path: string; /** 设置插槽的操作 */ // handle?: string; /** 参数配置 */ params?: string[]; /** 包裹配置参数 */ paramWrapKey?: string; } /** 插槽数据 约束格式 */ export type IHtmlSlotConstraintValues = Mapping>; /** 插槽组件数据 */ export interface IHtmlSlotDataEntity { /** 插槽 */ slots?: IHtmlSlotConstraintValues; /** 子节点 */ children?: any; /** 自定义 */ customs?: KV; /** 模版 */ template?: any; } /** Html协议节点数据 */ export interface IHtmlSchemaNode extends ISchemaNode { /** 组件、模版 标识 */ key: string; /** 组件类型,component, template, syntax */ type: string; /** 触发类型,merge, slot, default */ trigger: string; /** 是否叶子节点 */ isLeaf?: boolean; /** 是否展示 */ visible?: boolean; /** 是否动态构建多个组件 */ // multiple?: boolean; /** 组件属性数据 */ propData?: any; /** 组件样式数据 */ cssData?: ICssDataEntity; /** 事件集合 */ eventData?: IEventDataEntity[]; /** 动效集合 */ motionData?: IMotionEntity[]; /** 绑定变量数据 */ variableData?: IVariableDataEntity[]; /** 组件布局数据 */ htmlLayout?: IHtmlLayoutEntity; /** 语法数据 */ syntaxData?: ISyntaxDataEntity; /** 插槽组件数据集合 */ slotData?: IHtmlSlotDataEntity; /** 开启的插槽 */ slotStarts?: string[]; /** 处于外部的节点 */ outsideSlots?: string[]; } export interface IHtmlComponentEventEntity extends IIdentity { } /** Html组件 */ export interface IHtmlComponentEntity extends IComponentEntity { /** 组件库 key */ libraryKey: string; /** 是否是叶子节点,标识该组件是否是闭合组件 */ isLeaf: boolean; /** 是否虚拟组件 */ virtual: boolean; /** 自定义样式属性 */ styles?: IIdentity[]; /** 插槽集合 */ slots?: IHtmlSlotEntity[]; /** 组件事件 */ events?: IHtmlComponentEventEntity[]; /** 组件默认属性 */ defaultProps?: any; /** 允许添加指定的父节点 */ allowParents?: string[]; } /** 函数功能 数据 */ export type IFunctionalEntity = { /** 变量列表 */ variables?: IVariableEntity[]; /** 函数列表 */ functions?: any; } /** 页面通用元素数据 */ export interface IPageFactorEntity { /** 模版 函数功能 数据 */ functional: IFunctionalEntity; /** 样式数据 */ styleRules: IStyleRuleEntity[]; } /** Html 协议数据 */ export interface IHtmlSchemaData extends ISchemaData { isBuild?: boolean; } /** Html模版数据 */ export interface IHtmlTemplateEntity extends IComponentEntity, IPageFactorEntity, IHtmlSchemaData { /** 插槽属性 */ slots?: IHtmlSlotEntity[]; /** 自定义样式属性 */ styles?: IIdentity[]; } /** Html协议数据 */ export interface IHtmlSchemaRecord extends IIdentity, IPageFactorEntity, IHtmlSchemaData { }