@jxyszb/jxy-form-designer 0.1.0
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/CHANGELOG.md +8 -0
- package/LICENSE +21 -0
- package/README.md +85 -0
- package/dist/chunks/RuntimePreviewPanel-3704c8f8.js +1991 -0
- package/dist/chunks/compositeField-98c1b192.js +588 -0
- package/dist/chunks/dataSourceUrl-4b17feb8.js +55 -0
- package/dist/designer.js +3023 -0
- package/dist/index.js +45 -0
- package/dist/runtime.js +67 -0
- package/dist/schema.js +266 -0
- package/dist/style.css +1 -0
- package/dist/testing.js +1026 -0
- package/docs/field-suffix-extension.md +289 -0
- package/package.json +100 -0
- package/types/designer.d.ts +12 -0
- package/types/index.d.ts +345 -0
- package/types/runtime.d.ts +22 -0
- package/types/schema.d.ts +31 -0
- package/types/testing.d.ts +3 -0
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import type { Component, DefineComponent, Plugin } from 'vue';
|
|
2
|
+
import type { StoreDefinition } from 'pinia';
|
|
3
|
+
|
|
4
|
+
export type JxyFormData = Record<string, unknown>;
|
|
5
|
+
export type JxyComponentRegistry = Record<string, Component>;
|
|
6
|
+
|
|
7
|
+
export interface JxyOption {
|
|
8
|
+
label: string;
|
|
9
|
+
value: unknown;
|
|
10
|
+
disabled?: boolean;
|
|
11
|
+
children?: JxyOption[];
|
|
12
|
+
[key: string]: unknown;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface JxyDataSourceProvider {
|
|
16
|
+
loadDictOptions?(dictType: string, dictUrl: string): Promise<JxyOption[]>;
|
|
17
|
+
loadApiOptions?(url: string, params?: Record<string, unknown>): Promise<JxyOption[]>;
|
|
18
|
+
clearDictCache?(dictUrl?: string): void;
|
|
19
|
+
listApiSources?(): unknown[];
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export type JxyRequestClient = (config: Record<string, unknown>) => Promise<unknown>;
|
|
23
|
+
|
|
24
|
+
export interface JxyFormPluginOptions {
|
|
25
|
+
request?: JxyRequestClient;
|
|
26
|
+
dataSourceProvider?: JxyDataSourceProvider;
|
|
27
|
+
components?: {
|
|
28
|
+
fileUpload?: Component;
|
|
29
|
+
editor?: Component;
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface JxyDataSourceConfig {
|
|
34
|
+
dictUrl?: string;
|
|
35
|
+
[key: string]: unknown;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface JxyStaticDataSource {
|
|
39
|
+
id: string;
|
|
40
|
+
name: string;
|
|
41
|
+
type: 'static';
|
|
42
|
+
options: JxyOption[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export interface JxyDictDataSource {
|
|
46
|
+
id: string;
|
|
47
|
+
name: string;
|
|
48
|
+
type: 'dict';
|
|
49
|
+
dictType: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface JxyApiParam {
|
|
53
|
+
key: string;
|
|
54
|
+
valueType: 'field' | 'constant';
|
|
55
|
+
field?: string;
|
|
56
|
+
value?: unknown;
|
|
57
|
+
required?: boolean;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface JxyApiDataSource {
|
|
61
|
+
id: string;
|
|
62
|
+
name: string;
|
|
63
|
+
type: 'api';
|
|
64
|
+
url: string;
|
|
65
|
+
params: JxyApiParam[];
|
|
66
|
+
apiKey?: string;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type JxyDataSource = JxyStaticDataSource | JxyDictDataSource | JxyApiDataSource;
|
|
70
|
+
|
|
71
|
+
export interface JxyTitleNode {
|
|
72
|
+
id: string;
|
|
73
|
+
nodeType: 'title';
|
|
74
|
+
sort?: number;
|
|
75
|
+
title: string;
|
|
76
|
+
description?: string;
|
|
77
|
+
level?: number;
|
|
78
|
+
customClass?: string;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
export interface JxyFieldSuffixExtension {
|
|
82
|
+
enabled?: boolean;
|
|
83
|
+
width?: number | '';
|
|
84
|
+
[key: string]: unknown;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface JxyFieldExtensions {
|
|
88
|
+
suffix?: JxyFieldSuffixExtension;
|
|
89
|
+
[key: string]: unknown;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export interface JxyFieldNode {
|
|
93
|
+
id: string;
|
|
94
|
+
nodeType: 'field';
|
|
95
|
+
sort?: number;
|
|
96
|
+
prop: string;
|
|
97
|
+
label: string;
|
|
98
|
+
type: string;
|
|
99
|
+
defaultValue?: unknown;
|
|
100
|
+
placeholder?: string;
|
|
101
|
+
required?: boolean;
|
|
102
|
+
disabled?: boolean;
|
|
103
|
+
hidden?: boolean;
|
|
104
|
+
labelWidth?: number | '';
|
|
105
|
+
customClass?: string;
|
|
106
|
+
dataSourceId?: string;
|
|
107
|
+
componentKey?: string;
|
|
108
|
+
componentProps?: Record<string, unknown>;
|
|
109
|
+
props?: Record<string, unknown>;
|
|
110
|
+
validations?: Array<Record<string, unknown>>;
|
|
111
|
+
extensions?: JxyFieldExtensions;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export interface JxyGridColumn {
|
|
115
|
+
id: string;
|
|
116
|
+
sort?: number;
|
|
117
|
+
span: number;
|
|
118
|
+
labelWidth?: number | '';
|
|
119
|
+
customClass?: string;
|
|
120
|
+
children: JxyFieldNode[];
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface JxyGridNode {
|
|
124
|
+
id: string;
|
|
125
|
+
nodeType: 'grid';
|
|
126
|
+
sort?: number;
|
|
127
|
+
gutter?: number;
|
|
128
|
+
labelWidth?: number | '';
|
|
129
|
+
customClass?: string;
|
|
130
|
+
columns: JxyGridColumn[];
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export type JxyFormNode = JxyTitleNode | JxyFieldNode | JxyGridNode;
|
|
134
|
+
|
|
135
|
+
export interface JxyReaction {
|
|
136
|
+
id: string;
|
|
137
|
+
sourceField: string;
|
|
138
|
+
condition?: Record<string, unknown>;
|
|
139
|
+
effects: Array<Record<string, unknown>>;
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export interface JxyFormSchema {
|
|
143
|
+
schemaVersion: string;
|
|
144
|
+
meta: Record<string, unknown>;
|
|
145
|
+
config: Record<string, unknown>;
|
|
146
|
+
dataSourceConfig?: JxyDataSourceConfig;
|
|
147
|
+
dataSources: JxyDataSource[];
|
|
148
|
+
reactions: JxyReaction[];
|
|
149
|
+
nodes: JxyFormNode[];
|
|
150
|
+
[key: string]: unknown;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export interface JxyValidationResult {
|
|
154
|
+
valid: boolean;
|
|
155
|
+
errors: string[];
|
|
156
|
+
warnings: string[];
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export interface JxySchemaError {
|
|
160
|
+
type: string;
|
|
161
|
+
message: string;
|
|
162
|
+
component?: string;
|
|
163
|
+
field?: string;
|
|
164
|
+
[key: string]: unknown;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export interface JxyDataSourceError {
|
|
168
|
+
prop: string;
|
|
169
|
+
error: unknown;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export interface JxyFieldChangePayload {
|
|
173
|
+
prop: string;
|
|
174
|
+
value: unknown;
|
|
175
|
+
oldValue: unknown;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export interface JxyFieldSuffixSlotScope {
|
|
179
|
+
field: JxyFieldNode;
|
|
180
|
+
fieldId: string;
|
|
181
|
+
prop: string;
|
|
182
|
+
label: string;
|
|
183
|
+
value: unknown;
|
|
184
|
+
disabled: boolean;
|
|
185
|
+
required: boolean;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export interface JxyFieldSuffixSlots {
|
|
189
|
+
'field-suffix'?: (scope: JxyFieldSuffixSlotScope) => unknown;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
export interface JxyPreviewActionSlots {
|
|
193
|
+
'preview-actions'?: () => unknown;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export interface JxyFormDesignerSlots extends JxyFieldSuffixSlots, JxyPreviewActionSlots {}
|
|
197
|
+
export interface JxyRuntimePreviewPanelSlots extends JxyFieldSuffixSlots, JxyPreviewActionSlots {}
|
|
198
|
+
|
|
199
|
+
export interface JxyFormDesignerProps {
|
|
200
|
+
dataSourceProvider?: JxyDataSourceProvider | null;
|
|
201
|
+
componentRegistry?: JxyComponentRegistry;
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
export interface JxyFormDesignerExpose {
|
|
205
|
+
getSchema(): JxyFormSchema;
|
|
206
|
+
loadSchema(schema: JxyFormSchema): void;
|
|
207
|
+
saveDraft(): { success: true };
|
|
208
|
+
publish(): { success: boolean; errors?: string[]; warnings?: string[] };
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export interface JxyFormRuntimeProps {
|
|
212
|
+
schema: JxyFormSchema;
|
|
213
|
+
modelValue?: JxyFormData;
|
|
214
|
+
disabled?: boolean;
|
|
215
|
+
dataSourceProvider?: JxyDataSourceProvider | null;
|
|
216
|
+
componentRegistry?: JxyComponentRegistry;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export interface JxyFormRuntimeEmits {
|
|
220
|
+
(event: 'update:modelValue', value: JxyFormData): void;
|
|
221
|
+
(event: 'field-change', payload: JxyFieldChangePayload): void;
|
|
222
|
+
(event: 'data-source-error', payload: JxyDataSourceError): void;
|
|
223
|
+
(event: 'schema-error', payload: JxySchemaError): void;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export interface JxyFormRuntimeExpose {
|
|
227
|
+
validate(): Promise<boolean>;
|
|
228
|
+
getData(): JxyFormData;
|
|
229
|
+
setData(data: JxyFormData): Promise<void>;
|
|
230
|
+
resetFields(): Promise<void>;
|
|
231
|
+
clearValidate(prop?: string | string[]): void;
|
|
232
|
+
reloadOptions(prop: string): Promise<void>;
|
|
233
|
+
getOptions(prop: string): JxyOption[];
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export interface JxyRuntimePreviewPanelProps {
|
|
237
|
+
schema: JxyFormSchema;
|
|
238
|
+
dataSourceProvider?: JxyDataSourceProvider | null;
|
|
239
|
+
disabled?: boolean;
|
|
240
|
+
componentRegistry?: JxyComponentRegistry;
|
|
241
|
+
showActions?: boolean;
|
|
242
|
+
layout?: 'default' | 'dialog';
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export interface JxyRuntimePreviewPanelExpose {
|
|
246
|
+
validate(): Promise<boolean> | undefined;
|
|
247
|
+
resetFields(): Promise<void> | undefined;
|
|
248
|
+
getData(): JxyFormData | undefined;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
export type JxyFormDesignerComponent = DefineComponent<JxyFormDesignerProps> & {
|
|
252
|
+
new (): JxyFormDesignerExpose & {
|
|
253
|
+
$props: JxyFormDesignerProps;
|
|
254
|
+
$slots: JxyFormDesignerSlots;
|
|
255
|
+
};
|
|
256
|
+
};
|
|
257
|
+
|
|
258
|
+
export type JxyFormRuntimeComponent = DefineComponent<JxyFormRuntimeProps> & {
|
|
259
|
+
new (): JxyFormRuntimeExpose & {
|
|
260
|
+
$props: JxyFormRuntimeProps;
|
|
261
|
+
$emit: JxyFormRuntimeEmits;
|
|
262
|
+
$slots: JxyFieldSuffixSlots;
|
|
263
|
+
};
|
|
264
|
+
};
|
|
265
|
+
|
|
266
|
+
export type JxyRuntimePreviewPanelComponent = DefineComponent<JxyRuntimePreviewPanelProps> & {
|
|
267
|
+
new (): JxyRuntimePreviewPanelExpose & {
|
|
268
|
+
$props: JxyRuntimePreviewPanelProps;
|
|
269
|
+
$slots: JxyRuntimePreviewPanelSlots;
|
|
270
|
+
};
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
export const JXYFormDesigner: JxyFormDesignerComponent;
|
|
274
|
+
export const JXYFormRuntime: JxyFormRuntimeComponent;
|
|
275
|
+
export const JXYRuntimePreviewPanel: JxyRuntimePreviewPanelComponent;
|
|
276
|
+
|
|
277
|
+
export function createJxyFormPlugin(options?: JxyFormPluginOptions): Plugin;
|
|
278
|
+
export function createRequestDataSourceProvider(requestClient: JxyRequestClient): JxyDataSourceProvider;
|
|
279
|
+
|
|
280
|
+
export interface JxyFormDesignerStoreState {
|
|
281
|
+
schema: JxyFormSchema;
|
|
282
|
+
selectedNodeId: string;
|
|
283
|
+
readonly selectedNode: JxyFormNode | null;
|
|
284
|
+
activePanel: string;
|
|
285
|
+
clipboard: JxyFormNode | null;
|
|
286
|
+
draggingState: Record<string, unknown>;
|
|
287
|
+
canvasState: Record<string, unknown>;
|
|
288
|
+
history: Record<string, unknown>;
|
|
289
|
+
readonly canUndo: boolean;
|
|
290
|
+
readonly canRedo: boolean;
|
|
291
|
+
readonly allFieldNodes: JxyFieldNode[];
|
|
292
|
+
readonly allFieldProps: string[];
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export interface JxyFormDesignerStoreActions {
|
|
296
|
+
undo(): void;
|
|
297
|
+
redo(): void;
|
|
298
|
+
selectNode(id: string): void;
|
|
299
|
+
clearSelection(): void;
|
|
300
|
+
addNodeFromPalette(item: Record<string, unknown>, targetList: JxyFormNode[], index: number): void;
|
|
301
|
+
deleteNode(id: string): boolean;
|
|
302
|
+
deleteSelectedNode(): boolean;
|
|
303
|
+
copyNode(id?: string): void;
|
|
304
|
+
pasteNode(targetList: JxyFormNode[], index: number): void;
|
|
305
|
+
updateNodeProp(key: string, value: unknown): void;
|
|
306
|
+
onDragSortEnd(): void;
|
|
307
|
+
addDataSource(dataSource: JxyDataSource): void;
|
|
308
|
+
removeDataSource(id: string): void;
|
|
309
|
+
updateDataSource(id: string, updates: Partial<JxyDataSource>): void;
|
|
310
|
+
addReaction(reaction: JxyReaction): void;
|
|
311
|
+
removeReaction(id: string): void;
|
|
312
|
+
updateReaction(id: string, updates: Partial<JxyReaction>): void;
|
|
313
|
+
updateFormConfig(key: string, value: unknown): void;
|
|
314
|
+
updateFormMeta(key: string, value: unknown): void;
|
|
315
|
+
updateDataSourceConfig(key: string, value: unknown): void;
|
|
316
|
+
loadSchema(schema: JxyFormSchema): void;
|
|
317
|
+
resetSchema(): void;
|
|
318
|
+
initDesigner(): void;
|
|
319
|
+
saveDraft(): { success: true };
|
|
320
|
+
publish(): { success: boolean; errors?: string[]; warnings?: string[] };
|
|
321
|
+
validateDraft(): JxyValidationResult;
|
|
322
|
+
getPublishedSchema(formCode: string): JxyFormSchema | null;
|
|
323
|
+
setActivePanel(panel: string): void;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export const useFormDesignerStore: StoreDefinition<
|
|
327
|
+
'jxyFormDesigner',
|
|
328
|
+
JxyFormDesignerStoreState,
|
|
329
|
+
Record<string, never>,
|
|
330
|
+
JxyFormDesignerStoreActions
|
|
331
|
+
>;
|
|
332
|
+
|
|
333
|
+
export const SCHEMA_VERSION: string;
|
|
334
|
+
export const COMPONENT_GROUPS: Array<Record<string, unknown>>;
|
|
335
|
+
export function createDefaultSchema(): JxyFormSchema;
|
|
336
|
+
export function createFieldNode(type: string): JxyFieldNode;
|
|
337
|
+
export function createTitleNode(): JxyTitleNode;
|
|
338
|
+
export function createGridNode(columnCount?: number): JxyGridNode;
|
|
339
|
+
export function createNodeFromPaletteItem(item: Record<string, unknown>): JxyFormNode;
|
|
340
|
+
export function migrateSchema(schema: JxyFormSchema): { schema: JxyFormSchema; warnings: string[] };
|
|
341
|
+
export function normalizeImport(input: string | JxyFormSchema): { schema: JxyFormSchema; errors: string[]; warnings: string[] };
|
|
342
|
+
export function validateJxyFormSchema(schema: JxyFormSchema, options?: { mode?: 'draft' | 'publish' }): JxyValidationResult;
|
|
343
|
+
|
|
344
|
+
declare const pluginFactory: typeof createJxyFormPlugin;
|
|
345
|
+
export default pluginFactory;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export {
|
|
2
|
+
JXYFormRuntime,
|
|
3
|
+
JXYRuntimePreviewPanel,
|
|
4
|
+
createRequestDataSourceProvider
|
|
5
|
+
} from './index';
|
|
6
|
+
export type {
|
|
7
|
+
JxyDataSourceProvider,
|
|
8
|
+
JxyRequestClient,
|
|
9
|
+
JxyFormRuntimeProps,
|
|
10
|
+
JxyFormRuntimeEmits,
|
|
11
|
+
JxyFormRuntimeExpose,
|
|
12
|
+
JxyRuntimePreviewPanelProps,
|
|
13
|
+
JxyRuntimePreviewPanelExpose,
|
|
14
|
+
JxySchemaError,
|
|
15
|
+
JxyDataSourceError,
|
|
16
|
+
JxyFieldChangePayload,
|
|
17
|
+
JxyFieldSuffixSlotScope,
|
|
18
|
+
JxyFieldSuffixSlots,
|
|
19
|
+
JxyPreviewActionSlots,
|
|
20
|
+
JxyRuntimePreviewPanelSlots
|
|
21
|
+
} from './index';
|
|
22
|
+
export { JXYFormRuntime as default } from './index';
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export {
|
|
2
|
+
SCHEMA_VERSION,
|
|
3
|
+
COMPONENT_GROUPS,
|
|
4
|
+
createDefaultSchema,
|
|
5
|
+
createFieldNode,
|
|
6
|
+
createTitleNode,
|
|
7
|
+
createGridNode,
|
|
8
|
+
createNodeFromPaletteItem,
|
|
9
|
+
migrateSchema,
|
|
10
|
+
normalizeImport,
|
|
11
|
+
validateJxyFormSchema
|
|
12
|
+
} from './index';
|
|
13
|
+
export type {
|
|
14
|
+
JxyFormSchema,
|
|
15
|
+
JxyValidationResult,
|
|
16
|
+
JxyOption,
|
|
17
|
+
JxyDataSourceConfig,
|
|
18
|
+
JxyDataSource,
|
|
19
|
+
JxyStaticDataSource,
|
|
20
|
+
JxyDictDataSource,
|
|
21
|
+
JxyApiDataSource,
|
|
22
|
+
JxyApiParam,
|
|
23
|
+
JxyFormNode,
|
|
24
|
+
JxyTitleNode,
|
|
25
|
+
JxyGridNode,
|
|
26
|
+
JxyGridColumn,
|
|
27
|
+
JxyFieldNode,
|
|
28
|
+
JxyFieldExtensions,
|
|
29
|
+
JxyFieldSuffixExtension,
|
|
30
|
+
JxyReaction
|
|
31
|
+
} from './index';
|