phecda-vue 2.0.4-alpha.2 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import { Events } from 'phecda-core';
2
2
  export * from 'phecda-core';
3
3
  import * as vue from 'vue';
4
- import { Ref, App, UnwrapNestedRefs, Component, DefineComponent, VNode } from 'vue';
4
+ import { Ref, App, UnwrapNestedRefs, Component } from 'vue';
5
5
  import { Handler } from 'mitt';
6
6
 
7
7
  type ReplaceInstanceValues<I> = {
@@ -67,67 +67,8 @@ declare function createFilter<Data extends Record<string, any>>(initState?: Obje
67
67
  delState: (key: string) => void;
68
68
  };
69
69
 
70
- declare function createForm<P extends {
71
- $props: any;
72
- }>(compSet: Record<string, Component> | any, form: Component<P>, formItem: Component | false, options?: {
73
- modelKey?: string;
74
- onUpdate?: (key: string, v: any) => void;
75
- }): DefineComponent<{
76
- config: Object;
77
- data: Object;
78
- } & P['$props']>;
79
-
80
- declare function createFormData<Schema extends object, Data extends object>(schema: Schema, initData?: Data, options?: {
81
- expressionRE?: RegExp;
82
- fnRE?: RegExp;
83
- exclude?: string[];
84
- }): {
85
- config: SchemaToObj<Schema>;
86
- data: vue.Ref<Record<string, any>>;
87
- };
88
-
89
- declare function getElementPlusRules<M, O extends object>(Model: M, options?: O): any;
90
- declare const GetDevUIRules: typeof getElementPlusRules;
91
- declare function getNaiveUIRules<M, O extends object>(Model: M, options?: O): any;
92
- declare const getAntDRules: typeof getNaiveUIRules;
93
- declare function getNutUIRules<M, O extends object>(Model: M, options?: O): any;
94
- declare const getVantRules: typeof getNutUIRules;
95
- declare function getArcoRules<M, O extends object>(Model: M, options?: O): any;
96
-
97
70
  declare const createLayer: <T>(wrapComp: Component<T>, props?: Partial<T>, modelKey?: string) => <P>(comp: Component<P>, props?: P, modalProps?: Partial<T>) => void;
98
71
 
99
- declare function createTable<P extends {
100
- $props: any;
101
- }>(compSet: Record<string, Component> | any, options: {
102
- table: Component<P>;
103
- column?: Component | false;
104
- data?: any;
105
- columnSlot?: string;
106
- cellSlot?: string;
107
- }): DefineComponent<{
108
- config: Object;
109
- } & P['$props']>;
110
-
111
- declare function createPipe<Props extends {
112
- $props: any;
113
- }>(comp: Component<Props>, props: Props['$props'] & {
114
- [key in string]: any;
115
- }, to?: string, slot?: any): PipeRet;
116
- interface PipeRet {
117
- to: <Props extends {
118
- $props: any;
119
- }>(comp: Component<Props>, props: Props['$props'] & {
120
- [key in string]: any;
121
- }, to: string) => PipeRet;
122
- get: Record<string, () => VNode>;
123
- }
124
-
125
- declare const createModal: <T1, T2>(wrapComp: Component<T1>, comp: Component<T2>, opts?: {
126
- modelKey?: string;
127
- wrapProps?: Partial<T1>;
128
- compProps?: Partial<T2>;
129
- }) => (props?: Partial<T2>, modalProps?: Partial<T1>) => void;
130
-
131
72
  declare const createDialog: <T>(comp: Component<T>, opts?: {
132
73
  modelKey?: string;
133
74
  props?: Partial<T>;
@@ -141,4 +82,4 @@ declare class PV {
141
82
  off<Key extends keyof Events>(type: Key, handler?: (arg: Events[Key]) => void): void;
142
83
  }
143
84
 
144
- export { GetDevUIRules, PV, PhecdaEmitter, RE, ReplaceInstanceValues, SchemaToObj, createDialog, createFilter, createForm, createFormData, createLayer, createModal, createPhecda, createPipe, createTable, emitter, getActivePhecda, getAntDRules, getArcoRules, getElementPlusRules, getNaiveUIRules, getNutUIRules, getReactiveMap, getVantRules, initialize, interval, phecdaSymbol, setActivePhecda, useEvent, useO, usePatch, useR, useRaw, useV };
85
+ export { PV, PhecdaEmitter, RE, ReplaceInstanceValues, SchemaToObj, createDialog, createFilter, createLayer, createPhecda, emitter, getActivePhecda, getReactiveMap, initialize, interval, phecdaSymbol, setActivePhecda, useEvent, useO, usePatch, useR, useRaw, useV };
package/dist/index.js CHANGED
@@ -28,27 +28,15 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
28
28
  // src/index.ts
29
29
  var src_exports = {};
30
30
  __export(src_exports, {
31
- GetDevUIRules: () => GetDevUIRules,
32
31
  PV: () => PV,
33
32
  RE: () => RE,
34
33
  createDialog: () => createDialog,
35
34
  createFilter: () => createFilter,
36
- createForm: () => createForm,
37
- createFormData: () => createFormData,
38
35
  createLayer: () => createLayer,
39
- createModal: () => createModal,
40
36
  createPhecda: () => createPhecda,
41
- createPipe: () => createPipe,
42
- createTable: () => createTable,
43
37
  emitter: () => emitter,
44
38
  getActivePhecda: () => getActivePhecda,
45
- getAntDRules: () => getAntDRules,
46
- getArcoRules: () => getArcoRules,
47
- getElementPlusRules: () => getElementPlusRules,
48
- getNaiveUIRules: () => getNaiveUIRules,
49
- getNutUIRules: () => getNutUIRules,
50
39
  getReactiveMap: () => getReactiveMap,
51
- getVantRules: () => getVantRules,
52
40
  initialize: () => initialize,
53
41
  interval: () => interval,
54
42
  phecdaSymbol: () => phecdaSymbol,
@@ -445,295 +433,24 @@ __name(createFilter, "createFilter");
445
433
  // src/index.ts
446
434
  __reExport(src_exports, require("phecda-core"), module.exports);
447
435
 
448
- // src/components/createForm.ts
449
- var import_vue5 = require("vue");
450
- function createForm(compSet, form, formItem, options = {}) {
451
- const { modelKey = "modelValue", onUpdate } = options;
452
- function generateChildVNode(props) {
453
- return props._children?.map((item) => {
454
- if (item._active === false)
455
- return null;
456
- if (typeof item === "string")
457
- return item;
458
- return (0, import_vue5.h)(compSet[item._component] || item._component, item);
459
- });
460
- }
461
- __name(generateChildVNode, "generateChildVNode");
462
- function generateVNode(props) {
463
- const { property } = props;
464
- const item = props.config[property];
465
- if (!item._component)
466
- return (0, import_vue5.h)(item);
467
- return (0, import_vue5.h)(compSet[item._component] || item._component, {
468
- onVnodeMounted: (vnode) => item._mount?.(vnode),
469
- onVnodeUnmounted: (vnode) => item._unmount?.(vnode),
470
- [`${modelKey}`]: props.data[property],
471
- [`onUpdate:${modelKey}`]: (v) => {
472
- if (onUpdate)
473
- onUpdate(property, v);
474
- else
475
- props.data[property] = v;
476
- },
477
- ...item
478
- }, {
479
- default: () => generateChildVNode(props.config[props.property])
480
- });
481
- }
482
- __name(generateVNode, "generateVNode");
483
- const FormItem = (0, import_vue5.defineComponent)({
484
- name: "CustomFormItem",
485
- props: {
486
- formItem: {
487
- type: Object
488
- },
489
- config: {
490
- type: Object,
491
- required: true
492
- },
493
- data: {
494
- type: Object,
495
- required: true
496
- },
497
- property: {
498
- type: String,
499
- required: true
500
- }
501
- },
502
- setup(props) {
503
- return () => {
504
- return formItem ? (0, import_vue5.h)(formItem, {
505
- ...props.formItem
506
- }, {
507
- default: () => {
508
- return generateVNode(props);
509
- }
510
- }) : generateVNode(props);
511
- };
512
- }
513
- });
514
- return (0, import_vue5.defineComponent)({
515
- name: "CustomForm",
516
- props: {
517
- config: {
518
- type: Object,
519
- required: true
520
- },
521
- data: {
522
- type: Object,
523
- required: true
524
- }
525
- },
526
- setup(props, ctx) {
527
- const dom = (0, import_vue5.ref)();
528
- (0, import_vue5.onMounted)(() => {
529
- ctx.expose({
530
- ...dom.value
531
- });
532
- });
533
- return () => {
534
- return (0, import_vue5.h)(form, Object.assign({
535
- ref: dom
536
- }, ctx.attrs), {
537
- default: () => Object.keys(props.config).map((item) => {
538
- return props.config[item]._active === false ? null : (0, import_vue5.h)(FormItem, {
539
- formItem: props.config[item]._formItem,
540
- config: props.config,
541
- property: item,
542
- data: props.data
543
- });
544
- })
545
- });
546
- };
547
- }
548
- });
549
- }
550
- __name(createForm, "createForm");
551
-
552
- // src/components/formFilter.ts
553
- var import_vue6 = require("vue");
554
- function createFormData(schema, initData = {}, options = {}) {
555
- const { data, filter } = createFilter(initData, options);
556
- initlize(schema, data.value);
557
- const filterRet = filter(schema);
558
- watchChange(schema, data.value);
559
- function initlize(obj1, obj2) {
560
- for (const i in obj1) {
561
- if ("_default" in obj1[i])
562
- obj2[i] = obj1[i]._default;
563
- }
564
- }
565
- __name(initlize, "initlize");
566
- function watchChange(schema2, data2) {
567
- for (const i in schema2) {
568
- if ("_active" in schema2[i]) {
569
- (0, import_vue6.watch)(() => filterRet[i]._active, (n) => {
570
- if (n) {
571
- if ("_default" in schema2[i])
572
- data2[i] = schema2[i]._default;
573
- } else {
574
- delete data2[i];
575
- }
576
- }, {
577
- immediate: true
578
- });
579
- }
580
- }
581
- }
582
- __name(watchChange, "watchChange");
583
- return {
584
- config: filterRet,
585
- data
586
- };
587
- }
588
- __name(createFormData, "createFormData");
589
-
590
- // src/components/formResolve.ts
591
- var import_phecda_core3 = require("phecda-core");
592
- async function validate(p, v) {
593
- if (typeof p === "string" || typeof p === "number") {
594
- if (v === p)
595
- return true;
596
- }
597
- if (typeof p === "function")
598
- return p(v);
599
- if (p instanceof RegExp)
600
- return p.test(v);
601
- return false;
602
- }
603
- __name(validate, "validate");
604
- function getElementPlusRules(Model, options = {}) {
605
- const stateVars = (0, import_phecda_core3.getExposeKey)(Model);
606
- const ret = {};
607
- for (const item of stateVars) {
608
- const handlers = (0, import_phecda_core3.getHandler)(Model, item);
609
- if (handlers) {
610
- for (const handler of handlers) {
611
- const { rule, meta, info } = handler;
612
- if (rule) {
613
- if (!ret[item])
614
- ret[item] = [];
615
- ret[item].push({
616
- validator: async (_, value, callback) => {
617
- if (!await validate(rule, value))
618
- callback(new Error(info || ""));
619
- else
620
- callback();
621
- },
622
- ...options,
623
- ...meta || {}
624
- });
625
- }
626
- }
627
- }
628
- }
629
- return ret;
630
- }
631
- __name(getElementPlusRules, "getElementPlusRules");
632
- var GetDevUIRules = getElementPlusRules;
633
- function getNaiveUIRules(Model, options = {}) {
634
- const stateVars = (0, import_phecda_core3.getExposeKey)(Model);
635
- const ret = {};
636
- for (const item of stateVars) {
637
- const handlers = (0, import_phecda_core3.getHandler)(Model, item);
638
- if (handlers) {
639
- for (const handler of handlers) {
640
- const { rule, meta, info } = handler;
641
- if (rule) {
642
- if (!ret[item])
643
- ret[item] = [];
644
- ret[item].push({
645
- validator: async (_, value) => {
646
- if (!await validate(rule, value))
647
- return Promise.reject(info);
648
- else
649
- return Promise.resolve();
650
- },
651
- ...options,
652
- ...meta || {}
653
- });
654
- }
655
- }
656
- }
657
- }
658
- return ret;
659
- }
660
- __name(getNaiveUIRules, "getNaiveUIRules");
661
- var getAntDRules = getNaiveUIRules;
662
- function getNutUIRules(Model, options = {}) {
663
- const stateVars = (0, import_phecda_core3.getExposeKey)(Model);
664
- const ret = {};
665
- for (const item of stateVars) {
666
- const handlers = (0, import_phecda_core3.getHandler)(Model, item);
667
- if (handlers) {
668
- for (const handler of handlers) {
669
- const { rule, meta, info } = handler;
670
- if (rule) {
671
- if (!ret[item])
672
- ret[item] = [];
673
- ret[item].push({
674
- validator: async (_, value) => {
675
- if (!await validate(rule, value))
676
- return false;
677
- else
678
- return true;
679
- },
680
- message: info,
681
- ...options,
682
- ...meta || {}
683
- });
684
- }
685
- }
686
- }
687
- }
688
- return ret;
689
- }
690
- __name(getNutUIRules, "getNutUIRules");
691
- var getVantRules = getNutUIRules;
692
- function getArcoRules(Model, options = {}) {
693
- const stateVars = (0, import_phecda_core3.getExposeKey)(Model);
694
- const ret = {};
695
- for (const item of stateVars) {
696
- const handlers = (0, import_phecda_core3.getHandler)(Model, item);
697
- if (handlers) {
698
- for (const handler of handlers) {
699
- const { rule, meta, info } = handler;
700
- if (rule) {
701
- if (!ret[item])
702
- ret[item] = [];
703
- ret[item].push({
704
- validator: async (value, cb) => {
705
- if (!await validate(rule, value))
706
- cb(info);
707
- },
708
- ...options,
709
- ...meta || {}
710
- });
711
- }
712
- }
713
- }
714
- }
715
- return ret;
716
- }
717
- __name(getArcoRules, "getArcoRules");
718
-
719
436
  // src/components/createLayer.ts
720
- var import_vue7 = require("vue");
437
+ var import_vue5 = require("vue");
721
438
  var createLayer = /* @__PURE__ */ __name(function(modalWrapper, content_props = {}, modelKey = "modelValue") {
722
439
  let isMounted = false;
723
- const isShow = (0, import_vue7.shallowRef)(true);
724
- const content = (0, import_vue7.shallowRef)();
725
- const contentProps = (0, import_vue7.shallowRef)({});
726
- const modalProps = (0, import_vue7.shallowRef)({});
727
- const wrapper = (0, import_vue7.defineComponent)({
440
+ const isShow = (0, import_vue5.shallowRef)(true);
441
+ const content = (0, import_vue5.shallowRef)();
442
+ const contentProps = (0, import_vue5.shallowRef)({});
443
+ const modalProps = (0, import_vue5.shallowRef)({});
444
+ const wrapper = (0, import_vue5.defineComponent)({
728
445
  setup() {
729
- return () => (0, import_vue7.h)(modalWrapper, {
446
+ return () => (0, import_vue5.h)(modalWrapper, {
730
447
  [modelKey]: isShow.value,
731
448
  [`onUpdate:${modelKey}`]: (v) => {
732
449
  isShow.value = v;
733
450
  },
734
451
  ...modalProps.value
735
452
  }, {
736
- default: (slot = {}) => content.value && (0, import_vue7.h)(content.value, {
453
+ default: (slot = {}) => content.value && (0, import_vue5.h)(content.value, {
737
454
  ...contentProps.value,
738
455
  ...slot
739
456
  })
@@ -746,9 +463,9 @@ var createLayer = /* @__PURE__ */ __name(function(modalWrapper, content_props =
746
463
  modalProps.value = Object.assign({}, content_props, modal_props);
747
464
  if (!isMounted) {
748
465
  const el = document.createElement("div");
749
- const vnode = (0, import_vue7.h)(wrapper);
466
+ const vnode = (0, import_vue5.h)(wrapper);
750
467
  vnode.appContext = interval.app?._context;
751
- document.body.appendChild(((0, import_vue7.render)(vnode, el), el));
468
+ document.body.appendChild(((0, import_vue5.render)(vnode, el), el));
752
469
  isMounted = true;
753
470
  } else {
754
471
  isShow.value = true;
@@ -756,138 +473,16 @@ var createLayer = /* @__PURE__ */ __name(function(modalWrapper, content_props =
756
473
  };
757
474
  }, "createLayer");
758
475
 
759
- // src/components/createTable.ts
760
- var import_vue8 = require("vue");
761
- function createTable(compSet, options) {
762
- const { table, column: tableColumn, data, cellSlot = "default", columnSlot = "default" } = options;
763
- const TableColumn = (0, import_vue8.defineComponent)({
764
- name: "PhecdaTableColumn",
765
- setup(_props, { attrs }) {
766
- const compName = attrs._component;
767
- const childrens = attrs._children && {
768
- default: () => attrs._children.map((child) => (0, import_vue8.h)(tableColumn, child))
769
- };
770
- if (tableColumn) {
771
- return () => (0, import_vue8.h)(tableColumn, attrs, compName ? {
772
- [`${cellSlot}`]: (scope) => {
773
- const childrenProps = typeof attrs._props === "function" ? attrs._props?.(scope) : attrs._props;
774
- return (0, import_vue8.h)(compSet[compName], {
775
- data,
776
- ...childrenProps || {}
777
- }, childrenProps?._slots);
778
- }
779
- } : childrens);
780
- } else {
781
- return (scope) => {
782
- const childrenProps = typeof attrs._props === "function" ? attrs._props?.(scope) : attrs._props;
783
- return compName ? (0, import_vue8.h)(compSet[compName], {
784
- scope,
785
- data,
786
- ...childrenProps || {}
787
- }, childrenProps?._slots) : childrens;
788
- };
789
- }
790
- }
791
- });
792
- return (0, import_vue8.defineComponent)({
793
- name: "PhecdaTable",
794
- props: {
795
- config: {
796
- type: Array,
797
- required: true
798
- }
799
- },
800
- setup(props, ctx) {
801
- const dom = (0, import_vue8.ref)();
802
- (0, import_vue8.onMounted)(() => {
803
- ctx.expose({
804
- ...dom.value
805
- });
806
- });
807
- return () => {
808
- return (0, import_vue8.h)(table, Object.assign({
809
- ref: dom
810
- }, ctx.attrs), {
811
- [`${columnSlot}`]: (scope) => props.config.map((item) => {
812
- item = typeof item === "function" ? item(scope) : item;
813
- return (0, import_vue8.h)(TableColumn, item);
814
- })
815
- });
816
- };
817
- }
818
- });
819
- }
820
- __name(createTable, "createTable");
821
-
822
- // src/components/helper/pipe.ts
823
- var import_vue9 = require("vue");
824
- function createPipe(comp, props, to = "default", slot) {
825
- const vnodeMap = {
826
- [`${to}`]: () => (0, import_vue9.h)(comp, props, slot)
827
- };
828
- return {
829
- to(comp2, props2, to2 = "default") {
830
- return createPipe(comp2, props2, to2, vnodeMap);
831
- },
832
- get() {
833
- return vnodeMap;
834
- },
835
- bind(vnode, to2) {
836
- vnodeMap[to2] = () => vnode;
837
- }
838
- };
839
- }
840
- __name(createPipe, "createPipe");
841
-
842
- // src/components/createModal.ts
843
- var import_vue10 = require("vue");
844
- var createModal = /* @__PURE__ */ __name(function(wrapComp, comp, opts = {}) {
845
- let isMounted = false;
846
- const { modelKey = "modelValue", wrapProps = {}, compProps = {} } = opts;
847
- const isShow = (0, import_vue10.shallowRef)(true);
848
- const contentProps = (0, import_vue10.shallowRef)({});
849
- const modalProps = (0, import_vue10.shallowRef)({});
850
- const wrapper = (0, import_vue10.defineComponent)({
851
- setup() {
852
- return () => (0, import_vue10.h)(wrapComp, {
853
- [modelKey]: isShow.value,
854
- [`onUpdate:${modelKey}`]: (v) => {
855
- isShow.value = v;
856
- },
857
- ...modalProps.value
858
- }, {
859
- default: (slot = {}) => (0, import_vue10.h)(comp, {
860
- ...slot,
861
- ...contentProps.value
862
- })
863
- });
864
- }
865
- });
866
- return (props, wrap_props) => {
867
- contentProps.value = Object.assign({}, compProps, props);
868
- modalProps.value = Object.assign({}, wrapProps, wrap_props);
869
- if (!isMounted) {
870
- const el = document.createElement("div");
871
- const vnode = (0, import_vue10.h)(wrapper);
872
- vnode.appContext = interval.app?._context;
873
- document.body.appendChild(((0, import_vue10.render)(vnode, el), el));
874
- isMounted = true;
875
- } else {
876
- isShow.value = true;
877
- }
878
- };
879
- }, "createModal");
880
-
881
476
  // src/components/createDialog.ts
882
- var import_vue11 = require("vue");
477
+ var import_vue6 = require("vue");
883
478
  var createDialog = /* @__PURE__ */ __name(function(comp, opts = {}) {
884
479
  let isMounted = false;
885
480
  const { modelKey = "modelValue", props = {} } = opts;
886
- const isShow = (0, import_vue11.shallowRef)(true);
887
- const contentProps = (0, import_vue11.shallowRef)({});
888
- const wrapper = (0, import_vue11.defineComponent)({
481
+ const isShow = (0, import_vue6.shallowRef)(true);
482
+ const contentProps = (0, import_vue6.shallowRef)({});
483
+ const wrapper = (0, import_vue6.defineComponent)({
889
484
  setup() {
890
- return () => (0, import_vue11.h)(comp, {
485
+ return () => (0, import_vue6.h)(comp, {
891
486
  [modelKey]: isShow.value,
892
487
  [`onUpdate:${modelKey}`]: (v) => {
893
488
  isShow.value = v;
@@ -900,9 +495,9 @@ var createDialog = /* @__PURE__ */ __name(function(comp, opts = {}) {
900
495
  contentProps.value = Object.assign({}, props, _props);
901
496
  if (!isMounted) {
902
497
  const el = document.createElement("div");
903
- const vnode = (0, import_vue11.h)(wrapper);
498
+ const vnode = (0, import_vue6.h)(wrapper);
904
499
  vnode.appContext = interval.app?._context;
905
- document.body.appendChild(((0, import_vue11.render)(vnode, el), el));
500
+ document.body.appendChild(((0, import_vue6.render)(vnode, el), el));
906
501
  isMounted = true;
907
502
  } else {
908
503
  isShow.value = true;
@@ -930,27 +525,15 @@ var PV = class {
930
525
  __name(PV, "PV");
931
526
  // Annotate the CommonJS export names for ESM import in node:
932
527
  0 && (module.exports = {
933
- GetDevUIRules,
934
528
  PV,
935
529
  RE,
936
530
  createDialog,
937
531
  createFilter,
938
- createForm,
939
- createFormData,
940
532
  createLayer,
941
- createModal,
942
533
  createPhecda,
943
- createPipe,
944
- createTable,
945
534
  emitter,
946
535
  getActivePhecda,
947
- getAntDRules,
948
- getArcoRules,
949
- getElementPlusRules,
950
- getNaiveUIRules,
951
- getNutUIRules,
952
536
  getReactiveMap,
953
- getVantRules,
954
537
  initialize,
955
538
  interval,
956
539
  phecdaSymbol,
package/dist/index.mjs CHANGED
@@ -384,295 +384,24 @@ __name(createFilter, "createFilter");
384
384
  // src/index.ts
385
385
  export * from "phecda-core";
386
386
 
387
- // src/components/createForm.ts
388
- import { defineComponent, h, onMounted, ref as ref2 } from "vue";
389
- function createForm(compSet, form, formItem, options = {}) {
390
- const { modelKey = "modelValue", onUpdate } = options;
391
- function generateChildVNode(props) {
392
- return props._children?.map((item) => {
393
- if (item._active === false)
394
- return null;
395
- if (typeof item === "string")
396
- return item;
397
- return h(compSet[item._component] || item._component, item);
398
- });
399
- }
400
- __name(generateChildVNode, "generateChildVNode");
401
- function generateVNode(props) {
402
- const { property } = props;
403
- const item = props.config[property];
404
- if (!item._component)
405
- return h(item);
406
- return h(compSet[item._component] || item._component, {
407
- onVnodeMounted: (vnode) => item._mount?.(vnode),
408
- onVnodeUnmounted: (vnode) => item._unmount?.(vnode),
409
- [`${modelKey}`]: props.data[property],
410
- [`onUpdate:${modelKey}`]: (v) => {
411
- if (onUpdate)
412
- onUpdate(property, v);
413
- else
414
- props.data[property] = v;
415
- },
416
- ...item
417
- }, {
418
- default: () => generateChildVNode(props.config[props.property])
419
- });
420
- }
421
- __name(generateVNode, "generateVNode");
422
- const FormItem = defineComponent({
423
- name: "CustomFormItem",
424
- props: {
425
- formItem: {
426
- type: Object
427
- },
428
- config: {
429
- type: Object,
430
- required: true
431
- },
432
- data: {
433
- type: Object,
434
- required: true
435
- },
436
- property: {
437
- type: String,
438
- required: true
439
- }
440
- },
441
- setup(props) {
442
- return () => {
443
- return formItem ? h(formItem, {
444
- ...props.formItem
445
- }, {
446
- default: () => {
447
- return generateVNode(props);
448
- }
449
- }) : generateVNode(props);
450
- };
451
- }
452
- });
453
- return defineComponent({
454
- name: "CustomForm",
455
- props: {
456
- config: {
457
- type: Object,
458
- required: true
459
- },
460
- data: {
461
- type: Object,
462
- required: true
463
- }
464
- },
465
- setup(props, ctx) {
466
- const dom = ref2();
467
- onMounted(() => {
468
- ctx.expose({
469
- ...dom.value
470
- });
471
- });
472
- return () => {
473
- return h(form, Object.assign({
474
- ref: dom
475
- }, ctx.attrs), {
476
- default: () => Object.keys(props.config).map((item) => {
477
- return props.config[item]._active === false ? null : h(FormItem, {
478
- formItem: props.config[item]._formItem,
479
- config: props.config,
480
- property: item,
481
- data: props.data
482
- });
483
- })
484
- });
485
- };
486
- }
487
- });
488
- }
489
- __name(createForm, "createForm");
490
-
491
- // src/components/formFilter.ts
492
- import { watch } from "vue";
493
- function createFormData(schema, initData = {}, options = {}) {
494
- const { data, filter } = createFilter(initData, options);
495
- initlize(schema, data.value);
496
- const filterRet = filter(schema);
497
- watchChange(schema, data.value);
498
- function initlize(obj1, obj2) {
499
- for (const i in obj1) {
500
- if ("_default" in obj1[i])
501
- obj2[i] = obj1[i]._default;
502
- }
503
- }
504
- __name(initlize, "initlize");
505
- function watchChange(schema2, data2) {
506
- for (const i in schema2) {
507
- if ("_active" in schema2[i]) {
508
- watch(() => filterRet[i]._active, (n) => {
509
- if (n) {
510
- if ("_default" in schema2[i])
511
- data2[i] = schema2[i]._default;
512
- } else {
513
- delete data2[i];
514
- }
515
- }, {
516
- immediate: true
517
- });
518
- }
519
- }
520
- }
521
- __name(watchChange, "watchChange");
522
- return {
523
- config: filterRet,
524
- data
525
- };
526
- }
527
- __name(createFormData, "createFormData");
528
-
529
- // src/components/formResolve.ts
530
- import { getExposeKey, getHandler as getHandler2 } from "phecda-core";
531
- async function validate(p, v) {
532
- if (typeof p === "string" || typeof p === "number") {
533
- if (v === p)
534
- return true;
535
- }
536
- if (typeof p === "function")
537
- return p(v);
538
- if (p instanceof RegExp)
539
- return p.test(v);
540
- return false;
541
- }
542
- __name(validate, "validate");
543
- function getElementPlusRules(Model, options = {}) {
544
- const stateVars = getExposeKey(Model);
545
- const ret = {};
546
- for (const item of stateVars) {
547
- const handlers = getHandler2(Model, item);
548
- if (handlers) {
549
- for (const handler of handlers) {
550
- const { rule, meta, info } = handler;
551
- if (rule) {
552
- if (!ret[item])
553
- ret[item] = [];
554
- ret[item].push({
555
- validator: async (_, value, callback) => {
556
- if (!await validate(rule, value))
557
- callback(new Error(info || ""));
558
- else
559
- callback();
560
- },
561
- ...options,
562
- ...meta || {}
563
- });
564
- }
565
- }
566
- }
567
- }
568
- return ret;
569
- }
570
- __name(getElementPlusRules, "getElementPlusRules");
571
- var GetDevUIRules = getElementPlusRules;
572
- function getNaiveUIRules(Model, options = {}) {
573
- const stateVars = getExposeKey(Model);
574
- const ret = {};
575
- for (const item of stateVars) {
576
- const handlers = getHandler2(Model, item);
577
- if (handlers) {
578
- for (const handler of handlers) {
579
- const { rule, meta, info } = handler;
580
- if (rule) {
581
- if (!ret[item])
582
- ret[item] = [];
583
- ret[item].push({
584
- validator: async (_, value) => {
585
- if (!await validate(rule, value))
586
- return Promise.reject(info);
587
- else
588
- return Promise.resolve();
589
- },
590
- ...options,
591
- ...meta || {}
592
- });
593
- }
594
- }
595
- }
596
- }
597
- return ret;
598
- }
599
- __name(getNaiveUIRules, "getNaiveUIRules");
600
- var getAntDRules = getNaiveUIRules;
601
- function getNutUIRules(Model, options = {}) {
602
- const stateVars = getExposeKey(Model);
603
- const ret = {};
604
- for (const item of stateVars) {
605
- const handlers = getHandler2(Model, item);
606
- if (handlers) {
607
- for (const handler of handlers) {
608
- const { rule, meta, info } = handler;
609
- if (rule) {
610
- if (!ret[item])
611
- ret[item] = [];
612
- ret[item].push({
613
- validator: async (_, value) => {
614
- if (!await validate(rule, value))
615
- return false;
616
- else
617
- return true;
618
- },
619
- message: info,
620
- ...options,
621
- ...meta || {}
622
- });
623
- }
624
- }
625
- }
626
- }
627
- return ret;
628
- }
629
- __name(getNutUIRules, "getNutUIRules");
630
- var getVantRules = getNutUIRules;
631
- function getArcoRules(Model, options = {}) {
632
- const stateVars = getExposeKey(Model);
633
- const ret = {};
634
- for (const item of stateVars) {
635
- const handlers = getHandler2(Model, item);
636
- if (handlers) {
637
- for (const handler of handlers) {
638
- const { rule, meta, info } = handler;
639
- if (rule) {
640
- if (!ret[item])
641
- ret[item] = [];
642
- ret[item].push({
643
- validator: async (value, cb) => {
644
- if (!await validate(rule, value))
645
- cb(info);
646
- },
647
- ...options,
648
- ...meta || {}
649
- });
650
- }
651
- }
652
- }
653
- }
654
- return ret;
655
- }
656
- __name(getArcoRules, "getArcoRules");
657
-
658
387
  // src/components/createLayer.ts
659
- import { defineComponent as defineComponent2, h as h2, render, shallowRef } from "vue";
388
+ import { defineComponent, h, render, shallowRef } from "vue";
660
389
  var createLayer = /* @__PURE__ */ __name(function(modalWrapper, content_props = {}, modelKey = "modelValue") {
661
390
  let isMounted = false;
662
391
  const isShow = shallowRef(true);
663
392
  const content = shallowRef();
664
393
  const contentProps = shallowRef({});
665
394
  const modalProps = shallowRef({});
666
- const wrapper = defineComponent2({
395
+ const wrapper = defineComponent({
667
396
  setup() {
668
- return () => h2(modalWrapper, {
397
+ return () => h(modalWrapper, {
669
398
  [modelKey]: isShow.value,
670
399
  [`onUpdate:${modelKey}`]: (v) => {
671
400
  isShow.value = v;
672
401
  },
673
402
  ...modalProps.value
674
403
  }, {
675
- default: (slot = {}) => content.value && h2(content.value, {
404
+ default: (slot = {}) => content.value && h(content.value, {
676
405
  ...contentProps.value,
677
406
  ...slot
678
407
  })
@@ -685,7 +414,7 @@ var createLayer = /* @__PURE__ */ __name(function(modalWrapper, content_props =
685
414
  modalProps.value = Object.assign({}, content_props, modal_props);
686
415
  if (!isMounted) {
687
416
  const el = document.createElement("div");
688
- const vnode = h2(wrapper);
417
+ const vnode = h(wrapper);
689
418
  vnode.appContext = interval.app?._context;
690
419
  document.body.appendChild((render(vnode, el), el));
691
420
  isMounted = true;
@@ -695,138 +424,16 @@ var createLayer = /* @__PURE__ */ __name(function(modalWrapper, content_props =
695
424
  };
696
425
  }, "createLayer");
697
426
 
698
- // src/components/createTable.ts
699
- import { defineComponent as defineComponent3, h as h3, onMounted as onMounted2, ref as ref3 } from "vue";
700
- function createTable(compSet, options) {
701
- const { table, column: tableColumn, data, cellSlot = "default", columnSlot = "default" } = options;
702
- const TableColumn = defineComponent3({
703
- name: "PhecdaTableColumn",
704
- setup(_props, { attrs }) {
705
- const compName = attrs._component;
706
- const childrens = attrs._children && {
707
- default: () => attrs._children.map((child) => h3(tableColumn, child))
708
- };
709
- if (tableColumn) {
710
- return () => h3(tableColumn, attrs, compName ? {
711
- [`${cellSlot}`]: (scope) => {
712
- const childrenProps = typeof attrs._props === "function" ? attrs._props?.(scope) : attrs._props;
713
- return h3(compSet[compName], {
714
- data,
715
- ...childrenProps || {}
716
- }, childrenProps?._slots);
717
- }
718
- } : childrens);
719
- } else {
720
- return (scope) => {
721
- const childrenProps = typeof attrs._props === "function" ? attrs._props?.(scope) : attrs._props;
722
- return compName ? h3(compSet[compName], {
723
- scope,
724
- data,
725
- ...childrenProps || {}
726
- }, childrenProps?._slots) : childrens;
727
- };
728
- }
729
- }
730
- });
731
- return defineComponent3({
732
- name: "PhecdaTable",
733
- props: {
734
- config: {
735
- type: Array,
736
- required: true
737
- }
738
- },
739
- setup(props, ctx) {
740
- const dom = ref3();
741
- onMounted2(() => {
742
- ctx.expose({
743
- ...dom.value
744
- });
745
- });
746
- return () => {
747
- return h3(table, Object.assign({
748
- ref: dom
749
- }, ctx.attrs), {
750
- [`${columnSlot}`]: (scope) => props.config.map((item) => {
751
- item = typeof item === "function" ? item(scope) : item;
752
- return h3(TableColumn, item);
753
- })
754
- });
755
- };
756
- }
757
- });
758
- }
759
- __name(createTable, "createTable");
760
-
761
- // src/components/helper/pipe.ts
762
- import { h as h4 } from "vue";
763
- function createPipe(comp, props, to = "default", slot) {
764
- const vnodeMap = {
765
- [`${to}`]: () => h4(comp, props, slot)
766
- };
767
- return {
768
- to(comp2, props2, to2 = "default") {
769
- return createPipe(comp2, props2, to2, vnodeMap);
770
- },
771
- get() {
772
- return vnodeMap;
773
- },
774
- bind(vnode, to2) {
775
- vnodeMap[to2] = () => vnode;
776
- }
777
- };
778
- }
779
- __name(createPipe, "createPipe");
780
-
781
- // src/components/createModal.ts
782
- import { defineComponent as defineComponent4, h as h5, render as render2, shallowRef as shallowRef2 } from "vue";
783
- var createModal = /* @__PURE__ */ __name(function(wrapComp, comp, opts = {}) {
784
- let isMounted = false;
785
- const { modelKey = "modelValue", wrapProps = {}, compProps = {} } = opts;
786
- const isShow = shallowRef2(true);
787
- const contentProps = shallowRef2({});
788
- const modalProps = shallowRef2({});
789
- const wrapper = defineComponent4({
790
- setup() {
791
- return () => h5(wrapComp, {
792
- [modelKey]: isShow.value,
793
- [`onUpdate:${modelKey}`]: (v) => {
794
- isShow.value = v;
795
- },
796
- ...modalProps.value
797
- }, {
798
- default: (slot = {}) => h5(comp, {
799
- ...slot,
800
- ...contentProps.value
801
- })
802
- });
803
- }
804
- });
805
- return (props, wrap_props) => {
806
- contentProps.value = Object.assign({}, compProps, props);
807
- modalProps.value = Object.assign({}, wrapProps, wrap_props);
808
- if (!isMounted) {
809
- const el = document.createElement("div");
810
- const vnode = h5(wrapper);
811
- vnode.appContext = interval.app?._context;
812
- document.body.appendChild((render2(vnode, el), el));
813
- isMounted = true;
814
- } else {
815
- isShow.value = true;
816
- }
817
- };
818
- }, "createModal");
819
-
820
427
  // src/components/createDialog.ts
821
- import { defineComponent as defineComponent5, h as h6, render as render3, shallowRef as shallowRef3 } from "vue";
428
+ import { defineComponent as defineComponent2, h as h2, render as render2, shallowRef as shallowRef2 } from "vue";
822
429
  var createDialog = /* @__PURE__ */ __name(function(comp, opts = {}) {
823
430
  let isMounted = false;
824
431
  const { modelKey = "modelValue", props = {} } = opts;
825
- const isShow = shallowRef3(true);
826
- const contentProps = shallowRef3({});
827
- const wrapper = defineComponent5({
432
+ const isShow = shallowRef2(true);
433
+ const contentProps = shallowRef2({});
434
+ const wrapper = defineComponent2({
828
435
  setup() {
829
- return () => h6(comp, {
436
+ return () => h2(comp, {
830
437
  [modelKey]: isShow.value,
831
438
  [`onUpdate:${modelKey}`]: (v) => {
832
439
  isShow.value = v;
@@ -839,9 +446,9 @@ var createDialog = /* @__PURE__ */ __name(function(comp, opts = {}) {
839
446
  contentProps.value = Object.assign({}, props, _props);
840
447
  if (!isMounted) {
841
448
  const el = document.createElement("div");
842
- const vnode = h6(wrapper);
449
+ const vnode = h2(wrapper);
843
450
  vnode.appContext = interval.app?._context;
844
- document.body.appendChild((render3(vnode, el), el));
451
+ document.body.appendChild((render2(vnode, el), el));
845
452
  isMounted = true;
846
453
  } else {
847
454
  isShow.value = true;
@@ -868,27 +475,15 @@ var PV = class {
868
475
  };
869
476
  __name(PV, "PV");
870
477
  export {
871
- GetDevUIRules,
872
478
  PV,
873
479
  RE,
874
480
  createDialog,
875
481
  createFilter,
876
- createForm,
877
- createFormData,
878
482
  createLayer,
879
- createModal,
880
483
  createPhecda,
881
- createPipe,
882
- createTable,
883
484
  emitter,
884
485
  getActivePhecda,
885
- getAntDRules,
886
- getArcoRules,
887
- getElementPlusRules,
888
- getNaiveUIRules,
889
- getNutUIRules,
890
486
  getReactiveMap,
891
- getVantRules,
892
487
  initialize,
893
488
  interval,
894
489
  phecdaSymbol,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "phecda-vue",
3
- "version": "2.0.4-alpha.2",
3
+ "version": "2.1.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": "2.1.0-alpha.2"
17
+ "phecda-core": "2.1.1"
18
18
  },
19
19
  "devDependencies": {
20
20
  "tsup": "^6.5.0"