phecda-vue 1.2.7 → 1.2.8
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/README.md +16 -0
- package/dist/index.d.ts +4 -1
- package/dist/index.js +48 -26
- package/dist/index.mjs +28 -6
- package/package.json +2 -2
package/README.md
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# phecda-vue
|
|
2
|
+
provide store/form/table with phecda function to vue
|
|
3
|
+
|
|
4
|
+
## store
|
|
5
|
+
```ts
|
|
6
|
+
// in model
|
|
7
|
+
import { useR, useV } from 'phecda-vue'
|
|
8
|
+
export class Test {
|
|
9
|
+
name = 'phecda'
|
|
10
|
+
changeName() {
|
|
11
|
+
this.name = 'vue'
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
const state = useR(Test) // reactive
|
|
15
|
+
const { name, changeName } = useV(Test)// ref
|
|
16
|
+
```
|
package/dist/index.d.ts
CHANGED
|
@@ -75,7 +75,10 @@ declare function createFilter<Data extends Record<string, any>>(initState?: Obje
|
|
|
75
75
|
|
|
76
76
|
declare function createForm<P extends {
|
|
77
77
|
$props: any;
|
|
78
|
-
}>(compSet: Record<string, Component> | any, form: Component<P>, formItem: Component | false,
|
|
78
|
+
}>(compSet: Record<string, Component> | any, form: Component<P>, formItem: Component | false, options?: {
|
|
79
|
+
modelKey?: string;
|
|
80
|
+
onUpdate?: (key: string) => void;
|
|
81
|
+
}): DefineComponent<{
|
|
79
82
|
config: Object;
|
|
80
83
|
data: Object;
|
|
81
84
|
} & P['$props']>;
|
package/dist/index.js
CHANGED
|
@@ -427,17 +427,20 @@ __reExport(src_exports, require("phecda-core"), module.exports);
|
|
|
427
427
|
|
|
428
428
|
// src/components/createForm.ts
|
|
429
429
|
var import_vue5 = require("vue");
|
|
430
|
-
function createForm(compSet, form, formItem,
|
|
430
|
+
function createForm(compSet, form, formItem, options = {}) {
|
|
431
|
+
const { modelKey = "modelValue", onUpdate } = options;
|
|
431
432
|
function generateChildVNode(props) {
|
|
432
433
|
return props._children?.map((item) => item._active === false ? null : (0, import_vue5.h)(compSet[item._component], item));
|
|
433
434
|
}
|
|
434
435
|
__name(generateChildVNode, "generateChildVNode");
|
|
435
436
|
function generateVNode(props) {
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
437
|
+
const { property } = props;
|
|
438
|
+
return (0, import_vue5.h)(compSet[props.config[property]._component], {
|
|
439
|
+
...props.config[property],
|
|
440
|
+
[`${modelKey}`]: props.data[property],
|
|
439
441
|
[`onUpdate:${modelKey}`]: (v) => {
|
|
440
|
-
props.data[
|
|
442
|
+
props.data[property] = v;
|
|
443
|
+
onUpdate?.(property);
|
|
441
444
|
}
|
|
442
445
|
}, {
|
|
443
446
|
default: () => generateChildVNode(props.config[props.property])
|
|
@@ -514,17 +517,36 @@ function createForm(compSet, form, formItem, modelKey = "modelValue") {
|
|
|
514
517
|
__name(createForm, "createForm");
|
|
515
518
|
|
|
516
519
|
// src/components/formFilter.ts
|
|
520
|
+
var import_vue6 = require("vue");
|
|
517
521
|
function createFormData(schema, initData = {}, options = {}) {
|
|
518
522
|
const { data, filter } = createFilter(initData, options);
|
|
519
523
|
initlize(schema, data.value);
|
|
520
524
|
const filterRet = filter(schema);
|
|
525
|
+
watchChange(schema, data.value);
|
|
521
526
|
function initlize(obj1, obj2) {
|
|
522
527
|
for (const i in obj1) {
|
|
523
|
-
if (obj1[i]
|
|
528
|
+
if ("_default" in obj1[i])
|
|
524
529
|
obj2[i] = obj1[i]._default;
|
|
525
530
|
}
|
|
526
531
|
}
|
|
527
532
|
__name(initlize, "initlize");
|
|
533
|
+
function watchChange(schema2, data2) {
|
|
534
|
+
for (const i in schema2) {
|
|
535
|
+
if ("_active" in schema2[i]) {
|
|
536
|
+
(0, import_vue6.watch)(() => filterRet[i]._active, (n) => {
|
|
537
|
+
if (n) {
|
|
538
|
+
if ("_default" in schema2[i])
|
|
539
|
+
data2[i] = schema2[i]._default;
|
|
540
|
+
} else {
|
|
541
|
+
delete data2[i];
|
|
542
|
+
}
|
|
543
|
+
}, {
|
|
544
|
+
immediate: true
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
__name(watchChange, "watchChange");
|
|
528
550
|
return {
|
|
529
551
|
config: filterRet,
|
|
530
552
|
data
|
|
@@ -624,22 +646,22 @@ __name(getNutUIRules, "getNutUIRules");
|
|
|
624
646
|
var getVantRules = getNutUIRules;
|
|
625
647
|
|
|
626
648
|
// src/components/createModal.ts
|
|
627
|
-
var
|
|
649
|
+
var import_vue7 = require("vue");
|
|
628
650
|
var createModal = /* @__PURE__ */ __name(function(modalWrapper, props = {}, modelKey = "modelValue") {
|
|
629
651
|
let isMounted = false;
|
|
630
|
-
const isShow = (0,
|
|
631
|
-
const content = (0,
|
|
632
|
-
const propsRef = (0,
|
|
633
|
-
const wrapper = (0,
|
|
652
|
+
const isShow = (0, import_vue7.ref)(true);
|
|
653
|
+
const content = (0, import_vue7.shallowRef)();
|
|
654
|
+
const propsRef = (0, import_vue7.ref)({});
|
|
655
|
+
const wrapper = (0, import_vue7.defineComponent)({
|
|
634
656
|
setup() {
|
|
635
|
-
return () => (0,
|
|
657
|
+
return () => (0, import_vue7.h)(modalWrapper, {
|
|
636
658
|
[modelKey]: isShow.value,
|
|
637
659
|
[`onUpdate:${modelKey}`]: (v) => {
|
|
638
660
|
isShow.value = v;
|
|
639
661
|
},
|
|
640
662
|
...props
|
|
641
663
|
}, {
|
|
642
|
-
default: () => content.value && (0,
|
|
664
|
+
default: () => content.value && (0, import_vue7.h)(content.value, propsRef.value)
|
|
643
665
|
});
|
|
644
666
|
}
|
|
645
667
|
});
|
|
@@ -648,8 +670,8 @@ var createModal = /* @__PURE__ */ __name(function(modalWrapper, props = {}, mode
|
|
|
648
670
|
propsRef.value = props2;
|
|
649
671
|
if (!isMounted) {
|
|
650
672
|
const el = document.createElement("div");
|
|
651
|
-
const vnode = (0,
|
|
652
|
-
document.body.appendChild(((0,
|
|
673
|
+
const vnode = (0, import_vue7.h)(wrapper);
|
|
674
|
+
document.body.appendChild(((0, import_vue7.render)(vnode, el), el));
|
|
653
675
|
isMounted = true;
|
|
654
676
|
} else {
|
|
655
677
|
isShow.value = true;
|
|
@@ -658,9 +680,9 @@ var createModal = /* @__PURE__ */ __name(function(modalWrapper, props = {}, mode
|
|
|
658
680
|
}, "createModal");
|
|
659
681
|
|
|
660
682
|
// src/components/createTable.ts
|
|
661
|
-
var
|
|
683
|
+
var import_vue8 = require("vue");
|
|
662
684
|
function createTable(compSet, table, tableColumn, data) {
|
|
663
|
-
const TableColumn = (0,
|
|
685
|
+
const TableColumn = (0, import_vue8.defineComponent)({
|
|
664
686
|
name: "PhecdaTableColumn",
|
|
665
687
|
props: {
|
|
666
688
|
tableColumn: {
|
|
@@ -670,11 +692,11 @@ function createTable(compSet, table, tableColumn, data) {
|
|
|
670
692
|
},
|
|
671
693
|
setup(props) {
|
|
672
694
|
const compName = props.tableColumn._component;
|
|
673
|
-
return () => (0,
|
|
695
|
+
return () => (0, import_vue8.h)(tableColumn, {
|
|
674
696
|
...props.tableColumn
|
|
675
697
|
}, {
|
|
676
698
|
default: (scope) => {
|
|
677
|
-
return compName ? (0,
|
|
699
|
+
return compName ? (0, import_vue8.h)(compSet[compName], {
|
|
678
700
|
scope,
|
|
679
701
|
data,
|
|
680
702
|
...props.tableColumn._props || {}
|
|
@@ -683,7 +705,7 @@ function createTable(compSet, table, tableColumn, data) {
|
|
|
683
705
|
});
|
|
684
706
|
}
|
|
685
707
|
});
|
|
686
|
-
return (0,
|
|
708
|
+
return (0, import_vue8.defineComponent)({
|
|
687
709
|
name: "PhecdaTable",
|
|
688
710
|
props: {
|
|
689
711
|
config: {
|
|
@@ -692,18 +714,18 @@ function createTable(compSet, table, tableColumn, data) {
|
|
|
692
714
|
}
|
|
693
715
|
},
|
|
694
716
|
setup(props, ctx) {
|
|
695
|
-
const dom = (0,
|
|
696
|
-
(0,
|
|
717
|
+
const dom = (0, import_vue8.ref)();
|
|
718
|
+
(0, import_vue8.onMounted)(() => {
|
|
697
719
|
ctx.expose({
|
|
698
720
|
...dom.value
|
|
699
721
|
});
|
|
700
722
|
});
|
|
701
723
|
return () => {
|
|
702
|
-
return (0,
|
|
724
|
+
return (0, import_vue8.h)(table, Object.assign({
|
|
703
725
|
ref: dom
|
|
704
726
|
}, ctx.attrs), {
|
|
705
727
|
default: () => props.config.map((item) => {
|
|
706
|
-
return (0,
|
|
728
|
+
return (0, import_vue8.h)(TableColumn, {
|
|
707
729
|
tableColumn: item
|
|
708
730
|
});
|
|
709
731
|
})
|
|
@@ -715,10 +737,10 @@ function createTable(compSet, table, tableColumn, data) {
|
|
|
715
737
|
__name(createTable, "createTable");
|
|
716
738
|
|
|
717
739
|
// src/components/helper/pipe.ts
|
|
718
|
-
var
|
|
740
|
+
var import_vue9 = require("vue");
|
|
719
741
|
function createPipe(comp, props, to = "default", slot) {
|
|
720
742
|
const vnodeMap = {
|
|
721
|
-
[`${to}`]: () => (0,
|
|
743
|
+
[`${to}`]: () => (0, import_vue9.h)(comp, props, slot)
|
|
722
744
|
};
|
|
723
745
|
return {
|
|
724
746
|
to(comp2, props2, to2 = "default") {
|
package/dist/index.mjs
CHANGED
|
@@ -368,17 +368,20 @@ export * from "phecda-core";
|
|
|
368
368
|
|
|
369
369
|
// src/components/createForm.ts
|
|
370
370
|
import { defineComponent, h, onMounted, ref as ref2 } from "vue";
|
|
371
|
-
function createForm(compSet, form, formItem,
|
|
371
|
+
function createForm(compSet, form, formItem, options = {}) {
|
|
372
|
+
const { modelKey = "modelValue", onUpdate } = options;
|
|
372
373
|
function generateChildVNode(props) {
|
|
373
374
|
return props._children?.map((item) => item._active === false ? null : h(compSet[item._component], item));
|
|
374
375
|
}
|
|
375
376
|
__name(generateChildVNode, "generateChildVNode");
|
|
376
377
|
function generateVNode(props) {
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
378
|
+
const { property } = props;
|
|
379
|
+
return h(compSet[props.config[property]._component], {
|
|
380
|
+
...props.config[property],
|
|
381
|
+
[`${modelKey}`]: props.data[property],
|
|
380
382
|
[`onUpdate:${modelKey}`]: (v) => {
|
|
381
|
-
props.data[
|
|
383
|
+
props.data[property] = v;
|
|
384
|
+
onUpdate?.(property);
|
|
382
385
|
}
|
|
383
386
|
}, {
|
|
384
387
|
default: () => generateChildVNode(props.config[props.property])
|
|
@@ -455,17 +458,36 @@ function createForm(compSet, form, formItem, modelKey = "modelValue") {
|
|
|
455
458
|
__name(createForm, "createForm");
|
|
456
459
|
|
|
457
460
|
// src/components/formFilter.ts
|
|
461
|
+
import { watch } from "vue";
|
|
458
462
|
function createFormData(schema, initData = {}, options = {}) {
|
|
459
463
|
const { data, filter } = createFilter(initData, options);
|
|
460
464
|
initlize(schema, data.value);
|
|
461
465
|
const filterRet = filter(schema);
|
|
466
|
+
watchChange(schema, data.value);
|
|
462
467
|
function initlize(obj1, obj2) {
|
|
463
468
|
for (const i in obj1) {
|
|
464
|
-
if (obj1[i]
|
|
469
|
+
if ("_default" in obj1[i])
|
|
465
470
|
obj2[i] = obj1[i]._default;
|
|
466
471
|
}
|
|
467
472
|
}
|
|
468
473
|
__name(initlize, "initlize");
|
|
474
|
+
function watchChange(schema2, data2) {
|
|
475
|
+
for (const i in schema2) {
|
|
476
|
+
if ("_active" in schema2[i]) {
|
|
477
|
+
watch(() => filterRet[i]._active, (n) => {
|
|
478
|
+
if (n) {
|
|
479
|
+
if ("_default" in schema2[i])
|
|
480
|
+
data2[i] = schema2[i]._default;
|
|
481
|
+
} else {
|
|
482
|
+
delete data2[i];
|
|
483
|
+
}
|
|
484
|
+
}, {
|
|
485
|
+
immediate: true
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
}
|
|
490
|
+
__name(watchChange, "watchChange");
|
|
469
491
|
return {
|
|
470
492
|
config: filterRet,
|
|
471
493
|
data
|
package/package.json
CHANGED