@tmagic/editor 1.7.8-beta.1 → 1.7.8-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/fields/CodeSelectCol.vue_vue_type_script_setup_true_lang.js +1 -1
- package/dist/es/fields/DataSourceFieldSelect/Index.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/es/fields/StyleSetter/pro/Layout.vue_vue_type_script_setup_true_lang.js +9 -8
- package/dist/es/services/props.js +2 -1
- package/dist/es/utils/data-source/index.js +64 -63
- package/dist/es/utils/dep/worker.js +1 -1
- package/dist/es/utils/props.js +4 -4
- package/dist/tmagic-editor.umd.cjs +82 -79
- package/package.json +7 -7
- package/src/components/CodeBlockEditor.vue +2 -8
- package/src/fields/CodeSelectCol.vue +1 -1
- package/src/fields/DataSourceFieldSelect/Index.vue +7 -2
- package/src/fields/DataSourceFields.vue +4 -1
- package/src/fields/EventSelect.vue +5 -6
- package/src/fields/StyleSetter/components/BackgroundPosition.vue +2 -2
- package/src/fields/StyleSetter/pro/Layout.vue +8 -8
- package/src/services/props.ts +3 -1
- package/src/utils/data-source/index.ts +71 -73
- package/src/utils/props.ts +9 -7
- package/types/index.d.ts +197 -193
|
@@ -4659,12 +4659,12 @@
|
|
|
4659
4659
|
*/
|
|
4660
4660
|
var fillConfig = (config = [], { labelWidth = "80px", disabledDataSource = false, disabledCodeBlock = false } = {}) => {
|
|
4661
4661
|
const propsConfig = [];
|
|
4662
|
-
if (!config.find((item) => item.name === "type")) propsConfig.push({
|
|
4662
|
+
if (!config.find((item) => "name" in item && item.name === "type")) propsConfig.push({
|
|
4663
4663
|
text: "type",
|
|
4664
4664
|
name: "type",
|
|
4665
4665
|
type: "hidden"
|
|
4666
4666
|
});
|
|
4667
|
-
if (!config.find((item) => item.name === "id")) propsConfig.push({
|
|
4667
|
+
if (!config.find((item) => "name" in item && item.name === "id")) propsConfig.push({
|
|
4668
4668
|
name: "id",
|
|
4669
4669
|
text: "ID",
|
|
4670
4670
|
type: "text",
|
|
@@ -4681,11 +4681,11 @@
|
|
|
4681
4681
|
}
|
|
4682
4682
|
}
|
|
4683
4683
|
});
|
|
4684
|
-
if (!config.find((item) => item.name === "name")) propsConfig.push({
|
|
4684
|
+
if (!config.find((item) => "name" in item && item.name === "name")) propsConfig.push({
|
|
4685
4685
|
name: "name",
|
|
4686
4686
|
text: "组件名称"
|
|
4687
4687
|
});
|
|
4688
|
-
const noCodeAdvancedTabItems = advancedTabConfig.items.filter((item) => item.type !== "code-select");
|
|
4688
|
+
const noCodeAdvancedTabItems = advancedTabConfig.items.filter((item) => "type" in item && item.type !== "code-select");
|
|
4689
4689
|
if (noCodeAdvancedTabItems.length > 0 && disabledCodeBlock) advancedTabConfig.items = noCodeAdvancedTabItems;
|
|
4690
4690
|
const tabConfig = {
|
|
4691
4691
|
type: "tab",
|
|
@@ -4760,8 +4760,9 @@
|
|
|
4760
4760
|
});
|
|
4761
4761
|
}
|
|
4762
4762
|
async setPropsConfig(type, config) {
|
|
4763
|
-
let c
|
|
4763
|
+
let c;
|
|
4764
4764
|
if (typeof config === "function") c = config({ editorService: editor_default });
|
|
4765
|
+
else c = config;
|
|
4765
4766
|
this.state.propsConfigMap[(0, _tmagic_utils.toLine)(type)] = await this.fillConfig(Array.isArray(c) ? c : [c]);
|
|
4766
4767
|
}
|
|
4767
4768
|
/**
|
|
@@ -6781,72 +6782,73 @@
|
|
|
6781
6782
|
]);
|
|
6782
6783
|
//#endregion
|
|
6783
6784
|
//#region packages/editor/src/utils/data-source/index.ts
|
|
6785
|
+
var dataSourceFormConfig = {
|
|
6786
|
+
type: "tab",
|
|
6787
|
+
items: [
|
|
6788
|
+
{
|
|
6789
|
+
title: "数据定义",
|
|
6790
|
+
items: [{
|
|
6791
|
+
name: "fields",
|
|
6792
|
+
type: "data-source-fields",
|
|
6793
|
+
defaultValue: () => []
|
|
6794
|
+
}]
|
|
6795
|
+
},
|
|
6796
|
+
{
|
|
6797
|
+
title: "方法定义",
|
|
6798
|
+
items: [{
|
|
6799
|
+
name: "methods",
|
|
6800
|
+
type: "data-source-methods",
|
|
6801
|
+
defaultValue: () => []
|
|
6802
|
+
}]
|
|
6803
|
+
},
|
|
6804
|
+
{
|
|
6805
|
+
title: "事件配置",
|
|
6806
|
+
items: [{
|
|
6807
|
+
name: "events",
|
|
6808
|
+
src: "datasource",
|
|
6809
|
+
type: "event-select"
|
|
6810
|
+
}]
|
|
6811
|
+
},
|
|
6812
|
+
{
|
|
6813
|
+
title: "mock数据",
|
|
6814
|
+
items: [{
|
|
6815
|
+
name: "mocks",
|
|
6816
|
+
type: "data-source-mocks",
|
|
6817
|
+
defaultValue: () => []
|
|
6818
|
+
}]
|
|
6819
|
+
},
|
|
6820
|
+
{
|
|
6821
|
+
title: "请求参数裁剪",
|
|
6822
|
+
display: (_formState, { model }) => model.type === "http",
|
|
6823
|
+
items: [{
|
|
6824
|
+
name: "beforeRequest",
|
|
6825
|
+
type: "vs-code",
|
|
6826
|
+
parse: true,
|
|
6827
|
+
autosize: {
|
|
6828
|
+
minRows: 10,
|
|
6829
|
+
maxRows: 30
|
|
6830
|
+
}
|
|
6831
|
+
}]
|
|
6832
|
+
},
|
|
6833
|
+
{
|
|
6834
|
+
title: "响应数据裁剪",
|
|
6835
|
+
display: (_formState, { model }) => model.type === "http",
|
|
6836
|
+
items: [{
|
|
6837
|
+
name: "afterResponse",
|
|
6838
|
+
type: "vs-code",
|
|
6839
|
+
parse: true,
|
|
6840
|
+
autosize: {
|
|
6841
|
+
minRows: 10,
|
|
6842
|
+
maxRows: 30
|
|
6843
|
+
}
|
|
6844
|
+
}]
|
|
6845
|
+
}
|
|
6846
|
+
]
|
|
6847
|
+
};
|
|
6784
6848
|
var fillConfig$1 = (config) => [
|
|
6785
6849
|
...base_default(),
|
|
6786
6850
|
...config,
|
|
6787
|
-
|
|
6788
|
-
type: "tab",
|
|
6789
|
-
items: [
|
|
6790
|
-
{
|
|
6791
|
-
title: "数据定义",
|
|
6792
|
-
items: [{
|
|
6793
|
-
name: "fields",
|
|
6794
|
-
type: "data-source-fields",
|
|
6795
|
-
defaultValue: () => []
|
|
6796
|
-
}]
|
|
6797
|
-
},
|
|
6798
|
-
{
|
|
6799
|
-
title: "方法定义",
|
|
6800
|
-
items: [{
|
|
6801
|
-
name: "methods",
|
|
6802
|
-
type: "data-source-methods",
|
|
6803
|
-
defaultValue: () => []
|
|
6804
|
-
}]
|
|
6805
|
-
},
|
|
6806
|
-
{
|
|
6807
|
-
title: "事件配置",
|
|
6808
|
-
items: [{
|
|
6809
|
-
name: "events",
|
|
6810
|
-
src: "datasource",
|
|
6811
|
-
type: "event-select"
|
|
6812
|
-
}]
|
|
6813
|
-
},
|
|
6814
|
-
{
|
|
6815
|
-
title: "mock数据",
|
|
6816
|
-
items: [{
|
|
6817
|
-
name: "mocks",
|
|
6818
|
-
type: "data-source-mocks",
|
|
6819
|
-
defaultValue: () => []
|
|
6820
|
-
}]
|
|
6821
|
-
},
|
|
6822
|
-
{
|
|
6823
|
-
title: "请求参数裁剪",
|
|
6824
|
-
display: (_formState, { model }) => model.type === "http",
|
|
6825
|
-
items: [{
|
|
6826
|
-
name: "beforeRequest",
|
|
6827
|
-
type: "vs-code",
|
|
6828
|
-
parse: true,
|
|
6829
|
-
autosize: {
|
|
6830
|
-
minRows: 10,
|
|
6831
|
-
maxRows: 30
|
|
6832
|
-
}
|
|
6833
|
-
}]
|
|
6834
|
-
},
|
|
6835
|
-
{
|
|
6836
|
-
title: "响应数据裁剪",
|
|
6837
|
-
display: (_formState, { model }) => model.type === "http",
|
|
6838
|
-
items: [{
|
|
6839
|
-
name: "afterResponse",
|
|
6840
|
-
type: "vs-code",
|
|
6841
|
-
parse: true,
|
|
6842
|
-
autosize: {
|
|
6843
|
-
minRows: 10,
|
|
6844
|
-
maxRows: 30
|
|
6845
|
-
}
|
|
6846
|
-
}]
|
|
6847
|
-
}
|
|
6848
|
-
]
|
|
6849
|
-
}
|
|
6851
|
+
dataSourceFormConfig
|
|
6850
6852
|
];
|
|
6851
6853
|
var getFormConfig = (type, configs) => {
|
|
6852
6854
|
switch (type) {
|
|
@@ -12818,7 +12820,7 @@
|
|
|
12818
12820
|
var dataSource_default = new DataSource();
|
|
12819
12821
|
//#endregion
|
|
12820
12822
|
//#region packages/editor/src/utils/dep/worker.ts?worker&inline
|
|
12821
|
-
var jsContent = "(function() {\n //#region packages/schema/src/index.ts\n const NODE_CONDS_KEY = \"displayConds\";\n const NODE_DISABLE_DATA_SOURCE_KEY = \"_tmagic_node_disabled_data_source\";\n const NODE_DISABLE_CODE_BLOCK_KEY = \"_tmagic_node_disabled_code_block\";\n let HookType = /* @__PURE__ */ function(HookType) {\n /** 代码块钩子标识 */\n HookType[\"CODE\"] = \"code\";\n return HookType;\n }({});\n //#endregion\n //#region packages/utils/src/index.ts\n const isObject = (obj) => Object.prototype.toString.call(obj) === \"[object Object]\";\n const getKeysArray = (keys) => `${keys}`.replace(/\\[(\\d+)\\]/g, \".$1\").split(\".\");\n const DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX = \"ds-field::\";\n const dataSourceTemplateRegExp = /\\$\\{([\\s\\S]+?)\\}/g;\n //#endregion\n //#region packages/dep/src/types.ts\n /** 依赖收集的目标类型 */\n let DepTargetType = /* @__PURE__ */ function(DepTargetType) {\n DepTargetType[\"DEFAULT\"] = \"default\";\n /** 代码块 */\n DepTargetType[\"CODE_BLOCK\"] = \"code-block\";\n /** 数据源 */\n DepTargetType[\"DATA_SOURCE\"] = \"data-source\";\n /** 数据源方法 */\n DepTargetType[\"DATA_SOURCE_METHOD\"] = \"data-source-method\";\n /** 数据源条件 */\n DepTargetType[\"DATA_SOURCE_COND\"] = \"data-source-cond\";\n return DepTargetType;\n }({});\n //#endregion\n //#region packages/dep/src/Target.ts\n /**\n * 需要收集依赖的目标\n * 例如:一个代码块可以为一个目标\n */\n var Target = class {\n /**\n * 如何识别目标\n */\n isTarget;\n /**\n * 目标id,不可重复\n * 例如目标是代码块,则为代码块id\n */\n id;\n /**\n * 目标名称,用于显示在依赖列表中\n */\n name;\n /**\n * 不同的目标可以进行分类,例如代码块,数据源可以为两个不同的type\n */\n type = DepTargetType.DEFAULT;\n /**\n * 依赖详情\n * 实例:{ 'node_id': { name: 'node_name', keys: [ created, mounted ] } }\n */\n deps = {};\n /**\n * 是否默认收集,默认为true,当值为false时需要传入type参数给collect方法才会被收集\n */\n isCollectByDefault;\n constructor(options) {\n this.isTarget = options.isTarget;\n this.id = options.id;\n this.name = options.name;\n this.isCollectByDefault = options.isCollectByDefault ?? true;\n if (options.type) this.type = options.type;\n if (options.initialDeps) this.deps = options.initialDeps;\n }\n /**\n * 更新依赖\n * @param option 节点配置\n * @param key 哪个key配置了这个目标的id\n */\n updateDep({ id, name, key, data }) {\n const dep = this.deps[id] || {\n name,\n keys: []\n };\n dep.name = name;\n dep.data = data;\n this.deps[id] = dep;\n if (dep.keys.indexOf(key) === -1) dep.keys.push(key);\n }\n /**\n * 删除依赖\n * @param node 哪个节点的依赖需要移除,如果为空,则移除所有依赖\n * @param key 节点下哪个key需要移除,如果为空,则移除改节点下的所有依赖key\n * @returns void\n */\n removeDep(id, key) {\n if (typeof id === \"undefined\") {\n Object.keys(this.deps).forEach((depKey) => {\n delete this.deps[depKey];\n });\n return;\n }\n const dep = this.deps[id];\n if (!dep) return;\n if (key) {\n const index = dep.keys.indexOf(key);\n dep.keys.splice(index, 1);\n if (dep.keys.length === 0) delete this.deps[id];\n } else delete this.deps[id];\n }\n /**\n * 判断指定节点下的指定key是否存在在依赖列表中\n * @param node 哪个节点\n * @param key 哪个key\n * @returns boolean\n */\n hasDep(id, key) {\n const dep = this.deps[id];\n return Boolean(dep?.keys.find((d) => d === key));\n }\n destroy() {\n this.deps = {};\n }\n };\n //#endregion\n //#region packages/dep/src/utils.ts\n const createCodeBlockTarget = (id, codeBlock, initialDeps = {}) => new Target({\n type: DepTargetType.CODE_BLOCK,\n id,\n initialDeps,\n name: codeBlock.name,\n isTarget: (_key, value) => {\n if (id === value) return true;\n if (value?.hookType === HookType.CODE && Array.isArray(value.hookData)) {\n const index = value.hookData.findIndex((item) => item.codeId === id);\n return Boolean(index > -1);\n }\n return false;\n }\n });\n /**\n * ['array'] ['array', '0'] ['array', '0', 'a'] 这种返回false\n * ['array', 'a'] 这种返回true\n * @param keys\n * @param fields\n * @returns boolean\n */\n const isIncludeArrayField = (keys, fields) => {\n let f = fields;\n return keys.some((key, index) => {\n const field = f.find(({ name }) => name === key);\n f = field?.fields || [];\n return field?.type === \"array\" && /^(?!\\d+$).*$/.test(`${keys[index + 1]}`) && index < keys.length - 1;\n });\n };\n /**\n * 判断模板(value)是不是使用数据源Id(dsId),如:`xxx${dsId.field}xxx${dsId.field}`\n * @param value any\n * @param dsId string | number\n * @param hasArray boolean true: 一定要包含有需要迭代的模板; false: 一定要包含普通模板;\n * @returns boolean\n */\n const isDataSourceTemplate = (value, ds, hasArray = false) => {\n const templates = value.match(dataSourceTemplateRegExp) || [];\n if (templates.length <= 0) return false;\n const arrayFieldTemplates = [];\n const fieldTemplates = [];\n templates.forEach((tpl) => {\n const keys = getKeysArray(tpl.substring(2, tpl.length - 1));\n const dsId = keys.shift();\n if (!dsId || dsId !== ds.id) return;\n if (isIncludeArrayField(keys, ds.fields)) arrayFieldTemplates.push(tpl);\n else fieldTemplates.push(tpl);\n });\n if (hasArray) return arrayFieldTemplates.length > 0;\n return fieldTemplates.length > 0;\n };\n /**\n * 指定数据源的字符串模板,如:{ isBindDataSourceField: true, dataSourceId: 'id', template: `xxx${field}xxx`}\n * @param value any\n * @param dsId string | number\n * @returns boolean\n */\n const isSpecificDataSourceTemplate = (value, dsId) => value?.isBindDataSourceField && value.dataSourceId && value.dataSourceId === dsId && typeof value.template === \"string\";\n /**\n * 关联数据源字段,格式为 [前缀+数据源ID, 字段名]\n * 使用data-source-field-select value: 'value' 可以配置出来\n * @param value any[]\n * @param id string | number\n * @returns boolean\n */\n const isUseDataSourceField = (value, id) => {\n if (!Array.isArray(value) || typeof value[0] !== \"string\") return false;\n const [prefixId] = value;\n const prefixIndex = prefixId.indexOf(DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX);\n if (prefixIndex === -1) return false;\n return prefixId.substring(prefixIndex + DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX.length) === id;\n };\n const isDataSourceTarget = (ds, key, value, hasArray = false) => {\n if (!value || ![\"string\", \"object\"].includes(typeof value)) return false;\n if (`${key}`.startsWith(\"displayConds\")) return false;\n if (typeof value === \"string\") return isDataSourceTemplate(value, ds, hasArray);\n if (isObject(value) && value?.isBindDataSource && value.dataSourceId && value.dataSourceId === ds.id) return true;\n if (isSpecificDataSourceTemplate(value, ds.id)) return true;\n if (isUseDataSourceField(value, ds.id)) {\n const [, ...keys] = value;\n const includeArray = isIncludeArrayField(keys, ds.fields);\n if (hasArray) return includeArray;\n return !includeArray;\n }\n return false;\n };\n const isDataSourceCondTarget = (ds, key, value, hasArray = false) => {\n if (!Array.isArray(value) || !ds) return false;\n const [dsId, ...keys] = value;\n if (dsId !== ds.id || !`${key}`.startsWith(\"displayConds\")) return false;\n if (ds.fields?.find((field) => field.name === keys[0])) {\n const includeArray = isIncludeArrayField(keys, ds.fields);\n if (hasArray) return includeArray;\n return !includeArray;\n }\n return false;\n };\n const createDataSourceTarget = (ds, initialDeps = {}) => new Target({\n type: DepTargetType.DATA_SOURCE,\n id: ds.id,\n initialDeps,\n isTarget: (key, value) => isDataSourceTarget(ds, key, value)\n });\n const createDataSourceCondTarget = (ds, initialDeps = {}) => new Target({\n type: DepTargetType.DATA_SOURCE_COND,\n id: ds.id,\n initialDeps,\n isTarget: (key, value) => isDataSourceCondTarget(ds, key, value)\n });\n const createDataSourceMethodTarget = (ds, initialDeps = {}) => new Target({\n type: DepTargetType.DATA_SOURCE_METHOD,\n id: ds.id,\n initialDeps,\n isTarget: (_key, value) => {\n if (!Array.isArray(value)) return false;\n const [dsId, methodName] = value;\n if (!methodName || dsId !== ds.id) return false;\n if (ds.methods?.find((method) => method.name === methodName)) return true;\n if (ds.fields?.find((field) => field.name === methodName)) return false;\n return true;\n }\n });\n const traverseTarget = (targetsList, cb, type) => {\n for (const targets of Object.values(targetsList)) for (const target of Object.values(targets)) {\n if (type && target.type !== type) continue;\n cb(target);\n }\n };\n //#endregion\n //#region packages/dep/src/Watcher.ts\n var Watcher = class {\n targetsList = {};\n childrenProp = \"items\";\n idProp = \"id\";\n nameProp = \"name\";\n constructor(options) {\n if (options?.initialTargets) this.targetsList = options.initialTargets;\n if (options?.childrenProp) this.childrenProp = options.childrenProp;\n }\n getTargetsList() {\n return this.targetsList;\n }\n /**\n * 获取指定类型中的所有target\n * @param type 分类\n * @returns Target[]\n */\n getTargets(type = DepTargetType.DEFAULT) {\n return this.targetsList[type] || {};\n }\n /**\n * 添加新的目标\n * @param target Target\n */\n addTarget(target) {\n const targets = this.getTargets(target.type) || {};\n this.targetsList[target.type] = targets;\n targets[target.id] = target;\n }\n /**\n * 获取指定id的target\n * @param id target id\n * @returns Target\n */\n getTarget(id, type = DepTargetType.DEFAULT) {\n return this.getTargets(type)[id];\n }\n /**\n * 判断是否存在指定id的target\n * @param id target id\n * @returns boolean\n */\n hasTarget(id, type = DepTargetType.DEFAULT) {\n return Boolean(this.getTarget(id, type));\n }\n /**\n * 判断是否存在指定类型的target\n * @param type target type\n * @returns boolean\n */\n hasSpecifiedTypeTarget(type = DepTargetType.DEFAULT) {\n return Object.keys(this.getTargets(type)).length > 0;\n }\n /**\n * 删除指定id的target\n * @param id target id\n */\n removeTarget(id, type = DepTargetType.DEFAULT) {\n const targets = this.getTargets(type);\n if (targets[id]) {\n targets[id].destroy();\n delete targets[id];\n }\n }\n /**\n * 删除指定分类的所有target\n * @param type 分类\n * @returns void\n */\n removeTargets(type = DepTargetType.DEFAULT) {\n const targets = this.targetsList[type];\n if (!targets) return;\n for (const target of Object.values(targets)) target.destroy();\n delete this.targetsList[type];\n }\n /**\n * 删除所有target\n */\n clearTargets() {\n for (const key of Object.keys(this.targetsList)) delete this.targetsList[key];\n }\n /**\n * 收集依赖\n * @param nodes 需要收集的节点\n * @param deep 是否需要收集子节点\n * @param type 强制收集指定类型的依赖\n */\n collect(nodes, depExtendedData = {}, deep = false, type) {\n this.collectByCallback(nodes, type, ({ node, target }) => {\n this.removeTargetDep(target, node);\n this.collectItem(node, target, depExtendedData, deep);\n });\n }\n collectByCallback(nodes, type, cb) {\n traverseTarget(this.targetsList, (target) => {\n if (!type && !target.isCollectByDefault) return;\n for (const node of nodes) cb({\n node,\n target\n });\n }, type);\n }\n /**\n * 清除所有目标的依赖\n * @param nodes 需要清除依赖的节点\n */\n clear(nodes, type) {\n let { targetsList } = this;\n if (type) targetsList = { [type]: this.getTargets(type) };\n const clearedItemsNodeIds = [];\n traverseTarget(targetsList, (target) => {\n if (nodes) for (const node of nodes) {\n target.removeDep(node[this.idProp]);\n if (Array.isArray(node[this.childrenProp]) && node[this.childrenProp].length && !clearedItemsNodeIds.includes(node[this.idProp])) {\n clearedItemsNodeIds.push(node[this.idProp]);\n this.clear(node[this.childrenProp]);\n }\n }\n else target.removeDep();\n });\n }\n /**\n * 清除指定类型的依赖\n * @param type 类型\n * @param nodes 需要清除依赖的节点\n */\n clearByType(type, nodes) {\n this.clear(nodes, type);\n }\n collectItem(node, target, depExtendedData = {}, deep = false) {\n const dataSourceTargetTypes = [\n DepTargetType.DATA_SOURCE,\n DepTargetType.DATA_SOURCE_COND,\n DepTargetType.DATA_SOURCE_METHOD\n ];\n if (node[\"_tmagic_node_disabled_data_source\"] && dataSourceTargetTypes.includes(target.type)) return;\n if (node[\"_tmagic_node_disabled_code_block\"] && target.type === DepTargetType.CODE_BLOCK) return;\n const collectTarget = (config, prop = \"\") => {\n const doCollect = (key, value) => {\n const keyIsItems = key === this.childrenProp;\n const fullKey = prop ? `${prop}.${key}` : key;\n if (target.isTarget(fullKey, value)) target.updateDep({\n id: node[this.idProp],\n name: `${node[this.nameProp] || node[this.idProp]}`,\n data: depExtendedData,\n key: fullKey\n });\n else if (!keyIsItems && Array.isArray(value)) for (let i = 0, l = value.length; i < l; i++) {\n const item = value[i];\n if (isObject(item)) collectTarget(item, `${fullKey}[${i}]`);\n }\n else if (isObject(value)) collectTarget(value, fullKey);\n if (keyIsItems && deep && Array.isArray(value)) for (const child of value) this.collectItem(child, target, depExtendedData, deep);\n };\n for (const [key, value] of Object.entries(config)) {\n if (typeof value === \"undefined\" || value === \"\") continue;\n doCollect(key, value);\n }\n };\n collectTarget(node);\n }\n removeTargetDep(target, node, key) {\n target.removeDep(node[this.idProp], key);\n if (typeof key === \"undefined\" && Array.isArray(node[this.childrenProp]) && node[this.childrenProp].length) for (const item of node[this.childrenProp]) this.removeTargetDep(target, item, key);\n }\n };\n //#endregion\n //#region packages/editor/src/utils/logger.ts\n const error = (...args) => {};\n //#endregion\n //#region packages/editor/src/utils/dep/worker.ts\n onmessage = (e) => {\n const watcher = new Watcher({ initialTargets: {} });\n const { dsl } = e.data;\n try {\n const mApp = eval(`(${dsl})`);\n if (!mApp) postMessage({});\n watcher.clearTargets();\n if (mApp.codeBlocks) for (const [id, code] of Object.entries(mApp.codeBlocks)) watcher.addTarget(createCodeBlockTarget(id, code));\n if (mApp.dataSources) for (const ds of mApp.dataSources) {\n watcher.addTarget(createDataSourceTarget(ds, {}));\n watcher.addTarget(createDataSourceMethodTarget(ds, {}));\n watcher.addTarget(createDataSourceCondTarget(ds, {}));\n }\n watcher.collectByCallback(mApp.items, void 0, ({ node, target }) => {\n watcher.collectItem(node, target, { pageId: node.id }, true);\n });\n const data = {\n [DepTargetType.DATA_SOURCE]: {},\n [DepTargetType.DATA_SOURCE_METHOD]: {},\n [DepTargetType.DATA_SOURCE_COND]: {},\n [DepTargetType.CODE_BLOCK]: {}\n };\n traverseTarget(watcher.getTargetsList(), (target) => {\n data[target.type][target.id] = target.deps;\n });\n postMessage(data);\n } catch (e) {\n postMessage({});\n }\n };\n //#endregion\n})();\n";
|
|
12823
|
+
var jsContent = "(function() {\n //#region packages/schema/src/index.ts\n const NODE_CONDS_KEY = \"displayConds\";\n const NODE_DISABLE_DATA_SOURCE_KEY = \"_tmagic_node_disabled_data_source\";\n const NODE_DISABLE_CODE_BLOCK_KEY = \"_tmagic_node_disabled_code_block\";\n let HookType = /* @__PURE__ */ function(HookType) {\n /** 代码块钩子标识 */\n HookType[\"CODE\"] = \"code\";\n return HookType;\n }({});\n //#endregion\n //#region packages/utils/src/index.ts\n const isObject = (obj) => Object.prototype.toString.call(obj) === \"[object Object]\";\n const getKeysArray = (keys) => `${keys}`.replace(/\\[(\\d+)\\]/g, \".$1\").split(\".\");\n const DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX = \"ds-field::\";\n const dataSourceTemplateRegExp = /\\$\\{([\\s\\S]+?)\\}/g;\n //#endregion\n //#region packages/dep/src/types.ts\n /** 依赖收集的目标类型 */\n let DepTargetType = /* @__PURE__ */ function(DepTargetType) {\n DepTargetType[\"DEFAULT\"] = \"default\";\n /** 代码块 */\n DepTargetType[\"CODE_BLOCK\"] = \"code-block\";\n /** 数据源 */\n DepTargetType[\"DATA_SOURCE\"] = \"data-source\";\n /** 数据源方法 */\n DepTargetType[\"DATA_SOURCE_METHOD\"] = \"data-source-method\";\n /** 数据源条件 */\n DepTargetType[\"DATA_SOURCE_COND\"] = \"data-source-cond\";\n return DepTargetType;\n }({});\n //#endregion\n //#region packages/dep/src/Target.ts\n /**\n * 需要收集依赖的目标\n * 例如:一个代码块可以为一个目标\n */\n var Target = class {\n /**\n * 如何识别目标\n */\n isTarget;\n /**\n * 目标id,不可重复\n * 例如目标是代码块,则为代码块id\n */\n id;\n /**\n * 目标名称,用于显示在依赖列表中\n */\n name;\n /**\n * 不同的目标可以进行分类,例如代码块,数据源可以为两个不同的type\n */\n type = DepTargetType.DEFAULT;\n /**\n * 依赖详情\n * 实例:{ 'node_id': { name: 'node_name', keys: [ created, mounted ] } }\n */\n deps = {};\n /**\n * 是否默认收集,默认为true,当值为false时需要传入type参数给collect方法才会被收集\n */\n isCollectByDefault;\n constructor(options) {\n this.isTarget = options.isTarget;\n this.id = options.id;\n this.name = options.name;\n this.isCollectByDefault = options.isCollectByDefault ?? true;\n if (options.type) this.type = options.type;\n if (options.initialDeps) this.deps = options.initialDeps;\n }\n /**\n * 更新依赖\n * @param option 节点配置\n * @param key 哪个key配置了这个目标的id\n */\n updateDep({ id, name, key, data }) {\n const dep = this.deps[id] || {\n name,\n keys: []\n };\n dep.name = name;\n dep.data = data;\n this.deps[id] = dep;\n if (!dep.keys.includes(key)) dep.keys.push(key);\n }\n /**\n * 删除依赖\n * @param node 哪个节点的依赖需要移除,如果为空,则移除所有依赖\n * @param key 节点下哪个key需要移除,如果为空,则移除改节点下的所有依赖key\n * @returns void\n */\n removeDep(id, key) {\n if (typeof id === \"undefined\") {\n Object.keys(this.deps).forEach((depKey) => {\n delete this.deps[depKey];\n });\n return;\n }\n const dep = this.deps[id];\n if (!dep) return;\n if (key) {\n const index = dep.keys.indexOf(key);\n dep.keys.splice(index, 1);\n if (dep.keys.length === 0) delete this.deps[id];\n } else delete this.deps[id];\n }\n /**\n * 判断指定节点下的指定key是否存在在依赖列表中\n * @param node 哪个节点\n * @param key 哪个key\n * @returns boolean\n */\n hasDep(id, key) {\n return this.deps[id]?.keys.includes(key) ?? false;\n }\n destroy() {\n this.deps = {};\n }\n };\n //#endregion\n //#region packages/dep/src/utils.ts\n const INTEGER_REGEXP = /^\\d+$/;\n const createCodeBlockTarget = (id, codeBlock, initialDeps = {}) => new Target({\n type: DepTargetType.CODE_BLOCK,\n id,\n initialDeps,\n name: codeBlock.name,\n isTarget: (_key, value) => {\n if (id === value) return true;\n if (value?.hookType === HookType.CODE && Array.isArray(value.hookData)) return value.hookData.some((item) => item.codeId === id);\n return false;\n }\n });\n /**\n * ['array'] ['array', '0'] ['array', '0', 'a'] 这种返回false\n * ['array', 'a'] 这种返回true\n * @param keys\n * @param fields\n * @returns boolean\n */\n const isIncludeArrayField = (keys, fields) => {\n let f = fields;\n return keys.some((key, index) => {\n const field = f.find(({ name }) => name === key);\n f = field?.fields || [];\n return field?.type === \"array\" && index < keys.length - 1 && !INTEGER_REGEXP.test(keys[index + 1]);\n });\n };\n /**\n * 判断模板(value)是不是使用数据源Id(dsId),如:`xxx${dsId.field}xxx${dsId.field}`\n * @param value any\n * @param dsId string | number\n * @param hasArray boolean true: 一定要包含有需要迭代的模板; false: 一定要包含普通模板;\n * @returns boolean\n */\n const isDataSourceTemplate = (value, ds, hasArray = false) => {\n const templates = value.match(dataSourceTemplateRegExp) || [];\n if (templates.length <= 0) return false;\n for (const tpl of templates) {\n const keys = getKeysArray(tpl.substring(2, tpl.length - 1));\n const dsId = keys.shift();\n if (!dsId || dsId !== ds.id) continue;\n if (hasArray === isIncludeArrayField(keys, ds.fields)) return true;\n }\n return false;\n };\n /**\n * 指定数据源的字符串模板,如:{ isBindDataSourceField: true, dataSourceId: 'id', template: `xxx${field}xxx`}\n * @param value any\n * @param dsId string | number\n * @returns boolean\n */\n const isSpecificDataSourceTemplate = (value, dsId) => value?.isBindDataSourceField && value.dataSourceId && value.dataSourceId === dsId && typeof value.template === \"string\";\n /**\n * 关联数据源字段,格式为 [前缀+数据源ID, 字段名]\n * 使用data-source-field-select value: 'value' 可以配置出来\n * @param value any[]\n * @param id string | number\n * @returns boolean\n */\n const isUseDataSourceField = (value, id) => {\n if (!Array.isArray(value) || typeof value[0] !== \"string\") return false;\n const [prefixId] = value;\n const prefixIndex = prefixId.indexOf(DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX);\n if (prefixIndex === -1) return false;\n return prefixId.substring(prefixIndex + DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX.length) === id;\n };\n const isDataSourceTarget = (ds, key, value, hasArray = false) => {\n if (!value) return false;\n const valueType = typeof value;\n if (valueType !== \"string\" && valueType !== \"object\") return false;\n if (`${key}`.startsWith(\"displayConds\")) return false;\n if (valueType === \"string\") return isDataSourceTemplate(value, ds, hasArray);\n if (isObject(value) && value.isBindDataSource && value.dataSourceId === ds.id) return true;\n if (isSpecificDataSourceTemplate(value, ds.id)) return true;\n if (isUseDataSourceField(value, ds.id)) {\n const [, ...keys] = value;\n const includeArray = isIncludeArrayField(keys, ds.fields);\n return hasArray ? includeArray : !includeArray;\n }\n return false;\n };\n const isDataSourceCondTarget = (ds, key, value, hasArray = false) => {\n if (!Array.isArray(value) || !ds) return false;\n const [dsId, ...keys] = value;\n if (dsId !== ds.id || !`${key}`.startsWith(\"displayConds\")) return false;\n if (ds.fields?.some((field) => field.name === keys[0])) {\n const includeArray = isIncludeArrayField(keys, ds.fields);\n return hasArray ? includeArray : !includeArray;\n }\n return false;\n };\n const createDataSourceTarget = (ds, initialDeps = {}) => new Target({\n type: DepTargetType.DATA_SOURCE,\n id: ds.id,\n initialDeps,\n isTarget: (key, value) => isDataSourceTarget(ds, key, value)\n });\n const createDataSourceCondTarget = (ds, initialDeps = {}) => new Target({\n type: DepTargetType.DATA_SOURCE_COND,\n id: ds.id,\n initialDeps,\n isTarget: (key, value) => isDataSourceCondTarget(ds, key, value)\n });\n const createDataSourceMethodTarget = (ds, initialDeps = {}) => new Target({\n type: DepTargetType.DATA_SOURCE_METHOD,\n id: ds.id,\n initialDeps,\n isTarget: (_key, value) => {\n if (!Array.isArray(value)) return false;\n const [dsId, methodName] = value;\n if (!methodName || dsId !== ds.id) return false;\n if (ds.methods?.some((method) => method.name === methodName)) return true;\n if (ds.fields?.some((field) => field.name === methodName)) return false;\n return true;\n }\n });\n const traverseTarget = (targetsList, cb, type) => {\n if (type) {\n const targets = targetsList[type];\n if (targets) for (const target of Object.values(targets)) cb(target);\n return;\n }\n for (const targets of Object.values(targetsList)) for (const target of Object.values(targets)) cb(target);\n };\n //#endregion\n //#region packages/dep/src/Watcher.ts\n const DATA_SOURCE_TARGET_TYPES = new Set([\n DepTargetType.DATA_SOURCE,\n DepTargetType.DATA_SOURCE_COND,\n DepTargetType.DATA_SOURCE_METHOD\n ]);\n var Watcher = class {\n targetsList = {};\n childrenProp = \"items\";\n idProp = \"id\";\n nameProp = \"name\";\n constructor(options) {\n if (options?.initialTargets) this.targetsList = options.initialTargets;\n if (options?.childrenProp) this.childrenProp = options.childrenProp;\n }\n getTargetsList() {\n return this.targetsList;\n }\n /**\n * 获取指定类型中的所有target\n * @param type 分类\n * @returns Target[]\n */\n getTargets(type = DepTargetType.DEFAULT) {\n return this.targetsList[type] || {};\n }\n /**\n * 添加新的目标\n * @param target Target\n */\n addTarget(target) {\n const targets = this.getTargets(target.type) || {};\n this.targetsList[target.type] = targets;\n targets[target.id] = target;\n }\n /**\n * 获取指定id的target\n * @param id target id\n * @returns Target\n */\n getTarget(id, type = DepTargetType.DEFAULT) {\n return this.getTargets(type)[id];\n }\n /**\n * 判断是否存在指定id的target\n * @param id target id\n * @returns boolean\n */\n hasTarget(id, type = DepTargetType.DEFAULT) {\n return Boolean(this.getTarget(id, type));\n }\n /**\n * 判断是否存在指定类型的target\n * @param type target type\n * @returns boolean\n */\n hasSpecifiedTypeTarget(type = DepTargetType.DEFAULT) {\n return Object.keys(this.getTargets(type)).length > 0;\n }\n /**\n * 删除指定id的target\n * @param id target id\n */\n removeTarget(id, type = DepTargetType.DEFAULT) {\n const targets = this.getTargets(type);\n if (targets[id]) {\n targets[id].destroy();\n delete targets[id];\n }\n }\n /**\n * 删除指定分类的所有target\n * @param type 分类\n * @returns void\n */\n removeTargets(type = DepTargetType.DEFAULT) {\n const targets = this.targetsList[type];\n if (!targets) return;\n for (const target of Object.values(targets)) target.destroy();\n delete this.targetsList[type];\n }\n /**\n * 删除所有target\n */\n clearTargets() {\n for (const key of Object.keys(this.targetsList)) delete this.targetsList[key];\n }\n /**\n * 收集依赖\n * @param nodes 需要收集的节点\n * @param deep 是否需要收集子节点\n * @param type 强制收集指定类型的依赖\n */\n collect(nodes, depExtendedData = {}, deep = false, type) {\n this.collectByCallback(nodes, type, ({ node, target }) => {\n this.removeTargetDep(target, node);\n this.collectItem(node, target, depExtendedData, deep);\n });\n }\n collectByCallback(nodes, type, cb) {\n traverseTarget(this.targetsList, (target) => {\n if (!type && !target.isCollectByDefault) return;\n for (const node of nodes) cb({\n node,\n target\n });\n }, type);\n }\n /**\n * 清除所有目标的依赖\n * @param nodes 需要清除依赖的节点\n */\n clear(nodes, type) {\n let { targetsList } = this;\n if (type) targetsList = { [type]: this.getTargets(type) };\n const clearedItemsNodeIds = /* @__PURE__ */ new Set();\n traverseTarget(targetsList, (target) => {\n if (nodes) for (const node of nodes) {\n target.removeDep(node[this.idProp]);\n if (Array.isArray(node[this.childrenProp]) && node[this.childrenProp].length && !clearedItemsNodeIds.has(node[this.idProp])) {\n clearedItemsNodeIds.add(node[this.idProp]);\n this.clear(node[this.childrenProp]);\n }\n }\n else target.removeDep();\n });\n }\n /**\n * 清除指定类型的依赖\n * @param type 类型\n * @param nodes 需要清除依赖的节点\n */\n clearByType(type, nodes) {\n this.clear(nodes, type);\n }\n collectItem(node, target, depExtendedData = {}, deep = false) {\n if (node[\"_tmagic_node_disabled_data_source\"] && DATA_SOURCE_TARGET_TYPES.has(target.type)) return;\n if (node[\"_tmagic_node_disabled_code_block\"] && target.type === DepTargetType.CODE_BLOCK) return;\n const collectTarget = (config, prop = \"\") => {\n const doCollect = (key, value) => {\n const keyIsItems = key === this.childrenProp;\n const fullKey = prop ? `${prop}.${key}` : key;\n if (target.isTarget(fullKey, value)) target.updateDep({\n id: node[this.idProp],\n name: `${node[this.nameProp] || node[this.idProp]}`,\n data: depExtendedData,\n key: fullKey\n });\n else if (!keyIsItems && Array.isArray(value)) for (let i = 0, l = value.length; i < l; i++) {\n const item = value[i];\n if (isObject(item)) collectTarget(item, `${fullKey}[${i}]`);\n }\n else if (isObject(value)) collectTarget(value, fullKey);\n if (keyIsItems && deep && Array.isArray(value)) for (const child of value) this.collectItem(child, target, depExtendedData, deep);\n };\n for (const [key, value] of Object.entries(config)) {\n if (typeof value === \"undefined\" || value === \"\") continue;\n doCollect(key, value);\n }\n };\n collectTarget(node);\n }\n removeTargetDep(target, node, key) {\n target.removeDep(node[this.idProp], key);\n if (typeof key === \"undefined\" && Array.isArray(node[this.childrenProp]) && node[this.childrenProp].length) for (const item of node[this.childrenProp]) this.removeTargetDep(target, item, key);\n }\n };\n //#endregion\n //#region packages/editor/src/utils/logger.ts\n const error = (...args) => {};\n //#endregion\n //#region packages/editor/src/utils/dep/worker.ts\n onmessage = (e) => {\n const watcher = new Watcher({ initialTargets: {} });\n const { dsl } = e.data;\n try {\n const mApp = eval(`(${dsl})`);\n if (!mApp) postMessage({});\n watcher.clearTargets();\n if (mApp.codeBlocks) for (const [id, code] of Object.entries(mApp.codeBlocks)) watcher.addTarget(createCodeBlockTarget(id, code));\n if (mApp.dataSources) for (const ds of mApp.dataSources) {\n watcher.addTarget(createDataSourceTarget(ds, {}));\n watcher.addTarget(createDataSourceMethodTarget(ds, {}));\n watcher.addTarget(createDataSourceCondTarget(ds, {}));\n }\n watcher.collectByCallback(mApp.items, void 0, ({ node, target }) => {\n watcher.collectItem(node, target, { pageId: node.id }, true);\n });\n const data = {\n [DepTargetType.DATA_SOURCE]: {},\n [DepTargetType.DATA_SOURCE_METHOD]: {},\n [DepTargetType.DATA_SOURCE_COND]: {},\n [DepTargetType.CODE_BLOCK]: {}\n };\n traverseTarget(watcher.getTargetsList(), (target) => {\n data[target.type][target.id] = target.deps;\n });\n postMessage(data);\n } catch (e) {\n postMessage({});\n }\n };\n //#endregion\n})();\n";
|
|
12822
12824
|
var blob = typeof self !== "undefined" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", jsContent], { type: "text/javascript;charset=utf-8" });
|
|
12823
12825
|
function WorkerWrapper(options) {
|
|
12824
12826
|
let objURL;
|
|
@@ -14225,7 +14227,7 @@
|
|
|
14225
14227
|
const selectConfig = {
|
|
14226
14228
|
type: "select",
|
|
14227
14229
|
name: props.name,
|
|
14228
|
-
|
|
14230
|
+
disabled: props.disabled,
|
|
14229
14231
|
options: () => {
|
|
14230
14232
|
if (codeDsl.value) return map(codeDsl.value, (value, key) => ({
|
|
14231
14233
|
text: `${value.name}(${key})`,
|
|
@@ -15775,10 +15777,10 @@
|
|
|
15775
15777
|
if (typeof type === "function") type = type(mForm, { model: props.model });
|
|
15776
15778
|
if (type === "form") return "";
|
|
15777
15779
|
if (type === "container") return "";
|
|
15778
|
-
return type?.replace(/([A-Z])/g, "-$1").toLowerCase() || (props.config.items ? "" : "text");
|
|
15780
|
+
return type?.replace(/([A-Z])/g, "-$1").toLowerCase() || (props.config.fieldConfig && "items" in props.config.fieldConfig ? "" : "text");
|
|
15779
15781
|
});
|
|
15780
15782
|
const tagName = (0, vue.computed)(() => {
|
|
15781
|
-
const component = (0, _tmagic_form.getFormField)(type.value || "container") || (0, vue.resolveComponent)(`m-${props.config.items ? "form" : "fields"}-${type.value}`);
|
|
15783
|
+
const component = (0, _tmagic_form.getFormField)(type.value || "container") || (0, vue.resolveComponent)(`m-${props.config.fieldConfig && "items" in props.config.fieldConfig ? "form" : "fields"}-${type.value}`);
|
|
15782
15784
|
if (typeof component !== "string") return component;
|
|
15783
15785
|
return "m-fields-text";
|
|
15784
15786
|
});
|
|
@@ -17341,7 +17343,7 @@
|
|
|
17341
17343
|
emits: ["change"],
|
|
17342
17344
|
setup(__props, { emit: __emit }) {
|
|
17343
17345
|
const emit = __emit;
|
|
17344
|
-
const config = { items: [
|
|
17346
|
+
const config = (0, _tmagic_form.defineFormItem)({ items: [
|
|
17345
17347
|
{
|
|
17346
17348
|
name: "display",
|
|
17347
17349
|
text: "模式",
|
|
@@ -17404,7 +17406,7 @@
|
|
|
17404
17406
|
tooltip: "垂直方向 起点在下沿 column-reverse"
|
|
17405
17407
|
}
|
|
17406
17408
|
],
|
|
17407
|
-
display: (
|
|
17409
|
+
display: (_mForm, { model }) => model.display === "flex"
|
|
17408
17410
|
},
|
|
17409
17411
|
{
|
|
17410
17412
|
name: "justifyContent",
|
|
@@ -17439,7 +17441,7 @@
|
|
|
17439
17441
|
tooltip: "横向平分 space-around"
|
|
17440
17442
|
}
|
|
17441
17443
|
],
|
|
17442
|
-
display: (
|
|
17444
|
+
display: (_mForm, { model }) => model.display === "flex"
|
|
17443
17445
|
},
|
|
17444
17446
|
{
|
|
17445
17447
|
name: "alignItems",
|
|
@@ -17474,7 +17476,7 @@
|
|
|
17474
17476
|
tooltip: "横向平分 space-around"
|
|
17475
17477
|
}
|
|
17476
17478
|
],
|
|
17477
|
-
display: (
|
|
17479
|
+
display: (_mForm, { model }) => model.display === "flex"
|
|
17478
17480
|
},
|
|
17479
17481
|
{
|
|
17480
17482
|
name: "flexWrap",
|
|
@@ -17499,7 +17501,7 @@
|
|
|
17499
17501
|
tooltip: "第一行在下方 wrap-reverse"
|
|
17500
17502
|
}
|
|
17501
17503
|
],
|
|
17502
|
-
display: (
|
|
17504
|
+
display: (_mForm, { model }) => model.display === "flex"
|
|
17503
17505
|
},
|
|
17504
17506
|
{
|
|
17505
17507
|
type: "row",
|
|
@@ -17570,18 +17572,19 @@
|
|
|
17570
17572
|
fieldConfig: { type: "text" }
|
|
17571
17573
|
}]
|
|
17572
17574
|
}
|
|
17573
|
-
] };
|
|
17575
|
+
] });
|
|
17574
17576
|
const change = (value, eventData) => {
|
|
17575
17577
|
emit("change", value, eventData);
|
|
17576
17578
|
};
|
|
17577
17579
|
return (_ctx, _cache) => {
|
|
17578
17580
|
return (0, vue.openBlock)(), (0, vue.createElementBlock)(vue.Fragment, null, [(0, vue.createVNode)((0, vue.unref)(_tmagic_form.MContainer), {
|
|
17579
|
-
config,
|
|
17581
|
+
config: (0, vue.unref)(config),
|
|
17580
17582
|
model: __props.values,
|
|
17581
17583
|
size: __props.size,
|
|
17582
17584
|
disabled: __props.disabled,
|
|
17583
17585
|
onChange: change
|
|
17584
17586
|
}, null, 8, [
|
|
17587
|
+
"config",
|
|
17585
17588
|
"model",
|
|
17586
17589
|
"size",
|
|
17587
17590
|
"disabled"
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.7.8-beta.
|
|
2
|
+
"version": "1.7.8-beta.2",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -58,11 +58,11 @@
|
|
|
58
58
|
"moveable": "^0.53.0",
|
|
59
59
|
"serialize-javascript": "^7.0.0",
|
|
60
60
|
"sortablejs": "^1.15.6",
|
|
61
|
-
"@tmagic/design": "1.7.8-beta.
|
|
62
|
-
"@tmagic/form": "1.7.8-beta.
|
|
63
|
-
"@tmagic/utils": "1.7.8-beta.
|
|
64
|
-
"@tmagic/
|
|
65
|
-
"@tmagic/
|
|
61
|
+
"@tmagic/design": "1.7.8-beta.2",
|
|
62
|
+
"@tmagic/form": "1.7.8-beta.2",
|
|
63
|
+
"@tmagic/utils": "1.7.8-beta.2",
|
|
64
|
+
"@tmagic/stage": "1.7.8-beta.2",
|
|
65
|
+
"@tmagic/table": "1.7.8-beta.2"
|
|
66
66
|
},
|
|
67
67
|
"devDependencies": {
|
|
68
68
|
"@types/events": "^3.0.3",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
"type-fest": "^5.2.0",
|
|
77
77
|
"typescript": "^5.9.3",
|
|
78
78
|
"vue": "^3.5.24",
|
|
79
|
-
"@tmagic/core": "1.7.8-beta.
|
|
79
|
+
"@tmagic/core": "1.7.8-beta.2"
|
|
80
80
|
},
|
|
81
81
|
"peerDependenciesMeta": {
|
|
82
82
|
"typescript": {
|
|
@@ -63,13 +63,7 @@ import { computed, inject, nextTick, Ref, ref, useTemplateRef, watch } from 'vue
|
|
|
63
63
|
|
|
64
64
|
import type { CodeBlockContent } from '@tmagic/core';
|
|
65
65
|
import { TMagicButton, TMagicDialog, tMagicMessage, tMagicMessageBox, TMagicTag } from '@tmagic/design';
|
|
66
|
-
import {
|
|
67
|
-
type ContainerChangeEventData,
|
|
68
|
-
type FormConfig,
|
|
69
|
-
type FormState,
|
|
70
|
-
MFormBox,
|
|
71
|
-
type TableColumnConfig,
|
|
72
|
-
} from '@tmagic/form';
|
|
66
|
+
import { type ContainerChangeEventData, type FormConfig, type FormState, MFormBox } from '@tmagic/form';
|
|
73
67
|
|
|
74
68
|
import FloatingBox from '@editor/components/FloatingBox.vue';
|
|
75
69
|
import { useEditorContentHeight } from '@editor/hooks/use-editor-content-height';
|
|
@@ -118,7 +112,7 @@ const diffChange = () => {
|
|
|
118
112
|
difVisible.value = false;
|
|
119
113
|
};
|
|
120
114
|
|
|
121
|
-
const defaultParamColConfig
|
|
115
|
+
const defaultParamColConfig = {
|
|
122
116
|
type: 'row',
|
|
123
117
|
label: '参数类型',
|
|
124
118
|
items: [
|
|
@@ -106,13 +106,18 @@ const type = computed((): string => {
|
|
|
106
106
|
}
|
|
107
107
|
if (type === 'form') return '';
|
|
108
108
|
if (type === 'container') return '';
|
|
109
|
-
return
|
|
109
|
+
return (
|
|
110
|
+
type?.replace(/([A-Z])/g, '-$1').toLowerCase() ||
|
|
111
|
+
(props.config.fieldConfig && 'items' in props.config.fieldConfig ? '' : 'text')
|
|
112
|
+
);
|
|
110
113
|
});
|
|
111
114
|
|
|
112
115
|
const tagName = computed(() => {
|
|
113
116
|
const component =
|
|
114
117
|
getFormField(type.value || 'container') ||
|
|
115
|
-
resolveComponent(
|
|
118
|
+
resolveComponent(
|
|
119
|
+
`m-${props.config.fieldConfig && 'items' in props.config.fieldConfig ? 'form' : 'fields'}-${type.value}`,
|
|
120
|
+
);
|
|
116
121
|
if (typeof component !== 'string') return component;
|
|
117
122
|
return 'm-fields-text';
|
|
118
123
|
});
|
|
@@ -52,12 +52,15 @@ import { inject, Ref, ref } from 'vue';
|
|
|
52
52
|
import type { DataSchema } from '@tmagic/core';
|
|
53
53
|
import { TMagicButton, tMagicMessage, tMagicMessageBox } from '@tmagic/design';
|
|
54
54
|
import {
|
|
55
|
+
type CodeConfig,
|
|
55
56
|
type ContainerChangeEventData,
|
|
56
57
|
type DataSourceFieldsConfig,
|
|
57
58
|
type FieldProps,
|
|
58
59
|
type FormConfig,
|
|
59
60
|
type FormState,
|
|
60
61
|
MFormBox,
|
|
62
|
+
type NumberConfig,
|
|
63
|
+
type TextConfig,
|
|
61
64
|
} from '@tmagic/form';
|
|
62
65
|
import { type ColumnConfig, MagicTable } from '@tmagic/table';
|
|
63
66
|
import { getDefaultValueFromFields } from '@tmagic/utils';
|
|
@@ -247,7 +250,7 @@ const dataSourceFieldsConfig: FormConfig = [
|
|
|
247
250
|
{ text: 'true', value: true },
|
|
248
251
|
{ text: 'false', value: false },
|
|
249
252
|
],
|
|
250
|
-
},
|
|
253
|
+
} as unknown as CodeConfig | NumberConfig | TextConfig,
|
|
251
254
|
{
|
|
252
255
|
name: 'enable',
|
|
253
256
|
text: '是否可用',
|
|
@@ -59,7 +59,6 @@ import { ActionType } from '@tmagic/core';
|
|
|
59
59
|
import { TMagicButton } from '@tmagic/design';
|
|
60
60
|
import type {
|
|
61
61
|
CascaderOption,
|
|
62
|
-
ChildConfig,
|
|
63
62
|
CodeSelectColConfig,
|
|
64
63
|
ContainerChangeEventData,
|
|
65
64
|
DataSourceMethodSelectConfig,
|
|
@@ -90,10 +89,10 @@ const { editorService, dataSourceService, eventsService, codeBlockService, props
|
|
|
90
89
|
|
|
91
90
|
// 事件名称下拉框表单配置
|
|
92
91
|
const eventNameConfig = computed(() => {
|
|
93
|
-
const defaultEventNameConfig
|
|
92
|
+
const defaultEventNameConfig = {
|
|
94
93
|
name: 'name',
|
|
95
94
|
text: '事件',
|
|
96
|
-
type: (mForm, { formValue }: any) => {
|
|
95
|
+
type: (mForm: FormState | undefined, { formValue }: any) => {
|
|
97
96
|
if (
|
|
98
97
|
props.config.src !== 'component' ||
|
|
99
98
|
(formValue.type === 'page-fragment-container' && formValue.pageFragmentId)
|
|
@@ -227,10 +226,10 @@ const targetCompConfig = computed(() => {
|
|
|
227
226
|
|
|
228
227
|
// 联动组件动作配置
|
|
229
228
|
const compActionConfig = computed(() => {
|
|
230
|
-
const defaultCompActionConfig
|
|
229
|
+
const defaultCompActionConfig = {
|
|
231
230
|
name: 'method',
|
|
232
231
|
text: '动作',
|
|
233
|
-
type: (mForm, { model }: any) => {
|
|
232
|
+
type: (mForm: FormState | undefined, { model }: any) => {
|
|
234
233
|
const to = editorService.getNodeById(model.to);
|
|
235
234
|
|
|
236
235
|
if (to && to.type === 'page-fragment-container' && to.pageFragmentId) {
|
|
@@ -240,7 +239,7 @@ const compActionConfig = computed(() => {
|
|
|
240
239
|
return 'select';
|
|
241
240
|
},
|
|
242
241
|
checkStrictly: () => props.config.src !== 'component',
|
|
243
|
-
display: (mForm, { model }: any) => model.actionType === ActionType.COMP,
|
|
242
|
+
display: (mForm: FormState | undefined, { model }: any) => model.actionType === ActionType.COMP,
|
|
244
243
|
options: (mForm: FormState, { model }: any) => {
|
|
245
244
|
const node = editorService.getNodeById(model.to);
|
|
246
245
|
if (!node?.type) return [];
|
|
@@ -28,10 +28,10 @@
|
|
|
28
28
|
|
|
29
29
|
<script lang="ts" setup>
|
|
30
30
|
import { TMagicButton, TMagicInput } from '@tmagic/design';
|
|
31
|
-
import type { FieldProps,
|
|
31
|
+
import type { FieldProps, StyleSetterConfig } from '@tmagic/form';
|
|
32
32
|
|
|
33
33
|
const emit = defineEmits(['change']);
|
|
34
|
-
defineProps<FieldProps<
|
|
34
|
+
defineProps<FieldProps<StyleSetterConfig>>();
|
|
35
35
|
|
|
36
36
|
const horizontalList = [
|
|
37
37
|
{
|
|
@@ -12,8 +12,8 @@
|
|
|
12
12
|
<script lang="ts" setup>
|
|
13
13
|
import { markRaw } from 'vue';
|
|
14
14
|
|
|
15
|
-
import type { ContainerChangeEventData
|
|
16
|
-
import { MContainer } from '@tmagic/form';
|
|
15
|
+
import type { ContainerChangeEventData } from '@tmagic/form';
|
|
16
|
+
import { defineFormItem, MContainer } from '@tmagic/form';
|
|
17
17
|
import type { StyleSchema } from '@tmagic/schema';
|
|
18
18
|
|
|
19
19
|
import Box from '../components/Box.vue';
|
|
@@ -42,7 +42,7 @@ const emit = defineEmits<{
|
|
|
42
42
|
change: [v: string | StyleSchema, eventData: ContainerChangeEventData];
|
|
43
43
|
}>();
|
|
44
44
|
|
|
45
|
-
const config = {
|
|
45
|
+
const config = defineFormItem({
|
|
46
46
|
items: [
|
|
47
47
|
{
|
|
48
48
|
name: 'display',
|
|
@@ -74,7 +74,7 @@ const config = {
|
|
|
74
74
|
tooltip: '垂直方向 起点在下沿 column-reverse',
|
|
75
75
|
},
|
|
76
76
|
],
|
|
77
|
-
display: (
|
|
77
|
+
display: (_mForm, { model }: { model: Record<any, any> }) => model.display === 'flex',
|
|
78
78
|
},
|
|
79
79
|
{
|
|
80
80
|
name: 'justifyContent',
|
|
@@ -89,7 +89,7 @@ const config = {
|
|
|
89
89
|
{ value: 'space-between', icon: markRaw(JustifyContentSpaceBetween), tooltip: '两端对齐 space-between' },
|
|
90
90
|
{ value: 'space-around', icon: markRaw(JustifyContentSpaceAround), tooltip: '横向平分 space-around' },
|
|
91
91
|
],
|
|
92
|
-
display: (
|
|
92
|
+
display: (_mForm, { model }: { model: Record<any, any> }) => model.display === 'flex',
|
|
93
93
|
},
|
|
94
94
|
{
|
|
95
95
|
name: 'alignItems',
|
|
@@ -104,7 +104,7 @@ const config = {
|
|
|
104
104
|
{ value: 'space-between', icon: markRaw(JustifyContentSpaceBetween), tooltip: '两端对齐 space-between' },
|
|
105
105
|
{ value: 'space-around', icon: markRaw(JustifyContentSpaceAround), tooltip: '横向平分 space-around' },
|
|
106
106
|
],
|
|
107
|
-
display: (
|
|
107
|
+
display: (_mForm, { model }: { model: Record<any, any> }) => model.display === 'flex',
|
|
108
108
|
},
|
|
109
109
|
{
|
|
110
110
|
name: 'flexWrap',
|
|
@@ -117,7 +117,7 @@ const config = {
|
|
|
117
117
|
{ value: 'wrap', text: '正换行', tooltip: '第一行在上方 wrap' },
|
|
118
118
|
{ value: 'wrap-reverse', text: '逆换行', tooltip: '第一行在下方 wrap-reverse' },
|
|
119
119
|
],
|
|
120
|
-
display: (
|
|
120
|
+
display: (_mForm, { model }: { model: Record<any, any> }) => model.display === 'flex',
|
|
121
121
|
},
|
|
122
122
|
{
|
|
123
123
|
type: 'row',
|
|
@@ -180,7 +180,7 @@ const config = {
|
|
|
180
180
|
],
|
|
181
181
|
},
|
|
182
182
|
],
|
|
183
|
-
};
|
|
183
|
+
});
|
|
184
184
|
|
|
185
185
|
const change = (value: string | StyleSchema, eventData: ContainerChangeEventData) => {
|
|
186
186
|
emit('change', value, eventData);
|
package/src/services/props.ts
CHANGED
|
@@ -102,9 +102,11 @@ class Props extends BaseService {
|
|
|
102
102
|
}
|
|
103
103
|
|
|
104
104
|
public async setPropsConfig(type: string, config: FormConfig | PropsFormConfigFunction) {
|
|
105
|
-
let c
|
|
105
|
+
let c: FormConfig;
|
|
106
106
|
if (typeof config === 'function') {
|
|
107
107
|
c = config({ editorService });
|
|
108
|
+
} else {
|
|
109
|
+
c = config;
|
|
108
110
|
}
|
|
109
111
|
|
|
110
112
|
this.state.propsConfigMap[toLine(type)] = await this.fillConfig(Array.isArray(c) ? c : [c]);
|