zova-jsx 1.0.0 → 1.1.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/index.d.ts +2 -1
- package/dist/index.js +400 -1
- package/dist/lib/const.d.ts +1 -0
- package/dist/lib/index.d.ts +3 -0
- package/dist/lib/utils.d.ts +7 -0
- package/dist/lib/zovaJsx.d.ts +42 -0
- package/dist/types/index.d.ts +1 -16
- package/dist/types/rest.d.ts +23 -0
- package/package.json +25 -20
- package/dist/types/index.js +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export * from './
|
|
1
|
+
export * from './lib/index.ts';
|
|
2
|
+
export * from './types/index.ts';
|
package/dist/index.js
CHANGED
|
@@ -1 +1,400 @@
|
|
|
1
|
-
|
|
1
|
+
import { compose } from '@cabloy/compose';
|
|
2
|
+
import { celEnvBase, getProperty, evaluateExpressions, isPromise } from '@cabloy/utils';
|
|
3
|
+
import { toUpperCaseFirstChar } from '@cabloy/word-utils';
|
|
4
|
+
import { classes } from 'typestyle';
|
|
5
|
+
import { h, createTextVNode } from 'vue';
|
|
6
|
+
import { BeanSimple, objectAssignReactive, cast, beanFullNameFromOnionName, deepExtend } from 'zova-core';
|
|
7
|
+
|
|
8
|
+
const renderFieldJsxPropsSystem = ['children', 'v-slot', 'v-slot-scope', 'v-if', 'v-for', 'v-each', 'key'];
|
|
9
|
+
|
|
10
|
+
const __propsMapper = {
|
|
11
|
+
className: 'class'
|
|
12
|
+
};
|
|
13
|
+
function isNativeElement(Component) {
|
|
14
|
+
return typeof Component === 'string' && !Component.includes(':') && Component.charAt(0) >= 'a' && Component.charAt(0) <= 'z';
|
|
15
|
+
}
|
|
16
|
+
function isZovaComponent(Component) {
|
|
17
|
+
return typeof Component === 'string' && Component.includes(':');
|
|
18
|
+
}
|
|
19
|
+
function isLegacyComponent(Component) {
|
|
20
|
+
return typeof Component === 'string' && !Component.includes(':') && Component.charAt(0) >= 'A' && Component.charAt(0) <= 'Y';
|
|
21
|
+
}
|
|
22
|
+
function isJsxComponent(Component) {
|
|
23
|
+
return typeof Component === 'object' && Component.$$typeof === 'zova-jsx:component';
|
|
24
|
+
}
|
|
25
|
+
function isJsxEvent(Component) {
|
|
26
|
+
return typeof Component === 'object' && Component.$$typeof === 'zova-jsx:event';
|
|
27
|
+
}
|
|
28
|
+
function invokeProp(prop) {
|
|
29
|
+
if (typeof prop === 'function') return prop();
|
|
30
|
+
return prop;
|
|
31
|
+
}
|
|
32
|
+
function normalizePropName(name) {
|
|
33
|
+
return __propsMapper[name] ?? name;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
class ZovaJsx extends BeanSimple {
|
|
37
|
+
constructor(components, actions, celEnv) {
|
|
38
|
+
super();
|
|
39
|
+
this._components = void 0;
|
|
40
|
+
this._actions = void 0;
|
|
41
|
+
this._celEnv = void 0;
|
|
42
|
+
this._transientObject = void 0;
|
|
43
|
+
this._components = components;
|
|
44
|
+
this._actions = actions;
|
|
45
|
+
this._celEnv = this._prepareCelEnv(celEnv ?? celEnvBase);
|
|
46
|
+
}
|
|
47
|
+
_prepareCelEnv(celEnv) {
|
|
48
|
+
celEnv = celEnv.clone();
|
|
49
|
+
celEnv.registerFunction('getEvent():dyn', () => {
|
|
50
|
+
return this.transientObject.eventObject ?? null; // null means valid value
|
|
51
|
+
});
|
|
52
|
+
celEnv.registerFunction('getEventProp(string):dyn', prop => {
|
|
53
|
+
return getProperty(this.transientObject.eventObject, prop) ?? null; // null means valid value
|
|
54
|
+
});
|
|
55
|
+
return celEnv;
|
|
56
|
+
}
|
|
57
|
+
setTransientObject(transientObject, fnMethod) {
|
|
58
|
+
const transientObjectPrev = this._transientObject;
|
|
59
|
+
this._transientObject = transientObject;
|
|
60
|
+
try {
|
|
61
|
+
return fnMethod();
|
|
62
|
+
} finally {
|
|
63
|
+
this._transientObject = transientObjectPrev;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
get transientObject() {
|
|
67
|
+
return this._transientObject;
|
|
68
|
+
}
|
|
69
|
+
get event() {
|
|
70
|
+
return this.transientObject?.eventObject;
|
|
71
|
+
}
|
|
72
|
+
get components() {
|
|
73
|
+
return this._components;
|
|
74
|
+
}
|
|
75
|
+
get actions() {
|
|
76
|
+
return this._actions;
|
|
77
|
+
}
|
|
78
|
+
get celEnv() {
|
|
79
|
+
return this._celEnv;
|
|
80
|
+
}
|
|
81
|
+
evaluateExpression(expression, celScope) {
|
|
82
|
+
return evaluateExpressions(expression, celScope, this.celEnv);
|
|
83
|
+
}
|
|
84
|
+
renderJsxOrCel(componentOptions, props, celScope, renderContext) {
|
|
85
|
+
// component
|
|
86
|
+
if (isJsxComponent(componentOptions)) {
|
|
87
|
+
const transientObject = this.transientObject;
|
|
88
|
+
return () => {
|
|
89
|
+
return this.setTransientObject(transientObject, () => {
|
|
90
|
+
return this.render(componentOptions, props, celScope, renderContext);
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
if (isJsxEvent(componentOptions)) {
|
|
95
|
+
let transientObject = this.transientObject;
|
|
96
|
+
return event => {
|
|
97
|
+
transientObject = {
|
|
98
|
+
...transientObject,
|
|
99
|
+
eventObject: event
|
|
100
|
+
};
|
|
101
|
+
return this.setTransientObject(transientObject, () => {
|
|
102
|
+
return this.renderEvent(event, componentOptions, celScope, renderContext);
|
|
103
|
+
});
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
// normal
|
|
107
|
+
return this.evaluateExpression(componentOptions, celScope);
|
|
108
|
+
}
|
|
109
|
+
renderEvent(event, componentOptions, celScope, renderContext) {
|
|
110
|
+
// props
|
|
111
|
+
if (event && event instanceof Event) {
|
|
112
|
+
const props = this.renderJsxProps(componentOptions.props, {}, celScope, renderContext);
|
|
113
|
+
if (props.stop) event.stopPropagation();
|
|
114
|
+
if (props.prevent) event.preventDefault();
|
|
115
|
+
}
|
|
116
|
+
// render
|
|
117
|
+
const eventRes = [];
|
|
118
|
+
celScope = objectAssignReactive({}, celScope, {
|
|
119
|
+
res: eventRes
|
|
120
|
+
});
|
|
121
|
+
return this.renderEventDirect(componentOptions, celScope, renderContext, eventRes);
|
|
122
|
+
}
|
|
123
|
+
renderEventDirect(componentOptions, celScope, renderContext, eventRes, next) {
|
|
124
|
+
const actions = this._collectEventActions(componentOptions, celScope, renderContext, eventRes);
|
|
125
|
+
if (!actions || actions.length === 0) return next ? next(undefined) : undefined;
|
|
126
|
+
const transientObject = this.transientObject;
|
|
127
|
+
return compose(actions)(undefined, actionRes => {
|
|
128
|
+
if (!next) return actionRes;
|
|
129
|
+
return this.setTransientObject(transientObject, () => {
|
|
130
|
+
return next(actionRes);
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
_collectEventActions(componentOptions, celScope, renderContext, eventRes) {
|
|
135
|
+
let actionChildren = componentOptions.props?.children;
|
|
136
|
+
if (!actionChildren) return;
|
|
137
|
+
if (!Array.isArray(actionChildren)) actionChildren = [actionChildren];
|
|
138
|
+
const actions = [];
|
|
139
|
+
const transientObject = this.transientObject;
|
|
140
|
+
for (let index = 0; index < actionChildren.length; index++) {
|
|
141
|
+
const actionChild = actionChildren[index];
|
|
142
|
+
// action
|
|
143
|
+
const action = (actionRes, next) => {
|
|
144
|
+
if (isPromise(actionRes)) {
|
|
145
|
+
return actionRes.then(actionRes => {
|
|
146
|
+
return this._actionHandler(index, actionChild, actionRes, next, actionChildren, celScope, renderContext, eventRes, transientObject);
|
|
147
|
+
});
|
|
148
|
+
} else {
|
|
149
|
+
return this._actionHandler(index, actionChild, actionRes, next, actionChildren, celScope, renderContext, eventRes, transientObject);
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
actions.push(action);
|
|
153
|
+
}
|
|
154
|
+
return actions;
|
|
155
|
+
}
|
|
156
|
+
_actionHandler(index, actionChild, actionRes, next, actionChildren, celScope, renderContext, eventRes, transientObject) {
|
|
157
|
+
return this.setTransientObject(transientObject, () => {
|
|
158
|
+
// record res
|
|
159
|
+
if (index > 0) {
|
|
160
|
+
if (actionRes === undefined) actionRes = null;
|
|
161
|
+
eventRes[index - 1] = actionRes;
|
|
162
|
+
const actionChildPrev = actionChildren[index - 1];
|
|
163
|
+
const resName = cast(actionChildPrev.props)?.res;
|
|
164
|
+
if (resName) {
|
|
165
|
+
celScope = objectAssignReactive({}, celScope, {
|
|
166
|
+
[resName]: actionRes
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
// vIf
|
|
171
|
+
const vIf = this.evaluateExpression(actionChild.props?.['v-if'], celScope);
|
|
172
|
+
if (vIf === false) return next(undefined);
|
|
173
|
+
// action
|
|
174
|
+
if (actionChild.type === 'actionVar') {
|
|
175
|
+
const props = this.renderJsxProps(actionChild.props, {}, celScope, renderContext);
|
|
176
|
+
celScope = objectAssignReactive({}, celScope, {
|
|
177
|
+
[cast(props).name]: cast(props).value
|
|
178
|
+
});
|
|
179
|
+
return next(undefined);
|
|
180
|
+
} else if (actionChild.type === 'actionExpr') {
|
|
181
|
+
const expression = this.evaluateExpression(cast(actionChild.props)?.expression, celScope);
|
|
182
|
+
return next(expression);
|
|
183
|
+
} else if (isJsxEvent(actionChild)) {
|
|
184
|
+
// nested action
|
|
185
|
+
eventRes[index] = [];
|
|
186
|
+
return this.renderEventDirect(actionChild, objectAssignReactive({}, celScope), renderContext, eventRes[index], next);
|
|
187
|
+
} else {
|
|
188
|
+
// normal
|
|
189
|
+
return this._renderEventActionNormal(actionChild, celScope, renderContext, next);
|
|
190
|
+
}
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
_renderEventActionNormal(actionChild, celScope, renderContext, next) {
|
|
194
|
+
// action
|
|
195
|
+
const actionName = this.normalizeAction(actionChild.type);
|
|
196
|
+
const beanFullName = beanFullNameFromOnionName(actionName, 'action');
|
|
197
|
+
const beanInstance = this.sys.bean._getBeanSyncOnly(beanFullName);
|
|
198
|
+
if (beanInstance) {
|
|
199
|
+
// sync
|
|
200
|
+
return this._renderEventActionNormal_inner(beanInstance, actionChild, celScope, renderContext, next);
|
|
201
|
+
}
|
|
202
|
+
// async
|
|
203
|
+
const transientObject = this.transientObject;
|
|
204
|
+
return this.sys.bean._getBean(beanFullName, false).then(beanInstance => {
|
|
205
|
+
return this.setTransientObject(transientObject, () => {
|
|
206
|
+
return this._renderEventActionNormal_inner(beanInstance, actionChild, celScope, renderContext, next);
|
|
207
|
+
});
|
|
208
|
+
});
|
|
209
|
+
}
|
|
210
|
+
_renderEventActionNormal_inner(beanInstance, actionChild, celScope, renderContext, next) {
|
|
211
|
+
const onionOptions = beanInstance.$onionOptions;
|
|
212
|
+
// props
|
|
213
|
+
let props = this.renderJsxProps(actionChild.props, {}, celScope, renderContext);
|
|
214
|
+
if (onionOptions) {
|
|
215
|
+
props = deepExtend({}, onionOptions, props);
|
|
216
|
+
}
|
|
217
|
+
if (!renderContext) throw new Error('should provide renderContext');
|
|
218
|
+
return beanInstance.execute(props, renderContext, next);
|
|
219
|
+
}
|
|
220
|
+
render(componentOptions, props, celScope, renderContext) {
|
|
221
|
+
props = props ?? {};
|
|
222
|
+
componentOptions = this.normalizeComponenOptions(componentOptions);
|
|
223
|
+
// vIf
|
|
224
|
+
const vIf = this.evaluateExpression(componentOptions.props?.['v-if'], celScope);
|
|
225
|
+
if (vIf === false) return;
|
|
226
|
+
// component
|
|
227
|
+
const Component = this.normalizeComponent(componentOptions.type);
|
|
228
|
+
// vFor
|
|
229
|
+
const vFor = this.evaluateExpression(componentOptions.props?.['v-for'], celScope);
|
|
230
|
+
if (!vFor) return this._renderJsxSingle(Component, componentOptions, props, celScope, renderContext);
|
|
231
|
+
const children = [];
|
|
232
|
+
for (let index = 0; index < vFor.length; index++) {
|
|
233
|
+
const each = vFor[index];
|
|
234
|
+
const eachName = this.evaluateExpression(componentOptions.props?.['v-each'], celScope) ?? 'each';
|
|
235
|
+
const celScopeEach = objectAssignReactive({}, celScope, {
|
|
236
|
+
[eachName]: each,
|
|
237
|
+
[`${eachName}Index`]: index
|
|
238
|
+
});
|
|
239
|
+
const propsEach = {
|
|
240
|
+
...props
|
|
241
|
+
};
|
|
242
|
+
const child = this._renderJsxSingle(Component, componentOptions, propsEach, celScopeEach, renderContext);
|
|
243
|
+
if (child) {
|
|
244
|
+
children.push(child);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
return children;
|
|
248
|
+
}
|
|
249
|
+
normalizeComponenOptions(componentOptions) {
|
|
250
|
+
if (typeof componentOptions === 'object') return componentOptions;
|
|
251
|
+
return {
|
|
252
|
+
type: componentOptions
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
normalizeComponent(type) {
|
|
256
|
+
if (typeof type === 'function') return type;
|
|
257
|
+
if (typeof type === 'string') {
|
|
258
|
+
type = this.components?.[type] ?? type;
|
|
259
|
+
}
|
|
260
|
+
if (typeof type === 'string' && ['script', 'style', 'link'].includes(type)) {
|
|
261
|
+
throw new Error(`not valid zova jsx component: ${type}`);
|
|
262
|
+
}
|
|
263
|
+
// div/QInput/Zova Component
|
|
264
|
+
return type;
|
|
265
|
+
}
|
|
266
|
+
normalizeAction(type) {
|
|
267
|
+
return this.actions?.[type] ?? type;
|
|
268
|
+
}
|
|
269
|
+
_renderJsxSingle(Component, componentOptions, props, celScope, renderContext) {
|
|
270
|
+
const _isZovaComponent = isZovaComponent(Component);
|
|
271
|
+
// key
|
|
272
|
+
if (!cast(props).key && componentOptions.key) {
|
|
273
|
+
cast(props).key = this.evaluateExpression(componentOptions.key, celScope);
|
|
274
|
+
}
|
|
275
|
+
// props
|
|
276
|
+
this.renderJsxProps(componentOptions.props, props, celScope, renderContext);
|
|
277
|
+
// children
|
|
278
|
+
let children;
|
|
279
|
+
const propsChildren = componentOptions.props?.children;
|
|
280
|
+
if (!propsChildren) {
|
|
281
|
+
children = undefined;
|
|
282
|
+
} else {
|
|
283
|
+
if (isNativeElement(Component)) {
|
|
284
|
+
children = this.renderJsxChildrenDirect(componentOptions.props.children, celScope, renderContext);
|
|
285
|
+
} else {
|
|
286
|
+
const childrenCollect = this._renderJsxChildrenCollect(componentOptions.props.children, celScope, renderContext);
|
|
287
|
+
if (_isZovaComponent) {
|
|
288
|
+
for (const key in childrenCollect) {
|
|
289
|
+
const slot = childrenCollect[key];
|
|
290
|
+
if (key === 'default') {
|
|
291
|
+
children = slot;
|
|
292
|
+
} else {
|
|
293
|
+
props[`slot${toUpperCaseFirstChar(key)}`] = slot;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
} else {
|
|
297
|
+
children = childrenCollect;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
if (_isZovaComponent) {
|
|
302
|
+
Component = this.sys.meta.component.getZovaComponent(Component);
|
|
303
|
+
}
|
|
304
|
+
const vnode = h(Component, props, children);
|
|
305
|
+
if (_isZovaComponent && renderContext) {
|
|
306
|
+
cast(vnode).zovaHostProviders = {
|
|
307
|
+
$$renderContext: renderContext
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
return vnode;
|
|
311
|
+
}
|
|
312
|
+
renderJsxProps(jsxProps, props, celScope, renderContext) {
|
|
313
|
+
if (!jsxProps) return props;
|
|
314
|
+
const keys = Object.keys(jsxProps).filter(item => !renderFieldJsxPropsSystem.includes(item));
|
|
315
|
+
if (keys.length === 0) return props;
|
|
316
|
+
for (const key of keys) {
|
|
317
|
+
let keyValue = this.renderJsxOrCel(jsxProps[key], undefined, celScope, renderContext);
|
|
318
|
+
const propName = normalizePropName(key);
|
|
319
|
+
if (propName === 'class') {
|
|
320
|
+
keyValue = classes(props[propName], keyValue);
|
|
321
|
+
}
|
|
322
|
+
props[propName] = keyValue;
|
|
323
|
+
}
|
|
324
|
+
return props;
|
|
325
|
+
}
|
|
326
|
+
_renderJsxChildrenCollect(jsxChildren, celScope, renderContext) {
|
|
327
|
+
if (!Array.isArray(jsxChildren)) jsxChildren = [jsxChildren];
|
|
328
|
+
const children = [];
|
|
329
|
+
const slots = {};
|
|
330
|
+
const transientObject = this.transientObject;
|
|
331
|
+
for (const jsxChild of jsxChildren) {
|
|
332
|
+
if (jsxChild && typeof jsxChild === 'object' && jsxChild.props?.['v-slot']) {
|
|
333
|
+
const slotName = jsxChild.props?.['v-slot'];
|
|
334
|
+
const slotScopeName = jsxChild.props?.['v-slot-scope'];
|
|
335
|
+
let slot;
|
|
336
|
+
if (slotScopeName) {
|
|
337
|
+
slot = slotScope => {
|
|
338
|
+
return this.setTransientObject(transientObject, () => {
|
|
339
|
+
const celScopeSub = objectAssignReactive({}, celScope, {
|
|
340
|
+
[slotScopeName]: slotScope
|
|
341
|
+
});
|
|
342
|
+
return this.renderJsxChildrenDirect(jsxChild, celScopeSub, renderContext);
|
|
343
|
+
});
|
|
344
|
+
};
|
|
345
|
+
} else {
|
|
346
|
+
slot = () => {
|
|
347
|
+
return this.setTransientObject(transientObject, () => {
|
|
348
|
+
return this.renderJsxChildrenDirect(jsxChild, celScope, renderContext);
|
|
349
|
+
});
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
slots[slotName] = slot;
|
|
353
|
+
} else {
|
|
354
|
+
children.push(jsxChild);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
// slotDefault
|
|
358
|
+
const slotDefault = children.length === 0 ? undefined : () => {
|
|
359
|
+
return this.setTransientObject(transientObject, () => {
|
|
360
|
+
return this.renderJsxChildrenDirect(children, celScope, renderContext);
|
|
361
|
+
});
|
|
362
|
+
};
|
|
363
|
+
// ok
|
|
364
|
+
return {
|
|
365
|
+
...slots,
|
|
366
|
+
default: slotDefault
|
|
367
|
+
};
|
|
368
|
+
}
|
|
369
|
+
renderJsxChildrenDirect(jsxChildren, celScope, renderContext) {
|
|
370
|
+
if (!Array.isArray(jsxChildren)) jsxChildren = [jsxChildren];
|
|
371
|
+
const children = [];
|
|
372
|
+
for (const jsxChild of jsxChildren) {
|
|
373
|
+
let child;
|
|
374
|
+
if (isJsxComponent(jsxChild)) {
|
|
375
|
+
if (jsxChild.type === 'var') {
|
|
376
|
+
const props = this.renderJsxProps(jsxChild.props, {}, celScope, renderContext);
|
|
377
|
+
celScope = objectAssignReactive({}, celScope, {
|
|
378
|
+
[cast(props).name]: cast(props).value
|
|
379
|
+
});
|
|
380
|
+
child = undefined;
|
|
381
|
+
} else {
|
|
382
|
+
child = this.render(jsxChild, undefined, celScope, renderContext);
|
|
383
|
+
}
|
|
384
|
+
} else {
|
|
385
|
+
const childText = this.evaluateExpression(jsxChild, celScope);
|
|
386
|
+
child = createTextVNode(childText ?? '');
|
|
387
|
+
}
|
|
388
|
+
if (child) {
|
|
389
|
+
if (Array.isArray(child)) {
|
|
390
|
+
children.push(...child);
|
|
391
|
+
} else {
|
|
392
|
+
children.push(child);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
}
|
|
396
|
+
return children;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
export { ZovaJsx, invokeProp, isJsxComponent, isJsxEvent, isLegacyComponent, isNativeElement, isZovaComponent, normalizePropName, renderFieldJsxPropsSystem };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const renderFieldJsxPropsSystem: string[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export declare function isNativeElement(Component: any): boolean;
|
|
2
|
+
export declare function isZovaComponent(Component: any): boolean;
|
|
3
|
+
export declare function isLegacyComponent(Component: any): boolean;
|
|
4
|
+
export declare function isJsxComponent(Component: any): boolean;
|
|
5
|
+
export declare function isJsxEvent(Component: any): boolean;
|
|
6
|
+
export declare function invokeProp(prop: any): any;
|
|
7
|
+
export declare function normalizePropName(name: string): any;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { VNode } from 'vue';
|
|
2
|
+
import { celEnvBase } from '@cabloy/utils';
|
|
3
|
+
import { BeanSimple } from 'zova-core';
|
|
4
|
+
import type { IFormProviderComponents, TypeRenderComponent, TypeRenderComponentJsx, TypeRenderComponentJsxProps } from '../types/rest.ts';
|
|
5
|
+
type CelEnv = typeof celEnvBase;
|
|
6
|
+
export declare class ZovaJsx extends BeanSimple {
|
|
7
|
+
private _components;
|
|
8
|
+
private _actions;
|
|
9
|
+
private _celEnv;
|
|
10
|
+
private _transientObject;
|
|
11
|
+
constructor(components?: IFormProviderComponents, actions?: Record<string, string>, celEnv?: CelEnv);
|
|
12
|
+
private _prepareCelEnv;
|
|
13
|
+
setTransientObject<T>(transientObject: {} | undefined, fnMethod: () => T): T;
|
|
14
|
+
get transientObject(): any;
|
|
15
|
+
get event(): Event | undefined;
|
|
16
|
+
get components(): IFormProviderComponents | undefined;
|
|
17
|
+
get actions(): Record<string, string> | undefined;
|
|
18
|
+
get celEnv(): CelEnv;
|
|
19
|
+
evaluateExpression(expression: any, celScope?: {}): any;
|
|
20
|
+
renderJsxOrCel(componentOptions: TypeRenderComponent | any, props: {} | undefined, celScope: {}, renderContext: {}): any;
|
|
21
|
+
renderEvent(event: Event, componentOptions: TypeRenderComponentJsx, celScope: {}, renderContext: {}): any;
|
|
22
|
+
renderEventDirect(componentOptions: TypeRenderComponentJsx, celScope: {}, renderContext: {}, eventRes: any[], next?: Function): any;
|
|
23
|
+
private _collectEventActions;
|
|
24
|
+
private _actionHandler;
|
|
25
|
+
private _renderEventActionNormal;
|
|
26
|
+
private _renderEventActionNormal_inner;
|
|
27
|
+
render(componentOptions: TypeRenderComponent, props: {} | undefined, celScope: {}, renderContext: {}): VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
28
|
+
[key: string]: any;
|
|
29
|
+
}> | VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
30
|
+
[key: string]: any;
|
|
31
|
+
}>[] | undefined;
|
|
32
|
+
normalizeComponenOptions(componentOptions: TypeRenderComponent): TypeRenderComponentJsx;
|
|
33
|
+
normalizeComponent(type: TypeRenderComponent): TypeRenderComponent;
|
|
34
|
+
normalizeAction(type: string): string;
|
|
35
|
+
private _renderJsxSingle;
|
|
36
|
+
renderJsxProps(jsxProps: TypeRenderComponentJsxProps | undefined, props: {}, celScope: {}, renderContext: {}): {};
|
|
37
|
+
private _renderJsxChildrenCollect;
|
|
38
|
+
renderJsxChildrenDirect(jsxChildren: TypeRenderComponentJsx | TypeRenderComponentJsx[], celScope: {}, renderContext: {}): VNode<import("vue").RendererNode, import("vue").RendererElement, {
|
|
39
|
+
[key: string]: any;
|
|
40
|
+
}>[];
|
|
41
|
+
}
|
|
42
|
+
export {};
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,16 +1 @@
|
|
|
1
|
-
|
|
2
|
-
export type TypeOpenapiConfigMatchRule = string | RegExp | (string | RegExp)[];
|
|
3
|
-
export interface ZovaOpenapiConfigModuleBase {
|
|
4
|
-
source?: string;
|
|
5
|
-
options?: OpenAPITSOptions;
|
|
6
|
-
}
|
|
7
|
-
export interface ZovaOpenapiConfigModule extends ZovaOpenapiConfigModuleBase {
|
|
8
|
-
operations?: {
|
|
9
|
-
match?: TypeOpenapiConfigMatchRule;
|
|
10
|
-
ignore?: TypeOpenapiConfigMatchRule;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
export interface ZovaOpenapiConfig {
|
|
14
|
-
default?: ZovaOpenapiConfigModuleBase;
|
|
15
|
-
modules: Record<string, ZovaOpenapiConfigModule>;
|
|
16
|
-
}
|
|
1
|
+
export * from './rest.ts';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ComponentPublicInstance } from 'vue';
|
|
2
|
+
import type { Constructable, IComponentIntrinsicAttributes } from 'zova-core';
|
|
3
|
+
export interface TypeRenderComponentJsxPropsPublic extends IComponentIntrinsicAttributes {
|
|
4
|
+
'key'?: string;
|
|
5
|
+
'v-if'?: string | boolean;
|
|
6
|
+
'v-for'?: string | any[];
|
|
7
|
+
'v-each'?: string;
|
|
8
|
+
'v-slot'?: string;
|
|
9
|
+
'v-slot-scope'?: string;
|
|
10
|
+
'children'?: any;
|
|
11
|
+
}
|
|
12
|
+
export interface TypeRenderComponentJsxProps extends TypeRenderComponentJsxPropsPublic {
|
|
13
|
+
children: TypeRenderComponentJsx | TypeRenderComponentJsx[];
|
|
14
|
+
}
|
|
15
|
+
export interface TypeRenderComponentJsx {
|
|
16
|
+
type: string;
|
|
17
|
+
key?: string | null;
|
|
18
|
+
props?: TypeRenderComponentJsxProps;
|
|
19
|
+
}
|
|
20
|
+
export type TypeRenderComponentNormal = Constructable<ComponentPublicInstance> | string;
|
|
21
|
+
export type TypeRenderComponent = TypeRenderComponentNormal | TypeRenderComponentJsx;
|
|
22
|
+
export interface IFormProviderComponents {
|
|
23
|
+
}
|
package/package.json
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "zova-jsx",
|
|
3
|
-
"
|
|
4
|
-
"version": "1.0.0",
|
|
3
|
+
"version": "1.1.1",
|
|
5
4
|
"description": "Zova JSX",
|
|
6
|
-
"
|
|
7
|
-
"
|
|
5
|
+
"keywords": [
|
|
6
|
+
"ioc",
|
|
7
|
+
"vue3",
|
|
8
|
+
"zova"
|
|
9
|
+
],
|
|
10
|
+
"homepage": "https://github.com/cabloy/zova#readme",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/cabloy/zova/issues"
|
|
8
13
|
},
|
|
9
|
-
"author": "zhennann",
|
|
10
14
|
"license": "MIT",
|
|
11
|
-
"
|
|
15
|
+
"author": "zhennann",
|
|
12
16
|
"repository": {
|
|
13
17
|
"type": "git",
|
|
14
18
|
"url": "git+https://github.com/cabloy/zova.git"
|
|
15
19
|
},
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
},
|
|
19
|
-
"keywords": [
|
|
20
|
-
"vue3",
|
|
21
|
-
"ioc",
|
|
22
|
-
"zova"
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
23
22
|
],
|
|
23
|
+
"type": "module",
|
|
24
24
|
"exports": {
|
|
25
25
|
".": {
|
|
26
26
|
"types": [
|
|
@@ -31,18 +31,23 @@
|
|
|
31
31
|
},
|
|
32
32
|
"./package.json": "./package.json"
|
|
33
33
|
},
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
|
|
34
|
+
"publishConfig": {
|
|
35
|
+
"access": "public"
|
|
36
|
+
},
|
|
37
37
|
"scripts": {
|
|
38
|
-
"lint": "eslint .",
|
|
39
38
|
"clean": "rimraf dist tsconfig.tsbuildinfo",
|
|
40
|
-
"tsc:publish": "npm run clean && tsc",
|
|
39
|
+
"tsc:publish": "npm run clean && vona :bin:buildGeneral && tsc",
|
|
41
40
|
"prepublishOnly": "npm run tsc:publish",
|
|
42
41
|
"prepack": "clean-package",
|
|
43
42
|
"postpack": "clean-package restore"
|
|
44
43
|
},
|
|
45
44
|
"dependencies": {
|
|
46
|
-
"@cabloy/
|
|
47
|
-
|
|
45
|
+
"@cabloy/compose": "^2.0.4",
|
|
46
|
+
"@cabloy/utils": "^2.0.23",
|
|
47
|
+
"@cabloy/word-utils": "^2.1.1",
|
|
48
|
+
"typestyle": "^2.4.0",
|
|
49
|
+
"vue": "^3.5.6",
|
|
50
|
+
"zova-core": "^5.1.1"
|
|
51
|
+
},
|
|
52
|
+
"gitHead": "a1b13b06e259e4447ab2f361ec76941810bc4ad7"
|
|
48
53
|
}
|
package/dist/types/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|