@tmagic/editor 1.2.15 → 1.3.0-alpha.1
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/style.css +32 -0
- package/dist/tmagic-editor.js +949 -185
- package/dist/tmagic-editor.js.map +1 -1
- package/dist/tmagic-editor.umd.cjs +960 -194
- package/dist/tmagic-editor.umd.cjs.map +1 -1
- package/package.json +10 -9
- package/src/Editor.vue +2 -0
- package/src/components/CodeDraftEditor.vue +2 -2
- package/src/editorProps.ts +5 -0
- package/src/fields/CodeSelect.vue +1 -0
- package/src/fields/DataSourceFields.vue +178 -0
- package/src/fields/EventSelect.vue +1 -0
- package/src/fields/KeyValue.vue +93 -0
- package/src/index.ts +7 -0
- package/src/initService.ts +59 -3
- package/src/layouts/sidebar/LayerPanel.vue +2 -0
- package/src/layouts/sidebar/Sidebar.vue +14 -5
- package/src/layouts/sidebar/code-block/CodeBlockList.vue +7 -0
- package/src/layouts/sidebar/data-source/DataSourceConfigPanel.vue +84 -0
- package/src/layouts/sidebar/data-source/DataSourceListPanel.vue +130 -0
- package/src/services/codeBlock.ts +0 -2
- package/src/services/dataSource.ts +90 -0
- package/src/theme/data-source-fields.scss +13 -0
- package/src/theme/data-source.scss +17 -0
- package/src/theme/key-value.scss +13 -0
- package/src/theme/theme.scss +3 -0
- package/src/type.ts +3 -1
- package/src/utils/data-source/formConfigs/base.ts +32 -0
- package/src/utils/data-source/formConfigs/http.ts +50 -0
- package/src/utils/data-source/index.ts +31 -0
- package/src/utils/dep.ts +9 -1
- package/src/utils/props.ts +1 -0
- package/types/Editor.vue.d.ts +9 -0
- package/types/components/ContentMenu.vue.d.ts +2 -2
- package/types/components/ScrollViewer.vue.d.ts +1 -1
- package/types/editorProps.d.ts +4 -0
- package/types/fields/DataSourceFields.vue.d.ts +40 -0
- package/types/fields/KeyValue.vue.d.ts +50 -0
- package/types/index.d.ts +3 -0
- package/types/initService.d.ts +1 -1
- package/types/layouts/CodeEditor.vue.d.ts +1 -1
- package/types/layouts/sidebar/Sidebar.vue.d.ts +2 -2
- package/types/layouts/sidebar/data-source/DataSourceConfigPanel.vue.d.ts +22 -0
- package/types/layouts/sidebar/data-source/DataSourceListPanel.vue.d.ts +12 -0
- package/types/services/dataSource.d.ts +25 -0
- package/types/services/props.d.ts +2 -3
- package/types/type.d.ts +3 -1
- package/types/utils/data-source/formConfigs/base.d.ts +3 -0
- package/types/utils/data-source/formConfigs/http.d.ts +3 -0
- package/types/utils/data-source/index.d.ts +2 -0
- package/types/utils/dep.d.ts +2 -1
- package/types/utils/props.d.ts +2 -3
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
2
|
+
config: {
|
|
3
|
+
type: 'key-value';
|
|
4
|
+
name: string;
|
|
5
|
+
text: string;
|
|
6
|
+
};
|
|
7
|
+
model: Record<string, any>;
|
|
8
|
+
name: string;
|
|
9
|
+
prop: string;
|
|
10
|
+
disabled: boolean;
|
|
11
|
+
lastValues?: Record<string, any> | undefined;
|
|
12
|
+
size?: "default" | "small" | "large" | undefined;
|
|
13
|
+
}>, {
|
|
14
|
+
disabled: boolean;
|
|
15
|
+
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
16
|
+
change: (value: Record<string, any>) => void;
|
|
17
|
+
}, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
18
|
+
config: {
|
|
19
|
+
type: 'key-value';
|
|
20
|
+
name: string;
|
|
21
|
+
text: string;
|
|
22
|
+
};
|
|
23
|
+
model: Record<string, any>;
|
|
24
|
+
name: string;
|
|
25
|
+
prop: string;
|
|
26
|
+
disabled: boolean;
|
|
27
|
+
lastValues?: Record<string, any> | undefined;
|
|
28
|
+
size?: "default" | "small" | "large" | undefined;
|
|
29
|
+
}>, {
|
|
30
|
+
disabled: boolean;
|
|
31
|
+
}>>> & {
|
|
32
|
+
onChange?: ((value: Record<string, any>) => any) | undefined;
|
|
33
|
+
}, {
|
|
34
|
+
disabled: boolean;
|
|
35
|
+
}>;
|
|
36
|
+
export default _default;
|
|
37
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
38
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
39
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
40
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
41
|
+
} : {
|
|
42
|
+
type: import('vue').PropType<T[K]>;
|
|
43
|
+
required: true;
|
|
44
|
+
};
|
|
45
|
+
};
|
|
46
|
+
type __VLS_WithDefaults<P, D> = {
|
|
47
|
+
[K in keyof Pick<P, keyof P>]: K extends keyof D ? P[K] & {
|
|
48
|
+
default: D[K];
|
|
49
|
+
} : P[K];
|
|
50
|
+
};
|
package/types/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ export { default as propsService } from './services/props';
|
|
|
11
11
|
export { default as historyService } from './services/history';
|
|
12
12
|
export { default as storageService } from './services/storage';
|
|
13
13
|
export { default as eventsService } from './services/events';
|
|
14
|
+
export { default as dataSourceService } from './services/dataSource';
|
|
14
15
|
export { default as uiService } from './services/ui';
|
|
15
16
|
export { default as codeBlockService } from './services/codeBlock';
|
|
16
17
|
export { default as depService } from './services/dep';
|
|
@@ -18,7 +19,9 @@ export { default as ComponentListPanel } from './layouts/sidebar/ComponentListPa
|
|
|
18
19
|
export { default as LayerPanel } from './layouts/sidebar/LayerPanel.vue';
|
|
19
20
|
export { default as CodeSelect } from './fields/CodeSelect.vue';
|
|
20
21
|
export { default as CodeSelectCol } from './fields/CodeSelectCol.vue';
|
|
22
|
+
export { default as DataSourceFields } from './fields/DataSourceFields.vue';
|
|
21
23
|
export { default as EventSelect } from './fields/EventSelect.vue';
|
|
24
|
+
export { default as KeyValue } from './fields/KeyValue.vue';
|
|
22
25
|
export { default as CodeBlockList } from './layouts/sidebar/code-block/CodeBlockList.vue';
|
|
23
26
|
export { default as PropsPanel } from './layouts/PropsPanel.vue';
|
|
24
27
|
export { default as ToolButton } from './components/ToolButton.vue';
|
package/types/initService.d.ts
CHANGED
|
@@ -5,4 +5,4 @@ export declare type LooseRequired<T> = {
|
|
|
5
5
|
[P in string & keyof T]: T[P];
|
|
6
6
|
};
|
|
7
7
|
export declare const initServiceState: (props: Readonly<LooseRequired<Readonly<ExtractPropTypes<typeof editorProps>>>>, { editorService, historyService, componentListService, propsService, eventsService, uiService, codeBlockService, }: Services) => void;
|
|
8
|
-
export declare const initServiceEvents: (props: Readonly<LooseRequired<Readonly<ExtractPropTypes<typeof editorProps>>>>, emit: (event: 'props-panel-mounted' | 'update:modelValue', ...args: any[]) => void, { editorService, codeBlockService, depService }: Services) => void;
|
|
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;
|
|
@@ -37,10 +37,10 @@ declare const _default: import("vue").DefineComponent<__VLS_WithDefaults<__VLS_T
|
|
|
37
37
|
onSave?: ((...args: any[]) => any) | undefined;
|
|
38
38
|
onInitd?: ((...args: any[]) => any) | undefined;
|
|
39
39
|
}, {
|
|
40
|
-
language: string;
|
|
41
40
|
options: {
|
|
42
41
|
[key: string]: any;
|
|
43
42
|
};
|
|
43
|
+
language: string;
|
|
44
44
|
autoSave: boolean;
|
|
45
45
|
}>;
|
|
46
46
|
export default _default;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { MenuButton, MenuComponent } from '../../type';
|
|
2
2
|
import { SideBarData } from '../../type';
|
|
3
3
|
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
4
|
-
data
|
|
4
|
+
data: SideBarData;
|
|
5
5
|
layerContentMenu: (MenuButton | MenuComponent)[];
|
|
6
6
|
}>, {
|
|
7
7
|
data: () => {
|
|
@@ -12,7 +12,7 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
12
12
|
}>, {
|
|
13
13
|
activeTabName: import("vue").Ref<string>;
|
|
14
14
|
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, Record<string, any>, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
15
|
-
data
|
|
15
|
+
data: SideBarData;
|
|
16
16
|
layerContentMenu: (MenuButton | MenuComponent)[];
|
|
17
17
|
}>, {
|
|
18
18
|
data: () => {
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
declare const _default: import("vue").DefineComponent<__VLS_TypePropsToRuntimeProps<{
|
|
2
|
+
title?: string | undefined;
|
|
3
|
+
values: any;
|
|
4
|
+
}>, {
|
|
5
|
+
show(): void;
|
|
6
|
+
hide: () => void;
|
|
7
|
+
}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, "submit"[], "submit", import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<__VLS_TypePropsToRuntimeProps<{
|
|
8
|
+
title?: string | undefined;
|
|
9
|
+
values: any;
|
|
10
|
+
}>>> & {
|
|
11
|
+
onSubmit?: ((...args: any[]) => any) | undefined;
|
|
12
|
+
}, {}>;
|
|
13
|
+
export default _default;
|
|
14
|
+
type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
|
|
15
|
+
type __VLS_TypePropsToRuntimeProps<T> = {
|
|
16
|
+
[K in keyof T]-?: {} extends Pick<T, K> ? {
|
|
17
|
+
type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
|
|
18
|
+
} : {
|
|
19
|
+
type: import('vue').PropType<T[K]>;
|
|
20
|
+
required: true;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, import("vue").EmitsOptions, string, import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, Readonly<import("vue").ExtractPropTypes<{}>>, {}>, {
|
|
2
|
+
'data-source-panel-tool': (_: {
|
|
3
|
+
id: any;
|
|
4
|
+
data: any;
|
|
5
|
+
}) => any;
|
|
6
|
+
}>;
|
|
7
|
+
export default _default;
|
|
8
|
+
type __VLS_WithTemplateSlots<T, S> = T & {
|
|
9
|
+
new (): {
|
|
10
|
+
$slots: S;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { FormConfig } from '@tmagic/form';
|
|
2
|
+
import { DataSourceSchema } from '@tmagic/schema';
|
|
3
|
+
import BaseService from './BaseService';
|
|
4
|
+
interface State {
|
|
5
|
+
dataSources: DataSourceSchema[];
|
|
6
|
+
configs: Record<string, FormConfig>;
|
|
7
|
+
}
|
|
8
|
+
type StateKey = keyof State;
|
|
9
|
+
declare class DataSource extends BaseService {
|
|
10
|
+
private state;
|
|
11
|
+
set<K extends StateKey, T extends State[K]>(name: K, value: T): void;
|
|
12
|
+
get<K extends StateKey>(name: K): State[K];
|
|
13
|
+
getFormConfig(type?: string): FormConfig;
|
|
14
|
+
setFormConfig(type: string, config: FormConfig): void;
|
|
15
|
+
add(config: DataSourceSchema): void;
|
|
16
|
+
update(config: DataSourceSchema): void;
|
|
17
|
+
remove(id: string): void;
|
|
18
|
+
getDataSourceById(id: string): DataSourceSchema | undefined;
|
|
19
|
+
resetState(): void;
|
|
20
|
+
destroy(): void;
|
|
21
|
+
private createId;
|
|
22
|
+
}
|
|
23
|
+
export type DataSourceService = DataSource;
|
|
24
|
+
declare const _default: DataSource;
|
|
25
|
+
export default _default;
|
|
@@ -10,9 +10,7 @@ declare class Props extends BaseService {
|
|
|
10
10
|
items: ({
|
|
11
11
|
title: string;
|
|
12
12
|
labelWidth: string;
|
|
13
|
-
items:
|
|
14
|
-
[key: string]: any;
|
|
15
|
-
})[];
|
|
13
|
+
items: import("@tmagic/form").ChildConfig[];
|
|
16
14
|
lazy?: undefined;
|
|
17
15
|
} | {
|
|
18
16
|
title: string;
|
|
@@ -108,6 +106,7 @@ declare class Props extends BaseService {
|
|
|
108
106
|
items: {
|
|
109
107
|
name: string;
|
|
110
108
|
type: string;
|
|
109
|
+
labelWidth: number;
|
|
111
110
|
}[];
|
|
112
111
|
labelWidth?: undefined;
|
|
113
112
|
lazy?: undefined;
|
package/types/type.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import type StageCore from '@tmagic/stage';
|
|
|
5
5
|
import type { ContainerHighlightType, CustomizeMoveableOptionsCallbackConfig, MoveableOptions, UpdateDragEl } from '@tmagic/stage';
|
|
6
6
|
import type { CodeBlockService } from './services/codeBlock';
|
|
7
7
|
import type { ComponentListService } from './services/componentList';
|
|
8
|
+
import { DataSourceService } from './services/dataSource';
|
|
8
9
|
import type { DepService } from './services/dep';
|
|
9
10
|
import type { EditorService } from './services/editor';
|
|
10
11
|
import type { EventsService } from './services/events';
|
|
@@ -28,6 +29,7 @@ export interface Services {
|
|
|
28
29
|
uiService: UiService;
|
|
29
30
|
codeBlockService: CodeBlockService;
|
|
30
31
|
depService: DepService;
|
|
32
|
+
dataSourceService: DataSourceService;
|
|
31
33
|
}
|
|
32
34
|
export interface StageOptions {
|
|
33
35
|
runtimeUrl: string;
|
|
@@ -203,7 +205,7 @@ export interface SideComponent extends MenuComponent {
|
|
|
203
205
|
* layer: 已选组件树
|
|
204
206
|
* code-block: 代码块
|
|
205
207
|
*/
|
|
206
|
-
export type SideItem = 'component-list' | 'layer' | 'code-block' | SideComponent;
|
|
208
|
+
export type SideItem = 'component-list' | 'layer' | 'code-block' | 'data-source' | SideComponent;
|
|
207
209
|
/** 工具栏 */
|
|
208
210
|
export interface SideBarData {
|
|
209
211
|
/** 容器类型 */
|
package/types/utils/dep.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import { CodeBlockContent, Id } from '@tmagic/schema';
|
|
1
|
+
import { CodeBlockContent, DataSourceSchema, Id } from '@tmagic/schema';
|
|
2
2
|
import { Target } from '../services/dep';
|
|
3
3
|
export declare const createCodeBlockTarget: (id: Id, codeBlock: CodeBlockContent) => Target;
|
|
4
|
+
export declare const createDataSourceTarget: (id: Id, ds: DataSourceSchema) => Target;
|
package/types/utils/props.d.ts
CHANGED
|
@@ -9,9 +9,7 @@ export declare const fillConfig: (config?: FormConfig) => {
|
|
|
9
9
|
items: ({
|
|
10
10
|
title: string;
|
|
11
11
|
labelWidth: string;
|
|
12
|
-
items:
|
|
13
|
-
[key: string]: any;
|
|
14
|
-
})[];
|
|
12
|
+
items: import("@tmagic/form").ChildConfig[];
|
|
15
13
|
lazy?: undefined;
|
|
16
14
|
} | {
|
|
17
15
|
title: string;
|
|
@@ -95,6 +93,7 @@ export declare const fillConfig: (config?: FormConfig) => {
|
|
|
95
93
|
items: {
|
|
96
94
|
name: string;
|
|
97
95
|
type: string;
|
|
96
|
+
labelWidth: number;
|
|
98
97
|
}[];
|
|
99
98
|
labelWidth?: undefined;
|
|
100
99
|
lazy?: undefined;
|