@sepveneto/dnde-core 0.6.3 → 0.6.5
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/{Node-B7pDsvZF.d.cts → capability-Ce3qGTm3.d.cts} +198 -127
- package/dist/{Node-B7pDsvZF.d.ts → capability-Ce3qGTm3.d.ts} +198 -127
- package/dist/capability.cjs +172 -0
- package/dist/capability.d.cts +4 -0
- package/dist/capability.d.ts +4 -0
- package/dist/capability.js +15 -0
- package/dist/{chunk-PRK4NPVH.js → chunk-62FPS6PZ.js} +2 -0
- package/dist/chunk-IQ5LOS7W.js +0 -0
- package/dist/{chunk-KJZSF66T.js → chunk-RLMXVDJK.js} +1 -16
- package/dist/chunk-W7WBD3NX.js +360 -0
- package/dist/chunk-XXR7SKZ3.js +132 -0
- package/dist/class/Container.d.cts +2 -2
- package/dist/class/Container.d.ts +2 -2
- package/dist/class/Node.cjs +2 -18
- package/dist/class/Node.d.cts +1 -1
- package/dist/class/Node.d.ts +1 -1
- package/dist/class/Node.js +3 -5
- package/dist/class/Widget.d.cts +1 -1
- package/dist/class/Widget.d.ts +1 -1
- package/dist/class/index.cjs +0 -16
- package/dist/class/index.d.cts +2 -2
- package/dist/class/index.d.ts +2 -2
- package/dist/class/index.js +4 -5
- package/dist/dsl.cjs +405 -0
- package/dist/dsl.d.cts +85 -0
- package/dist/dsl.d.ts +85 -0
- package/dist/dsl.js +12 -0
- package/dist/helper/index.cjs +2 -0
- package/dist/helper/index.d.cts +1 -1
- package/dist/helper/index.d.ts +1 -1
- package/dist/helper/index.js +1 -1
- package/dist/helper/schema.cjs +2 -0
- package/dist/helper/schema.d.cts +3 -1
- package/dist/helper/schema.d.ts +3 -1
- package/dist/helper/schema.js +1 -1
- package/dist/helper/widget.d.cts +1 -1
- package/dist/helper/widget.d.ts +1 -1
- package/dist/index.cjs +693 -0
- package/dist/index.d.cts +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +34 -1
- package/dist/internal.d.cts +2 -2
- package/dist/internal.d.ts +2 -2
- package/dist/tokens.d.cts +1 -1
- package/dist/tokens.d.ts +1 -1
- package/dist/types.d.cts +1 -1
- package/dist/types.d.ts +1 -1
- package/package.json +1 -1
|
@@ -1,8 +1,126 @@
|
|
|
1
|
+
import { FormItemProps, FormItemRule, InputProps, ElOption, SelectProps, InputNumberProps, SwitchProps, RadioGroupProps, ElRadio, ElRadioButton, DatePickerProps, ColorPickerProps, CheckboxProps, UploadRequestOptions } from 'element-plus';
|
|
1
2
|
import * as vue from 'vue';
|
|
2
3
|
import { CSSProperties } from 'vue';
|
|
3
|
-
import { FormItemRule, UploadRequestOptions, FormItemProps, InputProps, ElOption, SelectProps, InputNumberProps, SwitchProps, RadioGroupProps, ElRadio, ElRadioButton, DatePickerProps, ColorPickerProps, CheckboxProps } from 'element-plus';
|
|
4
4
|
import Validator from 'async-validator';
|
|
5
5
|
|
|
6
|
+
type Option = InstanceType<typeof ElOption>['$props'];
|
|
7
|
+
type RadioOption = InstanceType<typeof ElRadio>['$props'];
|
|
8
|
+
type RadioButtonOption = InstanceType<typeof ElRadioButton>['$props'];
|
|
9
|
+
interface SchemaItemBase {
|
|
10
|
+
/** @private */
|
|
11
|
+
_role?: string;
|
|
12
|
+
label: string;
|
|
13
|
+
key: string;
|
|
14
|
+
/** Capability range used by DSL scope validation. */
|
|
15
|
+
scope?: FieldScope;
|
|
16
|
+
/** A field may be discovered but not written by the configuration Agent. */
|
|
17
|
+
readOnly?: boolean;
|
|
18
|
+
formItem?: Partial<FormItemProps>;
|
|
19
|
+
rules?: FormItemRule | FormItemRule[];
|
|
20
|
+
}
|
|
21
|
+
interface SchemaItemInput extends SchemaItemBase {
|
|
22
|
+
type: 'input';
|
|
23
|
+
attrs?: InputProps;
|
|
24
|
+
}
|
|
25
|
+
interface SchemaItemSelect extends SchemaItemBase {
|
|
26
|
+
type: 'select';
|
|
27
|
+
options?: Option[];
|
|
28
|
+
attrs?: SelectProps;
|
|
29
|
+
link?: Record<string | number, SchemaItem[]>;
|
|
30
|
+
}
|
|
31
|
+
interface SchemaItemNumber extends SchemaItemBase {
|
|
32
|
+
type: 'number';
|
|
33
|
+
attrs?: InputNumberProps;
|
|
34
|
+
}
|
|
35
|
+
interface SchemaItemSwitch extends SchemaItemBase {
|
|
36
|
+
type: 'switch';
|
|
37
|
+
attrs?: SwitchProps;
|
|
38
|
+
}
|
|
39
|
+
interface SchemaItemDatetimePicker extends SchemaItemBase {
|
|
40
|
+
type: 'datetimePicker';
|
|
41
|
+
attrs?: DatePickerProps;
|
|
42
|
+
}
|
|
43
|
+
interface SchemaItemColorPicker extends SchemaItemBase {
|
|
44
|
+
type: 'colorPicker';
|
|
45
|
+
attrs?: ColorPickerProps;
|
|
46
|
+
}
|
|
47
|
+
interface SchemaItemCheckbox extends SchemaItemBase {
|
|
48
|
+
type: 'checkbox';
|
|
49
|
+
attrs?: CheckboxProps;
|
|
50
|
+
}
|
|
51
|
+
interface SchemaItemCustom extends SchemaItemBase {
|
|
52
|
+
type: 'custom';
|
|
53
|
+
name: string;
|
|
54
|
+
attrs?: Record<string, any>;
|
|
55
|
+
}
|
|
56
|
+
interface SchemaItemStyleNumber extends SchemaItemBase {
|
|
57
|
+
type: 'styleNumber';
|
|
58
|
+
}
|
|
59
|
+
interface SchemaItemRadio extends SchemaItemBase {
|
|
60
|
+
type: 'radio';
|
|
61
|
+
attrs?: RadioGroupProps;
|
|
62
|
+
options?: RadioOption[];
|
|
63
|
+
link?: Record<string | number, SchemaItem[]>;
|
|
64
|
+
}
|
|
65
|
+
interface SchemaItemRadioButton extends SchemaItemBase {
|
|
66
|
+
type: 'radioButton';
|
|
67
|
+
attrs?: RadioGroupProps;
|
|
68
|
+
options?: RadioButtonOption[];
|
|
69
|
+
link?: Record<string | number, SchemaItem[]>;
|
|
70
|
+
}
|
|
71
|
+
type SchemaItem = SchemaItemInput | SchemaItemSelect | SchemaItemNumber | SchemaItemSwitch | SchemaItemCustom | SchemaItemStyleNumber | SchemaItemRadio | SchemaItemRadioButton | SchemaItemDatetimePicker | SchemaItemColorPicker | SchemaItemCheckbox;
|
|
72
|
+
declare class Widget {
|
|
73
|
+
name: string;
|
|
74
|
+
view: string;
|
|
75
|
+
_data: IWidget;
|
|
76
|
+
container: IWidget['container'];
|
|
77
|
+
constructor(widget: IWidget);
|
|
78
|
+
clone(): Widget;
|
|
79
|
+
get icon(): string | undefined;
|
|
80
|
+
get props(): SchemaItem[];
|
|
81
|
+
get style(): SchemaItem[];
|
|
82
|
+
get defaultStyle(): (vue.CSSProperties & WidgetPos) | undefined;
|
|
83
|
+
get defaultData(): any[] | Record<string, any> | undefined;
|
|
84
|
+
get agent(): WidgetAgent | undefined;
|
|
85
|
+
get draggable(): boolean;
|
|
86
|
+
get isFixed(): false | "header" | "footer" | undefined;
|
|
87
|
+
get visible(): boolean;
|
|
88
|
+
get validatorProps(): Validator;
|
|
89
|
+
get validatorStyle(): Validator;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
declare class Node {
|
|
93
|
+
level: number;
|
|
94
|
+
wid: string;
|
|
95
|
+
widget: Readonly<Widget>;
|
|
96
|
+
parent?: Node;
|
|
97
|
+
list: Node[];
|
|
98
|
+
data: Record<string, any>;
|
|
99
|
+
style: CSSProperties;
|
|
100
|
+
hovering: boolean;
|
|
101
|
+
dragging: boolean;
|
|
102
|
+
constructor(widget: Widget, info?: {
|
|
103
|
+
uuid?: string;
|
|
104
|
+
props?: Node['data'];
|
|
105
|
+
style?: Node['style'];
|
|
106
|
+
list?: Node['list'];
|
|
107
|
+
});
|
|
108
|
+
get info(): {
|
|
109
|
+
style: CSSProperties;
|
|
110
|
+
};
|
|
111
|
+
get isContainer(): boolean;
|
|
112
|
+
get hasList(): boolean;
|
|
113
|
+
get mouseover(): boolean;
|
|
114
|
+
get type(): string;
|
|
115
|
+
get name(): string;
|
|
116
|
+
get visible(): boolean | undefined;
|
|
117
|
+
validate(only?: boolean): Promise<string | undefined>;
|
|
118
|
+
triggerHover(hover: boolean): void;
|
|
119
|
+
setList(list: Node[]): void;
|
|
120
|
+
copy(): Node;
|
|
121
|
+
parse(): Record<string, any>;
|
|
122
|
+
}
|
|
123
|
+
|
|
6
124
|
interface WidgetPos {
|
|
7
125
|
x?: number;
|
|
8
126
|
y?: number;
|
|
@@ -11,24 +129,43 @@ interface WidgetPos {
|
|
|
11
129
|
}
|
|
12
130
|
/** 布局子 Agent 的输出项:选中的组件 + 要放进去的元素 */
|
|
13
131
|
interface WidgetLayoutItem {
|
|
14
|
-
widget
|
|
15
|
-
items
|
|
132
|
+
widget?: string;
|
|
133
|
+
items?: Array<{
|
|
16
134
|
category: string;
|
|
17
135
|
id: any;
|
|
18
136
|
}>;
|
|
137
|
+
componentKey?: string;
|
|
138
|
+
changes?: Record<string, any>;
|
|
139
|
+
}
|
|
140
|
+
interface WidgetCapabilityExecutionContext {
|
|
141
|
+
node: Node;
|
|
142
|
+
args: Record<string, unknown>;
|
|
143
|
+
context: Record<string, unknown>;
|
|
19
144
|
}
|
|
145
|
+
type WidgetCapabilityAdapter = (input: WidgetCapabilityExecutionContext) => void | Record<string, unknown> | Promise<void | Record<string, unknown>>;
|
|
20
146
|
interface WidgetAgent {
|
|
21
|
-
|
|
147
|
+
/**
|
|
148
|
+
* 组件的功能描述。
|
|
149
|
+
* 用于组件检索、用户意图匹配和编辑时的组件定位。
|
|
150
|
+
*/
|
|
151
|
+
description?: string;
|
|
152
|
+
/**
|
|
153
|
+
* 初始化页面时使用的布局信息。
|
|
154
|
+
*/
|
|
22
155
|
layout?: {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
156
|
+
/**
|
|
157
|
+
* 组件的布局特征与适用场景。
|
|
158
|
+
*/
|
|
159
|
+
description: string;
|
|
160
|
+
estimatedSize: string;
|
|
161
|
+
priority: 'large' | 'medium' | 'small' | 'tiny';
|
|
26
162
|
};
|
|
27
163
|
/**
|
|
28
164
|
* 布局子 Agent 结束、组件创建完成后,由业务侧决定数据如何更新到组件里。
|
|
29
165
|
*
|
|
30
166
|
* @param node 已创建的组件节点
|
|
31
167
|
* @param item 布局结果项(选中的组件 + 元素引用)
|
|
168
|
+
* @param state 当前 Agent Run 的上下文,包含业务工具准备的数据
|
|
32
169
|
*/
|
|
33
170
|
update?: (node: Node, item: WidgetLayoutItem, state: Record<string, unknown>) => void;
|
|
34
171
|
}
|
|
@@ -154,134 +291,68 @@ interface EditorData {
|
|
|
154
291
|
settings?: EditorSettings;
|
|
155
292
|
}
|
|
156
293
|
|
|
157
|
-
type
|
|
158
|
-
type
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
/** @private */
|
|
162
|
-
_role?: string;
|
|
163
|
-
label: string;
|
|
294
|
+
type FieldScope = 'style' | 'content' | 'layout';
|
|
295
|
+
type CapabilityValueType = 'string' | 'number' | 'integer' | 'boolean' | 'enum' | 'array' | 'object' | 'unknown';
|
|
296
|
+
interface WidgetFieldCapability {
|
|
297
|
+
source: 'prop';
|
|
164
298
|
key: string;
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
options?: Option[];
|
|
175
|
-
attrs?: SelectProps;
|
|
176
|
-
link?: Record<string | number, SchemaItem[]>;
|
|
177
|
-
}
|
|
178
|
-
interface SchemaItemNumber extends SchemaItemBase {
|
|
179
|
-
type: 'number';
|
|
180
|
-
attrs?: InputNumberProps;
|
|
181
|
-
}
|
|
182
|
-
interface SchemaItemSwitch extends SchemaItemBase {
|
|
183
|
-
type: 'switch';
|
|
184
|
-
attrs?: SwitchProps;
|
|
185
|
-
}
|
|
186
|
-
interface SchemaItemDatetimePicker extends SchemaItemBase {
|
|
187
|
-
type: 'datetimePicker';
|
|
188
|
-
attrs?: DatePickerProps;
|
|
189
|
-
}
|
|
190
|
-
interface SchemaItemColorPicker extends SchemaItemBase {
|
|
191
|
-
type: 'colorPicker';
|
|
192
|
-
attrs?: ColorPickerProps;
|
|
193
|
-
}
|
|
194
|
-
interface SchemaItemCheckbox extends SchemaItemBase {
|
|
195
|
-
type: 'checkbox';
|
|
196
|
-
attrs?: CheckboxProps;
|
|
299
|
+
label: string;
|
|
300
|
+
valueType: CapabilityValueType;
|
|
301
|
+
scope: FieldScope;
|
|
302
|
+
required: boolean;
|
|
303
|
+
readOnly: boolean;
|
|
304
|
+
enum?: unknown[];
|
|
305
|
+
minimum?: number;
|
|
306
|
+
maximum?: number;
|
|
307
|
+
default?: unknown;
|
|
197
308
|
}
|
|
198
|
-
interface
|
|
199
|
-
type: 'custom';
|
|
309
|
+
interface WidgetCustomCapability {
|
|
200
310
|
name: string;
|
|
201
|
-
|
|
311
|
+
inputSchema?: Record<string, unknown>;
|
|
312
|
+
semantics: 'append' | 'replace' | 'remove' | 'command';
|
|
313
|
+
idempotent: boolean;
|
|
314
|
+
destructive: boolean;
|
|
315
|
+
writableScope: FieldScope;
|
|
202
316
|
}
|
|
203
|
-
interface
|
|
204
|
-
type:
|
|
317
|
+
interface WidgetCustomTypeCapability {
|
|
318
|
+
type: string;
|
|
319
|
+
capabilities: WidgetCustomCapability[];
|
|
205
320
|
}
|
|
206
|
-
interface
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
321
|
+
interface StaticOption {
|
|
322
|
+
id: string;
|
|
323
|
+
name: string;
|
|
324
|
+
aliases: string[];
|
|
325
|
+
value: unknown;
|
|
326
|
+
types: string[];
|
|
211
327
|
}
|
|
212
|
-
interface
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
options?: RadioButtonOption[];
|
|
216
|
-
link?: Record<string | number, SchemaItem[]>;
|
|
328
|
+
interface WidgetCapabilityRegistration {
|
|
329
|
+
customTypes?: WidgetCustomTypeCapability[];
|
|
330
|
+
staticOptions?: StaticOption[];
|
|
217
331
|
}
|
|
218
|
-
type
|
|
219
|
-
|
|
332
|
+
type WidgetCapabilityRegistry = Record<string, WidgetCapabilityRegistration>;
|
|
333
|
+
interface WidgetCapability {
|
|
334
|
+
type: string;
|
|
220
335
|
name: string;
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
get props(): SchemaItem[];
|
|
228
|
-
get style(): SchemaItem[];
|
|
229
|
-
get defaultStyle(): (vue.CSSProperties & WidgetPos) | undefined;
|
|
230
|
-
get defaultData(): any[] | Record<string, any> | undefined;
|
|
231
|
-
get agent(): WidgetAgent | undefined;
|
|
232
|
-
get draggable(): boolean;
|
|
233
|
-
get isFixed(): false | "header" | "footer" | undefined;
|
|
234
|
-
get visible(): boolean;
|
|
235
|
-
get validatorProps(): Validator;
|
|
236
|
-
get validatorStyle(): Validator;
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
declare class Node {
|
|
240
|
-
level: number;
|
|
241
|
-
wid: string;
|
|
242
|
-
widget: Readonly<Widget>;
|
|
243
|
-
parent?: Node;
|
|
244
|
-
list: Node[];
|
|
245
|
-
data: Record<string, any>;
|
|
246
|
-
style: CSSProperties;
|
|
247
|
-
hovering: boolean;
|
|
248
|
-
dragging: boolean;
|
|
249
|
-
constructor(widget: Widget, info?: {
|
|
250
|
-
uuid?: string;
|
|
251
|
-
props?: Node['data'];
|
|
252
|
-
style?: Node['style'];
|
|
253
|
-
list?: Node['list'];
|
|
254
|
-
});
|
|
255
|
-
get info(): {
|
|
256
|
-
style: CSSProperties;
|
|
257
|
-
};
|
|
258
|
-
get isContainer(): boolean;
|
|
259
|
-
get hasList(): boolean;
|
|
260
|
-
get mouseover(): boolean;
|
|
261
|
-
get type(): string;
|
|
262
|
-
get name(): string;
|
|
263
|
-
get visible(): boolean | undefined;
|
|
264
|
-
validate(only?: boolean): Promise<string | undefined>;
|
|
265
|
-
triggerHover(hover: boolean): void;
|
|
266
|
-
setList(list: Node[]): void;
|
|
267
|
-
copy(): Node;
|
|
268
|
-
parse(): Record<string, any>;
|
|
336
|
+
description: string;
|
|
337
|
+
defaultData: Record<string, any>;
|
|
338
|
+
defaultStyle: Record<string, any>;
|
|
339
|
+
fields: WidgetFieldCapability[];
|
|
340
|
+
customTypes: WidgetCustomTypeCapability[];
|
|
341
|
+
staticOptions: StaticOption[];
|
|
269
342
|
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
widget: Readonly<Widget>;
|
|
274
|
-
parent?: Node;
|
|
275
|
-
list: any[];
|
|
276
|
-
data: Record<string, any>;
|
|
277
|
-
style: CSSProperties;
|
|
278
|
-
hovering: boolean;
|
|
279
|
-
dragging: boolean;
|
|
280
|
-
constructor(widget: Widget, info?: {
|
|
281
|
-
props?: Node['data'];
|
|
282
|
-
style?: Node['style'];
|
|
283
|
-
list?: Node['list'];
|
|
284
|
-
});
|
|
343
|
+
interface CapabilityCatalog {
|
|
344
|
+
catalogVersion: '1.0';
|
|
345
|
+
widgets: WidgetCapability[];
|
|
285
346
|
}
|
|
347
|
+
/**
|
|
348
|
+
* Convert live widget declarations into the stable catalog consumed by DSL
|
|
349
|
+
* validation. Custom schema entries are advertised from the schema itself;
|
|
350
|
+
* executable capabilities must be registered by the host.
|
|
351
|
+
*/
|
|
352
|
+
declare function createCapabilityCatalog(widgets: IWidget[], registry?: WidgetCapabilityRegistry): CapabilityCatalog;
|
|
353
|
+
declare function findWidgetCapability(catalog: CapabilityCatalog, type: string): WidgetCapability | undefined;
|
|
354
|
+
declare function findFieldCapability(widget: WidgetCapability, key: string): WidgetFieldCapability | undefined;
|
|
355
|
+
declare function findCustomCapability(widget: WidgetCapability, type: string, name: string): WidgetCustomCapability | undefined;
|
|
356
|
+
declare function listStaticOptions(catalog: CapabilityCatalog, widgetTypes?: string[], types?: string[]): StaticOption[];
|
|
286
357
|
|
|
287
|
-
export { type Base as B, type DisabledItemFn as D, type EditorConfig as E, type IWidget as I, Node as N, type Option as O, type RadioOption as R, type
|
|
358
|
+
export { type EditorRoute as A, type Base as B, type CapabilityValueType as C, type DisabledItemFn as D, type EditorConfig as E, type FieldScope as F, type EditorWidgets as G, type EditorSettings as H, type IWidget as I, type EditorData as J, Node as N, type Option as O, type RadioOption as R, type SchemaItemCustom as S, Widget as W, type RadioButtonOption as a, type SchemaItem as b, type WidgetFieldCapability as c, type WidgetCustomCapability as d, type WidgetCustomTypeCapability as e, type StaticOption as f, type WidgetCapabilityRegistration as g, type WidgetCapabilityRegistry as h, type WidgetCapability as i, type CapabilityCatalog as j, createCapabilityCatalog as k, findWidgetCapability as l, findFieldCapability as m, findCustomCapability as n, listStaticOptions as o, type WidgetPos as p, type WidgetLayoutItem as q, type WidgetCapabilityExecutionContext as r, type WidgetCapabilityAdapter as s, type WidgetAgent as t, type SchemaOther as u, type SchemaBox as v, type ISchema as w, isBox as x, type EditorSchema as y, type EditorWidget as z };
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
var __export = (target, all) => {
|
|
24
|
+
for (var name in all)
|
|
25
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
26
|
+
};
|
|
27
|
+
var __copyProps = (to, from, except, desc) => {
|
|
28
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
29
|
+
for (let key of __getOwnPropNames(from))
|
|
30
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
31
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
32
|
+
}
|
|
33
|
+
return to;
|
|
34
|
+
};
|
|
35
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
36
|
+
|
|
37
|
+
// src/capability.ts
|
|
38
|
+
var capability_exports = {};
|
|
39
|
+
__export(capability_exports, {
|
|
40
|
+
createCapabilityCatalog: () => createCapabilityCatalog,
|
|
41
|
+
findCustomCapability: () => findCustomCapability,
|
|
42
|
+
findFieldCapability: () => findFieldCapability,
|
|
43
|
+
findWidgetCapability: () => findWidgetCapability,
|
|
44
|
+
listStaticOptions: () => listStaticOptions
|
|
45
|
+
});
|
|
46
|
+
module.exports = __toCommonJS(capability_exports);
|
|
47
|
+
function optionValues(item) {
|
|
48
|
+
if (!("options" in item) || !Array.isArray(item.options))
|
|
49
|
+
return;
|
|
50
|
+
return item.options.map((option) => option && typeof option === "object" ? option.value : void 0).filter((value) => value !== void 0);
|
|
51
|
+
}
|
|
52
|
+
function fieldFromSchema(item, scope) {
|
|
53
|
+
var _a, _b, _c;
|
|
54
|
+
if (item.type === "custom")
|
|
55
|
+
return;
|
|
56
|
+
let valueType = "unknown";
|
|
57
|
+
let enumValues;
|
|
58
|
+
let minimum;
|
|
59
|
+
let maximum;
|
|
60
|
+
switch (item.type) {
|
|
61
|
+
case "input":
|
|
62
|
+
case "colorPicker":
|
|
63
|
+
case "datetimePicker":
|
|
64
|
+
valueType = "string";
|
|
65
|
+
break;
|
|
66
|
+
case "number":
|
|
67
|
+
case "styleNumber":
|
|
68
|
+
valueType = "number";
|
|
69
|
+
minimum = typeof ((_a = item.attrs) == null ? void 0 : _a.min) === "number" ? item.attrs.min : void 0;
|
|
70
|
+
maximum = typeof ((_b = item.attrs) == null ? void 0 : _b.max) === "number" ? item.attrs.max : void 0;
|
|
71
|
+
break;
|
|
72
|
+
case "switch":
|
|
73
|
+
if ("attrs" in item && item.attrs && ("activeValue" in item.attrs || "inactiveValue" in item.attrs)) {
|
|
74
|
+
valueType = "enum";
|
|
75
|
+
enumValues = [
|
|
76
|
+
item.attrs.activeValue,
|
|
77
|
+
item.attrs.inactiveValue
|
|
78
|
+
].filter((value) => value !== void 0);
|
|
79
|
+
} else {
|
|
80
|
+
valueType = "boolean";
|
|
81
|
+
}
|
|
82
|
+
break;
|
|
83
|
+
case "checkbox":
|
|
84
|
+
valueType = "boolean";
|
|
85
|
+
break;
|
|
86
|
+
case "select":
|
|
87
|
+
case "radio":
|
|
88
|
+
case "radioButton":
|
|
89
|
+
valueType = "enum";
|
|
90
|
+
enumValues = optionValues(item);
|
|
91
|
+
break;
|
|
92
|
+
}
|
|
93
|
+
const rules = Array.isArray(item.rules) ? item.rules : item.rules ? [item.rules] : [];
|
|
94
|
+
return {
|
|
95
|
+
source: "prop",
|
|
96
|
+
key: item.key,
|
|
97
|
+
label: item.label,
|
|
98
|
+
valueType,
|
|
99
|
+
scope: (_c = item.scope) != null ? _c : scope,
|
|
100
|
+
required: rules.some((rule) => rule.required === true),
|
|
101
|
+
readOnly: item.readOnly === true,
|
|
102
|
+
enum: enumValues,
|
|
103
|
+
minimum,
|
|
104
|
+
maximum
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
function registeredCustomTypes(registration) {
|
|
108
|
+
var _a;
|
|
109
|
+
return ((_a = registration == null ? void 0 : registration.customTypes) != null ? _a : []).map((type) => ({
|
|
110
|
+
type: type.type,
|
|
111
|
+
capabilities: type.capabilities.map((capability) => __spreadValues({}, capability))
|
|
112
|
+
}));
|
|
113
|
+
}
|
|
114
|
+
function schemaCustomTypes(widget) {
|
|
115
|
+
var _a, _b;
|
|
116
|
+
return ((_b = (_a = widget.schema) == null ? void 0 : _a.props) != null ? _b : []).filter((item) => item.type === "custom").map((item) => item.name);
|
|
117
|
+
}
|
|
118
|
+
function createCapabilityCatalog(widgets, registry = {}) {
|
|
119
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
120
|
+
const catalog = {
|
|
121
|
+
catalogVersion: "1.0",
|
|
122
|
+
widgets: []
|
|
123
|
+
};
|
|
124
|
+
for (const widget of widgets) {
|
|
125
|
+
const registration = registry[widget._view];
|
|
126
|
+
const declared = registeredCustomTypes(registration);
|
|
127
|
+
const declaredMap = new Map(declared.map((type) => [type.type, type]));
|
|
128
|
+
const customTypes = schemaCustomTypes(widget).map((type) => {
|
|
129
|
+
var _a2;
|
|
130
|
+
return (_a2 = declaredMap.get(type)) != null ? _a2 : { type, capabilities: [] };
|
|
131
|
+
});
|
|
132
|
+
catalog.widgets.push({
|
|
133
|
+
type: widget._view,
|
|
134
|
+
name: widget._name,
|
|
135
|
+
description: (_e = (_d = (_a = widget.agent) == null ? void 0 : _a.description) != null ? _d : (_c = (_b = widget.agent) == null ? void 0 : _b.layout) == null ? void 0 : _c.description) != null ? _e : "",
|
|
136
|
+
defaultData: JSON.parse(JSON.stringify((_f = widget.data) != null ? _f : {})),
|
|
137
|
+
defaultStyle: JSON.parse(JSON.stringify((_g = widget.style) != null ? _g : {})),
|
|
138
|
+
fields: [
|
|
139
|
+
...((_i = (_h = widget.schema) == null ? void 0 : _h.props) != null ? _i : []).map((item) => fieldFromSchema(item, "content")).filter((item) => Boolean(item)),
|
|
140
|
+
...((_k = (_j = widget.schema) == null ? void 0 : _j.style) != null ? _k : []).map((item) => fieldFromSchema(item, "style")).filter((item) => Boolean(item))
|
|
141
|
+
],
|
|
142
|
+
customTypes,
|
|
143
|
+
staticOptions: ((_l = registration == null ? void 0 : registration.staticOptions) != null ? _l : []).map((option) => __spreadProps(__spreadValues({}, option), {
|
|
144
|
+
aliases: [...option.aliases],
|
|
145
|
+
types: [...option.types]
|
|
146
|
+
}))
|
|
147
|
+
});
|
|
148
|
+
}
|
|
149
|
+
return catalog;
|
|
150
|
+
}
|
|
151
|
+
function findWidgetCapability(catalog, type) {
|
|
152
|
+
return catalog.widgets.find((widget) => widget.type === type);
|
|
153
|
+
}
|
|
154
|
+
function findFieldCapability(widget, key) {
|
|
155
|
+
return widget.fields.find((field) => field.key === key);
|
|
156
|
+
}
|
|
157
|
+
function findCustomCapability(widget, type, name) {
|
|
158
|
+
var _a;
|
|
159
|
+
return (_a = widget.customTypes.find((item) => item.type === type)) == null ? void 0 : _a.capabilities.find((capability) => capability.name === name);
|
|
160
|
+
}
|
|
161
|
+
function listStaticOptions(catalog, widgetTypes, types) {
|
|
162
|
+
const selected = (widgetTypes == null ? void 0 : widgetTypes.length) ? catalog.widgets.filter((widget) => widgetTypes.includes(widget.type)) : catalog.widgets;
|
|
163
|
+
return selected.flatMap((widget) => widget.staticOptions).filter((option) => !(types == null ? void 0 : types.length) || option.types.some((type) => types.includes(type)));
|
|
164
|
+
}
|
|
165
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
166
|
+
0 && (module.exports = {
|
|
167
|
+
createCapabilityCatalog,
|
|
168
|
+
findCustomCapability,
|
|
169
|
+
findFieldCapability,
|
|
170
|
+
findWidgetCapability,
|
|
171
|
+
listStaticOptions
|
|
172
|
+
});
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { j as CapabilityCatalog, C as CapabilityValueType, F as FieldScope, f as StaticOption, i as WidgetCapability, g as WidgetCapabilityRegistration, h as WidgetCapabilityRegistry, d as WidgetCustomCapability, e as WidgetCustomTypeCapability, c as WidgetFieldCapability, k as createCapabilityCatalog, n as findCustomCapability, m as findFieldCapability, l as findWidgetCapability, o as listStaticOptions } from './capability-Ce3qGTm3.cjs';
|
|
2
|
+
import 'element-plus';
|
|
3
|
+
import 'vue';
|
|
4
|
+
import 'async-validator';
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { j as CapabilityCatalog, C as CapabilityValueType, F as FieldScope, f as StaticOption, i as WidgetCapability, g as WidgetCapabilityRegistration, h as WidgetCapabilityRegistry, d as WidgetCustomCapability, e as WidgetCustomTypeCapability, c as WidgetFieldCapability, k as createCapabilityCatalog, n as findCustomCapability, m as findFieldCapability, l as findWidgetCapability, o as listStaticOptions } from './capability-Ce3qGTm3.js';
|
|
2
|
+
import 'element-plus';
|
|
3
|
+
import 'vue';
|
|
4
|
+
import 'async-validator';
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createCapabilityCatalog,
|
|
3
|
+
findCustomCapability,
|
|
4
|
+
findFieldCapability,
|
|
5
|
+
findWidgetCapability,
|
|
6
|
+
listStaticOptions
|
|
7
|
+
} from "./chunk-XXR7SKZ3.js";
|
|
8
|
+
import "./chunk-6FNC3XMI.js";
|
|
9
|
+
export {
|
|
10
|
+
createCapabilityCatalog,
|
|
11
|
+
findCustomCapability,
|
|
12
|
+
findFieldCapability,
|
|
13
|
+
findWidgetCapability,
|
|
14
|
+
listStaticOptions
|
|
15
|
+
};
|
|
File without changes
|
|
@@ -96,22 +96,7 @@ var Node = class _Node {
|
|
|
96
96
|
return res;
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
|
-
var RootNode = class {
|
|
100
|
-
constructor(widget, info) {
|
|
101
|
-
this.level = 0;
|
|
102
|
-
this.list = [];
|
|
103
|
-
this.data = {};
|
|
104
|
-
this.style = {};
|
|
105
|
-
this.hovering = false;
|
|
106
|
-
this.dragging = false;
|
|
107
|
-
this.widget = widget;
|
|
108
|
-
this.wid = v4();
|
|
109
|
-
this.data = (info == null ? void 0 : info.props) || {};
|
|
110
|
-
this.style = (info == null ? void 0 : info.style) || {};
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
99
|
|
|
114
100
|
export {
|
|
115
|
-
Node
|
|
116
|
-
RootNode
|
|
101
|
+
Node
|
|
117
102
|
};
|