mirror of
https://github.com/Tencent/tmagic-editor.git
synced 2026-07-28 08:55:50 +00:00
Compare commits
21 Commits
v1.8.0-bet
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
21baf58cda | ||
|
|
4923a34835 | ||
|
|
b7c04edcd5 | ||
|
|
2116408bd4 | ||
|
|
a342a78313 | ||
|
|
3fe9cf9b66 | ||
|
|
a123747e9d | ||
|
|
e4d4a11240 | ||
|
|
4ffda3ddd5 | ||
|
|
a0b5702330 | ||
|
|
e6cf694a03 | ||
|
|
be7b38f97e | ||
|
|
dec4ebfa20 | ||
|
|
596d86f2ab | ||
|
|
b564c9e4aa | ||
|
|
b5abf31066 | ||
|
|
bf8df74864 | ||
|
|
a37e0487c6 | ||
|
|
329cd947e1 | ||
|
|
0e1986c819 | ||
|
|
d0a22315c0 |
38
CHANGELOG.md
38
CHANGELOG.md
@ -1,3 +1,41 @@
|
|||||||
|
# [1.8.0-beta.19](https://github.com/Tencent/tmagic-editor/compare/v1.8.0-beta.18...v1.8.0-beta.19) (2026-07-28)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **form:** 新增 validateOnInit,默认关闭初始化时自动校验 ([b7c04ed](https://github.com/Tencent/tmagic-editor/commit/b7c04edcd518554d5117c2212bbfe8ef632a4b37))
|
||||||
|
# [1.8.0-beta.18](https://github.com/Tencent/tmagic-editor/compare/v1.8.0-beta.17...v1.8.0-beta.18) (2026-07-28)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **editor:** 修复 IdleTask 任务异常或 clearTasks 时队列卡住的问题 ([3fe9cf9](https://github.com/Tencent/tmagic-editor/commit/3fe9cf9b664dc5b39c17b40efe1d3935c89f7553))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **form:** 支持 typeMatch 异步校验与 validator 返回值约定 ([a123747](https://github.com/Tencent/tmagic-editor/commit/a123747e9d250166c2bb0f1d3ce3a39dd5baea9f))
|
||||||
|
# [1.8.0-beta.17](https://github.com/Tencent/tmagic-editor/compare/v1.8.0-beta.16...v1.8.0-beta.17) (2026-07-27)
|
||||||
|
|
||||||
|
|
||||||
|
### Bug Fixes
|
||||||
|
|
||||||
|
* **editor:** 修复 collectIdle 批次结算与中断时 Promise 挂起问题 ([b5abf31](https://github.com/Tencent/tmagic-editor/commit/b5abf310663f0bc34bd2c51c2e1a28de0bdf6ab9))
|
||||||
|
* **editor:** 切换动作类型时清空关联配置字段 ([b564c9e](https://github.com/Tencent/tmagic-editor/commit/b564c9e4aacd215dd46c4b839cf0033ceedc8047))
|
||||||
|
* **form,table:** groupList分界线、空状态、actions只存在一个 ([dec4ebf](https://github.com/Tencent/tmagic-editor/commit/dec4ebfa20483f699a676e41e0541d23ebe24d81))
|
||||||
|
* **form:** 完善 mountFormInstance 清理逻辑,避免临时表单实例泄漏 ([bf8df74](https://github.com/Tencent/tmagic-editor/commit/bf8df74864b78891a8820462062624702a1d33d3))
|
||||||
|
* **table:** 列操作点击后关闭popover ([596d86f](https://github.com/Tencent/tmagic-editor/commit/596d86f2ab08d3d4e6548b5e4bd5759d18e4493d))
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* **editor,stage:** 新增 containerHighlightAddOnly 配置 ([e6cf694](https://github.com/Tencent/tmagic-editor/commit/e6cf694a032652e4f2c05efbab4a07a252e2ffa1))
|
||||||
|
# [1.8.0-beta.16](https://github.com/Tencent/tmagic-editor/compare/v1.8.0-beta.15...v1.8.0-beta.16) (2026-07-23)
|
||||||
|
|
||||||
|
|
||||||
|
### Features
|
||||||
|
|
||||||
|
* 参考建议可选值最多展示个数由 5 调整为 20 ([0e1986c](https://github.com/Tencent/tmagic-editor/commit/0e1986c81998e50461c294c1a27a8139e8ae9a13))
|
||||||
# [1.8.0-beta.15](https://github.com/Tencent/tmagic-editor/compare/v1.8.0-beta.14...v1.8.0-beta.15) (2026-07-23)
|
# [1.8.0-beta.15](https://github.com/Tencent/tmagic-editor/compare/v1.8.0-beta.14...v1.8.0-beta.15) (2026-07-23)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -1020,6 +1020,18 @@ alt: 按住alt键启动识别
|
|||||||
|
|
||||||
- **类型:** `'default' | 'alt' | ''`
|
- **类型:** `'default' | 'alt' | ''`
|
||||||
|
|
||||||
|
## containerHighlightAddOnly
|
||||||
|
|
||||||
|
- **详情:**
|
||||||
|
|
||||||
|
是否只有新增组件(从组件列表拖入新组件)时才启用识别容器
|
||||||
|
|
||||||
|
开启后,在画布中拖动已有组件时不再识别容器,即已有组件不能通过拖动加入其他容器;新增组件仍然按 [containerHighlightType](#containerHighlightType) 配置的方式识别
|
||||||
|
|
||||||
|
- **默认值:** `false`
|
||||||
|
|
||||||
|
- **类型:** `boolean`
|
||||||
|
|
||||||
## stageRect
|
## stageRect
|
||||||
|
|
||||||
- **详情:**
|
- **详情:**
|
||||||
|
|||||||
@ -69,10 +69,11 @@
|
|||||||
|
|
||||||
## delayedMarkContainer
|
## delayedMarkContainer
|
||||||
|
|
||||||
- **类型**:`(event: MouseEvent, excludeElList?: Element[]) => NodeJS.Timeout | undefined`
|
- **类型**:`(event: MouseEvent, excludeElList?: Element[], isAdd?: boolean) => NodeJS.Timeout | undefined`
|
||||||
- **参数**:
|
- **参数**:
|
||||||
- `event`:鼠标事件
|
- `event`:鼠标事件
|
||||||
- `excludeElList`:计算鼠标所在容器时要排除的元素列表
|
- `excludeElList`:计算鼠标所在容器时要排除的元素列表
|
||||||
|
- `isAdd`:当前操作是否为新增组件(从组件列表拖入新组件),`containerHighlightType` 为 `addOnly` 时只有新增才会标记容器
|
||||||
- **详情**:
|
- **详情**:
|
||||||
|
|
||||||
鼠标拖拽着元素,在容器上方悬停,延迟一段时间后,对容器进行标记,如果悬停时间够长将标记成功,悬停时间短,调用方通过返回的timeoutId取消标记
|
鼠标拖拽着元素,在容器上方悬停,延迟一段时间后,对容器进行标记,如果悬停时间够长将标记成功,悬停时间短,调用方通过返回的timeoutId取消标记
|
||||||
|
|||||||
@ -69,6 +69,8 @@
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
`validator` 除了调用 `callback` 外,也兼容 async-validator 的返回值约定:返回 `false` 或 `Error` / 错误数组表示失败,返回 `true` 表示通过,返回 `Promise` 则以 resolve / reject 为结果,内部抛出的异常会转成校验失败。同步与异步 `typeMatch` 下这些约定行为一致,且只会上报一次结果(既调 `callback` 又返回 `Promise` 时以先到的为准)。
|
||||||
|
|
||||||
## 扩展自定义 type 规则
|
## 扩展自定义 type 规则
|
||||||
|
|
||||||
业务可覆盖内置规则,或为自定义字段 type 注册校验。自定义规则优先于内置规则。
|
业务可覆盖内置规则,或为自定义字段 type 注册校验。自定义规则优先于内置规则。
|
||||||
@ -107,7 +109,26 @@ deleteTypeMatchRule('foo');
|
|||||||
clearTypeMatchRules();
|
clearTypeMatchRules();
|
||||||
```
|
```
|
||||||
|
|
||||||
自定义校验器签名:`(value, context) => string | undefined`。返回错误文案表示失败,返回 `undefined` 表示通过。`context` 包含 `fieldType`、`mForm`、`props`、`message`。
|
自定义校验器签名:`(value, context) => string | undefined | Promise<string | undefined>`。返回错误文案表示失败,返回 `undefined` 表示通过。`context` 包含 `fieldType`、`mForm`、`props`、`message`。
|
||||||
|
|
||||||
|
### 异步校验
|
||||||
|
|
||||||
|
自定义校验器可以返回 `Promise`,用于需要异步确认取值是否合法的场景(如请求接口校验 id 是否存在)。内置规则均为同步。
|
||||||
|
|
||||||
|
```ts
|
||||||
|
registerTypeMatchRule('mod-select', async (value, { message }) => {
|
||||||
|
const exists = await checkModExists(value);
|
||||||
|
if (!exists) {
|
||||||
|
return message || `模块(${value})不存在`;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
```
|
||||||
|
|
||||||
|
异步校验器通过后才会执行同一条 rule 上的自定义 `validator`。需要注意几点:
|
||||||
|
|
||||||
|
- **校验器自身失败不算校验失败。** Promise 被 reject(如接口异常)时只打印错误、该字段按通过处理,避免网络故障阻塞操作。需要把失败暴露给用户时请在校验器内部 catch 并返回错误文案。
|
||||||
|
- **建议自行缓存请求结果。** 每次校验都会执行校验器,无缓存会导致逐次输入都发请求;也可以给 rule 配 `trigger: 'blur'` 降低触发频率。
|
||||||
|
- **只有最新一轮校验的结论会被采用。** 新一轮校验开始后,上一轮针对旧值、尚未返回的校验不再使用自己的结论,而是等最新一轮出结论后一起结算,因此旧结论不会晚到覆盖新结论,`form.validate()` 也不会对一个尚未校验完的值返回成功。
|
||||||
|
|
||||||
### 安装时注册
|
### 安装时注册
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "1.8.0-beta.15",
|
"version": "1.8.0-beta.19",
|
||||||
"name": "tmagic",
|
"name": "tmagic",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "1.8.0-beta.15",
|
"version": "1.8.0-beta.19",
|
||||||
"name": "@tmagic/cli",
|
"name": "@tmagic/cli",
|
||||||
"main": "lib/index.js",
|
"main": "lib/index.js",
|
||||||
"types": "lib/index.d.ts",
|
"types": "lib/index.d.ts",
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "1.8.0-beta.15",
|
"version": "1.8.0-beta.19",
|
||||||
"name": "@tmagic/core",
|
"name": "@tmagic/core",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "1.8.0-beta.15",
|
"version": "1.8.0-beta.19",
|
||||||
"name": "@tmagic/data-source",
|
"name": "@tmagic/data-source",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "1.8.0-beta.15",
|
"version": "1.8.0-beta.19",
|
||||||
"name": "@tmagic/dep",
|
"name": "@tmagic/dep",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "1.8.0-beta.15",
|
"version": "1.8.0-beta.19",
|
||||||
"name": "@tmagic/design",
|
"name": "@tmagic/design",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"sideEffects": [
|
"sideEffects": [
|
||||||
|
|||||||
@ -1,5 +1,9 @@
|
|||||||
<template>
|
<template>
|
||||||
<component :is="uiComponent" :class="['tmagic-design-card', { 'tmagic-design-card--flat': isFlat }]" v-bind="uiProps">
|
<component
|
||||||
|
:is="uiComponent"
|
||||||
|
:class="['tmagic-design-card', { 'tmagic-design-card--flat': isFlat, 'm-flat-hide-body': isHideBody }]"
|
||||||
|
v-bind="uiProps"
|
||||||
|
>
|
||||||
<template #header v-if="$slots.header">
|
<template #header v-if="$slots.header">
|
||||||
<slot name="header" class="header"></slot>
|
<slot name="header" class="header"></slot>
|
||||||
</template>
|
</template>
|
||||||
@ -30,7 +34,7 @@ const uiComponent = ui?.component || 'el-card';
|
|||||||
// 当祖先 `<MEditor>` / `<MForm>` 的 theme 是 `magic-admin` 时,整套设计语言默认走「无卡片感」,
|
// 当祖先 `<MEditor>` / `<MForm>` 的 theme 是 `magic-admin` 时,整套设计语言默认走「无卡片感」,
|
||||||
// 因此这里自动等价于 `flat=true`;调用方仍可显式传 `flat` 强制开启。
|
// 因此这里自动等价于 `flat=true`;调用方仍可显式传 `flat` 强制开启。
|
||||||
const isFlat = computed(() => !!props.flat || isGlobalFlat.value);
|
const isFlat = computed(() => !!props.flat || isGlobalFlat.value);
|
||||||
|
const isHideBody = computed(() => isFlat.value && props.bodyStyle?.display === 'none');
|
||||||
// 把 `flat` 从转发给底层 UI 库(el-card / t-card 等)的 props 中剥离:
|
// 把 `flat` 从转发给底层 UI 库(el-card / t-card 等)的 props 中剥离:
|
||||||
// 它仅作用于本组件的视觉修饰类,不需要也不应该作为属性落到底层组件 / DOM 上。
|
// 它仅作用于本组件的视觉修饰类,不需要也不应该作为属性落到底层组件 / DOM 上。
|
||||||
const uiProps = computed<CardProps>(() => {
|
const uiProps = computed<CardProps>(() => {
|
||||||
|
|||||||
@ -11,7 +11,11 @@
|
|||||||
border-right: 0;
|
border-right: 0;
|
||||||
border-radius: 0;
|
border-radius: 0;
|
||||||
border-bottom: 0;
|
border-bottom: 0;
|
||||||
|
&.m-flat-hide-body {
|
||||||
|
.el-card__header {
|
||||||
|
border-bottom: 0 !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
&.m-fields-group-list-item {
|
&.m-fields-group-list-item {
|
||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
}
|
}
|
||||||
@ -29,6 +33,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.m-fields-group-list-footer {
|
||||||
|
margin-bottom: 4px;
|
||||||
|
margin-top: 4px;
|
||||||
|
}
|
||||||
.el-card__body {
|
.el-card__body {
|
||||||
padding: 0 16px 0 16px;
|
padding: 0 16px 0 16px;
|
||||||
// 这里每个form-item应该要有一个16px间距,但是除了tbody中的form-item
|
// 这里每个form-item应该要有一个16px间距,但是除了tbody中的form-item
|
||||||
@ -61,7 +69,7 @@
|
|||||||
}
|
}
|
||||||
> .el-card__body {
|
> .el-card__body {
|
||||||
background-color: #fff;
|
background-color: #fff;
|
||||||
padding-top: 16px;
|
padding-top: 8px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "1.8.0-beta.15",
|
"version": "1.8.0-beta.19",
|
||||||
"name": "@tmagic/editor",
|
"name": "@tmagic/editor",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"sideEffects": [
|
"sideEffects": [
|
||||||
|
|||||||
@ -218,6 +218,7 @@ const stageOptions: StageOptions = {
|
|||||||
containerHighlightClassName: props.containerHighlightClassName,
|
containerHighlightClassName: props.containerHighlightClassName,
|
||||||
containerHighlightDuration: props.containerHighlightDuration,
|
containerHighlightDuration: props.containerHighlightDuration,
|
||||||
containerHighlightType: props.containerHighlightType,
|
containerHighlightType: props.containerHighlightType,
|
||||||
|
containerHighlightAddOnly: props.containerHighlightAddOnly,
|
||||||
disabledDragStart: props.disabledDragStart,
|
disabledDragStart: props.disabledDragStart,
|
||||||
renderType: props.renderType,
|
renderType: props.renderType,
|
||||||
guidesOptions: props.guidesOptions,
|
guidesOptions: props.guidesOptions,
|
||||||
|
|||||||
@ -82,6 +82,11 @@ export interface EditorProps {
|
|||||||
containerHighlightDuration?: number;
|
containerHighlightDuration?: number;
|
||||||
/** 拖入画布中容器时,识别容器的操作类型 */
|
/** 拖入画布中容器时,识别容器的操作类型 */
|
||||||
containerHighlightType?: ContainerHighlightType;
|
containerHighlightType?: ContainerHighlightType;
|
||||||
|
/**
|
||||||
|
* 是否仅在新增组件(从组件列表拖入新组件)时才启用识别容器,
|
||||||
|
* 开启后在画布中拖动已有组件不会识别容器,默认 false
|
||||||
|
*/
|
||||||
|
containerHighlightAddOnly?: boolean;
|
||||||
/** 画布大小 */
|
/** 画布大小 */
|
||||||
stageRect?: StageRect;
|
stageRect?: StageRect;
|
||||||
/** monaco editor 的配置 */
|
/** monaco editor 的配置 */
|
||||||
@ -163,6 +168,7 @@ export const defaultEditorProps = {
|
|||||||
containerHighlightClassName: CONTAINER_HIGHLIGHT_CLASS_NAME,
|
containerHighlightClassName: CONTAINER_HIGHLIGHT_CLASS_NAME,
|
||||||
containerHighlightDuration: 800,
|
containerHighlightDuration: 800,
|
||||||
containerHighlightType: ContainerHighlightType.DEFAULT,
|
containerHighlightType: ContainerHighlightType.DEFAULT,
|
||||||
|
containerHighlightAddOnly: false,
|
||||||
disabledShowSrc: false,
|
disabledShowSrc: false,
|
||||||
disabledDataSource: false,
|
disabledDataSource: false,
|
||||||
disabledCodeBlock: false,
|
disabledCodeBlock: false,
|
||||||
|
|||||||
@ -37,13 +37,12 @@
|
|||||||
:model="entry.cardItem"
|
:model="entry.cardItem"
|
||||||
:last-values="entry.lastCardItem"
|
:last-values="entry.lastCardItem"
|
||||||
:is-compare="isCompareMode"
|
:is-compare="isCompareMode"
|
||||||
:hide-expand="true"
|
:hide-expand="false"
|
||||||
:label-width="config.labelWidth || '100px'"
|
:label-width="config.labelWidth || '100px'"
|
||||||
@change="onChangeHandler"
|
@change="onChangeHandler"
|
||||||
>
|
>
|
||||||
<template #header>
|
<template #header>
|
||||||
<div class="event-item-header">
|
<div class="event-item-header">
|
||||||
<div class="event-item-title">事件{{ Number(entry.index) + 1 }}</div>
|
|
||||||
<MFormContainer
|
<MFormContainer
|
||||||
class="fullWidth"
|
class="fullWidth"
|
||||||
:config="eventNameConfig"
|
:config="eventNameConfig"
|
||||||
@ -210,6 +209,12 @@ const actionTypeConfig = computed(() => {
|
|||||||
trigger: 'blur',
|
trigger: 'blur',
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
onChange: (_mForm: FormState, _v: string, { setModel }: any) => {
|
||||||
|
setModel('to', '');
|
||||||
|
setModel('method', '');
|
||||||
|
setModel('codeId', '');
|
||||||
|
setModel('dataSourceMethod', []);
|
||||||
|
},
|
||||||
};
|
};
|
||||||
return { ...defaultActionTypeConfig, ...props.config.actionTypeConfig };
|
return { ...defaultActionTypeConfig, ...props.config.actionTypeConfig };
|
||||||
});
|
});
|
||||||
@ -222,7 +227,7 @@ const targetCompConfig = computed(() => {
|
|||||||
type: 'ui-select',
|
type: 'ui-select',
|
||||||
labelPosition: 'left',
|
labelPosition: 'left',
|
||||||
display: (_mForm, { model }) => model.actionType === ActionType.COMP,
|
display: (_mForm, { model }) => model.actionType === ActionType.COMP,
|
||||||
onChange: (_MForm, _v, { setModel }) => {
|
onChange: (_mForm, _v, { setModel }) => {
|
||||||
setModel('method', '');
|
setModel('method', '');
|
||||||
},
|
},
|
||||||
rules: [
|
rules: [
|
||||||
|
|||||||
@ -28,6 +28,7 @@ export const useStage = (stageOptions: StageOptions) => {
|
|||||||
containerHighlightClassName: stageOptions.containerHighlightClassName,
|
containerHighlightClassName: stageOptions.containerHighlightClassName,
|
||||||
containerHighlightDuration: stageOptions.containerHighlightDuration,
|
containerHighlightDuration: stageOptions.containerHighlightDuration,
|
||||||
containerHighlightType: stageOptions.containerHighlightType,
|
containerHighlightType: stageOptions.containerHighlightType,
|
||||||
|
containerHighlightAddOnly: stageOptions.containerHighlightAddOnly,
|
||||||
disabledDragStart: stageOptions.disabledDragStart,
|
disabledDragStart: stageOptions.disabledDragStart,
|
||||||
renderType: stageOptions.renderType,
|
renderType: stageOptions.renderType,
|
||||||
canSelect: (el, event, stop) => {
|
canSelect: (el, event, stop) => {
|
||||||
|
|||||||
@ -333,11 +333,11 @@ export const initServiceEvents = (
|
|||||||
Promise.all(
|
Promise.all(
|
||||||
nodes.map((node) => {
|
nodes.map((node) => {
|
||||||
if (node.type === NodeType.ROOT) {
|
if (node.type === NodeType.ROOT) {
|
||||||
return Promise.resolve();
|
return Promise.resolve(true);
|
||||||
}
|
}
|
||||||
return depService.collectIdle([node], { pageId: getPageIdByNode(node) }, deep, type);
|
return depService.collectIdle([node], { pageId: getPageIdByNode(node) }, deep, type);
|
||||||
}),
|
}),
|
||||||
);
|
).then((results) => results.every(Boolean));
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => editorService.get('stage'),
|
() => editorService.get('stage'),
|
||||||
@ -351,7 +351,7 @@ export const initServiceEvents = (
|
|||||||
|
|
||||||
if (!node) return;
|
if (!node) return;
|
||||||
|
|
||||||
await collectIdle([node], true, DepTargetType.DATA_SOURCE);
|
if (!(await collectIdle([node], true, DepTargetType.DATA_SOURCE))) return;
|
||||||
updateStageNode(node);
|
updateStageNode(node);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
@ -494,8 +494,10 @@ export const initServiceEvents = (
|
|||||||
|
|
||||||
// 新增节点,收集依赖
|
// 新增节点,收集依赖
|
||||||
const nodeAddHandler = (nodes: MComponent[]) => {
|
const nodeAddHandler = (nodes: MComponent[]) => {
|
||||||
collectIdle(nodes, true).then(() => {
|
collectIdle(nodes, true).then((completed) => {
|
||||||
updateStageNodes(nodes);
|
if (completed) {
|
||||||
|
updateStageNodes(nodes);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -549,8 +551,8 @@ export const initServiceEvents = (
|
|||||||
if (needRecollectNodes.length) {
|
if (needRecollectNodes.length) {
|
||||||
// 有数据源依赖,需要等依赖重新收集完才更新stage
|
// 有数据源依赖,需要等依赖重新收集完才更新stage
|
||||||
const handler = async () => {
|
const handler = async () => {
|
||||||
await collectIdle(needRecollectNodes, true, DepTargetType.DATA_SOURCE);
|
if (!(await collectIdle(needRecollectNodes, true, DepTargetType.DATA_SOURCE))) return;
|
||||||
await collectIdle(needRecollectNodes, true, DepTargetType.DATA_SOURCE_COND);
|
if (!(await collectIdle(needRecollectNodes, true, DepTargetType.DATA_SOURCE_COND))) return;
|
||||||
updateStageNodes(needRecollectNodes);
|
updateStageNodes(needRecollectNodes);
|
||||||
};
|
};
|
||||||
handler();
|
handler();
|
||||||
@ -572,8 +574,10 @@ export const initServiceEvents = (
|
|||||||
|
|
||||||
// 历史记录变化时,需要重新收集依赖
|
// 历史记录变化时,需要重新收集依赖
|
||||||
const historyChangeHandler = (page: MPage | MPageFragment) => {
|
const historyChangeHandler = (page: MPage | MPageFragment) => {
|
||||||
collectIdle([page], true).then(() => {
|
collectIdle([page], true).then((completed) => {
|
||||||
updateStageNode(page);
|
if (completed) {
|
||||||
|
updateStageNode(page);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -654,7 +658,7 @@ export const initServiceEvents = (
|
|||||||
if (Array.isArray(root?.items)) {
|
if (Array.isArray(root?.items)) {
|
||||||
depService.clearIdleTasks();
|
depService.clearIdleTasks();
|
||||||
|
|
||||||
let collectIdlePromises: Promise<void[]>[] = [];
|
let collectIdlePromises: Promise<boolean>[] = [];
|
||||||
if (isModifyField) {
|
if (isModifyField) {
|
||||||
depService.removeTarget(config.id, DepTargetType.DATA_SOURCE);
|
depService.removeTarget(config.id, DepTargetType.DATA_SOURCE);
|
||||||
depService.removeTarget(config.id, DepTargetType.DATA_SOURCE_COND);
|
depService.removeTarget(config.id, DepTargetType.DATA_SOURCE_COND);
|
||||||
@ -679,10 +683,15 @@ export const initServiceEvents = (
|
|||||||
|
|
||||||
collectIdlePromises = [collectIdle(root.items, true, DepTargetType.DATA_SOURCE_METHOD)];
|
collectIdlePromises = [collectIdle(root.items, true, DepTargetType.DATA_SOURCE_METHOD)];
|
||||||
}
|
}
|
||||||
Promise.all(collectIdlePromises)
|
const handler = async () => {
|
||||||
.then(() => updateDataSourceSchema())
|
const results = await Promise.all(collectIdlePromises);
|
||||||
.then(() => updateDsData())
|
if (!results.every(Boolean)) return;
|
||||||
.then(() => updateStageNodes(root.items));
|
|
||||||
|
updateDataSourceSchema();
|
||||||
|
await updateDsData();
|
||||||
|
updateStageNodes(root.items);
|
||||||
|
};
|
||||||
|
handler();
|
||||||
}
|
}
|
||||||
} else if (root?.dataSources) {
|
} else if (root?.dataSources) {
|
||||||
updateDsData();
|
updateDsData();
|
||||||
@ -706,11 +715,12 @@ export const initServiceEvents = (
|
|||||||
const nodeIds = Object.keys(root.dataSourceDeps?.[id] || {});
|
const nodeIds = Object.keys(root.dataSourceDeps?.[id] || {});
|
||||||
const nodes = getNodes(nodeIds, root.items);
|
const nodes = getNodes(nodeIds, root.items);
|
||||||
|
|
||||||
await Promise.all([
|
const results = await Promise.all([
|
||||||
collectIdle(nodes, false, DepTargetType.DATA_SOURCE),
|
collectIdle(nodes, false, DepTargetType.DATA_SOURCE),
|
||||||
collectIdle(nodes, false, DepTargetType.DATA_SOURCE_COND),
|
collectIdle(nodes, false, DepTargetType.DATA_SOURCE_COND),
|
||||||
collectIdle(nodes, false, DepTargetType.DATA_SOURCE_METHOD),
|
collectIdle(nodes, false, DepTargetType.DATA_SOURCE_METHOD),
|
||||||
]);
|
]);
|
||||||
|
if (!results.every(Boolean)) return;
|
||||||
|
|
||||||
updateDataSourceSchema();
|
updateDataSourceSchema();
|
||||||
|
|
||||||
|
|||||||
@ -14,6 +14,7 @@
|
|||||||
:config="config"
|
:config="config"
|
||||||
:type-match-valid="true"
|
:type-match-valid="true"
|
||||||
:extend-state="extendState"
|
:extend-state="extendState"
|
||||||
|
:validate-on-init="true"
|
||||||
@change="submit"
|
@change="submit"
|
||||||
@error="errorHandler"
|
@error="errorHandler"
|
||||||
></MForm>
|
></MForm>
|
||||||
@ -49,14 +50,13 @@ import { Document as DocumentIcon } from '@element-plus/icons-vue';
|
|||||||
|
|
||||||
import { TMagicButton, tMagicMessage, TMagicScrollbar } from '@tmagic/design';
|
import { TMagicButton, tMagicMessage, TMagicScrollbar } from '@tmagic/design';
|
||||||
import type { ContainerChangeEventData, FormConfig, FormState, FormValue } from '@tmagic/form';
|
import type { ContainerChangeEventData, FormConfig, FormState, FormValue } from '@tmagic/form';
|
||||||
import { MForm } from '@tmagic/form';
|
import { MForm, validateForm } from '@tmagic/form';
|
||||||
import { filterXSS } from '@tmagic/utils';
|
import { filterXSS } from '@tmagic/utils';
|
||||||
|
|
||||||
import MIcon from '@editor/components/Icon.vue';
|
import MIcon from '@editor/components/Icon.vue';
|
||||||
import { ENABLE_PROPS_FORM_VALIDATE } from '@editor/editorProps';
|
import { ENABLE_PROPS_FORM_VALIDATE } from '@editor/editorProps';
|
||||||
import { useEditorContentHeight } from '@editor/hooks/use-editor-content-height';
|
import { useEditorContentHeight } from '@editor/hooks/use-editor-content-height';
|
||||||
import { useServices } from '@editor/hooks/use-services';
|
import { useServices } from '@editor/hooks/use-services';
|
||||||
import { validatePropsForm } from '@editor/utils/props';
|
|
||||||
|
|
||||||
import CodeEditor from '../CodeEditor.vue';
|
import CodeEditor from '../CodeEditor.vue';
|
||||||
|
|
||||||
@ -162,14 +162,19 @@ const saveCode = async (values: any) => {
|
|||||||
// 做一次静默校验(不复用、也不污染页面上正在展示的表单),并将校验结果(错误信息)随提交
|
// 做一次静默校验(不复用、也不污染页面上正在展示的表单),并将校验结果(错误信息)随提交
|
||||||
// 一并抛给上层记录,使源码保存的错误状态与表单编辑保持一致。
|
// 一并抛给上层记录,使源码保存的错误状态与表单编辑保持一致。
|
||||||
try {
|
try {
|
||||||
const error = await validatePropsForm({
|
const error = await validateForm({
|
||||||
config: props.config,
|
config: props.config,
|
||||||
values: newValues,
|
|
||||||
appContext: internalInstance?.appContext ?? null,
|
|
||||||
services,
|
|
||||||
stage: stage.value,
|
|
||||||
typeMatchValid: true,
|
typeMatchValid: true,
|
||||||
extendState: props.extendState,
|
initValues: newValues,
|
||||||
|
// 将当前组件实例的 provides(含 Editor 顶层的 services / codeOptions 等组件级 provide)
|
||||||
|
// 合入 appContext,使临时 MForm 中的编辑器字段组件(DataSourceInput 等)能正常 inject
|
||||||
|
appContext: internalInstance?.appContext ? { ...internalInstance?.appContext, provides: { services } } : null,
|
||||||
|
extendState: (state) => {
|
||||||
|
if (configFormRef.value?.formState) {
|
||||||
|
return { ...(configFormRef.value?.formState || {}) };
|
||||||
|
}
|
||||||
|
return props.extendState?.(state) || {};
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
|||||||
@ -145,6 +145,6 @@ const dragHandler = (e: DragEvent) => {
|
|||||||
|
|
||||||
if (timeout || !stage.value) return;
|
if (timeout || !stage.value) return;
|
||||||
|
|
||||||
timeout = stage.value.delayedMarkContainer(e);
|
timeout = stage.value.delayedMarkContainer(e, [], true);
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@ -42,6 +42,21 @@ interface State {
|
|||||||
|
|
||||||
type StateKey = keyof State;
|
type StateKey = keyof State;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 一次 collectIdle 调用对应一个批次。批次自行统计入队/完成的任务数,在自身任务全部完成或被中断时
|
||||||
|
* 结算对应的 Promise,避免多次快速触发时共用 idleTask 的 finish 事件造成的串扰、提前 resolve,
|
||||||
|
* 以及 clearTasks 后 Promise 永不 resolve(collecting 卡死、监听器泄漏)。
|
||||||
|
*/
|
||||||
|
interface CollectBatch {
|
||||||
|
nodes: MNode[];
|
||||||
|
deep: boolean;
|
||||||
|
pending: number;
|
||||||
|
dsPending: number;
|
||||||
|
collectedEmitted: boolean;
|
||||||
|
dsSettled: boolean;
|
||||||
|
resolve: (completed: boolean) => void;
|
||||||
|
}
|
||||||
|
|
||||||
class Dep extends BaseService {
|
class Dep extends BaseService {
|
||||||
private state = shallowReactive<State>({
|
private state = shallowReactive<State>({
|
||||||
collecting: false,
|
collecting: false,
|
||||||
@ -54,6 +69,12 @@ class Dep extends BaseService {
|
|||||||
|
|
||||||
private waitingWorker?: Promise<void>;
|
private waitingWorker?: Promise<void>;
|
||||||
|
|
||||||
|
private resolveWaitingWorker?: () => void;
|
||||||
|
|
||||||
|
private workerGeneration = 0;
|
||||||
|
|
||||||
|
private activeBatches = new Set<CollectBatch>();
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
@ -137,38 +158,44 @@ class Dep extends BaseService {
|
|||||||
await this.waitingWorker;
|
await this.waitingWorker;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.set('collecting', true);
|
const batch: CollectBatch = {
|
||||||
let startTask = false;
|
nodes,
|
||||||
this.watcher.collectByCallback(nodes, type, ({ node, target }) => {
|
deep,
|
||||||
startTask = true;
|
pending: 0,
|
||||||
|
dsPending: 0,
|
||||||
|
collectedEmitted: false,
|
||||||
|
dsSettled: false,
|
||||||
|
resolve: () => {},
|
||||||
|
};
|
||||||
|
|
||||||
this.enqueueTask(node, target, depExtendedData, deep);
|
this.watcher.collectByCallback(nodes, type, ({ node, target }) => {
|
||||||
|
this.enqueueTask(node, target, depExtendedData, deep, batch);
|
||||||
});
|
});
|
||||||
|
|
||||||
return new Promise<void>((resolve) => {
|
// 没有命中任何 target,无需收集,直接完成
|
||||||
if (!startTask) {
|
if (batch.pending === 0) {
|
||||||
this.emit('collected', nodes, deep);
|
this.emit('collected', nodes, deep);
|
||||||
this.set('collecting', false);
|
this.updateCollectingState();
|
||||||
resolve();
|
return true;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
this.idleTask.once('finish', () => {
|
this.activeBatches.add(batch);
|
||||||
this.emit('collected', nodes, deep);
|
this.set('collecting', true);
|
||||||
this.set('collecting', false);
|
|
||||||
});
|
return new Promise<boolean>((resolve) => {
|
||||||
this.idleTask.once('hight-level-finish', () => {
|
batch.resolve = resolve;
|
||||||
this.emit('ds-collected', nodes, deep);
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public collectByWorker(dsl: MApp) {
|
public collectByWorker(dsl: MApp) {
|
||||||
this.set('collecting', true);
|
this.set('collecting', true);
|
||||||
|
this.workerGeneration += 1;
|
||||||
|
const generation = this.workerGeneration;
|
||||||
|
|
||||||
const { promise, resolve: waitingResolve } = Promise.withResolvers<void>();
|
const { promise, resolve: waitingResolve } = Promise.withResolvers<void>();
|
||||||
|
|
||||||
this.waitingWorker = promise;
|
this.waitingWorker = promise;
|
||||||
|
this.resolveWaitingWorker = waitingResolve;
|
||||||
|
|
||||||
return new Promise<Record<string, Record<string, DepData>>>((resolve) => {
|
return new Promise<Record<string, Record<string, DepData>>>((resolve) => {
|
||||||
const worker = new Work();
|
const worker = new Work();
|
||||||
@ -182,6 +209,11 @@ class Dep extends BaseService {
|
|||||||
resolve({});
|
resolve({});
|
||||||
};
|
};
|
||||||
}).then((depsData) => {
|
}).then((depsData) => {
|
||||||
|
if (generation !== this.workerGeneration) {
|
||||||
|
waitingResolve();
|
||||||
|
return depsData;
|
||||||
|
}
|
||||||
|
|
||||||
traverseTarget(this.watcher.getTargetsList(), (target) => {
|
traverseTarget(this.watcher.getTargetsList(), (target) => {
|
||||||
if (depsData[target.type]?.[target.id]) {
|
if (depsData[target.type]?.[target.id]) {
|
||||||
target.deps = reactive(depsData[target.type][target.id]);
|
target.deps = reactive(depsData[target.type][target.id]);
|
||||||
@ -200,6 +232,10 @@ class Dep extends BaseService {
|
|||||||
this.emit('collected', dsl.items, true);
|
this.emit('collected', dsl.items, true);
|
||||||
this.emit('ds-collected', dsl.items, true);
|
this.emit('ds-collected', dsl.items, true);
|
||||||
waitingResolve();
|
waitingResolve();
|
||||||
|
if (this.waitingWorker === promise) {
|
||||||
|
this.waitingWorker = undefined;
|
||||||
|
this.resolveWaitingWorker = undefined;
|
||||||
|
}
|
||||||
|
|
||||||
return depsData;
|
return depsData;
|
||||||
});
|
});
|
||||||
@ -233,6 +269,7 @@ class Dep extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public clearIdleTasks() {
|
public clearIdleTasks() {
|
||||||
|
this.abortActiveBatches();
|
||||||
this.idleTask.clearTasks();
|
this.idleTask.clearTasks();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -251,6 +288,11 @@ class Dep extends BaseService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public reset() {
|
public reset() {
|
||||||
|
this.abortActiveBatches();
|
||||||
|
this.workerGeneration += 1;
|
||||||
|
this.resolveWaitingWorker?.();
|
||||||
|
this.resolveWaitingWorker = undefined;
|
||||||
|
this.waitingWorker = undefined;
|
||||||
this.idleTask.clearTasks();
|
this.idleTask.clearTasks();
|
||||||
|
|
||||||
for (const type of Object.keys(this.watcher.getTargetsList())) {
|
for (const type of Object.keys(this.watcher.getTargetsList())) {
|
||||||
@ -286,25 +328,99 @@ class Dep extends BaseService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private enqueueTask(node: MNode, target: Target, depExtendedData: DepExtendedData, deep: boolean) {
|
private enqueueTask(
|
||||||
|
node: MNode,
|
||||||
|
target: Target,
|
||||||
|
depExtendedData: DepExtendedData,
|
||||||
|
deep: boolean,
|
||||||
|
batch: CollectBatch,
|
||||||
|
) {
|
||||||
|
const isDataSource = target.type === DepTargetType.DATA_SOURCE;
|
||||||
|
|
||||||
|
batch.pending += 1;
|
||||||
|
if (isDataSource) {
|
||||||
|
batch.dsPending += 1;
|
||||||
|
}
|
||||||
|
|
||||||
this.idleTask.enqueueTask(
|
this.idleTask.enqueueTask(
|
||||||
({ node, deep, target }) => {
|
({ node, deep, target }) => {
|
||||||
this.collectNode(node, target, depExtendedData, deep);
|
try {
|
||||||
|
this.collectNode(node, target, depExtendedData, deep);
|
||||||
|
} finally {
|
||||||
|
this.onBatchTaskDone(batch, isDataSource);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
node,
|
node,
|
||||||
deep: false,
|
deep: false,
|
||||||
target,
|
target,
|
||||||
},
|
},
|
||||||
target.type === DepTargetType.DATA_SOURCE,
|
isDataSource,
|
||||||
);
|
);
|
||||||
|
|
||||||
if (deep && Array.isArray(node.items) && node.items.length) {
|
if (deep && Array.isArray(node.items) && node.items.length) {
|
||||||
node.items.forEach((item) => {
|
node.items.forEach((item) => {
|
||||||
this.enqueueTask(item, target, depExtendedData, deep);
|
this.enqueueTask(item, target, depExtendedData, deep, batch);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private onBatchTaskDone(batch: CollectBatch, isDataSource: boolean) {
|
||||||
|
if (isDataSource) {
|
||||||
|
batch.dsPending -= 1;
|
||||||
|
// 数据源依赖收集完先 resolve,让 stage 尽快更新,其余依赖继续在后台收集
|
||||||
|
if (batch.dsPending === 0) {
|
||||||
|
this.settleBatchDs(batch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
batch.pending -= 1;
|
||||||
|
if (batch.pending === 0) {
|
||||||
|
this.finishBatch(batch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private settleBatchDs(batch: CollectBatch) {
|
||||||
|
if (batch.dsSettled) return;
|
||||||
|
batch.dsSettled = true;
|
||||||
|
this.emit('ds-collected', batch.nodes, batch.deep);
|
||||||
|
batch.resolve(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private finishBatch(batch: CollectBatch) {
|
||||||
|
if (!batch.collectedEmitted) {
|
||||||
|
batch.collectedEmitted = true;
|
||||||
|
this.emit('collected', batch.nodes, batch.deep);
|
||||||
|
}
|
||||||
|
// 没有数据源任务的批次在此结算 Promise
|
||||||
|
this.settleBatchDs(batch);
|
||||||
|
this.activeBatches.delete(batch);
|
||||||
|
this.updateCollectingState();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* idleTask 被清空时,在途批次的任务不会再执行,必须主动结算,
|
||||||
|
* 否则对应的 collectIdle Promise 永远不会 resolve(collecting 卡在 true、once 监听器泄漏)。
|
||||||
|
* 收集被中断(通常紧跟一次全量重新收集),因此不再 emit collected/ds-collected,仅结算 Promise。
|
||||||
|
*/
|
||||||
|
private abortActiveBatches() {
|
||||||
|
if (!this.activeBatches.size) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const batches = [...this.activeBatches];
|
||||||
|
this.activeBatches.clear();
|
||||||
|
|
||||||
|
for (const batch of batches) {
|
||||||
|
batch.resolve(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.updateCollectingState();
|
||||||
|
}
|
||||||
|
|
||||||
|
private updateCollectingState() {
|
||||||
|
this.set('collecting', this.activeBatches.size > 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export type DepService = Dep;
|
export type DepService = Dep;
|
||||||
|
|||||||
@ -19,7 +19,7 @@
|
|||||||
}
|
}
|
||||||
.el-card__body {
|
.el-card__body {
|
||||||
.tmagic-design-form-item {
|
.tmagic-design-form-item {
|
||||||
margin-bottom: 18px;
|
margin-bottom: 16px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.code-select-content {
|
.code-select-content {
|
||||||
|
|||||||
@ -3,6 +3,12 @@
|
|||||||
.fullWidth {
|
.fullWidth {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
&.create-button {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
&.m-container-ui-event {
|
||||||
|
width: calc(100% - 32px);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.event-select-container {
|
.event-select-container {
|
||||||
padding: 0 16px;
|
padding: 0 16px;
|
||||||
@ -76,17 +82,18 @@
|
|||||||
.event-item-header {
|
.event-item-header {
|
||||||
position: relative;
|
position: relative;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
.event-item-title {
|
.event-item-title {
|
||||||
color: #0f1113;
|
color: #0f1113;
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
font-weight: 500;
|
font-weight: 500;
|
||||||
line-height: 24px;
|
line-height: 24px;
|
||||||
margin-bottom: 16px;
|
margin-bottom: 8px;
|
||||||
}
|
}
|
||||||
.event-item-delete-button {
|
.event-item-delete-button {
|
||||||
position: absolute;
|
color: #0f1113;
|
||||||
right: 0;
|
|
||||||
top: 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-form-item {
|
.el-form-item {
|
||||||
|
|||||||
@ -178,6 +178,11 @@ export interface StageOptions {
|
|||||||
containerHighlightClassName?: string;
|
containerHighlightClassName?: string;
|
||||||
containerHighlightDuration?: number;
|
containerHighlightDuration?: number;
|
||||||
containerHighlightType?: ContainerHighlightType;
|
containerHighlightType?: ContainerHighlightType;
|
||||||
|
/**
|
||||||
|
* 是否仅在新增组件(从组件列表拖入新组件)时才启用识别容器,
|
||||||
|
* 开启后在画布中拖动已有组件不会识别容器,默认 false
|
||||||
|
*/
|
||||||
|
containerHighlightAddOnly?: boolean;
|
||||||
disabledDragStart?: boolean;
|
disabledDragStart?: boolean;
|
||||||
render?: (stage: StageCore) => HTMLDivElement | void | Promise<HTMLDivElement | void>;
|
render?: (stage: StageCore) => HTMLDivElement | void | Promise<HTMLDivElement | void>;
|
||||||
moveableOptions?: CustomizeMoveableOptions;
|
moveableOptions?: CustomizeMoveableOptions;
|
||||||
|
|||||||
@ -1,5 +1,7 @@
|
|||||||
import { EventEmitter } from 'events';
|
import { EventEmitter } from 'events';
|
||||||
|
|
||||||
|
import { error } from '../logger';
|
||||||
|
|
||||||
export interface IdleTaskEvents {
|
export interface IdleTaskEvents {
|
||||||
finish: [];
|
finish: [];
|
||||||
'hight-level-finish': [];
|
'hight-level-finish': [];
|
||||||
@ -25,6 +27,12 @@ globalThis.requestIdleCallback =
|
|||||||
}, 1);
|
}, 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
globalThis.cancelIdleCallback =
|
||||||
|
globalThis.cancelIdleCallback ||
|
||||||
|
function (handle) {
|
||||||
|
clearTimeout(handle as unknown as ReturnType<typeof setTimeout>);
|
||||||
|
};
|
||||||
|
|
||||||
export class IdleTask<T = any> extends EventEmitter {
|
export class IdleTask<T = any> extends EventEmitter {
|
||||||
private taskList: TaskList<T> = [];
|
private taskList: TaskList<T> = [];
|
||||||
|
|
||||||
@ -58,7 +66,7 @@ export class IdleTask<T = any> extends EventEmitter {
|
|||||||
this.taskHandle = null;
|
this.taskHandle = null;
|
||||||
|
|
||||||
this.emit('update-task-length', {
|
this.emit('update-task-length', {
|
||||||
length: this.taskList.length + this.hightLevelTaskList.length,
|
length: this.getTaskLength(),
|
||||||
hightLevelLength: this.hightLevelTaskList.length,
|
hightLevelLength: this.hightLevelTaskList.length,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -82,51 +90,80 @@ export class IdleTask<T = any> extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private runTaskQueue(deadline: IdleDeadline) {
|
private runTaskQueue(deadline: IdleDeadline) {
|
||||||
const { hightLevelTaskList, taskList } = this;
|
// 本次回调已触发,句柄随之失效;置空后 clearTasks / enqueueTask 才能正确判断是否需要重新调度
|
||||||
|
this.taskHandle = null;
|
||||||
|
|
||||||
// 动画会占用空闲时间,当任务一直无法执行时,看看是否有动画正在播放
|
try {
|
||||||
// 根据空闲时间的多少来决定执行的任务数,保证页面不卡死的情况下尽量多执行任务,不然当任务数巨大时,执行时间会很久
|
// 动画会占用空闲时间,当任务一直无法执行时,看看是否有动画正在播放
|
||||||
// 执行不完不会影响配置,但是会影响画布渲染
|
// 根据空闲时间的多少来决定执行的任务数,保证页面不卡死的情况下尽量多执行任务,不然当任务数巨大时,执行时间会很久
|
||||||
while (deadline.timeRemaining() > 0 && (taskList.length || hightLevelTaskList.length)) {
|
// 执行不完不会影响配置,但是会影响画布渲染
|
||||||
const timeRemaining = deadline.timeRemaining();
|
while (deadline.timeRemaining() > 0 && this.getTaskLength()) {
|
||||||
let times = 0;
|
const timeRemaining = deadline.timeRemaining();
|
||||||
if (timeRemaining <= 5) {
|
let times = 0;
|
||||||
times = 10;
|
if (timeRemaining <= 5) {
|
||||||
} else if (timeRemaining <= 10) {
|
times = 10;
|
||||||
times = 100;
|
} else if (timeRemaining <= 10) {
|
||||||
} else if (timeRemaining <= 15) {
|
times = 100;
|
||||||
times = 300;
|
} else if (timeRemaining <= 15) {
|
||||||
|
times = 300;
|
||||||
|
} else {
|
||||||
|
times = 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (let i = 0; i < times; i++) {
|
||||||
|
// 每次都从实例上取队列,任务执行过程中调用 clearTasks 能立即生效,不会继续消费已被清空的旧队列
|
||||||
|
const task = this.hightLevelTaskList.length > 0 ? this.hightLevelTaskList.shift() : this.taskList.shift();
|
||||||
|
if (task) {
|
||||||
|
this.runTask(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!this.getTaskLength()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
// 必须放在 finally 中:一旦这里被跳过,taskHandle 会一直是真值,
|
||||||
|
// enqueueTask 也就不会再重新调度,剩余任务与任务数将永久停在当前状态
|
||||||
|
this.finishRun();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 单个任务失败不能中断整个队列,否则后续任务永远不会被执行,
|
||||||
|
* 依赖收集会停在半路(收集中状态与剩余任务数都不再变化)
|
||||||
|
*/
|
||||||
|
private runTask(task: TaskList<T>[number]) {
|
||||||
|
try {
|
||||||
|
task.handler(task.data);
|
||||||
|
} catch (e) {
|
||||||
|
error('magic editor: 空闲任务执行失败', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private finishRun() {
|
||||||
|
try {
|
||||||
|
if (!this.hightLevelTaskList.length) {
|
||||||
|
this.emit('hight-level-finish');
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (this.getTaskLength()) {
|
||||||
|
// 任务执行或事件监听中可能已经重新调度过
|
||||||
|
if (!this.taskHandle) {
|
||||||
|
this.taskHandle = globalThis.requestIdleCallback(this.runTaskQueue.bind(this), { timeout: 300 });
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
times = 600;
|
this.emit('finish');
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < times; i++) {
|
this.emit('update-task-length', {
|
||||||
const task = hightLevelTaskList.length > 0 ? hightLevelTaskList.shift() : taskList.shift();
|
length: this.getTaskLength(),
|
||||||
if (task) {
|
hightLevelLength: this.hightLevelTaskList.length,
|
||||||
task.handler(task.data);
|
});
|
||||||
}
|
|
||||||
|
|
||||||
if (hightLevelTaskList.length === 0 && taskList.length === 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!hightLevelTaskList.length) {
|
private getTaskLength() {
|
||||||
this.emit('hight-level-finish');
|
return this.taskList.length + this.hightLevelTaskList.length;
|
||||||
}
|
|
||||||
|
|
||||||
if (hightLevelTaskList.length || taskList.length) {
|
|
||||||
this.taskHandle = globalThis.requestIdleCallback(this.runTaskQueue.bind(this), { timeout: 300 });
|
|
||||||
} else {
|
|
||||||
this.taskHandle = 0;
|
|
||||||
|
|
||||||
this.emit('finish');
|
|
||||||
}
|
|
||||||
|
|
||||||
this.emit('update-task-length', {
|
|
||||||
length: taskList.length + hightLevelTaskList.length,
|
|
||||||
hightLevelLength: hightLevelTaskList.length,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,9 +16,6 @@
|
|||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import type { AppContext } from 'vue';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
HookType,
|
HookType,
|
||||||
NODE_CONDS_KEY,
|
NODE_CONDS_KEY,
|
||||||
@ -27,18 +24,7 @@ import {
|
|||||||
NODE_DISABLE_DATA_SOURCE_KEY,
|
NODE_DISABLE_DATA_SOURCE_KEY,
|
||||||
} from '@tmagic/core';
|
} from '@tmagic/core';
|
||||||
import { tMagicMessage } from '@tmagic/design';
|
import { tMagicMessage } from '@tmagic/design';
|
||||||
import type {
|
import type { ChildConfig, DisplayCondsConfig, FormConfig, TabConfig, TabPaneConfig } from '@tmagic/form';
|
||||||
ChildConfig,
|
|
||||||
DisplayCondsConfig,
|
|
||||||
FormConfig,
|
|
||||||
FormState,
|
|
||||||
FormValue,
|
|
||||||
TabConfig,
|
|
||||||
TabPaneConfig,
|
|
||||||
} from '@tmagic/form';
|
|
||||||
import { validateForm } from '@tmagic/form';
|
|
||||||
|
|
||||||
import type { Services } from '@editor/type';
|
|
||||||
|
|
||||||
export const arrayOptions = [
|
export const arrayOptions = [
|
||||||
{ text: '包含', value: 'include' },
|
{ text: '包含', value: 'include' },
|
||||||
@ -403,86 +389,3 @@ export const removeStyleDisplayConfig = (formConfig: FormConfig): FormConfig =>
|
|||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
// #region ValidatePropsFormOptions
|
|
||||||
/**
|
|
||||||
* validatePropsForm 参数
|
|
||||||
*/
|
|
||||||
export interface ValidatePropsFormOptions {
|
|
||||||
/** 组件属性表单配置 */
|
|
||||||
config: FormConfig;
|
|
||||||
/** 待校验的表单值 */
|
|
||||||
values: FormValue;
|
|
||||||
/**
|
|
||||||
* 当前组件实例的 appContext(通常为 `getCurrentInstance()?.appContext`)。
|
|
||||||
* 会与 services 一并合入临时 MForm 的 appContext,使编辑器字段组件(DataSourceInput 等)能正常 inject。
|
|
||||||
*/
|
|
||||||
appContext?: AppContext | null;
|
|
||||||
/** 编辑器服务集合,注入到临时表单的 formState */
|
|
||||||
services?: Services;
|
|
||||||
/** stage 实例,注入到临时表单的 formState */
|
|
||||||
stage?: any;
|
|
||||||
/** 外部扩展的 formState */
|
|
||||||
extendState?: (_state: FormState) => Record<string, any> | Promise<Record<string, any>>;
|
|
||||||
/**
|
|
||||||
* 调试模式,默认 `true`:以弹层形式可见地渲染表单,点击「确定」才触发校验。
|
|
||||||
* 置为 `false` 时静默挂载后自动校验。
|
|
||||||
*/
|
|
||||||
debug?: boolean;
|
|
||||||
typeMatchValid?: boolean;
|
|
||||||
}
|
|
||||||
// #endregion ValidatePropsFormOptions
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 对一份「组件属性表单配置 + 值」做一次独立的校验,**不复用也不污染页面上正在展示的表单**。
|
|
||||||
*
|
|
||||||
* 内部基于 `@tmagic/form` 的 `validateForm` 另建一个独立的 MForm 实例完成校验,并统一处理
|
|
||||||
* 编辑器场景所需的上下文注入:将当前组件实例的 provides 合入 appContext,并向 formState 注入
|
|
||||||
* stage / services 及外部扩展状态,保证校验规则依赖的上下文可用。
|
|
||||||
*
|
|
||||||
* 常用于源码编辑器保存后,对最新配置做一次校验,并将校验结果(错误信息)随提交一并抛给上层记录,
|
|
||||||
* 使源码保存的错误状态与表单编辑保持一致。
|
|
||||||
*
|
|
||||||
* @returns 校验通过返回空字符串 `''`,否则返回以 `<br>` 拼接的错误文案。
|
|
||||||
* 仅在初始化超时或挂载失败等异常情况下才会 reject。
|
|
||||||
*
|
|
||||||
* @example
|
|
||||||
* ```ts
|
|
||||||
* const error = await validatePropsForm({
|
|
||||||
* config,
|
|
||||||
* values,
|
|
||||||
* appContext: getCurrentInstance()?.appContext,
|
|
||||||
* services,
|
|
||||||
* stage: editorService.get('stage'),
|
|
||||||
* extendState,
|
|
||||||
* });
|
|
||||||
* if (error) {
|
|
||||||
* // 配置不合法,error 为错误文案
|
|
||||||
* }
|
|
||||||
* ```
|
|
||||||
*/
|
|
||||||
export const validatePropsForm = ({
|
|
||||||
config,
|
|
||||||
values,
|
|
||||||
appContext = null,
|
|
||||||
services,
|
|
||||||
stage,
|
|
||||||
extendState,
|
|
||||||
debug,
|
|
||||||
typeMatchValid,
|
|
||||||
}: ValidatePropsFormOptions): Promise<string> =>
|
|
||||||
validateForm({
|
|
||||||
config,
|
|
||||||
debug,
|
|
||||||
typeMatchValid,
|
|
||||||
initValues: values,
|
|
||||||
// 将当前组件实例的 provides(含 Editor 顶层的 services / codeOptions 等组件级 provide)
|
|
||||||
// 合入 appContext,使临时 MForm 中的编辑器字段组件(DataSourceInput 等)能正常 inject
|
|
||||||
appContext: appContext ? { ...appContext, provides: { services } } : null,
|
|
||||||
// 与页面表单保持一致:注入 stage/services 及外部扩展状态,保证校验规则依赖的上下文可用
|
|
||||||
extendState: async (state) => ({
|
|
||||||
...((await extendState?.(state)) || {}),
|
|
||||||
stage,
|
|
||||||
services,
|
|
||||||
}),
|
|
||||||
});
|
|
||||||
|
|||||||
@ -58,7 +58,7 @@ const stringifyExampleValue = (value: any): string => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 参考建议中最多展示的可选值个数,超出以「等」省略。
|
// 参考建议中最多展示的可选值个数,超出以「等」省略。
|
||||||
const MAX_SUGGESTION_OPTIONS = 5;
|
const MAX_SUGGESTION_OPTIONS = 20;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成「请使用以下某一个值:xxx;xxx」形式的参考建议;无可选值时返回空字符串(不追加建议)。
|
* 生成「请使用以下某一个值:xxx;xxx」形式的参考建议;无可选值时返回空字符串(不追加建议)。
|
||||||
|
|||||||
@ -21,6 +21,7 @@ describe('defaultEditorProps', () => {
|
|||||||
test('containerHighlight 默认值', () => {
|
test('containerHighlight 默认值', () => {
|
||||||
expect(defaultEditorProps.containerHighlightDuration).toBe(800);
|
expect(defaultEditorProps.containerHighlightDuration).toBe(800);
|
||||||
expect(typeof defaultEditorProps.containerHighlightClassName).toBe('string');
|
expect(typeof defaultEditorProps.containerHighlightClassName).toBe('string');
|
||||||
|
expect(defaultEditorProps.containerHighlightAddOnly).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('数组/对象工厂函数返回空值', () => {
|
test('数组/对象工厂函数返回空值', () => {
|
||||||
|
|||||||
@ -91,7 +91,7 @@ const mkServices = () => {
|
|||||||
clear: vi.fn(),
|
clear: vi.fn(),
|
||||||
clearTargets: vi.fn(),
|
clearTargets: vi.fn(),
|
||||||
clearIdleTasks: vi.fn(),
|
clearIdleTasks: vi.fn(),
|
||||||
collectIdle: vi.fn(async () => undefined),
|
collectIdle: vi.fn(async () => true),
|
||||||
collectByWorker: vi.fn(async () => undefined),
|
collectByWorker: vi.fn(async () => undefined),
|
||||||
reset: vi.fn(),
|
reset: vi.fn(),
|
||||||
};
|
};
|
||||||
|
|||||||
@ -135,6 +135,6 @@ describe('ComponentListPanel', () => {
|
|||||||
const item = wrapper.find('.component-item');
|
const item = wrapper.find('.component-item');
|
||||||
await item.trigger('drag', { clientX: 0, clientY: 0 });
|
await item.trigger('drag', { clientX: 0, clientY: 0 });
|
||||||
await item.trigger('drag', { clientX: 0, clientY: 0 });
|
await item.trigger('drag', { clientX: 0, clientY: 0 });
|
||||||
expect(stage.delayedMarkContainer).toHaveBeenCalled();
|
expect(stage.delayedMarkContainer).toHaveBeenCalledWith(expect.anything(), [], true);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -13,16 +13,17 @@ vi.mock('@editor/utils/dep/worker.ts?worker&inline', () => ({
|
|||||||
default: class FakeWorker {
|
default: class FakeWorker {
|
||||||
public static nextData: Record<string, any> = {};
|
public static nextData: Record<string, any> = {};
|
||||||
public static nextError = false;
|
public static nextError = false;
|
||||||
|
public static nextDelay = 0;
|
||||||
public onmessage: ((e: any) => void) | null = null;
|
public onmessage: ((e: any) => void) | null = null;
|
||||||
public onerror: (() => void) | null = null;
|
public onerror: (() => void) | null = null;
|
||||||
public postMessage() {
|
public postMessage() {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (FakeWorker.nextError) {
|
if (FakeWorker.nextError) {
|
||||||
this.onerror?.(new Event('error'));
|
this.onerror?.();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
this.onmessage?.({ data: FakeWorker.nextData });
|
this.onmessage?.({ data: FakeWorker.nextData });
|
||||||
}, 0);
|
}, FakeWorker.nextDelay);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
@ -121,7 +122,7 @@ describe('Dep service', () => {
|
|||||||
test('collectIdle - 没有命中时立即 resolve 并 emit collected', async () => {
|
test('collectIdle - 没有命中时立即 resolve 并 emit collected', async () => {
|
||||||
const fn = vi.fn();
|
const fn = vi.fn();
|
||||||
depService.on('collected', fn);
|
depService.on('collected', fn);
|
||||||
await depService.collectIdle([{ id: 'n1', type: 'text' }] as any);
|
await expect(depService.collectIdle([{ id: 'n1', type: 'text' }] as any)).resolves.toBe(true);
|
||||||
expect(fn).toHaveBeenCalled();
|
expect(fn).toHaveBeenCalled();
|
||||||
depService.off('collected', fn);
|
depService.off('collected', fn);
|
||||||
});
|
});
|
||||||
@ -219,6 +220,106 @@ describe('Dep service', () => {
|
|||||||
fakeWorker.nextData = {};
|
fakeWorker.nextData = {};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('collectIdle 命中 target 时最终 resolve 并按批次 emit collected/ds-collected', async () => {
|
||||||
|
depService.addTarget(makeTarget('ds1', DepTargetType.DATA_SOURCE));
|
||||||
|
const collected = vi.fn();
|
||||||
|
const dsCollected = vi.fn();
|
||||||
|
depService.on('collected', collected);
|
||||||
|
depService.on('ds-collected', dsCollected);
|
||||||
|
|
||||||
|
const nodes = [{ id: 'n1', type: 'text' }] as any;
|
||||||
|
await expect(depService.collectIdle(nodes, {}, false, DepTargetType.DATA_SOURCE)).resolves.toBe(true);
|
||||||
|
|
||||||
|
expect(dsCollected).toHaveBeenCalledWith(nodes, false);
|
||||||
|
expect(collected).toHaveBeenCalledWith(nodes, false);
|
||||||
|
expect(depService.get('collecting')).toBe(false);
|
||||||
|
|
||||||
|
depService.off('collected', collected);
|
||||||
|
depService.off('ds-collected', dsCollected);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('clearIdleTasks 会结算在途 collectIdle,避免 Promise 永久挂起且 collecting 复位', async () => {
|
||||||
|
depService.addTarget(makeTarget('ds1', DepTargetType.DATA_SOURCE));
|
||||||
|
|
||||||
|
const promise = depService.collectIdle([{ id: 'n1', type: 'text' }] as any, {}, false, DepTargetType.DATA_SOURCE);
|
||||||
|
expect(depService.get('collecting')).toBe(true);
|
||||||
|
|
||||||
|
// 快速触发:任务尚未执行就清空队列,批次应被主动结算而不是永久挂起
|
||||||
|
depService.clearIdleTasks();
|
||||||
|
|
||||||
|
await expect(promise).resolves.toBe(false);
|
||||||
|
expect(depService.get('collecting')).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('reset 会结算在途 collectIdle', async () => {
|
||||||
|
depService.addTarget(makeTarget('ds1', DepTargetType.DATA_SOURCE));
|
||||||
|
|
||||||
|
const promise = depService.collectIdle([{ id: 'n1', type: 'text' }] as any, {}, false, DepTargetType.DATA_SOURCE);
|
||||||
|
depService.reset();
|
||||||
|
|
||||||
|
await expect(promise).resolves.toBe(false);
|
||||||
|
expect(depService.get('collecting')).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('reset 会忽略在途 worker 的过期结果,避免覆盖新依赖', async () => {
|
||||||
|
const fakeWorker = (await import('@editor/utils/dep/worker.ts?worker&inline')).default as any;
|
||||||
|
fakeWorker.nextDelay = 20;
|
||||||
|
fakeWorker.nextData = {
|
||||||
|
[DepTargetType.DATA_SOURCE]: { ds1: { n1: { data: {} } } },
|
||||||
|
};
|
||||||
|
|
||||||
|
const workerPromise = depService.collectByWorker({ items: [], id: 'app', type: 'app' } as any);
|
||||||
|
depService.reset();
|
||||||
|
|
||||||
|
const target = makeTarget('ds1', DepTargetType.DATA_SOURCE);
|
||||||
|
depService.addTarget(target);
|
||||||
|
const idlePromise = depService.collectIdle(
|
||||||
|
[{ id: 'n1', type: 'text' }] as any,
|
||||||
|
{},
|
||||||
|
false,
|
||||||
|
DepTargetType.DATA_SOURCE,
|
||||||
|
);
|
||||||
|
|
||||||
|
await Promise.all([workerPromise, idlePromise]);
|
||||||
|
expect(target.deps.n1).toBeUndefined();
|
||||||
|
|
||||||
|
fakeWorker.nextDelay = 0;
|
||||||
|
fakeWorker.nextData = {};
|
||||||
|
});
|
||||||
|
|
||||||
|
test('多个批次并发时各自独立 resolve,全部完成后 collecting 复位', async () => {
|
||||||
|
depService.addTarget(makeTarget('ds1', DepTargetType.DATA_SOURCE));
|
||||||
|
|
||||||
|
const p1 = depService.collectIdle([{ id: 'n1', type: 'text' }] as any, {}, false, DepTargetType.DATA_SOURCE);
|
||||||
|
const p2 = depService.collectIdle([{ id: 'n2', type: 'text' }] as any, {}, false, DepTargetType.DATA_SOURCE);
|
||||||
|
|
||||||
|
await Promise.all([p1, p2]);
|
||||||
|
expect(depService.get('collecting')).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('target 收集抛错时批次仍会结算,collecting 与 taskLength 复位', async () => {
|
||||||
|
const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => undefined);
|
||||||
|
depService.addTarget(
|
||||||
|
new Target({
|
||||||
|
id: 'throw-target',
|
||||||
|
type: DepTargetType.DATA_SOURCE,
|
||||||
|
isTarget: () => {
|
||||||
|
throw new Error('boom');
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
const nodes = Array.from({ length: 50 }, (_, i) => ({ id: `n${i}`, type: 'text', text: 'x' })) as any;
|
||||||
|
await expect(depService.collectIdle(nodes, {}, false, DepTargetType.DATA_SOURCE)).resolves.toBe(true);
|
||||||
|
|
||||||
|
expect(depService.get('collecting')).toBe(false);
|
||||||
|
// taskLength 的更新做了 1s 节流,等节流窗口结束后才会同步到 0
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 1100));
|
||||||
|
expect(depService.get('taskLength')).toBe(0);
|
||||||
|
|
||||||
|
errorSpy.mockRestore();
|
||||||
|
});
|
||||||
|
|
||||||
test('destroy 会 reset 并移除监听', () => {
|
test('destroy 会 reset 并移除监听', () => {
|
||||||
depService.addTarget(makeTarget('destroy-me'));
|
depService.addTarget(makeTarget('destroy-me'));
|
||||||
expect(() => depService.destroy()).not.toThrow();
|
expect(() => depService.destroy()).not.toThrow();
|
||||||
|
|||||||
@ -6,6 +6,7 @@
|
|||||||
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
|
import { afterEach, beforeEach, describe, expect, test, vi } from 'vitest';
|
||||||
|
|
||||||
import { IdleTask } from '@editor/utils/dep/idle-task';
|
import { IdleTask } from '@editor/utils/dep/idle-task';
|
||||||
|
import * as logger from '@editor/utils/logger';
|
||||||
|
|
||||||
const fakeIdleDeadline = (timeRemaining: number, callsBeforeZero = 1): IdleDeadline => {
|
const fakeIdleDeadline = (timeRemaining: number, callsBeforeZero = 1): IdleDeadline => {
|
||||||
let remainingCalls = callsBeforeZero;
|
let remainingCalls = callsBeforeZero;
|
||||||
@ -127,6 +128,77 @@ describe('IdleTask', () => {
|
|||||||
expect(scheduled.length).toBeGreaterThan(1);
|
expect(scheduled.length).toBeGreaterThan(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('单个任务抛错不会中断整个队列', () => {
|
||||||
|
const errorSpy = vi.spyOn(logger, 'error').mockImplementation(() => undefined);
|
||||||
|
const task = new IdleTask<number>();
|
||||||
|
const done: number[] = [];
|
||||||
|
const finishHandler = vi.fn();
|
||||||
|
task.on('finish', finishHandler);
|
||||||
|
|
||||||
|
for (let i = 0; i < 10; i++) {
|
||||||
|
task.enqueueTask((n) => {
|
||||||
|
if (n === 3) throw new Error('boom');
|
||||||
|
done.push(n);
|
||||||
|
}, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
expect(() => scheduled[0].cb(fakeIdleDeadline(50))).not.toThrow();
|
||||||
|
expect(done).toEqual([0, 1, 2, 4, 5, 6, 7, 8, 9]);
|
||||||
|
expect(finishHandler).toHaveBeenCalled();
|
||||||
|
expect(errorSpy).toHaveBeenCalled();
|
||||||
|
errorSpy.mockRestore();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('任务抛错且仍有剩余任务时继续调度下一轮并同步任务数', () => {
|
||||||
|
const errorSpy = vi.spyOn(logger, 'error').mockImplementation(() => undefined);
|
||||||
|
const task = new IdleTask<number>();
|
||||||
|
const updateHandler = vi.fn();
|
||||||
|
task.on('update-task-length', updateHandler);
|
||||||
|
|
||||||
|
for (let i = 0; i < 200; i++) {
|
||||||
|
task.enqueueTask((n) => {
|
||||||
|
if (n === 0) throw new Error('boom');
|
||||||
|
}, i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 单批最多执行 10 个,执行完仍有剩余任务
|
||||||
|
scheduled[0].cb(fakeIdleDeadline(3, 1));
|
||||||
|
|
||||||
|
expect(scheduled.length).toBeGreaterThan(1);
|
||||||
|
expect(updateHandler).toHaveBeenCalledWith({ length: 190, hightLevelLength: 0 });
|
||||||
|
errorSpy.mockRestore();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('任务执行过程中 clearTasks 会立即停止消费已清空的队列', () => {
|
||||||
|
const task = new IdleTask<number>();
|
||||||
|
const handler = vi.fn((n: number) => {
|
||||||
|
if (n === 0) {
|
||||||
|
task.clearTasks();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
for (let i = 0; i < 200; i++) task.enqueueTask(handler, i);
|
||||||
|
|
||||||
|
scheduled[0].cb(fakeIdleDeadline(50));
|
||||||
|
|
||||||
|
expect(handler).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('任务执行过程中清空并重新入队,新任务仍会被执行', () => {
|
||||||
|
const task = new IdleTask<number>();
|
||||||
|
const afterHandler = vi.fn();
|
||||||
|
task.enqueueTask((n) => {
|
||||||
|
if (n === 0) {
|
||||||
|
task.clearTasks();
|
||||||
|
task.enqueueTask(afterHandler, 999);
|
||||||
|
}
|
||||||
|
}, 0);
|
||||||
|
for (let i = 1; i < 200; i++) task.enqueueTask(() => undefined, i);
|
||||||
|
|
||||||
|
scheduled[0].cb(fakeIdleDeadline(50));
|
||||||
|
|
||||||
|
expect(afterHandler).toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
test('clearTasks - 取消挂起任务并重置队列', () => {
|
test('clearTasks - 取消挂起任务并重置队列', () => {
|
||||||
const task = new IdleTask<number>();
|
const task = new IdleTask<number>();
|
||||||
task.enqueueTask(() => undefined, 1);
|
task.enqueueTask(() => undefined, 1);
|
||||||
|
|||||||
@ -3,10 +3,9 @@
|
|||||||
*
|
*
|
||||||
* Copyright (C) 2025 Tencent.
|
* Copyright (C) 2025 Tencent.
|
||||||
*/
|
*/
|
||||||
import { beforeEach, describe, expect, test, vi } from 'vitest';
|
import { describe, expect, test, vi } from 'vitest';
|
||||||
|
|
||||||
import { NODE_CONDS_RESULT_KEY } from '@tmagic/core';
|
import { NODE_CONDS_RESULT_KEY } from '@tmagic/core';
|
||||||
import { validateForm } from '@tmagic/form';
|
|
||||||
|
|
||||||
import {
|
import {
|
||||||
advancedTabConfig,
|
advancedTabConfig,
|
||||||
@ -20,7 +19,6 @@ import {
|
|||||||
numberOptions,
|
numberOptions,
|
||||||
removeStyleDisplayConfig,
|
removeStyleDisplayConfig,
|
||||||
styleTabConfig,
|
styleTabConfig,
|
||||||
validatePropsForm,
|
|
||||||
} from '@editor/utils/props';
|
} from '@editor/utils/props';
|
||||||
|
|
||||||
vi.mock('@tmagic/design', () => ({
|
vi.mock('@tmagic/design', () => ({
|
||||||
@ -172,59 +170,6 @@ describe('fillConfig', () => {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('validatePropsForm', () => {
|
|
||||||
beforeEach(() => {
|
|
||||||
vi.mocked(validateForm).mockReset();
|
|
||||||
});
|
|
||||||
|
|
||||||
test('合入 appContext.provides、注入 stage/services 并合并外部 extendState,debug 默认 undefined', async () => {
|
|
||||||
vi.mocked(validateForm).mockResolvedValue('err-text');
|
|
||||||
|
|
||||||
const services = { uiService: {} } as any;
|
|
||||||
const stage = { id: 'stage' };
|
|
||||||
const appContext = { app: {}, provides: { foo: 1 } } as any;
|
|
||||||
|
|
||||||
const result = await validatePropsForm({
|
|
||||||
config: [],
|
|
||||||
values: { a: 1 },
|
|
||||||
appContext,
|
|
||||||
services,
|
|
||||||
stage,
|
|
||||||
extendState: async () => ({ extra: true }),
|
|
||||||
});
|
|
||||||
|
|
||||||
// 直接返回 validateForm 的结果
|
|
||||||
expect(result).toBe('err-text');
|
|
||||||
|
|
||||||
const arg = vi.mocked(validateForm).mock.calls[0][0];
|
|
||||||
expect(arg.config).toEqual([]);
|
|
||||||
expect(arg.debug).toBeUndefined();
|
|
||||||
expect(arg.initValues).toEqual({ a: 1 });
|
|
||||||
// appContext 保留原字段,但 provides 被替换为 { services }
|
|
||||||
expect(arg.appContext).toEqual({ app: {}, provides: { services } });
|
|
||||||
|
|
||||||
// extendState 合并外部返回并注入 stage/services
|
|
||||||
const state = await arg.extendState!({} as any);
|
|
||||||
expect(state).toEqual({ extra: true, stage, services });
|
|
||||||
});
|
|
||||||
|
|
||||||
test('appContext 缺省为 null,extendState 缺省时仍注入 stage/services,可覆盖 debug', async () => {
|
|
||||||
vi.mocked(validateForm).mockResolvedValue('');
|
|
||||||
|
|
||||||
const services = {} as any;
|
|
||||||
const stage = {};
|
|
||||||
|
|
||||||
await validatePropsForm({ config: [], values: {}, services, stage, debug: false });
|
|
||||||
|
|
||||||
const arg = vi.mocked(validateForm).mock.calls[0][0];
|
|
||||||
expect(arg.appContext).toBeNull();
|
|
||||||
expect(arg.debug).toBe(false);
|
|
||||||
|
|
||||||
const state = await arg.extendState!({} as any);
|
|
||||||
expect(state).toEqual({ stage, services });
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
describe('removeStyleDisplayConfig', () => {
|
describe('removeStyleDisplayConfig', () => {
|
||||||
test('将 tab 内「样式」pane 的 display 置为 true', () => {
|
test('将 tab 内「样式」pane 的 display 置为 true', () => {
|
||||||
const config = [
|
const config = [
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "1.8.0-beta.15",
|
"version": "1.8.0-beta.19",
|
||||||
"name": "@tmagic/element-plus-adapter",
|
"name": "@tmagic/element-plus-adapter",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "1.8.0-beta.15",
|
"version": "1.8.0-beta.19",
|
||||||
"name": "@tmagic/form-schema",
|
"name": "@tmagic/form-schema",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "1.8.0-beta.15",
|
"version": "1.8.0-beta.19",
|
||||||
"name": "@tmagic/form",
|
"name": "@tmagic/form",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"sideEffects": [
|
"sideEffects": [
|
||||||
|
|||||||
@ -88,6 +88,13 @@ const props = withDefaults(
|
|||||||
labelWidth?: string;
|
labelWidth?: string;
|
||||||
/** 是否开启类型匹配校验 */
|
/** 是否开启类型匹配校验 */
|
||||||
typeMatchValid?: boolean;
|
typeMatchValid?: boolean;
|
||||||
|
/**
|
||||||
|
* 初始化(`config` / `initValues` 就绪)后是否立即执行一次表单校验。
|
||||||
|
*
|
||||||
|
* - `false`(默认):不自动校验,避免打开表单时就展示错误态;
|
||||||
|
* - `true`:初始化完成后在 `nextTick` 中调用 `validate()`。
|
||||||
|
*/
|
||||||
|
validateOnInit?: boolean;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
height?: string;
|
height?: string;
|
||||||
stepActive?: string | number;
|
stepActive?: string | number;
|
||||||
@ -156,6 +163,7 @@ const props = withDefaults(
|
|||||||
labelPosition: 'right',
|
labelPosition: 'right',
|
||||||
keyProp: '__key',
|
keyProp: '__key',
|
||||||
useFieldTextInError: true,
|
useFieldTextInError: true,
|
||||||
|
validateOnInit: false,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -261,6 +269,18 @@ const formState: FormState = reactive<FormState>({
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* formState 的内置 key 快照(keyProp / values / $emit / fields / post 等)。
|
||||||
|
*
|
||||||
|
* 在 `extendState` 首次合并前捕获,`applyExtendState` 会据此禁止 `extendState`
|
||||||
|
* 覆盖这些已有字段(只能新增字段),避免表单核心状态被外部意外改写。
|
||||||
|
*
|
||||||
|
* 之所以在此处(effect 之外)捕获而不是在 `applyExtendState` 内动态取:
|
||||||
|
* `watchEffect` 会在依赖变化时重跑,若动态取,`extendState` 自己新增的字段在第二次
|
||||||
|
* 合并时也会被当成「已有 key」而拒绝刷新;这里只锁定内置字段即可规避该问题。
|
||||||
|
*/
|
||||||
|
const reservedStateKeys = new Set<string | symbol>(Reflect.ownKeys(formState));
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* `extendState` 的同步段(直到第一个 `await` 之前)所访问的任何响应式数据,
|
* `extendState` 的同步段(直到第一个 `await` 之前)所访问的任何响应式数据,
|
||||||
* 都会被 `watchEffect` 自动跟踪。这样可以兼容历史用法 ——
|
* 都会被 `watchEffect` 自动跟踪。这样可以兼容历史用法 ——
|
||||||
@ -299,7 +319,7 @@ watchEffect(async (onCleanup) => {
|
|||||||
}
|
}
|
||||||
if (stale) return;
|
if (stale) return;
|
||||||
|
|
||||||
applyExtendState(formState, state);
|
applyExtendState(formState, state, reservedStateKeys);
|
||||||
});
|
});
|
||||||
|
|
||||||
provide('mForm', formState);
|
provide('mForm', formState);
|
||||||
@ -341,9 +361,11 @@ watch(
|
|||||||
// 非对比模式,初始化完成
|
// 非对比模式,初始化完成
|
||||||
initialized.value = !props.isCompare;
|
initialized.value = !props.isCompare;
|
||||||
|
|
||||||
nextTick(() => {
|
if (props.validateOnInit) {
|
||||||
tMagicFormRef.value?.validate();
|
nextTick(() => {
|
||||||
});
|
tMagicFormRef.value?.validate();
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
if (props.isCompare) {
|
if (props.isCompare) {
|
||||||
|
|||||||
@ -16,6 +16,7 @@
|
|||||||
:use-field-text-in-error="useFieldTextInError"
|
:use-field-text-in-error="useFieldTextInError"
|
||||||
:extend-state="extendState"
|
:extend-state="extendState"
|
||||||
:type-match-valid="typeMatchValid"
|
:type-match-valid="typeMatchValid"
|
||||||
|
:validate-on-init="validateOnInit"
|
||||||
@change="changeHandler"
|
@change="changeHandler"
|
||||||
></Form>
|
></Form>
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
@ -59,6 +60,8 @@ const props = withDefaults(
|
|||||||
labelWidth?: string;
|
labelWidth?: string;
|
||||||
/** 是否开启类型匹配校验 */
|
/** 是否开启类型匹配校验 */
|
||||||
typeMatchValid?: boolean;
|
typeMatchValid?: boolean;
|
||||||
|
/** 透传给内部 `MForm`,初始化完成后是否立即校验(默认 `false`) */
|
||||||
|
validateOnInit?: boolean;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
size?: 'small' | 'default' | 'large';
|
size?: 'small' | 'default' | 'large';
|
||||||
confirmText?: string;
|
confirmText?: string;
|
||||||
@ -74,6 +77,7 @@ const props = withDefaults(
|
|||||||
values: () => ({}),
|
values: () => ({}),
|
||||||
confirmText: '确定',
|
confirmText: '确定',
|
||||||
useFieldTextInError: true,
|
useFieldTextInError: true,
|
||||||
|
validateOnInit: false,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -33,6 +33,7 @@
|
|||||||
:prevent-submit-default="preventSubmitDefault"
|
:prevent-submit-default="preventSubmitDefault"
|
||||||
:use-field-text-in-error="useFieldTextInError"
|
:use-field-text-in-error="useFieldTextInError"
|
||||||
:type-match-valid="typeMatchValid"
|
:type-match-valid="typeMatchValid"
|
||||||
|
:validate-on-init="validateOnInit"
|
||||||
:extend-state="extendState"
|
:extend-state="extendState"
|
||||||
:theme="effectiveTheme"
|
:theme="effectiveTheme"
|
||||||
@change="changeHandler"
|
@change="changeHandler"
|
||||||
@ -87,6 +88,8 @@ const props = withDefaults(
|
|||||||
labelWidth?: string;
|
labelWidth?: string;
|
||||||
/** 是否开启类型匹配校验 */
|
/** 是否开启类型匹配校验 */
|
||||||
typeMatchValid?: boolean;
|
typeMatchValid?: boolean;
|
||||||
|
/** 透传给内部 `MForm`,初始化完成后是否立即校验(默认 `false`) */
|
||||||
|
validateOnInit?: boolean;
|
||||||
fullscreen?: boolean;
|
fullscreen?: boolean;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
title?: string;
|
title?: string;
|
||||||
@ -122,6 +125,7 @@ const props = withDefaults(
|
|||||||
showClose: true,
|
showClose: true,
|
||||||
showCancel: true,
|
showCancel: true,
|
||||||
useFieldTextInError: true,
|
useFieldTextInError: true,
|
||||||
|
validateOnInit: false,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -30,6 +30,7 @@
|
|||||||
:prevent-submit-default="preventSubmitDefault"
|
:prevent-submit-default="preventSubmitDefault"
|
||||||
:use-field-text-in-error="useFieldTextInError"
|
:use-field-text-in-error="useFieldTextInError"
|
||||||
:type-match-valid="typeMatchValid"
|
:type-match-valid="typeMatchValid"
|
||||||
|
:validate-on-init="validateOnInit"
|
||||||
:extend-state="extendState"
|
:extend-state="extendState"
|
||||||
:theme="effectiveTheme"
|
:theme="effectiveTheme"
|
||||||
@change="changeHandler"
|
@change="changeHandler"
|
||||||
@ -78,6 +79,8 @@ const props = withDefaults(
|
|||||||
labelWidth?: string;
|
labelWidth?: string;
|
||||||
/** 是否开启类型匹配校验 */
|
/** 是否开启类型匹配校验 */
|
||||||
typeMatchValid?: boolean;
|
typeMatchValid?: boolean;
|
||||||
|
/** 透传给内部 `MForm`,初始化完成后是否立即校验(默认 `false`) */
|
||||||
|
validateOnInit?: boolean;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
closeOnPressEscape?: boolean;
|
closeOnPressEscape?: boolean;
|
||||||
title?: string;
|
title?: string;
|
||||||
@ -106,6 +109,7 @@ const props = withDefaults(
|
|||||||
values: () => ({}),
|
values: () => ({}),
|
||||||
confirmText: '确定',
|
confirmText: '确定',
|
||||||
useFieldTextInError: true,
|
useFieldTextInError: true,
|
||||||
|
validateOnInit: false,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@ -87,6 +87,11 @@ export interface SubmitFormOptions {
|
|||||||
*/
|
*/
|
||||||
debug?: boolean;
|
debug?: boolean;
|
||||||
typeMatchValid?: boolean;
|
typeMatchValid?: boolean;
|
||||||
|
/**
|
||||||
|
* 外部中断信号。abort 时会立即以 `signal.reason` reject 并卸载临时表单实例、移除容器。
|
||||||
|
* 主要用于 `debug` 模式(无超时兜底)下取消一个被放弃的表单弹层,避免其无限驻留在页面上。
|
||||||
|
*/
|
||||||
|
signal?: AbortSignal;
|
||||||
}
|
}
|
||||||
// #endregion SubmitFormOptions
|
// #endregion SubmitFormOptions
|
||||||
|
|
||||||
@ -127,7 +132,7 @@ interface MountFormInstanceOptions<T> {
|
|||||||
formProps: Record<string, any>;
|
formProps: Record<string, any>;
|
||||||
/** 父级应用上下文,用于继承全局组件、指令、provide 等 */
|
/** 父级应用上下文,用于继承全局组件、指令、provide 等 */
|
||||||
appContext?: AppContext | null;
|
appContext?: AppContext | null;
|
||||||
/** 等待表单初始化的最长时间(毫秒),<=0 表示不注册超时 */
|
/** 等待表单初始化的最长时间(毫秒),<=0 时回退到默认超时以保证兜底清理生效 */
|
||||||
timeout: number;
|
timeout: number;
|
||||||
/** 超时 reject 的错误文案 */
|
/** 超时 reject 的错误文案 */
|
||||||
timeoutMessage: string;
|
timeoutMessage: string;
|
||||||
@ -135,10 +140,15 @@ interface MountFormInstanceOptions<T> {
|
|||||||
hidden?: boolean;
|
hidden?: boolean;
|
||||||
/** 是否跳过超时注册。调试模式等待人工操作,应传 `true` */
|
/** 是否跳过超时注册。调试模式等待人工操作,应传 `true` */
|
||||||
skipTimeout?: boolean;
|
skipTimeout?: boolean;
|
||||||
|
/** 外部中断信号:abort 时会 reject 并卸载实例、移除容器,用于取消无超时(如 debug)的挂载 */
|
||||||
|
signal?: AbortSignal;
|
||||||
/** 构造 wrapper 组件 */
|
/** 构造 wrapper 组件 */
|
||||||
createWrapper: FormWrapperFactory<T>;
|
createWrapper: FormWrapperFactory<T>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 未指定或传入非正数 timeout 时的兜底超时(毫秒),保证非 debug 挂载始终能被清理 */
|
||||||
|
const DEFAULT_MOUNT_TIMEOUT = 10000;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* submitForm / validateForm 的公共脚手架:
|
* submitForm / validateForm 的公共脚手架:
|
||||||
*
|
*
|
||||||
@ -149,20 +159,36 @@ interface MountFormInstanceOptions<T> {
|
|||||||
* 容器创建、卸载、超时、上下文注入等模板代码在此统一收口。
|
* 容器创建、卸载、超时、上下文注入等模板代码在此统一收口。
|
||||||
*/
|
*/
|
||||||
const mountFormInstance = <T>(options: MountFormInstanceOptions<T>): Promise<T> => {
|
const mountFormInstance = <T>(options: MountFormInstanceOptions<T>): Promise<T> => {
|
||||||
const { formProps, appContext, timeout, timeoutMessage, hidden = true, skipTimeout = false, createWrapper } = options;
|
const {
|
||||||
|
formProps,
|
||||||
|
appContext,
|
||||||
|
timeout,
|
||||||
|
timeoutMessage,
|
||||||
|
hidden = true,
|
||||||
|
skipTimeout = false,
|
||||||
|
signal,
|
||||||
|
createWrapper,
|
||||||
|
} = options;
|
||||||
|
|
||||||
return new Promise<T>((resolve, reject) => {
|
return new Promise<T>((resolve, reject) => {
|
||||||
|
// 已中断则直接 reject,不创建任何容器/实例
|
||||||
|
if (signal?.aborted) {
|
||||||
|
reject(signal.reason ?? new Error('mountFormInstance aborted'));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let cleaned = false;
|
||||||
|
let timer: ReturnType<typeof setTimeout> | null = null;
|
||||||
|
let onAbort: (() => void) | null = null;
|
||||||
|
// 用 holder 持有 app,使 cleanup 可在 app 创建之前定义(const app + 无 TDZ / 无 use-before-define)
|
||||||
|
const instance: { app: ReturnType<typeof createApp> | null } = { app: null };
|
||||||
|
|
||||||
const container = document.createElement('div');
|
const container = document.createElement('div');
|
||||||
if (hidden) {
|
if (hidden) {
|
||||||
container.style.display = 'none';
|
container.style.display = 'none';
|
||||||
}
|
}
|
||||||
document.body.appendChild(container);
|
document.body.appendChild(container);
|
||||||
|
|
||||||
let cleaned = false;
|
|
||||||
let timer: ReturnType<typeof setTimeout> | null = null;
|
|
||||||
// 用 holder 持有 app,使 cleanup 可在 app 创建之前定义(const app + 无 TDZ / 无 use-before-define)
|
|
||||||
const instance: { app: ReturnType<typeof createApp> | null } = { app: null };
|
|
||||||
|
|
||||||
const cleanup = () => {
|
const cleanup = () => {
|
||||||
if (cleaned) return;
|
if (cleaned) return;
|
||||||
cleaned = true;
|
cleaned = true;
|
||||||
@ -170,6 +196,10 @@ const mountFormInstance = <T>(options: MountFormInstanceOptions<T>): Promise<T>
|
|||||||
clearTimeout(timer);
|
clearTimeout(timer);
|
||||||
timer = null;
|
timer = null;
|
||||||
}
|
}
|
||||||
|
if (signal && onAbort) {
|
||||||
|
signal.removeEventListener('abort', onAbort);
|
||||||
|
onAbort = null;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
instance.app?.unmount();
|
instance.app?.unmount();
|
||||||
} catch {
|
} catch {
|
||||||
@ -178,81 +208,101 @@ const mountFormInstance = <T>(options: MountFormInstanceOptions<T>): Promise<T>
|
|||||||
container.parentNode?.removeChild(container);
|
container.parentNode?.removeChild(container);
|
||||||
};
|
};
|
||||||
|
|
||||||
const formRef = ref<any>(null);
|
// 支持外部通过 AbortSignal 主动中断:debug 模式无超时兜底,若调用方放弃了该 Promise,
|
||||||
|
// 可通过 abort 卸载实例、移除遮罩/容器,避免无限驻留在 DOM 中。
|
||||||
|
if (signal) {
|
||||||
|
onAbort = () => {
|
||||||
|
if (cleaned) return;
|
||||||
|
reject(signal.reason ?? new Error('mountFormInstance aborted'));
|
||||||
|
cleanup();
|
||||||
|
};
|
||||||
|
signal.addEventListener('abort', onAbort);
|
||||||
|
}
|
||||||
|
|
||||||
// 将 extendState 从 formProps 中剥离:不由 Form.vue 的 async watchEffect 异步应用,
|
// 从容器创建到 mount 的全流程统一 try/catch:任一步骤(createWrapper/createApp/上下文合并/mount)
|
||||||
// 而是在 wrapper 中通过 sync watch 在 formRef 就绪后直接写入 formState,
|
// 抛错都会走到 cleanup,避免已插入 body 的 container 及未挂载的 app 残留导致泄漏。
|
||||||
// 避免 display 等 filterFunction 在首次渲染时读到 undefined。
|
try {
|
||||||
// 与 CompareForm / FormPanel 中「formRef.value.formState.services = ...」的做法一致。
|
const formRef = ref<any>(null);
|
||||||
const { extendState, ...restFormProps } = formProps;
|
|
||||||
|
|
||||||
const userWrapper = createWrapper({ formRef, formProps: restFormProps, cleanup, resolve, reject });
|
// 将 extendState 从 formProps 中剥离:不由 Form.vue 的 async watchEffect 异步应用,
|
||||||
|
// 而是在 wrapper 中通过 sync watch 在 formRef 就绪后直接写入 formState,
|
||||||
|
// 避免 display 等 filterFunction 在首次渲染时读到 undefined。
|
||||||
|
// 与 CompareForm / FormPanel 中「formRef.value.formState.services = ...」的做法一致。
|
||||||
|
const { extendState, ...restFormProps } = formProps;
|
||||||
|
|
||||||
const wrapperComponent =
|
const userWrapper = createWrapper({ formRef, formProps: restFormProps, cleanup, resolve, reject });
|
||||||
typeof extendState === 'function'
|
|
||||||
|
const wrapperComponent =
|
||||||
|
typeof extendState === 'function'
|
||||||
|
? defineComponent({
|
||||||
|
name: 'MFormExtendStateInjector',
|
||||||
|
setup() {
|
||||||
|
watch(
|
||||||
|
() => formRef.value,
|
||||||
|
(form) => {
|
||||||
|
if (!form) return;
|
||||||
|
let result: any;
|
||||||
|
try {
|
||||||
|
result = extendState(form.formState);
|
||||||
|
} catch (e) {
|
||||||
|
console.error('[MForm] extendState failed:', e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// formState 的内置 key 快照:在 extendState 合并前捕获,
|
||||||
|
// 供 applyExtendState 禁止 extendState 覆盖这些已有字段(只能新增),
|
||||||
|
// 与 Form.vue 中 reservedStateKeys 的语义保持一致。
|
||||||
|
const reservedStateKeys = new Set<string | symbol>(Reflect.ownKeys(form.formState));
|
||||||
|
// 合并逻辑收口在 applyExtendState:props 派生的只读 getter 字段
|
||||||
|
// (keyProp 等)以普通字段形式返回时会被跳过并告警,避免 proxy set 抛错
|
||||||
|
const apply = (state: Record<string, any> | null | undefined) =>
|
||||||
|
applyExtendState(form.formState, state, reservedStateKeys);
|
||||||
|
if (result && typeof result.then === 'function') {
|
||||||
|
result.then(apply, (e: any) => console.error('[MForm] extendState failed:', e));
|
||||||
|
} else {
|
||||||
|
apply(result);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ flush: 'sync', immediate: true },
|
||||||
|
);
|
||||||
|
return () => h(userWrapper);
|
||||||
|
},
|
||||||
|
})
|
||||||
|
: userWrapper;
|
||||||
|
|
||||||
|
// 静默(隐藏挂载)模式下注入静默标记:vs-code 等重型字段组件可据此跳过自身渲染,
|
||||||
|
// 校验/取值依赖 FormItem 与 model 值,与叶子 UI 组件无关(见 FORM_SILENT_MODE_KEY 注释)。
|
||||||
|
// 用组件级 provide 而非 app.provide:appContext 合并后 app._context.provides 与父级应用
|
||||||
|
// 共享引用,app.provide 会把标记泄漏到父级应用。
|
||||||
|
const rootComponent = hidden
|
||||||
? defineComponent({
|
? defineComponent({
|
||||||
name: 'MFormExtendStateInjector',
|
name: 'MFormSilentProvider',
|
||||||
setup() {
|
setup() {
|
||||||
watch(
|
provide(FORM_SILENT_MODE_KEY, true);
|
||||||
() => formRef.value,
|
return () => h(wrapperComponent);
|
||||||
(form) => {
|
|
||||||
if (!form) return;
|
|
||||||
let result: any;
|
|
||||||
try {
|
|
||||||
result = extendState(form.formState);
|
|
||||||
} catch (e) {
|
|
||||||
console.error('[MForm] extendState failed:', e);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
// 合并逻辑收口在 applyExtendState:props 派生的只读 getter 字段
|
|
||||||
// (keyProp 等)以普通字段形式返回时会被跳过并告警,避免 proxy set 抛错
|
|
||||||
const apply = (state: Record<string, any> | null | undefined) =>
|
|
||||||
applyExtendState(form.formState, state);
|
|
||||||
if (result && typeof result.then === 'function') {
|
|
||||||
result.then(apply, (e: any) => console.error('[MForm] extendState failed:', e));
|
|
||||||
} else {
|
|
||||||
apply(result);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{ flush: 'sync', immediate: true },
|
|
||||||
);
|
|
||||||
return () => h(userWrapper);
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
: userWrapper;
|
: wrapperComponent;
|
||||||
|
|
||||||
// 静默(隐藏挂载)模式下注入静默标记:vs-code 等重型字段组件可据此跳过自身渲染,
|
const app = createApp(rootComponent);
|
||||||
// 校验/取值依赖 FormItem 与 model 值,与叶子 UI 组件无关(见 FORM_SILENT_MODE_KEY 注释)。
|
instance.app = app;
|
||||||
// 用组件级 provide 而非 app.provide:appContext 合并后 app._context.provides 与父级应用
|
|
||||||
// 共享引用,app.provide 会把标记泄漏到父级应用。
|
|
||||||
const rootComponent = hidden
|
|
||||||
? defineComponent({
|
|
||||||
name: 'MFormSilentProvider',
|
|
||||||
setup() {
|
|
||||||
provide(FORM_SILENT_MODE_KEY, true);
|
|
||||||
return () => h(wrapperComponent);
|
|
||||||
},
|
|
||||||
})
|
|
||||||
: wrapperComponent;
|
|
||||||
|
|
||||||
const app = createApp(rootComponent);
|
// 继承父级应用上下文(components / directives / provides / config 等)
|
||||||
instance.app = app;
|
if (appContext) {
|
||||||
|
Object.assign(app._context, appContext);
|
||||||
|
}
|
||||||
|
|
||||||
// 继承父级应用上下文(components / directives / provides / config 等)
|
// 非 debug(未跳过超时)场景始终注册超时兜底:timeout 为非正数时回退到默认值,
|
||||||
if (appContext) {
|
// 避免表单永不初始化时实例/容器/watcher 无限驻留而泄漏。
|
||||||
Object.assign(app._context, appContext);
|
if (!skipTimeout) {
|
||||||
}
|
const effectiveTimeout = timeout > 0 ? timeout : DEFAULT_MOUNT_TIMEOUT;
|
||||||
|
timer = setTimeout(() => {
|
||||||
|
if (!cleaned) {
|
||||||
|
reject(new Error(timeoutMessage));
|
||||||
|
cleanup();
|
||||||
|
}
|
||||||
|
}, effectiveTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
if (timeout > 0 && !skipTimeout) {
|
|
||||||
timer = setTimeout(() => {
|
|
||||||
if (!cleaned) {
|
|
||||||
reject(new Error(timeoutMessage));
|
|
||||||
cleanup();
|
|
||||||
}
|
|
||||||
}, timeout);
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
app.mount(container);
|
app.mount(container);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
reject(err);
|
reject(err);
|
||||||
@ -450,12 +500,13 @@ const createDebugWrapper = (options: DebugWrapperOptions): Component => {
|
|||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
export const submitForm = (options: SubmitFormOptions): Promise<any> => {
|
export const submitForm = (options: SubmitFormOptions): Promise<any> => {
|
||||||
const { native, appContext, timeout = 10000, returnChangeRecords, debug = false, ...formProps } = options;
|
const { native, appContext, timeout = 10000, returnChangeRecords, debug = false, signal, ...formProps } = options;
|
||||||
|
|
||||||
return mountFormInstance<any>({
|
return mountFormInstance<any>({
|
||||||
formProps,
|
formProps,
|
||||||
appContext,
|
appContext,
|
||||||
timeout,
|
timeout,
|
||||||
|
signal,
|
||||||
// 调试模式需把表单展示出来;普通模式隐藏挂载
|
// 调试模式需把表单展示出来;普通模式隐藏挂载
|
||||||
hidden: !debug,
|
hidden: !debug,
|
||||||
// 调试模式等待人工操作,不应用超时
|
// 调试模式等待人工操作,不应用超时
|
||||||
@ -559,6 +610,11 @@ export interface ValidateFormOptions {
|
|||||||
*/
|
*/
|
||||||
debug?: boolean;
|
debug?: boolean;
|
||||||
typeMatchValid?: boolean;
|
typeMatchValid?: boolean;
|
||||||
|
/**
|
||||||
|
* 外部中断信号。abort 时会立即以 `signal.reason` reject 并卸载临时表单实例、移除容器。
|
||||||
|
* 主要用于 `debug` 模式(无超时兜底)下取消一个被放弃的表单弹层,避免其无限驻留在页面上。
|
||||||
|
*/
|
||||||
|
signal?: AbortSignal;
|
||||||
}
|
}
|
||||||
// #endregion ValidateFormOptions
|
// #endregion ValidateFormOptions
|
||||||
|
|
||||||
@ -654,7 +710,7 @@ export const stripTabItemsLazy = (config: FormConfig): FormConfig => {
|
|||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
export const validateForm = (options: ValidateFormOptions): Promise<string> => {
|
export const validateForm = (options: ValidateFormOptions): Promise<string> => {
|
||||||
const { appContext, timeout = 10000, debug = false, config, ...rest } = options;
|
const { appContext, timeout = 10000, debug = false, config, signal, ...rest } = options;
|
||||||
|
|
||||||
// 去掉 tab 容器各标签页的 lazy,确保懒加载标签页内的字段也参与校验
|
// 去掉 tab 容器各标签页的 lazy,确保懒加载标签页内的字段也参与校验
|
||||||
const formProps = { ...rest, config: stripTabItemsLazy(config) };
|
const formProps = { ...rest, config: stripTabItemsLazy(config) };
|
||||||
@ -663,6 +719,7 @@ export const validateForm = (options: ValidateFormOptions): Promise<string> => {
|
|||||||
formProps,
|
formProps,
|
||||||
appContext,
|
appContext,
|
||||||
timeout,
|
timeout,
|
||||||
|
signal,
|
||||||
// 调试模式需把表单展示出来;普通模式隐藏挂载
|
// 调试模式需把表单展示出来;普通模式隐藏挂载
|
||||||
hidden: !debug,
|
hidden: !debug,
|
||||||
// 调试模式等待人工操作,不应用超时
|
// 调试模式等待人工操作,不应用超时
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
.m-fields-group-list-item.tmagic-design-card--flat:last-child {
|
.m-fields-group-list-item.tmagic-design-card--flat:last-child {
|
||||||
border: 0;
|
border: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.el-button--text {
|
.el-button--text {
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin-bottom: 7px;
|
margin-bottom: 7px;
|
||||||
@ -32,9 +31,19 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.m-fields-group-list-footer {
|
.m-fields-group-list-footer {
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
justify-content: space-between;
|
||||||
margin-top: 10px;
|
margin-top: 10px;
|
||||||
margin-bottom: 16px;
|
margin-bottom: 16px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** 最外层的groupList需要每个item需要增加空白区域界限时,增加outer-gorup_list可以实现 */
|
||||||
|
.m-container-group-list {
|
||||||
|
&.outer-gorup_list {
|
||||||
|
> .m-fields-group-list {
|
||||||
|
> .m-fields-group-list-item {
|
||||||
|
margin-bottom: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@ -92,4 +92,15 @@
|
|||||||
text-align: left;
|
text-align: left;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.m-fields-group-list {
|
||||||
|
.el-table__empty-block {
|
||||||
|
.el-table__empty-text {
|
||||||
|
width: 100%;
|
||||||
|
background-color: rgba(0, 0, 0, 0.03);
|
||||||
|
margin-top: 8px;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -60,13 +60,15 @@ export const adaptFormValidator = (validator: AsyncValidatorFn): AsyncValidatorF
|
|||||||
const value = arg1;
|
const value = arg1;
|
||||||
return new Promise((resolve) => {
|
return new Promise((resolve) => {
|
||||||
let settled = false;
|
let settled = false;
|
||||||
const callback = (error?: Error | string) => {
|
const callback = (error?: Error | string | (Error | string)[]) => {
|
||||||
if (settled) return;
|
if (settled) return;
|
||||||
settled = true;
|
settled = true;
|
||||||
if (error) {
|
// async-validator 约定 callback 也可接收错误数组,TDesign 只能展示一条,取首条
|
||||||
|
const first = Array.isArray(error) ? error[0] : error;
|
||||||
|
if (first) {
|
||||||
resolve({
|
resolve({
|
||||||
result: false,
|
result: false,
|
||||||
message: typeof error === 'string' ? error : error.message,
|
message: typeof first === 'string' ? first : first.message,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
resolve(true);
|
resolve(true);
|
||||||
@ -74,8 +76,9 @@ export const adaptFormValidator = (validator: AsyncValidatorFn): AsyncValidatorF
|
|||||||
};
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
// 异步 validator 会先返回 undefined,稍后再调 callback,这里不能当成 thenable 取值
|
||||||
const result = validator(undefined, value, callback);
|
const result = validator(undefined, value, callback);
|
||||||
if (result !== null && typeof (result as PromiseLike<unknown>).then === 'function') {
|
if (result && typeof (result as PromiseLike<unknown>).then === 'function') {
|
||||||
Promise.resolve(result).then(
|
Promise.resolve(result).then(
|
||||||
() => {
|
() => {
|
||||||
if (!settled) callback();
|
if (!settled) callback();
|
||||||
@ -449,16 +452,27 @@ export const sortChange = (data: any[], { prop, order }: SortProp) => {
|
|||||||
* - accessor 描述符(`{ get stage() { return ... } }`)按原样 defineProperty,调用方
|
* - accessor 描述符(`{ get stage() { return ... } }`)按原样 defineProperty,调用方
|
||||||
* 可控制读时求值;强制 `configurable: true` 以便下一次合并可再 define。
|
* 可控制读时求值;强制 `configurable: true` 以便下一次合并可再 define。
|
||||||
*
|
*
|
||||||
* 注意:formState 上由 props 派生的字段(keyProp / popperClass / config / initValues /
|
* 注意:extendState 只能向 formState「新增」字段,不允许覆盖其已有 key。
|
||||||
* isCompare / lastValues / parentValues)是只读 getter(无 setter),extendState 若以
|
* 调用方可通过 `reservedKeys` 传入合并前已存在的内置 key 快照(keyProp / popperClass /
|
||||||
* 普通字段形式返回同名 key,直接赋值会让 proxy 的 set trap 失败并抛出
|
* config / initValues / isCompare / lastValues / parentValues / values / $emit / fields /
|
||||||
* `TypeError: 'set' on proxy: trap returned falsish`,这里统一跳过并告警;
|
* post 等),命中这些 key 时统一跳过并告警。
|
||||||
* 如确需覆盖,可在 extendState 中以 get 访问器形式返回。
|
*
|
||||||
|
* 兜底:未传 `reservedKeys` 时,仍会拦截 props 派生的只读 getter 字段(无 setter),
|
||||||
|
* 否则以普通字段形式赋值会让 proxy 的 set trap 抛出
|
||||||
|
* `TypeError: 'set' on proxy: trap returned falsish`。
|
||||||
*/
|
*/
|
||||||
export const applyExtendState = (formState: FormState, state: Record<string, any> | null | undefined): void => {
|
export const applyExtendState = (
|
||||||
|
formState: FormState,
|
||||||
|
state: Record<string, any> | null | undefined,
|
||||||
|
reservedKeys?: Set<string | symbol>,
|
||||||
|
): void => {
|
||||||
if (!state) return;
|
if (!state) return;
|
||||||
|
|
||||||
for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(state))) {
|
for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(state))) {
|
||||||
|
if (reservedKeys?.has(key)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (!('value' in descriptor)) {
|
if (!('value' in descriptor)) {
|
||||||
descriptor.configurable = true;
|
descriptor.configurable = true;
|
||||||
Object.defineProperty(formState, key, descriptor);
|
Object.defineProperty(formState, key, descriptor);
|
||||||
|
|||||||
@ -38,8 +38,15 @@ export interface TypeMatchValidateContext {
|
|||||||
// #endregion TypeMatchValidateContext
|
// #endregion TypeMatchValidateContext
|
||||||
|
|
||||||
// #region TypeMatchValidator
|
// #region TypeMatchValidator
|
||||||
/** 自定义 type 校验器:返回错误文案;通过则返回 undefined */
|
/**
|
||||||
export type TypeMatchValidator = (value: any, context: TypeMatchValidateContext) => string | undefined;
|
* 自定义 type 校验器:返回错误文案;通过则返回 undefined。
|
||||||
|
*
|
||||||
|
* 支持返回 Promise,用于需要异步确认取值是否合法的场景(如请求接口校验 id 是否存在)。
|
||||||
|
*/
|
||||||
|
export type TypeMatchValidator = (
|
||||||
|
value: any,
|
||||||
|
context: TypeMatchValidateContext,
|
||||||
|
) => string | undefined | Promise<string | undefined>;
|
||||||
// #endregion TypeMatchValidator
|
// #endregion TypeMatchValidator
|
||||||
|
|
||||||
const typeMatchRuleRegistry = new Map<string, TypeMatchValidator>();
|
const typeMatchRuleRegistry = new Map<string, TypeMatchValidator>();
|
||||||
@ -142,7 +149,7 @@ const stringifyExampleValue = (value: any): string => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// 参考建议中最多展示的可选值个数,超出以「等」省略。
|
// 参考建议中最多展示的可选值个数,超出以「等」省略。
|
||||||
const MAX_SUGGESTION_OPTIONS = 5;
|
const MAX_SUGGESTION_OPTIONS = 20;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生成「请使用以下某一个值:xxx;xxx」形式的参考建议;无可选值时返回空字符串(不追加建议)。
|
* 生成「请使用以下某一个值:xxx;xxx」形式的参考建议;无可选值时返回空字符串(不追加建议)。
|
||||||
@ -692,12 +699,17 @@ const validateBuiltinTypeMatch = (
|
|||||||
return undefined;
|
return undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 校验取值与字段 type 是否匹配;通过返回 undefined,否则返回错误文案。
|
||||||
|
*
|
||||||
|
* 命中的自定义规则是异步校验器时返回 Promise,内置规则始终同步返回。
|
||||||
|
*/
|
||||||
export const validateTypeMatch = (
|
export const validateTypeMatch = (
|
||||||
value: any,
|
value: any,
|
||||||
mForm: FormState | undefined,
|
mForm: FormState | undefined,
|
||||||
props: any,
|
props: any,
|
||||||
message?: string,
|
message?: string,
|
||||||
): string | undefined => {
|
): string | undefined | Promise<string | undefined> => {
|
||||||
if (isEmptyValue(value) || isEmptyArray(value)) {
|
if (isEmptyValue(value) || isEmptyArray(value)) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
@ -724,43 +736,135 @@ export const validateTypeMatch = (
|
|||||||
return validateBuiltinTypeMatch(value, fieldType, mForm, props, message);
|
return validateBuiltinTypeMatch(value, fieldType, mForm, props, message);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const toError = (error: any): Error => (error instanceof Error ? error : new Error(`${error}`));
|
||||||
|
|
||||||
export const createTypeMatchValidator = (mForm: FormState | undefined, props: any, rule: Rule) => {
|
export const createTypeMatchValidator = (mForm: FormState | undefined, props: any, rule: Rule) => {
|
||||||
const originalValidator = typeof rule.validator === 'function' ? rule.validator : undefined;
|
const originalValidator = typeof rule.validator === 'function' ? rule.validator : undefined;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 每次校验取一个自增序号,只有最新一轮的结论会被采用。
|
||||||
|
*
|
||||||
|
* 旧值的在途校验不能用自己的结论结算:它可能晚于新校验结束,用过期结论覆盖新结论
|
||||||
|
* (表单取最后结束的那次结果);也不能在新校验开始时无条件按通过结算,否则
|
||||||
|
* `form.validate()` 会对一个还没校验过的值返回成功。因此所有尚未结算的调用都登记在
|
||||||
|
* pendingSettlers 中,等最新一轮出结论后用同一个结论一起结算。
|
||||||
|
*
|
||||||
|
* 不比较取值本身:配了 names 或取值为对象/数组时拿到的是同一个引用,就地修改后比较不出变化。
|
||||||
|
*/
|
||||||
|
let generation = 0;
|
||||||
|
let pendingSettlers: ((args: any[]) => void)[] = [];
|
||||||
|
|
||||||
return (asyncValidatorRule: any, value: any, callback: Function, source: any, options: any) => {
|
return (asyncValidatorRule: any, value: any, callback: Function, source: any, options: any) => {
|
||||||
const actualValue = props.config?.names ? props.model : value;
|
const actualValue = props.config?.names ? props.model : value;
|
||||||
try {
|
|
||||||
const error = validateTypeMatch(actualValue, mForm, props, rule.message);
|
|
||||||
|
|
||||||
if (error) {
|
generation += 1;
|
||||||
callback(new Error(error));
|
const currentGeneration = generation;
|
||||||
|
/** 已有更新的一轮校验开始,本轮结论作废 */
|
||||||
|
const isStale = () => currentGeneration !== generation;
|
||||||
|
|
||||||
|
pendingSettlers.push((args: any[]) => callback(...args));
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 结算本轮与被本轮取代的所有在途校验。
|
||||||
|
*
|
||||||
|
* async-validator 的 callback 不幂等:重复调用会让它的内部计数提前满足、错误信息重复;
|
||||||
|
* 原始 validator 写成 async 时很容易既调 callback 又返回 Promise,故所有回调都收敛到这里,
|
||||||
|
* 由「取出即出队」保证每个调用的 callback 只会被调用一次。
|
||||||
|
*/
|
||||||
|
const conclude = (...args: any[]) => {
|
||||||
|
if (isStale()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
const settlers = pendingSettlers;
|
||||||
|
pendingSettlers = [];
|
||||||
|
for (const settle of settlers) {
|
||||||
|
settle(args);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行原始 validator 并把结果统一转成 callback。
|
||||||
|
*
|
||||||
|
* async-validator 只解析同步返回给它的返回值(true / false / Error / 错误数组 / Promise,
|
||||||
|
* 抛错转成错误信息),异步路径已脱离它的调用栈,这些约定会失效导致校验永不结束,故复刻一份。
|
||||||
|
*/
|
||||||
|
const settleWithOriginalValidator = () => {
|
||||||
|
// 本轮结论已作废,不必再跑一遍原始 validator 触发副作用
|
||||||
|
if (isStale()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!originalValidator) {
|
||||||
|
conclude();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
let result: any;
|
||||||
|
try {
|
||||||
|
result = originalValidator(
|
||||||
|
{ rule: asyncValidatorRule, value: actualValue, callback: conclude, source, options },
|
||||||
|
{
|
||||||
|
values: mForm?.initValues || {},
|
||||||
|
model: props.model,
|
||||||
|
parent: mForm?.parentValues || {},
|
||||||
|
formValue: mForm?.values || props.model,
|
||||||
|
prop: props.prop,
|
||||||
|
config: props.config,
|
||||||
|
},
|
||||||
|
mForm,
|
||||||
|
);
|
||||||
|
} catch (err) {
|
||||||
|
conclude(toError(err));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isPromise(result)) {
|
||||||
|
result.then(
|
||||||
|
() => conclude(),
|
||||||
|
(err: any) => conclude(toError(err)),
|
||||||
|
);
|
||||||
|
} else if (result === true) {
|
||||||
|
conclude();
|
||||||
|
} else if (result === false) {
|
||||||
|
const field = asyncValidatorRule?.fullField || asyncValidatorRule?.field || props.prop;
|
||||||
|
conclude(new Error(rule.message || `${field} fails`));
|
||||||
|
} else if (result instanceof Error || Array.isArray(result)) {
|
||||||
|
conclude(result);
|
||||||
|
}
|
||||||
|
// 其余返回值(undefined / void)按约定由 validator 自行调用 callback
|
||||||
|
};
|
||||||
|
|
||||||
|
// 校验器自身失败(如接口异常)不应阻塞用户,记录后按通过处理
|
||||||
|
const skipFailedTypeMatch = (err: any) => {
|
||||||
|
console.error(err);
|
||||||
|
settleWithOriginalValidator();
|
||||||
|
};
|
||||||
|
|
||||||
|
let error: string | undefined | Promise<string | undefined>;
|
||||||
|
try {
|
||||||
|
error = validateTypeMatch(actualValue, mForm, props, rule.message);
|
||||||
|
} catch (err) {
|
||||||
|
skipFailedTypeMatch(err);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (originalValidator) {
|
if (isPromise(error)) {
|
||||||
return originalValidator(
|
error.then((asyncMessage) => {
|
||||||
{
|
if (asyncMessage) {
|
||||||
rule: asyncValidatorRule,
|
conclude(new Error(asyncMessage));
|
||||||
value: actualValue,
|
return;
|
||||||
callback,
|
}
|
||||||
source,
|
settleWithOriginalValidator();
|
||||||
options,
|
}, skipFailedTypeMatch);
|
||||||
},
|
return;
|
||||||
{
|
|
||||||
values: mForm?.initValues || {},
|
|
||||||
model: props.model,
|
|
||||||
parent: mForm?.parentValues || {},
|
|
||||||
formValue: mForm?.values || props.model,
|
|
||||||
prop: props.prop,
|
|
||||||
config: props.config,
|
|
||||||
},
|
|
||||||
mForm,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
callback();
|
if (error) {
|
||||||
|
conclude(new Error(error));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
settleWithOriginalValidator();
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@ -189,9 +189,7 @@ describe('Form.vue —— extendState', () => {
|
|||||||
expect(v2).toMatch(/^stage-/);
|
expect(v2).toMatch(/^stage-/);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('extendState 以普通字段返回 props 派生的只读字段时跳过并告警,不抛错', async () => {
|
test('extendState 以普通字段返回内置保留字段时静默跳过,其余字段正常合并', async () => {
|
||||||
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
||||||
|
|
||||||
const wrapper = mountForm({
|
const wrapper = mountForm({
|
||||||
keyProp: 'id',
|
keyProp: 'id',
|
||||||
extendState: () => ({ keyProp: 'custom', config: [], extra: 'ok' }),
|
extendState: () => ({ keyProp: 'custom', config: [], extra: 'ok' }),
|
||||||
@ -201,18 +199,15 @@ describe('Form.vue —— extendState', () => {
|
|||||||
await nextTick();
|
await nextTick();
|
||||||
await nextTick();
|
await nextTick();
|
||||||
|
|
||||||
// 只读派生字段保持 props 值,未被覆盖
|
// 内置保留字段(keyProp / config)未被 extendState 覆盖
|
||||||
expect((wrapper.vm.formState as any).keyProp).toBe('id');
|
expect((wrapper.vm.formState as any).keyProp).toBe('id');
|
||||||
expect(Array.isArray((wrapper.vm.formState as any).config)).toBe(true);
|
expect(Array.isArray((wrapper.vm.formState as any).config)).toBe(true);
|
||||||
// 其他字段正常合并
|
// 非保留字段正常合并
|
||||||
expect((wrapper.vm.formState as any).extra).toBe('ok');
|
expect((wrapper.vm.formState as any).extra).toBe('ok');
|
||||||
expect(warnSpy).toHaveBeenCalled();
|
|
||||||
expect(wrapper.find('.m-form').exists()).toBe(true);
|
expect(wrapper.find('.m-form').exists()).toBe(true);
|
||||||
|
|
||||||
warnSpy.mockRestore();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('extendState 以 get 访问器返回只读字段同名 key 时允许显式覆盖', async () => {
|
test('extendState 以 get 访问器返回内置保留字段同名 key 时仍被拦截,无法覆盖', async () => {
|
||||||
const wrapper = mountForm({
|
const wrapper = mountForm({
|
||||||
keyProp: 'id',
|
keyProp: 'id',
|
||||||
extendState: () =>
|
extendState: () =>
|
||||||
@ -228,7 +223,8 @@ describe('Form.vue —— extendState', () => {
|
|||||||
await nextTick();
|
await nextTick();
|
||||||
await nextTick();
|
await nextTick();
|
||||||
|
|
||||||
expect((wrapper.vm.formState as any).keyProp).toBe('custom-key');
|
// keyProp 属于内置保留字段,即使以访问器形式返回也不允许覆盖
|
||||||
|
expect((wrapper.vm.formState as any).keyProp).toBe('id');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('extendState 同步段读到的响应式数据变化时会重跑', async () => {
|
test('extendState 同步段读到的响应式数据变化时会重跑', async () => {
|
||||||
|
|||||||
@ -90,9 +90,7 @@ describe('submitForm', () => {
|
|||||||
expect(extendState).toHaveBeenCalled();
|
expect(extendState).toHaveBeenCalled();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('extendState 返回 keyProp 等只读派生字段时不抛错且正常 resolve', async () => {
|
test('extendState 返回 keyProp 等内置保留字段时静默跳过且正常 resolve', async () => {
|
||||||
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => {});
|
|
||||||
|
|
||||||
const values = await submitForm({
|
const values = await submitForm({
|
||||||
config: [{ type: 'text', name: 'text', text: 'text' }],
|
config: [{ type: 'text', name: 'text', text: 'text' }],
|
||||||
initValues: { text: 'foo' },
|
initValues: { text: 'foo' },
|
||||||
@ -100,10 +98,8 @@ describe('submitForm', () => {
|
|||||||
appContext,
|
appContext,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// keyProp 属于内置保留字段,被静默跳过,不污染最终 values
|
||||||
expect(values).toEqual({ text: 'foo' });
|
expect(values).toEqual({ text: 'foo' });
|
||||||
expect(warnSpy).toHaveBeenCalled();
|
|
||||||
|
|
||||||
warnSpy.mockRestore();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
test('在嵌套 items 配置下也能正确 resolve', async () => {
|
test('在嵌套 items 配置下也能正确 resolve', async () => {
|
||||||
|
|||||||
@ -16,9 +16,10 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { describe, expect, test } from 'vitest';
|
import { describe, expect, test, vi } from 'vitest';
|
||||||
import type { FormState } from '@form/index';
|
import type { FormState } from '@form/index';
|
||||||
import {
|
import {
|
||||||
|
applyExtendState,
|
||||||
createObjectProp,
|
createObjectProp,
|
||||||
createValues,
|
createValues,
|
||||||
datetimeFormatter,
|
datetimeFormatter,
|
||||||
@ -1014,3 +1015,130 @@ describe('createObjectProp', () => {
|
|||||||
expect(createObjectProp('a.b.c', 'newKey', 'c')).toBe('a.b.newKey');
|
expect(createObjectProp('a.b.c', 'newKey', 'c')).toBe('a.b.newKey');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('applyExtendState', () => {
|
||||||
|
test('state 为 null 或 undefined 时不修改 formState', () => {
|
||||||
|
const formState = { a: 1 } as any;
|
||||||
|
|
||||||
|
applyExtendState(formState, null);
|
||||||
|
applyExtendState(formState, undefined);
|
||||||
|
|
||||||
|
expect(formState).toEqual({ a: 1 });
|
||||||
|
});
|
||||||
|
|
||||||
|
test('普通字段(data descriptor)以新增字段形式合并进 formState', () => {
|
||||||
|
const formState = {} as any;
|
||||||
|
|
||||||
|
applyExtendState(formState, { foo: 'bar', num: 1 });
|
||||||
|
|
||||||
|
expect(formState.foo).toBe('bar');
|
||||||
|
expect(formState.num).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('accessor descriptor 按原样 define 且读时求值', () => {
|
||||||
|
const formState = {} as any;
|
||||||
|
let count = 0;
|
||||||
|
const state = {};
|
||||||
|
Object.defineProperty(state, 'stage', {
|
||||||
|
get() {
|
||||||
|
count += 1;
|
||||||
|
return 'stageValue';
|
||||||
|
},
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
applyExtendState(formState, state);
|
||||||
|
|
||||||
|
// 读时才求值
|
||||||
|
expect(count).toBe(0);
|
||||||
|
expect(formState.stage).toBe('stageValue');
|
||||||
|
expect(count).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('accessor descriptor 强制 configurable=true,可再次 define 不报错', () => {
|
||||||
|
const formState = {} as any;
|
||||||
|
const state = {};
|
||||||
|
// 原始描述符 configurable 为 false
|
||||||
|
Object.defineProperty(state, 'stage', {
|
||||||
|
get: () => 'v',
|
||||||
|
enumerable: true,
|
||||||
|
configurable: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
applyExtendState(formState, state);
|
||||||
|
|
||||||
|
const descriptor = Object.getOwnPropertyDescriptor(formState, 'stage');
|
||||||
|
expect(descriptor?.configurable).toBe(true);
|
||||||
|
// 再次合并(重新 define)不应抛出
|
||||||
|
expect(() => applyExtendState(formState, state)).not.toThrow();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('reservedKeys 命中的 key 被跳过,不覆盖已有内置字段', () => {
|
||||||
|
const formState = { values: { origin: true } } as any;
|
||||||
|
const reservedKeys = new Set<string | symbol>(['values']);
|
||||||
|
|
||||||
|
applyExtendState(formState, { values: { changed: true }, extra: 1 }, reservedKeys);
|
||||||
|
|
||||||
|
// reserved key 未被覆盖
|
||||||
|
expect(formState.values).toEqual({ origin: true });
|
||||||
|
// 非 reserved 的新字段正常新增
|
||||||
|
expect(formState.extra).toBe(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('reservedKeys 对 accessor 形式的同名 key 同样跳过', () => {
|
||||||
|
const formState = { keyProp: 'origin' } as any;
|
||||||
|
const reservedKeys = new Set<string | symbol>(['keyProp']);
|
||||||
|
const state = {};
|
||||||
|
Object.defineProperty(state, 'keyProp', {
|
||||||
|
get: () => 'override',
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
applyExtendState(formState, state, reservedKeys);
|
||||||
|
|
||||||
|
expect(formState.keyProp).toBe('origin');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('未传 reservedKeys 时,只读 getter 字段被跳过并告警', () => {
|
||||||
|
const warnSpy = vi.spyOn(console, 'warn').mockImplementation(() => undefined);
|
||||||
|
const formState = {} as any;
|
||||||
|
Object.defineProperty(formState, 'keyProp', {
|
||||||
|
get: () => 'readonly',
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
applyExtendState(formState, { keyProp: 'newValue' });
|
||||||
|
|
||||||
|
expect(formState.keyProp).toBe('readonly');
|
||||||
|
expect(warnSpy).toHaveBeenCalled();
|
||||||
|
warnSpy.mockRestore();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('未传 reservedKeys 时,存在 setter 的字段可被赋值', () => {
|
||||||
|
let inner = 'old';
|
||||||
|
const formState = {} as any;
|
||||||
|
Object.defineProperty(formState, 'writable', {
|
||||||
|
get: () => inner,
|
||||||
|
set: (v: string) => {
|
||||||
|
inner = v;
|
||||||
|
},
|
||||||
|
enumerable: true,
|
||||||
|
configurable: true,
|
||||||
|
});
|
||||||
|
|
||||||
|
applyExtendState(formState, { writable: 'new' });
|
||||||
|
|
||||||
|
expect(formState.writable).toBe('new');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('未传 reservedKeys 时,普通可写字段正常覆盖赋值', () => {
|
||||||
|
const formState = { editable: 'old' } as any;
|
||||||
|
|
||||||
|
applyExtendState(formState, { editable: 'new' });
|
||||||
|
|
||||||
|
expect(formState.editable).toBe('new');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|||||||
@ -196,13 +196,14 @@ describe('validateTypeMatch', () => {
|
|||||||
expect(validateTypeMatch(3, mForm, propsOf(config))).toBe('3 不在可选项中\n\n请使用以下某一个值:1;2');
|
expect(validateTypeMatch(3, mForm, propsOf(config))).toBe('3 不在可选项中\n\n请使用以下某一个值:1;2');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('可选项超过 5 个时建议仅展示前 5 个并以「等」省略', () => {
|
test('可选项超过 20 个时建议仅展示前 20 个并以「等」省略', () => {
|
||||||
|
const values = Array.from({ length: 21 }, (_, i) => i + 1);
|
||||||
const config = {
|
const config = {
|
||||||
type: 'select',
|
type: 'select',
|
||||||
options: [1, 2, 3, 4, 5, 6, 7].map((v) => ({ text: `${v}`, value: v })),
|
options: values.map((v) => ({ text: `${v}`, value: v })),
|
||||||
};
|
};
|
||||||
expect(validateTypeMatch(99, mForm, propsOf(config))).toBe(
|
expect(validateTypeMatch(99, mForm, propsOf(config))).toBe(
|
||||||
'99 不在可选项中\n\n请使用以下某一个值:1;2;3;4;5 等',
|
`99 不在可选项中\n\n请使用以下某一个值:${values.slice(0, 20).join(';')} 等`,
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -624,6 +625,88 @@ describe('getRules tdesign validator', () => {
|
|||||||
});
|
});
|
||||||
await expect(newRules[0].validator(1)).resolves.toBe(true);
|
await expect(newRules[0].validator(1)).resolves.toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('异步 typeMatch 校验器的结果能正确适配', async () => {
|
||||||
|
registerTypeMatchRule('async-type', async (value) => (value === 'ok' ? undefined : '异步校验失败'));
|
||||||
|
|
||||||
|
const rules: any = [{ typeMatch: true }];
|
||||||
|
const newRules: any = getRules(mForm, rules, propsOf({ type: 'async-type' }));
|
||||||
|
|
||||||
|
await expect(newRules[0].validator('ok')).resolves.toBe(true);
|
||||||
|
await expect(newRules[0].validator('bad')).resolves.toEqual({
|
||||||
|
result: false,
|
||||||
|
message: '异步校验失败',
|
||||||
|
});
|
||||||
|
|
||||||
|
deleteTypeMatchRule('async-type');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('自定义 validator 返回 Promise 时按 Promise 结果适配', async () => {
|
||||||
|
const rules: any = [
|
||||||
|
{ validator: () => Promise.resolve() },
|
||||||
|
{ validator: () => Promise.reject(new Error('异步失败')) },
|
||||||
|
{ validator: () => Promise.reject('非 Error') },
|
||||||
|
];
|
||||||
|
const newRules: any = getRules(mForm, rules, { config: {} });
|
||||||
|
|
||||||
|
await expect(newRules[0].validator('ok')).resolves.toBe(true);
|
||||||
|
await expect(newRules[1].validator('ok')).resolves.toEqual({
|
||||||
|
result: false,
|
||||||
|
message: '异步失败',
|
||||||
|
});
|
||||||
|
await expect(newRules[2].validator('ok')).resolves.toEqual({
|
||||||
|
result: false,
|
||||||
|
message: '非 Error',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('自定义 validator 同步抛错时转成 CustomValidateObj', async () => {
|
||||||
|
const rules: any = [
|
||||||
|
{
|
||||||
|
validator: () => {
|
||||||
|
throw new Error('validator 内部抛错');
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
validator: () => {
|
||||||
|
throw 'string error';
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const newRules: any = getRules(mForm, rules, { config: {} });
|
||||||
|
|
||||||
|
await expect(newRules[0].validator('ok')).resolves.toEqual({
|
||||||
|
result: false,
|
||||||
|
message: 'validator 内部抛错',
|
||||||
|
});
|
||||||
|
await expect(newRules[1].validator('ok')).resolves.toEqual({
|
||||||
|
result: false,
|
||||||
|
message: 'string error',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test('callback 收到错误数组时取首条展示', async () => {
|
||||||
|
const rules: any = [
|
||||||
|
{
|
||||||
|
validator: ({ callback }: any) => {
|
||||||
|
callback([new Error('错误一'), new Error('错误二')]);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
validator: ({ callback }: any) => {
|
||||||
|
callback([]);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
];
|
||||||
|
const newRules: any = getRules(mForm, rules, { config: {} });
|
||||||
|
|
||||||
|
await expect(newRules[0].validator('ok')).resolves.toEqual({
|
||||||
|
result: false,
|
||||||
|
message: '错误一',
|
||||||
|
});
|
||||||
|
// 空数组视为无错误
|
||||||
|
await expect(newRules[1].validator('ok')).resolves.toBe(true);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('typeMatch 扩展注册', () => {
|
describe('typeMatch 扩展注册', () => {
|
||||||
@ -747,4 +830,402 @@ describe('createTypeMatchValidator', () => {
|
|||||||
expect(errorSpy).toHaveBeenCalled();
|
expect(errorSpy).toHaveBeenCalled();
|
||||||
errorSpy.mockRestore();
|
errorSpy.mockRestore();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('异步校验器返回错误文案时回调 Error', async () => {
|
||||||
|
registerTypeMatchRule('async-type', async (value) => (value === 'ok' ? undefined : '异步校验失败'));
|
||||||
|
|
||||||
|
const callback = vi.fn();
|
||||||
|
const validator = createTypeMatchValidator(mForm, propsOf({ type: 'async-type' }), { typeMatch: true } as any);
|
||||||
|
|
||||||
|
// 异步校验器不能把 Promise 交还给 async-validator,否则会重复回调
|
||||||
|
expect(validator({}, 'bad', callback, {}, {})).toBeUndefined();
|
||||||
|
expect(callback).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
await vi.waitFor(() => expect(callback).toHaveBeenCalledTimes(1));
|
||||||
|
expect(callback.mock.calls[0][0]).toBeInstanceOf(Error);
|
||||||
|
expect(callback.mock.calls[0][0].message).toBe('异步校验失败');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('异步校验器通过时无参回调', async () => {
|
||||||
|
registerTypeMatchRule('async-type', async (value) => (value === 'ok' ? undefined : '异步校验失败'));
|
||||||
|
|
||||||
|
const callback = vi.fn();
|
||||||
|
const validator = createTypeMatchValidator(mForm, propsOf({ type: 'async-type' }), { typeMatch: true } as any);
|
||||||
|
|
||||||
|
validator({}, 'ok', callback, {}, {});
|
||||||
|
|
||||||
|
await vi.waitFor(() => expect(callback).toHaveBeenCalledTimes(1));
|
||||||
|
expect(callback).toHaveBeenCalledWith();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('异步校验器通过后继续执行原始 validator', async () => {
|
||||||
|
registerTypeMatchRule('async-type', async () => undefined);
|
||||||
|
|
||||||
|
const callback = vi.fn();
|
||||||
|
const originalValidator = vi.fn();
|
||||||
|
const validator = createTypeMatchValidator(mForm, propsOf({ type: 'async-type' }), {
|
||||||
|
typeMatch: true,
|
||||||
|
validator: originalValidator,
|
||||||
|
} as any);
|
||||||
|
|
||||||
|
validator({}, 'ok', callback, {}, {});
|
||||||
|
|
||||||
|
await vi.waitFor(() => expect(originalValidator).toHaveBeenCalled());
|
||||||
|
// 原始 validator 拿到 callback 后自行回调,这里不重复调用
|
||||||
|
expect(callback).not.toHaveBeenCalled();
|
||||||
|
expect(originalValidator.mock.calls[0][0].value).toBe('ok');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('异步校验器不通过时不执行原始 validator', async () => {
|
||||||
|
registerTypeMatchRule('async-type', async () => '异步校验失败');
|
||||||
|
|
||||||
|
const callback = vi.fn();
|
||||||
|
const originalValidator = vi.fn();
|
||||||
|
const validator = createTypeMatchValidator(mForm, propsOf({ type: 'async-type' }), {
|
||||||
|
typeMatch: true,
|
||||||
|
validator: originalValidator,
|
||||||
|
} as any);
|
||||||
|
|
||||||
|
validator({}, 'bad', callback, {}, {});
|
||||||
|
|
||||||
|
await vi.waitFor(() => expect(callback).toHaveBeenCalledTimes(1));
|
||||||
|
expect(originalValidator).not.toHaveBeenCalled();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('异步校验器 reject 时忽略异常并继续执行原始 validator', async () => {
|
||||||
|
registerTypeMatchRule('async-type', () => Promise.reject(new Error('boom')));
|
||||||
|
|
||||||
|
const errorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
|
||||||
|
const callback = vi.fn();
|
||||||
|
const originalValidator = vi.fn();
|
||||||
|
const validator = createTypeMatchValidator(mForm, propsOf({ type: 'async-type' }), {
|
||||||
|
typeMatch: true,
|
||||||
|
validator: originalValidator,
|
||||||
|
} as any);
|
||||||
|
|
||||||
|
validator({}, 'value', callback, {}, {});
|
||||||
|
|
||||||
|
await vi.waitFor(() => expect(originalValidator).toHaveBeenCalled());
|
||||||
|
expect(errorSpy).toHaveBeenCalled();
|
||||||
|
errorSpy.mockRestore();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('异步路径下原始 validator 返回的 Promise 会被转成 callback', async () => {
|
||||||
|
registerTypeMatchRule('async-type', async () => undefined);
|
||||||
|
|
||||||
|
const callback = vi.fn();
|
||||||
|
const validator = createTypeMatchValidator(mForm, propsOf({ type: 'async-type' }), {
|
||||||
|
typeMatch: true,
|
||||||
|
validator: () => Promise.reject(new Error('原始校验失败')),
|
||||||
|
} as any);
|
||||||
|
|
||||||
|
validator({}, 'ok', callback, {}, {});
|
||||||
|
|
||||||
|
await vi.waitFor(() => expect(callback).toHaveBeenCalledTimes(1));
|
||||||
|
expect(callback.mock.calls[0][0].message).toBe('原始校验失败');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('原始 validator 既调 callback 又返回 Promise 时只回调一次', async () => {
|
||||||
|
registerTypeMatchRule('async-type', async () => undefined);
|
||||||
|
|
||||||
|
const callback = vi.fn();
|
||||||
|
const validator = createTypeMatchValidator(mForm, propsOf({ type: 'async-type' }), {
|
||||||
|
typeMatch: true,
|
||||||
|
// async 写法很常见:内部调了 callback,函数本身又返回 Promise
|
||||||
|
validator: async ({ callback: cb }: any) => {
|
||||||
|
cb(new Error('原始校验失败'));
|
||||||
|
},
|
||||||
|
} as any);
|
||||||
|
|
||||||
|
validator({}, 'ok', callback, {}, {});
|
||||||
|
|
||||||
|
await vi.waitFor(() => expect(callback).toHaveBeenCalledTimes(1));
|
||||||
|
expect(callback.mock.calls[0][0].message).toBe('原始校验失败');
|
||||||
|
|
||||||
|
// 等 Promise 链彻底跑完,确认没有第二次回调
|
||||||
|
await Promise.resolve();
|
||||||
|
await Promise.resolve();
|
||||||
|
expect(callback).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('异步校验器不影响同步内置规则', () => {
|
||||||
|
registerTypeMatchRule('async-type', async () => '异步校验失败');
|
||||||
|
|
||||||
|
const callback = vi.fn();
|
||||||
|
const validator = createTypeMatchValidator(mForm, propsOf({ type: 'number' }), { typeMatch: true } as any);
|
||||||
|
|
||||||
|
validator({}, 'not-a-number', callback, {}, {});
|
||||||
|
|
||||||
|
// 内置规则仍同步回调
|
||||||
|
expect(callback).toHaveBeenCalledTimes(1);
|
||||||
|
expect(callback.mock.calls[0][0].message).toContain('类型应为数字');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
/**
|
||||||
|
* async-validator 只解析同步返回给它的 validator 返回值,异步 typeMatch 通过后已脱离其调用栈,
|
||||||
|
* 因此这些约定必须由 createTypeMatchValidator 自行复刻,否则 callback 永不触发、校验一直挂起。
|
||||||
|
*/
|
||||||
|
describe('createTypeMatchValidator 原始 validator 返回值约定', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
clearTypeMatchRules();
|
||||||
|
registerTypeMatchRule('async-type', async () => undefined);
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
clearTypeMatchRules();
|
||||||
|
});
|
||||||
|
|
||||||
|
const validatorOf = (originalValidator: any, type = 'async-type') =>
|
||||||
|
createTypeMatchValidator(mForm, propsOf({ type }), {
|
||||||
|
typeMatch: true,
|
||||||
|
validator: originalValidator,
|
||||||
|
} as any);
|
||||||
|
|
||||||
|
/** async-type 走异步 typeMatch 路径,text 走同步内置规则路径,两者行为应完全一致 */
|
||||||
|
const paths = ['async-type', 'text'];
|
||||||
|
|
||||||
|
test.each(paths)('%s:返回 false 时回调错误', async (type) => {
|
||||||
|
const callback = vi.fn();
|
||||||
|
validatorOf(() => false, type)({ fullField: 'title' }, 'ok', callback, {}, {});
|
||||||
|
|
||||||
|
await vi.waitFor(() => expect(callback).toHaveBeenCalledTimes(1));
|
||||||
|
expect(callback.mock.calls[0][0].message).toBe('title fails');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('返回 false 时优先使用 rule.message', async () => {
|
||||||
|
const callback = vi.fn();
|
||||||
|
createTypeMatchValidator(mForm, propsOf({ type: 'async-type' }), {
|
||||||
|
typeMatch: true,
|
||||||
|
message: '自定义错误',
|
||||||
|
validator: () => false,
|
||||||
|
} as any)({}, 'ok', callback, {}, {});
|
||||||
|
|
||||||
|
await vi.waitFor(() => expect(callback).toHaveBeenCalledTimes(1));
|
||||||
|
expect(callback.mock.calls[0][0].message).toBe('自定义错误');
|
||||||
|
});
|
||||||
|
|
||||||
|
test.each(paths)('%s:返回 true 时无参回调', async (type) => {
|
||||||
|
const callback = vi.fn();
|
||||||
|
validatorOf(() => true, type)({}, 'ok', callback, {}, {});
|
||||||
|
|
||||||
|
await vi.waitFor(() => expect(callback).toHaveBeenCalledTimes(1));
|
||||||
|
expect(callback).toHaveBeenCalledWith();
|
||||||
|
});
|
||||||
|
|
||||||
|
test.each(paths)('%s:返回 Error 实例时透传', async (type) => {
|
||||||
|
const error = new Error('返回 Error');
|
||||||
|
const callback = vi.fn();
|
||||||
|
validatorOf(() => error, type)({}, 'ok', callback, {}, {});
|
||||||
|
|
||||||
|
await vi.waitFor(() => expect(callback).toHaveBeenCalledTimes(1));
|
||||||
|
expect(callback).toHaveBeenCalledWith(error);
|
||||||
|
});
|
||||||
|
|
||||||
|
test.each(paths)('%s:返回错误数组时透传', async (type) => {
|
||||||
|
const errors = [new Error('错误一'), new Error('错误二')];
|
||||||
|
const callback = vi.fn();
|
||||||
|
validatorOf(() => errors, type)({}, 'ok', callback, {}, {});
|
||||||
|
|
||||||
|
await vi.waitFor(() => expect(callback).toHaveBeenCalledTimes(1));
|
||||||
|
expect(callback).toHaveBeenCalledWith(errors);
|
||||||
|
});
|
||||||
|
|
||||||
|
test.each(paths)('%s:同步抛错时转成回调而非未捕获异常', async (type) => {
|
||||||
|
const unhandled: any[] = [];
|
||||||
|
const onUnhandled = (reason: any) => unhandled.push(reason);
|
||||||
|
process.on('unhandledRejection', onUnhandled);
|
||||||
|
|
||||||
|
const callback = vi.fn();
|
||||||
|
validatorOf(() => {
|
||||||
|
throw new Error('validator 内部抛错');
|
||||||
|
}, type)({}, 'ok', callback, {}, {});
|
||||||
|
|
||||||
|
await vi.waitFor(() => expect(callback).toHaveBeenCalledTimes(1));
|
||||||
|
expect(callback.mock.calls[0][0].message).toBe('validator 内部抛错');
|
||||||
|
|
||||||
|
// 等待微任务队列排空,确认异常没有变成游离的 rejected promise
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||||
|
process.off('unhandledRejection', onUnhandled);
|
||||||
|
expect(unhandled).toEqual([]);
|
||||||
|
});
|
||||||
|
|
||||||
|
test.each([
|
||||||
|
[
|
||||||
|
'抛出',
|
||||||
|
() => {
|
||||||
|
throw 'string error';
|
||||||
|
},
|
||||||
|
],
|
||||||
|
['reject', () => Promise.reject('string error')],
|
||||||
|
])('%s非 Error 时包装成 Error', async (_case, originalValidator) => {
|
||||||
|
const callback = vi.fn();
|
||||||
|
validatorOf(originalValidator)({}, 'ok', callback, {}, {});
|
||||||
|
|
||||||
|
await vi.waitFor(() => expect(callback).toHaveBeenCalledTimes(1));
|
||||||
|
expect(callback.mock.calls[0][0]).toBeInstanceOf(Error);
|
||||||
|
expect(callback.mock.calls[0][0].message).toBe('string error');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('同步 typeMatch 路径不把 Promise 交还 async-validator,避免重复回调', async () => {
|
||||||
|
const callback = vi.fn();
|
||||||
|
// async 写法很常见:内部调了 callback,函数本身又返回 Promise
|
||||||
|
const returned = validatorOf(async ({ callback: cb }: any) => {
|
||||||
|
cb(new Error('原始校验失败'));
|
||||||
|
}, 'text')({}, 'ok', callback, {}, {});
|
||||||
|
|
||||||
|
// 返回 undefined,async-validator 不会再解析 Promise 二次回调
|
||||||
|
expect(returned).toBeUndefined();
|
||||||
|
expect(callback).toHaveBeenCalledTimes(1);
|
||||||
|
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||||
|
expect(callback).toHaveBeenCalledTimes(1);
|
||||||
|
expect(callback.mock.calls[0][0].message).toBe('原始校验失败');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('createTypeMatchValidator 异步校验竞态', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
clearTypeMatchRules();
|
||||||
|
});
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
clearTypeMatchRules();
|
||||||
|
});
|
||||||
|
|
||||||
|
/** 注册一个由测试手动控制结束时机的异步规则,返回按调用顺序收集的 resolve 队列 */
|
||||||
|
const registerManualRule = () => {
|
||||||
|
const resolvers: ((message: string | undefined) => void)[] = [];
|
||||||
|
registerTypeMatchRule('async-type', () => new Promise<string | undefined>((resolve) => resolvers.push(resolve)));
|
||||||
|
return resolvers;
|
||||||
|
};
|
||||||
|
|
||||||
|
test('旧校验不会用过期结论结算,而是跟随最新一轮的结论', async () => {
|
||||||
|
const resolvers = registerManualRule();
|
||||||
|
const validator = createTypeMatchValidator(mForm, propsOf({ type: 'async-type' }), { typeMatch: true } as any);
|
||||||
|
|
||||||
|
const staleCallback = vi.fn();
|
||||||
|
const freshCallback = vi.fn();
|
||||||
|
validator({}, 'old', staleCallback, {}, {});
|
||||||
|
expect(staleCallback).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
// 值变化触发新一轮校验:旧校验的结论作废,但不能提前按通过结算
|
||||||
|
validator({}, 'new', freshCallback, {}, {});
|
||||||
|
expect(staleCallback).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
// 旧校验先返回,它的结论被丢弃
|
||||||
|
resolvers[0]('旧值校验失败');
|
||||||
|
await Promise.resolve();
|
||||||
|
expect(staleCallback).not.toHaveBeenCalled();
|
||||||
|
|
||||||
|
// 最新一轮出结论后,两次调用都以新结论结算
|
||||||
|
resolvers[1]('新值校验失败');
|
||||||
|
|
||||||
|
await vi.waitFor(() => expect(staleCallback).toHaveBeenCalledTimes(1));
|
||||||
|
expect(freshCallback).toHaveBeenCalledTimes(1);
|
||||||
|
expect(staleCallback.mock.calls[0][0].message).toBe('新值校验失败');
|
||||||
|
expect(freshCallback.mock.calls[0][0].message).toBe('新值校验失败');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('旧校验被同步路径的校验取代时,跟随同步结论结算', async () => {
|
||||||
|
const resolvers = registerManualRule();
|
||||||
|
const validator = createTypeMatchValidator(mForm, propsOf({ type: 'async-type' }), { typeMatch: true } as any);
|
||||||
|
|
||||||
|
const staleCallback = vi.fn();
|
||||||
|
const freshCallback = vi.fn();
|
||||||
|
validator({}, 'bad', staleCallback, {}, {});
|
||||||
|
|
||||||
|
// 值被清空:空值走同步路径直接通过,在途的旧校验必须跟着通过
|
||||||
|
validator({}, '', freshCallback, {}, {});
|
||||||
|
expect(freshCallback).toHaveBeenCalledWith();
|
||||||
|
expect(staleCallback).toHaveBeenCalledWith();
|
||||||
|
|
||||||
|
// 旧校验的失败结论晚到,不能落到已经通过的新值上
|
||||||
|
resolvers[0]('异步校验失败');
|
||||||
|
await new Promise((resolve) => setTimeout(resolve, 0));
|
||||||
|
expect(staleCallback).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('取值为同一引用(names / 对象值)时也能识别出旧校验', async () => {
|
||||||
|
const resolvers = registerManualRule();
|
||||||
|
const model: Record<string, any> = { start: 'old' };
|
||||||
|
const props = { ...propsOf({ type: 'async-type', names: ['start'] }), model };
|
||||||
|
const validator = createTypeMatchValidator(mForm, props, { typeMatch: true } as any);
|
||||||
|
|
||||||
|
const staleCallback = vi.fn();
|
||||||
|
const freshCallback = vi.fn();
|
||||||
|
validator({}, 'x', staleCallback, {}, {});
|
||||||
|
|
||||||
|
// names 场景下校验的是 model 本身,就地修改后引用不变
|
||||||
|
model.start = 'new';
|
||||||
|
validator({}, 'y', freshCallback, {}, {});
|
||||||
|
|
||||||
|
// 新校验先通过,旧校验的失败结论后到,不能覆盖
|
||||||
|
resolvers[1](undefined);
|
||||||
|
resolvers[0]('旧值校验失败');
|
||||||
|
|
||||||
|
await vi.waitFor(() => expect(freshCallback).toHaveBeenCalledTimes(1));
|
||||||
|
expect(freshCallback).toHaveBeenCalledWith();
|
||||||
|
expect(staleCallback).toHaveBeenCalledTimes(1);
|
||||||
|
expect(staleCallback).toHaveBeenCalledWith();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('同值的多次在途校验都会被最新一轮结算', async () => {
|
||||||
|
const resolvers = registerManualRule();
|
||||||
|
const validator = createTypeMatchValidator(mForm, propsOf({ type: 'async-type' }), { typeMatch: true } as any);
|
||||||
|
|
||||||
|
const first = vi.fn();
|
||||||
|
const second = vi.fn();
|
||||||
|
const third = vi.fn();
|
||||||
|
// 同一个值可能被 blur、change 触发两次校验,之后值才变化
|
||||||
|
validator({}, 'old', first, {}, {});
|
||||||
|
validator({}, 'old', second, {}, {});
|
||||||
|
validator({}, 'new', third, {}, {});
|
||||||
|
|
||||||
|
resolvers[0]('旧值校验失败');
|
||||||
|
resolvers[1]('旧值校验失败');
|
||||||
|
resolvers[2]('新值校验失败');
|
||||||
|
|
||||||
|
await vi.waitFor(() => expect(third).toHaveBeenCalledTimes(1));
|
||||||
|
expect(first.mock.calls[0][0].message).toBe('新值校验失败');
|
||||||
|
expect(second.mock.calls[0][0].message).toBe('新值校验失败');
|
||||||
|
expect(third.mock.calls[0][0].message).toBe('新值校验失败');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('并发的多次校验都会拿到结论,不会有调用被漏掉', async () => {
|
||||||
|
registerTypeMatchRule('async-type', async () => '异步校验失败');
|
||||||
|
|
||||||
|
const validator = createTypeMatchValidator(mForm, propsOf({ type: 'async-type' }), { typeMatch: true } as any);
|
||||||
|
|
||||||
|
const first = vi.fn();
|
||||||
|
const second = vi.fn();
|
||||||
|
validator({}, 'same', first, {}, {});
|
||||||
|
validator({}, 'same', second, {}, {});
|
||||||
|
|
||||||
|
await vi.waitFor(() => {
|
||||||
|
expect(first).toHaveBeenCalledTimes(1);
|
||||||
|
expect(second).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
|
expect(first.mock.calls[0][0].message).toBe('异步校验失败');
|
||||||
|
expect(second.mock.calls[0][0].message).toBe('异步校验失败');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('结论已作废的旧校验返回后不再执行原始 validator', async () => {
|
||||||
|
const resolvers = registerManualRule();
|
||||||
|
const originalValidator = vi.fn(({ callback }: any) => callback());
|
||||||
|
const validator = createTypeMatchValidator(mForm, propsOf({ type: 'async-type' }), {
|
||||||
|
typeMatch: true,
|
||||||
|
validator: originalValidator,
|
||||||
|
} as any);
|
||||||
|
|
||||||
|
validator({}, 'old', vi.fn(), {}, {});
|
||||||
|
validator({}, 'new', vi.fn(), {}, {});
|
||||||
|
|
||||||
|
// 旧校验的结论已作废,它的 typeMatch 通过后不应再触发一次原始 validator(可能带副作用)
|
||||||
|
resolvers[0](undefined);
|
||||||
|
resolvers[1](undefined);
|
||||||
|
|
||||||
|
await vi.waitFor(() => expect(originalValidator).toHaveBeenCalled());
|
||||||
|
expect(originalValidator).toHaveBeenCalledTimes(1);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "1.8.0-beta.15",
|
"version": "1.8.0-beta.19",
|
||||||
"name": "@tmagic/schema",
|
"name": "@tmagic/schema",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "1.8.0-beta.15",
|
"version": "1.8.0-beta.19",
|
||||||
"name": "@tmagic/stage",
|
"name": "@tmagic/stage",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
|
|||||||
@ -84,6 +84,8 @@ export default class ActionManager extends EventEmitter {
|
|||||||
private containerHighlightDuration: number;
|
private containerHighlightDuration: number;
|
||||||
/** 将组件加入容器的操作方式 */
|
/** 将组件加入容器的操作方式 */
|
||||||
private containerHighlightType?: ContainerHighlightType;
|
private containerHighlightType?: ContainerHighlightType;
|
||||||
|
/** 是否仅在新增组件时才启用将组件加入容器 */
|
||||||
|
private containerHighlightAddOnly = false;
|
||||||
private isAltKeydown = false;
|
private isAltKeydown = false;
|
||||||
private getTargetElement: GetTargetElement;
|
private getTargetElement: GetTargetElement;
|
||||||
private getElementsFromPoint: GetElementsFromPoint;
|
private getElementsFromPoint: GetElementsFromPoint;
|
||||||
@ -124,6 +126,7 @@ export default class ActionManager extends EventEmitter {
|
|||||||
this.containerHighlightClassName = config.containerHighlightClassName || CONTAINER_HIGHLIGHT_CLASS_NAME;
|
this.containerHighlightClassName = config.containerHighlightClassName || CONTAINER_HIGHLIGHT_CLASS_NAME;
|
||||||
this.containerHighlightDuration = config.containerHighlightDuration || defaultContainerHighlightDuration;
|
this.containerHighlightDuration = config.containerHighlightDuration || defaultContainerHighlightDuration;
|
||||||
this.containerHighlightType = config.containerHighlightType;
|
this.containerHighlightType = config.containerHighlightType;
|
||||||
|
this.containerHighlightAddOnly = config.containerHighlightAddOnly ?? false;
|
||||||
this.disabledMultiSelect = config.disabledMultiSelect ?? false;
|
this.disabledMultiSelect = config.disabledMultiSelect ?? false;
|
||||||
this.alwaysMultiSelect = config.alwaysMultiSelect ?? false;
|
this.alwaysMultiSelect = config.alwaysMultiSelect ?? false;
|
||||||
this.getTargetElement = config.getTargetElement;
|
this.getTargetElement = config.getTargetElement;
|
||||||
@ -428,10 +431,15 @@ export default class ActionManager extends EventEmitter {
|
|||||||
* 标记的作用:1、高亮容器,给用户一个加入容器的交互感知;2、释放鼠标后,通过标记的标志找到要加入的容器
|
* 标记的作用:1、高亮容器,给用户一个加入容器的交互感知;2、释放鼠标后,通过标记的标志找到要加入的容器
|
||||||
* @param event 鼠标事件
|
* @param event 鼠标事件
|
||||||
* @param excludeElList 计算鼠标所在容器时要排除的元素列表
|
* @param excludeElList 计算鼠标所在容器时要排除的元素列表
|
||||||
|
* @param isAdd 当前操作是否为新增组件(从组件列表拖入),开启 containerHighlightAddOnly 时只有新增才会标记
|
||||||
* @returns timeoutId,调用方在鼠标移走时要取消该timeout,阻止标记
|
* @returns timeoutId,调用方在鼠标移走时要取消该timeout,阻止标记
|
||||||
*/
|
*/
|
||||||
public delayedMarkContainer(event: MouseEvent, excludeElList: Element[] = []): NodeJS.Timeout | undefined {
|
public delayedMarkContainer(
|
||||||
if (this.canAddToContainer()) {
|
event: MouseEvent,
|
||||||
|
excludeElList: Element[] = [],
|
||||||
|
isAdd = false,
|
||||||
|
): NodeJS.Timeout | undefined {
|
||||||
|
if (this.canAddToContainer(isAdd)) {
|
||||||
return globalThis.setTimeout(() => {
|
return globalThis.setTimeout(() => {
|
||||||
this.addContainerHighlightClassName(event, excludeElList);
|
this.addContainerHighlightClassName(event, excludeElList);
|
||||||
}, this.containerHighlightDuration);
|
}, this.containerHighlightDuration);
|
||||||
@ -609,9 +617,13 @@ export default class ActionManager extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 当前状态下能否将组件加入容器,默认是鼠标悬停一段时间加入,alt模式则是按住alt+鼠标悬停一段时间加入
|
* 当前状态下能否将组件加入容器,默认是鼠标悬停一段时间加入,alt模式则是按住alt+鼠标悬停一段时间加入;
|
||||||
|
* 开启containerHighlightAddOnly时,画布中拖动已有组件不能加入容器
|
||||||
|
* @param isAdd 当前操作是否为新增组件
|
||||||
*/
|
*/
|
||||||
private canAddToContainer(): boolean {
|
private canAddToContainer(isAdd = false): boolean {
|
||||||
|
if (this.containerHighlightAddOnly && !isAdd) return false;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
this.containerHighlightType === ContainerHighlightType.DEFAULT ||
|
this.containerHighlightType === ContainerHighlightType.DEFAULT ||
|
||||||
(this.containerHighlightType === ContainerHighlightType.ALT && this.isAltKeydown)
|
(this.containerHighlightType === ContainerHighlightType.ALT && this.isAltKeydown)
|
||||||
@ -624,10 +636,10 @@ export default class ActionManager extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
private markContainerEnd(): HTMLElement | null {
|
private markContainerEnd(): HTMLElement | null {
|
||||||
const doc = this.getRenderDocument();
|
const doc = this.getRenderDocument();
|
||||||
if (doc && this.canAddToContainer()) {
|
if (!doc) return null;
|
||||||
return removeClassNameByClassName(doc, this.containerHighlightClassName);
|
|
||||||
}
|
const markedContainer = removeClassNameByClassName(doc, this.containerHighlightClassName);
|
||||||
return null;
|
return this.canAddToContainer() ? markedContainer : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private initMouseEvent(): void {
|
private initMouseEvent(): void {
|
||||||
|
|||||||
@ -263,10 +263,15 @@ export default class StageCore extends EventEmitter {
|
|||||||
* 标记的作用:1、高亮容器,给用户一个加入容器的交互感知;2、释放鼠标后,通过标记的标志找到要加入的容器
|
* 标记的作用:1、高亮容器,给用户一个加入容器的交互感知;2、释放鼠标后,通过标记的标志找到要加入的容器
|
||||||
* @param event 鼠标事件
|
* @param event 鼠标事件
|
||||||
* @param excludeElList 计算鼠标所在容器时要排除的元素列表
|
* @param excludeElList 计算鼠标所在容器时要排除的元素列表
|
||||||
|
* @param isAdd 当前操作是否为新增组件(从组件列表拖入),开启 containerHighlightAddOnly 时只有新增才会标记
|
||||||
* @returns timeoutId,调用方在鼠标移走时要取消该timeout,阻止标记
|
* @returns timeoutId,调用方在鼠标移走时要取消该timeout,阻止标记
|
||||||
*/
|
*/
|
||||||
public delayedMarkContainer(event: MouseEvent, excludeElList: Element[] = []): NodeJS.Timeout | undefined {
|
public delayedMarkContainer(
|
||||||
return this.actionManager?.delayedMarkContainer(event, excludeElList);
|
event: MouseEvent,
|
||||||
|
excludeElList: Element[] = [],
|
||||||
|
isAdd = false,
|
||||||
|
): NodeJS.Timeout | undefined {
|
||||||
|
return this.actionManager?.delayedMarkContainer(event, excludeElList, isAdd);
|
||||||
}
|
}
|
||||||
|
|
||||||
public getMoveableOption<K extends keyof MoveableOptions>(key: K): MoveableOptions[K] | undefined {
|
public getMoveableOption<K extends keyof MoveableOptions>(key: K): MoveableOptions[K] | undefined {
|
||||||
@ -368,6 +373,7 @@ export default class StageCore extends EventEmitter {
|
|||||||
containerHighlightClassName: config.containerHighlightClassName,
|
containerHighlightClassName: config.containerHighlightClassName,
|
||||||
containerHighlightDuration: config.containerHighlightDuration,
|
containerHighlightDuration: config.containerHighlightDuration,
|
||||||
containerHighlightType: config.containerHighlightType,
|
containerHighlightType: config.containerHighlightType,
|
||||||
|
containerHighlightAddOnly: config.containerHighlightAddOnly,
|
||||||
moveableOptions: config.moveableOptions,
|
moveableOptions: config.moveableOptions,
|
||||||
container: this.mask!.content,
|
container: this.mask!.content,
|
||||||
disabledDragStart: config.disabledDragStart,
|
disabledDragStart: config.disabledDragStart,
|
||||||
|
|||||||
@ -53,7 +53,11 @@ export type GetTargetElement = (id: Id) => HTMLElement | null;
|
|||||||
/** render提供的接口,通过坐标获得坐标下所有HTML元素数组 */
|
/** render提供的接口,通过坐标获得坐标下所有HTML元素数组 */
|
||||||
export type GetElementsFromPoint = (point: Point) => HTMLElement[];
|
export type GetElementsFromPoint = (point: Point) => HTMLElement[];
|
||||||
export type GetRenderDocument = () => Document | undefined;
|
export type GetRenderDocument = () => Document | undefined;
|
||||||
export type DelayedMarkContainer = (event: MouseEvent, exclude: Element[]) => NodeJS.Timeout | undefined;
|
export type DelayedMarkContainer = (
|
||||||
|
event: MouseEvent,
|
||||||
|
exclude?: Element[],
|
||||||
|
isAdd?: boolean,
|
||||||
|
) => NodeJS.Timeout | undefined;
|
||||||
export type MarkContainerEnd = () => HTMLElement | null;
|
export type MarkContainerEnd = () => HTMLElement | null;
|
||||||
export type GetRootContainer = () => HTMLDivElement | undefined;
|
export type GetRootContainer = () => HTMLDivElement | undefined;
|
||||||
|
|
||||||
@ -74,6 +78,11 @@ export interface StageCoreConfig {
|
|||||||
containerHighlightClassName?: string;
|
containerHighlightClassName?: string;
|
||||||
containerHighlightDuration?: number;
|
containerHighlightDuration?: number;
|
||||||
containerHighlightType?: ContainerHighlightType;
|
containerHighlightType?: ContainerHighlightType;
|
||||||
|
/**
|
||||||
|
* 是否仅在新增组件(从组件列表拖入新组件)时才启用将组件拖入容器,
|
||||||
|
* 开启后在画布中拖动已有组件不会识别容器,默认 false
|
||||||
|
*/
|
||||||
|
containerHighlightAddOnly?: boolean;
|
||||||
moveableOptions?: CustomizeMoveableOptions;
|
moveableOptions?: CustomizeMoveableOptions;
|
||||||
/** runtime 的HTML地址,可以是一个HTTP地址,如果和编辑器不同域,需要设置跨域,也可以是一个相对或绝对路径 */
|
/** runtime 的HTML地址,可以是一个HTTP地址,如果和编辑器不同域,需要设置跨域,也可以是一个相对或绝对路径 */
|
||||||
runtimeUrl?: string;
|
runtimeUrl?: string;
|
||||||
@ -102,6 +111,8 @@ export interface ActionManagerConfig {
|
|||||||
containerHighlightClassName?: string;
|
containerHighlightClassName?: string;
|
||||||
containerHighlightDuration?: number;
|
containerHighlightDuration?: number;
|
||||||
containerHighlightType?: ContainerHighlightType;
|
containerHighlightType?: ContainerHighlightType;
|
||||||
|
/** 见 StageCoreConfig.containerHighlightAddOnly */
|
||||||
|
containerHighlightAddOnly?: boolean;
|
||||||
moveableOptions?: CustomizeMoveableOptions;
|
moveableOptions?: CustomizeMoveableOptions;
|
||||||
disabledDragStart?: boolean;
|
disabledDragStart?: boolean;
|
||||||
disabledMultiSelect?: boolean;
|
disabledMultiSelect?: boolean;
|
||||||
|
|||||||
@ -275,6 +275,84 @@ describe('ActionManager - 交互与事件', () => {
|
|||||||
expect(containerEl.classList.contains('tmagic-stage-container-highlight')).toBe(true);
|
expect(containerEl.classList.contains('tmagic-stage-container-highlight')).toBe(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('delayedMarkContainer 未配置 containerHighlightType 时不标记容器', () => {
|
||||||
|
am = new ActionManager(createConfig({ isContainer: async () => true }));
|
||||||
|
expect(am.delayedMarkContainer(mouseAtOrigin())).toBeUndefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('delayedMarkContainer alt 模式下需按住 alt 才标记容器', () => {
|
||||||
|
am = new ActionManager(
|
||||||
|
createConfig({
|
||||||
|
containerHighlightType: ContainerHighlightType.ALT,
|
||||||
|
isContainer: async () => true,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
expect(am.delayedMarkContainer(mouseAtOrigin())).toBeUndefined();
|
||||||
|
(am as any).isAltKeydown = true;
|
||||||
|
expect(am.delayedMarkContainer(mouseAtOrigin())).toBeDefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('containerHighlightAddOnly 开启时拖动已有组件不标记容器', () => {
|
||||||
|
const containerEl = globalThis.document.createElement('div');
|
||||||
|
containerEl.dataset.tmagicId = 'container_1';
|
||||||
|
am = new ActionManager(
|
||||||
|
createConfig({
|
||||||
|
containerHighlightType: ContainerHighlightType.DEFAULT,
|
||||||
|
containerHighlightAddOnly: true,
|
||||||
|
getElementsFromPoint: () => [containerEl],
|
||||||
|
isContainer: async () => true,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
expect(am.delayedMarkContainer(mouseAtOrigin(), [globalThis.document.createElement('div')])).toBeUndefined();
|
||||||
|
vi.advanceTimersByTime(900);
|
||||||
|
expect(containerEl.classList.contains('tmagic-stage-container-highlight')).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('containerHighlightAddOnly 开启时新增组件仍按 containerHighlightType 标记容器', async () => {
|
||||||
|
const containerEl = globalThis.document.createElement('div');
|
||||||
|
containerEl.dataset.tmagicId = 'container_1';
|
||||||
|
am = new ActionManager(
|
||||||
|
createConfig({
|
||||||
|
containerHighlightType: ContainerHighlightType.DEFAULT,
|
||||||
|
containerHighlightAddOnly: true,
|
||||||
|
getElementsFromPoint: () => [containerEl],
|
||||||
|
isContainer: async () => true,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
expect(am.delayedMarkContainer(mouseAtOrigin(), [], true)).toBeDefined();
|
||||||
|
vi.advanceTimersByTime(900);
|
||||||
|
await Promise.resolve();
|
||||||
|
expect(containerEl.classList.contains('tmagic-stage-container-highlight')).toBe(true);
|
||||||
|
});
|
||||||
|
|
||||||
|
test('containerHighlightAddOnly 开启且 containerHighlightType 为 alt 时新增组件也需按住 alt', () => {
|
||||||
|
am = new ActionManager(
|
||||||
|
createConfig({
|
||||||
|
containerHighlightType: ContainerHighlightType.ALT,
|
||||||
|
containerHighlightAddOnly: true,
|
||||||
|
isContainer: async () => true,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
expect(am.delayedMarkContainer(mouseAtOrigin(), [], true)).toBeUndefined();
|
||||||
|
(am as any).isAltKeydown = true;
|
||||||
|
expect(am.delayedMarkContainer(mouseAtOrigin(), [], true)).toBeDefined();
|
||||||
|
});
|
||||||
|
|
||||||
|
test('containerHighlightAddOnly 开启时结束标记仍清理高亮但不返回容器', () => {
|
||||||
|
const containerEl = globalThis.document.createElement('div');
|
||||||
|
containerEl.classList.add('tmagic-stage-container-highlight');
|
||||||
|
globalThis.document.body.appendChild(containerEl);
|
||||||
|
am = new ActionManager(
|
||||||
|
createConfig({
|
||||||
|
containerHighlightType: ContainerHighlightType.DEFAULT,
|
||||||
|
containerHighlightAddOnly: true,
|
||||||
|
}),
|
||||||
|
);
|
||||||
|
|
||||||
|
expect((am as any).markContainerEnd()).toBeNull();
|
||||||
|
expect(containerEl.classList.contains('tmagic-stage-container-highlight')).toBe(false);
|
||||||
|
});
|
||||||
|
|
||||||
test('updateMoveableOptions / getDragStatus 可调用', () => {
|
test('updateMoveableOptions / getDragStatus 可调用', () => {
|
||||||
am = new ActionManager(createConfig());
|
am = new ActionManager(createConfig());
|
||||||
expect(() => am.updateMoveableOptions()).not.toThrow();
|
expect(() => am.updateMoveableOptions()).not.toThrow();
|
||||||
|
|||||||
@ -181,6 +181,16 @@ describe('StageCore', () => {
|
|||||||
stage.destroy();
|
stage.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('delayedMarkContainer 将新增标识透传给 actionManager', async () => {
|
||||||
|
const { host, stage } = createStage();
|
||||||
|
await stage.mount(host);
|
||||||
|
const spy = vi.spyOn(stage.actionManager!, 'delayedMarkContainer');
|
||||||
|
const event = mouseAtOrigin();
|
||||||
|
stage.delayedMarkContainer(event, [], true);
|
||||||
|
expect(spy).toHaveBeenCalledWith(event, [], true);
|
||||||
|
stage.destroy();
|
||||||
|
});
|
||||||
|
|
||||||
test('autoScrollIntoView 选中时调用 mask.observerIntersection', async () => {
|
test('autoScrollIntoView 选中时调用 mask.observerIntersection', async () => {
|
||||||
const host = globalThis.document.createElement('div');
|
const host = globalThis.document.createElement('div');
|
||||||
globalThis.document.body.appendChild(host);
|
globalThis.document.body.appendChild(host);
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "1.8.0-beta.15",
|
"version": "1.8.0-beta.19",
|
||||||
"name": "@tmagic/table",
|
"name": "@tmagic/table",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"sideEffects": [
|
"sideEffects": [
|
||||||
|
|||||||
@ -17,6 +17,7 @@
|
|||||||
:width="action.subActionConfig?.popoverWidth"
|
:width="action.subActionConfig?.popoverWidth"
|
||||||
:popper-class="action.subActionConfig?.popoverClass"
|
:popper-class="action.subActionConfig?.popoverClass"
|
||||||
:destroy-on-close="action.subActionConfig?.popoverDestroyOnClose ?? true"
|
:destroy-on-close="action.subActionConfig?.popoverDestroyOnClose ?? true"
|
||||||
|
@clickoutside="popoverVisible = false"
|
||||||
>
|
>
|
||||||
<template #reference>
|
<template #reference>
|
||||||
<TMagicButton
|
<TMagicButton
|
||||||
@ -84,8 +85,15 @@
|
|||||||
>
|
>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts">
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
|
||||||
|
// 所有行共享:同一时间仅允许一个 sub-actions 气泡展开,激活新的会自动关闭上一个
|
||||||
|
const activePopoverId = ref<symbol | null>(null);
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script lang="ts" setup>
|
||||||
|
import { watch } from 'vue';
|
||||||
import { ArrowDown, ArrowRight } from '@element-plus/icons-vue';
|
import { ArrowDown, ArrowRight } from '@element-plus/icons-vue';
|
||||||
import { cloneDeep } from 'lodash-es';
|
import { cloneDeep } from 'lodash-es';
|
||||||
|
|
||||||
@ -117,7 +125,23 @@ const props = withDefaults(
|
|||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const popoverId = Symbol('sub-actions-popover');
|
||||||
const popoverVisible = ref(false);
|
const popoverVisible = ref(false);
|
||||||
|
|
||||||
|
watch(popoverVisible, (visible) => {
|
||||||
|
if (visible) {
|
||||||
|
activePopoverId.value = popoverId;
|
||||||
|
} else if (activePopoverId.value === popoverId) {
|
||||||
|
activePopoverId.value = null;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
watch(activePopoverId, (id) => {
|
||||||
|
if (id !== popoverId && popoverVisible.value) {
|
||||||
|
popoverVisible.value = false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const togglePopover = () => {
|
const togglePopover = () => {
|
||||||
popoverVisible.value = !popoverVisible.value;
|
popoverVisible.value = !popoverVisible.value;
|
||||||
};
|
};
|
||||||
@ -134,7 +158,8 @@ const actionHandler = async (action: ColumnActionConfig, row: any, index: number
|
|||||||
} else {
|
} else {
|
||||||
await action.handler?.(row, index);
|
await action.handler?.(row, index);
|
||||||
}
|
}
|
||||||
action.after?.(row, index);
|
await action.after?.(row, index);
|
||||||
|
popoverVisible.value = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
const save = async (index: number, config: ColumnConfig) => {
|
const save = async (index: number, config: ColumnConfig) => {
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "1.8.0-beta.15",
|
"version": "1.8.0-beta.19",
|
||||||
"name": "@tmagic/tdesign-vue-next-adapter",
|
"name": "@tmagic/tdesign-vue-next-adapter",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "1.8.0-beta.15",
|
"version": "1.8.0-beta.19",
|
||||||
"name": "@tmagic/utils",
|
"name": "@tmagic/utils",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"sideEffects": false,
|
"sideEffects": false,
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "tmagic-playground",
|
"name": "tmagic-playground",
|
||||||
"version": "1.8.0-beta.15",
|
"version": "1.8.0-beta.19",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
@ -12,11 +12,11 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@element-plus/icons-vue": "^2.3.2",
|
"@element-plus/icons-vue": "^2.3.2",
|
||||||
"@tmagic/core": "1.8.0-beta.15",
|
"@tmagic/core": "1.8.0-beta.19",
|
||||||
"@tmagic/design": "1.8.0-beta.15",
|
"@tmagic/design": "1.8.0-beta.19",
|
||||||
"@tmagic/editor": "1.8.0-beta.15",
|
"@tmagic/editor": "1.8.0-beta.19",
|
||||||
"@tmagic/element-plus-adapter": "1.8.0-beta.15",
|
"@tmagic/element-plus-adapter": "1.8.0-beta.19",
|
||||||
"@tmagic/tdesign-vue-next-adapter": "1.8.0-beta.15",
|
"@tmagic/tdesign-vue-next-adapter": "1.8.0-beta.19",
|
||||||
"@tmagic/tmagic-form-runtime": "1.1.3",
|
"@tmagic/tmagic-form-runtime": "1.1.3",
|
||||||
"element-plus": "^2.14.3",
|
"element-plus": "^2.14.3",
|
||||||
"lodash-es": "^4.17.21",
|
"lodash-es": "^4.17.21",
|
||||||
|
|||||||
228
pnpm-lock.yaml
generated
228
pnpm-lock.yaml
generated
@ -564,23 +564,23 @@ importers:
|
|||||||
specifier: ^2.3.2
|
specifier: ^2.3.2
|
||||||
version: 2.3.2(vue@3.5.40(typescript@6.0.3))
|
version: 2.3.2(vue@3.5.40(typescript@6.0.3))
|
||||||
'@tmagic/core':
|
'@tmagic/core':
|
||||||
specifier: 1.8.0-beta.15
|
specifier: 1.8.0-beta.19
|
||||||
version: 1.8.0-beta.15(typescript@6.0.3)
|
version: 1.8.0-beta.19(typescript@6.0.3)
|
||||||
'@tmagic/design':
|
'@tmagic/design':
|
||||||
specifier: 1.8.0-beta.15
|
specifier: 1.8.0-beta.19
|
||||||
version: 1.8.0-beta.15(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))
|
version: 1.8.0-beta.19(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))
|
||||||
'@tmagic/editor':
|
'@tmagic/editor':
|
||||||
specifier: 1.8.0-beta.15
|
specifier: 1.8.0-beta.19
|
||||||
version: 1.8.0-beta.15(@tmagic/core@1.8.0-beta.15(typescript@6.0.3))(@tmagic/form-schema@1.8.0-beta.15(typescript@6.0.3))(@tmagic/schema@1.8.0-beta.15(typescript@6.0.3))(monaco-editor@0.55.1)(type-fest@5.2.0)(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))
|
version: 1.8.0-beta.19(@tmagic/core@1.8.0-beta.19(typescript@6.0.3))(@tmagic/form-schema@1.8.0-beta.19(typescript@6.0.3))(@tmagic/schema@1.8.0-beta.19(typescript@6.0.3))(monaco-editor@0.55.1)(type-fest@5.2.0)(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))
|
||||||
'@tmagic/element-plus-adapter':
|
'@tmagic/element-plus-adapter':
|
||||||
specifier: 1.8.0-beta.15
|
specifier: 1.8.0-beta.19
|
||||||
version: 1.8.0-beta.15(@tmagic/design@1.8.0-beta.15(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3)))(element-plus@2.14.3(vue@3.5.40(typescript@6.0.3)))(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))
|
version: 1.8.0-beta.19(@tmagic/design@1.8.0-beta.19(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3)))(element-plus@2.14.3(vue@3.5.40(typescript@6.0.3)))(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))
|
||||||
'@tmagic/tdesign-vue-next-adapter':
|
'@tmagic/tdesign-vue-next-adapter':
|
||||||
specifier: 1.8.0-beta.15
|
specifier: 1.8.0-beta.19
|
||||||
version: 1.8.0-beta.15(@tmagic/design@1.8.0-beta.15(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3)))(tdesign-vue-next@1.17.3(vue@3.5.40(typescript@6.0.3)))(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))
|
version: 1.8.0-beta.19(@tmagic/design@1.8.0-beta.19(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3)))(tdesign-vue-next@1.17.3(vue@3.5.40(typescript@6.0.3)))(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))
|
||||||
'@tmagic/tmagic-form-runtime':
|
'@tmagic/tmagic-form-runtime':
|
||||||
specifier: 1.1.3
|
specifier: 1.1.3
|
||||||
version: 1.1.3(@tmagic/core@1.8.0-beta.15(typescript@6.0.3))(@tmagic/editor@1.8.0-beta.15(@tmagic/core@1.8.0-beta.15(typescript@6.0.3))(@tmagic/form-schema@1.8.0-beta.15(typescript@6.0.3))(@tmagic/schema@1.8.0-beta.15(typescript@6.0.3))(monaco-editor@0.55.1)(type-fest@5.2.0)(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3)))(element-plus@2.14.3(vue@3.5.40(typescript@6.0.3)))(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))
|
version: 1.1.3(@tmagic/core@1.8.0-beta.19(typescript@6.0.3))(@tmagic/editor@1.8.0-beta.19(@tmagic/core@1.8.0-beta.19(typescript@6.0.3))(@tmagic/form-schema@1.8.0-beta.19(typescript@6.0.3))(@tmagic/schema@1.8.0-beta.19(typescript@6.0.3))(monaco-editor@0.55.1)(type-fest@5.2.0)(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3)))(element-plus@2.14.3(vue@3.5.40(typescript@6.0.3)))(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))
|
||||||
element-plus:
|
element-plus:
|
||||||
specifier: ^2.14.3
|
specifier: ^2.14.3
|
||||||
version: 2.14.3(vue@3.5.40(typescript@6.0.3))
|
version: 2.14.3(vue@3.5.40(typescript@6.0.3))
|
||||||
@ -920,14 +920,14 @@ importers:
|
|||||||
runtime/react:
|
runtime/react:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@tmagic/core':
|
'@tmagic/core':
|
||||||
specifier: 1.8.0-beta.15
|
specifier: 1.8.0-beta.19
|
||||||
version: 1.8.0-beta.15(typescript@6.0.3)
|
version: 1.8.0-beta.19(typescript@6.0.3)
|
||||||
'@tmagic/react-runtime-help':
|
'@tmagic/react-runtime-help':
|
||||||
specifier: 0.2.2
|
specifier: 0.2.2
|
||||||
version: 0.2.2(@tmagic/core@1.8.0-beta.15(typescript@6.0.3))(@tmagic/stage@1.8.0-beta.15(@tmagic/core@1.8.0-beta.15(typescript@6.0.3))(typescript@6.0.3))(lodash-es@4.18.1)(react@18.3.1)(typescript@6.0.3)
|
version: 0.2.2(@tmagic/core@1.8.0-beta.19(typescript@6.0.3))(@tmagic/stage@1.8.0-beta.19(@tmagic/core@1.8.0-beta.19(typescript@6.0.3))(typescript@6.0.3))(lodash-es@4.18.1)(react@18.3.1)(typescript@6.0.3)
|
||||||
'@tmagic/stage':
|
'@tmagic/stage':
|
||||||
specifier: 1.8.0-beta.15
|
specifier: 1.8.0-beta.19
|
||||||
version: 1.8.0-beta.15(@tmagic/core@1.8.0-beta.15(typescript@6.0.3))(typescript@6.0.3)
|
version: 1.8.0-beta.19(@tmagic/core@1.8.0-beta.19(typescript@6.0.3))(typescript@6.0.3)
|
||||||
axios:
|
axios:
|
||||||
specifier: ^1.13.2
|
specifier: ^1.13.2
|
||||||
version: 1.13.2
|
version: 1.13.2
|
||||||
@ -942,8 +942,8 @@ importers:
|
|||||||
version: 18.3.1(react@18.3.1)
|
version: 18.3.1(react@18.3.1)
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@tmagic/cli':
|
'@tmagic/cli':
|
||||||
specifier: 1.8.0-beta.15
|
specifier: 1.8.0-beta.19
|
||||||
version: 1.8.0-beta.15(typescript@6.0.3)
|
version: 1.8.0-beta.19(typescript@6.0.3)
|
||||||
'@types/fs-extra':
|
'@types/fs-extra':
|
||||||
specifier: ^11.0.4
|
specifier: ^11.0.4
|
||||||
version: 11.0.4
|
version: 11.0.4
|
||||||
@ -1018,14 +1018,14 @@ importers:
|
|||||||
runtime/vue:
|
runtime/vue:
|
||||||
dependencies:
|
dependencies:
|
||||||
'@tmagic/core':
|
'@tmagic/core':
|
||||||
specifier: 1.8.0-beta.15
|
specifier: 1.8.0-beta.19
|
||||||
version: 1.8.0-beta.15(typescript@6.0.3)
|
version: 1.8.0-beta.19(typescript@6.0.3)
|
||||||
'@tmagic/stage':
|
'@tmagic/stage':
|
||||||
specifier: 1.8.0-beta.15
|
specifier: 1.8.0-beta.19
|
||||||
version: 1.8.0-beta.15(@tmagic/core@1.8.0-beta.15(typescript@6.0.3))(typescript@6.0.3)
|
version: 1.8.0-beta.19(@tmagic/core@1.8.0-beta.19(typescript@6.0.3))(typescript@6.0.3)
|
||||||
'@tmagic/vue-runtime-help':
|
'@tmagic/vue-runtime-help':
|
||||||
specifier: ^2.0.4
|
specifier: ^2.0.4
|
||||||
version: 2.0.4(@tmagic/core@1.8.0-beta.15(typescript@6.0.3))(@tmagic/stage@1.8.0-beta.15(@tmagic/core@1.8.0-beta.15(typescript@6.0.3))(typescript@6.0.3))(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))
|
version: 2.0.4(@tmagic/core@1.8.0-beta.19(typescript@6.0.3))(@tmagic/stage@1.8.0-beta.19(@tmagic/core@1.8.0-beta.19(typescript@6.0.3))(typescript@6.0.3))(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))
|
||||||
axios:
|
axios:
|
||||||
specifier: ^1.13.2
|
specifier: ^1.13.2
|
||||||
version: 1.13.2
|
version: 1.13.2
|
||||||
@ -1034,8 +1034,8 @@ importers:
|
|||||||
version: 3.5.40(typescript@6.0.3)
|
version: 3.5.40(typescript@6.0.3)
|
||||||
devDependencies:
|
devDependencies:
|
||||||
'@tmagic/cli':
|
'@tmagic/cli':
|
||||||
specifier: 1.8.0-beta.15
|
specifier: 1.8.0-beta.19
|
||||||
version: 1.8.0-beta.15(typescript@6.0.3)
|
version: 1.8.0-beta.19(typescript@6.0.3)
|
||||||
'@types/fs-extra':
|
'@types/fs-extra':
|
||||||
specifier: ^11.0.4
|
specifier: ^11.0.4
|
||||||
version: 11.0.4
|
version: 11.0.4
|
||||||
@ -2997,8 +2997,8 @@ packages:
|
|||||||
'@sxzz/popperjs-es@2.11.8':
|
'@sxzz/popperjs-es@2.11.8':
|
||||||
resolution: {integrity: sha512-wOwESXvvED3S8xBmcPWHs2dUuzrE4XiZeFu7e1hROIJkm02a49N120pmOXxY33sBb6hArItm5W5tcg1cBtV+HQ==}
|
resolution: {integrity: sha512-wOwESXvvED3S8xBmcPWHs2dUuzrE4XiZeFu7e1hROIJkm02a49N120pmOXxY33sBb6hArItm5W5tcg1cBtV+HQ==}
|
||||||
|
|
||||||
'@tmagic/cli@1.8.0-beta.15':
|
'@tmagic/cli@1.8.0-beta.19':
|
||||||
resolution: {integrity: sha512-SXheOCY5pcl+UbJmsoeOIcNkHVvfrwd2/Tp3wlm8n4HuBF13kElbhaBaT79fvkH7govXaO3LyIIGnh+DG+6jBg==}
|
resolution: {integrity: sha512-bE4HOcfiutLxA8YPG6AEyJm8sm6Is9kTWyOB59rUY0qNwDy1sxe9QcqWrKPNvYqchVVNpsBx3xGNeI2w059QsQ==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
hasBin: true
|
hasBin: true
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
@ -3025,8 +3025,8 @@ packages:
|
|||||||
typescript:
|
typescript:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@tmagic/core@1.8.0-beta.15':
|
'@tmagic/core@1.8.0-beta.19':
|
||||||
resolution: {integrity: sha512-nN5C1/tVyV9vOb9BTQvdVpM2UmQOBw6Xjrzj7NFusPyC8HCKgYAdWqoIciODPqoM9V6uPGuM450Y5E6zXsm1bA==}
|
resolution: {integrity: sha512-9pDaAlesKrA9Ngs+EOy/lzS3CXgFNT7hBlAKCAR16csGGAkW8wkLBPdsSUotBcOqhAw1+VrsbztU+U8l5K6kEQ==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
typescript: ^6.0.3
|
typescript: ^6.0.3
|
||||||
@ -3054,11 +3054,11 @@ packages:
|
|||||||
typescript:
|
typescript:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@tmagic/data-source@1.8.0-beta.15':
|
'@tmagic/data-source@1.8.0-beta.19':
|
||||||
resolution: {integrity: sha512-2Me1wbdyd7+Vo7EUKYnKu36mGSBcdK5GwMpuRm6RX+3NEgxW/tg+PHdSnxhyXe57eyjeQsBE6PNjkuYWc36knQ==}
|
resolution: {integrity: sha512-ysOT1wG5gWUsPZFv77Lc/IShWGyMxNDqPjFTVFFk9yfBc0rd1RMZmuWTMEyGjl1wVEXgPYZ+Exbq1mJxAOoPYQ==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
'@tmagic/core': 1.8.0-beta.15
|
'@tmagic/core': 1.8.0-beta.19
|
||||||
typescript: ^6.0.3
|
typescript: ^6.0.3
|
||||||
peerDependenciesMeta:
|
peerDependenciesMeta:
|
||||||
typescript:
|
typescript:
|
||||||
@ -3086,12 +3086,12 @@ packages:
|
|||||||
typescript:
|
typescript:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@tmagic/dep@1.8.0-beta.15':
|
'@tmagic/dep@1.8.0-beta.19':
|
||||||
resolution: {integrity: sha512-9y4RDPUpyyMbG94x2rkvriI7KHg29nn7xykDPGy2PtF4eZECtj9fgf5oDqVo21kT/n/nDn1WpMoEX56jO/2tmw==}
|
resolution: {integrity: sha512-DuZACNcHISFBIidTpPCkatTuNu/gzIVZPlIHAnVIsZLYlkkZNGExm/fvNGH6O5LTNZoqNaO4xfAq6O+3W3RreA==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
'@tmagic/schema': 1.8.0-beta.15
|
'@tmagic/schema': 1.8.0-beta.19
|
||||||
'@tmagic/utils': 1.8.0-beta.15
|
'@tmagic/utils': 1.8.0-beta.19
|
||||||
typescript: ^6.0.3
|
typescript: ^6.0.3
|
||||||
peerDependenciesMeta:
|
peerDependenciesMeta:
|
||||||
typescript:
|
typescript:
|
||||||
@ -3107,8 +3107,8 @@ packages:
|
|||||||
typescript:
|
typescript:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@tmagic/design@1.8.0-beta.15':
|
'@tmagic/design@1.8.0-beta.19':
|
||||||
resolution: {integrity: sha512-vh7fNy3gs63FzVILojstTx2xYszE2RKdeijAHDGMkWmnrTpWj1QhuEd+lq8ipu41fjGZsz/9EeAImJ0PWaRCPA==}
|
resolution: {integrity: sha512-ctk5+0GPhS5NmQOGUIs5W3MA5cEmVQa1OZvNKwtUj1Jqbe5pF/j4BgnXbg2dpdnkYYe07CVP3GpCv6sbPhxm5A==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
typescript: ^6.0.3
|
typescript: ^6.0.3
|
||||||
@ -3129,11 +3129,11 @@ packages:
|
|||||||
typescript:
|
typescript:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@tmagic/editor@1.8.0-beta.15':
|
'@tmagic/editor@1.8.0-beta.19':
|
||||||
resolution: {integrity: sha512-B34YITY0QHu5j6/ZD/JhF6ft/GPpWeV4c7SpxTRkTQGwxaB0xyJ1M2W+p2pGtDM+mlAswJ7h5MXlfmpOYGne/w==}
|
resolution: {integrity: sha512-cXzSUTqunuGDMNDpYVt3qKOeldmk3hQVW3ykkVG2P/nPNcYYWKraXUsQ8gz6AtIVlt75OsKi1HrFvMSezhGR1w==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
'@tmagic/core': 1.8.0-beta.15
|
'@tmagic/core': 1.8.0-beta.19
|
||||||
monaco-editor: '^0.55.1 '
|
monaco-editor: '^0.55.1 '
|
||||||
type-fest: ^5.2.0
|
type-fest: ^5.2.0
|
||||||
typescript: ^6.0.3
|
typescript: ^6.0.3
|
||||||
@ -3144,11 +3144,11 @@ packages:
|
|||||||
typescript:
|
typescript:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@tmagic/element-plus-adapter@1.8.0-beta.15':
|
'@tmagic/element-plus-adapter@1.8.0-beta.19':
|
||||||
resolution: {integrity: sha512-UyBnS3mskpg6foWftGcVyIhF3yiLvVVgOxJDNhUhEWO5X3M09XWFmIFb+759fomCDvMhRIX3VJuos2sQIFRjTQ==}
|
resolution: {integrity: sha512-i3gCJB+qKVIt62hhheiaPLBiFfVbGSXki2G3CFts1kkjlQ9i7VePnkJOMbUZikJbJxk6NJ4GlPohxuot9NB99Q==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
'@tmagic/design': 1.8.0-beta.15
|
'@tmagic/design': 1.8.0-beta.19
|
||||||
element-plus: ^2.14.3
|
element-plus: ^2.14.3
|
||||||
typescript: ^6.0.3
|
typescript: ^6.0.3
|
||||||
vue: ^3.5.40
|
vue: ^3.5.40
|
||||||
@ -3165,8 +3165,8 @@ packages:
|
|||||||
typescript:
|
typescript:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@tmagic/form-schema@1.8.0-beta.15':
|
'@tmagic/form-schema@1.8.0-beta.19':
|
||||||
resolution: {integrity: sha512-a1cAcoW/FrCcm0Mw2yYa/PbIH8hT4pGxBrV9wt5mF6u+7eQ3wP4b9vKcnwTj142sfR11H2zgS5hu4rxF7mDJJQ==}
|
resolution: {integrity: sha512-BJi9n2WaMVTlPi1Tjm3O3e3QOANrbztZM6GwHHw/k9LS9cnJx+yhfTO+poF64gNPfS3fEAc80gXf2raiT+olFQ==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
typescript: ^6.0.3
|
typescript: ^6.0.3
|
||||||
@ -3187,13 +3187,13 @@ packages:
|
|||||||
typescript:
|
typescript:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@tmagic/form@1.8.0-beta.15':
|
'@tmagic/form@1.8.0-beta.19':
|
||||||
resolution: {integrity: sha512-cx8JmiZi9kGwt/mEqwX7RHm4B+NvHbjZs70ogpzwVgkLNefylYNOg8JGdiyjUSRhP3bU+D+epGo9o53l4Pzz0g==}
|
resolution: {integrity: sha512-uIELcBaNNQoKmJntpU8QOwozVKKKHU8pvwaClLFI3+cIFA2818d6BNIOUqb0fjkahUxyJ85CCa4iPjGy9Qnkjw==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
'@tmagic/design': 1.8.0-beta.15
|
'@tmagic/design': 1.8.0-beta.19
|
||||||
'@tmagic/form-schema': 1.8.0-beta.15
|
'@tmagic/form-schema': 1.8.0-beta.19
|
||||||
'@tmagic/utils': 1.8.0-beta.15
|
'@tmagic/utils': 1.8.0-beta.19
|
||||||
typescript: ^6.0.3
|
typescript: ^6.0.3
|
||||||
vue: ^3.5.40
|
vue: ^3.5.40
|
||||||
peerDependenciesMeta:
|
peerDependenciesMeta:
|
||||||
@ -3235,8 +3235,8 @@ packages:
|
|||||||
typescript:
|
typescript:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@tmagic/schema@1.8.0-beta.15':
|
'@tmagic/schema@1.8.0-beta.19':
|
||||||
resolution: {integrity: sha512-ehlSOGQh6RYg0CCNHiWsq6WlHIcMsnI3XitmRISyslEBJDI+0BS08ElLIb9BlhyE+hhL+1mhAOXVdiKfE2Lj/Q==}
|
resolution: {integrity: sha512-I30VYTns7KqG8TQVELlEYYB6ghKLMw5uOHk7Lksh7IxbEkNT4gaYLg8uFlOiDx5SOjRxjeI4IRfIoQYBVok3JA==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
typescript: ^6.0.3
|
typescript: ^6.0.3
|
||||||
@ -3264,11 +3264,11 @@ packages:
|
|||||||
typescript:
|
typescript:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@tmagic/stage@1.8.0-beta.15':
|
'@tmagic/stage@1.8.0-beta.19':
|
||||||
resolution: {integrity: sha512-3YsKf7PFRqwzeHQcCmdgAKmFHEL1kbHkCXjj/5fLs0d3Dca0FT+zkcIM+lRlBocIeFz11I7JasQ83iJwA6qTtg==}
|
resolution: {integrity: sha512-YEXJVOPtI0m3garxOf/LS/bZpWDj643pvB2FXDSIeXtgg3roy3wnqaJ44Y2s/+ekdwyJ2XencN9BAFov/Zrk2g==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
'@tmagic/core': 1.8.0-beta.15
|
'@tmagic/core': 1.8.0-beta.19
|
||||||
typescript: ^6.0.3
|
typescript: ^6.0.3
|
||||||
peerDependenciesMeta:
|
peerDependenciesMeta:
|
||||||
typescript:
|
typescript:
|
||||||
@ -3286,24 +3286,24 @@ packages:
|
|||||||
typescript:
|
typescript:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@tmagic/table@1.8.0-beta.15':
|
'@tmagic/table@1.8.0-beta.19':
|
||||||
resolution: {integrity: sha512-iuzWL/5oIWJ1/w8n8oLOXlVwk2KHg+DaHLZB4ux2DlreXuq6/EDkRjeR1YJxY1XQcBOA2lTp6x/cHUMWtZFs7g==}
|
resolution: {integrity: sha512-4bKUAk3NPUEGfPTCXLW8LQOS8QKXv1UmSuuOTWJMchI2o3f2BhY2VleXS3vcpEnNruvr0EODHQKdidhXWrxCtA==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
'@tmagic/design': 1.8.0-beta.15
|
'@tmagic/design': 1.8.0-beta.19
|
||||||
'@tmagic/form': 1.8.0-beta.15
|
'@tmagic/form': 1.8.0-beta.19
|
||||||
'@tmagic/utils': 1.8.0-beta.15
|
'@tmagic/utils': 1.8.0-beta.19
|
||||||
typescript: ^6.0.3
|
typescript: ^6.0.3
|
||||||
vue: ^3.5.40
|
vue: ^3.5.40
|
||||||
peerDependenciesMeta:
|
peerDependenciesMeta:
|
||||||
typescript:
|
typescript:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@tmagic/tdesign-vue-next-adapter@1.8.0-beta.15':
|
'@tmagic/tdesign-vue-next-adapter@1.8.0-beta.19':
|
||||||
resolution: {integrity: sha512-1IMYlV36O7cpR0U2Vo2hL+7Jruz6szZYYw8glVB/kGd1Ou4A0dwmzZoIQdTTBGfHTJHVudye4+22BAXh7oELPA==}
|
resolution: {integrity: sha512-ihCOW/YaSZfnxzvi3uC/kAHTXD2arvjgtBhNW00IN0+2y2xrIaO1k2YRNdMg6PjGwXbjZOEQ7aScbQaTtHcT+g==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
'@tmagic/design': 1.8.0-beta.15
|
'@tmagic/design': 1.8.0-beta.19
|
||||||
tdesign-vue-next: ^1.17.1
|
tdesign-vue-next: ^1.17.1
|
||||||
typescript: ^6.0.3
|
typescript: ^6.0.3
|
||||||
vue: ^3.5.40
|
vue: ^3.5.40
|
||||||
@ -3346,11 +3346,11 @@ packages:
|
|||||||
typescript:
|
typescript:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@tmagic/utils@1.8.0-beta.15':
|
'@tmagic/utils@1.8.0-beta.19':
|
||||||
resolution: {integrity: sha512-MmUHz9K7VnsqeyvuxBECIsHcDglaiOwGyaEZoEs6zCw3UfZE2pFKAxWs5YZqDpEWsEqOlk99gAXt77zgb727VQ==}
|
resolution: {integrity: sha512-MsjCwnm6uwag2UNrZEDnyeVVYyMYnw4uRFhPwK/uJZ/SZwUnim3Mrz7Ay8oD68adcv69wdKWzatkqQ5ExJT/XA==}
|
||||||
engines: {node: '>=18'}
|
engines: {node: '>=18'}
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
'@tmagic/schema': 1.8.0-beta.15
|
'@tmagic/schema': 1.8.0-beta.19
|
||||||
typescript: ^6.0.3
|
typescript: ^6.0.3
|
||||||
peerDependenciesMeta:
|
peerDependenciesMeta:
|
||||||
typescript:
|
typescript:
|
||||||
@ -8737,7 +8737,7 @@ snapshots:
|
|||||||
|
|
||||||
'@sxzz/popperjs-es@2.11.8': {}
|
'@sxzz/popperjs-es@2.11.8': {}
|
||||||
|
|
||||||
'@tmagic/cli@1.8.0-beta.15(typescript@6.0.3)':
|
'@tmagic/cli@1.8.0-beta.19(typescript@6.0.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
cac: 6.7.14
|
cac: 6.7.14
|
||||||
chokidar: 3.6.0
|
chokidar: 3.6.0
|
||||||
@ -8772,12 +8772,12 @@ snapshots:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
|
|
||||||
'@tmagic/core@1.8.0-beta.15(typescript@6.0.3)':
|
'@tmagic/core@1.8.0-beta.19(typescript@6.0.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@tmagic/data-source': 1.8.0-beta.15(@tmagic/core@1.8.0-beta.15(typescript@6.0.3))(typescript@6.0.3)
|
'@tmagic/data-source': 1.8.0-beta.19(@tmagic/core@1.8.0-beta.19(typescript@6.0.3))(typescript@6.0.3)
|
||||||
'@tmagic/dep': 1.8.0-beta.15(@tmagic/schema@1.8.0-beta.15(typescript@6.0.3))(@tmagic/utils@1.8.0-beta.15(@tmagic/schema@1.8.0-beta.15(typescript@6.0.3))(typescript@6.0.3))(typescript@6.0.3)
|
'@tmagic/dep': 1.8.0-beta.19(@tmagic/schema@1.8.0-beta.19(typescript@6.0.3))(@tmagic/utils@1.8.0-beta.19(@tmagic/schema@1.8.0-beta.19(typescript@6.0.3))(typescript@6.0.3))(typescript@6.0.3)
|
||||||
'@tmagic/schema': 1.8.0-beta.15(typescript@6.0.3)
|
'@tmagic/schema': 1.8.0-beta.19(typescript@6.0.3)
|
||||||
'@tmagic/utils': 1.8.0-beta.15(@tmagic/schema@1.8.0-beta.15(typescript@6.0.3))(typescript@6.0.3)
|
'@tmagic/utils': 1.8.0-beta.19(@tmagic/schema@1.8.0-beta.19(typescript@6.0.3))(typescript@6.0.3)
|
||||||
events: 3.3.0
|
events: 3.3.0
|
||||||
lodash-es: 4.18.1
|
lodash-es: 4.18.1
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
@ -8801,9 +8801,9 @@ snapshots:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
|
|
||||||
'@tmagic/data-source@1.8.0-beta.15(@tmagic/core@1.8.0-beta.15(typescript@6.0.3))(typescript@6.0.3)':
|
'@tmagic/data-source@1.8.0-beta.19(@tmagic/core@1.8.0-beta.19(typescript@6.0.3))(typescript@6.0.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@tmagic/core': 1.8.0-beta.15(typescript@6.0.3)
|
'@tmagic/core': 1.8.0-beta.19(typescript@6.0.3)
|
||||||
deep-state-observer: 5.5.14
|
deep-state-observer: 5.5.14
|
||||||
events: 3.3.0
|
events: 3.3.0
|
||||||
lodash-es: 4.18.1
|
lodash-es: 4.18.1
|
||||||
@ -8824,10 +8824,10 @@ snapshots:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
|
|
||||||
'@tmagic/dep@1.8.0-beta.15(@tmagic/schema@1.8.0-beta.15(typescript@6.0.3))(@tmagic/utils@1.8.0-beta.15(@tmagic/schema@1.8.0-beta.15(typescript@6.0.3))(typescript@6.0.3))(typescript@6.0.3)':
|
'@tmagic/dep@1.8.0-beta.19(@tmagic/schema@1.8.0-beta.19(typescript@6.0.3))(@tmagic/utils@1.8.0-beta.19(@tmagic/schema@1.8.0-beta.19(typescript@6.0.3))(typescript@6.0.3))(typescript@6.0.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@tmagic/schema': 1.8.0-beta.15(typescript@6.0.3)
|
'@tmagic/schema': 1.8.0-beta.19(typescript@6.0.3)
|
||||||
'@tmagic/utils': 1.8.0-beta.15(@tmagic/schema@1.8.0-beta.15(typescript@6.0.3))(typescript@6.0.3)
|
'@tmagic/utils': 1.8.0-beta.19(@tmagic/schema@1.8.0-beta.19(typescript@6.0.3))(typescript@6.0.3)
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
|
|
||||||
@ -8838,7 +8838,7 @@ snapshots:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
|
|
||||||
'@tmagic/design@1.8.0-beta.15(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))':
|
'@tmagic/design@1.8.0-beta.19(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@popperjs/core': 2.11.8
|
'@popperjs/core': 2.11.8
|
||||||
vue: 3.5.40(typescript@6.0.3)
|
vue: 3.5.40(typescript@6.0.3)
|
||||||
@ -8872,15 +8872,15 @@ snapshots:
|
|||||||
- '@tmagic/form-schema'
|
- '@tmagic/form-schema'
|
||||||
- '@tmagic/schema'
|
- '@tmagic/schema'
|
||||||
|
|
||||||
'@tmagic/editor@1.8.0-beta.15(@tmagic/core@1.8.0-beta.15(typescript@6.0.3))(@tmagic/form-schema@1.8.0-beta.15(typescript@6.0.3))(@tmagic/schema@1.8.0-beta.15(typescript@6.0.3))(monaco-editor@0.55.1)(type-fest@5.2.0)(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))':
|
'@tmagic/editor@1.8.0-beta.19(@tmagic/core@1.8.0-beta.19(typescript@6.0.3))(@tmagic/form-schema@1.8.0-beta.19(typescript@6.0.3))(@tmagic/schema@1.8.0-beta.19(typescript@6.0.3))(monaco-editor@0.55.1)(type-fest@5.2.0)(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@element-plus/icons-vue': 2.3.2(vue@3.5.40(typescript@6.0.3))
|
'@element-plus/icons-vue': 2.3.2(vue@3.5.40(typescript@6.0.3))
|
||||||
'@tmagic/core': 1.8.0-beta.15(typescript@6.0.3)
|
'@tmagic/core': 1.8.0-beta.19(typescript@6.0.3)
|
||||||
'@tmagic/design': 1.8.0-beta.15(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))
|
'@tmagic/design': 1.8.0-beta.19(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))
|
||||||
'@tmagic/form': 1.8.0-beta.15(@tmagic/design@1.8.0-beta.15(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3)))(@tmagic/form-schema@1.8.0-beta.15(typescript@6.0.3))(@tmagic/utils@1.8.0-beta.15(@tmagic/schema@1.8.0-beta.15(typescript@6.0.3))(typescript@6.0.3))(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))
|
'@tmagic/form': 1.8.0-beta.19(@tmagic/design@1.8.0-beta.19(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3)))(@tmagic/form-schema@1.8.0-beta.19(typescript@6.0.3))(@tmagic/utils@1.8.0-beta.19(@tmagic/schema@1.8.0-beta.19(typescript@6.0.3))(typescript@6.0.3))(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))
|
||||||
'@tmagic/stage': 1.8.0-beta.15(@tmagic/core@1.8.0-beta.15(typescript@6.0.3))(typescript@6.0.3)
|
'@tmagic/stage': 1.8.0-beta.19(@tmagic/core@1.8.0-beta.19(typescript@6.0.3))(typescript@6.0.3)
|
||||||
'@tmagic/table': 1.8.0-beta.15(@tmagic/design@1.8.0-beta.15(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3)))(@tmagic/form@1.8.0-beta.15(@tmagic/design@1.8.0-beta.15(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3)))(@tmagic/form-schema@1.8.0-beta.15(typescript@6.0.3))(@tmagic/utils@1.8.0-beta.15(@tmagic/schema@1.8.0-beta.15(typescript@6.0.3))(typescript@6.0.3))(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3)))(@tmagic/utils@1.8.0-beta.15(@tmagic/schema@1.8.0-beta.15(typescript@6.0.3))(typescript@6.0.3))(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))
|
'@tmagic/table': 1.8.0-beta.19(@tmagic/design@1.8.0-beta.19(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3)))(@tmagic/form@1.8.0-beta.19(@tmagic/design@1.8.0-beta.19(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3)))(@tmagic/form-schema@1.8.0-beta.19(typescript@6.0.3))(@tmagic/utils@1.8.0-beta.19(@tmagic/schema@1.8.0-beta.19(typescript@6.0.3))(typescript@6.0.3))(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3)))(@tmagic/utils@1.8.0-beta.19(@tmagic/schema@1.8.0-beta.19(typescript@6.0.3))(typescript@6.0.3))(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))
|
||||||
'@tmagic/utils': 1.8.0-beta.15(@tmagic/schema@1.8.0-beta.15(typescript@6.0.3))(typescript@6.0.3)
|
'@tmagic/utils': 1.8.0-beta.19(@tmagic/schema@1.8.0-beta.19(typescript@6.0.3))(typescript@6.0.3)
|
||||||
buffer: 6.0.3
|
buffer: 6.0.3
|
||||||
deep-object-diff: 1.1.9
|
deep-object-diff: 1.1.9
|
||||||
emmet-monaco-es: 5.7.0(monaco-editor@0.55.1)
|
emmet-monaco-es: 5.7.0(monaco-editor@0.55.1)
|
||||||
@ -8900,9 +8900,9 @@ snapshots:
|
|||||||
- '@tmagic/form-schema'
|
- '@tmagic/form-schema'
|
||||||
- '@tmagic/schema'
|
- '@tmagic/schema'
|
||||||
|
|
||||||
'@tmagic/element-plus-adapter@1.8.0-beta.15(@tmagic/design@1.8.0-beta.15(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3)))(element-plus@2.14.3(vue@3.5.40(typescript@6.0.3)))(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))':
|
'@tmagic/element-plus-adapter@1.8.0-beta.19(@tmagic/design@1.8.0-beta.19(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3)))(element-plus@2.14.3(vue@3.5.40(typescript@6.0.3)))(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@tmagic/design': 1.8.0-beta.15(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))
|
'@tmagic/design': 1.8.0-beta.19(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))
|
||||||
element-plus: 2.14.3(vue@3.5.40(typescript@6.0.3))
|
element-plus: 2.14.3(vue@3.5.40(typescript@6.0.3))
|
||||||
vue: 3.5.40(typescript@6.0.3)
|
vue: 3.5.40(typescript@6.0.3)
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
@ -8914,9 +8914,9 @@ snapshots:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
|
|
||||||
'@tmagic/form-schema@1.8.0-beta.15(typescript@6.0.3)':
|
'@tmagic/form-schema@1.8.0-beta.19(typescript@6.0.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@tmagic/schema': 1.8.0-beta.15(typescript@6.0.3)
|
'@tmagic/schema': 1.8.0-beta.19(typescript@6.0.3)
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
|
|
||||||
@ -8934,13 +8934,13 @@ snapshots:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
|
|
||||||
'@tmagic/form@1.8.0-beta.15(@tmagic/design@1.8.0-beta.15(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3)))(@tmagic/form-schema@1.8.0-beta.15(typescript@6.0.3))(@tmagic/utils@1.8.0-beta.15(@tmagic/schema@1.8.0-beta.15(typescript@6.0.3))(typescript@6.0.3))(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))':
|
'@tmagic/form@1.8.0-beta.19(@tmagic/design@1.8.0-beta.19(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3)))(@tmagic/form-schema@1.8.0-beta.19(typescript@6.0.3))(@tmagic/utils@1.8.0-beta.19(@tmagic/schema@1.8.0-beta.19(typescript@6.0.3))(typescript@6.0.3))(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@element-plus/icons-vue': 2.3.2(vue@3.5.40(typescript@6.0.3))
|
'@element-plus/icons-vue': 2.3.2(vue@3.5.40(typescript@6.0.3))
|
||||||
'@popperjs/core': 2.11.8
|
'@popperjs/core': 2.11.8
|
||||||
'@tmagic/design': 1.8.0-beta.15(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))
|
'@tmagic/design': 1.8.0-beta.19(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))
|
||||||
'@tmagic/form-schema': 1.8.0-beta.15(typescript@6.0.3)
|
'@tmagic/form-schema': 1.8.0-beta.19(typescript@6.0.3)
|
||||||
'@tmagic/utils': 1.8.0-beta.15(@tmagic/schema@1.8.0-beta.15(typescript@6.0.3))(typescript@6.0.3)
|
'@tmagic/utils': 1.8.0-beta.19(@tmagic/schema@1.8.0-beta.19(typescript@6.0.3))(typescript@6.0.3)
|
||||||
dayjs: 1.11.21
|
dayjs: 1.11.21
|
||||||
lodash-es: 4.18.1
|
lodash-es: 4.18.1
|
||||||
sortablejs: 1.15.6
|
sortablejs: 1.15.6
|
||||||
@ -8948,13 +8948,13 @@ snapshots:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
|
|
||||||
'@tmagic/react-runtime-help@0.2.2(@tmagic/core@1.8.0-beta.15(typescript@6.0.3))(@tmagic/stage@1.8.0-beta.15(@tmagic/core@1.8.0-beta.15(typescript@6.0.3))(typescript@6.0.3))(lodash-es@4.18.1)(react@18.3.1)(typescript@6.0.3)':
|
'@tmagic/react-runtime-help@0.2.2(@tmagic/core@1.8.0-beta.19(typescript@6.0.3))(@tmagic/stage@1.8.0-beta.19(@tmagic/core@1.8.0-beta.19(typescript@6.0.3))(typescript@6.0.3))(lodash-es@4.18.1)(react@18.3.1)(typescript@6.0.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
lodash-es: 4.18.1
|
lodash-es: 4.18.1
|
||||||
react: 18.3.1
|
react: 18.3.1
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@tmagic/core': 1.8.0-beta.15(typescript@6.0.3)
|
'@tmagic/core': 1.8.0-beta.19(typescript@6.0.3)
|
||||||
'@tmagic/stage': 1.8.0-beta.15(@tmagic/core@1.8.0-beta.15(typescript@6.0.3))(typescript@6.0.3)
|
'@tmagic/stage': 1.8.0-beta.19(@tmagic/core@1.8.0-beta.19(typescript@6.0.3))(typescript@6.0.3)
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
|
|
||||||
'@tmagic/schema@1.7.0(typescript@6.0.3)':
|
'@tmagic/schema@1.7.0(typescript@6.0.3)':
|
||||||
@ -8965,7 +8965,7 @@ snapshots:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
|
|
||||||
'@tmagic/schema@1.8.0-beta.15(typescript@6.0.3)':
|
'@tmagic/schema@1.8.0-beta.19(typescript@6.0.3)':
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
|
|
||||||
@ -8995,10 +8995,10 @@ snapshots:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
|
|
||||||
'@tmagic/stage@1.8.0-beta.15(@tmagic/core@1.8.0-beta.15(typescript@6.0.3))(typescript@6.0.3)':
|
'@tmagic/stage@1.8.0-beta.19(@tmagic/core@1.8.0-beta.19(typescript@6.0.3))(typescript@6.0.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@scena/guides': 0.29.2
|
'@scena/guides': 0.29.2
|
||||||
'@tmagic/core': 1.8.0-beta.15(typescript@6.0.3)
|
'@tmagic/core': 1.8.0-beta.19(typescript@6.0.3)
|
||||||
'@zumer/snapdom': 2.8.0
|
'@zumer/snapdom': 2.8.0
|
||||||
events: 3.3.0
|
events: 3.3.0
|
||||||
keycon: 1.4.0
|
keycon: 1.4.0
|
||||||
@ -9018,32 +9018,32 @@ snapshots:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
|
|
||||||
'@tmagic/table@1.8.0-beta.15(@tmagic/design@1.8.0-beta.15(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3)))(@tmagic/form@1.8.0-beta.15(@tmagic/design@1.8.0-beta.15(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3)))(@tmagic/form-schema@1.8.0-beta.15(typescript@6.0.3))(@tmagic/utils@1.8.0-beta.15(@tmagic/schema@1.8.0-beta.15(typescript@6.0.3))(typescript@6.0.3))(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3)))(@tmagic/utils@1.8.0-beta.15(@tmagic/schema@1.8.0-beta.15(typescript@6.0.3))(typescript@6.0.3))(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))':
|
'@tmagic/table@1.8.0-beta.19(@tmagic/design@1.8.0-beta.19(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3)))(@tmagic/form@1.8.0-beta.19(@tmagic/design@1.8.0-beta.19(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3)))(@tmagic/form-schema@1.8.0-beta.19(typescript@6.0.3))(@tmagic/utils@1.8.0-beta.19(@tmagic/schema@1.8.0-beta.19(typescript@6.0.3))(typescript@6.0.3))(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3)))(@tmagic/utils@1.8.0-beta.19(@tmagic/schema@1.8.0-beta.19(typescript@6.0.3))(typescript@6.0.3))(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@element-plus/icons-vue': 2.3.2(vue@3.5.40(typescript@6.0.3))
|
'@element-plus/icons-vue': 2.3.2(vue@3.5.40(typescript@6.0.3))
|
||||||
'@tmagic/design': 1.8.0-beta.15(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))
|
'@tmagic/design': 1.8.0-beta.19(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))
|
||||||
'@tmagic/form': 1.8.0-beta.15(@tmagic/design@1.8.0-beta.15(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3)))(@tmagic/form-schema@1.8.0-beta.15(typescript@6.0.3))(@tmagic/utils@1.8.0-beta.15(@tmagic/schema@1.8.0-beta.15(typescript@6.0.3))(typescript@6.0.3))(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))
|
'@tmagic/form': 1.8.0-beta.19(@tmagic/design@1.8.0-beta.19(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3)))(@tmagic/form-schema@1.8.0-beta.19(typescript@6.0.3))(@tmagic/utils@1.8.0-beta.19(@tmagic/schema@1.8.0-beta.19(typescript@6.0.3))(typescript@6.0.3))(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))
|
||||||
'@tmagic/utils': 1.8.0-beta.15(@tmagic/schema@1.8.0-beta.15(typescript@6.0.3))(typescript@6.0.3)
|
'@tmagic/utils': 1.8.0-beta.19(@tmagic/schema@1.8.0-beta.19(typescript@6.0.3))(typescript@6.0.3)
|
||||||
lodash-es: 4.18.1
|
lodash-es: 4.18.1
|
||||||
vue: 3.5.40(typescript@6.0.3)
|
vue: 3.5.40(typescript@6.0.3)
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
|
|
||||||
'@tmagic/tdesign-vue-next-adapter@1.8.0-beta.15(@tmagic/design@1.8.0-beta.15(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3)))(tdesign-vue-next@1.17.3(vue@3.5.40(typescript@6.0.3)))(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))':
|
'@tmagic/tdesign-vue-next-adapter@1.8.0-beta.19(@tmagic/design@1.8.0-beta.19(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3)))(tdesign-vue-next@1.17.3(vue@3.5.40(typescript@6.0.3)))(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@tmagic/design': 1.8.0-beta.15(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))
|
'@tmagic/design': 1.8.0-beta.19(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))
|
||||||
tdesign-vue-next: 1.17.3(vue@3.5.40(typescript@6.0.3))
|
tdesign-vue-next: 1.17.3(vue@3.5.40(typescript@6.0.3))
|
||||||
vue: 3.5.40(typescript@6.0.3)
|
vue: 3.5.40(typescript@6.0.3)
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
|
|
||||||
'@tmagic/tmagic-form-runtime@1.1.3(@tmagic/core@1.8.0-beta.15(typescript@6.0.3))(@tmagic/editor@1.8.0-beta.15(@tmagic/core@1.8.0-beta.15(typescript@6.0.3))(@tmagic/form-schema@1.8.0-beta.15(typescript@6.0.3))(@tmagic/schema@1.8.0-beta.15(typescript@6.0.3))(monaco-editor@0.55.1)(type-fest@5.2.0)(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3)))(element-plus@2.14.3(vue@3.5.40(typescript@6.0.3)))(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))':
|
'@tmagic/tmagic-form-runtime@1.1.3(@tmagic/core@1.8.0-beta.19(typescript@6.0.3))(@tmagic/editor@1.8.0-beta.19(@tmagic/core@1.8.0-beta.19(typescript@6.0.3))(@tmagic/form-schema@1.8.0-beta.19(typescript@6.0.3))(@tmagic/schema@1.8.0-beta.19(typescript@6.0.3))(monaco-editor@0.55.1)(type-fest@5.2.0)(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3)))(element-plus@2.14.3(vue@3.5.40(typescript@6.0.3)))(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@tmagic/editor': 1.8.0-beta.15(@tmagic/core@1.8.0-beta.15(typescript@6.0.3))(@tmagic/form-schema@1.8.0-beta.15(typescript@6.0.3))(@tmagic/schema@1.8.0-beta.15(typescript@6.0.3))(monaco-editor@0.55.1)(type-fest@5.2.0)(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))
|
'@tmagic/editor': 1.8.0-beta.19(@tmagic/core@1.8.0-beta.19(typescript@6.0.3))(@tmagic/form-schema@1.8.0-beta.19(typescript@6.0.3))(@tmagic/schema@1.8.0-beta.19(typescript@6.0.3))(monaco-editor@0.55.1)(type-fest@5.2.0)(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))
|
||||||
element-plus: 2.14.3(vue@3.5.40(typescript@6.0.3))
|
element-plus: 2.14.3(vue@3.5.40(typescript@6.0.3))
|
||||||
vue: 3.5.40(typescript@6.0.3)
|
vue: 3.5.40(typescript@6.0.3)
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@tmagic/core': 1.8.0-beta.15(typescript@6.0.3)
|
'@tmagic/core': 1.8.0-beta.19(typescript@6.0.3)
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
|
|
||||||
'@tmagic/utils@1.7.0(@tmagic/schema@1.7.0(typescript@6.0.3))(typescript@6.0.3)':
|
'@tmagic/utils@1.7.0(@tmagic/schema@1.7.0(typescript@6.0.3))(typescript@6.0.3)':
|
||||||
@ -9060,19 +9060,19 @@ snapshots:
|
|||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
|
|
||||||
'@tmagic/utils@1.8.0-beta.15(@tmagic/schema@1.8.0-beta.15(typescript@6.0.3))(typescript@6.0.3)':
|
'@tmagic/utils@1.8.0-beta.19(@tmagic/schema@1.8.0-beta.19(typescript@6.0.3))(typescript@6.0.3)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@tmagic/schema': 1.8.0-beta.15(typescript@6.0.3)
|
'@tmagic/schema': 1.8.0-beta.19(typescript@6.0.3)
|
||||||
lodash-es: 4.18.1
|
lodash-es: 4.18.1
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
|
|
||||||
'@tmagic/vue-runtime-help@2.0.4(@tmagic/core@1.8.0-beta.15(typescript@6.0.3))(@tmagic/stage@1.8.0-beta.15(@tmagic/core@1.8.0-beta.15(typescript@6.0.3))(typescript@6.0.3))(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))':
|
'@tmagic/vue-runtime-help@2.0.4(@tmagic/core@1.8.0-beta.19(typescript@6.0.3))(@tmagic/stage@1.8.0-beta.19(@tmagic/core@1.8.0-beta.19(typescript@6.0.3))(typescript@6.0.3))(typescript@6.0.3)(vue@3.5.40(typescript@6.0.3))':
|
||||||
dependencies:
|
dependencies:
|
||||||
vue: 3.5.40(typescript@6.0.3)
|
vue: 3.5.40(typescript@6.0.3)
|
||||||
optionalDependencies:
|
optionalDependencies:
|
||||||
'@tmagic/core': 1.8.0-beta.15(typescript@6.0.3)
|
'@tmagic/core': 1.8.0-beta.19(typescript@6.0.3)
|
||||||
'@tmagic/stage': 1.8.0-beta.15(@tmagic/core@1.8.0-beta.15(typescript@6.0.3))(typescript@6.0.3)
|
'@tmagic/stage': 1.8.0-beta.19(@tmagic/core@1.8.0-beta.19(typescript@6.0.3))(typescript@6.0.3)
|
||||||
typescript: 6.0.3
|
typescript: 6.0.3
|
||||||
|
|
||||||
'@tybys/wasm-util@0.10.3':
|
'@tybys/wasm-util@0.10.3':
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "runtime-react",
|
"name": "runtime-react",
|
||||||
"version": "1.8.0-beta.15",
|
"version": "1.8.0-beta.19",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"private": true,
|
"private": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
@ -16,16 +16,16 @@
|
|||||||
"build:playground": "node scripts/build.mjs --type=playground"
|
"build:playground": "node scripts/build.mjs --type=playground"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tmagic/core": "1.8.0-beta.15",
|
"@tmagic/core": "1.8.0-beta.19",
|
||||||
"@tmagic/react-runtime-help": "0.2.2",
|
"@tmagic/react-runtime-help": "0.2.2",
|
||||||
"@tmagic/stage": "1.8.0-beta.15",
|
"@tmagic/stage": "1.8.0-beta.19",
|
||||||
"axios": "^1.13.2",
|
"axios": "^1.13.2",
|
||||||
"qrcode": "^1.5.0",
|
"qrcode": "^1.5.0",
|
||||||
"react": "^18.3.1",
|
"react": "^18.3.1",
|
||||||
"react-dom": "^18.3.1"
|
"react-dom": "^18.3.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tmagic/cli": "1.8.0-beta.15",
|
"@tmagic/cli": "1.8.0-beta.19",
|
||||||
"@types/fs-extra": "^11.0.4",
|
"@types/fs-extra": "^11.0.4",
|
||||||
"@types/react": "^18.3.3",
|
"@types/react": "^18.3.3",
|
||||||
"@types/react-dom": "^18.3.0",
|
"@types/react-dom": "^18.3.0",
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "runtime-vue",
|
"name": "runtime-vue",
|
||||||
"version": "1.8.0-beta.15",
|
"version": "1.8.0-beta.19",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"private": true,
|
"private": true,
|
||||||
"engines": {
|
"engines": {
|
||||||
@ -16,14 +16,14 @@
|
|||||||
"build:playground": "node scripts/build.mjs --type=playground"
|
"build:playground": "node scripts/build.mjs --type=playground"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@tmagic/core": "1.8.0-beta.15",
|
"@tmagic/core": "1.8.0-beta.19",
|
||||||
"@tmagic/stage": "1.8.0-beta.15",
|
"@tmagic/stage": "1.8.0-beta.19",
|
||||||
"@tmagic/vue-runtime-help": "^2.0.4",
|
"@tmagic/vue-runtime-help": "^2.0.4",
|
||||||
"axios": "^1.13.2",
|
"axios": "^1.13.2",
|
||||||
"vue": "catalog:"
|
"vue": "catalog:"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@tmagic/cli": "1.8.0-beta.15",
|
"@tmagic/cli": "1.8.0-beta.19",
|
||||||
"@types/fs-extra": "^11.0.4",
|
"@types/fs-extra": "^11.0.4",
|
||||||
"@types/node": "^24.0.10",
|
"@types/node": "^24.0.10",
|
||||||
"@vitejs/plugin-legacy": "^8.0.1",
|
"@vitejs/plugin-legacy": "^8.0.1",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user