devject-design 0.1.1 → 0.2.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/README.md +482 -127
- package/dist/core/builtin/advanced.d.ts +1 -0
- package/dist/core/builtin/basics.d.ts +1 -0
- package/dist/core/builtin/containers.d.ts +1 -0
- package/dist/core/builtin/editors.d.ts +1 -0
- package/dist/core/builtin/index.d.ts +1 -0
- package/dist/core/builtin/utils.d.ts +9 -0
- package/dist/core/editors.d.ts +17 -0
- package/dist/core/registry.d.ts +38 -0
- package/dist/index.d.ts +9 -1
- package/dist/index.es.js +11899 -2785
- package/dist/index.umd.js +39 -1
- package/dist/pages/FormDesigner.d.ts +16 -1
- package/dist/style.css +1 -1
- package/dist/ui/PaletteItem.d.ts +2 -0
- package/dist/ui/PreviewDialog.d.ts +42 -1
- package/dist/ui/components/Checkbox.d.ts +11 -0
- package/dist/ui/components/Collapse.d.ts +11 -0
- package/dist/ui/components/FileUpload.d.ts +11 -0
- package/dist/ui/components/FlexRow.d.ts +11 -0
- package/dist/ui/components/ImageUpload.d.ts +11 -0
- package/dist/ui/components/Input.d.ts +11 -0
- package/dist/ui/components/Radio.d.ts +11 -0
- package/dist/ui/components/Select.d.ts +11 -0
- package/dist/ui/components/StaticTable.d.ts +7 -0
- package/dist/ui/components/Switch.d.ts +11 -0
- package/dist/ui/components/Table.d.ts +11 -0
- package/dist/ui/components/Tabs.d.ts +11 -0
- package/dist/ui/components/Textarea.d.ts +11 -0
- package/dist/ui/components/Title.d.ts +7 -0
- package/dist/ui/components/Tree.d.ts +7 -0
- package/dist/ui/editors/CollapseEditor.d.ts +5 -0
- package/dist/ui/editors/ExcelIOEditor.d.ts +5 -0
- package/dist/ui/editors/FlexLayoutEditor.d.ts +5 -0
- package/dist/ui/editors/JsonDataEditor.d.ts +9 -0
- package/dist/ui/editors/OptionsEditor.d.ts +9 -0
- package/dist/ui/editors/TableColumnsEditor.d.ts +10 -0
- package/dist/ui/editors/TabsEditor.d.ts +5 -0
- package/dist/ui/hooks/useValidator.d.ts +4 -0
- package/dist/ui/preview/FormRenderer.d.ts +15 -2
- package/dist/ui/state/designerState.d.ts +30 -1405
- package/dist/ui/state/dragState.d.ts +11 -6
- package/dist/ui/state/injectionKeys.d.ts +4 -0
- package/dist/ui/state/schemaOps.d.ts +1 -3
- package/dist/ui/state/types.d.ts +29 -92
- package/dist/ui/state/useDragLogic.d.ts +10 -0
- package/dist/ui/state/useHotkeys.d.ts +4 -0
- package/dist/ui/state/validator.d.ts +36 -0
- package/package.json +7 -2
- package/dist/ui/state/history.d.ts +0 -8413
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
import { DragItem, DropTarget } from './types';
|
|
2
|
+
declare function begin(item: DragItem, ev: PointerEvent): void;
|
|
3
|
+
declare function move(ev: PointerEvent): void;
|
|
4
|
+
declare function setHover(target: DropTarget | null): void;
|
|
5
|
+
declare function end(): void;
|
|
2
6
|
export declare function useDragState(): {
|
|
3
7
|
dragging: import('vue').Ref<{
|
|
4
8
|
kind: "palette";
|
|
5
|
-
nodeType:
|
|
9
|
+
nodeType: string;
|
|
6
10
|
preset?: Record<string, unknown> | undefined;
|
|
7
11
|
} | {
|
|
8
12
|
kind: "node";
|
|
9
13
|
nodeId: string;
|
|
10
14
|
} | null, DragItem | {
|
|
11
15
|
kind: "palette";
|
|
12
|
-
nodeType:
|
|
16
|
+
nodeType: string;
|
|
13
17
|
preset?: Record<string, unknown> | undefined;
|
|
14
18
|
} | {
|
|
15
19
|
kind: "node";
|
|
@@ -57,8 +61,9 @@ export declare function useDragState(): {
|
|
|
57
61
|
y: number;
|
|
58
62
|
};
|
|
59
63
|
isDragging: import('vue').ComputedRef<boolean>;
|
|
60
|
-
begin:
|
|
61
|
-
move:
|
|
62
|
-
setHover:
|
|
63
|
-
end:
|
|
64
|
+
begin: typeof begin;
|
|
65
|
+
move: typeof move;
|
|
66
|
+
setHover: typeof setHover;
|
|
67
|
+
end: typeof end;
|
|
64
68
|
};
|
|
69
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { InjectionKey, Ref } from 'vue';
|
|
2
|
+
export declare const UPLOAD_URL_KEY: InjectionKey<Ref<string | undefined>>;
|
|
3
|
+
export declare const DOWNLOAD_URL_KEY: InjectionKey<Ref<string | undefined>>;
|
|
4
|
+
export declare const UPLOAD_PARSE_KEY: InjectionKey<Ref<string | undefined>>;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { DropTarget, LayoutSchema,
|
|
1
|
+
import { DropTarget, LayoutSchema, NodeType, SchemaNode } from './types';
|
|
2
2
|
export declare function createEmptySchema(): LayoutSchema;
|
|
3
|
-
export declare function createNodeMeta(): NodeMeta;
|
|
4
3
|
export declare function deepClone<T>(value: T): T;
|
|
5
4
|
export declare function createNode(nodeType: NodeType): SchemaNode;
|
|
6
5
|
export type NodeLocation = {
|
|
@@ -30,7 +29,6 @@ export declare function removeNode(schema: LayoutSchema, nodeId: string): Schema
|
|
|
30
29
|
export declare function insertNode(schema: LayoutSchema, target: DropTarget, node: SchemaNode): void;
|
|
31
30
|
export declare function moveNode(schema: LayoutSchema, nodeId: string, target: DropTarget): void;
|
|
32
31
|
export declare function getListByDropTarget(schema: LayoutSchema, target: DropTarget): SchemaNode[];
|
|
33
|
-
export declare function canDrop(schema: LayoutSchema, dragKind: "palette" | "node", nodeType: NodeType, target: DropTarget): boolean;
|
|
34
32
|
export declare function normalizeSchema(input: unknown): LayoutSchema;
|
|
35
33
|
export type ExportLayoutSchema = LayoutSchema;
|
|
36
34
|
export declare function exportLayout(schema: LayoutSchema): ExportLayoutSchema;
|
package/dist/ui/state/types.d.ts
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
|
-
export type NodeType =
|
|
1
|
+
export type NodeType = string;
|
|
2
2
|
export type DeviceMode = "pc" | "mobile";
|
|
3
|
-
export type NodeMeta = {
|
|
4
|
-
createdAt: string;
|
|
5
|
-
updatedAt: string;
|
|
6
|
-
style: Record<string, unknown>;
|
|
7
|
-
};
|
|
8
3
|
export type DragItem = {
|
|
9
4
|
kind: "palette";
|
|
10
|
-
nodeType:
|
|
5
|
+
nodeType: string;
|
|
11
6
|
preset?: Record<string, unknown>;
|
|
12
7
|
} | {
|
|
13
8
|
kind: "node";
|
|
@@ -32,80 +27,6 @@ export type DropTarget = {
|
|
|
32
27
|
tabId: string;
|
|
33
28
|
insertIndex: number;
|
|
34
29
|
};
|
|
35
|
-
export type FieldNode = {
|
|
36
|
-
id: string;
|
|
37
|
-
type: Exclude<NodeType, "flexRow" | "collapse" | "tabs" | "table" | "title">;
|
|
38
|
-
meta: NodeMeta;
|
|
39
|
-
props: {
|
|
40
|
-
label: string;
|
|
41
|
-
field: string;
|
|
42
|
-
placeholder?: string;
|
|
43
|
-
required?: boolean;
|
|
44
|
-
options?: Array<{
|
|
45
|
-
label: string;
|
|
46
|
-
value: string;
|
|
47
|
-
}>;
|
|
48
|
-
multiple?: boolean;
|
|
49
|
-
inputType?: "text" | "number" | "date" | "time" | "datetime";
|
|
50
|
-
accept?: string;
|
|
51
|
-
limit?: number;
|
|
52
|
-
activeText?: string;
|
|
53
|
-
inactiveText?: string;
|
|
54
|
-
activeValue?: any;
|
|
55
|
-
inactiveValue?: any;
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
export type TitleNode = {
|
|
59
|
-
id: string;
|
|
60
|
-
type: "title";
|
|
61
|
-
meta: NodeMeta;
|
|
62
|
-
props: {
|
|
63
|
-
label: string;
|
|
64
|
-
fontSize?: number;
|
|
65
|
-
bold?: boolean;
|
|
66
|
-
align?: "left" | "center" | "right";
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
export type FlexRowNode = {
|
|
70
|
-
id: string;
|
|
71
|
-
type: "flexRow";
|
|
72
|
-
meta: NodeMeta;
|
|
73
|
-
props: {
|
|
74
|
-
cols: 1 | 2 | 3 | 4;
|
|
75
|
-
gap?: number;
|
|
76
|
-
};
|
|
77
|
-
columns: Array<{
|
|
78
|
-
id: string;
|
|
79
|
-
children: SchemaNode[];
|
|
80
|
-
}>;
|
|
81
|
-
};
|
|
82
|
-
export type CollapseNode = {
|
|
83
|
-
id: string;
|
|
84
|
-
type: "collapse";
|
|
85
|
-
meta: NodeMeta;
|
|
86
|
-
props: {
|
|
87
|
-
accordion: boolean;
|
|
88
|
-
};
|
|
89
|
-
items: Array<{
|
|
90
|
-
id: string;
|
|
91
|
-
title: string;
|
|
92
|
-
name: string;
|
|
93
|
-
children: SchemaNode[];
|
|
94
|
-
}>;
|
|
95
|
-
};
|
|
96
|
-
export type TabsNode = {
|
|
97
|
-
id: string;
|
|
98
|
-
type: "tabs";
|
|
99
|
-
meta: NodeMeta;
|
|
100
|
-
props: {
|
|
101
|
-
type: "card" | "border-card";
|
|
102
|
-
};
|
|
103
|
-
tabs: Array<{
|
|
104
|
-
id: string;
|
|
105
|
-
label: string;
|
|
106
|
-
children: SchemaNode[];
|
|
107
|
-
}>;
|
|
108
|
-
};
|
|
109
30
|
export type TableColumn = {
|
|
110
31
|
id: string;
|
|
111
32
|
label: string;
|
|
@@ -124,20 +45,36 @@ export type TableColumn = {
|
|
|
124
45
|
filterable?: boolean;
|
|
125
46
|
sortable?: boolean;
|
|
126
47
|
};
|
|
127
|
-
export type
|
|
48
|
+
export type SchemaNode = {
|
|
128
49
|
id: string;
|
|
129
|
-
type:
|
|
130
|
-
|
|
131
|
-
|
|
50
|
+
type: string;
|
|
51
|
+
props: Record<string, any>;
|
|
52
|
+
children?: SchemaNode[];
|
|
53
|
+
columns?: Array<{
|
|
54
|
+
id: string;
|
|
55
|
+
width?: number;
|
|
56
|
+
widthType?: 'fr' | 'px';
|
|
57
|
+
children: SchemaNode[];
|
|
58
|
+
}>;
|
|
59
|
+
items?: Array<{
|
|
60
|
+
id: string;
|
|
61
|
+
title: string;
|
|
62
|
+
name: string;
|
|
63
|
+
children: SchemaNode[];
|
|
64
|
+
}>;
|
|
65
|
+
tabs?: Array<{
|
|
66
|
+
id: string;
|
|
132
67
|
label: string;
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
pagination: boolean;
|
|
136
|
-
pageSize: number;
|
|
137
|
-
enableExcelImport: boolean;
|
|
138
|
-
};
|
|
68
|
+
children: SchemaNode[];
|
|
69
|
+
}>;
|
|
139
70
|
};
|
|
140
|
-
export type
|
|
71
|
+
export type FieldNode = SchemaNode;
|
|
72
|
+
export type FlexRowNode = SchemaNode;
|
|
73
|
+
export type CollapseNode = SchemaNode;
|
|
74
|
+
export type TabsNode = SchemaNode;
|
|
75
|
+
export type TableNode = SchemaNode;
|
|
76
|
+
export type TitleNode = SchemaNode;
|
|
77
|
+
export type CustomNode = SchemaNode;
|
|
141
78
|
export type LayoutSchema = {
|
|
142
79
|
version: 1;
|
|
143
80
|
root: {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Ref } from 'vue';
|
|
2
|
+
import { DropTarget, LayoutSchema, SchemaNode, NodeType } from './types';
|
|
3
|
+
export declare function useDragLogic(schemaState: Ref<LayoutSchema>, selection: {
|
|
4
|
+
selectedNodeId: Ref<string | null>;
|
|
5
|
+
}, commit: (next: LayoutSchema) => void): {
|
|
6
|
+
beginPaletteDrag: (nodeType: NodeType, ev: PointerEvent) => void;
|
|
7
|
+
beginNodeDrag: (nodeId: string, ev: PointerEvent) => void;
|
|
8
|
+
setHover: (target: DropTarget | null) => void;
|
|
9
|
+
findTypeById: (schema: LayoutSchema, nodeId: string) => SchemaNode | null;
|
|
10
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { LayoutSchema, FormDataModel } from './types';
|
|
3
|
+
declare const baseNodeSchema: z.ZodObject<{
|
|
4
|
+
id: z.ZodString;
|
|
5
|
+
type: z.ZodString;
|
|
6
|
+
props: z.ZodDefault<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
|
|
7
|
+
}, z.core.$strip>;
|
|
8
|
+
export type ZodSchemaNode = z.infer<typeof baseNodeSchema> & {
|
|
9
|
+
children?: ZodSchemaNode[];
|
|
10
|
+
columns?: {
|
|
11
|
+
id: string;
|
|
12
|
+
children: ZodSchemaNode[];
|
|
13
|
+
width?: number;
|
|
14
|
+
widthType?: string;
|
|
15
|
+
}[];
|
|
16
|
+
items?: {
|
|
17
|
+
id: string;
|
|
18
|
+
title: string;
|
|
19
|
+
name: string;
|
|
20
|
+
children: ZodSchemaNode[];
|
|
21
|
+
}[];
|
|
22
|
+
tabs?: {
|
|
23
|
+
id: string;
|
|
24
|
+
label: string;
|
|
25
|
+
children: ZodSchemaNode[];
|
|
26
|
+
}[];
|
|
27
|
+
};
|
|
28
|
+
export declare const schemaNodeSchema: z.ZodType<ZodSchemaNode>;
|
|
29
|
+
export declare const layoutSchemaValidator: z.ZodObject<{
|
|
30
|
+
version: z.ZodDefault<z.ZodNumber>;
|
|
31
|
+
root: z.ZodType<ZodSchemaNode, unknown, z.core.$ZodTypeInternals<ZodSchemaNode, unknown>>;
|
|
32
|
+
}, z.core.$strip>;
|
|
33
|
+
export declare const formDataValidator: z.ZodRecord<z.ZodString, z.ZodUnknown>;
|
|
34
|
+
export declare function validateLayout(data: unknown): LayoutSchema;
|
|
35
|
+
export declare function validateFormData(data: unknown): FormDataModel;
|
|
36
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "devject-design",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist"
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"import": "./dist/index.es.js",
|
|
15
15
|
"require": "./dist/index.umd.js"
|
|
16
16
|
},
|
|
17
|
-
"./style.css": "./dist/style.css"
|
|
17
|
+
"./dist/style.css": "./dist/style.css"
|
|
18
18
|
},
|
|
19
19
|
"scripts": {
|
|
20
20
|
"dev": "vite",
|
|
@@ -37,5 +37,10 @@
|
|
|
37
37
|
"vue": "^3.5.13",
|
|
38
38
|
"vue-tsc": "^2.2.0",
|
|
39
39
|
"xlsx": "^0.18.5"
|
|
40
|
+
},
|
|
41
|
+
"dependencies": {
|
|
42
|
+
"@element-plus/icons-vue": "^2.3.2",
|
|
43
|
+
"immer": "^11.1.3",
|
|
44
|
+
"zod": "^4.3.6"
|
|
40
45
|
}
|
|
41
46
|
}
|