diff --git a/packages/code-generator/package.json b/packages/code-generator/package.json index 4f3b87d88..e85b50574 100644 --- a/packages/code-generator/package.json +++ b/packages/code-generator/package.json @@ -1,6 +1,6 @@ { "name": "@ali/lowcode-code-generator", - "version": "0.8.10", + "version": "0.8.12", "description": "出码引擎 for LowCode Engine", "main": "lib/index.js", "files": [ diff --git a/packages/code-generator/src/const/file.ts b/packages/code-generator/src/const/file.ts new file mode 100644 index 000000000..d29ea43a3 --- /dev/null +++ b/packages/code-generator/src/const/file.ts @@ -0,0 +1,3 @@ +import { FileType } from '../types/core'; + +export const FILE_TYPE_FAMILY = [[FileType.TSX, FileType.TS, FileType.JSX, FileType.JS]]; diff --git a/packages/code-generator/src/generator/ChunkBuilder.ts b/packages/code-generator/src/generator/ChunkBuilder.ts index 18ff63991..67ecd504e 100644 --- a/packages/code-generator/src/generator/ChunkBuilder.ts +++ b/packages/code-generator/src/generator/ChunkBuilder.ts @@ -1,28 +1,72 @@ -import { - BuilderComponentPlugin, - IChunkBuilder, - ICodeChunk, - ICodeStruct, -} from '../types'; +import { BuilderComponentPlugin, IChunkBuilder, ICodeChunk, ICodeStruct, FileType } from '../types'; import { COMMON_SUB_MODULE_NAME } from '../const/generator'; +import { FILE_TYPE_FAMILY } from '../const/file'; + +type ChunkGroupInfo = { + chunk: ICodeChunk; + familyIdx?: number; +}; + +function whichFamily(type: FileType): [number, FileType[]] | undefined { + const idx = FILE_TYPE_FAMILY.findIndex((family) => family.indexOf(type) >= 0); + if (idx < 0) { + return undefined; + } + return [idx, FILE_TYPE_FAMILY[idx]]; +} export const groupChunks = (chunks: ICodeChunk[]): ICodeChunk[][] => { - const col = chunks.reduce( - (chunksSet: Record, chunk) => { - const fileKey = `${chunk.subModule || COMMON_SUB_MODULE_NAME}.${ - chunk.fileType - }`; - if (!chunksSet[fileKey]) { - chunksSet[fileKey] = []; + const tmp: Record> = {}; + const col = chunks.reduce((chunksSet: Record, chunk) => { + const fileKey = chunk.subModule || COMMON_SUB_MODULE_NAME; + if (!chunksSet[fileKey]) { + chunksSet[fileKey] = []; + } + const res = whichFamily(chunk.fileType as FileType); + const info: ChunkGroupInfo = { + chunk, + }; + if (res) { + const [familyIdx, family] = res; + const rank = family.indexOf(chunk.fileType as FileType); + if (tmp[fileKey]) { + if (tmp[fileKey][familyIdx] !== undefined) { + if (tmp[fileKey][familyIdx] > rank) { + tmp[fileKey][familyIdx] = rank; + } + } else { + tmp[fileKey][familyIdx] = rank; + } + } else { + tmp[fileKey] = {}; + tmp[fileKey][familyIdx] = rank; } - chunksSet[fileKey].push(chunk); - return chunksSet; - }, - {}, - ); + info.familyIdx = familyIdx; + } - return Object.keys(col).map(key => col[key]); + chunksSet[fileKey].push(info); + return chunksSet; + }, {}); + + const result: ICodeChunk[][] = []; + Object.keys(col).forEach((key) => { + const byType: Record = {}; + col[key].forEach((info) => { + let t: string = info.chunk.fileType; + if (info.familyIdx !== undefined) { + t = FILE_TYPE_FAMILY[info.familyIdx][tmp[key][info.familyIdx]]; + info.chunk.fileType = t; + } + if (!byType[t]) { + byType[t] = []; + } + byType[t].push(info.chunk); + }); + result.push(...Object.keys(byType).map((t) => byType[t])); + }); + + return result; }; /** @@ -39,7 +83,7 @@ export default class ChunkBuilder implements IChunkBuilder { this.plugins = plugins; } - public async run( + async run( ir: unknown, initialStructure: ICodeStruct = { ir, @@ -64,11 +108,11 @@ export default class ChunkBuilder implements IChunkBuilder { }; } - public getPlugins() { + getPlugins() { return this.plugins; } - public addPlugin(plugin: BuilderComponentPlugin) { + addPlugin(plugin: BuilderComponentPlugin) { this.plugins.push(plugin); } } diff --git a/packages/code-generator/src/generator/ModuleBuilder.ts b/packages/code-generator/src/generator/ModuleBuilder.ts index 991ffedec..063434cb4 100644 --- a/packages/code-generator/src/generator/ModuleBuilder.ts +++ b/packages/code-generator/src/generator/ModuleBuilder.ts @@ -37,29 +37,23 @@ export function createModuleBuilder( const generateModule = async (input: unknown): Promise => { const moduleMainName = options.mainFileName || COMMON_SUB_MODULE_NAME; if (chunkGenerator.getPlugins().length <= 0) { - throw new CodeGeneratorError( - 'No plugins found. Component generation cannot work without any plugins!', - ); + throw new CodeGeneratorError('No plugins found. Component generation cannot work without any plugins!'); } let files: IResultFile[] = []; const { chunks } = await chunkGenerator.run(input); - chunks.forEach(fileChunkList => { + chunks.forEach((fileChunkList) => { const content = linker.link(fileChunkList); - const file = new ResultFile( - fileChunkList[0].subModule || moduleMainName, - fileChunkList[0].fileType, - content, - ); + const file = new ResultFile(fileChunkList[0].subModule || moduleMainName, fileChunkList[0].fileType, content); files.push(file); }); if (options.postProcessors.length > 0) { - files = files.map(file => { + files = files.map((file) => { let content = file.content; const type = file.ext; - options.postProcessors.forEach(processer => { + options.postProcessors.forEach((processer) => { content = processer(content, type); }); @@ -81,25 +75,18 @@ export function createModuleBuilder( const { files } = await generateModule(containerInfo); const dir = new ResultDir(containerInfo.moduleName); - files.forEach(file => dir.addFile(file)); + files.forEach((file) => dir.addFile(file)); return dir; - } + }; - const linkCodeChunks = ( - chunks: Record, - fileName: string, - ) => { + const linkCodeChunks = (chunks: Record, fileName: string) => { const files: IResultFile[] = []; - Object.keys(chunks).forEach(fileKey => { + Object.keys(chunks).forEach((fileKey) => { const fileChunkList = chunks[fileKey]; const content = linker.link(fileChunkList); - const file = new ResultFile( - fileChunkList[0].subModule || fileName, - fileChunkList[0].fileType, - content, - ); + const file = new ResultFile(fileChunkList[0].subModule || fileName, fileChunkList[0].fileType, content); files.push(file); }); diff --git a/packages/code-generator/src/utils/nodeToJSX.ts b/packages/code-generator/src/utils/nodeToJSX.ts index 018eac1d4..39791d7cd 100644 --- a/packages/code-generator/src/utils/nodeToJSX.ts +++ b/packages/code-generator/src/utils/nodeToJSX.ts @@ -166,15 +166,13 @@ export function generateBasicNode( export function generateReactCtrlLine(ctx: INodeGeneratorContext, nodeItem: IComponentNodeItem): CodePiece[] { const pieces: CodePiece[] = []; - if (nodeItem.loop && nodeItem.loopArgs) { - let loopDataExp; - if (isJsExpression(nodeItem.loop)) { - loopDataExp = `(${generateExpression(nodeItem.loop)})`; - } else { - loopDataExp = JSON.stringify(nodeItem.loop); - } + if (nodeItem.loop) { + const args: [string, string] = nodeItem.loopArgs || ['item', 'index']; + const loopData = generateCompositeType(nodeItem.loop, { + nodeGenerator: ctx.generator, + }); pieces.unshift({ - value: `${loopDataExp}.map((${nodeItem.loopArgs[0]}, ${nodeItem.loopArgs[1]}) => (`, + value: `(${loopData}).map((${args[0]}, ${args[1]}) => (`, type: PIECE_TYPE.BEFORE, }); pieces.push({ @@ -198,7 +196,7 @@ export function generateReactCtrlLine(ctx: INodeGeneratorContext, nodeItem: ICom }); } - if (nodeItem.condition || (nodeItem.loop && nodeItem.loopArgs)) { + if (nodeItem.condition || nodeItem.loop) { pieces.unshift({ value: '{', type: PIECE_TYPE.BEFORE, diff --git a/packages/demo/public/assets.json b/packages/demo/public/assets.json index 674a9696d..cbf185a0e 100644 --- a/packages/demo/public/assets.json +++ b/packages/demo/public/assets.json @@ -28,7 +28,10 @@ "props": [ { "name": "style", - "propType": "object" + "propType": "object", + "defaultValue": { + "padding": 12 + } } ], "configure": { @@ -57,6 +60,99 @@ } } }, + { + "componentName": "a", + "title": "Link", + "npm": { + "exportName": "a" + }, + "props": [ + { + "name": "href", + "title": "链接", + "propType": "string", + "defaultValue": "https://fusion.design" + }, + { + "name": "children", + "title": "内容", + "propType": { + "type": "oneOfType", + "value": [ + "string", + "node" + ] + }, + "defaultValue": "这是一个超链接" + }, + { + "name": "style", + "propType": "object" + }, + { + "name": "target", + "title": "新开页面", + "propType": { + "type": "oneOf", + "value": [ + "_blank", + "_self" + ] + } + } + ] + }, + { + "componentName": "img", + "title": "Image", + "npm": { + "exportName": "img" + }, + "props": [ + { + "name": "src", + "title": "图片链接", + "propType": "string", + "defaultValue": "https://img.alicdn.com/tps/TB16TQvOXXXXXbiaFXXXXXXXXXX-120-120.svg" + }, + { + "name": "title", + "title": { + "label": "标题", + "tip": "HTML 原生 title 属性" + }, + "propType": "string" + }, + { + "name": "alt", + "title": { + "label": "代替文本", + "tip": "HTML 原生 alt 属性" + }, + "propType": "string" + }, + { + "name": "width", + "title": { + "label": "宽度", + "tip": "HTML 原生 width 属性" + }, + "propType": "number" + }, + { + "name": "height", + "title": { + "label": "高度", + "tip": "HTML 原生 height 属性" + }, + "propType": "number" + }, + { + "name": "style", + "propType": "object" + } + ] + }, { "componentName": "Div", "title": "Div", @@ -1592,7 +1688,14 @@ }, { "name": "children", - "title": "文本内容", + "title": { + "label": { + "type": "i18n", + "zh_CN": "文本内容", + "en_US": "content" + }, + "tip": "按钮文本内容" + }, "setter": { "componentName": "MixedSetter", "props": { @@ -4499,7 +4602,13 @@ }, { "name": "visible", - "propType": "JSExpression", + "propType": { + "type": "oneOfType", + "value": [ + "JSExpression", + "bool" + ] + }, "description": "是否显示", "defaultValue": false }, @@ -4969,12 +5078,6 @@ "subName": "" }, "props": [ - { - "name": "prefix", - "propType": "string", - "description": "样式前缀", - "defaultValue": "next-" - }, { "name": "inline", "propType": "bool", @@ -4982,6 +5085,10 @@ }, { "name": "size", + "title": { + "label": "Size", + "tip": "单个 Item 的 size 自定义,优先级高于 Form 的 size, 并且当组件与 Item 一起使用时,组件自身设置 size 属性无效。\n@enumdesc 大, 中, 小" + }, "propType": { "type": "oneOf", "value": [ @@ -5000,6 +5107,10 @@ }, { "name": "labelAlign", + "title": { + "label": "标签的位置", + "tip": "上, 左, 内" + }, "propType": { "type": "oneOf", "value": [ @@ -5022,74 +5133,11 @@ }, "description": "标签的左右对齐方式\n@enumdesc 左, 右" }, - { - "name": "field", - "propType": "any", - "description": "field 实例, 传 false 会禁用 field" - }, - { - "name": "saveField", - "propType": "func", - "description": "保存 Form 自动生成的 field 对象" - }, - { - "name": "labelCol", - "propType": { - "type": "shape", - "value": [{ - "name": "span", - "description": "fixedSpan", - "propType": "number" - },{ - "name": "fixedSpan", - "description": "fixedSpan", - "propType": "number" - },{ - "name": "offset", - "description": "offset", - "propType": "number" - },{ - "name": "fixedOffset", - "description": "fixedOffset", - "propType": "number" - }] - }, - "description": "控制第一级 Item 的 labelCol" - }, - { - "name": "wrapperCol", - "propType": { - "type": "shape", - "value": [{ - "name": "span", - "description": "fixedSpan", - "propType": "number" - },{ - "name": "fixedSpan", - "description": "fixedSpan", - "propType": "number" - },{ - "name": "offset", - "description": "offset", - "propType": "number" - },{ - "name": "fixedOffset", - "description": "fixedOffset", - "propType": "number" - }] - }, - "description": "控制第一级 Item 的 wrapperCol" - }, { "name": "onSubmit", "propType": "func", "description": "form内有 `htmlType=\"submit\"` 的元素的时候会触发" }, - { - "name": "children", - "propType": "any", - "description": "子元素" - }, { "name": "className", "propType": "string", @@ -5102,7 +5150,13 @@ }, { "name": "value", - "propType": "object", + "propType": { + "type": "oneOfType", + "value": [ + "Json", + "JSExpression" + ] + }, "description": "表单数值" }, { @@ -5110,22 +5164,6 @@ "propType": "func", "description": "表单变化回调\n@param {Object} values 表单数据\n@param {Object} item 详细\n@param {String} item.name 变化的组件名\n@param {String} item.value 变化的数据\n@param {Object} item.field field 实例" }, - { - "name": "component", - "propType": { - "type": "oneOfType", - "value": [ - "string", - "func" - ] - }, - "description": "设置标签类型", - "defaultValue": "form" - }, - { - "name": "fieldOptions", - "propType": "object" - }, { "name": "rtl", "propType": "bool" @@ -5153,7 +5191,12 @@ "propType": "bool", "description": "是否开启预览态" } - ] + ], + "configure": { + "component": { + "isContainer": true + } + } }, { "componentName": "Form.Item", @@ -5170,10 +5213,8 @@ }, "props": [ { - "name": "prefix", - "propType": "string", - "description": "样式前缀", - "defaultValue": "next-" + "name": "id", + "propType": "string" }, { "name": "rtl", @@ -5186,32 +5227,60 @@ }, { "name": "labelCol", - "propType": "object", + "propType": { + "type": "shape", + "value": [{ + "name": "span", + "description": "span", + "propType": "number" + },{ + "name": "offset", + "description": "offset", + "propType": "number" + }] + }, "description": "label 标签布局,通 `` 组件,设置 span offset 值,如 {span: 8, offset: 16},该项仅在垂直表单有效" }, { "name": "wrapperCol", - "propType": "object", + "propType": { + "type": "shape", + "value": [{ + "name": "span", + "description": "span", + "propType": "number" + },{ + "name": "offset", + "description": "offset", + "propType": "number" + }] + }, "description": "需要为输入控件设置布局样式时,使用该属性,用法同 labelCol" }, { "name": "help", - "propType": { - "type": "instanceOf", - "value": "node" + "title": { + "label": "自定义提示信息", + "tip": "如不设置,则会根据校验规则自动生成." }, + "propType": "string", "description": "自定义提示信息,如不设置,则会根据校验规则自动生成." }, { "name": "extra", - "propType": { - "type": "instanceOf", - "value": "node" + "title": { + "label": "额外的提示信息", + "tip": "和 help 类似,当需要错误信息和提示文案同时出现时,可以使用这个。 位于错误信息后面" }, + "propType": "string", "description": "额外的提示信息,和 help 类似,当需要错误信息和提示文案同时出现时,可以使用这个。 位于错误信息后面" }, { "name": "validateState", + "title": { + "label": "校验状态", + "tip": "如不设置,则会根据校验规则自动生成\n@enumdesc 失败, 成功, 校验中, 警告" + }, "propType": { "type": "oneOf", "value": [ @@ -5223,37 +5292,17 @@ }, "description": "校验状态,如不设置,则会根据校验规则自动生成\n@enumdesc 失败, 成功, 校验中, 警告" }, - { - "name": "hasFeedback", - "propType": "bool", - "description": "配合 validateState 属性使用,是否展示 success/loading 的校验状态图标, 目前只有Input支持", - "defaultValue": false - }, { "name": "style", "propType": "object", "description": "自定义内联样式" }, - { - "name": "id", - "propType": "string" - }, - { - "name": "children", - "propType": { - "type": "oneOfType", - "value": [ - { - "type": "instanceOf", - "value": "node" - }, - "func" - ] - }, - "description": "node 或者 function(values)" - }, { "name": "size", + "title": { + "label": "Size", + "tip": "单个 Item 的 size 自定义,优先级高于 Form 的 size, 并且当组件与 Item 一起使用时,组件自身设置 size 属性无效。" + }, "propType": { "type": "oneOf", "value": [ @@ -5266,11 +5315,19 @@ }, { "name": "fullWidth", + "title": { + "label": "fullWidth", + "tip": "单个 Item 中表单类组件宽度是否是100%" + }, "propType": "bool", "description": "单个 Item 中表单类组件宽度是否是100%" }, { "name": "labelAlign", + "title": { + "label": "标签的位置", + "tip": "上, 左, 内" + }, "propType": { "type": "oneOf", "value": [ @@ -5283,6 +5340,10 @@ }, { "name": "labelTextAlign", + "title": { + "label": "标签的左右对齐方式", + "tip": "左, 右" + }, "propType": { "type": "oneOf", "value": [ @@ -5299,141 +5360,118 @@ }, { "name": "required", + "title": { + "label": "不能为空", + "tip": "[表单校验] 不能为空" + }, "propType": "bool", "description": "[表单校验] 不能为空" }, - { - "name": "asterisk", - "propType": "bool", - "description": "required 的星号是否显示" - }, { "name": "requiredMessage", + "title": { + "label": "自定义错误信息", + "tip": "[表单校验]为空时自定义错误信息" + }, "propType": "string", "description": "required 自定义错误信息" }, - { - "name": "requiredTrigger", - "propType": { - "type": "oneOfType", - "value": [ - "string", - { - "type": "instanceOf", - "value": "array" - } - ] - }, - "description": "required 自定义触发方式" - }, { "name": "min", + "title": { + "label": "最小值", + "tip": "[表单校验] 最小值" + }, "propType": "number", "description": "[表单校验] 最小值" }, { "name": "max", + "title": { + "label": "最大值", + "tip": "[表单校验] 最大值" + }, "propType": "number", "description": "[表单校验] 最大值" }, { "name": "minmaxMessage", + "title": { + "label": "min/max message", + "tip": "[表单校验] min/max 自定义错误信息" + }, "propType": "string", "description": "min/max 自定义错误信息" }, - { - "name": "minmaxTrigger", - "propType": { - "type": "oneOfType", - "value": [ - "string", - { - "type": "instanceOf", - "value": "array" - } - ] - }, - "description": "min/max 自定义触发方式" - }, { "name": "minLength", + "title": { + "label": "最小长度", + "tip": "[表单校验] 字符串最小长度 / 数组最小个数" + }, "propType": "number", "description": "[表单校验] 字符串最小长度 / 数组最小个数" }, { "name": "maxLength", + "title": { + "label": "最大长度", + "tip": "[表单校验] 字符串最大长度 / 数组最大个数" + }, "propType": "number", "description": "[表单校验] 字符串最大长度 / 数组最大个数" }, { "name": "minmaxLengthMessage", + "title": { + "label": "max|min length error message", + "tip": "[表单校验] minLength/maxLength 自定义错误信息" + }, "propType": "string", "description": "minLength/maxLength 自定义错误信息" }, - { - "name": "minmaxLengthTrigger", - "propType": { - "type": "oneOfType", - "value": [ - "string", - { - "type": "instanceOf", - "value": "array" - } - ] - }, - "description": "minLength/maxLength 自定义触发方式" - }, { "name": "length", + "title": { + "label": "长度", + "tip": "[表单校验] 字符串精确长度 / 数组精确个数" + }, "propType": "number", "description": "[表单校验] 字符串精确长度 / 数组精确个数" }, { "name": "lengthMessage", + "title": { + "label": "length error message", + "tip": "[表单校验] minLength/maxLength 自定义错误信息" + }, "propType": "string", "description": "length 自定义错误信息" }, - { - "name": "lengthTrigger", - "propType": { - "type": "oneOfType", - "value": [ - "string", - { - "type": "instanceOf", - "value": "array" - } - ] - }, - "description": "length 自定义触发方式" - }, { "name": "pattern", - "propType": "any", + "title": { + "label": "正则", + "tip": "[表单校验] 正则校验" + }, + "propType": "string", "description": "正则校验" }, { "name": "patternMessage", + "title": { + "label": "pattern error message", + "tip": "[表单校验] pattern 自定义错误信息" + }, "propType": "string", "description": "pattern 自定义错误信息" }, - { - "name": "patternTrigger", - "propType": { - "type": "oneOfType", - "value": [ - "string", - { - "type": "instanceOf", - "value": "array" - } - ] - }, - "description": "pattern 自定义触发方式" - }, { "name": "format", + "title": { + "label": "format", + "tip": "[表单校验] 四种常用的 pattern" + }, "propType": { "type": "oneOf", "value": [ @@ -5447,42 +5485,18 @@ }, { "name": "formatMessage", + "title": { + "label": "format error message", + "tip": "[表单校验] format 自定义错误信息" + }, "propType": "string", "description": "format 自定义错误信息" }, - { - "name": "formatTrigger", - "propType": { - "type": "oneOfType", - "value": [ - "string", - { - "type": "instanceOf", - "value": "array" - } - ] - }, - "description": "format 自定义触发方式" - }, { "name": "validator", "propType": "func", "description": "[表单校验] 自定义校验函数" }, - { - "name": "validatorTrigger", - "propType": { - "type": "oneOfType", - "value": [ - "string", - { - "type": "instanceOf", - "value": "array" - } - ] - }, - "description": "validator 自定义触发方式" - }, { "name": "autoValidate", "propType": "bool", @@ -5525,11 +5539,6 @@ "name": "isPreview", "propType": "bool", "description": "是否开启预览态" - }, - { - "name": "renderPreview", - "propType": "func", - "description": "预览态模式下渲染的内容\n@param {any} value 根据包裹的组件的 value 类型而决定" } ], "configure": { @@ -5785,6 +5794,166 @@ "subName": "" }, "props": [ + { + "name": "label", + "propType": "string", + "title":"标签文案", + "description": "label" + }, + { + "name": "name", + "propType": "string" + }, + { + "name": "hasClear", + "propType": "bool", + "description": "是否出现清除按钮" + }, + { + "name": "state", + "title": "状态", + "propType": { + "type": "oneOf", + "value": [ + "error", + "loading", + "success", + "warning" + ] + }, + "description": "状态\n@enumdesc 错误, 校验中, 成功, 警告" + }, + { + "name": "size", + "title": "尺寸", + "propType": { + "type": "oneOf", + "value": [ + "small", + "medium", + "large" + ] + }, + "description": "尺寸\n@enumdesc 小, 中, 大", + "defaultValue": "medium" + }, + { + "name": "disabled", + "propType": "bool", + "description": "是否禁用" + }, + { + "name": "maxLength", + "propType": "number", + "description": "最大长度" + }, + { + "name": "hasLimitHint", + "propType": "bool", + "description": "是否展现最大长度样式" + }, + { + "name": "cutString", + "propType": "bool", + "description": "是否截断超出字符串" + }, + { + "name": "readOnly", + "propType": "bool", + "description": "是否只读" + }, + { + "name": "trim", + "propType": "bool", + "description": "onChange返回会自动去除头尾空字符" + }, + { + "name": "placeholder", + "propType": "string", + "description": "输入提示" + }, + { + "name": "hasBorder", + "propType": "bool", + "description": "是否有边框" + }, + + { + "name": "onPressEnter", + "propType": "func", + "description": "按下回车的回调" + }, + { + "name": "onClear", + "propType": "func" + }, + { + "name": "hint", + "title": "Icon 水印", + "propType": "icon", + "description": "水印 (Icon的type类型,和hasClear占用一个地方)" + }, + { + "name": "innerBefore", + "propType": "string", + "description": "文字前附加内容" + }, + { + "name": "innerAfter", + "propType": "string", + "description": "文字后附加内容" + }, + { + "name": "addonBefore", + "propType": "string", + "description": "输入框前附加内容" + }, + { + "name": "addonAfter", + "propType": "string", + "description": "输入框后附加内容" + }, + { + "name": "addonTextBefore", + "propType": "string", + "description": "输入框前附加文字" + }, + { + "name": "addonTextAfter", + "propType": "string", + "description": "输入框后附加文字" + }, + { + "name": "autoFocus", + "propType": "bool", + "description": "自动聚焦" + }, + { + "name": "style", + "propType": "object" + } + ] + }, + { + "componentName": "Input.Password", + "title": "Input.Password", + "docUrl": "", + "screenshot": "", + "npm": { + "package": "@alifd/next", + "version": "1.19.18", + "exportName": "Input", + "main": "src/index.js", + "destructuring": true, + "subName": "Password" + }, + "props": [ + { + "name": "showToggle", + "propType": "bool", + "description": "是否展示切换按钮", + "defaultValue": true + }, { "name": "label", "propType": "string", @@ -5921,32 +6090,6 @@ } ] }, - { - "componentName": "Input.Password", - "title": "Input.Password", - "docUrl": "", - "screenshot": "", - "npm": { - "package": "@alifd/next", - "version": "1.19.18", - "exportName": "Input", - "main": "src/index.js", - "destructuring": true, - "subName": "Password" - }, - "props": [ - { - "name": "showToggle", - "propType": "bool", - "description": "是否展示切换按钮", - "defaultValue": true - }, - { - "name": "style", - "propType": "object" - } - ] - }, { "componentName": "Input.TextArea", "title": "Input.TextArea", @@ -7236,7 +7379,7 @@ }, { "name": "iconType", - "propType": "string", + "propType": "icon", "description": "显示的图标类型,会覆盖内部设置的IconType" }, { @@ -7827,7 +7970,13 @@ }, { "name": "innerAfter", - "propType": "string", + "propType": { + "type": "oneOfType", + "value": [ + "string", + "icon" + ] + }, "description": "inner after" }, { @@ -7895,6 +8044,23 @@ { "name": "downBtnProps", "setter": "JsonSetter" + }, + { + "name": "innerAfter", + "setter": { + "componentName": "MixedSetter", + "props": { + "setters": [ + "StringSetter", + { + "componentName": "IconSetter", + "props": { + "type": "node" + } + } + ] + } + } } ] } @@ -10322,11 +10488,6 @@ "destructuring": true }, "props": [ - { - "name": "prefix", - "propType": "string", - "defaultValue": "next-" - }, { "name": "type", "propType": { @@ -10360,11 +10521,6 @@ "propType": "bool", "description": "是否开启动效" }, - { - "name": "afterAppear", - "propType": "func", - "description": "标签出现动画结束后执行的回调" - }, { "name": "onClick", "propType": "func", @@ -10372,17 +10528,11 @@ }, { "name": "children", - "propType": { - "type": "instanceOf", - "value": "node" - } + "propType": "string", + "description": "内容" } ], - "configure": { - "component": { - "isContainer": true - } - } + "configure": {} }, { "componentName": "Tag.Selectable", @@ -10398,11 +10548,6 @@ "subName": "Selectable" }, "props": [ - { - "name": "prefix", - "propType": "string", - "defaultValue": "next-" - }, { "name": "checked", "propType": "bool", @@ -10425,17 +10570,11 @@ }, { "name": "children", - "propType": { - "type": "instanceOf", - "value": "node" - } + "propType": "string", + "description": "内容" } ], - "configure": { - "component": { - "isContainer": true - } - } + "configure": {} }, { "componentName": "Tag.Closeable", @@ -10451,11 +10590,6 @@ "subName": "Closeable" }, "props": [ - { - "name": "prefix", - "propType": "string", - "defaultValue": "next-" - }, { "name": "closeArea", "propType": { @@ -10484,11 +10618,6 @@ "propType": "func", "description": "点击关闭按钮时的回调,返回值 true 则关闭, false 阻止关闭" }, - { - "name": "afterClose", - "propType": "func", - "description": "标签关闭后执行的回调" - }, { "name": "onClick", "propType": "func", @@ -10496,17 +10625,11 @@ }, { "name": "children", - "propType": { - "type": "instanceOf", - "value": "node" - } + "propType": "string", + "description": "内容" } ], - "configure": { - "component": { - "isContainer": true - } - } + "configure": {} }, { "componentName": "TimePicker", @@ -12365,6 +12488,26 @@ } ] }, + { + "componentName": "Field", + "title": "Field", + "docUrl": "", + "screenshot": "", + "npm": { + "package": "@alifd/next", + "version": "1.19.18", + "exportName": "Field", + "main": "src/index.js", + "destructuring": true, + "subName": "" + }, + "props": [ + { + "name": "this", + "propType": "any" + } + ] + }, { "componentName": "Avatar", "title": "Avatar", @@ -12389,6 +12532,7 @@ }, { "name": "size", + "title": "size", "propType": { "type": "oneOfType", "value": [ @@ -12408,6 +12552,7 @@ }, { "name": "shape", + "title": "shap", "propType": { "type": "oneOf", "value": [ @@ -12420,11 +12565,13 @@ }, { "name": "icon", - "propType": "string", + "title": "icon", + "propType": "icon", "description": "icon 类头像的图标类型,可设为 Icon 的 `type` 或 `ReactNode`" }, { "name": "src", + "title": "src", "propType": "string", "description": "图片类头像的资源地址" }, @@ -12433,16 +12580,6 @@ "propType": "func", "description": "图片加载失败的事件,返回 false 会关闭组件默认的 fallback 行为" }, - { - "name": "alt", - "propType": "string", - "description": "图像无法显示时的 alt 替代文本" - }, - { - "name": "srcSet", - "propType": "string", - "description": "图片类头像响应式资源地址" - }, { "name": "style", "propType": "object" @@ -12607,21 +12744,12 @@ "subName": "" }, "props": [ - { - "name": "prefix", - "propType": "string", - "defaultValue": "next-" - }, - { - "name": "style", - "propType": "object" - }, - { - "name": "className", - "propType": "any" - }, { "name": "direction", + "title": { + "label": "布局方向", + "tip": "布局方向,默认为 column ,一个元素占据一整行,默认为column" + }, "propType": { "type": "oneOf", "value": [ @@ -12629,17 +12757,21 @@ "column" ] }, - "description": "布局方向,默认为 column ,一个元素占据一整行\n@default column", "defaultValue": "column" }, { "name": "wrap", + "title": "是否折行", "propType": "bool", "description": "是否折行", "defaultValue": false }, { "name": "justify", + "title": { + "label": "沿主轴排布关系", + "tip": "沿着主轴方向,子元素们的排布关系 (兼容性同 justify-content )" + }, "propType": { "type": "oneOf", "value": [ @@ -12649,11 +12781,14 @@ "space-between", "space-around" ] - }, - "description": "沿着主轴方向,子元素们的排布关系 (兼容性同 justify-content )" + } }, { "name": "align", + "title": { + "label": "垂直主轴排布关系", + "tip": "垂直主轴方向,子元素们的排布关系 (兼容性同 align-items )" + }, "propType": { "type": "oneOf", "value": [ @@ -12663,17 +12798,22 @@ "baseline", "stretch" ] - }, - "description": "垂直主轴方向,子元素们的排布关系 (兼容性同 align-items )" + } }, { - "name": "device", + "name": "spacing", + "title": { + "label": "元素间距", + "tip": "元素之间的间距 [bottom&top, right&left]" + }, "propType": { - "type": "oneOf", + "type": "oneOfType", "value": [ - "phone", - "tablet", - "desktop" + "number", + { + "type": "arrayOf", + "value": "number" + } ] } } @@ -12781,7 +12921,7 @@ "componentName": "Dropdown", "title": "下拉菜单", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -12805,7 +12945,7 @@ "componentName": "Avatar", "title": "头像", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -12816,7 +12956,8 @@ "props": { "prefix": "next-", "size": "medium", - "shape": "circle" + "shape": "circle", + "icon": "smile" } } } @@ -12826,7 +12967,7 @@ "componentName": "Badge", "title": "徽标数", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -12846,7 +12987,7 @@ "componentName": "Drawer", "title": "抽屉", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -12870,7 +13011,7 @@ "componentName": "Table", "title": "表格", "icon": "https://alifd.oss-cn-hangzhou.aliyuncs.com/fusion-cool/icons/icon-light/ic_light_table.png", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -12908,10 +13049,10 @@ "componentName": "Button", "props": { "type": "primary", - "children": [{ + "children": { "type": "JSExpression", "value": "this.value" - }] + } } }] } @@ -12932,7 +13073,7 @@ "componentName": "Table.Column", "title": "表格列", "icon": "https://alifd.oss-cn-hangzhou.aliyuncs.com/fusion-cool/icons/icon-light/ic_light_table.png", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -12951,7 +13092,7 @@ "componentName": "Calendar", "title": "日历", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -12990,7 +13131,7 @@ "componentName": "Card", "title": "卡片", "icon": "https://alifd.oss-cn-hangzhou.aliyuncs.com/fusion-cool/icons/icon-light/ic_light_card.png", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13024,7 +13165,7 @@ "componentName": "Cascader", "title": "级联", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13053,7 +13194,7 @@ "componentName": "Collapse", "title": "折叠面板", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13080,7 +13221,7 @@ "componentName": "List", "title": "列表", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13096,7 +13237,7 @@ "componentName": "List.Item", "title": "列表项", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13113,7 +13254,7 @@ "componentName": "Menu", "title": "菜单", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13146,7 +13287,7 @@ "componentName": "Menu.Item", "title": "菜单项", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13165,7 +13306,7 @@ "componentName": "Progress", "title": "进度指示器", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13187,7 +13328,7 @@ "componentName": "Slider", "title": "图片轮播", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13230,7 +13371,7 @@ "componentName": "Tag", "title": "标签", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13238,7 +13379,13 @@ "screenshot": "https://alifd.oss-cn-hangzhou.aliyuncs.com/fusion-cool/icons/icon-light/ic_light_tag.png", "schema": { "componentName": "Tag", - "props": {} + "props": { + "prefix": "next-", + "type": "normal", + "size": "medium", + "animation": false, + "children": "Tag" + } } } ] @@ -13247,7 +13394,7 @@ "componentName": "Tag.Closeable", "title": "可关闭标签", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13255,7 +13402,12 @@ "screenshot": "https://alifd.oss-cn-hangzhou.aliyuncs.com/fusion-cool/icons/icon-light/ic_light_tag.png", "schema": { "componentName": "Tag.Closeable", - "props": {} + "props": { + "prefix": "next-", + "closeArea": "tail", + "size": "medium", + "children": "Tag" + } } } ] @@ -13264,7 +13416,7 @@ "componentName": "Tag.Selectable", "title": "可选中标签", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13272,7 +13424,10 @@ "screenshot": "https://alifd.oss-cn-hangzhou.aliyuncs.com/fusion-cool/icons/icon-light/ic_light_tag.png", "schema": { "componentName": "Tag.Selectable", - "props": {} + "props": { + "prefix": "next-", + "children": "Tag" + } } } ] @@ -13281,7 +13436,7 @@ "componentName": "Timeline", "title": "时间轴", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13321,7 +13476,7 @@ "componentName": "TimelineItem", "title": "时间轴 Item", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13342,7 +13497,7 @@ "componentName": "Tree", "title": "树形控件", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13366,7 +13521,7 @@ "componentName": "TreeNode", "title": "树形控件节点", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13391,7 +13546,7 @@ "componentName": "Balloon", "title": "气泡提示", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13427,7 +13582,7 @@ "componentName": "Dialog", "title": "弹窗", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13455,7 +13610,7 @@ "componentName": "Loading", "title": "加载", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13464,6 +13619,7 @@ "schema": { "componentName": "Loading", "props": { + "color": "red", "prefix": "next-", "tipAlign": "bottom", "visible": true, @@ -13478,7 +13634,7 @@ "componentName": "Message", "title": "信息提示", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13508,7 +13664,7 @@ "componentName": "Box", "title": "弹性布局", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13521,21 +13677,67 @@ } ] }, + { + "componentName": "a", + "title": "Link", + "icon": "", + "snippets": [ + { + "title": "Link", + "screenshot": "https://img.alicdn.com/tfs/TB15DZVReL2gK0jSZFmXXc7iXXa-200-200.svg", + "schema": { + "componentName": "a", + "title": "Link", + "props": { + "href": "https://fusion.design", + "target": "_blank", + "children": { + "type": "JSSlot", + "value": { + "componentName": "Typography.Text", + "props": { + "children": "这是一个超链接" + } + } + } + } + } + } + ] + }, + { + "componentName": "img", + "title": "Image", + "icon": "", + "snippets": [ + { + "title": "Image", + "screenshot": "https://img.alicdn.com/tfs/TB10nEur.Y1gK0jSZFCXXcwqXXa-234-230.png", + "schema": { + "title": "Image", + "componentName": "img", + "props": { + "src": "https://img.alicdn.com/tps/TB16TQvOXXXXXbiaFXXXXXXXXXX-120-120.svg" + } + } + } + ] + }, { "componentName": "Button", "title": "按钮", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { - "title": "按钮", + "title": "主要", "screenshot": "https://alifd.oss-cn-hangzhou.aliyuncs.com/fusion-cool/icons/icon-light/ic_light_button.png", "schema": { "componentName": "Button", "props": { "prefix": "next-", - "type": "normal", + "type": "primary", "size": "medium", "htmlType": "button", "component": "button", @@ -13549,8 +13751,8 @@ "schema": { "componentName": "Button", "props": { - "type": "primary", - "size": "large", + "type": "secondary", + "size": "medium", "htmlType": "button", "component": "button", "children": ["提交"] @@ -13563,7 +13765,7 @@ "componentName": "Button.Group", "title": "按钮组", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13611,7 +13813,7 @@ "componentName": "Divider", "title": "分隔符", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13632,7 +13834,7 @@ "componentName": "Icon", "title": "图标", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13651,7 +13853,7 @@ "componentName": "MenuButton", "title": "菜单按钮", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13673,7 +13875,7 @@ "componentName": "ResponsiveGrid", "title": "栅格布局", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13690,7 +13892,7 @@ "componentName": "ResponsiveGrid.Cell", "title": "栅格布局 Cell", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13707,7 +13909,7 @@ "componentName": "SplitButton", "title": "分隔按钮", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13731,7 +13933,7 @@ "componentName": "Typography", "title": "Text", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13757,7 +13959,7 @@ "componentName": "Breadcrumb", "title": "面包屑", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13800,7 +14002,7 @@ "componentName": "Breadcrumb.Item", "title": "面包屑 Item", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13841,7 +14043,7 @@ "componentName": "Nav", "title": "导航", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13870,7 +14072,7 @@ "componentName": "Nav.Item", "title": "导航Item", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13899,7 +14101,7 @@ "componentName": "Pagination", "title": "翻页器", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13927,7 +14129,7 @@ "componentName": "Step", "title": "步骤", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13957,7 +14159,7 @@ "componentName": "Tab", "title": "选项卡", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -13983,7 +14185,7 @@ "componentName": "Tab.Item", "title": "选项卡Item", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -14004,13 +14206,312 @@ "icon": "" }, { - "title": "DataEntry", + "title": "表单", "children": [ + { + "componentName": "Form", + "title": "表单容器", + "icon": "https://img.alicdn.com/tfs/TB1oH02u2b2gK0jSZK9XXaEgFXa-112-64.png", + "package": "@alifd/next", + "library": "Next", + "snippets": [ + { + "title": "表单容器", + "screenshot": "https://img.alicdn.com/tfs/TB1oH02u2b2gK0jSZK9XXaEgFXa-112-64.png", + "schema": { + "componentName": "Form", + "props": { + "labelCol": { + "span": 2, + "labelAlign": "left" + }, + "role": "grid" + }, + "children": [ + { + "componentName": "Form.Item", + "props": { + "label": "Email: ", + "required": true + }, + "children": [ + { + "componentName": "Input", + "props": { + "name": "email", + "size": "medium", + "placeholder": "用户名" + } + } + ] + }, + { + "componentName": "Form.Item", + "props": { + "label": "Password: ", + "required": true + }, + "children": [ + { + "componentName": "Input.Password", + "props": { + "name": "password", + "placeholder": "请输入密码", + "size": "medium" + } + } + ] + }, + { + "componentName": "Form.Item", + "props": { + "wrapperCol": { + "offset": 7 + } + }, + "children": [ + { + "componentName": "Form.Submit", + "props": { + "type": "primary", + "validate": true, + "onClick": { + "type": "JSFunction", + "value": "(v, e) => { console.log(v, e) }" + } + }, + "children": "Submit" + }, + { + "componentName": "Form.Reset", + "props": { + "style": {"marginLeft": 10} + }, + "children": "Reset" + } + ] + } + ] + } + } + ] + }, + { + "componentName": "Form.Item", + "title": "表单项", + "icon": "https://img.alicdn.com/tfs/TB1nYqOuW61gK0jSZFlXXXDKFXa-112-64.png", + "package": "@alifd/next", + "library": "Next", + "snippets": [ + { + "title": "Form.Item", + "screenshot": "https://img.alicdn.com/tfs/TB1nYqOuW61gK0jSZFlXXXDKFXa-112-64.png", + "schema": { + "componentName": "Form.Item", + "props": { + "placeholder": "拖动组件到这里" + } + } + } + ] + }, + { + "componentName": "Input", + "title": "输入框", + "icon": "", + "package": "@alifd/next", + "library": "Next", + "snippets": [ + { + "title": "输入框", + "screenshot": "https://img.alicdn.com/tfs/TB1ysp3u8v0gK0jSZKbXXbK2FXa-112-64.png", + "schema": { + "componentName": "Form.Item", + "props": { + "label": "标签", + "labelAlign": "top", + "labelCol": { + "span": 4 + } + }, + "children": [ + { + "componentName": "Input", + "props": { + "hasBorder": true, + "size": "medium", + "autoComplete": "off" + } + } + ] + } + }, + { + "title": "密码框", + "screenshot": "https://img.alicdn.com/tfs/TB1ikF3u7P2gK0jSZPxXXacQpXa-112-64.png", + "schema": { + "componentName": "Input.Password", + "props": { + "hasBorder": true, + "size": "medium", + "autoComplete": "off" + } + } + }, + { + "title": "TextArea", + "screenshot": "https://alifd.oss-cn-hangzhou.aliyuncs.com/fusion-cool/icons/icon-light/ic_light_input.png", + "schema": { + "componentName": "Input.TextArea", + "props": { + "hasBorder": true, + "size": "medium", + "autoComplete": "off" + } + } + } + ] + }, + { + "componentName": "NumberPicker", + "title": "数字输入框", + "icon": "", + "package": "@alifd/next", + "library": "Next", + "snippets": [ + { + "title": "数字输入框", + "screenshot": "https://alifd.oss-cn-hangzhou.aliyuncs.com/fusion-cool/icons/icon-light/ic_light_number-picker.png", + "schema": { + "componentName": "NumberPicker", + "props": { + "prefix": "next-", + "type": "normal", + "size": "medium", + "step": 1, + "editable": true + } + } + } + ] + }, + { + "componentName": "Radio", + "title": "单选框", + "icon": "", + "package": "@alifd/next", + "library": "Next", + "snippets": [ + { + "title": "单选框", + "screenshot": "https://alifd.oss-cn-hangzhou.aliyuncs.com/fusion-cool/icons/icon-light/ic_light_radio.png", + "schema": { + "componentName": "Radio", + "props": {} + } + } + ] + }, + { + "componentName": "Radio.Group", + "title": "单选框组", + "icon": "", + "package": "@alifd/next", + "library": "Next", + "snippets": [ + { + "title": "单选框组", + "screenshot": "https://alifd.oss-cn-hangzhou.aliyuncs.com/fusion-cool/icons/icon-light/ic_light_radio.png", + "schema": { + "componentName": "Radio.Group", + "props": {} + } + } + ] + }, + { + "componentName": "Checkbox", + "title": "复选按钮", + "icon": "", + "package": "@alifd/next", + "library": "Next", + "snippets": [ + { + "title": "复选按钮", + "screenshot": "https://alifd.oss-cn-hangzhou.aliyuncs.com/fusion-cool/icons/icon-light/ic_light_checkbox.png", + "schema": { + "componentName": "Checkbox", + "props": { + "prefix": "next-" + } + } + } + ] + }, + { + "componentName": "Select", + "title": "选择器", + "icon": "", + "package": "@alifd/next", + "library": "Next", + "snippets": [ + { + "title": "选择器", + "screenshot": "https://alifd.oss-cn-hangzhou.aliyuncs.com/fusion-cool/icons/icon-light/ic_light_select.png", + "schema": { + "componentName": "Select", + "props": { + "mode": "single", + "hasArrow": true, + "cacheValue": true + } + } + } + ] + }, + { + "componentName": "Select.Option", + "title": "Select.Option", + "icon": "", + "package": "@alifd/next", + "library": "Next", + "snippets": [ + { + "title": "Select.Option", + "screenshot": "", + "schema": { + "componentName": "Select.Option", + "props": { + } + } + } + ] + }, + { + "componentName": "Switch", + "title": "开关组件", + "icon": "", + "package": "@alifd/next", + "library": "Next", + "snippets": [ + { + "title": "开关组件", + "screenshot": "https://alifd.oss-cn-hangzhou.aliyuncs.com/fusion-cool/icons/icon-light/ic_light_switch.png", + "schema": { + "componentName": "Switch", + "props": { + "prefix": "next-", + "size": "medium" + } + } + } + ] + }, { "componentName": "CascaderSelect", "title": "级联选择", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -14040,30 +14541,11 @@ } ] }, - { - "componentName": "Checkbox", - "title": "复选按钮", - "icon": "", - "package": "@alife/next", - "library": "Next", - "snippets": [ - { - "title": "复选按钮", - "screenshot": "https://alifd.oss-cn-hangzhou.aliyuncs.com/fusion-cool/icons/icon-light/ic_light_checkbox.png", - "schema": { - "componentName": "Checkbox", - "props": { - "prefix": "next-" - } - } - } - ] - }, { "componentName": "DatePicker", "title": "日期选择框", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -14083,152 +14565,11 @@ } ] }, - { - "componentName": "Form.Item", - "title": "Form.Item", - "icon": "", - "package": "@alife/next", - "library": "Next", - "snippets": [ - { - "title": "Form.Item", - "screenshot": "", - "schema": { - "componentName": "Form.Item", - "props": { - "style":{ - "minWidth": "200px", - "minHeight": "28px" - } - } - } - } - ] - }, - { - "componentName": "Form", - "title": "表单", - "icon": "", - "package": "@alife/next", - "library": "Next", - "snippets": [ - { - "title": "表单", - "screenshot": "", - "schema": { - "componentName": "Form", - "props": {} - } - } - ] - }, - { - "componentName": "Input", - "title": "输入框", - "icon": "", - "package": "@alife/next", - "library": "Next", - "snippets": [ - { - "title": "输入框", - "screenshot": "https://alifd.oss-cn-hangzhou.aliyuncs.com/fusion-cool/icons/icon-light/ic_light_input.png", - "schema": { - "componentName": "Input", - "props": { - "hasBorder": true, - "size": "medium", - "autoComplete": "off" - } - } - }, - { - "title": "密码框", - "screenshot": "https://alifd.oss-cn-hangzhou.aliyuncs.com/fusion-cool/icons/icon-light/ic_light_input.png", - "schema": { - "componentName": "Input.Password", - "props": { - "hasBorder": true, - "size": "medium", - "autoComplete": "off" - } - } - }, - { - "title": "TextArea", - "screenshot": "https://alifd.oss-cn-hangzhou.aliyuncs.com/fusion-cool/icons/icon-light/ic_light_input.png", - "schema": { - "componentName": "Input.TextArea", - "props": { - "hasBorder": true, - "size": "medium", - "autoComplete": "off" - } - } - } - ] - }, - { - "componentName": "NumberPicker", - "title": "数字输入框", - "icon": "", - "package": "@alife/next", - "library": "Next", - "snippets": [ - { - "title": "数字输入框", - "screenshot": "https://alifd.oss-cn-hangzhou.aliyuncs.com/fusion-cool/icons/icon-light/ic_light_number-picker.png", - "schema": { - "componentName": "NumberPicker", - "props": { - "prefix": "next-", - "type": "normal", - "size": "medium", - "step": 1, - "editable": true - } - } - } - ] - }, - { - "componentName": "Radio", - "title": "单选框", - "icon": "", - "package": "@alife/next", - "library": "Next", - "snippets": [ - { - "title": "单选框", - "screenshot": "https://alifd.oss-cn-hangzhou.aliyuncs.com/fusion-cool/icons/icon-light/ic_light_radio.png", - "schema": { - "componentName": "Radio", - "props": {} - } - } - ] - }, - { - "componentName": "Radio.Group", - "title": "单选框组", - "icon": "", - "package": "@alife/next", - "library": "Next", - "snippets": [ - { - "title": "单选框组", - "screenshot": "https://alifd.oss-cn-hangzhou.aliyuncs.com/fusion-cool/icons/icon-light/ic_light_radio.png", - "schema": { - "componentName": "Radio.Group", - "props": {} - } - } - ] - }, { "componentName": "Range", "title": "区段选择器", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -14252,7 +14593,7 @@ "componentName": "Rating", "title": "评分", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -14274,7 +14615,7 @@ "componentName": "Search", "title": "搜索", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -14294,70 +14635,11 @@ } ] }, - { - "componentName": "Select", - "title": "选择器", - "icon": "", - "package": "@alife/next", - "library": "Next", - "snippets": [ - { - "title": "选择器", - "screenshot": "https://alifd.oss-cn-hangzhou.aliyuncs.com/fusion-cool/icons/icon-light/ic_light_select.png", - "schema": { - "componentName": "Select", - "props": { - "mode": "single", - "hasArrow": true, - "cacheValue": true - } - } - } - ] - }, - { - "componentName": "Select.Option", - "title": "Select.Option", - "icon": "", - "package": "@alife/next", - "library": "Next", - "snippets": [ - { - "title": "Select.Option", - "screenshot": "", - "schema": { - "componentName": "Select.Option", - "props": { - } - } - } - ] - }, - { - "componentName": "Switch", - "title": "开关组件", - "icon": "", - "package": "@alife/next", - "library": "Next", - "snippets": [ - { - "title": "开关组件", - "screenshot": "https://alifd.oss-cn-hangzhou.aliyuncs.com/fusion-cool/icons/icon-light/ic_light_switch.png", - "schema": { - "componentName": "Switch", - "props": { - "prefix": "next-", - "size": "medium" - } - } - } - ] - }, { "componentName": "TimePicker", "title": "时间选择框", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -14381,7 +14663,7 @@ "componentName": "Transfer", "title": "穿梭框", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -14402,7 +14684,7 @@ "componentName": "TreeSelect", "title": "树型选择控件", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { @@ -14427,7 +14709,7 @@ "componentName": "Upload", "title": "上传组件", "icon": "", - "package": "@alife/next", + "package": "@alifd/next", "library": "Next", "snippets": [ { diff --git a/packages/editor-setters/src/icon-setter/index.tsx b/packages/editor-setters/src/icon-setter/index.tsx index edf3b1855..0762b9ff3 100644 --- a/packages/editor-setters/src/icon-setter/index.tsx +++ b/packages/editor-setters/src/icon-setter/index.tsx @@ -64,44 +64,61 @@ const icons = [ ]; interface IconSetterProps { value: string; + type: string; defaultValue: string; placeholder: string; hasClear: boolean; - onChange: (icon: string) => undefined; + onChange: (icon: string | object) => undefined; icons: string[]; } export default class IconSetter extends PureComponent { static defaultProps = { value: undefined, + type: 'string', defaultValue: '', hasClear: true, icons: icons, placeholder: '请点击选择 Icon', - onChange: (icon: string) => undefined, + onChange: (icon: string | object) => undefined, }; state = { firstLoad: true, }; + _onChange = (icon: string) => { + const { onChange, type } = this.props; + if (type === 'string') { + onChange(icon); + } else if (type === 'node') { + onChange({ + componentName: 'Icon', + props: { + type: icon, + }, + }); + } + }; + onInputChange = (icon: string) => { - const { onChange } = this.props; - onChange(icon); + this._onChange(icon); }; onSelectIcon = (icon: string) => { - const { onChange } = this.props; - onChange(icon); + this._onChange(icon); }; render() { - const { icons, value, defaultValue, onChange, placeholder, hasClear } = this.props; + const { icons, value, defaultValue, onChange, placeholder, hasClear, type } = this.props; const { firstLoad } = this.state; - if (firstLoad && defaultValue && typeof value === 'undefined') onChange(defaultValue); - this.setState({ - firstLoad: false, - }); - const currentIcon = ; + const _value = typeof value === 'object' ? value?.props?.type : value; + if (firstLoad && defaultValue && typeof value === 'undefined') { + onChange(defaultValue); + this.setState({ + firstLoad: false, + }); + } + const currentIcon = ; const clearIcon = hasClear && ( { placeholder={placeholder} addonTextBefore={currentIcon} onChange={this.onInputChange} - value={value} + value={_value} defaultValue={defaultValue} readOnly addonTextAfter={clearIcon} @@ -141,7 +158,7 @@ export default class IconSetter extends PureComponent { >
    {icons.map((icon) => ( -
  • this.onSelectIcon(icon)}> +
  • this.onSelectIcon(icon)}>
  • ))} diff --git a/packages/editor-setters/src/index.tsx b/packages/editor-setters/src/index.tsx index 40865c956..cb4d38e6e 100644 --- a/packages/editor-setters/src/index.tsx +++ b/packages/editor-setters/src/index.tsx @@ -15,6 +15,10 @@ export const StringSetter = { defaultProps: { placeholder: '请输入', style: { maxWidth: 180 } }, title: 'StringSetter', recommend: true, + condition: (field: any) => { + const v = field.getValue(); + return typeof v === 'string'; + }, }; export const NumberSetter = NumberPicker; export class BoolSetter extends Component { @@ -38,6 +42,10 @@ export const TextAreaSetter = { defaultProps: { placeholder: '请输入', style: { maxWidth: 180 } }, title: 'TextAreaSetter', recommend: true, + condition: (field: any) => { + const v = field.getValue(); + return typeof v === 'string'; + }, }; export const DateSetter = DatePicker; export const DateYearSetter = DatePicker.YearPicker; diff --git a/packages/editor-skeleton/src/layouts/workbench.less b/packages/editor-skeleton/src/layouts/workbench.less index a5ea65a77..0ceaea4cc 100644 --- a/packages/editor-skeleton/src/layouts/workbench.less +++ b/packages/editor-skeleton/src/layouts/workbench.less @@ -13,7 +13,7 @@ --popup-border-radius: @popup-border-radius; --left-area-width: 48px; - --right-area-width: 280px; + --right-area-width: 300px; --top-area-height: 48px; --toolbar-height: 36px; --dock-pane-width: 280px; diff --git a/packages/editor-skeleton/src/transducers/parse-props.ts b/packages/editor-skeleton/src/transducers/parse-props.ts index a799b514c..0ae73b371 100644 --- a/packages/editor-skeleton/src/transducers/parse-props.ts +++ b/packages/editor-skeleton/src/transducers/parse-props.ts @@ -47,6 +47,12 @@ function propTypeToSetter(propType: PropType): SetterType { isRequired, initialValue: '', }; + case 'Json': + return { + componentName: 'JsonSetter', + isRequired, + initialValue: '', + }; case 'color': return { componentName: 'ColorSetter', @@ -88,7 +94,7 @@ function propTypeToSetter(propType: PropType): SetterType { value, }; }); - const componentName = dataSource.length > 4 ? 'SelectSetter' : 'RadioGroupSetter'; + const componentName = dataSource.length >= 4 ? 'SelectSetter' : 'RadioGroupSetter'; return { componentName, props: { dataSource }, diff --git a/packages/plugin-undo-redo/src/index.tsx b/packages/plugin-undo-redo/src/index.tsx index b3b0f604e..98bec6274 100644 --- a/packages/plugin-undo-redo/src/index.tsx +++ b/packages/plugin-undo-redo/src/index.tsx @@ -1,5 +1,5 @@ import React, { PureComponent } from 'react'; -import { Editor, Title } from '@ali/lowcode-editor-core'; +import { Editor } from '@ali/lowcode-editor-core'; import Icon from '@ali/ve-icons'; import { Button } from '@alifd/next'; import { Designer } from '@ali/lowcode-designer'; @@ -81,7 +81,7 @@ export default class UndoRedo extends PureComponent { return (