@tmagic/editor 1.3.0-alpha.19 → 1.3.0-alpha.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tmagic-editor.js +3717 -3646
- package/dist/tmagic-editor.js.map +1 -1
- package/dist/tmagic-editor.umd.cjs +3715 -3642
- package/dist/tmagic-editor.umd.cjs.map +1 -1
- package/package.json +10 -10
- package/src/components/CodeParams.vue +2 -1
- package/src/editorProps.ts +30 -3
- package/src/fields/DataSourceInput.vue +8 -45
- package/src/initService.ts +33 -0
- package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +11 -1
- package/src/services/dataSource.ts +15 -2
- package/src/services/editor.ts +2 -2
- package/src/services/props.ts +2 -2
- package/src/type.ts +6 -1
- package/src/utils/data-source/formConfigs/base.ts +35 -30
- package/src/utils/data-source/index.ts +64 -6
- package/src/utils/index.ts +1 -0
- package/src/utils/undo-redo.ts +1 -1
- package/types/Editor.vue.d.ts +30 -3
- package/types/editorProps.d.ts +19 -3
- package/types/initService.d.ts +1 -1
- package/types/services/dataSource.d.ts +6 -1
- package/types/services/props.d.ts +2 -2
- package/types/type.d.ts +5 -1
- package/types/utils/data-source/formConfigs/base.d.ts +2 -2
- package/types/utils/data-source/index.d.ts +7 -1
- package/types/utils/index.d.ts +1 -0
package/types/editorProps.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { PropType } from 'vue';
|
|
2
2
|
import type { EventOption } from '@tmagic/core';
|
|
3
3
|
import type { FormConfig, FormState } from '@tmagic/form';
|
|
4
|
-
import type { MApp, MNode } from '@tmagic/schema';
|
|
4
|
+
import type { DataSourceSchema, MApp, MNode } from '@tmagic/schema';
|
|
5
5
|
import StageCore, { ContainerHighlightType, CustomizeMoveableOptionsCallbackConfig, MoveableOptions, UpdateDragEl } from '@tmagic/stage';
|
|
6
|
-
import type { ComponentGroup, MenuBarData, MenuButton, MenuComponent, SideBarData, StageRect } from './type';
|
|
6
|
+
import type { ComponentGroup, DatasourceTypeOption, MenuBarData, MenuButton, MenuComponent, SideBarData, StageRect } from './type';
|
|
7
7
|
declare const _default: {
|
|
8
8
|
/** 页面初始值 */
|
|
9
9
|
modelValue: {
|
|
@@ -16,6 +16,11 @@ declare const _default: {
|
|
|
16
16
|
type: PropType<ComponentGroup[]>;
|
|
17
17
|
default: () => never[];
|
|
18
18
|
};
|
|
19
|
+
/** 左侧面板中的组件列表 */
|
|
20
|
+
datasourceList: {
|
|
21
|
+
type: PropType<DatasourceTypeOption[]>;
|
|
22
|
+
default: () => never[];
|
|
23
|
+
};
|
|
19
24
|
/** 左侧面板配置 */
|
|
20
25
|
sidebar: {
|
|
21
26
|
type: PropType<SideBarData>;
|
|
@@ -53,7 +58,7 @@ declare const _default: {
|
|
|
53
58
|
};
|
|
54
59
|
/** 添加组件时的默认值 */
|
|
55
60
|
propsValues: {
|
|
56
|
-
type: PropType<Record<string, MNode
|
|
61
|
+
type: PropType<Record<string, Partial<MNode>>>;
|
|
57
62
|
default: () => {};
|
|
58
63
|
};
|
|
59
64
|
/** 组件联动事件选项列表 */
|
|
@@ -64,6 +69,17 @@ declare const _default: {
|
|
|
64
69
|
}>>;
|
|
65
70
|
default: () => {};
|
|
66
71
|
};
|
|
72
|
+
/** 组件的属性配置表单的dsl */
|
|
73
|
+
datasourceConfigs: {
|
|
74
|
+
type: PropType<Record<string, FormConfig>>;
|
|
75
|
+
default: () => {};
|
|
76
|
+
};
|
|
77
|
+
/** 添加数据源时的默认值 */
|
|
78
|
+
datasourceValues: {
|
|
79
|
+
type: PropType<Record<string, Partial<DataSourceSchema>>>;
|
|
80
|
+
default: () => {};
|
|
81
|
+
};
|
|
82
|
+
/** 数据源的属性配置表单的dsl */
|
|
67
83
|
dataScourceConfigs: {
|
|
68
84
|
type: PropType<Record<string, FormConfig>>;
|
|
69
85
|
default: () => {};
|
package/types/initService.d.ts
CHANGED
|
@@ -4,5 +4,5 @@ import { Services } from './type';
|
|
|
4
4
|
export declare type LooseRequired<T> = {
|
|
5
5
|
[P in string & keyof T]: T[P];
|
|
6
6
|
};
|
|
7
|
-
export declare const initServiceState: (props: Readonly<LooseRequired<Readonly<ExtractPropTypes<typeof editorProps>>>>, { editorService, historyService, componentListService, propsService, eventsService, uiService, codeBlockService, keybindingService, }: Services) => void;
|
|
7
|
+
export declare const initServiceState: (props: Readonly<LooseRequired<Readonly<ExtractPropTypes<typeof editorProps>>>>, { editorService, historyService, componentListService, propsService, eventsService, uiService, codeBlockService, keybindingService, dataSourceService, }: Services) => void;
|
|
8
8
|
export declare const initServiceEvents: (props: Readonly<LooseRequired<Readonly<ExtractPropTypes<typeof editorProps>>>>, emit: (event: 'props-panel-mounted' | 'update:modelValue', ...args: any[]) => void, { editorService, codeBlockService, dataSourceService, depService }: Services) => void;
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import type { FormConfig } from '@tmagic/form';
|
|
2
|
-
import { DataSourceSchema } from '@tmagic/schema';
|
|
2
|
+
import type { DataSourceSchema } from '@tmagic/schema';
|
|
3
|
+
import type { DatasourceTypeOption } from '../type';
|
|
3
4
|
import BaseService from './BaseService';
|
|
4
5
|
interface State {
|
|
6
|
+
datasourceTypeList: DatasourceTypeOption[];
|
|
5
7
|
dataSources: DataSourceSchema[];
|
|
6
8
|
editable: boolean;
|
|
7
9
|
configs: Record<string, FormConfig>;
|
|
10
|
+
values: Record<string, Partial<DataSourceSchema>>;
|
|
8
11
|
}
|
|
9
12
|
type StateKey = keyof State;
|
|
10
13
|
declare class DataSource extends BaseService {
|
|
@@ -13,6 +16,8 @@ declare class DataSource extends BaseService {
|
|
|
13
16
|
get<K extends StateKey>(name: K): State[K];
|
|
14
17
|
getFormConfig(type?: string): FormConfig;
|
|
15
18
|
setFormConfig(type: string, config: FormConfig): void;
|
|
19
|
+
getFormValue(type?: string): Partial<DataSourceSchema>;
|
|
20
|
+
setFormValue(type: string, value: Partial<DataSourceSchema>): void;
|
|
16
21
|
add(config: DataSourceSchema): void;
|
|
17
22
|
update(config: DataSourceSchema): void;
|
|
18
23
|
remove(id: string): void;
|
|
@@ -29,13 +29,13 @@ declare class Props extends BaseService {
|
|
|
29
29
|
* @returns 组件属性表单配置
|
|
30
30
|
*/
|
|
31
31
|
getPropsConfig(type: string): Promise<FormConfig>;
|
|
32
|
-
setPropsValues(values: Record<string, MNode
|
|
32
|
+
setPropsValues(values: Record<string, Partial<MNode>>): void;
|
|
33
33
|
/**
|
|
34
34
|
* 为指点类型组件设置组件初始值
|
|
35
35
|
* @param type 组件类型
|
|
36
36
|
* @param value 组件初始值
|
|
37
37
|
*/
|
|
38
|
-
setPropsValue(type: string, value: MNode): Promise<void>;
|
|
38
|
+
setPropsValue(type: string, value: Partial<MNode>): Promise<void>;
|
|
39
39
|
/**
|
|
40
40
|
* 获取指定类型的组件初始值
|
|
41
41
|
* @param type 组件类型
|
package/types/type.d.ts
CHANGED
|
@@ -61,7 +61,7 @@ export interface StoreState {
|
|
|
61
61
|
export type StoreStateKey = keyof StoreState;
|
|
62
62
|
export interface PropsState {
|
|
63
63
|
propsConfigMap: Record<string, FormConfig>;
|
|
64
|
-
propsValueMap: Record<string, MNode
|
|
64
|
+
propsValueMap: Record<string, Partial<MNode>>;
|
|
65
65
|
}
|
|
66
66
|
export interface ComponentGroupState {
|
|
67
67
|
list: ComponentGroup[];
|
|
@@ -430,3 +430,7 @@ export declare enum DepTargetType {
|
|
|
430
430
|
/** 数据源条件 */
|
|
431
431
|
DATA_SOURCE_COND = "data-source-cond"
|
|
432
432
|
}
|
|
433
|
+
export interface DatasourceTypeOption {
|
|
434
|
+
type: string;
|
|
435
|
+
text: string;
|
|
436
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { FormConfig } from '@tmagic/form';
|
|
2
|
-
|
|
3
|
-
export default
|
|
2
|
+
import type { DatasourceTypeOption } from '../../../type';
|
|
3
|
+
export default function (datasourceTypeList?: DatasourceTypeOption[]): FormConfig;
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
import { FormConfig } from '@tmagic/form';
|
|
2
|
-
|
|
2
|
+
import { DataSourceSchema } from '@tmagic/schema';
|
|
3
|
+
import { DatasourceTypeOption } from '../../type';
|
|
4
|
+
export declare const getFormConfig: (type: string, datasourceTypeList: DatasourceTypeOption[], configs: Record<string, FormConfig>) => FormConfig;
|
|
5
|
+
export declare const getDisplayField: (dataSources: DataSourceSchema[], key: string) => {
|
|
6
|
+
value: string;
|
|
7
|
+
type: 'var' | 'text';
|
|
8
|
+
}[];
|
package/types/utils/index.d.ts
CHANGED