From b374af3adee39bc8293be765c5ccf3fff5922bef Mon Sep 17 00:00:00 2001 From: engvuchen <1742284391@qq.com> Date: Fri, 7 May 2021 08:05:15 +0800 Subject: [PATCH 1/2] =?UTF-8?q?A=20=E6=B7=BB=E5=8A=A0vue-docs-to-snippet?= =?UTF-8?q?=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/snippets.js | 177 ++++++++++++++ build/test-gen-snippet.js | 476 ++++++++++++++++++++++++++++++++++++++ docs/components.js | 441 +++++++++++++++++++++++++++++++++++ package.json | 3 +- 4 files changed, 1096 insertions(+), 1 deletion(-) create mode 100644 build/snippets.js create mode 100644 build/test-gen-snippet.js diff --git a/build/snippets.js b/build/snippets.js new file mode 100644 index 0000000..6183c50 --- /dev/null +++ b/build/snippets.js @@ -0,0 +1,177 @@ +const fs = require("fs"); +const componentInfoList = require("../docs/components.js"); + +const matchComponentNames = [ + "button", + "calendar", + // "origincalendar", + "chart", + "checkbox", + "container", + // "async_modal", + // "modal", + "input", + "pagination", + "processor", + "radio", + "select", + "tab", + "table", + "tag", + "text", + "textarea", + // "tips-tpl", + // "upload-item", + "upload" +]; +const componentProsDesMap = {}; + +let snippetCollection = {}; + +let matchNum = /^\d+$/; +let matchLetter = /^'|"([a-zA-Z]+|[\u4e00-\u9fa5]+)'|"$/; +let matchFunc = /^\(\) => \[\]$/; +let matchEmptyStr = /^(''|\"\")$/; +let matchEmptyArr = /^\[\]$/; +let matchBool = /^(true|false)$/; + +function parseDefaultValue(defaultValue) { + let result = false; + let matchFuncArr = [ + value => matchNum.test(value) && "number", + value => matchLetter.test(value) && "string", + value => matchFunc.test(value) && "array", + value => matchEmptyStr.test(value) && "emptyString", + value => matchEmptyArr.test(value) && "emptyArray", + value => matchBool.test(value) && "boolean" + ]; + while (matchFuncArr.length !== 0 && !result) { + let func = matchFuncArr.pop(); + if (func) { + result = func(defaultValue) || false; + } + } + + if (!result) return defaultValue; + + switch (result) { + case "number": + defaultValue = Number.parseInt(defaultValue); + break; + case "string": + defaultValue = defaultValue.replace( + /\'([a-zA-Z]+|[\u4e00-\u9fa5]+)\'/, + "$1" + ); + break; + case "array": + defaultValue = []; + break; + case "emptyString": + defaultValue = ""; + break; + case "emptyArray": + defaultValue = []; + break; + case "boolean": + defaultValue = defaultValue === "true"; + break; + } + return defaultValue; +} + +componentInfoList.forEach(currentComponentInfo => { + let { displayName, props, events, methods, slots } = currentComponentInfo; + if (!matchComponentNames.includes(displayName.toLowerCase())) return; + + let componentName = displayName.toLowerCase(); + let prefix = `test-v2-${componentName}-full`; + let desc = `@cls ${prefix}`; + let snippetConstructor = { + [desc]: { + scope: "javascript", + prefix, + description: desc, + body: [] + } + }; + let snippetConstructorBody = { + component: componentName, + id: "$1", + name: "$1", + label: "", + value: undefined, + attributes: {}, + validity: {}, + decoration: [] + }; + Object.keys(props).forEach(propsKey => { + let { description, tags, defaultValue, name } = props[propsKey]; + + // ## 检测到 tagsProperty 中包含 'ignore',退出 + let { property: tagsProperty, ignore: tagsIgnore } = tags; + if ( + tagsIgnore && + tagsIgnore.some(curItem => curItem.title === "ignore") + ) + return; + + if (!componentProsDesMap[componentName]) + componentProsDesMap[componentName] = {}; + componentProsDesMap[componentName][name] = description; + + let curDefaultValue = ""; + if (defaultValue) { + ({ value: curDefaultValue } = defaultValue); + } + + curDefaultValue = parseDefaultValue(curDefaultValue); + if (tagsProperty) { + let wrapperNameFindResult = tagsProperty.find( + curItem => curItem.name + ); + if (wrapperNameFindResult) { + let { name: wrapperName } = wrapperNameFindResult; + + if (name === "wraperClass") name = "class"; + snippetConstructorBody[wrapperName][name] = curDefaultValue; + } + } else { + curDefaultValue = parseDefaultValue(curDefaultValue); + + // ### 配置默认填写区 + if (name === "id" || name === "name") curDefaultValue = "$1"; + + snippetConstructorBody[name] = curDefaultValue; + } + }); + + let snippetBodyArr = JSON.stringify( + snippetConstructorBody, + undefined, + 2 + ).split("\n"); + let snippetBodyArrLength = snippetBodyArr.length; + for (let i = 0; i < snippetBodyArrLength; i++) { + let str = snippetBodyArr[i]; + let propsNames = Object.keys(componentProsDesMap[componentName]); + + let selectProsName = propsNames.find(curName => { + let testReg = new RegExp(`${curName}(?![a-zA-Z])`); + return testReg.test(str); + }); + if (selectProsName) { + let desc = componentProsDesMap[componentName][selectProsName]; + desc = desc.replace(/\n/g, "; "); + snippetBodyArr[i] = `${str} // ${desc}`; + } + } + + snippetConstructor[desc].body = snippetBodyArr; + Object.assign(snippetCollection, snippetConstructor); +}); + +fs.writeFileSync( + "./.vscode/snippets.code-snippets", + JSON.stringify(snippetCollection, undefined, 4) +); diff --git a/build/test-gen-snippet.js b/build/test-gen-snippet.js new file mode 100644 index 0000000..d1eb988 --- /dev/null +++ b/build/test-gen-snippet.js @@ -0,0 +1,476 @@ +let matchComponentNames = [ + "button", + "calendar", + // "origincalendar", + "chart", + "checkbox", + "container", + // "async_modal", + // "modal", + "input", + "pagination", + "processor", + "radio", + "select", + "tab", + "table", + "tag", + "text", + "textarea", + // "tips-tpl", + // "upload-item", + "upload" +]; + +var btnObj2 = { + component: "button", + id: "btn", // 组件id + name: "btn", + label: "button", // Button组件展示文案 + attributes: { + hide: false, // 控制Button组件展示/隐藏 + disabled: "", // 控制Button组件是否可点击 + clickEventName: "onButtonClick", // Button组件点击事件名称 + suffixClickEventName: "onButtonSuffixClick", // Button组件suffix点击事件名称 + type: "default", // Button组件样式类别; 可选值: default, primary, danger, link + throttleTime: 0, // Button组件点击事件间隔时间; 若设置,则会对Button点击事件进行节流处理 + loading: false, // 控制Button组件是否展示加载中的样式 + class: "", + animated: "", // 动画名称 + suffix: "" // Button组件自定义拓展HTML内容的富文本 + }, + validity: {}, + decoration: [] +}; + +var btnOriginFull = { + component: "button", + name: "btn", + id: "btn", + label: "搜索", + attributes: { + hide: false, + disabled: false, + loading: false, // 是否展示加载中的样式 + buttonType: "default", + // throttleTime: 200, // 点击事件间隔时间; clickEventName包含'submit', 内部设置为 200 + class: "", + flexItemWrap: false, + // flexJustify: 'center', // 容器居中 + animated: "", + suffix: "" + }, + events: { + clickEventName: "", + suffixClickEventName: "" + } +}; + +var calendarObj2 = { + component: "calendar", + id: "calendar", // 组件id + name: "calendar", // 组件承载数据的key + label: "", // 组件标题 + attributes: { + hide: false, // 组件是否隐藏 + disabled: "", // 组件是否禁用 // todo: + resetable: true, // 组件值是否可重置 + readonly: "", // 组件是否只读 // todo: + class: "", + animated: "", // 动画名称 + labelWidth: "", // 组件label宽度,单位为px + changeEventName: "onCalendarChange", // 组件值变更事件名称 + help: "", // 组件值补充文案 + pickTime: false, // 是否选择时分秒,若为true,则可同时选择日期与具体时分秒 + pickRange: false, // 是否选择时间区间,若为true,则提供第二个日期选择器以支持时间区间选择 + range: [] // 可选时间区间,区间外日期禁止选择 + }, + validity: { + required: "", // 组件值是否必填 + format: "" // 组件值类型; 可选值:yyyy-MM, yyyy-MM-dd, yyyy-MM-dd HH, yyyy-MM-dd HH:mm, yyyy-MM-dd HH:mm:ss + }, + decoration: [], + value: "" // 组件承载数据 +}; + +var calendarOriginFull = { + component: "calendar", + name: "calendar", + id: "calendar", + label: "", + value: "", // number|string|array + attributes: { + hide: false, + disabled: false, + resetable: true, + readonly: false, + class: "", + flexItemWrap: false, + animated: "", + // labelWidth: 100, + changeEventName: "", + help: "", + pickTime: false, // 不选择时分秒 + pickRange: false, // 不选择时间区间, + range: [] // 可选时间范围 + }, + validity: { + required: false, + format: "yyyy-MM-dd HH" + } +}; + +var chartObj = { + attributes: {}, + validity: {}, + decoration: [], + id: "", + name: "", + label: "", + items: "() => []", // todo: + value: "() => []", // todo: + hide: false, + width: 600, + categories: "", // todo: + height: 400, + wraperClass: "", // todo: + placeholder: "没有数据", + flexItemWrap: false, + animated: "", + type: "", + draggable: false, + repulsion: 5000, // todo: + help: "", // todo: 应该在 help 里 + changeEventName: '"onChartChange"', + extra: "" // todo: 这个是额外组件 +}; + +var checkboxObj = { + attributes: { + hide: false, + disabled: "", // todo: + readonly: "", + wraperClass: "", // todo: + animated: "", + labelWidth: "", + help: "", + changeEventName: "onCheckboxChange" + }, + validity: { + required: "", + format: "String" + }, + decoration: [], + id: "", + label: "", + name: "", + value: "() => []", // todo: + items: "[]", // todo: + extra: "" +}; + +var containerObj = { + attributes: { + hide: false, + wraperClass: "", // todo: + animated: "", + width: "", // todo: 用新的属性屏蔽掉默认配置? + height: "", // todo: + modal: false, + collapse: false, + deletable: false, + copyable: false, + layout: "", // todo: + flexJustify: "", + flexAlign: "", + flexWrap: "", + collapseEventName: "onContainerCollapse", + deleteEventName: "onContainerDelete", + copyEventName: "onContainerCopy", + closeEventName: "onModalClose" + }, + validity: {}, + decoration: [], + id: "", + label: "", + items: "" // todo: +}; + +var inputObj = { + attributes: { + hide: false, + placeholder: "", + disabled: "", // todo: + readonly: "", + resetable: true, + wraperClass: "", // todo: + animated: "", + labelWidth: "", + clickEventName: "onInputClick", + changeEventName: "onInputChange", + dblClickEventName: "onInputDblClick", + help: "", + size: "medium" + }, + validity: { + required: "", + format: "String", + max: "" + }, + decoration: [], + id: "", + label: "", + name: "", + value: "", + valueFilterName: "" // todo: +}; + +var paginationObj = { + attributes: {}, // todo: 为什么,attribute 属性为空? + validity: {}, + decoration: [], + pageIndex: 0, + pageSize: 10, + total: 10, + pagination: "" // todo: +}; + +var processorObj = { + attributes: { + hide: false, + disabled: "", // todo: + readonly: "", // todo: 应为 Boolean + wraperClass: "", // todo: + animated: "", + labelWidth: "", + clickEventName: "onProcessClick", + changeEventName: "onProcessChange" + }, + validity: { + required: "", // todo: + format: "String" + }, + decoration: [], + id: "", + label: "", + name: "", + value: "", + items: "[]" // todo: +}; + +var radioObj = { + attributes: { + hide: false, + disabled: "", + readonly: "", + wraperClass: "", + animated: "", + labelWidth: "", + help: "", + changeEventName: "onRadioChange" + }, + validity: { + required: "", + format: "String" + }, + decoration: [], + id: "", + label: "", + name: "", + value: "", + items: "[]" // todo: +}; + +var selectObj = { + attributes: { + hide: false, + disabled: "", // todo: + searchable: true, + multiple: false, + readonly: "", // todo: + wraperClass: "", // todo: + animated: "", + labelWidth: "", // todo: 应为number + inputEventName: "onSelectInput", + clickEventName: "onSelectClick", + changeEventName: "onSelectChange", + addable: false, + help: "" + }, + validity: { + required: "", // todo: + format: "String" // todo: 还有 Number + }, + decoration: [], + id: "", + label: "", + name: "", + value: "", + items: "[]" // todo: +}; + +var tabObj = { + attributes: { + hide: false, + disabled: "", // todo: + readonly: "", // todo: + wraperClass: "", // todo: + animated: "", + clickEventName: "onTabClick", + changeEventName: "onTabChange" + }, + validity: { + required: "", // todo: + format: "String" + }, + decoration: [], + id: "", + label: "", + name: "", + value: "", + items: "[]" +}; + +var tableObj = { + attributes: { + wraperClass: "", // todo: + animated: "", + hide: false, + placeholder: "暂无数据", + showIndex: false, + showSelection: false, + wrap: true, + filterItems: "", + filterEventName: "onTableFilter", + exportData: false, + pageIndex: 0, + pageSize: "", + pageTotal: "", + pagination: "", + autoPaging: true, + height: "", + sortEventName: "onTableSort", + collapseEventName: "onTableRowCollapse", + selectRowEventName: "onTableRowSelected", + selectAllEventName: "onTableAllSelected", + paginationEventName: "onTablePagination" + }, + validity: {}, + decoration: [], + id: "", + label: "", + value: "() => []", // todo: + items: "() => []" // todo: +}; + +var tagObj = { + attributes: {}, + validity: {}, + decoration: [], + id: "", + label: "", + name: "", + value: "", + hide: false, + placeholder: "", // todo: 应在 attributes 内的属性,溢出了 + disabled: "", + readonly: "", + wraperClass: "", // todo: + animated: "", + labelWidth: "", + changeEventName: '"onTagChange"', // todo: 这里应该修改组件文件备注 + help: "", + flexItemWrap: false, + required: "", // todo: + format: '"StringArray"', + max: "", + min: "" +}; + +var textObj = { + attributes: { + hide: false, + wraperClass: "", + animated: "", + labelWidth: "", // todo: + bold: false, + size: "small", + clickEventName: "onTextClick", + mouseEnterEventName: "onTextMouseEnter", + mouseLeaveEventName: "onTextMouseLeave", + help: "" + }, + validity: { + required: "" // todo: + }, + decoration: [], + id: "", + label: "", + name: "", + value: "", + extra: "" +}; + +var textareaObj = { + attributes: { + hide: false, + placeholder: "", + disabled: "", // todo: + readonly: "", // todo: + resetable: true, + wraperClass: "", // todo: + animated: "", + labelWidth: "", + clickEventName: "onTextareaClick", + changeEventName: "onTextareaChange", + dblClickEventName: "onTextareaDblClick", + help: "" + }, + validity: { + required: "", // todo: + format: "String", + max: "" // todo: + }, + decoration: [], + id: "", + label: "", + name: "", + value: "" +}; + +var uploadObj = { + attributes: { + hide: false, + disabled: "", + wraperClass: "", // todo: + animated: "", + labelWidth: "", // todo: + readonly: "", // todo: + clickEventName: "", + changeEventName: "onUploadChange", + help: "", + editable: true, + deletable: true, + options: "() => []", // todo: + multiple: true, + upload: "", // todo: + fileType: "image" + }, + validity: { + required: "", + format: "String", + min: 0, + max: "", // todo: + width: "", + height: "", + size: "", + accept: "() => []" // todo: + }, + decoration: [], + id: "", + label: "", + name: "", + value: "", + finishEventName: '"uploadFinish"', // todo: + uploadEventName: "" // todo: +}; diff --git a/docs/components.js b/docs/components.js index 61a726e..c7743ff 100644 --- a/docs/components.js +++ b/docs/components.js @@ -1057,6 +1057,19 @@ module.exports = [ }, "required": "" }, + "placeholder": { + "description": "无数据时的文案\n___attributes___", + "tags": {}, + "name": "placeholder", + "type": { + "name": "string" + }, + "required": "", + "defaultValue": { + "func": false, + "value": "'没有数据'" + } + }, "flexItemWrap": { "description": "若为true,当组件所在容器采用flex布局时,当前组件强制占用一行\n___attributes___", "tags": {}, @@ -2264,6 +2277,22 @@ module.exports = [ }, "required": "" }, + "valueFilterName": { + "description": "组件数据过滤函数名称,对应currentPageInstance中的Vue实例methods中的方法名", + "tags": {}, + "name": "valueFilterName", + "mixin": { + "name": "emitter" + }, + "type": { + "name": "string" + }, + "required": "", + "defaultValue": { + "func": false, + "value": "''" + } + }, "hide": { "description": "组件是否隐藏", "tags": { @@ -5039,6 +5068,330 @@ module.exports = [ } } }, + { + "displayName": "Tag", + "description": "", + "tags": {}, + "props": { + "id": { + "description": "组件id", + "tags": {}, + "name": "id", + "mixin": { + "name": "emitter" + }, + "type": { + "name": "string" + }, + "required": "" + }, + "label": { + "description": "组件标题", + "tags": {}, + "name": "label", + "mixin": { + "name": "emitter" + }, + "type": { + "name": "string" + }, + "required": "", + "defaultValue": { + "func": false, + "value": "\"\"" + } + }, + "name": { + "description": "组件承载数据的key", + "tags": {}, + "name": "name", + "mixin": { + "name": "emitter" + }, + "type": { + "name": "string" + }, + "required": "" + }, + "value": { + "description": "组件承载数据", + "tags": {}, + "name": "value", + "mixin": { + "name": "emitter" + }, + "type": { + "name": "string|array" + }, + "required": "" + }, + "hide": { + "description": "组件是否隐藏\n___attributes___", + "tags": {}, + "name": "hide", + "mixin": { + "name": "emitter" + }, + "type": { + "name": "boolean" + }, + "required": "", + "defaultValue": { + "func": false, + "value": "false" + } + }, + "placeholder": { + "description": "组件占位符\n___attributes___", + "tags": {}, + "name": "placeholder", + "mixin": { + "name": "emitter" + }, + "type": { + "name": "string" + }, + "required": "" + }, + "disabled": { + "description": "组件是否禁用\n___attributes___", + "tags": {}, + "name": "disabled", + "mixin": { + "name": "emitter" + }, + "type": { + "name": "boolean" + }, + "required": "" + }, + "readonly": { + "description": "组件是否只读\n___attributes___", + "tags": {}, + "name": "readonly", + "mixin": { + "name": "emitter" + }, + "type": { + "name": "boolean" + }, + "required": "" + }, + "wraperClass": { + "description": "组件顶层class\n___attributes___", + "tags": {}, + "name": "wraperClass", + "mixin": { + "name": "emitter" + }, + "type": { + "name": "string" + }, + "required": "" + }, + "animated": { + "description": "动画名称\n___attributes___", + "tags": {}, + "name": "animated", + "mixin": { + "name": "emitter" + }, + "type": { + "name": "string" + }, + "required": "" + }, + "labelWidth": { + "description": "组件label宽度,单位为px\n___attributes___", + "tags": {}, + "name": "labelWidth", + "mixin": { + "name": "emitter" + }, + "type": { + "name": "number" + }, + "required": "" + }, + "changeEventName": { + "description": "组件值变更事件名称\n___attributes___", + "tags": {}, + "name": "changeEventName", + "mixin": { + "name": "emitter" + }, + "type": { + "name": "string" + }, + "required": "", + "defaultValue": { + "func": false, + "value": "\"onTagChange\"" + } + }, + "help": { + "description": "组件值补充文案\n___attributes___", + "tags": {}, + "name": "help", + "mixin": { + "name": "emitter" + }, + "type": { + "name": "string" + }, + "required": "", + "defaultValue": { + "func": false, + "value": "\"\"" + } + }, + "flexItemWrap": { + "description": "若为true,当组件所在容器采用flex布局时,当前组件强制占用一行\n___attributes___", + "tags": {}, + "name": "flexItemWrap", + "mixin": { + "name": "emitter" + }, + "type": { + "name": "boolean" + }, + "required": "", + "defaultValue": { + "func": false, + "value": "false" + } + }, + "required": { + "description": "组件值是否必填\n___validity___", + "tags": {}, + "name": "required", + "mixin": { + "name": "emitter" + }, + "type": { + "name": "boolean" + }, + "required": "" + }, + "format": { + "description": "组件值类型\n可选值:String, Number\n___validity___", + "tags": {}, + "name": "format", + "mixin": { + "name": "emitter" + }, + "type": { + "name": "string" + }, + "required": "", + "defaultValue": { + "func": false, + "value": "\"StringArray\"" + } + }, + "max": { + "description": "tag的最大个数\n___validity___", + "tags": {}, + "name": "max", + "mixin": { + "name": "emitter" + }, + "type": { + "name": "number" + }, + "required": "" + }, + "min": { + "description": "tag的最小个数\n___validity___", + "tags": {}, + "name": "min", + "mixin": { + "name": "emitter" + }, + "type": { + "name": "number" + }, + "required": "" + }, + "_validityErrorMessage": { + "description": "保存validity产生的错误信息", + "tags": { + "ignore": [ + { + "description": true, + "title": "ignore" + } + ] + }, + "name": "_validityErrorMessage", + "mixin": { + "name": "emitter" + }, + "type": { + "name": "string" + }, + "required": "" + }, + "_tableData": { + "description": "", + "tags": { + "ignore": [ + { + "description": true, + "title": "ignore" + } + ] + }, + "name": "_tableData", + "mixin": { + "name": "emitter" + }, + "type": { + "name": "object" + }, + "required": "" + }, + "_parentContainerAttributes": { + "description": "保存父容器组件attributes对象", + "tags": { + "ignore": [ + { + "description": true, + "title": "ignore" + } + ] + }, + "name": "_parentContainerAttributes", + "mixin": { + "name": "emitter" + }, + "type": { + "name": "object" + }, + "required": "" + } + }, + "events": {}, + "methods": [], + "slots": { + "top": { + "description": "组件顶部的组件组合", + "bindings": {} + }, + "left": { + "description": "组件左侧的组件组合", + "bindings": {} + }, + "right": { + "description": "组件右侧的组件组合", + "bindings": {} + }, + "bottom": { + "description": "组件底部的组件组合", + "bindings": {} + } + } + }, { "displayName": "Text", "description": "", @@ -5283,6 +5636,25 @@ module.exports = [ "value": "'onTextMouseLeave'" } }, + "required": { + "description": "组件值是否必填", + "tags": { + "property": [ + { + "title": "property", + "type": { + "name": "mixed" + }, + "name": "validity" + } + ] + }, + "name": "required", + "type": { + "name": "boolean" + }, + "required": "" + }, "help": { "description": "组件值补充文案", "tags": { @@ -5311,6 +5683,26 @@ module.exports = [ }, "required": "" }, + "enableHtml": { + "description": "组件是否支持富文本展示", + "tags": { + "ignore": [ + { + "description": true, + "title": "ignore" + } + ] + }, + "name": "enableHtml", + "type": { + "name": "boolean" + }, + "required": "", + "defaultValue": { + "func": false, + "value": "false" + } + }, "_tableData": { "description": "", "tags": { @@ -6065,6 +6457,24 @@ module.exports = [ }, "required": "" }, + "finishEventName": { + "description": "", + "tags": {}, + "name": "finishEventName", + "type": { + "name": "string" + }, + "required": "" + }, + "uploadEventName": { + "description": "", + "tags": {}, + "name": "uploadEventName", + "type": { + "name": "string" + }, + "required": "" + }, "width": { "description": "", "tags": {}, @@ -6113,6 +6523,15 @@ module.exports = [ "func": false, "value": "'image'" } + }, + "accept": { + "description": "", + "tags": {}, + "name": "accept", + "type": { + "name": "array" + }, + "required": "" } }, "events": { @@ -6337,6 +6756,28 @@ module.exports = [ "value": "'onUploadChange'" } }, + "finishEventName": { + "description": "上传完成事件名称,无论上传成功还是失败,都会触发该事件\n为兼容之前版本,默认事件名称不包含on\n___attributes___", + "tags": {}, + "name": "finishEventName", + "type": { + "name": "string" + }, + "required": "", + "defaultValue": { + "func": false, + "value": "\"uploadFinish\"" + } + }, + "uploadEventName": { + "description": "自定义上传事件名称,若设置,则可在指向的方法中自定义上传逻辑\n___attributes___", + "tags": {}, + "name": "uploadEventName", + "type": { + "name": "string" + }, + "required": "" + }, "help": { "description": "组件值补充文案", "tags": { diff --git a/package.json b/package.json index 2dbddc5..d7c6d39 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "example": "cross-env NODE_ENV=development webpack-dev-server --inline --progress --config build/webpack.dev.js", "docs": "node ./build/docs.js", "build": "node ./build/script.js", - "release": "node ./build/release.js" + "release": "node ./build/release.js", + "snippets": "node ./build/snippets.js" }, "repository": { "type": "git", From 5b31ec5177a80941ba06a2e4b6485b15d3235647 Mon Sep 17 00:00:00 2001 From: engvuchen <1742284391@qq.com> Date: Sun, 13 Jun 2021 21:48:57 +0800 Subject: [PATCH 2/2] =?UTF-8?q?U=20snippet=E8=83=BD=E5=8A=9B=20=E5=AF=B9?= =?UTF-8?q?=E9=83=A8=E5=88=86=E7=BB=84=E4=BB=B6=E6=8B=93=E5=B1=95attribute?= =?UTF-8?q?s/validityy=E8=83=BD=E5=8A=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build/docs.js | 5 +- build/snippet.js | 301 ++++++++++++++++++++++++ build/snippets.js | 177 -------------- build/test-gen-snippet.js | 476 -------------------------------------- package.json | 2 +- 5 files changed, 305 insertions(+), 656 deletions(-) create mode 100644 build/snippet.js delete mode 100644 build/snippets.js delete mode 100644 build/test-gen-snippet.js diff --git a/build/docs.js b/build/docs.js index 139e3a4..ee850c7 100644 --- a/build/docs.js +++ b/build/docs.js @@ -1,6 +1,7 @@ var vueDocs = require('vue-docgen-api'); var rd = require('rd'); var fs = require('fs'); +var path = require('path'); var componentInfo = []; @@ -17,11 +18,11 @@ function deepFilter(obj, filterProperties = []) { return copy; } -rd.eachFileFilterSync('./src/components', /\.vue$/, function (f, s) { +rd.eachFileFilterSync(path.resolve(__dirname, '../src/components'), /\.vue$/, function(f, s) { let info = deepFilter(vueDocs.parse(f), ['path']); componentInfo.push(info); }); let content = 'module.exports = ' + JSON.stringify(componentInfo, undefined, 4); -fs.writeFileSync('./docs/components.js', content); +fs.writeFileSync(path.resolve(__dirname, '../docs/components.js'), content); diff --git a/build/snippet.js b/build/snippet.js new file mode 100644 index 0000000..a596533 --- /dev/null +++ b/build/snippet.js @@ -0,0 +1,301 @@ +require('./docs.js'); +console.log('成功解析组件'); + +const fs = require('fs'); +const path = require('path'); +const componentInfoList = require('../docs/components.js'); + +let childrenComponentNames = [ + // "button", + // "calendar", + 'origincalendar', + // "chart", + // "checkbox", + // "container", + // "input", + // "link", + // "vpagination", + // "processor", + // "querybuilder", + // "radio", + // "richtext", + // "select", + 'selectlist', + // "tab", + // "table", + // "tag", + // "text", + // "textarea", + // "tree", + 'upload-item', + // "upload" + 'async_modal', + 'modal', + 'tips-tpl' +]; +let supportExpandProps = ['attributes', 'validity']; + +const componentProsDesMap = {}; +let snippetCollection = {}; +let matchNum = /^\d+$/; +let matchLetter = /^'|"([a-zA-Z]+|[\u4e00-\u9fa5]+)'|"$/; +let matchFunc = /^\(\) => \[\]$/; +let matchEmptyStr = /^(''|\"\")$/; +let matchEmptyArr = /^\[\]$/; +let matchBool = /^(true|false)$/; +let pathConf = { + path: `${process.env.INIT_CWD.replace(/\\/g, '/')}/.vscode`, + file: 'snippets.code-snippets', + data: snippetCollection +}; + +function parseDefaultValue(defaultValue) { + let result = false; + let matchFuncArr = [ + value => matchNum.test(value) && 'number', + value => matchLetter.test(value) && 'string', + value => matchFunc.test(value) && 'array', + value => matchEmptyStr.test(value) && 'emptyString', + value => matchEmptyArr.test(value) && 'emptyArray', + value => matchBool.test(value) && 'boolean' + ]; + while (matchFuncArr.length !== 0 && !result) { + let func = matchFuncArr.pop(); + if (func) { + result = func(defaultValue) || false; + } + } + + if (!result) return defaultValue; + + switch (result) { + case 'number': + defaultValue = Number.parseInt(defaultValue); + break; + case 'string': + defaultValue = defaultValue.replace(/\'([a-zA-Z]+|[\u4e00-\u9fa5]+)\'/, '$1'); + break; + case 'array': + defaultValue = []; + break; + case 'emptyString': + defaultValue = ''; + break; + case 'emptyArray': + defaultValue = []; + break; + case 'boolean': + defaultValue = defaultValue === 'true'; + break; + } + return defaultValue; +} +function afterInitDirAndFile(conf) { + let { path: curPath, file: curFilePath, success: successCallBack, error: errorCallBack, data } = conf; + + let fileExistPath = path.resolve(__dirname, curPath, curFilePath); + Object.assign(conf, { file_exist_path: fileExistPath }); + + // ## 检测文件是否存在 + fs.access(fileExistPath, fs.constants.F_OK, err => { + if (!err) { + successCallBack(conf); + } else { + console.log(`${fileExistPath}不存在。已创建目录、文件。`); + + // ### 文件不存在,可能是 目录不存在,也可能是 文件不存在 + let folderPath = path.resolve(__dirname, curPath); + fs.mkdirSync(folderPath, { recursive: true }); + // 默认 flag = 'w',文件不存在会创建它 + fs.writeFileSync(path.resolve(__dirname, fileExistPath), JSON.stringify({}, undefined, 2), 'utf8', err => { + if (err) { + console.log(`${curPath} ${err}`); + } + }); + + errorCallBack(conf); + } + }); +} +function writeToProjectSnippets(conf = { path: '', file: '', data: {} }) { + afterInitDirAndFile({ + ...conf, + success(conf) { + fs.writeFile(conf.file_exist_path, JSON.stringify(conf.data, undefined, 2), 'utf8', err => { + if (err) { + console.log('writeToProjectSnippets', `${conf.path} ${err}`); + } + }); + }, + error(conf) { + writeToProjectSnippets(conf); + } + }); +} +function getWrapperNameFromDesc(desc) { + let wrapperNames = ['___attributes___', '___validity___']; + for (let i = 0; i < wrapperNames.length; i++) { + let wrapperName = wrapperNames[i]; + if (desc.includes(wrapperName)) { + return wrapperName; + } + } + return ''; +} +/** + * 为匹配属性添加备注;返回一个操作后的字符串数组 + * @param {object} conf {body: [], propsToDescMap: [] } + * @returns {array} bodyArr + */ +function addDescToMatchProp(conf = { body: [], propsToDescMap: {} }) { + let { body, propsToDescMap } = conf; + + let bodyArr = JSON.stringify(body, undefined, 2).split('\n') || []; + let bodyArrLength = bodyArr.length; + for (let i = 0; i < bodyArrLength; i++) { + let str = bodyArr[i]; + + // {id, attributes, ..} + if (propsToDescMap) { + let propsNames = Object.keys(propsToDescMap); + + let reg = /"([a-zA-Z]+)"/; + let matchPropName = propsNames.find(curName => { + // NOTE: validity 包含 id,造成干扰,属性名需要完全匹配 + let result = str.match(reg); + if (result && result[1] === curName) return true; + }); + if (matchPropName) { + let desc = propsToDescMap[matchPropName]; + desc = desc.replace(/\n/g, '; '); + bodyArr[i] = `${str} // ${desc}`; + } + } + } + + return bodyArr; +} +/** + * 从 prefix/desc 获取 snippet 基础结构 + * @param {object} conf + * @returns {object} result + */ +function getSnippetConstructor(conf = { prefix: '', desc: '' }) { + let { prefix, desc } = conf; + return { + [desc]: { + scope: ['javascript', 'vue'], + prefix, + description: desc, + body: [] + } + }; +} + +let componentPrefixes = []; +componentInfoList + .filter(curItem => !childrenComponentNames.includes(curItem.displayName.toLowerCase())) + .forEach(currentComponentInfo => { + let { displayName, props, events, methods, slots } = currentComponentInfo; + + let componentName = displayName.toLowerCase(); + let prefix = `cls-${componentName}`; + let desc = `@cls ${prefix}`; + let snippetConstructor = getSnippetConstructor({ prefix, desc }); + + let needExpand = []; + let snippetConstructorBody = { + component: componentName, + id: '$1', + name: '$1', + label: '', + value: undefined, + attributes: {}, + validity: {}, + decoration: [] + }; + if (props) { + Object.keys(props).forEach(propsKey => { + let { description, tags, defaultValue } = props[propsKey]; + + // ## 检测到 tagsProperty 中包含 'ignore',退出 + let { property: tagsProperty, ignore: tagsIgnore } = tags; + if (tagsIgnore && tagsIgnore.some(curItem => curItem.title === 'ignore')) return; + + // ## 构造属性默认值 + let curDefaultValue = ''; + if (defaultValue) { + ({ value: curDefaultValue } = defaultValue); + } + curDefaultValue = parseDefaultValue(curDefaultValue); + + // ## 从备注中获取 该属性是哪部分包裹属性(attributes/validity) + let wrapperName = getWrapperNameFromDesc(description).replace(/___/g, ''); + // ## 包裹属性可能会被写在 tag 中 + if (tagsProperty || wrapperName) { + let tagName = ''; + // ### tags 属性中包含 name 的部分,这个 name 是包裹属性名 + if (tagsProperty) { + let wrapperNameFindResult = tagsProperty.find(curItem => curItem.name); + if (wrapperNameFindResult) { + let { name: wrapperName } = wrapperNameFindResult; + tagName = wrapperName; + } + } + + wrapperName = tagName || wrapperName; + if (propsKey === 'wraperClass') propsKey = 'class'; + snippetConstructorBody[wrapperName][propsKey] = curDefaultValue; + } + + // ## 存储备注 + if (!componentProsDesMap[componentName]) componentProsDesMap[componentName] = {}; + // { input: {id: ''} } + componentProsDesMap[componentName][propsKey] = description; + + if (supportExpandProps.includes(wrapperName)) needExpand.push(wrapperName); + }); + } + + // ## 为匹配属性添加备注 - Full 版本 + snippetConstructor[desc].body = addDescToMatchProp({ + body: snippetConstructorBody, + propsToDescMap: componentProsDesMap[componentName] + }); + Object.assign(snippetCollection, snippetConstructor); + + // ## 构造/存储额外拓展的 snippet(目前仅支持 attributes/validity) + needExpand.forEach(curWrapperName => { + let newPrefix = `${prefix}-${curWrapperName}`; + let newDesc = `@cls ${newPrefix}`; + let newSnippetConstructor = getSnippetConstructor({ + prefix: newPrefix, + desc: newDesc + }); + + newSnippetConstructor[newDesc].body = addDescToMatchProp({ + body: snippetConstructorBody[curWrapperName], + propsToDescMap: componentProsDesMap[componentName] + }); + Object.assign(snippetCollection, newSnippetConstructor); + }); + + // ### 打印列表的存储 + componentPrefixes.push(prefix); + }); + +writeToProjectSnippets(pathConf); +console.log('成功写入到项目snippets'); + +const PLACEHOLDER_MAX = 2; +console.log('以下是调用指令列表:'); +console.log( + componentPrefixes + .map((curPrefix, index) => { + let num = index + 1 + ''; + let numLength = num.length; + + return `${num}${new Array(PLACEHOLDER_MAX - numLength).fill(' ').join('')}: ${curPrefix}`; + }) + .join('\n') +); diff --git a/build/snippets.js b/build/snippets.js deleted file mode 100644 index 6183c50..0000000 --- a/build/snippets.js +++ /dev/null @@ -1,177 +0,0 @@ -const fs = require("fs"); -const componentInfoList = require("../docs/components.js"); - -const matchComponentNames = [ - "button", - "calendar", - // "origincalendar", - "chart", - "checkbox", - "container", - // "async_modal", - // "modal", - "input", - "pagination", - "processor", - "radio", - "select", - "tab", - "table", - "tag", - "text", - "textarea", - // "tips-tpl", - // "upload-item", - "upload" -]; -const componentProsDesMap = {}; - -let snippetCollection = {}; - -let matchNum = /^\d+$/; -let matchLetter = /^'|"([a-zA-Z]+|[\u4e00-\u9fa5]+)'|"$/; -let matchFunc = /^\(\) => \[\]$/; -let matchEmptyStr = /^(''|\"\")$/; -let matchEmptyArr = /^\[\]$/; -let matchBool = /^(true|false)$/; - -function parseDefaultValue(defaultValue) { - let result = false; - let matchFuncArr = [ - value => matchNum.test(value) && "number", - value => matchLetter.test(value) && "string", - value => matchFunc.test(value) && "array", - value => matchEmptyStr.test(value) && "emptyString", - value => matchEmptyArr.test(value) && "emptyArray", - value => matchBool.test(value) && "boolean" - ]; - while (matchFuncArr.length !== 0 && !result) { - let func = matchFuncArr.pop(); - if (func) { - result = func(defaultValue) || false; - } - } - - if (!result) return defaultValue; - - switch (result) { - case "number": - defaultValue = Number.parseInt(defaultValue); - break; - case "string": - defaultValue = defaultValue.replace( - /\'([a-zA-Z]+|[\u4e00-\u9fa5]+)\'/, - "$1" - ); - break; - case "array": - defaultValue = []; - break; - case "emptyString": - defaultValue = ""; - break; - case "emptyArray": - defaultValue = []; - break; - case "boolean": - defaultValue = defaultValue === "true"; - break; - } - return defaultValue; -} - -componentInfoList.forEach(currentComponentInfo => { - let { displayName, props, events, methods, slots } = currentComponentInfo; - if (!matchComponentNames.includes(displayName.toLowerCase())) return; - - let componentName = displayName.toLowerCase(); - let prefix = `test-v2-${componentName}-full`; - let desc = `@cls ${prefix}`; - let snippetConstructor = { - [desc]: { - scope: "javascript", - prefix, - description: desc, - body: [] - } - }; - let snippetConstructorBody = { - component: componentName, - id: "$1", - name: "$1", - label: "", - value: undefined, - attributes: {}, - validity: {}, - decoration: [] - }; - Object.keys(props).forEach(propsKey => { - let { description, tags, defaultValue, name } = props[propsKey]; - - // ## 检测到 tagsProperty 中包含 'ignore',退出 - let { property: tagsProperty, ignore: tagsIgnore } = tags; - if ( - tagsIgnore && - tagsIgnore.some(curItem => curItem.title === "ignore") - ) - return; - - if (!componentProsDesMap[componentName]) - componentProsDesMap[componentName] = {}; - componentProsDesMap[componentName][name] = description; - - let curDefaultValue = ""; - if (defaultValue) { - ({ value: curDefaultValue } = defaultValue); - } - - curDefaultValue = parseDefaultValue(curDefaultValue); - if (tagsProperty) { - let wrapperNameFindResult = tagsProperty.find( - curItem => curItem.name - ); - if (wrapperNameFindResult) { - let { name: wrapperName } = wrapperNameFindResult; - - if (name === "wraperClass") name = "class"; - snippetConstructorBody[wrapperName][name] = curDefaultValue; - } - } else { - curDefaultValue = parseDefaultValue(curDefaultValue); - - // ### 配置默认填写区 - if (name === "id" || name === "name") curDefaultValue = "$1"; - - snippetConstructorBody[name] = curDefaultValue; - } - }); - - let snippetBodyArr = JSON.stringify( - snippetConstructorBody, - undefined, - 2 - ).split("\n"); - let snippetBodyArrLength = snippetBodyArr.length; - for (let i = 0; i < snippetBodyArrLength; i++) { - let str = snippetBodyArr[i]; - let propsNames = Object.keys(componentProsDesMap[componentName]); - - let selectProsName = propsNames.find(curName => { - let testReg = new RegExp(`${curName}(?![a-zA-Z])`); - return testReg.test(str); - }); - if (selectProsName) { - let desc = componentProsDesMap[componentName][selectProsName]; - desc = desc.replace(/\n/g, "; "); - snippetBodyArr[i] = `${str} // ${desc}`; - } - } - - snippetConstructor[desc].body = snippetBodyArr; - Object.assign(snippetCollection, snippetConstructor); -}); - -fs.writeFileSync( - "./.vscode/snippets.code-snippets", - JSON.stringify(snippetCollection, undefined, 4) -); diff --git a/build/test-gen-snippet.js b/build/test-gen-snippet.js deleted file mode 100644 index d1eb988..0000000 --- a/build/test-gen-snippet.js +++ /dev/null @@ -1,476 +0,0 @@ -let matchComponentNames = [ - "button", - "calendar", - // "origincalendar", - "chart", - "checkbox", - "container", - // "async_modal", - // "modal", - "input", - "pagination", - "processor", - "radio", - "select", - "tab", - "table", - "tag", - "text", - "textarea", - // "tips-tpl", - // "upload-item", - "upload" -]; - -var btnObj2 = { - component: "button", - id: "btn", // 组件id - name: "btn", - label: "button", // Button组件展示文案 - attributes: { - hide: false, // 控制Button组件展示/隐藏 - disabled: "", // 控制Button组件是否可点击 - clickEventName: "onButtonClick", // Button组件点击事件名称 - suffixClickEventName: "onButtonSuffixClick", // Button组件suffix点击事件名称 - type: "default", // Button组件样式类别; 可选值: default, primary, danger, link - throttleTime: 0, // Button组件点击事件间隔时间; 若设置,则会对Button点击事件进行节流处理 - loading: false, // 控制Button组件是否展示加载中的样式 - class: "", - animated: "", // 动画名称 - suffix: "" // Button组件自定义拓展HTML内容的富文本 - }, - validity: {}, - decoration: [] -}; - -var btnOriginFull = { - component: "button", - name: "btn", - id: "btn", - label: "搜索", - attributes: { - hide: false, - disabled: false, - loading: false, // 是否展示加载中的样式 - buttonType: "default", - // throttleTime: 200, // 点击事件间隔时间; clickEventName包含'submit', 内部设置为 200 - class: "", - flexItemWrap: false, - // flexJustify: 'center', // 容器居中 - animated: "", - suffix: "" - }, - events: { - clickEventName: "", - suffixClickEventName: "" - } -}; - -var calendarObj2 = { - component: "calendar", - id: "calendar", // 组件id - name: "calendar", // 组件承载数据的key - label: "", // 组件标题 - attributes: { - hide: false, // 组件是否隐藏 - disabled: "", // 组件是否禁用 // todo: - resetable: true, // 组件值是否可重置 - readonly: "", // 组件是否只读 // todo: - class: "", - animated: "", // 动画名称 - labelWidth: "", // 组件label宽度,单位为px - changeEventName: "onCalendarChange", // 组件值变更事件名称 - help: "", // 组件值补充文案 - pickTime: false, // 是否选择时分秒,若为true,则可同时选择日期与具体时分秒 - pickRange: false, // 是否选择时间区间,若为true,则提供第二个日期选择器以支持时间区间选择 - range: [] // 可选时间区间,区间外日期禁止选择 - }, - validity: { - required: "", // 组件值是否必填 - format: "" // 组件值类型; 可选值:yyyy-MM, yyyy-MM-dd, yyyy-MM-dd HH, yyyy-MM-dd HH:mm, yyyy-MM-dd HH:mm:ss - }, - decoration: [], - value: "" // 组件承载数据 -}; - -var calendarOriginFull = { - component: "calendar", - name: "calendar", - id: "calendar", - label: "", - value: "", // number|string|array - attributes: { - hide: false, - disabled: false, - resetable: true, - readonly: false, - class: "", - flexItemWrap: false, - animated: "", - // labelWidth: 100, - changeEventName: "", - help: "", - pickTime: false, // 不选择时分秒 - pickRange: false, // 不选择时间区间, - range: [] // 可选时间范围 - }, - validity: { - required: false, - format: "yyyy-MM-dd HH" - } -}; - -var chartObj = { - attributes: {}, - validity: {}, - decoration: [], - id: "", - name: "", - label: "", - items: "() => []", // todo: - value: "() => []", // todo: - hide: false, - width: 600, - categories: "", // todo: - height: 400, - wraperClass: "", // todo: - placeholder: "没有数据", - flexItemWrap: false, - animated: "", - type: "", - draggable: false, - repulsion: 5000, // todo: - help: "", // todo: 应该在 help 里 - changeEventName: '"onChartChange"', - extra: "" // todo: 这个是额外组件 -}; - -var checkboxObj = { - attributes: { - hide: false, - disabled: "", // todo: - readonly: "", - wraperClass: "", // todo: - animated: "", - labelWidth: "", - help: "", - changeEventName: "onCheckboxChange" - }, - validity: { - required: "", - format: "String" - }, - decoration: [], - id: "", - label: "", - name: "", - value: "() => []", // todo: - items: "[]", // todo: - extra: "" -}; - -var containerObj = { - attributes: { - hide: false, - wraperClass: "", // todo: - animated: "", - width: "", // todo: 用新的属性屏蔽掉默认配置? - height: "", // todo: - modal: false, - collapse: false, - deletable: false, - copyable: false, - layout: "", // todo: - flexJustify: "", - flexAlign: "", - flexWrap: "", - collapseEventName: "onContainerCollapse", - deleteEventName: "onContainerDelete", - copyEventName: "onContainerCopy", - closeEventName: "onModalClose" - }, - validity: {}, - decoration: [], - id: "", - label: "", - items: "" // todo: -}; - -var inputObj = { - attributes: { - hide: false, - placeholder: "", - disabled: "", // todo: - readonly: "", - resetable: true, - wraperClass: "", // todo: - animated: "", - labelWidth: "", - clickEventName: "onInputClick", - changeEventName: "onInputChange", - dblClickEventName: "onInputDblClick", - help: "", - size: "medium" - }, - validity: { - required: "", - format: "String", - max: "" - }, - decoration: [], - id: "", - label: "", - name: "", - value: "", - valueFilterName: "" // todo: -}; - -var paginationObj = { - attributes: {}, // todo: 为什么,attribute 属性为空? - validity: {}, - decoration: [], - pageIndex: 0, - pageSize: 10, - total: 10, - pagination: "" // todo: -}; - -var processorObj = { - attributes: { - hide: false, - disabled: "", // todo: - readonly: "", // todo: 应为 Boolean - wraperClass: "", // todo: - animated: "", - labelWidth: "", - clickEventName: "onProcessClick", - changeEventName: "onProcessChange" - }, - validity: { - required: "", // todo: - format: "String" - }, - decoration: [], - id: "", - label: "", - name: "", - value: "", - items: "[]" // todo: -}; - -var radioObj = { - attributes: { - hide: false, - disabled: "", - readonly: "", - wraperClass: "", - animated: "", - labelWidth: "", - help: "", - changeEventName: "onRadioChange" - }, - validity: { - required: "", - format: "String" - }, - decoration: [], - id: "", - label: "", - name: "", - value: "", - items: "[]" // todo: -}; - -var selectObj = { - attributes: { - hide: false, - disabled: "", // todo: - searchable: true, - multiple: false, - readonly: "", // todo: - wraperClass: "", // todo: - animated: "", - labelWidth: "", // todo: 应为number - inputEventName: "onSelectInput", - clickEventName: "onSelectClick", - changeEventName: "onSelectChange", - addable: false, - help: "" - }, - validity: { - required: "", // todo: - format: "String" // todo: 还有 Number - }, - decoration: [], - id: "", - label: "", - name: "", - value: "", - items: "[]" // todo: -}; - -var tabObj = { - attributes: { - hide: false, - disabled: "", // todo: - readonly: "", // todo: - wraperClass: "", // todo: - animated: "", - clickEventName: "onTabClick", - changeEventName: "onTabChange" - }, - validity: { - required: "", // todo: - format: "String" - }, - decoration: [], - id: "", - label: "", - name: "", - value: "", - items: "[]" -}; - -var tableObj = { - attributes: { - wraperClass: "", // todo: - animated: "", - hide: false, - placeholder: "暂无数据", - showIndex: false, - showSelection: false, - wrap: true, - filterItems: "", - filterEventName: "onTableFilter", - exportData: false, - pageIndex: 0, - pageSize: "", - pageTotal: "", - pagination: "", - autoPaging: true, - height: "", - sortEventName: "onTableSort", - collapseEventName: "onTableRowCollapse", - selectRowEventName: "onTableRowSelected", - selectAllEventName: "onTableAllSelected", - paginationEventName: "onTablePagination" - }, - validity: {}, - decoration: [], - id: "", - label: "", - value: "() => []", // todo: - items: "() => []" // todo: -}; - -var tagObj = { - attributes: {}, - validity: {}, - decoration: [], - id: "", - label: "", - name: "", - value: "", - hide: false, - placeholder: "", // todo: 应在 attributes 内的属性,溢出了 - disabled: "", - readonly: "", - wraperClass: "", // todo: - animated: "", - labelWidth: "", - changeEventName: '"onTagChange"', // todo: 这里应该修改组件文件备注 - help: "", - flexItemWrap: false, - required: "", // todo: - format: '"StringArray"', - max: "", - min: "" -}; - -var textObj = { - attributes: { - hide: false, - wraperClass: "", - animated: "", - labelWidth: "", // todo: - bold: false, - size: "small", - clickEventName: "onTextClick", - mouseEnterEventName: "onTextMouseEnter", - mouseLeaveEventName: "onTextMouseLeave", - help: "" - }, - validity: { - required: "" // todo: - }, - decoration: [], - id: "", - label: "", - name: "", - value: "", - extra: "" -}; - -var textareaObj = { - attributes: { - hide: false, - placeholder: "", - disabled: "", // todo: - readonly: "", // todo: - resetable: true, - wraperClass: "", // todo: - animated: "", - labelWidth: "", - clickEventName: "onTextareaClick", - changeEventName: "onTextareaChange", - dblClickEventName: "onTextareaDblClick", - help: "" - }, - validity: { - required: "", // todo: - format: "String", - max: "" // todo: - }, - decoration: [], - id: "", - label: "", - name: "", - value: "" -}; - -var uploadObj = { - attributes: { - hide: false, - disabled: "", - wraperClass: "", // todo: - animated: "", - labelWidth: "", // todo: - readonly: "", // todo: - clickEventName: "", - changeEventName: "onUploadChange", - help: "", - editable: true, - deletable: true, - options: "() => []", // todo: - multiple: true, - upload: "", // todo: - fileType: "image" - }, - validity: { - required: "", - format: "String", - min: 0, - max: "", // todo: - width: "", - height: "", - size: "", - accept: "() => []" // todo: - }, - decoration: [], - id: "", - label: "", - name: "", - value: "", - finishEventName: '"uploadFinish"', // todo: - uploadEventName: "" // todo: -}; diff --git a/package.json b/package.json index d7c6d39..0237366 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,7 @@ "docs": "node ./build/docs.js", "build": "node ./build/script.js", "release": "node ./build/release.js", - "snippets": "node ./build/snippets.js" + "snippet": "node ./build/snippet.js" }, "repository": { "type": "git",