@tmagic/editor 1.5.15 → 1.5.17

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.
@@ -5461,52 +5461,57 @@
5461
5461
  }
5462
5462
  ]
5463
5463
  };
5464
- const fillConfig$1 = (config = [], labelWidth = "80px") => [
5465
- {
5466
- type: "tab",
5467
- labelWidth,
5468
- items: [
5469
- {
5470
- title: "属性",
5471
- items: [
5472
- // 组件类型,必须要有
5473
- {
5474
- text: "type",
5475
- name: "type",
5476
- type: "hidden"
5477
- },
5478
- // 组件id,必须要有
5479
- {
5480
- name: "id",
5481
- text: "ID",
5482
- type: "text",
5483
- disabled: true,
5484
- append: {
5485
- type: "button",
5486
- text: "复制",
5487
- handler: (vm, { model }) => {
5488
- navigator.clipboard.writeText(`${model.id}`).then(() => {
5489
- designPlugin.tMagicMessage.success("已复制");
5490
- }).catch(() => {
5491
- designPlugin.tMagicMessage.error("复制失败");
5492
- });
5493
- }
5494
- }
5495
- },
5496
- {
5497
- name: "name",
5498
- text: "组件名称"
5499
- },
5500
- ...config
5501
- ]
5502
- },
5503
- { ...styleTabConfig },
5504
- { ...eventTabConfig },
5505
- { ...advancedTabConfig },
5506
- { ...displayTabConfig }
5507
- ]
5464
+ const fillConfig$1 = (config = [], labelWidth = "80px") => {
5465
+ const propsConfig = [];
5466
+ if (!config.find((item) => item.name === "type")) {
5467
+ propsConfig.push({
5468
+ text: "type",
5469
+ name: "type",
5470
+ type: "hidden"
5471
+ });
5508
5472
  }
5509
- ];
5473
+ if (!config.find((item) => item.name === "id")) {
5474
+ propsConfig.push({
5475
+ name: "id",
5476
+ text: "ID",
5477
+ type: "text",
5478
+ disabled: true,
5479
+ append: {
5480
+ type: "button",
5481
+ text: "复制",
5482
+ handler: (vm, { model }) => {
5483
+ navigator.clipboard.writeText(`${model.id}`).then(() => {
5484
+ designPlugin.tMagicMessage.success("已复制");
5485
+ }).catch(() => {
5486
+ designPlugin.tMagicMessage.error("复制失败");
5487
+ });
5488
+ }
5489
+ }
5490
+ });
5491
+ }
5492
+ if (!config.find((item) => item.name === "name")) {
5493
+ propsConfig.push({
5494
+ name: "name",
5495
+ text: "组件名称"
5496
+ });
5497
+ }
5498
+ return [
5499
+ {
5500
+ type: "tab",
5501
+ labelWidth,
5502
+ items: [
5503
+ {
5504
+ title: "属性",
5505
+ items: [...propsConfig, ...config]
5506
+ },
5507
+ { ...styleTabConfig },
5508
+ { ...eventTabConfig },
5509
+ { ...advancedTabConfig },
5510
+ { ...displayTabConfig }
5511
+ ]
5512
+ }
5513
+ ];
5514
+ };
5510
5515
 
5511
5516
  const log = (...args) => {
5512
5517
  if (process.env.NODE_ENV === "development") {
@@ -7340,36 +7345,34 @@
7340
7345
  return newNode;
7341
7346
  };
7342
7347
 
7343
- function BaseFormConfig() {
7344
- return [
7345
- {
7346
- name: "id",
7347
- type: "hidden"
7348
- },
7349
- {
7350
- name: "type",
7351
- text: "类型",
7352
- type: "hidden",
7353
- defaultValue: "base"
7354
- },
7355
- {
7356
- name: "title",
7357
- text: "名称",
7358
- rules: [
7359
- {
7360
- required: true,
7361
- message: "请输入名称"
7362
- }
7363
- ]
7364
- },
7365
- {
7366
- name: "description",
7367
- text: "描述"
7368
- }
7369
- ];
7370
- }
7348
+ const BaseFormConfig = () => formPlugin.defineFormConfig([
7349
+ {
7350
+ name: "id",
7351
+ type: "hidden"
7352
+ },
7353
+ {
7354
+ name: "type",
7355
+ text: "类型",
7356
+ type: "hidden",
7357
+ defaultValue: "base"
7358
+ },
7359
+ {
7360
+ name: "title",
7361
+ text: "名称",
7362
+ rules: [
7363
+ {
7364
+ required: true,
7365
+ message: "请输入名称"
7366
+ }
7367
+ ]
7368
+ },
7369
+ {
7370
+ name: "description",
7371
+ text: "描述"
7372
+ }
7373
+ ]);
7371
7374
 
7372
- const HttpFormConfig = [
7375
+ const HttpFormConfig = formPlugin.defineFormConfig([
7373
7376
  {
7374
7377
  name: "autoFetch",
7375
7378
  text: "自动请求",
@@ -7428,7 +7431,7 @@
7428
7431
  }
7429
7432
  ]
7430
7433
  }
7431
- ];
7434
+ ]);
7432
7435
 
7433
7436
  const fillConfig = (config) => [
7434
7437
  ...BaseFormConfig(),
@@ -18735,6 +18738,34 @@
18735
18738
  }
18736
18739
  const dataSourceService = new DataSource();
18737
18740
 
18741
+ const jsContent = "(function () {\n 'use strict';\n\n var events = {exports: {}};\n\n var hasRequiredEvents;\n\n function requireEvents () {\n \tif (hasRequiredEvents) return events.exports;\n \thasRequiredEvents = 1;\n\n \tvar R = typeof Reflect === 'object' ? Reflect : null;\n \tvar ReflectApply = R && typeof R.apply === 'function'\n \t ? R.apply\n \t : function ReflectApply(target, receiver, args) {\n \t return Function.prototype.apply.call(target, receiver, args);\n \t };\n\n \tvar ReflectOwnKeys;\n \tif (R && typeof R.ownKeys === 'function') {\n \t ReflectOwnKeys = R.ownKeys;\n \t} else if (Object.getOwnPropertySymbols) {\n \t ReflectOwnKeys = function ReflectOwnKeys(target) {\n \t return Object.getOwnPropertyNames(target)\n \t .concat(Object.getOwnPropertySymbols(target));\n \t };\n \t} else {\n \t ReflectOwnKeys = function ReflectOwnKeys(target) {\n \t return Object.getOwnPropertyNames(target);\n \t };\n \t}\n\n \tfunction ProcessEmitWarning(warning) {\n \t if (console && console.warn) console.warn(warning);\n \t}\n\n \tvar NumberIsNaN = Number.isNaN || function NumberIsNaN(value) {\n \t return value !== value;\n \t};\n\n \tfunction EventEmitter() {\n \t EventEmitter.init.call(this);\n \t}\n \tevents.exports = EventEmitter;\n \tevents.exports.once = once;\n\n \t// Backwards-compat with node 0.10.x\n \tEventEmitter.EventEmitter = EventEmitter;\n\n \tEventEmitter.prototype._events = undefined;\n \tEventEmitter.prototype._eventsCount = 0;\n \tEventEmitter.prototype._maxListeners = undefined;\n\n \t// By default EventEmitters will print a warning if more than 10 listeners are\n \t// added to it. This is a useful default which helps finding memory leaks.\n \tvar defaultMaxListeners = 10;\n\n \tfunction checkListener(listener) {\n \t if (typeof listener !== 'function') {\n \t throw new TypeError('The \"listener\" argument must be of type Function. Received type ' + typeof listener);\n \t }\n \t}\n\n \tObject.defineProperty(EventEmitter, 'defaultMaxListeners', {\n \t enumerable: true,\n \t get: function() {\n \t return defaultMaxListeners;\n \t },\n \t set: function(arg) {\n \t if (typeof arg !== 'number' || arg < 0 || NumberIsNaN(arg)) {\n \t throw new RangeError('The value of \"defaultMaxListeners\" is out of range. It must be a non-negative number. Received ' + arg + '.');\n \t }\n \t defaultMaxListeners = arg;\n \t }\n \t});\n\n \tEventEmitter.init = function() {\n\n \t if (this._events === undefined ||\n \t this._events === Object.getPrototypeOf(this)._events) {\n \t this._events = Object.create(null);\n \t this._eventsCount = 0;\n \t }\n\n \t this._maxListeners = this._maxListeners || undefined;\n \t};\n\n \t// Obviously not all Emitters should be limited to 10. This function allows\n \t// that to be increased. Set to zero for unlimited.\n \tEventEmitter.prototype.setMaxListeners = function setMaxListeners(n) {\n \t if (typeof n !== 'number' || n < 0 || NumberIsNaN(n)) {\n \t throw new RangeError('The value of \"n\" is out of range. It must be a non-negative number. Received ' + n + '.');\n \t }\n \t this._maxListeners = n;\n \t return this;\n \t};\n\n \tfunction _getMaxListeners(that) {\n \t if (that._maxListeners === undefined)\n \t return EventEmitter.defaultMaxListeners;\n \t return that._maxListeners;\n \t}\n\n \tEventEmitter.prototype.getMaxListeners = function getMaxListeners() {\n \t return _getMaxListeners(this);\n \t};\n\n \tEventEmitter.prototype.emit = function emit(type) {\n \t var args = [];\n \t for (var i = 1; i < arguments.length; i++) args.push(arguments[i]);\n \t var doError = (type === 'error');\n\n \t var events = this._events;\n \t if (events !== undefined)\n \t doError = (doError && events.error === undefined);\n \t else if (!doError)\n \t return false;\n\n \t // If there is no 'error' event listener then throw.\n \t if (doError) {\n \t var er;\n \t if (args.length > 0)\n \t er = args[0];\n \t if (er instanceof Error) {\n \t // Note: The comments on the `throw` lines are intentional, they show\n \t // up in Node's output if this results in an unhandled exception.\n \t throw er; // Unhandled 'error' event\n \t }\n \t // At least give some kind of context to the user\n \t var err = new Error('Unhandled error.' + (er ? ' (' + er.message + ')' : ''));\n \t err.context = er;\n \t throw err; // Unhandled 'error' event\n \t }\n\n \t var handler = events[type];\n\n \t if (handler === undefined)\n \t return false;\n\n \t if (typeof handler === 'function') {\n \t ReflectApply(handler, this, args);\n \t } else {\n \t var len = handler.length;\n \t var listeners = arrayClone(handler, len);\n \t for (var i = 0; i < len; ++i)\n \t ReflectApply(listeners[i], this, args);\n \t }\n\n \t return true;\n \t};\n\n \tfunction _addListener(target, type, listener, prepend) {\n \t var m;\n \t var events;\n \t var existing;\n\n \t checkListener(listener);\n\n \t events = target._events;\n \t if (events === undefined) {\n \t events = target._events = Object.create(null);\n \t target._eventsCount = 0;\n \t } else {\n \t // To avoid recursion in the case that type === \"newListener\"! Before\n \t // adding it to the listeners, first emit \"newListener\".\n \t if (events.newListener !== undefined) {\n \t target.emit('newListener', type,\n \t listener.listener ? listener.listener : listener);\n\n \t // Re-assign `events` because a newListener handler could have caused the\n \t // this._events to be assigned to a new object\n \t events = target._events;\n \t }\n \t existing = events[type];\n \t }\n\n \t if (existing === undefined) {\n \t // Optimize the case of one listener. Don't need the extra array object.\n \t existing = events[type] = listener;\n \t ++target._eventsCount;\n \t } else {\n \t if (typeof existing === 'function') {\n \t // Adding the second element, need to change to array.\n \t existing = events[type] =\n \t prepend ? [listener, existing] : [existing, listener];\n \t // If we've already got an array, just append.\n \t } else if (prepend) {\n \t existing.unshift(listener);\n \t } else {\n \t existing.push(listener);\n \t }\n\n \t // Check for listener leak\n \t m = _getMaxListeners(target);\n \t if (m > 0 && existing.length > m && !existing.warned) {\n \t existing.warned = true;\n \t // No error code for this since it is a Warning\n \t // eslint-disable-next-line no-restricted-syntax\n \t var w = new Error('Possible EventEmitter memory leak detected. ' +\n \t existing.length + ' ' + String(type) + ' listeners ' +\n \t 'added. Use emitter.setMaxListeners() to ' +\n \t 'increase limit');\n \t w.name = 'MaxListenersExceededWarning';\n \t w.emitter = target;\n \t w.type = type;\n \t w.count = existing.length;\n \t ProcessEmitWarning(w);\n \t }\n \t }\n\n \t return target;\n \t}\n\n \tEventEmitter.prototype.addListener = function addListener(type, listener) {\n \t return _addListener(this, type, listener, false);\n \t};\n\n \tEventEmitter.prototype.on = EventEmitter.prototype.addListener;\n\n \tEventEmitter.prototype.prependListener =\n \t function prependListener(type, listener) {\n \t return _addListener(this, type, listener, true);\n \t };\n\n \tfunction onceWrapper() {\n \t if (!this.fired) {\n \t this.target.removeListener(this.type, this.wrapFn);\n \t this.fired = true;\n \t if (arguments.length === 0)\n \t return this.listener.call(this.target);\n \t return this.listener.apply(this.target, arguments);\n \t }\n \t}\n\n \tfunction _onceWrap(target, type, listener) {\n \t var state = { fired: false, wrapFn: undefined, target: target, type: type, listener: listener };\n \t var wrapped = onceWrapper.bind(state);\n \t wrapped.listener = listener;\n \t state.wrapFn = wrapped;\n \t return wrapped;\n \t}\n\n \tEventEmitter.prototype.once = function once(type, listener) {\n \t checkListener(listener);\n \t this.on(type, _onceWrap(this, type, listener));\n \t return this;\n \t};\n\n \tEventEmitter.prototype.prependOnceListener =\n \t function prependOnceListener(type, listener) {\n \t checkListener(listener);\n \t this.prependListener(type, _onceWrap(this, type, listener));\n \t return this;\n \t };\n\n \t// Emits a 'removeListener' event if and only if the listener was removed.\n \tEventEmitter.prototype.removeListener =\n \t function removeListener(type, listener) {\n \t var list, events, position, i, originalListener;\n\n \t checkListener(listener);\n\n \t events = this._events;\n \t if (events === undefined)\n \t return this;\n\n \t list = events[type];\n \t if (list === undefined)\n \t return this;\n\n \t if (list === listener || list.listener === listener) {\n \t if (--this._eventsCount === 0)\n \t this._events = Object.create(null);\n \t else {\n \t delete events[type];\n \t if (events.removeListener)\n \t this.emit('removeListener', type, list.listener || listener);\n \t }\n \t } else if (typeof list !== 'function') {\n \t position = -1;\n\n \t for (i = list.length - 1; i >= 0; i--) {\n \t if (list[i] === listener || list[i].listener === listener) {\n \t originalListener = list[i].listener;\n \t position = i;\n \t break;\n \t }\n \t }\n\n \t if (position < 0)\n \t return this;\n\n \t if (position === 0)\n \t list.shift();\n \t else {\n \t spliceOne(list, position);\n \t }\n\n \t if (list.length === 1)\n \t events[type] = list[0];\n\n \t if (events.removeListener !== undefined)\n \t this.emit('removeListener', type, originalListener || listener);\n \t }\n\n \t return this;\n \t };\n\n \tEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\n\n \tEventEmitter.prototype.removeAllListeners =\n \t function removeAllListeners(type) {\n \t var listeners, events, i;\n\n \t events = this._events;\n \t if (events === undefined)\n \t return this;\n\n \t // not listening for removeListener, no need to emit\n \t if (events.removeListener === undefined) {\n \t if (arguments.length === 0) {\n \t this._events = Object.create(null);\n \t this._eventsCount = 0;\n \t } else if (events[type] !== undefined) {\n \t if (--this._eventsCount === 0)\n \t this._events = Object.create(null);\n \t else\n \t delete events[type];\n \t }\n \t return this;\n \t }\n\n \t // emit removeListener for all listeners on all events\n \t if (arguments.length === 0) {\n \t var keys = Object.keys(events);\n \t var key;\n \t for (i = 0; i < keys.length; ++i) {\n \t key = keys[i];\n \t if (key === 'removeListener') continue;\n \t this.removeAllListeners(key);\n \t }\n \t this.removeAllListeners('removeListener');\n \t this._events = Object.create(null);\n \t this._eventsCount = 0;\n \t return this;\n \t }\n\n \t listeners = events[type];\n\n \t if (typeof listeners === 'function') {\n \t this.removeListener(type, listeners);\n \t } else if (listeners !== undefined) {\n \t // LIFO order\n \t for (i = listeners.length - 1; i >= 0; i--) {\n \t this.removeListener(type, listeners[i]);\n \t }\n \t }\n\n \t return this;\n \t };\n\n \tfunction _listeners(target, type, unwrap) {\n \t var events = target._events;\n\n \t if (events === undefined)\n \t return [];\n\n \t var evlistener = events[type];\n \t if (evlistener === undefined)\n \t return [];\n\n \t if (typeof evlistener === 'function')\n \t return unwrap ? [evlistener.listener || evlistener] : [evlistener];\n\n \t return unwrap ?\n \t unwrapListeners(evlistener) : arrayClone(evlistener, evlistener.length);\n \t}\n\n \tEventEmitter.prototype.listeners = function listeners(type) {\n \t return _listeners(this, type, true);\n \t};\n\n \tEventEmitter.prototype.rawListeners = function rawListeners(type) {\n \t return _listeners(this, type, false);\n \t};\n\n \tEventEmitter.listenerCount = function(emitter, type) {\n \t if (typeof emitter.listenerCount === 'function') {\n \t return emitter.listenerCount(type);\n \t } else {\n \t return listenerCount.call(emitter, type);\n \t }\n \t};\n\n \tEventEmitter.prototype.listenerCount = listenerCount;\n \tfunction listenerCount(type) {\n \t var events = this._events;\n\n \t if (events !== undefined) {\n \t var evlistener = events[type];\n\n \t if (typeof evlistener === 'function') {\n \t return 1;\n \t } else if (evlistener !== undefined) {\n \t return evlistener.length;\n \t }\n \t }\n\n \t return 0;\n \t}\n\n \tEventEmitter.prototype.eventNames = function eventNames() {\n \t return this._eventsCount > 0 ? ReflectOwnKeys(this._events) : [];\n \t};\n\n \tfunction arrayClone(arr, n) {\n \t var copy = new Array(n);\n \t for (var i = 0; i < n; ++i)\n \t copy[i] = arr[i];\n \t return copy;\n \t}\n\n \tfunction spliceOne(list, index) {\n \t for (; index + 1 < list.length; index++)\n \t list[index] = list[index + 1];\n \t list.pop();\n \t}\n\n \tfunction unwrapListeners(arr) {\n \t var ret = new Array(arr.length);\n \t for (var i = 0; i < ret.length; ++i) {\n \t ret[i] = arr[i].listener || arr[i];\n \t }\n \t return ret;\n \t}\n\n \tfunction once(emitter, name) {\n \t return new Promise(function (resolve, reject) {\n \t function errorListener(err) {\n \t emitter.removeListener(name, resolver);\n \t reject(err);\n \t }\n\n \t function resolver() {\n \t if (typeof emitter.removeListener === 'function') {\n \t emitter.removeListener('error', errorListener);\n \t }\n \t resolve([].slice.call(arguments));\n \t }\n \t eventTargetAgnosticAddListener(emitter, name, resolver, { once: true });\n \t if (name !== 'error') {\n \t addErrorHandlerIfEventEmitter(emitter, errorListener, { once: true });\n \t }\n \t });\n \t}\n\n \tfunction addErrorHandlerIfEventEmitter(emitter, handler, flags) {\n \t if (typeof emitter.on === 'function') {\n \t eventTargetAgnosticAddListener(emitter, 'error', handler, flags);\n \t }\n \t}\n\n \tfunction eventTargetAgnosticAddListener(emitter, name, listener, flags) {\n \t if (typeof emitter.on === 'function') {\n \t if (flags.once) {\n \t emitter.once(name, listener);\n \t } else {\n \t emitter.on(name, listener);\n \t }\n \t } else if (typeof emitter.addEventListener === 'function') {\n \t // EventTarget does not have `error` event semantics like Node\n \t // EventEmitters, we do not listen for `error` events here.\n \t emitter.addEventListener(name, function wrapListener(arg) {\n \t // IE does not have builtin `{ once: true }` support so we\n \t // have to do it manually.\n \t if (flags.once) {\n \t emitter.removeEventListener(name, wrapListener);\n \t }\n \t listener(arg);\n \t });\n \t } else {\n \t throw new TypeError('The \"emitter\" argument must be of type EventEmitter. Received type ' + typeof emitter);\n \t }\n \t}\n \treturn events.exports;\n }\n\n requireEvents();\n\n /*! *****************************************************************************\r\n Copyright (c) Microsoft Corporation.\r\n\r\n Permission to use, copy, modify, and/or distribute this software for any\r\n purpose with or without fee is hereby granted.\r\n\r\n THE SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH\r\n REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY\r\n AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,\r\n INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM\r\n LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR\r\n OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR\r\n PERFORMANCE OF THIS SOFTWARE.\r\n ***************************************************************************** */\r\n\r\n\n let cachedTextEncoder = new TextEncoder(\"utf-8\");\n\n typeof cachedTextEncoder.encodeInto === \"function\"\n ? function (arg, view) {\n return cachedTextEncoder.encodeInto(arg, view);\n }\n : function (arg, view) {\n const buf = cachedTextEncoder.encode(arg);\n view.set(buf);\n return {\n read: arg.length,\n written: buf.length,\n };\n };\n\n const NODE_CONDS_KEY = \"displayConds\";\n var HookType = /* @__PURE__ */ ((HookType2) => {\n HookType2[\"CODE\"] = \"code\";\n return HookType2;\n })(HookType || {});\n\n const isObject = (obj) => Object.prototype.toString.call(obj) === \"[object Object]\";\n const getKeysArray = (keys) => (\n // 将 array[0] 转成 array.0\n `${keys}`.replaceAll(/\\[(\\d+)\\]/g, \".$1\").split(\".\")\n );\n const DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX = \"ds-field::\";\n const dataSourceTemplateRegExp = /\\$\\{([\\s\\S]+?)\\}/g;\n\n var DepTargetType = /* @__PURE__ */ ((DepTargetType2) => {\n DepTargetType2[\"DEFAULT\"] = \"default\";\n DepTargetType2[\"CODE_BLOCK\"] = \"code-block\";\n DepTargetType2[\"DATA_SOURCE\"] = \"data-source\";\n DepTargetType2[\"DATA_SOURCE_METHOD\"] = \"data-source-method\";\n DepTargetType2[\"DATA_SOURCE_COND\"] = \"data-source-cond\";\n return DepTargetType2;\n })(DepTargetType || {});\n\n class Target {\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) {\n this.type = options.type;\n }\n if (options.initialDeps) {\n this.deps = options.initialDeps;\n }\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) {\n dep.keys.push(key);\n }\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) {\n delete this.deps[id];\n }\n } else {\n delete this.deps[id];\n }\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\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) {\n return true;\n }\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 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 && field.type === \"array\" && // 不是整数\n /^(?!\\d+$).*$/.test(`${keys[index + 1]}`) && index < keys.length - 1;\n });\n };\n const isDataSourceTemplate = (value, ds, hasArray = false) => {\n const templates = value.match(dataSourceTemplateRegExp) || [];\n if (templates.length <= 0) {\n return false;\n }\n const arrayFieldTemplates = [];\n const fieldTemplates = [];\n templates.forEach((tpl) => {\n const expression = tpl.substring(2, tpl.length - 1);\n const keys = getKeysArray(expression);\n const dsId = keys.shift();\n if (!dsId || dsId !== ds.id) {\n return;\n }\n if (isIncludeArrayField(keys, ds.fields)) {\n arrayFieldTemplates.push(tpl);\n } else {\n fieldTemplates.push(tpl);\n }\n });\n if (hasArray) {\n return arrayFieldTemplates.length > 0;\n }\n return fieldTemplates.length > 0;\n };\n const isSpecificDataSourceTemplate = (value, dsId) => value?.isBindDataSourceField && value.dataSourceId && value.dataSourceId === dsId && typeof value.template === \"string\";\n const isUseDataSourceField = (value, id) => {\n if (!Array.isArray(value) || typeof value[0] !== \"string\") {\n return false;\n }\n const [prefixId] = value;\n const prefixIndex = prefixId.indexOf(DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX);\n if (prefixIndex === -1) {\n return false;\n }\n const dsId = prefixId.substring(prefixIndex + DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX.length);\n return dsId === id;\n };\n const isDataSourceTarget = (ds, key, value, hasArray = false) => {\n if (!value || ![\"string\", \"object\"].includes(typeof value)) {\n return false;\n }\n if (`${key}`.startsWith(NODE_CONDS_KEY)) {\n return false;\n }\n if (typeof value === \"string\") {\n return isDataSourceTemplate(value, ds, hasArray);\n }\n if (isObject(value) && value?.isBindDataSource && value.dataSourceId && value.dataSourceId === ds.id) {\n return true;\n }\n if (isSpecificDataSourceTemplate(value, ds.id)) {\n return true;\n }\n if (isUseDataSourceField(value, ds.id)) {\n const [, ...keys] = value;\n const includeArray = isIncludeArrayField(keys, ds.fields);\n if (hasArray) {\n return includeArray;\n }\n return !includeArray;\n }\n return false;\n };\n const isDataSourceCondTarget = (ds, key, value, hasArray = false) => {\n if (!Array.isArray(value) || !ds) {\n return false;\n }\n const [dsId, ...keys] = value;\n if (dsId !== ds.id || !`${key}`.startsWith(NODE_CONDS_KEY)) {\n return false;\n }\n if (ds.fields?.find((field) => field.name === keys[0])) {\n const includeArray = isIncludeArrayField(keys, ds.fields);\n if (hasArray) {\n return includeArray;\n }\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)) {\n return false;\n }\n const [dsId, methodName] = value;\n if (!methodName || dsId !== ds.id) {\n return false;\n }\n if (ds.methods?.find((method) => method.name === methodName)) {\n return true;\n }\n if (ds.fields?.find((field) => field.name === methodName)) {\n return false;\n }\n return true;\n }\n });\n const traverseTarget = (targetsList, cb, type) => {\n for (const targets of Object.values(targetsList)) {\n for (const target of Object.values(targets)) {\n if (type && target.type !== type) {\n continue;\n }\n cb(target);\n }\n }\n };\n\n class Watcher {\n targetsList = {};\n childrenProp = \"items\";\n idProp = \"id\";\n nameProp = \"name\";\n constructor(options) {\n if (options?.initialTargets) {\n this.targetsList = options.initialTargets;\n }\n if (options?.childrenProp) {\n this.childrenProp = options.childrenProp;\n }\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)) {\n target.destroy();\n }\n delete this.targetsList[type];\n }\n /**\n * 删除所有target\n */\n clearTargets() {\n for (const key of Object.keys(this.targetsList)) {\n delete this.targetsList[key];\n }\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(\n this.targetsList,\n (target) => {\n if (!type && !target.isCollectByDefault) {\n return;\n }\n for (const node of nodes) {\n cb({ node, target });\n }\n },\n type\n );\n }\n /**\n * 清除所有目标的依赖\n * @param nodes 需要清除依赖的节点\n */\n clear(nodes, type) {\n let { targetsList } = this;\n if (type) {\n targetsList = {\n [type]: this.getTargets(type)\n };\n }\n const clearedItemsNodeIds = [];\n traverseTarget(targetsList, (target) => {\n if (nodes) {\n 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 {\n target.removeDep();\n }\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 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)) {\n 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)) {\n for (let i = 0, l = value.length; i < l; i++) {\n const item = value[i];\n if (isObject(item)) {\n collectTarget(item, `${fullKey}[${i}]`);\n }\n }\n } else if (isObject(value)) {\n collectTarget(value, fullKey);\n }\n if (keyIsItems && deep && Array.isArray(value)) {\n for (const child of value) {\n this.collectItem(child, target, depExtendedData, deep);\n }\n }\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) {\n for (const item of node[this.childrenProp]) {\n this.removeTargetDep(target, item, key);\n }\n }\n }\n }\n\n const error = (...args) => {\n if (process.env.NODE_ENV === \"development\") {\n console.error(\"magic editor: \", ...args);\n }\n };\n\n onmessage = (e) => {\n const watcher = new Watcher({ initialTargets: {} });\n const { dsl } = e.data;\n try {\n const mApp = eval(`(${dsl})`);\n if (!mApp) {\n postMessage({});\n }\n if (mApp.codeBlocks) {\n for (const [id, code] of Object.entries(mApp.codeBlocks)) {\n watcher.addTarget(createCodeBlockTarget(id, code));\n }\n }\n if (mApp.dataSources) {\n for (const ds of mApp.dataSources) {\n watcher.addTarget(createDataSourceTarget(ds, {}));\n watcher.addTarget(createDataSourceMethodTarget(ds, {}));\n watcher.addTarget(createDataSourceCondTarget(ds, {}));\n }\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 (e2) {\n error(e2);\n postMessage({});\n }\n };\n\n})();\n";
18742
+ const blob = typeof self !== "undefined" && self.Blob && new Blob([jsContent], { type: "text/javascript;charset=utf-8" });
18743
+ function WorkerWrapper(options) {
18744
+ let objURL;
18745
+ try {
18746
+ objURL = blob && (self.URL || self.webkitURL).createObjectURL(blob);
18747
+ if (!objURL) throw ''
18748
+ const worker = new Worker(objURL, {
18749
+
18750
+ name: options?.name
18751
+ });
18752
+ worker.addEventListener("error", () => {
18753
+ (self.URL || self.webkitURL).revokeObjectURL(objURL);
18754
+ });
18755
+ return worker;
18756
+ } catch(e) {
18757
+ return new Worker(
18758
+ 'data:text/javascript;charset=utf-8,' + encodeURIComponent(jsContent),
18759
+ {
18760
+
18761
+ name: options?.name
18762
+ }
18763
+ );
18764
+ } finally {
18765
+ objURL && (self.URL || self.webkitURL).revokeObjectURL(objURL);
18766
+ }
18767
+ }
18768
+
18738
18769
  class Dep extends BaseService {
18739
18770
  state = vue.shallowReactive({
18740
18771
  collecting: false,
@@ -18742,6 +18773,7 @@
18742
18773
  });
18743
18774
  idleTask = new IdleTask();
18744
18775
  watcher = new core.Watcher({ initialTargets: vue.reactive({}) });
18776
+ waitingWorker;
18745
18777
  constructor() {
18746
18778
  super();
18747
18779
  this.idleTask.on(
@@ -18791,7 +18823,10 @@
18791
18823
  this.emit("collected", nodes, deep);
18792
18824
  this.emit("ds-collected", nodes, deep);
18793
18825
  }
18794
- collectIdle(nodes, depExtendedData = {}, deep = false, type) {
18826
+ async collectIdle(nodes, depExtendedData = {}, deep = false, type) {
18827
+ if (this.waitingWorker) {
18828
+ await this.waitingWorker;
18829
+ }
18795
18830
  this.set("collecting", true);
18796
18831
  let startTask = false;
18797
18832
  this.watcher.collectByCallback(nodes, type, ({ node, target }) => {
@@ -18815,6 +18850,41 @@
18815
18850
  });
18816
18851
  });
18817
18852
  }
18853
+ collectByWorker(dsl) {
18854
+ this.set("collecting", true);
18855
+ const { promise, resolve: waitingResolve } = Promise.withResolvers();
18856
+ this.waitingWorker = promise;
18857
+ return new Promise((resolve) => {
18858
+ const worker = new WorkerWrapper();
18859
+ worker.postMessage({
18860
+ dsl: serialize(dsl)
18861
+ });
18862
+ worker.onmessage = (e) => {
18863
+ resolve(e.data);
18864
+ };
18865
+ worker.onerror = () => {
18866
+ resolve({});
18867
+ };
18868
+ }).then((depsData) => {
18869
+ core.traverseTarget(this.watcher.getTargetsList(), (target) => {
18870
+ if (depsData[target.type]?.[target.id]) {
18871
+ target.deps = vue.reactive(depsData[target.type][target.id]);
18872
+ if (target.type === core.DepTargetType.DATA_SOURCE && dsl.dataSourceDeps) {
18873
+ dsl.dataSourceDeps[target.id] = target.deps;
18874
+ } else if (target.type === core.DepTargetType.DATA_SOURCE_COND && dsl.dataSourceCondDeps) {
18875
+ dsl.dataSourceCondDeps[target.id] = target.deps;
18876
+ } else if (target.type === core.DepTargetType.DATA_SOURCE_METHOD) {
18877
+ dsl.dataSourceMethodDeps[target.id] = target.deps;
18878
+ }
18879
+ }
18880
+ });
18881
+ this.set("collecting", false);
18882
+ this.emit("collected", dsl.items, true);
18883
+ this.emit("ds-collected", dsl.items, true);
18884
+ waitingResolve();
18885
+ return depsData;
18886
+ });
18887
+ }
18818
18888
  collectNode(node, target, depExtendedData = {}, deep = false) {
18819
18889
  if (utils.isPage(node)) {
18820
18890
  for (const [depKey, dep] of Object.entries(target.deps)) {
@@ -19493,18 +19563,17 @@
19493
19563
  }
19494
19564
  });
19495
19565
  };
19496
- const collectIdle = (nodes, deep, type) => Promise.all(
19497
- nodes.map((node) => {
19498
- let pageId;
19499
- if (utils.isPage(node)) {
19500
- pageId = node.id;
19501
- } else {
19502
- const info = editorService.getNodeInfo(node.id);
19503
- pageId = info.page?.id;
19504
- }
19505
- return depService.collectIdle([node], { pageId }, deep, type);
19506
- })
19507
- );
19566
+ const getPageIdByNode = (node) => {
19567
+ let pageId;
19568
+ if (utils.isPage(node)) {
19569
+ pageId = node.id;
19570
+ } else {
19571
+ const info = editorService.getNodeInfo(node.id);
19572
+ pageId = info.page?.id;
19573
+ }
19574
+ return pageId;
19575
+ };
19576
+ const collectIdle = (nodes, deep, type) => Promise.all(nodes.map((node) => depService.collectIdle([node], { pageId: getPageIdByNode(node) }, deep, type)));
19508
19577
  vue.watch(
19509
19578
  () => editorService.get("stage"),
19510
19579
  (stage) => {
@@ -19539,7 +19608,7 @@
19539
19608
  }
19540
19609
  if (Array.isArray(value.items)) {
19541
19610
  depService.clearIdleTasks();
19542
- collectIdle(value.items, true).then(() => {
19611
+ (typeof Worker === "undefined" ? collectIdle(value.items, true) : depService.collectByWorker(value)).then(() => {
19543
19612
  updateStageNodes(value.items);
19544
19613
  });
19545
19614
  } else {
@@ -19752,14 +19821,12 @@
19752
19821
  root.dataSourceDeps = {};
19753
19822
  }
19754
19823
  root.dataSourceDeps[target.id] = target.deps;
19755
- }
19756
- if (target.type === core.DepTargetType.DATA_SOURCE_COND) {
19824
+ } else if (target.type === core.DepTargetType.DATA_SOURCE_COND) {
19757
19825
  if (!root.dataSourceCondDeps) {
19758
19826
  root.dataSourceCondDeps = {};
19759
19827
  }
19760
19828
  root.dataSourceCondDeps[target.id] = target.deps;
19761
- }
19762
- if (target.type === core.DepTargetType.DATA_SOURCE_METHOD) {
19829
+ } else if (target.type === core.DepTargetType.DATA_SOURCE_METHOD) {
19763
19830
  if (!root.dataSourceMethodDeps) {
19764
19831
  root.dataSourceMethodDeps = {};
19765
19832
  }
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.5.15",
2
+ "version": "1.5.17",
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": "^6.0.0",
60
60
  "sortablejs": "^1.15.2",
61
- "@tmagic/stage": "1.5.15",
62
- "@tmagic/form": "1.5.15",
63
- "@tmagic/table": "1.5.15",
64
- "@tmagic/design": "1.5.15",
65
- "@tmagic/utils": "1.5.15"
61
+ "@tmagic/design": "1.5.17",
62
+ "@tmagic/utils": "1.5.17",
63
+ "@tmagic/form": "1.5.17",
64
+ "@tmagic/stage": "1.5.17",
65
+ "@tmagic/table": "1.5.17"
66
66
  },
67
67
  "devDependencies": {
68
68
  "@types/events": "^3.0.0",
@@ -76,7 +76,7 @@
76
76
  "monaco-editor": "^0.48.0",
77
77
  "typescript": "*",
78
78
  "vue": ">=3.5.0",
79
- "@tmagic/core": "1.5.15"
79
+ "@tmagic/core": "1.5.17"
80
80
  },
81
81
  "peerDependenciesMeta": {
82
82
  "typescript": {
@@ -13,7 +13,7 @@
13
13
  </template>
14
14
 
15
15
  <script lang="ts" setup>
16
- import type { FieldProps, FormItem } from '@tmagic/form';
16
+ import type { CodeConfig, FieldProps } from '@tmagic/form';
17
17
 
18
18
  import MagicCodeEditor from '@editor/layouts/CodeEditor.vue';
19
19
 
@@ -25,23 +25,9 @@ const emit = defineEmits<{
25
25
  change: [value: string | any];
26
26
  }>();
27
27
 
28
- withDefaults(
29
- defineProps<
30
- FieldProps<
31
- {
32
- language?: string;
33
- options?: {
34
- [key: string]: any;
35
- };
36
- height?: string;
37
- parse?: boolean;
38
- } & FormItem
39
- >
40
- >(),
41
- {
42
- disabled: false,
43
- },
44
- );
28
+ withDefaults(defineProps<FieldProps<CodeConfig>>(), {
29
+ disabled: false,
30
+ });
45
31
 
46
32
  const save = (v: string | any) => {
47
33
  emit('change', v);
@@ -6,7 +6,7 @@
6
6
  import { computed, reactive, watch } from 'vue';
7
7
  import serialize from 'serialize-javascript';
8
8
 
9
- import type { FieldProps, FormItem } from '@tmagic/form';
9
+ import type { CodeLinkConfig, FieldProps } from '@tmagic/form';
10
10
 
11
11
  import { getEditorConfig } from '@editor/utils/config';
12
12
 
@@ -14,15 +14,7 @@ defineOptions({
14
14
  name: 'MFieldsCodeLink',
15
15
  });
16
16
 
17
- const props = defineProps<
18
- FieldProps<
19
- {
20
- type: 'code-link';
21
- formTitle?: string;
22
- codeOptions?: Object;
23
- } & FormItem
24
- >
25
- >();
17
+ const props = defineProps<FieldProps<CodeLinkConfig>>();
26
18
 
27
19
  const emit = defineEmits(['change']);
28
20
 
@@ -21,7 +21,7 @@ import { isEmpty } from 'lodash-es';
21
21
 
22
22
  import { HookCodeType, HookType } from '@tmagic/core';
23
23
  import { TMagicCard } from '@tmagic/design';
24
- import type { ContainerChangeEventData, FieldProps, FormItem, GroupListConfig } from '@tmagic/form';
24
+ import type { CodeSelectConfig, ContainerChangeEventData, FieldProps, GroupListConfig } from '@tmagic/form';
25
25
  import { MContainer } from '@tmagic/form';
26
26
 
27
27
  import { useServices } from '@editor/hooks/use-services';
@@ -36,16 +36,7 @@ const emit = defineEmits<{
36
36
 
37
37
  const { dataSourceService, codeBlockService } = useServices();
38
38
 
39
- const props = withDefaults(
40
- defineProps<
41
- FieldProps<
42
- {
43
- className?: string;
44
- } & FormItem
45
- >
46
- >(),
47
- {},
48
- );
39
+ const props = withDefaults(defineProps<FieldProps<CodeSelectConfig>>(), {});
49
40
 
50
41
  const codeConfig = computed<GroupListConfig>(() => ({
51
42
  type: 'group-list',
@@ -42,6 +42,7 @@ import { isEmpty, map } from 'lodash-es';
42
42
  import type { Id } from '@tmagic/core';
43
43
  import { TMagicButton } from '@tmagic/design';
44
44
  import {
45
+ type CodeSelectColConfig,
45
46
  type ContainerChangeEventData,
46
47
  createValues,
47
48
  type FieldProps,
@@ -53,7 +54,7 @@ import {
53
54
  import CodeParams from '@editor/components/CodeParams.vue';
54
55
  import MIcon from '@editor/components/Icon.vue';
55
56
  import { useServices } from '@editor/hooks/use-services';
56
- import type { CodeParamStatement, CodeSelectColConfig, EventBus } from '@editor/type';
57
+ import type { CodeParamStatement, EventBus } from '@editor/type';
57
58
  import { SideItemKey } from '@editor/type';
58
59
 
59
60
  defineOptions({
@@ -30,10 +30,9 @@
30
30
  import { computed } from 'vue';
31
31
 
32
32
  import { getDesignConfig, TMagicSelect } from '@tmagic/design';
33
- import type { FieldProps } from '@tmagic/form';
33
+ import type { CondOpSelectConfig, FieldProps } from '@tmagic/form';
34
34
 
35
35
  import { useServices } from '@editor/hooks/use-services';
36
- import type { CondOpSelectConfig } from '@editor/type';
37
36
  import { arrayOptions, eqOptions, numberOptions } from '@editor/utils';
38
37
 
39
38
  defineOptions({
@@ -44,12 +44,11 @@ import { Coin } from '@element-plus/icons-vue';
44
44
 
45
45
  import { DataSchema } from '@tmagic/core';
46
46
  import { TMagicButton, tMagicMessage, TMagicTooltip } from '@tmagic/design';
47
- import type { ContainerChangeEventData, FieldProps, FormState } from '@tmagic/form';
47
+ import type { ContainerChangeEventData, DataSourceFieldSelectConfig, FieldProps, FormState } from '@tmagic/form';
48
48
  import { DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX } from '@tmagic/utils';
49
49
 
50
50
  import MIcon from '@editor/components/Icon.vue';
51
51
  import { useServices } from '@editor/hooks/use-services';
52
- import type { DataSourceFieldSelectConfig } from '@editor/type';
53
52
  import { removeDataSourceFieldPrefix } from '@editor/utils';
54
53
 
55
54
  import FieldSelect from './FieldSelect.vue';
@@ -53,6 +53,7 @@ import type { DataSchema } from '@tmagic/core';
53
53
  import { TMagicButton, tMagicMessage, tMagicMessageBox } from '@tmagic/design';
54
54
  import {
55
55
  type ContainerChangeEventData,
56
+ type DataSourceFieldsConfig,
56
57
  type FieldProps,
57
58
  type FormConfig,
58
59
  type FormState,
@@ -71,16 +72,9 @@ defineOptions({
71
72
  name: 'MFieldsDataSourceFields',
72
73
  });
73
74
 
74
- const props = withDefaults(
75
- defineProps<
76
- FieldProps<{
77
- type: 'data-source-fields';
78
- }>
79
- >(),
80
- {
81
- disabled: false,
82
- },
83
- );
75
+ const props = withDefaults(defineProps<FieldProps<DataSourceFieldsConfig>>(), {
76
+ disabled: false,
77
+ });
84
78
 
85
79
  const emit = defineEmits<{
86
80
  change: [v: any, eventData?: ContainerChangeEventData];
@@ -53,7 +53,7 @@ import { Coin } from '@element-plus/icons-vue';
53
53
 
54
54
  import type { DataSchema, DataSourceSchema } from '@tmagic/core';
55
55
  import { getDesignConfig, TMagicAutocomplete, TMagicTag } from '@tmagic/design';
56
- import type { FieldProps, FormItem } from '@tmagic/form';
56
+ import type { DataSourceInputConfig, FieldProps } from '@tmagic/form';
57
57
  import { getKeysArray, isNumber } from '@tmagic/utils';
58
58
 
59
59
  import Icon from '@editor/components/Icon.vue';
@@ -64,18 +64,9 @@ defineOptions({
64
64
  name: 'MFieldsDataSourceInput',
65
65
  });
66
66
 
67
- const props = withDefaults(
68
- defineProps<
69
- FieldProps<
70
- {
71
- type: 'data-source-input';
72
- } & FormItem
73
- >
74
- >(),
75
- {
76
- disabled: false,
77
- },
78
- );
67
+ const props = withDefaults(defineProps<FieldProps<DataSourceInputConfig>>(), {
68
+ disabled: false,
69
+ });
79
70
 
80
71
  const emit = defineEmits<{
81
72
  change: [value: string];
@@ -39,6 +39,7 @@ import type { Id } from '@tmagic/core';
39
39
  import { TMagicButton, TMagicTooltip } from '@tmagic/design';
40
40
  import {
41
41
  createValues,
42
+ type DataSourceMethodSelectConfig,
42
43
  type FieldProps,
43
44
  filterFunction,
44
45
  type FormState,
@@ -49,7 +50,7 @@ import {
49
50
  import CodeParams from '@editor/components/CodeParams.vue';
50
51
  import MIcon from '@editor/components/Icon.vue';
51
52
  import { useServices } from '@editor/hooks/use-services';
52
- import type { CodeParamStatement, DataSourceMethodSelectConfig, EventBus } from '@editor/type';
53
+ import type { CodeParamStatement, EventBus } from '@editor/type';
53
54
  import { SideItemKey } from '@editor/type';
54
55
 
55
56
  defineOptions({