@vunk/form 0.0.1-alpha.22 → 0.0.1-alpha.23

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.
@@ -30,6 +30,7 @@ const useSourceManager = (source, opts = {}) => {
30
30
  const manager = computed$1(() => {
31
31
  const keyRecord = {};
32
32
  const propRecord = {};
33
+ const idRecord = {};
33
34
  function intoData(list, k = []) {
34
35
  list.forEach((item, index) => {
35
36
  const currentK = [...k, index];
@@ -37,12 +38,16 @@ const useSourceManager = (source, opts = {}) => {
37
38
  source: item,
38
39
  key: currentK,
39
40
  nextKey: [...k, index + 1],
40
- prop: item.prop
41
+ prop: item.prop,
42
+ id: item.id
41
43
  };
42
44
  keyRecord[currentK.join()] = managerInfo;
43
45
  if (item.prop) {
44
46
  propRecord[item.prop] = managerInfo;
45
47
  }
48
+ if (item.id) {
49
+ idRecord[item.id] = managerInfo;
50
+ }
46
51
  if (item.templateSlots) {
47
52
  if (Array.isArray(item.templateSlots)) {
48
53
  currentK.push("templateSlots");
@@ -60,21 +65,26 @@ const useSourceManager = (source, opts = {}) => {
60
65
  intoData(unref(source));
61
66
  return {
62
67
  keyRecord,
63
- propRecord
68
+ propRecord,
69
+ idRecord
64
70
  };
65
71
  });
66
72
  const getManagerInfoByProp = (prop) => {
67
73
  return manager.value.propRecord[prop];
68
74
  };
69
75
  const getManagerInfoByKey = (key) => {
70
- return manager.value.propRecord[key.join()];
76
+ return manager.value.keyRecord[key.join()];
77
+ };
78
+ const getManagerInfoById = (id) => {
79
+ return manager.value.idRecord[id];
71
80
  };
72
81
  return [
73
82
  source,
74
83
  {
75
84
  manager,
76
85
  getManagerInfoByProp,
77
- getManagerInfoByKey
86
+ getManagerInfoByKey,
87
+ getManagerInfoById
78
88
  }
79
89
  ];
80
90
  };
@@ -7,7 +7,9 @@ export declare const useSourceManager: <T = FormItemRendererSource<string>>(sour
7
7
  readonly manager: import("vue").ComputedRef<{
8
8
  keyRecord: Record<string, ManagerInfo<T>>;
9
9
  propRecord: Record<string, ManagerInfo<T>>;
10
+ idRecord: Record<string, ManagerInfo<T>>;
10
11
  }>;
11
12
  readonly getManagerInfoByProp: <I = T>(prop: string) => ManagerInfo<I>;
12
13
  readonly getManagerInfoByKey: <I_1 = T>(key: (string | number)[]) => ManagerInfo<I_1>;
14
+ readonly getManagerInfoById: <I_2 = T>(id: string) => ManagerInfo<I_2>;
13
15
  }];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vunk/form",
3
- "version": "0.0.1-alpha.22",
3
+ "version": "0.0.1-alpha.23",
4
4
  "description": "",
5
5
  "main": "index.esm.js",
6
6
  "scripts": {