phecda-vue 1.1.1 → 1.2.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/dist/index.d.ts +11 -4
- package/dist/index.js +126 -69
- package/dist/index.mjs +128 -69
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -5,8 +5,14 @@ import { Ref, App, UnwrapNestedRefs, Component, DefineComponent, ExtractPropType
|
|
|
5
5
|
import { Phecda } from 'phecda-core';
|
|
6
6
|
export * from 'phecda-core';
|
|
7
7
|
|
|
8
|
-
type
|
|
9
|
-
[
|
|
8
|
+
type ReadonlyValue<T> = {
|
|
9
|
+
readonly [K in keyof T]: K extends 'value' ? T[K] : ReadonlyValue<T[K]>;
|
|
10
|
+
};
|
|
11
|
+
type PublicOnly<T> = {
|
|
12
|
+
[K in keyof T]: T[K] extends Function ? T[K] : K extends string ? T[K] extends ('private' | 'protected') ? never : T[K] : never;
|
|
13
|
+
};
|
|
14
|
+
type ReplaceInstanceValues<I> = {
|
|
15
|
+
[P in keyof I]: I[P] extends (...args: any[]) => any ? I[P] : I[P] extends Readonly<any> ? ReadonlyValue<Ref<I[P]>> : Ref<I[P]>;
|
|
10
16
|
};
|
|
11
17
|
type SchemaToObj<S> = {
|
|
12
18
|
[P in keyof S]: S[P] extends object ? SchemaToObj<S[P]> : (S[P] extends string ? any : S[P]);
|
|
@@ -48,7 +54,7 @@ type _DeepPartial<T> = {
|
|
|
48
54
|
declare function useO<T extends new (...args: any) => any>(Model: T): UnwrapNestedRefs<InstanceType<T>>;
|
|
49
55
|
declare function usePatch<T extends new (...args: any) => any>(Model: T, Data: _DeepPartial<InstanceType<T>>): void;
|
|
50
56
|
declare function useR<T extends new (...args: any) => any>(Model: T): UnwrapNestedRefs<InstanceType<T>>;
|
|
51
|
-
declare function useV<T extends new (...args: any) => any>(Model: T):
|
|
57
|
+
declare function useV<T extends new (...args: any) => any>(Model: T): PublicOnly<ReplaceInstanceValues<InstanceType<T>>>;
|
|
52
58
|
declare function useEvent<Key extends keyof PhecdaEvents>(eventName: Key, cb: Handler<PhecdaEvents[Key]>): () => void;
|
|
53
59
|
declare function initalize<M extends new (...args: any) => any>(Model: M): InstanceType<M> | void;
|
|
54
60
|
declare function clearStorage<M extends new (...args: any) => any>(Model: M, isForceUpdate?: boolean): void;
|
|
@@ -60,6 +66,7 @@ declare function createFilter<Data extends Record<string, any>>(initState?: Obje
|
|
|
60
66
|
expressionRE?: RegExp;
|
|
61
67
|
fnRE?: RegExp;
|
|
62
68
|
exclude?: string[];
|
|
69
|
+
errorHandler?: (error?: Error, errorPath?: string) => any;
|
|
63
70
|
}): {
|
|
64
71
|
filter: <Schema>(obj: Schema) => SchemaToObj<Schema>;
|
|
65
72
|
data: [Data] extends [vue.Ref<any>] ? Data : vue.Ref<vue.UnwrapRef<Data>>;
|
|
@@ -129,4 +136,4 @@ interface PipeRet {
|
|
|
129
136
|
get: Record<string, () => VNode>;
|
|
130
137
|
}
|
|
131
138
|
|
|
132
|
-
export { EXPRESS_RE, FN_RE, GetDevUIRules, P, PhecdaEvents,
|
|
139
|
+
export { EXPRESS_RE, FN_RE, GetDevUIRules, P, PhecdaEvents, PublicOnly, ReplaceInstanceValues, SchemaToObj, clearStorage, createFilter, createForm, createFormData, createModal, createPhecda, createPipe, createTable, deleteStorage, emitter, getActivePhecda, getAntDRules, getElementPlusRules, getNaiveUIRules, getNutUIRules, getReactiveMap, getVantRules, initalize, invokeAction, phecdaSymbol, setActivePhecda, useEvent, useO, usePatch, useR, useV };
|
package/dist/index.js
CHANGED
|
@@ -5,6 +5,8 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
5
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
8
10
|
var __export = (target, all) => {
|
|
9
11
|
for (var name in all)
|
|
10
12
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
@@ -23,6 +25,10 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
25
|
mod
|
|
24
26
|
));
|
|
25
27
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var __publicField = (obj, key, value) => {
|
|
29
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
30
|
+
return value;
|
|
31
|
+
};
|
|
26
32
|
|
|
27
33
|
// src/index.ts
|
|
28
34
|
var src_exports = {};
|
|
@@ -82,7 +88,10 @@ function createPhecda(symbol) {
|
|
|
82
88
|
snapshot: () => {
|
|
83
89
|
const ret = [];
|
|
84
90
|
for (const [key, value] of phecda.useOMap)
|
|
85
|
-
ret.push({
|
|
91
|
+
ret.push({
|
|
92
|
+
key: (0, import_phecda_core.getTag)(key) || key.name,
|
|
93
|
+
value
|
|
94
|
+
});
|
|
86
95
|
return ret;
|
|
87
96
|
}
|
|
88
97
|
};
|
|
@@ -90,14 +99,15 @@ function createPhecda(symbol) {
|
|
|
90
99
|
const eventRecord = [];
|
|
91
100
|
(0, import_phecda_core.injectProperty)("watcher", ({ eventName, instance, key }) => {
|
|
92
101
|
const fn = typeof instance[key] === "function" ? instance[key].bind(instance) : (v) => instance[key] = v;
|
|
93
|
-
eventRecord.push([
|
|
102
|
+
eventRecord.push([
|
|
103
|
+
eventName,
|
|
104
|
+
fn
|
|
105
|
+
]);
|
|
94
106
|
emitter.on(eventName, fn);
|
|
95
107
|
});
|
|
96
108
|
const originUnmount = app.unmount.bind(app);
|
|
97
109
|
app.unmount = () => {
|
|
98
|
-
eventRecord.forEach(
|
|
99
|
-
([eventName, handler]) => emitter.off(eventName, handler)
|
|
100
|
-
);
|
|
110
|
+
eventRecord.forEach(([eventName, handler]) => emitter.off(eventName, handler));
|
|
101
111
|
if (symbol)
|
|
102
112
|
delete window.__PHECDA_VUE__[symbol];
|
|
103
113
|
originUnmount();
|
|
@@ -111,6 +121,7 @@ function createPhecda(symbol) {
|
|
|
111
121
|
});
|
|
112
122
|
return phecda;
|
|
113
123
|
}
|
|
124
|
+
__name(createPhecda, "createPhecda");
|
|
114
125
|
var activePhecda = {
|
|
115
126
|
useVMap: /* @__PURE__ */ new WeakMap(),
|
|
116
127
|
useOMap: /* @__PURE__ */ new WeakMap(),
|
|
@@ -121,9 +132,11 @@ var activePhecda = {
|
|
|
121
132
|
function setActivePhecda(phecda) {
|
|
122
133
|
activePhecda = phecda;
|
|
123
134
|
}
|
|
135
|
+
__name(setActivePhecda, "setActivePhecda");
|
|
124
136
|
function getActivePhecda() {
|
|
125
137
|
return activePhecda;
|
|
126
138
|
}
|
|
139
|
+
__name(getActivePhecda, "getActivePhecda");
|
|
127
140
|
function getReactiveMap(symbol) {
|
|
128
141
|
if (!window.__PHECDA_VUE__?.[symbol])
|
|
129
142
|
return null;
|
|
@@ -133,6 +146,7 @@ function getReactiveMap(symbol) {
|
|
|
133
146
|
});
|
|
134
147
|
return ret;
|
|
135
148
|
}
|
|
149
|
+
__name(getReactiveMap, "getReactiveMap");
|
|
136
150
|
|
|
137
151
|
// src/vue/composable.ts
|
|
138
152
|
var import_vue3 = require("vue");
|
|
@@ -143,6 +157,7 @@ var import_vue2 = require("vue");
|
|
|
143
157
|
function isObject(o) {
|
|
144
158
|
return Object.prototype.toString.call(o) === "[object Object]";
|
|
145
159
|
}
|
|
160
|
+
__name(isObject, "isObject");
|
|
146
161
|
function mergeReactiveObjects(target, patchToApply) {
|
|
147
162
|
for (const key in patchToApply) {
|
|
148
163
|
if (!patchToApply.hasOwnProperty(key))
|
|
@@ -157,6 +172,7 @@ function mergeReactiveObjects(target, patchToApply) {
|
|
|
157
172
|
}
|
|
158
173
|
return target;
|
|
159
174
|
}
|
|
175
|
+
__name(mergeReactiveObjects, "mergeReactiveObjects");
|
|
160
176
|
function wrapError(target, key, errorHandler) {
|
|
161
177
|
if (isAsyncFunc(target[key])) {
|
|
162
178
|
return (...args) => {
|
|
@@ -172,19 +188,21 @@ function wrapError(target, key, errorHandler) {
|
|
|
172
188
|
};
|
|
173
189
|
}
|
|
174
190
|
}
|
|
191
|
+
__name(wrapError, "wrapError");
|
|
175
192
|
function isAsyncFunc(fn) {
|
|
176
193
|
return fn[Symbol.toStringTag] === "AsyncFunction";
|
|
177
194
|
}
|
|
195
|
+
__name(isAsyncFunc, "isAsyncFunc");
|
|
178
196
|
function createSharedReactive(composable) {
|
|
179
197
|
let subscribers = 0;
|
|
180
198
|
let state;
|
|
181
199
|
let scope;
|
|
182
|
-
const dispose = () => {
|
|
200
|
+
const dispose = /* @__PURE__ */ __name(() => {
|
|
183
201
|
if (scope && --subscribers <= 0) {
|
|
184
202
|
scope.stop();
|
|
185
203
|
state = scope = null;
|
|
186
204
|
}
|
|
187
|
-
};
|
|
205
|
+
}, "dispose");
|
|
188
206
|
return () => {
|
|
189
207
|
subscribers++;
|
|
190
208
|
if (!state) {
|
|
@@ -195,6 +213,7 @@ function createSharedReactive(composable) {
|
|
|
195
213
|
return state;
|
|
196
214
|
};
|
|
197
215
|
}
|
|
216
|
+
__name(createSharedReactive, "createSharedReactive");
|
|
198
217
|
|
|
199
218
|
// src/vue/composable.ts
|
|
200
219
|
function useO(Model) {
|
|
@@ -211,12 +230,14 @@ function useO(Model) {
|
|
|
211
230
|
}
|
|
212
231
|
return useOMap.get(Model);
|
|
213
232
|
}
|
|
233
|
+
__name(useO, "useO");
|
|
214
234
|
function usePatch(Model, Data) {
|
|
215
235
|
useO(Model);
|
|
216
236
|
const { useOMap } = getActivePhecda();
|
|
217
237
|
const target = useOMap.get(Model);
|
|
218
238
|
mergeReactiveObjects(target, Data);
|
|
219
239
|
}
|
|
240
|
+
__name(usePatch, "usePatch");
|
|
220
241
|
function useR(Model) {
|
|
221
242
|
useO(Model);
|
|
222
243
|
const { useRMap, useOMap, fnMap } = getActivePhecda();
|
|
@@ -245,6 +266,7 @@ function useR(Model) {
|
|
|
245
266
|
useRMap.set(Model, proxy);
|
|
246
267
|
return proxy;
|
|
247
268
|
}
|
|
269
|
+
__name(useR, "useR");
|
|
248
270
|
function useV(Model) {
|
|
249
271
|
useO(Model);
|
|
250
272
|
const { useVMap, useOMap, fnMap, computedMap } = getActivePhecda();
|
|
@@ -286,6 +308,7 @@ function useV(Model) {
|
|
|
286
308
|
useVMap.set(Model, proxy);
|
|
287
309
|
return proxy;
|
|
288
310
|
}
|
|
311
|
+
__name(useV, "useV");
|
|
289
312
|
function useEvent(eventName, cb) {
|
|
290
313
|
(0, import_vue3.onBeforeUnmount)(() => {
|
|
291
314
|
emitter.off(eventName, cb);
|
|
@@ -293,6 +316,7 @@ function useEvent(eventName, cb) {
|
|
|
293
316
|
emitter.on(eventName, cb);
|
|
294
317
|
return () => emitter.off(eventName, cb);
|
|
295
318
|
}
|
|
319
|
+
__name(useEvent, "useEvent");
|
|
296
320
|
function initalize(Model) {
|
|
297
321
|
const instance = useO(Model);
|
|
298
322
|
if (instance) {
|
|
@@ -300,44 +324,43 @@ function initalize(Model) {
|
|
|
300
324
|
return instance;
|
|
301
325
|
}
|
|
302
326
|
}
|
|
327
|
+
__name(initalize, "initalize");
|
|
303
328
|
function clearStorage(Model, isForceUpdate = true) {
|
|
304
329
|
localStorage.removeItem(`_phecda_${useO(Model)._symbol}`);
|
|
305
330
|
isForceUpdate && initalize(Model);
|
|
306
331
|
}
|
|
332
|
+
__name(clearStorage, "clearStorage");
|
|
307
333
|
function deleteStorage(tag) {
|
|
308
334
|
localStorage.removeItem(`_phecda_${tag}`);
|
|
309
335
|
}
|
|
336
|
+
__name(deleteStorage, "deleteStorage");
|
|
310
337
|
|
|
311
338
|
// src/filter.ts
|
|
312
339
|
var import_vue4 = require("vue");
|
|
313
340
|
var EXPRESS_RE = /^{{(.*)}}$/;
|
|
314
341
|
var FN_RE = /^\[\[(.*)\]\]$/;
|
|
315
342
|
function createFilter(initState = {}, option = {}) {
|
|
316
|
-
const resolveOption = Object.assign(
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
},
|
|
322
|
-
option
|
|
323
|
-
);
|
|
343
|
+
const resolveOption = Object.assign({
|
|
344
|
+
expressionRE: EXPRESS_RE,
|
|
345
|
+
fnRE: FN_RE,
|
|
346
|
+
exclude: []
|
|
347
|
+
}, option);
|
|
324
348
|
const scope = (0, import_vue4.effectScope)(true);
|
|
325
349
|
let data = scope.run(() => (0, import_vue4.ref)(initState));
|
|
326
350
|
let store = {};
|
|
327
|
-
function traverse(obj) {
|
|
351
|
+
function traverse(obj, path) {
|
|
328
352
|
for (const i in obj) {
|
|
329
353
|
if (Array.isArray(obj[i]) || resolveOption.exclude.includes(i))
|
|
330
354
|
continue;
|
|
355
|
+
const errorPath = path ? `${path}.${i}` : i;
|
|
331
356
|
if (typeof obj[i] === "object" && obj[i])
|
|
332
|
-
traverse(obj[i]);
|
|
357
|
+
traverse(obj[i], errorPath);
|
|
333
358
|
if (typeof obj[i] === "string") {
|
|
334
359
|
if (resolveOption.expressionRE.test(obj[i])) {
|
|
335
360
|
const body = obj[i].match(resolveOption.expressionRE)[1];
|
|
336
361
|
Object.defineProperty(obj, i, {
|
|
337
362
|
get() {
|
|
338
|
-
return new Function(...Object.keys(data.value), `return ${body}`)(
|
|
339
|
-
...Object.values(data.value)
|
|
340
|
-
);
|
|
363
|
+
return new Function(...Object.keys(data.value), "_eh", resolveOption.errorHandler ? `try{return ${body}}catch(e){return _eh(e,"${errorPath}")}` : `return ${body}`)(...Object.values(data.value), resolveOption.errorHandler);
|
|
341
364
|
}
|
|
342
365
|
});
|
|
343
366
|
}
|
|
@@ -345,51 +368,69 @@ function createFilter(initState = {}, option = {}) {
|
|
|
345
368
|
const body = obj[i].match(resolveOption.fnRE)[1];
|
|
346
369
|
Object.defineProperty(obj, i, {
|
|
347
370
|
get() {
|
|
348
|
-
return new Function(...Object.keys(data.value), `${body}`)(
|
|
349
|
-
...Object.values(data.value)
|
|
350
|
-
);
|
|
371
|
+
return new Function(...Object.keys(data.value), "_eh", resolveOption.errorHandler ? `try{${body}}catch(e){return _eh(e,"${errorPath}")}` : `${body}`)(...Object.values(data.value), resolveOption.errorHandler);
|
|
351
372
|
}
|
|
352
373
|
});
|
|
353
374
|
}
|
|
354
375
|
}
|
|
355
376
|
}
|
|
356
377
|
}
|
|
378
|
+
__name(traverse, "traverse");
|
|
357
379
|
function filter(obj) {
|
|
358
380
|
obj = (0, import_vue4.reactive)(obj);
|
|
359
381
|
traverse(obj);
|
|
360
382
|
return obj;
|
|
361
383
|
}
|
|
384
|
+
__name(filter, "filter");
|
|
362
385
|
function setState(key, value) {
|
|
363
386
|
data.value[key] = value;
|
|
364
387
|
}
|
|
388
|
+
__name(setState, "setState");
|
|
365
389
|
function storeState(key, params) {
|
|
366
390
|
store[key] = data.value;
|
|
367
391
|
init(params);
|
|
368
392
|
}
|
|
393
|
+
__name(storeState, "storeState");
|
|
369
394
|
function applyStore(key) {
|
|
370
395
|
if (!store[key])
|
|
371
396
|
return;
|
|
372
397
|
data.value = store[key];
|
|
373
398
|
}
|
|
399
|
+
__name(applyStore, "applyStore");
|
|
374
400
|
function init(params) {
|
|
375
401
|
data.value = params || initState || {};
|
|
376
402
|
}
|
|
403
|
+
__name(init, "init");
|
|
377
404
|
function clearStore(key) {
|
|
378
405
|
delete store[key];
|
|
379
406
|
}
|
|
407
|
+
__name(clearStore, "clearStore");
|
|
380
408
|
function dispose() {
|
|
381
409
|
data = null;
|
|
382
410
|
store = null;
|
|
383
411
|
scope.stop();
|
|
384
412
|
}
|
|
385
|
-
|
|
413
|
+
__name(dispose, "dispose");
|
|
414
|
+
return {
|
|
415
|
+
filter,
|
|
416
|
+
data,
|
|
417
|
+
init,
|
|
418
|
+
setState,
|
|
419
|
+
storeState,
|
|
420
|
+
store,
|
|
421
|
+
applyStore,
|
|
422
|
+
dispose,
|
|
423
|
+
clearStore
|
|
424
|
+
};
|
|
386
425
|
}
|
|
426
|
+
__name(createFilter, "createFilter");
|
|
387
427
|
|
|
388
428
|
// src/index.ts
|
|
389
429
|
__reExport(src_exports, require("phecda-core"), module.exports);
|
|
390
430
|
|
|
391
431
|
// src/wrapper.ts
|
|
392
432
|
var _P = class {
|
|
433
|
+
_namespace;
|
|
393
434
|
constructor() {
|
|
394
435
|
}
|
|
395
436
|
get tag() {
|
|
@@ -406,35 +447,34 @@ var _P = class {
|
|
|
406
447
|
}
|
|
407
448
|
};
|
|
408
449
|
var P = _P;
|
|
409
|
-
P
|
|
450
|
+
__name(P, "P");
|
|
451
|
+
__publicField(P, "emitter", emitter);
|
|
410
452
|
|
|
411
453
|
// src/components/createForm.ts
|
|
412
454
|
var import_vue5 = require("vue");
|
|
413
455
|
function createForm(compSet, form, formItem, modelKey = "modelValue") {
|
|
414
456
|
function generateChildVNode(props) {
|
|
415
|
-
return props._children?.map(
|
|
416
|
-
(item) => item._active === false ? null : (0, import_vue5.h)(compSet[item._component], item)
|
|
417
|
-
);
|
|
457
|
+
return props._children?.map((item) => item._active === false ? null : (0, import_vue5.h)(compSet[item._component], item));
|
|
418
458
|
}
|
|
459
|
+
__name(generateChildVNode, "generateChildVNode");
|
|
419
460
|
function generateVNode(props) {
|
|
420
|
-
return (0, import_vue5.h)(
|
|
421
|
-
|
|
422
|
-
{
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
[`onUpdate:${modelKey}`]: (v) => {
|
|
426
|
-
props.data[props.property] = v;
|
|
427
|
-
}
|
|
428
|
-
},
|
|
429
|
-
{
|
|
430
|
-
default: () => generateChildVNode(props.config[props.property])
|
|
461
|
+
return (0, import_vue5.h)(compSet[props.config[props.property]._component], {
|
|
462
|
+
...props.config[props.property],
|
|
463
|
+
[`${modelKey}`]: props.data[props.property],
|
|
464
|
+
[`onUpdate:${modelKey}`]: (v) => {
|
|
465
|
+
props.data[props.property] = v;
|
|
431
466
|
}
|
|
432
|
-
|
|
467
|
+
}, {
|
|
468
|
+
default: () => generateChildVNode(props.config[props.property])
|
|
469
|
+
});
|
|
433
470
|
}
|
|
471
|
+
__name(generateVNode, "generateVNode");
|
|
434
472
|
const FormItem = (0, import_vue5.defineComponent)({
|
|
435
473
|
name: "CustomFormItem",
|
|
436
474
|
props: {
|
|
437
|
-
formItem: {
|
|
475
|
+
formItem: {
|
|
476
|
+
type: Object
|
|
477
|
+
},
|
|
438
478
|
config: {
|
|
439
479
|
type: Object,
|
|
440
480
|
required: true
|
|
@@ -450,17 +490,13 @@ function createForm(compSet, form, formItem, modelKey = "modelValue") {
|
|
|
450
490
|
},
|
|
451
491
|
setup(props) {
|
|
452
492
|
return () => {
|
|
453
|
-
return formItem ? (0, import_vue5.h)(
|
|
454
|
-
formItem
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
{
|
|
459
|
-
default: () => {
|
|
460
|
-
return generateVNode(props);
|
|
461
|
-
}
|
|
493
|
+
return formItem ? (0, import_vue5.h)(formItem, {
|
|
494
|
+
...props.formItem
|
|
495
|
+
}, {
|
|
496
|
+
default: () => {
|
|
497
|
+
return generateVNode(props);
|
|
462
498
|
}
|
|
463
|
-
) : generateVNode(props);
|
|
499
|
+
}) : generateVNode(props);
|
|
464
500
|
};
|
|
465
501
|
}
|
|
466
502
|
});
|
|
@@ -479,10 +515,14 @@ function createForm(compSet, form, formItem, modelKey = "modelValue") {
|
|
|
479
515
|
setup(props, ctx) {
|
|
480
516
|
const dom = (0, import_vue5.ref)();
|
|
481
517
|
(0, import_vue5.onMounted)(() => {
|
|
482
|
-
ctx.expose({
|
|
518
|
+
ctx.expose({
|
|
519
|
+
...dom.value
|
|
520
|
+
});
|
|
483
521
|
});
|
|
484
522
|
return () => {
|
|
485
|
-
return (0, import_vue5.h)(form, Object.assign({
|
|
523
|
+
return (0, import_vue5.h)(form, Object.assign({
|
|
524
|
+
ref: dom
|
|
525
|
+
}, ctx.attrs), {
|
|
486
526
|
default: () => Object.keys(props.config).map((item) => {
|
|
487
527
|
return props.config[item]._active === false ? null : (0, import_vue5.h)(FormItem, {
|
|
488
528
|
formItem: props.config[item]._formItem,
|
|
@@ -496,6 +536,7 @@ function createForm(compSet, form, formItem, modelKey = "modelValue") {
|
|
|
496
536
|
}
|
|
497
537
|
});
|
|
498
538
|
}
|
|
539
|
+
__name(createForm, "createForm");
|
|
499
540
|
|
|
500
541
|
// src/components/formFilter.ts
|
|
501
542
|
function createFormData(schema, initData = {}, options = {}) {
|
|
@@ -508,8 +549,13 @@ function createFormData(schema, initData = {}, options = {}) {
|
|
|
508
549
|
obj2[i] = obj1[i]._default;
|
|
509
550
|
}
|
|
510
551
|
}
|
|
511
|
-
|
|
552
|
+
__name(initlize, "initlize");
|
|
553
|
+
return {
|
|
554
|
+
config: filterRet,
|
|
555
|
+
data
|
|
556
|
+
};
|
|
512
557
|
}
|
|
558
|
+
__name(createFormData, "createFormData");
|
|
513
559
|
|
|
514
560
|
// src/components/formResolve.ts
|
|
515
561
|
var import_phecda_core3 = require("phecda-core");
|
|
@@ -540,6 +586,7 @@ function getElementPlusRules(Model, options = {}) {
|
|
|
540
586
|
}
|
|
541
587
|
return ret;
|
|
542
588
|
}
|
|
589
|
+
__name(getElementPlusRules, "getElementPlusRules");
|
|
543
590
|
var GetDevUIRules = getElementPlusRules;
|
|
544
591
|
function getNaiveUIRules(Model, options = {}) {
|
|
545
592
|
const stateVars = (0, import_phecda_core3.getModelState)(Model);
|
|
@@ -568,6 +615,7 @@ function getNaiveUIRules(Model, options = {}) {
|
|
|
568
615
|
}
|
|
569
616
|
return ret;
|
|
570
617
|
}
|
|
618
|
+
__name(getNaiveUIRules, "getNaiveUIRules");
|
|
571
619
|
var getAntDRules = getNaiveUIRules;
|
|
572
620
|
function getNutUIRules(Model, options = {}) {
|
|
573
621
|
const stateVars = (0, import_phecda_core3.getModelState)(Model);
|
|
@@ -597,11 +645,12 @@ function getNutUIRules(Model, options = {}) {
|
|
|
597
645
|
}
|
|
598
646
|
return ret;
|
|
599
647
|
}
|
|
648
|
+
__name(getNutUIRules, "getNutUIRules");
|
|
600
649
|
var getVantRules = getNutUIRules;
|
|
601
650
|
|
|
602
651
|
// src/components/createModal.ts
|
|
603
652
|
var import_vue6 = require("vue");
|
|
604
|
-
var createModal = function(modalWrapper, modelKey = "modelValue") {
|
|
653
|
+
var createModal = /* @__PURE__ */ __name(function(modalWrapper, modelKey = "modelValue") {
|
|
605
654
|
let isMounted = false;
|
|
606
655
|
const isShow = (0, import_vue6.ref)(true);
|
|
607
656
|
const content = (0, import_vue6.shallowRef)();
|
|
@@ -630,7 +679,7 @@ var createModal = function(modalWrapper, modelKey = "modelValue") {
|
|
|
630
679
|
isShow.value = true;
|
|
631
680
|
}
|
|
632
681
|
};
|
|
633
|
-
};
|
|
682
|
+
}, "createModal");
|
|
634
683
|
|
|
635
684
|
// src/components/createTable.ts
|
|
636
685
|
var import_vue7 = require("vue");
|
|
@@ -645,17 +694,17 @@ function createTable(compSet, table, tableColumn, data) {
|
|
|
645
694
|
},
|
|
646
695
|
setup(props) {
|
|
647
696
|
const compName = props.tableColumn._component;
|
|
648
|
-
return () => (0, import_vue7.h)(
|
|
649
|
-
tableColumn
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
}
|
|
697
|
+
return () => (0, import_vue7.h)(tableColumn, {
|
|
698
|
+
...props.tableColumn
|
|
699
|
+
}, {
|
|
700
|
+
default: (scope) => {
|
|
701
|
+
return compName ? (0, import_vue7.h)(compSet[compName], {
|
|
702
|
+
scope,
|
|
703
|
+
data,
|
|
704
|
+
...props.tableColumn._props || {}
|
|
705
|
+
}) : null;
|
|
657
706
|
}
|
|
658
|
-
);
|
|
707
|
+
});
|
|
659
708
|
}
|
|
660
709
|
});
|
|
661
710
|
return (0, import_vue7.defineComponent)({
|
|
@@ -669,10 +718,14 @@ function createTable(compSet, table, tableColumn, data) {
|
|
|
669
718
|
setup(props, ctx) {
|
|
670
719
|
const dom = (0, import_vue7.ref)();
|
|
671
720
|
(0, import_vue7.onMounted)(() => {
|
|
672
|
-
ctx.expose({
|
|
721
|
+
ctx.expose({
|
|
722
|
+
...dom.value
|
|
723
|
+
});
|
|
673
724
|
});
|
|
674
725
|
return () => {
|
|
675
|
-
return (0, import_vue7.h)(table, Object.assign({
|
|
726
|
+
return (0, import_vue7.h)(table, Object.assign({
|
|
727
|
+
ref: dom
|
|
728
|
+
}, ctx.attrs), {
|
|
676
729
|
default: () => props.config.map((item) => {
|
|
677
730
|
return (0, import_vue7.h)(TableColumn, {
|
|
678
731
|
tableColumn: item
|
|
@@ -683,11 +736,14 @@ function createTable(compSet, table, tableColumn, data) {
|
|
|
683
736
|
}
|
|
684
737
|
});
|
|
685
738
|
}
|
|
739
|
+
__name(createTable, "createTable");
|
|
686
740
|
|
|
687
741
|
// src/components/helper/pipe.ts
|
|
688
742
|
var import_vue8 = require("vue");
|
|
689
743
|
function createPipe(comp, props, to = "default", slot) {
|
|
690
|
-
const vnodeMap = {
|
|
744
|
+
const vnodeMap = {
|
|
745
|
+
[`${to}`]: () => (0, import_vue8.h)(comp, props, slot)
|
|
746
|
+
};
|
|
691
747
|
return {
|
|
692
748
|
to(comp2, props2, to2 = "default") {
|
|
693
749
|
return createPipe(comp2, props2, to2, vnodeMap);
|
|
@@ -700,6 +756,7 @@ function createPipe(comp, props, to = "default", slot) {
|
|
|
700
756
|
}
|
|
701
757
|
};
|
|
702
758
|
}
|
|
759
|
+
__name(createPipe, "createPipe");
|
|
703
760
|
// Annotate the CommonJS export names for ESM import in node:
|
|
704
761
|
0 && (module.exports = {
|
|
705
762
|
EXPRESS_RE,
|
package/dist/index.mjs
CHANGED
|
@@ -1,3 +1,11 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
4
|
+
var __publicField = (obj, key, value) => {
|
|
5
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
6
|
+
return value;
|
|
7
|
+
};
|
|
8
|
+
|
|
1
9
|
// src/emitter.ts
|
|
2
10
|
import mitt from "mitt";
|
|
3
11
|
var emitter = mitt();
|
|
@@ -20,7 +28,10 @@ function createPhecda(symbol) {
|
|
|
20
28
|
snapshot: () => {
|
|
21
29
|
const ret = [];
|
|
22
30
|
for (const [key, value] of phecda.useOMap)
|
|
23
|
-
ret.push({
|
|
31
|
+
ret.push({
|
|
32
|
+
key: getTag(key) || key.name,
|
|
33
|
+
value
|
|
34
|
+
});
|
|
24
35
|
return ret;
|
|
25
36
|
}
|
|
26
37
|
};
|
|
@@ -28,14 +39,15 @@ function createPhecda(symbol) {
|
|
|
28
39
|
const eventRecord = [];
|
|
29
40
|
injectProperty("watcher", ({ eventName, instance, key }) => {
|
|
30
41
|
const fn = typeof instance[key] === "function" ? instance[key].bind(instance) : (v) => instance[key] = v;
|
|
31
|
-
eventRecord.push([
|
|
42
|
+
eventRecord.push([
|
|
43
|
+
eventName,
|
|
44
|
+
fn
|
|
45
|
+
]);
|
|
32
46
|
emitter.on(eventName, fn);
|
|
33
47
|
});
|
|
34
48
|
const originUnmount = app.unmount.bind(app);
|
|
35
49
|
app.unmount = () => {
|
|
36
|
-
eventRecord.forEach(
|
|
37
|
-
([eventName, handler]) => emitter.off(eventName, handler)
|
|
38
|
-
);
|
|
50
|
+
eventRecord.forEach(([eventName, handler]) => emitter.off(eventName, handler));
|
|
39
51
|
if (symbol)
|
|
40
52
|
delete window.__PHECDA_VUE__[symbol];
|
|
41
53
|
originUnmount();
|
|
@@ -49,6 +61,7 @@ function createPhecda(symbol) {
|
|
|
49
61
|
});
|
|
50
62
|
return phecda;
|
|
51
63
|
}
|
|
64
|
+
__name(createPhecda, "createPhecda");
|
|
52
65
|
var activePhecda = {
|
|
53
66
|
useVMap: /* @__PURE__ */ new WeakMap(),
|
|
54
67
|
useOMap: /* @__PURE__ */ new WeakMap(),
|
|
@@ -59,9 +72,11 @@ var activePhecda = {
|
|
|
59
72
|
function setActivePhecda(phecda) {
|
|
60
73
|
activePhecda = phecda;
|
|
61
74
|
}
|
|
75
|
+
__name(setActivePhecda, "setActivePhecda");
|
|
62
76
|
function getActivePhecda() {
|
|
63
77
|
return activePhecda;
|
|
64
78
|
}
|
|
79
|
+
__name(getActivePhecda, "getActivePhecda");
|
|
65
80
|
function getReactiveMap(symbol) {
|
|
66
81
|
if (!window.__PHECDA_VUE__?.[symbol])
|
|
67
82
|
return null;
|
|
@@ -71,6 +86,7 @@ function getReactiveMap(symbol) {
|
|
|
71
86
|
});
|
|
72
87
|
return ret;
|
|
73
88
|
}
|
|
89
|
+
__name(getReactiveMap, "getReactiveMap");
|
|
74
90
|
|
|
75
91
|
// src/vue/composable.ts
|
|
76
92
|
import { computed, getCurrentInstance, inject, onBeforeUnmount, reactive } from "vue";
|
|
@@ -81,6 +97,7 @@ import { effectScope, isReactive, isRef, onScopeDispose } from "vue";
|
|
|
81
97
|
function isObject(o) {
|
|
82
98
|
return Object.prototype.toString.call(o) === "[object Object]";
|
|
83
99
|
}
|
|
100
|
+
__name(isObject, "isObject");
|
|
84
101
|
function mergeReactiveObjects(target, patchToApply) {
|
|
85
102
|
for (const key in patchToApply) {
|
|
86
103
|
if (!patchToApply.hasOwnProperty(key))
|
|
@@ -95,6 +112,7 @@ function mergeReactiveObjects(target, patchToApply) {
|
|
|
95
112
|
}
|
|
96
113
|
return target;
|
|
97
114
|
}
|
|
115
|
+
__name(mergeReactiveObjects, "mergeReactiveObjects");
|
|
98
116
|
function wrapError(target, key, errorHandler) {
|
|
99
117
|
if (isAsyncFunc(target[key])) {
|
|
100
118
|
return (...args) => {
|
|
@@ -110,19 +128,21 @@ function wrapError(target, key, errorHandler) {
|
|
|
110
128
|
};
|
|
111
129
|
}
|
|
112
130
|
}
|
|
131
|
+
__name(wrapError, "wrapError");
|
|
113
132
|
function isAsyncFunc(fn) {
|
|
114
133
|
return fn[Symbol.toStringTag] === "AsyncFunction";
|
|
115
134
|
}
|
|
135
|
+
__name(isAsyncFunc, "isAsyncFunc");
|
|
116
136
|
function createSharedReactive(composable) {
|
|
117
137
|
let subscribers = 0;
|
|
118
138
|
let state;
|
|
119
139
|
let scope;
|
|
120
|
-
const dispose = () => {
|
|
140
|
+
const dispose = /* @__PURE__ */ __name(() => {
|
|
121
141
|
if (scope && --subscribers <= 0) {
|
|
122
142
|
scope.stop();
|
|
123
143
|
state = scope = null;
|
|
124
144
|
}
|
|
125
|
-
};
|
|
145
|
+
}, "dispose");
|
|
126
146
|
return () => {
|
|
127
147
|
subscribers++;
|
|
128
148
|
if (!state) {
|
|
@@ -133,6 +153,7 @@ function createSharedReactive(composable) {
|
|
|
133
153
|
return state;
|
|
134
154
|
};
|
|
135
155
|
}
|
|
156
|
+
__name(createSharedReactive, "createSharedReactive");
|
|
136
157
|
|
|
137
158
|
// src/vue/composable.ts
|
|
138
159
|
function useO(Model) {
|
|
@@ -149,12 +170,14 @@ function useO(Model) {
|
|
|
149
170
|
}
|
|
150
171
|
return useOMap.get(Model);
|
|
151
172
|
}
|
|
173
|
+
__name(useO, "useO");
|
|
152
174
|
function usePatch(Model, Data) {
|
|
153
175
|
useO(Model);
|
|
154
176
|
const { useOMap } = getActivePhecda();
|
|
155
177
|
const target = useOMap.get(Model);
|
|
156
178
|
mergeReactiveObjects(target, Data);
|
|
157
179
|
}
|
|
180
|
+
__name(usePatch, "usePatch");
|
|
158
181
|
function useR(Model) {
|
|
159
182
|
useO(Model);
|
|
160
183
|
const { useRMap, useOMap, fnMap } = getActivePhecda();
|
|
@@ -183,6 +206,7 @@ function useR(Model) {
|
|
|
183
206
|
useRMap.set(Model, proxy);
|
|
184
207
|
return proxy;
|
|
185
208
|
}
|
|
209
|
+
__name(useR, "useR");
|
|
186
210
|
function useV(Model) {
|
|
187
211
|
useO(Model);
|
|
188
212
|
const { useVMap, useOMap, fnMap, computedMap } = getActivePhecda();
|
|
@@ -224,6 +248,7 @@ function useV(Model) {
|
|
|
224
248
|
useVMap.set(Model, proxy);
|
|
225
249
|
return proxy;
|
|
226
250
|
}
|
|
251
|
+
__name(useV, "useV");
|
|
227
252
|
function useEvent(eventName, cb) {
|
|
228
253
|
onBeforeUnmount(() => {
|
|
229
254
|
emitter.off(eventName, cb);
|
|
@@ -231,6 +256,7 @@ function useEvent(eventName, cb) {
|
|
|
231
256
|
emitter.on(eventName, cb);
|
|
232
257
|
return () => emitter.off(eventName, cb);
|
|
233
258
|
}
|
|
259
|
+
__name(useEvent, "useEvent");
|
|
234
260
|
function initalize(Model) {
|
|
235
261
|
const instance = useO(Model);
|
|
236
262
|
if (instance) {
|
|
@@ -238,44 +264,43 @@ function initalize(Model) {
|
|
|
238
264
|
return instance;
|
|
239
265
|
}
|
|
240
266
|
}
|
|
267
|
+
__name(initalize, "initalize");
|
|
241
268
|
function clearStorage(Model, isForceUpdate = true) {
|
|
242
269
|
localStorage.removeItem(`_phecda_${useO(Model)._symbol}`);
|
|
243
270
|
isForceUpdate && initalize(Model);
|
|
244
271
|
}
|
|
272
|
+
__name(clearStorage, "clearStorage");
|
|
245
273
|
function deleteStorage(tag) {
|
|
246
274
|
localStorage.removeItem(`_phecda_${tag}`);
|
|
247
275
|
}
|
|
276
|
+
__name(deleteStorage, "deleteStorage");
|
|
248
277
|
|
|
249
278
|
// src/filter.ts
|
|
250
279
|
import { effectScope as effectScope2, reactive as reactive2, ref } from "vue";
|
|
251
280
|
var EXPRESS_RE = /^{{(.*)}}$/;
|
|
252
281
|
var FN_RE = /^\[\[(.*)\]\]$/;
|
|
253
282
|
function createFilter(initState = {}, option = {}) {
|
|
254
|
-
const resolveOption = Object.assign(
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
},
|
|
260
|
-
option
|
|
261
|
-
);
|
|
283
|
+
const resolveOption = Object.assign({
|
|
284
|
+
expressionRE: EXPRESS_RE,
|
|
285
|
+
fnRE: FN_RE,
|
|
286
|
+
exclude: []
|
|
287
|
+
}, option);
|
|
262
288
|
const scope = effectScope2(true);
|
|
263
289
|
let data = scope.run(() => ref(initState));
|
|
264
290
|
let store = {};
|
|
265
|
-
function traverse(obj) {
|
|
291
|
+
function traverse(obj, path) {
|
|
266
292
|
for (const i in obj) {
|
|
267
293
|
if (Array.isArray(obj[i]) || resolveOption.exclude.includes(i))
|
|
268
294
|
continue;
|
|
295
|
+
const errorPath = path ? `${path}.${i}` : i;
|
|
269
296
|
if (typeof obj[i] === "object" && obj[i])
|
|
270
|
-
traverse(obj[i]);
|
|
297
|
+
traverse(obj[i], errorPath);
|
|
271
298
|
if (typeof obj[i] === "string") {
|
|
272
299
|
if (resolveOption.expressionRE.test(obj[i])) {
|
|
273
300
|
const body = obj[i].match(resolveOption.expressionRE)[1];
|
|
274
301
|
Object.defineProperty(obj, i, {
|
|
275
302
|
get() {
|
|
276
|
-
return new Function(...Object.keys(data.value), `return ${body}`)(
|
|
277
|
-
...Object.values(data.value)
|
|
278
|
-
);
|
|
303
|
+
return new Function(...Object.keys(data.value), "_eh", resolveOption.errorHandler ? `try{return ${body}}catch(e){return _eh(e,"${errorPath}")}` : `return ${body}`)(...Object.values(data.value), resolveOption.errorHandler);
|
|
279
304
|
}
|
|
280
305
|
});
|
|
281
306
|
}
|
|
@@ -283,51 +308,69 @@ function createFilter(initState = {}, option = {}) {
|
|
|
283
308
|
const body = obj[i].match(resolveOption.fnRE)[1];
|
|
284
309
|
Object.defineProperty(obj, i, {
|
|
285
310
|
get() {
|
|
286
|
-
return new Function(...Object.keys(data.value), `${body}`)(
|
|
287
|
-
...Object.values(data.value)
|
|
288
|
-
);
|
|
311
|
+
return new Function(...Object.keys(data.value), "_eh", resolveOption.errorHandler ? `try{${body}}catch(e){return _eh(e,"${errorPath}")}` : `${body}`)(...Object.values(data.value), resolveOption.errorHandler);
|
|
289
312
|
}
|
|
290
313
|
});
|
|
291
314
|
}
|
|
292
315
|
}
|
|
293
316
|
}
|
|
294
317
|
}
|
|
318
|
+
__name(traverse, "traverse");
|
|
295
319
|
function filter(obj) {
|
|
296
320
|
obj = reactive2(obj);
|
|
297
321
|
traverse(obj);
|
|
298
322
|
return obj;
|
|
299
323
|
}
|
|
324
|
+
__name(filter, "filter");
|
|
300
325
|
function setState(key, value) {
|
|
301
326
|
data.value[key] = value;
|
|
302
327
|
}
|
|
328
|
+
__name(setState, "setState");
|
|
303
329
|
function storeState(key, params) {
|
|
304
330
|
store[key] = data.value;
|
|
305
331
|
init(params);
|
|
306
332
|
}
|
|
333
|
+
__name(storeState, "storeState");
|
|
307
334
|
function applyStore(key) {
|
|
308
335
|
if (!store[key])
|
|
309
336
|
return;
|
|
310
337
|
data.value = store[key];
|
|
311
338
|
}
|
|
339
|
+
__name(applyStore, "applyStore");
|
|
312
340
|
function init(params) {
|
|
313
341
|
data.value = params || initState || {};
|
|
314
342
|
}
|
|
343
|
+
__name(init, "init");
|
|
315
344
|
function clearStore(key) {
|
|
316
345
|
delete store[key];
|
|
317
346
|
}
|
|
347
|
+
__name(clearStore, "clearStore");
|
|
318
348
|
function dispose() {
|
|
319
349
|
data = null;
|
|
320
350
|
store = null;
|
|
321
351
|
scope.stop();
|
|
322
352
|
}
|
|
323
|
-
|
|
353
|
+
__name(dispose, "dispose");
|
|
354
|
+
return {
|
|
355
|
+
filter,
|
|
356
|
+
data,
|
|
357
|
+
init,
|
|
358
|
+
setState,
|
|
359
|
+
storeState,
|
|
360
|
+
store,
|
|
361
|
+
applyStore,
|
|
362
|
+
dispose,
|
|
363
|
+
clearStore
|
|
364
|
+
};
|
|
324
365
|
}
|
|
366
|
+
__name(createFilter, "createFilter");
|
|
325
367
|
|
|
326
368
|
// src/index.ts
|
|
327
369
|
export * from "phecda-core";
|
|
328
370
|
|
|
329
371
|
// src/wrapper.ts
|
|
330
372
|
var _P = class {
|
|
373
|
+
_namespace;
|
|
331
374
|
constructor() {
|
|
332
375
|
}
|
|
333
376
|
get tag() {
|
|
@@ -344,35 +387,34 @@ var _P = class {
|
|
|
344
387
|
}
|
|
345
388
|
};
|
|
346
389
|
var P = _P;
|
|
347
|
-
P
|
|
390
|
+
__name(P, "P");
|
|
391
|
+
__publicField(P, "emitter", emitter);
|
|
348
392
|
|
|
349
393
|
// src/components/createForm.ts
|
|
350
394
|
import { defineComponent, h, onMounted, ref as ref2 } from "vue";
|
|
351
395
|
function createForm(compSet, form, formItem, modelKey = "modelValue") {
|
|
352
396
|
function generateChildVNode(props) {
|
|
353
|
-
return props._children?.map(
|
|
354
|
-
(item) => item._active === false ? null : h(compSet[item._component], item)
|
|
355
|
-
);
|
|
397
|
+
return props._children?.map((item) => item._active === false ? null : h(compSet[item._component], item));
|
|
356
398
|
}
|
|
399
|
+
__name(generateChildVNode, "generateChildVNode");
|
|
357
400
|
function generateVNode(props) {
|
|
358
|
-
return h(
|
|
359
|
-
|
|
360
|
-
{
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
[`onUpdate:${modelKey}`]: (v) => {
|
|
364
|
-
props.data[props.property] = v;
|
|
365
|
-
}
|
|
366
|
-
},
|
|
367
|
-
{
|
|
368
|
-
default: () => generateChildVNode(props.config[props.property])
|
|
401
|
+
return h(compSet[props.config[props.property]._component], {
|
|
402
|
+
...props.config[props.property],
|
|
403
|
+
[`${modelKey}`]: props.data[props.property],
|
|
404
|
+
[`onUpdate:${modelKey}`]: (v) => {
|
|
405
|
+
props.data[props.property] = v;
|
|
369
406
|
}
|
|
370
|
-
|
|
407
|
+
}, {
|
|
408
|
+
default: () => generateChildVNode(props.config[props.property])
|
|
409
|
+
});
|
|
371
410
|
}
|
|
411
|
+
__name(generateVNode, "generateVNode");
|
|
372
412
|
const FormItem = defineComponent({
|
|
373
413
|
name: "CustomFormItem",
|
|
374
414
|
props: {
|
|
375
|
-
formItem: {
|
|
415
|
+
formItem: {
|
|
416
|
+
type: Object
|
|
417
|
+
},
|
|
376
418
|
config: {
|
|
377
419
|
type: Object,
|
|
378
420
|
required: true
|
|
@@ -388,17 +430,13 @@ function createForm(compSet, form, formItem, modelKey = "modelValue") {
|
|
|
388
430
|
},
|
|
389
431
|
setup(props) {
|
|
390
432
|
return () => {
|
|
391
|
-
return formItem ? h(
|
|
392
|
-
formItem
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
{
|
|
397
|
-
default: () => {
|
|
398
|
-
return generateVNode(props);
|
|
399
|
-
}
|
|
433
|
+
return formItem ? h(formItem, {
|
|
434
|
+
...props.formItem
|
|
435
|
+
}, {
|
|
436
|
+
default: () => {
|
|
437
|
+
return generateVNode(props);
|
|
400
438
|
}
|
|
401
|
-
) : generateVNode(props);
|
|
439
|
+
}) : generateVNode(props);
|
|
402
440
|
};
|
|
403
441
|
}
|
|
404
442
|
});
|
|
@@ -417,10 +455,14 @@ function createForm(compSet, form, formItem, modelKey = "modelValue") {
|
|
|
417
455
|
setup(props, ctx) {
|
|
418
456
|
const dom = ref2();
|
|
419
457
|
onMounted(() => {
|
|
420
|
-
ctx.expose({
|
|
458
|
+
ctx.expose({
|
|
459
|
+
...dom.value
|
|
460
|
+
});
|
|
421
461
|
});
|
|
422
462
|
return () => {
|
|
423
|
-
return h(form, Object.assign({
|
|
463
|
+
return h(form, Object.assign({
|
|
464
|
+
ref: dom
|
|
465
|
+
}, ctx.attrs), {
|
|
424
466
|
default: () => Object.keys(props.config).map((item) => {
|
|
425
467
|
return props.config[item]._active === false ? null : h(FormItem, {
|
|
426
468
|
formItem: props.config[item]._formItem,
|
|
@@ -434,6 +476,7 @@ function createForm(compSet, form, formItem, modelKey = "modelValue") {
|
|
|
434
476
|
}
|
|
435
477
|
});
|
|
436
478
|
}
|
|
479
|
+
__name(createForm, "createForm");
|
|
437
480
|
|
|
438
481
|
// src/components/formFilter.ts
|
|
439
482
|
function createFormData(schema, initData = {}, options = {}) {
|
|
@@ -446,8 +489,13 @@ function createFormData(schema, initData = {}, options = {}) {
|
|
|
446
489
|
obj2[i] = obj1[i]._default;
|
|
447
490
|
}
|
|
448
491
|
}
|
|
449
|
-
|
|
492
|
+
__name(initlize, "initlize");
|
|
493
|
+
return {
|
|
494
|
+
config: filterRet,
|
|
495
|
+
data
|
|
496
|
+
};
|
|
450
497
|
}
|
|
498
|
+
__name(createFormData, "createFormData");
|
|
451
499
|
|
|
452
500
|
// src/components/formResolve.ts
|
|
453
501
|
import { getHandler as getHandler2, getModelState, validate } from "phecda-core";
|
|
@@ -478,6 +526,7 @@ function getElementPlusRules(Model, options = {}) {
|
|
|
478
526
|
}
|
|
479
527
|
return ret;
|
|
480
528
|
}
|
|
529
|
+
__name(getElementPlusRules, "getElementPlusRules");
|
|
481
530
|
var GetDevUIRules = getElementPlusRules;
|
|
482
531
|
function getNaiveUIRules(Model, options = {}) {
|
|
483
532
|
const stateVars = getModelState(Model);
|
|
@@ -506,6 +555,7 @@ function getNaiveUIRules(Model, options = {}) {
|
|
|
506
555
|
}
|
|
507
556
|
return ret;
|
|
508
557
|
}
|
|
558
|
+
__name(getNaiveUIRules, "getNaiveUIRules");
|
|
509
559
|
var getAntDRules = getNaiveUIRules;
|
|
510
560
|
function getNutUIRules(Model, options = {}) {
|
|
511
561
|
const stateVars = getModelState(Model);
|
|
@@ -535,11 +585,12 @@ function getNutUIRules(Model, options = {}) {
|
|
|
535
585
|
}
|
|
536
586
|
return ret;
|
|
537
587
|
}
|
|
588
|
+
__name(getNutUIRules, "getNutUIRules");
|
|
538
589
|
var getVantRules = getNutUIRules;
|
|
539
590
|
|
|
540
591
|
// src/components/createModal.ts
|
|
541
592
|
import { defineComponent as defineComponent2, h as h2, ref as ref3, render, shallowRef } from "vue";
|
|
542
|
-
var createModal = function(modalWrapper, modelKey = "modelValue") {
|
|
593
|
+
var createModal = /* @__PURE__ */ __name(function(modalWrapper, modelKey = "modelValue") {
|
|
543
594
|
let isMounted = false;
|
|
544
595
|
const isShow = ref3(true);
|
|
545
596
|
const content = shallowRef();
|
|
@@ -568,7 +619,7 @@ var createModal = function(modalWrapper, modelKey = "modelValue") {
|
|
|
568
619
|
isShow.value = true;
|
|
569
620
|
}
|
|
570
621
|
};
|
|
571
|
-
};
|
|
622
|
+
}, "createModal");
|
|
572
623
|
|
|
573
624
|
// src/components/createTable.ts
|
|
574
625
|
import { defineComponent as defineComponent3, h as h3, onMounted as onMounted2, ref as ref4 } from "vue";
|
|
@@ -583,17 +634,17 @@ function createTable(compSet, table, tableColumn, data) {
|
|
|
583
634
|
},
|
|
584
635
|
setup(props) {
|
|
585
636
|
const compName = props.tableColumn._component;
|
|
586
|
-
return () => h3(
|
|
587
|
-
tableColumn
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
}
|
|
637
|
+
return () => h3(tableColumn, {
|
|
638
|
+
...props.tableColumn
|
|
639
|
+
}, {
|
|
640
|
+
default: (scope) => {
|
|
641
|
+
return compName ? h3(compSet[compName], {
|
|
642
|
+
scope,
|
|
643
|
+
data,
|
|
644
|
+
...props.tableColumn._props || {}
|
|
645
|
+
}) : null;
|
|
595
646
|
}
|
|
596
|
-
);
|
|
647
|
+
});
|
|
597
648
|
}
|
|
598
649
|
});
|
|
599
650
|
return defineComponent3({
|
|
@@ -607,10 +658,14 @@ function createTable(compSet, table, tableColumn, data) {
|
|
|
607
658
|
setup(props, ctx) {
|
|
608
659
|
const dom = ref4();
|
|
609
660
|
onMounted2(() => {
|
|
610
|
-
ctx.expose({
|
|
661
|
+
ctx.expose({
|
|
662
|
+
...dom.value
|
|
663
|
+
});
|
|
611
664
|
});
|
|
612
665
|
return () => {
|
|
613
|
-
return h3(table, Object.assign({
|
|
666
|
+
return h3(table, Object.assign({
|
|
667
|
+
ref: dom
|
|
668
|
+
}, ctx.attrs), {
|
|
614
669
|
default: () => props.config.map((item) => {
|
|
615
670
|
return h3(TableColumn, {
|
|
616
671
|
tableColumn: item
|
|
@@ -621,11 +676,14 @@ function createTable(compSet, table, tableColumn, data) {
|
|
|
621
676
|
}
|
|
622
677
|
});
|
|
623
678
|
}
|
|
679
|
+
__name(createTable, "createTable");
|
|
624
680
|
|
|
625
681
|
// src/components/helper/pipe.ts
|
|
626
682
|
import { h as h4 } from "vue";
|
|
627
683
|
function createPipe(comp, props, to = "default", slot) {
|
|
628
|
-
const vnodeMap = {
|
|
684
|
+
const vnodeMap = {
|
|
685
|
+
[`${to}`]: () => h4(comp, props, slot)
|
|
686
|
+
};
|
|
629
687
|
return {
|
|
630
688
|
to(comp2, props2, to2 = "default") {
|
|
631
689
|
return createPipe(comp2, props2, to2, vnodeMap);
|
|
@@ -638,6 +696,7 @@ function createPipe(comp, props, to = "default", slot) {
|
|
|
638
696
|
}
|
|
639
697
|
};
|
|
640
698
|
}
|
|
699
|
+
__name(createPipe, "createPipe");
|
|
641
700
|
export {
|
|
642
701
|
EXPRESS_RE,
|
|
643
702
|
FN_RE,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phecda-vue",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"dependencies": {
|
|
15
15
|
"mitt": "^3.0.0",
|
|
16
16
|
"vue": "^3.2.45",
|
|
17
|
-
"phecda-core": "1.0.
|
|
17
|
+
"phecda-core": "1.0.6"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"tsup": "^6.5.0"
|