phecda-vue 1.2.10 → 1.3.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 +3 -5
- package/dist/index.js +59 -46
- package/dist/index.mjs +61 -46
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -48,9 +48,7 @@ declare function usePatch<T extends new (...args: any) => any>(Model: T, Data: _
|
|
|
48
48
|
declare function useR<T extends new (...args: any) => any>(Model: T): UnwrapNestedRefs<InstanceType<T>>;
|
|
49
49
|
declare function useV<T extends new (...args: any) => any>(Model: T): PublicOnly<ReplaceInstanceValues<InstanceType<T>>>;
|
|
50
50
|
declare function useEvent<Key extends keyof PhecdaEvents>(eventName: Key, cb: Handler<PhecdaEvents[Key]>): () => void;
|
|
51
|
-
declare function
|
|
52
|
-
declare function clearStorage<M extends new (...args: any) => any>(Model: M, isForceUpdate?: boolean): void;
|
|
53
|
-
declare function deleteStorage(tag: string): void;
|
|
51
|
+
declare function initialize<M extends new (...args: any) => any>(Model: M): InstanceType<M> | void;
|
|
54
52
|
|
|
55
53
|
declare const EXPRESS_RE: RegExp;
|
|
56
54
|
declare const FN_RE: RegExp;
|
|
@@ -99,7 +97,7 @@ declare const getAntDRules: typeof getNaiveUIRules;
|
|
|
99
97
|
declare function getNutUIRules<M, O extends object>(Model: M, options?: O): any;
|
|
100
98
|
declare const getVantRules: typeof getNutUIRules;
|
|
101
99
|
|
|
102
|
-
declare const
|
|
100
|
+
declare const createLayer: <T>(wrapComp: Component<T>, props?: Partial<T>, modelKey?: string) => <P>(comp: Component<P>, props?: P) => void;
|
|
103
101
|
|
|
104
102
|
declare function createTable<P extends {
|
|
105
103
|
$props: any;
|
|
@@ -129,4 +127,4 @@ declare class PV {
|
|
|
129
127
|
off<Key extends keyof PhecdaEvents>(type: Key, handler?: (arg: PhecdaEvents[Key]) => void): void;
|
|
130
128
|
}
|
|
131
129
|
|
|
132
|
-
export { EXPRESS_RE, FN_RE, GetDevUIRules, PV, PhecdaEmitter, PublicOnly, ReplaceInstanceValues, SchemaToObj,
|
|
130
|
+
export { EXPRESS_RE, FN_RE, GetDevUIRules, PV, PhecdaEmitter, PublicOnly, ReplaceInstanceValues, SchemaToObj, createFilter, createForm, createFormData, createLayer, createPhecda, createPipe, createTable, emitter, getActivePhecda, getAntDRules, getElementPlusRules, getNaiveUIRules, getNutUIRules, getReactiveMap, getVantRules, initialize, phecdaSymbol, setActivePhecda, useEvent, useO, usePatch, useR, useV };
|
package/dist/index.js
CHANGED
|
@@ -32,15 +32,13 @@ __export(src_exports, {
|
|
|
32
32
|
FN_RE: () => FN_RE,
|
|
33
33
|
GetDevUIRules: () => GetDevUIRules,
|
|
34
34
|
PV: () => PV,
|
|
35
|
-
clearStorage: () => clearStorage,
|
|
36
35
|
createFilter: () => createFilter,
|
|
37
36
|
createForm: () => createForm,
|
|
38
37
|
createFormData: () => createFormData,
|
|
39
|
-
|
|
38
|
+
createLayer: () => createLayer,
|
|
40
39
|
createPhecda: () => createPhecda,
|
|
41
40
|
createPipe: () => createPipe,
|
|
42
41
|
createTable: () => createTable,
|
|
43
|
-
deleteStorage: () => deleteStorage,
|
|
44
42
|
emitter: () => emitter,
|
|
45
43
|
getActivePhecda: () => getActivePhecda,
|
|
46
44
|
getAntDRules: () => getAntDRules,
|
|
@@ -49,7 +47,7 @@ __export(src_exports, {
|
|
|
49
47
|
getNutUIRules: () => getNutUIRules,
|
|
50
48
|
getReactiveMap: () => getReactiveMap,
|
|
51
49
|
getVantRules: () => getVantRules,
|
|
52
|
-
|
|
50
|
+
initialize: () => initialize,
|
|
53
51
|
phecdaSymbol: () => phecdaSymbol,
|
|
54
52
|
setActivePhecda: () => setActivePhecda,
|
|
55
53
|
useEvent: () => useEvent,
|
|
@@ -91,26 +89,49 @@ function createPhecda(symbol) {
|
|
|
91
89
|
};
|
|
92
90
|
}
|
|
93
91
|
let eventRecord = [];
|
|
94
|
-
(0, import_phecda_core.
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
92
|
+
if (!(0, import_phecda_core.getProperty)("watcher")) {
|
|
93
|
+
(0, import_phecda_core.injectProperty)("watcher", ({ eventName, instance, key, options }) => {
|
|
94
|
+
const fn = typeof instance[key] === "function" ? instance[key].bind(instance) : (v) => instance[key] = v;
|
|
95
|
+
if (options?.once) {
|
|
96
|
+
const handler = /* @__PURE__ */ __name((...args) => {
|
|
97
|
+
fn(...args);
|
|
98
|
+
emitter.off(eventName, handler);
|
|
99
|
+
}, "handler");
|
|
100
|
+
emitter.on(eventName, handler);
|
|
101
|
+
eventRecord.push([
|
|
102
|
+
eventName,
|
|
103
|
+
handler
|
|
104
|
+
]);
|
|
105
|
+
} else {
|
|
106
|
+
eventRecord.push([
|
|
107
|
+
eventName,
|
|
108
|
+
fn
|
|
109
|
+
]);
|
|
110
|
+
emitter.on(eventName, fn);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
if (!(0, import_phecda_core.getProperty)("storage")) {
|
|
115
|
+
(0, import_phecda_core.injectProperty)("storage", ({ tag, key, instance }) => {
|
|
116
|
+
if (!tag)
|
|
117
|
+
return;
|
|
118
|
+
const initstr = localStorage.getItem(tag);
|
|
119
|
+
if (initstr) {
|
|
120
|
+
const data = JSON.parse(initstr);
|
|
121
|
+
if (key) {
|
|
122
|
+
instance[key] = data;
|
|
123
|
+
} else {
|
|
124
|
+
for (const i in data) {
|
|
125
|
+
if (i)
|
|
126
|
+
instance[i] = data[i];
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
globalThis.addEventListener("beforeunload", () => {
|
|
131
|
+
localStorage.setItem(tag, JSON.stringify(key ? instance[key] : instance));
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
}
|
|
114
135
|
const originUnmount = app.unmount.bind(app);
|
|
115
136
|
app.unmount = () => {
|
|
116
137
|
eventRecord.forEach(([eventName, handler]) => emitter.off(eventName, handler));
|
|
@@ -314,23 +335,14 @@ function useEvent(eventName, cb) {
|
|
|
314
335
|
return () => emitter.off(eventName, cb);
|
|
315
336
|
}
|
|
316
337
|
__name(useEvent, "useEvent");
|
|
317
|
-
function
|
|
338
|
+
function initialize(Model) {
|
|
318
339
|
const instance = useO(Model);
|
|
319
340
|
if (instance) {
|
|
320
341
|
Object.assign(instance, new Model());
|
|
321
342
|
return instance;
|
|
322
343
|
}
|
|
323
344
|
}
|
|
324
|
-
__name(
|
|
325
|
-
function clearStorage(Model, isForceUpdate = true) {
|
|
326
|
-
localStorage.removeItem(`_phecda_${useO(Model)._symbol}`);
|
|
327
|
-
isForceUpdate && initalize(Model);
|
|
328
|
-
}
|
|
329
|
-
__name(clearStorage, "clearStorage");
|
|
330
|
-
function deleteStorage(tag) {
|
|
331
|
-
localStorage.removeItem(`_phecda_${tag}`);
|
|
332
|
-
}
|
|
333
|
-
__name(deleteStorage, "deleteStorage");
|
|
345
|
+
__name(initialize, "initialize");
|
|
334
346
|
|
|
335
347
|
// src/filter.ts
|
|
336
348
|
var import_vue4 = require("vue");
|
|
@@ -435,8 +447,11 @@ function createForm(compSet, form, formItem, options = {}) {
|
|
|
435
447
|
__name(generateChildVNode, "generateChildVNode");
|
|
436
448
|
function generateVNode(props) {
|
|
437
449
|
const { property } = props;
|
|
438
|
-
|
|
439
|
-
|
|
450
|
+
const item = props.config[property];
|
|
451
|
+
return (0, import_vue5.h)(compSet[item._component], {
|
|
452
|
+
...item,
|
|
453
|
+
onVnodeMounted: (vnode) => item._mount?.(vnode),
|
|
454
|
+
onVnodeUnmounted: (vnode) => item._unmount?.(vnode),
|
|
440
455
|
[`${modelKey}`]: props.data[property],
|
|
441
456
|
[`onUpdate:${modelKey}`]: (v) => {
|
|
442
457
|
if (onUpdate)
|
|
@@ -647,13 +662,13 @@ function getNutUIRules(Model, options = {}) {
|
|
|
647
662
|
__name(getNutUIRules, "getNutUIRules");
|
|
648
663
|
var getVantRules = getNutUIRules;
|
|
649
664
|
|
|
650
|
-
// src/components/
|
|
665
|
+
// src/components/createLayer.ts
|
|
651
666
|
var import_vue7 = require("vue");
|
|
652
|
-
var
|
|
667
|
+
var createLayer = /* @__PURE__ */ __name(function(modalWrapper, props = {}, modelKey = "modelValue") {
|
|
653
668
|
let isMounted = false;
|
|
654
|
-
const isShow = (0, import_vue7.
|
|
669
|
+
const isShow = (0, import_vue7.shallowRef)(true);
|
|
655
670
|
const content = (0, import_vue7.shallowRef)();
|
|
656
|
-
const propsRef = (0, import_vue7.
|
|
671
|
+
const propsRef = (0, import_vue7.shallowRef)({});
|
|
657
672
|
const wrapper = (0, import_vue7.defineComponent)({
|
|
658
673
|
setup() {
|
|
659
674
|
return () => (0, import_vue7.h)(modalWrapper, {
|
|
@@ -679,7 +694,7 @@ var createModal = /* @__PURE__ */ __name(function(modalWrapper, props = {}, mode
|
|
|
679
694
|
isShow.value = true;
|
|
680
695
|
}
|
|
681
696
|
};
|
|
682
|
-
}, "
|
|
697
|
+
}, "createLayer");
|
|
683
698
|
|
|
684
699
|
// src/components/createTable.ts
|
|
685
700
|
var import_vue8 = require("vue");
|
|
@@ -782,15 +797,13 @@ __name(PV, "PV");
|
|
|
782
797
|
FN_RE,
|
|
783
798
|
GetDevUIRules,
|
|
784
799
|
PV,
|
|
785
|
-
clearStorage,
|
|
786
800
|
createFilter,
|
|
787
801
|
createForm,
|
|
788
802
|
createFormData,
|
|
789
|
-
|
|
803
|
+
createLayer,
|
|
790
804
|
createPhecda,
|
|
791
805
|
createPipe,
|
|
792
806
|
createTable,
|
|
793
|
-
deleteStorage,
|
|
794
807
|
emitter,
|
|
795
808
|
getActivePhecda,
|
|
796
809
|
getAntDRules,
|
|
@@ -799,7 +812,7 @@ __name(PV, "PV");
|
|
|
799
812
|
getNutUIRules,
|
|
800
813
|
getReactiveMap,
|
|
801
814
|
getVantRules,
|
|
802
|
-
|
|
815
|
+
initialize,
|
|
803
816
|
phecdaSymbol,
|
|
804
817
|
setActivePhecda,
|
|
805
818
|
useEvent,
|
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,7 @@ var emitter = mitt();
|
|
|
7
7
|
|
|
8
8
|
// src/vue/phecda.ts
|
|
9
9
|
import { markRaw } from "vue";
|
|
10
|
-
import { getTag, injectProperty } from "phecda-core";
|
|
10
|
+
import { getProperty, getTag, injectProperty } from "phecda-core";
|
|
11
11
|
var phecdaSymbol = Symbol("phecda");
|
|
12
12
|
function createPhecda(symbol) {
|
|
13
13
|
const phecda = markRaw({
|
|
@@ -32,26 +32,49 @@ function createPhecda(symbol) {
|
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
34
|
let eventRecord = [];
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
35
|
+
if (!getProperty("watcher")) {
|
|
36
|
+
injectProperty("watcher", ({ eventName, instance, key, options }) => {
|
|
37
|
+
const fn = typeof instance[key] === "function" ? instance[key].bind(instance) : (v) => instance[key] = v;
|
|
38
|
+
if (options?.once) {
|
|
39
|
+
const handler = /* @__PURE__ */ __name((...args) => {
|
|
40
|
+
fn(...args);
|
|
41
|
+
emitter.off(eventName, handler);
|
|
42
|
+
}, "handler");
|
|
43
|
+
emitter.on(eventName, handler);
|
|
44
|
+
eventRecord.push([
|
|
45
|
+
eventName,
|
|
46
|
+
handler
|
|
47
|
+
]);
|
|
48
|
+
} else {
|
|
49
|
+
eventRecord.push([
|
|
50
|
+
eventName,
|
|
51
|
+
fn
|
|
52
|
+
]);
|
|
53
|
+
emitter.on(eventName, fn);
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
if (!getProperty("storage")) {
|
|
58
|
+
injectProperty("storage", ({ tag, key, instance }) => {
|
|
59
|
+
if (!tag)
|
|
60
|
+
return;
|
|
61
|
+
const initstr = localStorage.getItem(tag);
|
|
62
|
+
if (initstr) {
|
|
63
|
+
const data = JSON.parse(initstr);
|
|
64
|
+
if (key) {
|
|
65
|
+
instance[key] = data;
|
|
66
|
+
} else {
|
|
67
|
+
for (const i in data) {
|
|
68
|
+
if (i)
|
|
69
|
+
instance[i] = data[i];
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
globalThis.addEventListener("beforeunload", () => {
|
|
74
|
+
localStorage.setItem(tag, JSON.stringify(key ? instance[key] : instance));
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}
|
|
55
78
|
const originUnmount = app.unmount.bind(app);
|
|
56
79
|
app.unmount = () => {
|
|
57
80
|
eventRecord.forEach(([eventName, handler]) => emitter.off(eventName, handler));
|
|
@@ -255,23 +278,14 @@ function useEvent(eventName, cb) {
|
|
|
255
278
|
return () => emitter.off(eventName, cb);
|
|
256
279
|
}
|
|
257
280
|
__name(useEvent, "useEvent");
|
|
258
|
-
function
|
|
281
|
+
function initialize(Model) {
|
|
259
282
|
const instance = useO(Model);
|
|
260
283
|
if (instance) {
|
|
261
284
|
Object.assign(instance, new Model());
|
|
262
285
|
return instance;
|
|
263
286
|
}
|
|
264
287
|
}
|
|
265
|
-
__name(
|
|
266
|
-
function clearStorage(Model, isForceUpdate = true) {
|
|
267
|
-
localStorage.removeItem(`_phecda_${useO(Model)._symbol}`);
|
|
268
|
-
isForceUpdate && initalize(Model);
|
|
269
|
-
}
|
|
270
|
-
__name(clearStorage, "clearStorage");
|
|
271
|
-
function deleteStorage(tag) {
|
|
272
|
-
localStorage.removeItem(`_phecda_${tag}`);
|
|
273
|
-
}
|
|
274
|
-
__name(deleteStorage, "deleteStorage");
|
|
288
|
+
__name(initialize, "initialize");
|
|
275
289
|
|
|
276
290
|
// src/filter.ts
|
|
277
291
|
import { effectScope as effectScope2, reactive as reactive2, ref } from "vue";
|
|
@@ -376,8 +390,11 @@ function createForm(compSet, form, formItem, options = {}) {
|
|
|
376
390
|
__name(generateChildVNode, "generateChildVNode");
|
|
377
391
|
function generateVNode(props) {
|
|
378
392
|
const { property } = props;
|
|
379
|
-
|
|
380
|
-
|
|
393
|
+
const item = props.config[property];
|
|
394
|
+
return h(compSet[item._component], {
|
|
395
|
+
...item,
|
|
396
|
+
onVnodeMounted: (vnode) => item._mount?.(vnode),
|
|
397
|
+
onVnodeUnmounted: (vnode) => item._unmount?.(vnode),
|
|
381
398
|
[`${modelKey}`]: props.data[property],
|
|
382
399
|
[`onUpdate:${modelKey}`]: (v) => {
|
|
383
400
|
if (onUpdate)
|
|
@@ -588,13 +605,13 @@ function getNutUIRules(Model, options = {}) {
|
|
|
588
605
|
__name(getNutUIRules, "getNutUIRules");
|
|
589
606
|
var getVantRules = getNutUIRules;
|
|
590
607
|
|
|
591
|
-
// src/components/
|
|
592
|
-
import { defineComponent as defineComponent2, h as h2,
|
|
593
|
-
var
|
|
608
|
+
// src/components/createLayer.ts
|
|
609
|
+
import { defineComponent as defineComponent2, h as h2, render, shallowRef } from "vue";
|
|
610
|
+
var createLayer = /* @__PURE__ */ __name(function(modalWrapper, props = {}, modelKey = "modelValue") {
|
|
594
611
|
let isMounted = false;
|
|
595
|
-
const isShow =
|
|
612
|
+
const isShow = shallowRef(true);
|
|
596
613
|
const content = shallowRef();
|
|
597
|
-
const propsRef =
|
|
614
|
+
const propsRef = shallowRef({});
|
|
598
615
|
const wrapper = defineComponent2({
|
|
599
616
|
setup() {
|
|
600
617
|
return () => h2(modalWrapper, {
|
|
@@ -620,10 +637,10 @@ var createModal = /* @__PURE__ */ __name(function(modalWrapper, props = {}, mode
|
|
|
620
637
|
isShow.value = true;
|
|
621
638
|
}
|
|
622
639
|
};
|
|
623
|
-
}, "
|
|
640
|
+
}, "createLayer");
|
|
624
641
|
|
|
625
642
|
// src/components/createTable.ts
|
|
626
|
-
import { defineComponent as defineComponent3, h as h3, onMounted as onMounted2, ref as
|
|
643
|
+
import { defineComponent as defineComponent3, h as h3, onMounted as onMounted2, ref as ref3 } from "vue";
|
|
627
644
|
function createTable(compSet, table, tableColumn, data) {
|
|
628
645
|
const TableColumn = defineComponent3({
|
|
629
646
|
name: "PhecdaTableColumn",
|
|
@@ -657,7 +674,7 @@ function createTable(compSet, table, tableColumn, data) {
|
|
|
657
674
|
}
|
|
658
675
|
},
|
|
659
676
|
setup(props, ctx) {
|
|
660
|
-
const dom =
|
|
677
|
+
const dom = ref3();
|
|
661
678
|
onMounted2(() => {
|
|
662
679
|
ctx.expose({
|
|
663
680
|
...dom.value
|
|
@@ -722,15 +739,13 @@ export {
|
|
|
722
739
|
FN_RE,
|
|
723
740
|
GetDevUIRules,
|
|
724
741
|
PV,
|
|
725
|
-
clearStorage,
|
|
726
742
|
createFilter,
|
|
727
743
|
createForm,
|
|
728
744
|
createFormData,
|
|
729
|
-
|
|
745
|
+
createLayer,
|
|
730
746
|
createPhecda,
|
|
731
747
|
createPipe,
|
|
732
748
|
createTable,
|
|
733
|
-
deleteStorage,
|
|
734
749
|
emitter,
|
|
735
750
|
getActivePhecda,
|
|
736
751
|
getAntDRules,
|
|
@@ -739,7 +754,7 @@ export {
|
|
|
739
754
|
getNutUIRules,
|
|
740
755
|
getReactiveMap,
|
|
741
756
|
getVantRules,
|
|
742
|
-
|
|
757
|
+
initialize,
|
|
743
758
|
phecdaSymbol,
|
|
744
759
|
setActivePhecda,
|
|
745
760
|
useEvent,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "phecda-vue",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "provide store/form/table with phecda function to vue",
|
|
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.
|
|
17
|
+
"phecda-core": "1.2.0"
|
|
18
18
|
},
|
|
19
19
|
"devDependencies": {
|
|
20
20
|
"tsup": "^6.5.0"
|