@ibiz-template/vue3-util 0.0.4-beta.1 → 0.0.4-beta.3
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.esm.js +552 -0
- package/dist/index.system.min.js +1 -0
- package/out/index.d.ts +1 -0
- package/out/index.d.ts.map +1 -1
- package/out/index.js +1 -0
- package/out/interface/util/route/route.d.ts +5 -13
- package/out/interface/util/route/route.d.ts.map +1 -1
- package/out/props/common.d.ts +19 -0
- package/out/props/common.d.ts.map +1 -0
- package/out/props/common.js +23 -0
- package/out/props/editor/common.d.ts +71 -0
- package/out/props/editor/common.d.ts.map +1 -0
- package/out/props/editor/common.js +77 -0
- package/out/props/editor/index.d.ts +3 -0
- package/out/props/editor/index.d.ts.map +1 -0
- package/out/props/editor/index.js +2 -0
- package/out/props/editor/text-box.d.ts +160 -0
- package/out/props/editor/text-box.d.ts.map +1 -0
- package/out/props/editor/text-box.js +73 -0
- package/out/props/index.d.ts +3 -0
- package/out/props/index.d.ts.map +1 -0
- package/out/props/index.js +2 -0
- package/out/use/index.d.ts +2 -0
- package/out/use/index.d.ts.map +1 -1
- package/out/use/index.js +2 -0
- package/out/use/view/index.d.ts +2 -0
- package/out/use/view/index.d.ts.map +1 -0
- package/out/use/view/index.js +1 -0
- package/out/use/view/use-view-controller/use-view-controller.d.ts +14 -0
- package/out/use/view/use-view-controller/use-view-controller.d.ts.map +1 -0
- package/out/use/view/use-view-controller/use-view-controller.js +36 -0
- package/out/use/widgets/index.d.ts +2 -0
- package/out/use/widgets/index.d.ts.map +1 -0
- package/out/use/widgets/index.js +1 -0
- package/out/use/widgets/use-control-controller/use-control-controller.d.ts +13 -0
- package/out/use/widgets/use-control-controller/use-control-controller.d.ts.map +1 -0
- package/out/use/widgets/use-control-controller/use-control-controller.js +28 -0
- package/out/util/route/route-listener.d.ts.map +1 -1
- package/out/util/route/route-listener.js +1 -2
- package/out/util/route/route.d.ts +1 -1
- package/out/util/route/route.d.ts.map +1 -1
- package/out/util/route/route.js +8 -5
- package/package.json +12 -12
- package/src/index.ts +1 -0
- package/src/interface/util/route/route.ts +6 -14
- package/src/props/common.ts +30 -0
- package/src/props/editor/common.ts +83 -0
- package/src/props/editor/index.ts +2 -0
- package/src/props/editor/text-box.ts +79 -0
- package/src/props/index.ts +2 -0
- package/src/use/index.ts +2 -0
- package/src/use/view/index.ts +1 -0
- package/src/use/view/use-view-controller/use-view-controller.ts +43 -0
- package/src/use/widgets/index.ts +1 -0
- package/src/use/widgets/use-control-controller/use-control-controller.ts +35 -0
- package/src/util/route/route-listener.ts +1 -2
- package/src/util/route/route.ts +9 -7
- package/dist/system/index.system.js +0 -1
|
@@ -0,0 +1,552 @@
|
|
|
1
|
+
// src/use/namespace/namespace.ts
|
|
2
|
+
import { Namespace } from "@ibiz-template/core";
|
|
3
|
+
function useNamespace(block) {
|
|
4
|
+
return new Namespace(block, ibiz.env.namespace);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
// src/use/route/route.ts
|
|
8
|
+
import { useRoute } from "vue-router";
|
|
9
|
+
import { ref, watch as watch2 } from "vue";
|
|
10
|
+
|
|
11
|
+
// src/util/route/route.ts
|
|
12
|
+
import { notNilEmpty } from "qx-util";
|
|
13
|
+
import { RuntimeError } from "@ibiz-template/core";
|
|
14
|
+
import qs from "qs";
|
|
15
|
+
function getOwnRouteContext(context) {
|
|
16
|
+
const ownContext = context.getOwnContext();
|
|
17
|
+
const excludeKeys = ["srfsessionid"];
|
|
18
|
+
Object.keys(ownContext).forEach((key) => {
|
|
19
|
+
if (excludeKeys.includes(key)) {
|
|
20
|
+
delete ownContext[key];
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
return ownContext;
|
|
24
|
+
}
|
|
25
|
+
function generateRoutePath(appView, route, context, params) {
|
|
26
|
+
const routePath = route2routePath(route);
|
|
27
|
+
let level = 2;
|
|
28
|
+
if (context.toRouteLevel) {
|
|
29
|
+
level = context.toRouteLevel;
|
|
30
|
+
delete context.toRouteLevel;
|
|
31
|
+
}
|
|
32
|
+
routePath.pathNodes.splice(level - 1, routePath.pathNodes.length - level + 1);
|
|
33
|
+
if (context.currentSrfNav) {
|
|
34
|
+
const currentNode = routePath.pathNodes[routePath.pathNodes.length - 1];
|
|
35
|
+
currentNode.params = currentNode.params || {};
|
|
36
|
+
currentNode.params.srfnav = context.currentSrfNav;
|
|
37
|
+
delete context.currentSrfNav;
|
|
38
|
+
}
|
|
39
|
+
if (route.fullPath.startsWith("/appredirectview")) {
|
|
40
|
+
if (params == null ? void 0 : params.srfindexname) {
|
|
41
|
+
routePath.pathNodes[0].viewName = params.srfindexname;
|
|
42
|
+
delete params.srfindexname;
|
|
43
|
+
} else {
|
|
44
|
+
routePath.pathNodes[0].viewName = "index";
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
routePath.pathNodes.push({
|
|
48
|
+
viewName: appView.codeName.toLowerCase(),
|
|
49
|
+
context: getOwnRouteContext(context),
|
|
50
|
+
params
|
|
51
|
+
});
|
|
52
|
+
return { path: routePath2string(routePath) };
|
|
53
|
+
}
|
|
54
|
+
function getViewName(model) {
|
|
55
|
+
return model.codeName.toLowerCase();
|
|
56
|
+
}
|
|
57
|
+
function findViewByName(_appModel, _viewCodeName) {
|
|
58
|
+
return void 0;
|
|
59
|
+
}
|
|
60
|
+
function findView(_appModel, _viewCodeName) {
|
|
61
|
+
return void 0;
|
|
62
|
+
}
|
|
63
|
+
async function parseRouteViewData(route, level) {
|
|
64
|
+
var _a;
|
|
65
|
+
const routePath = route2routePath(route);
|
|
66
|
+
let viewCodeName = routePath.pathNodes[level - 1].viewName;
|
|
67
|
+
if (!viewCodeName) {
|
|
68
|
+
throw new RuntimeError(`\u7B2C${level}\u7EA7\u8DEF\u7531\u4E0D\u5B58\u5728\u89C6\u56FE\u6807\u8BC6`);
|
|
69
|
+
}
|
|
70
|
+
if (viewCodeName === "index") {
|
|
71
|
+
viewCodeName = ibiz.hub.defaultAppIndexViewName;
|
|
72
|
+
}
|
|
73
|
+
const viewModel = await ibiz.hub.getAppView(viewCodeName);
|
|
74
|
+
if (!viewModel) {
|
|
75
|
+
throw new RuntimeError(`\u627E\u4E0D\u5230\u89C6\u56FE${viewCodeName}`);
|
|
76
|
+
}
|
|
77
|
+
const context = {};
|
|
78
|
+
if ((_a = ibiz.appData) == null ? void 0 : _a.context) {
|
|
79
|
+
Object.assign(context, ibiz.appData.context);
|
|
80
|
+
}
|
|
81
|
+
if (routePath.appContext) {
|
|
82
|
+
Object.assign(context, routePath.appContext);
|
|
83
|
+
}
|
|
84
|
+
for (let index = 0; index < level; index++) {
|
|
85
|
+
const pathNode = routePath.pathNodes[index];
|
|
86
|
+
if (notNilEmpty(pathNode.context)) {
|
|
87
|
+
Object.assign(context, pathNode.context);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
const { params, srfnav } = routePath.pathNodes[level - 1];
|
|
91
|
+
return {
|
|
92
|
+
viewModel,
|
|
93
|
+
context,
|
|
94
|
+
params,
|
|
95
|
+
srfnav
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
function route2routePath(route) {
|
|
99
|
+
const level = route.matched.length;
|
|
100
|
+
const pathNodes = [];
|
|
101
|
+
for (let index = 1; index <= level; index++) {
|
|
102
|
+
const viewName = route.params[`view${index}`];
|
|
103
|
+
const paramsStr = route.params[`params${index}`];
|
|
104
|
+
let params;
|
|
105
|
+
let context;
|
|
106
|
+
let srfnav;
|
|
107
|
+
if (!paramsStr || paramsStr === ibiz.env.routePlaceholder) {
|
|
108
|
+
params = void 0;
|
|
109
|
+
} else {
|
|
110
|
+
params = qs.parse(paramsStr, {
|
|
111
|
+
strictNullHandling: true,
|
|
112
|
+
delimiter: ";"
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
if (params) {
|
|
116
|
+
if (index === 1) {
|
|
117
|
+
context = params;
|
|
118
|
+
params = void 0;
|
|
119
|
+
} else {
|
|
120
|
+
if (params.srfnavctx) {
|
|
121
|
+
context = JSON.parse(decodeURIComponent(params.srfnavctx));
|
|
122
|
+
delete params.srfnavctx;
|
|
123
|
+
}
|
|
124
|
+
if (params.srfnav) {
|
|
125
|
+
srfnav = params.srfnav;
|
|
126
|
+
delete params.srfnav;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
pathNodes.push({ viewName, context, params, srfnav });
|
|
131
|
+
}
|
|
132
|
+
let appContext;
|
|
133
|
+
if (route.params.appContext && route.params.appContext !== ibiz.env.routePlaceholder) {
|
|
134
|
+
appContext = qs.parse(route.params.appContext, {
|
|
135
|
+
strictNullHandling: true,
|
|
136
|
+
delimiter: ";"
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
return { appContext, pathNodes };
|
|
140
|
+
}
|
|
141
|
+
function routePath2string(routePath) {
|
|
142
|
+
let pathStr = "";
|
|
143
|
+
if (routePath.appContext) {
|
|
144
|
+
pathStr += `/${qs.stringify(routePath.appContext, {
|
|
145
|
+
delimiter: ";",
|
|
146
|
+
strictNullHandling: true
|
|
147
|
+
})}`;
|
|
148
|
+
} else {
|
|
149
|
+
pathStr += `/${ibiz.env.routePlaceholder}`;
|
|
150
|
+
}
|
|
151
|
+
routePath.pathNodes.forEach((pathNode, index) => {
|
|
152
|
+
pathStr += `/${pathNode.viewName}/`;
|
|
153
|
+
let routeParams;
|
|
154
|
+
if (index === 0) {
|
|
155
|
+
if (notNilEmpty(pathNode.context)) {
|
|
156
|
+
routeParams = pathNode.context;
|
|
157
|
+
}
|
|
158
|
+
} else {
|
|
159
|
+
routeParams = notNilEmpty(pathNode.params) ? pathNode.params : {};
|
|
160
|
+
if (notNilEmpty(pathNode.context)) {
|
|
161
|
+
const objStr = JSON.stringify(pathNode.context);
|
|
162
|
+
if (objStr !== "{}") {
|
|
163
|
+
routeParams.srfnavctx = encodeURIComponent(objStr);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
pathStr += qs.stringify(routeParams, { delimiter: ";", strictNullHandling: true }) || ibiz.env.routePlaceholder;
|
|
168
|
+
});
|
|
169
|
+
return pathStr;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
// src/util/route/route-listener.ts
|
|
173
|
+
import { watch } from "vue";
|
|
174
|
+
var RouteListener = class {
|
|
175
|
+
constructor(route, wait) {
|
|
176
|
+
/**
|
|
177
|
+
* 回调集合
|
|
178
|
+
*
|
|
179
|
+
* @memberof RouteListener
|
|
180
|
+
*/
|
|
181
|
+
this.callbacks = [];
|
|
182
|
+
/**
|
|
183
|
+
* 计时器集合
|
|
184
|
+
*
|
|
185
|
+
* @private
|
|
186
|
+
* @type {any[]}
|
|
187
|
+
* @memberof RouteListener
|
|
188
|
+
*/
|
|
189
|
+
this.timers = [];
|
|
190
|
+
/**
|
|
191
|
+
* 等待路由响应时间
|
|
192
|
+
*
|
|
193
|
+
* @private
|
|
194
|
+
* @type {number}
|
|
195
|
+
* @memberof RouteListener
|
|
196
|
+
*/
|
|
197
|
+
this.wait = 500;
|
|
198
|
+
if (wait) {
|
|
199
|
+
this.wait = wait;
|
|
200
|
+
}
|
|
201
|
+
watch(
|
|
202
|
+
() => route.path,
|
|
203
|
+
(newVal, oldVal) => {
|
|
204
|
+
if (newVal !== oldVal) {
|
|
205
|
+
if (this.callbacks.length) {
|
|
206
|
+
for (let index = 0; index < this.callbacks.length; index++) {
|
|
207
|
+
const fn = this.callbacks[index];
|
|
208
|
+
fn();
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
this.callbacks = [];
|
|
212
|
+
if (this.timers.length) {
|
|
213
|
+
for (let index = 0; index < this.timers.length; index++) {
|
|
214
|
+
const timer = this.timers[index];
|
|
215
|
+
clearTimeout(timer);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
this.timers = [];
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* 下一次路由变更后执行回调,只执行一次
|
|
225
|
+
*
|
|
226
|
+
* @param {ChangeCallback} callback
|
|
227
|
+
* @memberof RouteListener
|
|
228
|
+
*/
|
|
229
|
+
nextChange(callback) {
|
|
230
|
+
if (callback) {
|
|
231
|
+
this.timers.push(
|
|
232
|
+
setTimeout(() => {
|
|
233
|
+
callback();
|
|
234
|
+
const index = this.callbacks.findIndex((item) => item === callback);
|
|
235
|
+
this.callbacks.splice(index, 1);
|
|
236
|
+
}, this.wait)
|
|
237
|
+
);
|
|
238
|
+
this.callbacks.push(callback);
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
// src/use/route/route.ts
|
|
244
|
+
function useRouterQuery() {
|
|
245
|
+
const route = useRoute();
|
|
246
|
+
const { query } = route;
|
|
247
|
+
return query;
|
|
248
|
+
}
|
|
249
|
+
function useRouteKey(originKey, route, routeKey) {
|
|
250
|
+
if (!routeKey) {
|
|
251
|
+
routeKey = ref("");
|
|
252
|
+
}
|
|
253
|
+
routeKey.value = originKey.value;
|
|
254
|
+
const routeListener = new RouteListener(route);
|
|
255
|
+
watch2(originKey, (newVal, oldVal) => {
|
|
256
|
+
if (newVal !== oldVal) {
|
|
257
|
+
routeListener.nextChange(() => {
|
|
258
|
+
routeKey.value = newVal;
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
});
|
|
262
|
+
return routeKey;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
// src/use/vue/vue.ts
|
|
266
|
+
import { isFunc } from "qx-util";
|
|
267
|
+
import {
|
|
268
|
+
createCommentVNode,
|
|
269
|
+
getCurrentInstance,
|
|
270
|
+
isReactive,
|
|
271
|
+
toRaw,
|
|
272
|
+
watch as watch3
|
|
273
|
+
} from "vue";
|
|
274
|
+
function useProps() {
|
|
275
|
+
const vue = getCurrentInstance().proxy;
|
|
276
|
+
return vue.$props;
|
|
277
|
+
}
|
|
278
|
+
function getOrigin(val) {
|
|
279
|
+
return isReactive(val) ? toRaw(val) : val;
|
|
280
|
+
}
|
|
281
|
+
function usePropsWatch(key, callback, options) {
|
|
282
|
+
const props = useProps();
|
|
283
|
+
if (Object.prototype.hasOwnProperty.call(props, key)) {
|
|
284
|
+
watch3(
|
|
285
|
+
() => props[key],
|
|
286
|
+
(newVal, oldVal) => {
|
|
287
|
+
callback(getOrigin(newVal), getOrigin(oldVal));
|
|
288
|
+
},
|
|
289
|
+
options
|
|
290
|
+
);
|
|
291
|
+
callback(getOrigin(props[key]), void 0);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
function useForce() {
|
|
295
|
+
const vue = getCurrentInstance().proxy;
|
|
296
|
+
return (callback) => {
|
|
297
|
+
vue.$forceUpdate();
|
|
298
|
+
if (callback && isFunc(callback)) {
|
|
299
|
+
vue.$nextTick(() => {
|
|
300
|
+
callback();
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
};
|
|
304
|
+
}
|
|
305
|
+
function useForceTogether(vue, controller) {
|
|
306
|
+
const orignForce = controller.force;
|
|
307
|
+
const selfForce = useForce();
|
|
308
|
+
controller.force = (callback) => {
|
|
309
|
+
orignForce(callback);
|
|
310
|
+
selfForce();
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
function useController(controller) {
|
|
314
|
+
controller.force = useForce();
|
|
315
|
+
}
|
|
316
|
+
var EmptyVNode = createCommentVNode("EmptyVNode");
|
|
317
|
+
function isEmptyVNode(nodes) {
|
|
318
|
+
if (!Array.isArray(nodes)) {
|
|
319
|
+
return nodes === EmptyVNode;
|
|
320
|
+
}
|
|
321
|
+
return nodes.length === 1 && nodes[0] === EmptyVNode;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
// src/use/click-outside/click-outside.ts
|
|
325
|
+
import {
|
|
326
|
+
NOOP,
|
|
327
|
+
onClickOutside
|
|
328
|
+
} from "@ibiz-template/core";
|
|
329
|
+
import { isNil } from "ramda";
|
|
330
|
+
import { onBeforeUnmount, watch as watch4 } from "vue";
|
|
331
|
+
function useClickOutside(elRef, handler, options = {}) {
|
|
332
|
+
let stop = NOOP;
|
|
333
|
+
let pause = NOOP;
|
|
334
|
+
let proceed = NOOP;
|
|
335
|
+
const destroy = () => {
|
|
336
|
+
stop();
|
|
337
|
+
stop = NOOP;
|
|
338
|
+
pause = NOOP;
|
|
339
|
+
proceed = NOOP;
|
|
340
|
+
};
|
|
341
|
+
watch4(
|
|
342
|
+
elRef,
|
|
343
|
+
(newVal, oldVal) => {
|
|
344
|
+
if (newVal !== oldVal) {
|
|
345
|
+
if (isNil(newVal)) {
|
|
346
|
+
destroy();
|
|
347
|
+
} else {
|
|
348
|
+
const result = onClickOutside(
|
|
349
|
+
(newVal == null ? void 0 : newVal.$el) || newVal,
|
|
350
|
+
handler,
|
|
351
|
+
options
|
|
352
|
+
);
|
|
353
|
+
stop = result.stop;
|
|
354
|
+
pause = result.pause;
|
|
355
|
+
proceed = result.proceed;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
},
|
|
359
|
+
{ immediate: true }
|
|
360
|
+
);
|
|
361
|
+
onBeforeUnmount(() => {
|
|
362
|
+
if (stop !== NOOP) {
|
|
363
|
+
destroy();
|
|
364
|
+
}
|
|
365
|
+
});
|
|
366
|
+
return {
|
|
367
|
+
stop: () => stop(),
|
|
368
|
+
pause: () => pause(),
|
|
369
|
+
proceed: () => proceed()
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// src/use/event/event.ts
|
|
374
|
+
import { listenJSEvent, NOOP as NOOP2 } from "@ibiz-template/core";
|
|
375
|
+
import { isNil as isNil2 } from "ramda";
|
|
376
|
+
import { onBeforeUnmount as onBeforeUnmount2, watch as watch5 } from "vue";
|
|
377
|
+
function useEventListener(elRef, eventName, listener, options = {}) {
|
|
378
|
+
let cleanup = NOOP2;
|
|
379
|
+
watch5(
|
|
380
|
+
elRef,
|
|
381
|
+
(newVal, oldVal) => {
|
|
382
|
+
if (newVal !== oldVal) {
|
|
383
|
+
if (isNil2(newVal)) {
|
|
384
|
+
cleanup();
|
|
385
|
+
cleanup = NOOP2;
|
|
386
|
+
} else {
|
|
387
|
+
cleanup = listenJSEvent(
|
|
388
|
+
(newVal == null ? void 0 : newVal.$el) || newVal,
|
|
389
|
+
eventName,
|
|
390
|
+
listener,
|
|
391
|
+
options
|
|
392
|
+
);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
},
|
|
396
|
+
{ immediate: true }
|
|
397
|
+
);
|
|
398
|
+
onBeforeUnmount2(() => {
|
|
399
|
+
if (cleanup !== NOOP2) {
|
|
400
|
+
cleanup();
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
return () => {
|
|
404
|
+
cleanup();
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
// src/use/view/use-view-controller/use-view-controller.ts
|
|
409
|
+
import { inject, onBeforeUnmount as onBeforeUnmount3, provide, reactive } from "vue";
|
|
410
|
+
function useViewController(fn) {
|
|
411
|
+
const props = useProps();
|
|
412
|
+
const ctx = inject("ctx", void 0);
|
|
413
|
+
ctx == null ? void 0 : ctx.evt.emit("forecast", props.modelData.name);
|
|
414
|
+
const c = fn(props.modelData, props.context, props.params, ctx);
|
|
415
|
+
provide("ctx", c.ctx);
|
|
416
|
+
c.state = reactive(c.state);
|
|
417
|
+
if (props.modal) {
|
|
418
|
+
c.modal = props.modal;
|
|
419
|
+
}
|
|
420
|
+
c.force = useForce();
|
|
421
|
+
c.created();
|
|
422
|
+
onBeforeUnmount3(() => c.destroyed());
|
|
423
|
+
return c;
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
// src/use/widgets/use-control-controller/use-control-controller.ts
|
|
427
|
+
import { inject as inject2, onBeforeUnmount as onBeforeUnmount4, reactive as reactive2 } from "vue";
|
|
428
|
+
function useControlController(fn) {
|
|
429
|
+
const ctx = inject2("ctx");
|
|
430
|
+
const props = useProps();
|
|
431
|
+
ctx.evt.emit("forecast", props.modelData.name);
|
|
432
|
+
const c = fn(props.modelData, props.context, props.params, ctx);
|
|
433
|
+
c.state = reactive2(c.state);
|
|
434
|
+
c.force = useForce();
|
|
435
|
+
c.created();
|
|
436
|
+
onBeforeUnmount4(() => c.destroyed());
|
|
437
|
+
return c;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
// src/props/common.ts
|
|
441
|
+
var RequiredProp = class {
|
|
442
|
+
constructor(type, _default, validator) {
|
|
443
|
+
this.required = true;
|
|
444
|
+
if (_default) {
|
|
445
|
+
this.default = _default;
|
|
446
|
+
}
|
|
447
|
+
if (validator) {
|
|
448
|
+
this.validator = validator;
|
|
449
|
+
}
|
|
450
|
+
this.type = type;
|
|
451
|
+
}
|
|
452
|
+
};
|
|
453
|
+
|
|
454
|
+
// src/props/editor/common.ts
|
|
455
|
+
function getEditorProps() {
|
|
456
|
+
return {
|
|
457
|
+
value: String,
|
|
458
|
+
controller: new RequiredProp(Object),
|
|
459
|
+
data: new RequiredProp(Object),
|
|
460
|
+
disabled: {
|
|
461
|
+
type: Boolean
|
|
462
|
+
},
|
|
463
|
+
readonly: {
|
|
464
|
+
type: Boolean,
|
|
465
|
+
default: false
|
|
466
|
+
},
|
|
467
|
+
autoFocus: {
|
|
468
|
+
type: Boolean,
|
|
469
|
+
default: false
|
|
470
|
+
}
|
|
471
|
+
};
|
|
472
|
+
}
|
|
473
|
+
function getEditorEmits() {
|
|
474
|
+
return {
|
|
475
|
+
/** 值变更事件 */
|
|
476
|
+
change: (_value, _name) => true,
|
|
477
|
+
/** 是否正在操作事件 */
|
|
478
|
+
operate: (_isOperating) => true
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
function getGridEditorEmits() {
|
|
482
|
+
return {
|
|
483
|
+
/** 值变更事件 */
|
|
484
|
+
change: (_value, _name) => true,
|
|
485
|
+
/** 是否正在操作事件 */
|
|
486
|
+
rowSave: () => true
|
|
487
|
+
};
|
|
488
|
+
}
|
|
489
|
+
function getGridEditorCommonProps() {
|
|
490
|
+
return {
|
|
491
|
+
hasError: {
|
|
492
|
+
type: Boolean
|
|
493
|
+
}
|
|
494
|
+
};
|
|
495
|
+
}
|
|
496
|
+
|
|
497
|
+
// src/props/editor/text-box.ts
|
|
498
|
+
function getInputProps() {
|
|
499
|
+
return { ...getEditorProps(), value: String };
|
|
500
|
+
}
|
|
501
|
+
function getGridInputProps() {
|
|
502
|
+
return { ...getInputProps(), ...getGridEditorCommonProps() };
|
|
503
|
+
}
|
|
504
|
+
function getInputNumberProps() {
|
|
505
|
+
return { ...getEditorProps(), value: Number };
|
|
506
|
+
}
|
|
507
|
+
function getGridInputNumberProps() {
|
|
508
|
+
return { ...getInputNumberProps(), ...getGridEditorCommonProps() };
|
|
509
|
+
}
|
|
510
|
+
function getInputIpProps() {
|
|
511
|
+
return { ...getEditorProps(), value: String };
|
|
512
|
+
}
|
|
513
|
+
function getGridInputIpProps() {
|
|
514
|
+
return { ...getInputIpProps(), ...getGridEditorCommonProps() };
|
|
515
|
+
}
|
|
516
|
+
export {
|
|
517
|
+
EmptyVNode,
|
|
518
|
+
RequiredProp,
|
|
519
|
+
RouteListener,
|
|
520
|
+
findView,
|
|
521
|
+
findViewByName,
|
|
522
|
+
generateRoutePath,
|
|
523
|
+
getEditorEmits,
|
|
524
|
+
getEditorProps,
|
|
525
|
+
getGridEditorCommonProps,
|
|
526
|
+
getGridEditorEmits,
|
|
527
|
+
getGridInputIpProps,
|
|
528
|
+
getGridInputNumberProps,
|
|
529
|
+
getGridInputProps,
|
|
530
|
+
getInputIpProps,
|
|
531
|
+
getInputNumberProps,
|
|
532
|
+
getInputProps,
|
|
533
|
+
getOrigin,
|
|
534
|
+
getOwnRouteContext,
|
|
535
|
+
getViewName,
|
|
536
|
+
isEmptyVNode,
|
|
537
|
+
parseRouteViewData,
|
|
538
|
+
route2routePath,
|
|
539
|
+
routePath2string,
|
|
540
|
+
useClickOutside,
|
|
541
|
+
useControlController,
|
|
542
|
+
useController,
|
|
543
|
+
useEventListener,
|
|
544
|
+
useForce,
|
|
545
|
+
useForceTogether,
|
|
546
|
+
useNamespace,
|
|
547
|
+
useProps,
|
|
548
|
+
usePropsWatch,
|
|
549
|
+
useRouteKey,
|
|
550
|
+
useRouterQuery,
|
|
551
|
+
useViewController
|
|
552
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
System.register(["@ibiz-template/core","vue-router","vue","qx-util","qs","ramda"],(function(e){"use strict";var t,n,r,o,a,i,s,c,u,l,p,d,f,m,h,v,g,x,N,w;return{setters:[function(e){t=e.Namespace,n=e.RuntimeError,r=e.onClickOutside,o=e.NOOP,a=e.listenJSEvent},function(e){i=e.useRoute},function(e){s=e.createCommentVNode,c=e.watch,u=e.ref,l=e.getCurrentInstance,p=e.isReactive,d=e.toRaw,f=e.onBeforeUnmount,m=e.inject,h=e.provide,v=e.reactive},function(e){g=e.notNilEmpty,x=e.isFunc},function(e){N=e.default},function(e){w=e.isNil}],execute:function(){function b(e){const t=e.getOwnContext(),n=["srfsessionid"];return Object.keys(t).forEach((e=>{n.includes(e)&&delete t[e]})),t}function y(e){const t=e.matched.length,n=[];for(let r=1;r<=t;r++){const t=e.params[`view${r}`],o=e.params[`params${r}`];let a,i,s;a=o&&o!==ibiz.env.routePlaceholder?N.parse(o,{strictNullHandling:!0,delimiter:";"}):void 0,a&&(1===r?(i=a,a=void 0):(a.srfnavctx&&(i=JSON.parse(decodeURIComponent(a.srfnavctx)),delete a.srfnavctx),a.srfnav&&(s=a.srfnav,delete a.srfnav))),n.push({viewName:t,context:i,params:a,srfnav:s})}let r;return e.params.appContext&&e.params.appContext!==ibiz.env.routePlaceholder&&(r=N.parse(e.params.appContext,{strictNullHandling:!0,delimiter:";"})),{appContext:r,pathNodes:n}}function C(e){let t="";return e.appContext?t+=`/${N.stringify(e.appContext,{delimiter:";",strictNullHandling:!0})}`:t+=`/${ibiz.env.routePlaceholder}`,e.pathNodes.forEach(((e,n)=>{let r;if(t+=`/${e.viewName}/`,0===n)g(e.context)&&(r=e.context);else if(r=g(e.params)?e.params:{},g(e.context)){const t=JSON.stringify(e.context);"{}"!==t&&(r.srfnavctx=encodeURIComponent(t))}t+=N.stringify(r,{delimiter:";",strictNullHandling:!0})||ibiz.env.routePlaceholder})),t}e({findView:function(e,t){return},findViewByName:function(e,t){return},generateRoutePath:function(e,t,n,r){const o=y(t);let a=2;n.toRouteLevel&&(a=n.toRouteLevel,delete n.toRouteLevel);if(o.pathNodes.splice(a-1,o.pathNodes.length-a+1),n.currentSrfNav){const e=o.pathNodes[o.pathNodes.length-1];e.params=e.params||{},e.params.srfnav=n.currentSrfNav,delete n.currentSrfNav}t.fullPath.startsWith("/appredirectview")&&((null==r?void 0:r.srfindexname)?(o.pathNodes[0].viewName=r.srfindexname,delete r.srfindexname):o.pathNodes[0].viewName="index");return o.pathNodes.push({viewName:e.codeName.toLowerCase(),context:b(n),params:r}),{path:C(o)}},getEditorEmits:function(){return{change:(e,t)=>!0,operate:e=>!0}},getEditorProps:$,getGridEditorCommonProps:S,getGridEditorEmits:function(){return{change:(e,t)=>!0,rowSave:()=>!0}},getGridInputIpProps:function(){return{...j(),...S()}},getGridInputNumberProps:function(){return{...z(),...S()}},getGridInputProps:function(){return{...V(),...S()}},getInputIpProps:j,getInputNumberProps:z,getInputProps:V,getOrigin:E,getOwnRouteContext:b,getViewName:function(e){return e.codeName.toLowerCase()},isEmptyVNode:function(e){if(!Array.isArray(e))return e===I;return 1===e.length&&e[0]===I},parseRouteViewData:async function(e,t){var r;const o=y(e);let a=o.pathNodes[t-1].viewName;if(!a)throw new n(`第${t}级路由不存在视图标识`);"index"===a&&(a=ibiz.hub.defaultAppIndexViewName);const i=await ibiz.hub.getAppView(a);if(!i)throw new n(`找不到视图${a}`);const s={};(null==(r=ibiz.appData)?void 0:r.context)&&Object.assign(s,ibiz.appData.context);o.appContext&&Object.assign(s,o.appContext);for(let e=0;e<t;e++){const t=o.pathNodes[e];g(t.context)&&Object.assign(s,t.context)}const{params:c,srfnav:u}=o.pathNodes[t-1];return{viewModel:i,context:s,params:c,srfnav:u}},route2routePath:y,routePath2string:C,useClickOutside:function(e,t,n={}){let a=o,i=o,s=o;const u=()=>{a(),a=o,i=o,s=o};return c(e,((e,o)=>{if(e!==o)if(w(e))u();else{const o=r((null==e?void 0:e.$el)||e,t,n);a=o.stop,i=o.pause,s=o.proceed}}),{immediate:!0}),f((()=>{a!==o&&u()})),{stop:()=>a(),pause:()=>i(),proceed:()=>s()}},useControlController:function(e){const t=m("ctx"),n=O();t.evt.emit("forecast",n.modelData.name);const r=e(n.modelData,n.context,n.params,t);return r.state=v(r.state),r.force=R(),r.created(),f((()=>r.destroyed())),r},useController:function(e){e.force=R()},useEventListener:function(e,t,n,r={}){let i=o;return c(e,((e,s)=>{e!==s&&(w(e)?(i(),i=o):i=a((null==e?void 0:e.$el)||e,t,n,r))}),{immediate:!0}),f((()=>{i!==o&&i()})),()=>{i()}},useForce:R,useForceTogether:function(e,t){const n=t.force,r=R();t.force=e=>{n(e),r()}},useNamespace:function(e){return new t(e,ibiz.env.namespace)},useProps:O,usePropsWatch:function(e,t,n){const r=O();Object.prototype.hasOwnProperty.call(r,e)&&(c((()=>r[e]),((e,n)=>{t(E(e),E(n))}),n),t(E(r[e]),void 0))},useRouteKey:function(e,t,n){n||(n=u(""));n.value=e.value;const r=new P(t);return c(e,((e,t)=>{e!==t&&r.nextChange((()=>{n.value=e}))})),n},useRouterQuery:function(){const e=i(),{query:t}=e;return t},useViewController:function(e){const t=O(),n=m("ctx",void 0);null==n||n.evt.emit("forecast",t.modelData.name);const r=e(t.modelData,t.context,t.params,n);h("ctx",r.ctx),r.state=v(r.state),t.modal&&(r.modal=t.modal);return r.force=R(),r.created(),f((()=>r.destroyed())),r}});var P=e("RouteListener",class{constructor(e,t){this.callbacks=[],this.timers=[],this.wait=500,t&&(this.wait=t),c((()=>e.path),((e,t)=>{if(e!==t){if(this.callbacks.length)for(let e=0;e<this.callbacks.length;e++){(0,this.callbacks[e])()}if(this.callbacks=[],this.timers.length)for(let e=0;e<this.timers.length;e++){const t=this.timers[e];clearTimeout(t)}this.timers=[]}}))}nextChange(e){e&&(this.timers.push(setTimeout((()=>{e();const t=this.callbacks.findIndex((t=>t===e));this.callbacks.splice(t,1)}),this.wait)),this.callbacks.push(e))}});function O(){return l().proxy.$props}function E(e){return p(e)?d(e):e}function R(){const e=l().proxy;return t=>{e.$forceUpdate(),t&&x(t)&&e.$nextTick((()=>{t()}))}}var I=e("EmptyVNode",s("EmptyVNode"));var k=e("RequiredProp",class{constructor(e,t,n){this.required=!0,t&&(this.default=t),n&&(this.validator=n),this.type=e}});function $(){return{value:String,controller:new k(Object),data:new k(Object),disabled:{type:Boolean},readonly:{type:Boolean,default:!1},autoFocus:{type:Boolean,default:!1}}}function S(){return{hasError:{type:Boolean}}}function V(){return{...$(),value:String}}function z(){return{...$(),value:Number}}function j(){return{...$(),value:String}}}}}));
|
package/out/index.d.ts
CHANGED
package/out/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,OAAO,CAAC;AACtB,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC"}
|
package/out/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { IAppView } from '@ibiz/model-core';
|
|
1
2
|
/**
|
|
2
3
|
* 路由壳绘制需要的视图数据
|
|
3
4
|
*
|
|
@@ -8,21 +9,12 @@
|
|
|
8
9
|
*/
|
|
9
10
|
export interface IRouteViewData {
|
|
10
11
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
12
|
+
* 视图模型
|
|
13
13
|
* @author lxm
|
|
14
|
-
* @date
|
|
15
|
-
* @type {
|
|
16
|
-
*/
|
|
17
|
-
viewPath?: string;
|
|
18
|
-
/**
|
|
19
|
-
*视图类型
|
|
20
|
-
*
|
|
21
|
-
* @author lxm
|
|
22
|
-
* @date 2022-08-17 23:08:08
|
|
23
|
-
* @type {string}
|
|
14
|
+
* @date 2023-04-19 01:44:13
|
|
15
|
+
* @type {IAppView}
|
|
24
16
|
*/
|
|
25
|
-
|
|
17
|
+
viewModel?: IAppView;
|
|
26
18
|
/**
|
|
27
19
|
*视图上下文
|
|
28
20
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../src/interface/util/route/route.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../src/interface/util/route/route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;OAKG;IACH,SAAS,CAAC,EAAE,QAAQ,CAAC;IAErB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,cAAc;IAC7B;;;;;;OAMG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;;;;;OAMG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;IAElB;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,OAAO,CAAC;IAEjB;;;;;OAKG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,UAAU;IACzB;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;;OAKG;IACH,SAAS,EAAE,cAAc,EAAE,CAAC;CAC7B"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 必填props类型
|
|
3
|
+
*
|
|
4
|
+
* @author lxm
|
|
5
|
+
* @date 2022-11-01 19:11:47
|
|
6
|
+
* @export
|
|
7
|
+
* @class RequiredProp
|
|
8
|
+
* @template T type的类型
|
|
9
|
+
* @template D 默认值的类型
|
|
10
|
+
* @template V 校验函数的类型
|
|
11
|
+
*/
|
|
12
|
+
export declare class RequiredProp<T, D = undefined, V = undefined> {
|
|
13
|
+
readonly required = true;
|
|
14
|
+
type: T;
|
|
15
|
+
default?: D | undefined;
|
|
16
|
+
validator?: V | undefined;
|
|
17
|
+
constructor(type: T, _default?: D, validator?: V);
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/props/common.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,qBAAa,YAAY,CAAC,CAAC,EAAE,CAAC,GAAG,SAAS,EAAE,CAAC,GAAG,SAAS;IACvD,QAAQ,CAAC,QAAQ,QAAQ;IAEzB,IAAI,EAAE,CAAC,CAAC;IAER,OAAO,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC;IAExB,SAAS,CAAC,EAAE,CAAC,GAAG,SAAS,CAAC;gBAEd,IAAI,EAAE,CAAC,EAAE,QAAQ,CAAC,EAAE,CAAC,EAAE,SAAS,CAAC,EAAE,CAAC;CASjD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 必填props类型
|
|
3
|
+
*
|
|
4
|
+
* @author lxm
|
|
5
|
+
* @date 2022-11-01 19:11:47
|
|
6
|
+
* @export
|
|
7
|
+
* @class RequiredProp
|
|
8
|
+
* @template T type的类型
|
|
9
|
+
* @template D 默认值的类型
|
|
10
|
+
* @template V 校验函数的类型
|
|
11
|
+
*/
|
|
12
|
+
export class RequiredProp {
|
|
13
|
+
constructor(type, _default, validator) {
|
|
14
|
+
this.required = true;
|
|
15
|
+
if (_default) {
|
|
16
|
+
this.default = _default;
|
|
17
|
+
}
|
|
18
|
+
if (validator) {
|
|
19
|
+
this.validator = validator;
|
|
20
|
+
}
|
|
21
|
+
this.type = type;
|
|
22
|
+
}
|
|
23
|
+
}
|