@fangzhongya/fang-ui 0.1.81 → 0.1.82

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.
@@ -43,9 +43,9 @@ function processFatherObject(obj, currentValue, row, is) {
43
43
  }
44
44
  function getFatherValue(obj, currentValue) {
45
45
  if (obj.pars) {
46
- return objValue.getObjValue(obj.prop, currentValue) ?? obj.default;
46
+ return objValue.getObjValue(obj.prop, currentValue) ?? getDefault(obj);
47
47
  }
48
- return (currentValue == null ? void 0 : currentValue[obj.prop]) ?? obj.default;
48
+ return (currentValue == null ? void 0 : currentValue[obj.prop]) ?? getDefault(obj);
49
49
  }
50
50
  function useVueValue(v, key) {
51
51
  if (key) {
@@ -103,6 +103,16 @@ function getFormRule(obj) {
103
103
  fps.push(prop);
104
104
  return fps.join(".");
105
105
  }
106
+ function getDefault(obj) {
107
+ if (obj.default) {
108
+ if (typeof obj.default == "function") {
109
+ return obj.default(obj);
110
+ } else {
111
+ return obj.default;
112
+ }
113
+ }
114
+ return void 0;
115
+ }
106
116
  function setComputed(obj, v) {
107
117
  if (!obj.computed) return;
108
118
  if (obj.default) {
@@ -112,7 +122,7 @@ function setComputed(obj, v) {
112
122
  }
113
123
  }
114
124
  function handleComputedWithDefault(obj, v) {
115
- const value = obj.default;
125
+ const value = getDefault(obj);
116
126
  if (Array.isArray(obj.computed)) {
117
127
  handleArrayComputedWithDefault(obj.computed, value, v);
118
128
  } else if (obj.computed.set) {
@@ -137,11 +147,14 @@ function handleComputedWithoutDefault(obj, v) {
137
147
  } else if (obj.computed.get) {
138
148
  v[obj.prop] = obj.computed.get(currentValue, v, obj);
139
149
  }
140
- obj.default = v[obj.prop];
150
+ const z = v[obj.prop];
151
+ obj.default = () => z;
141
152
  } else if (Array.isArray(obj.computed)) {
142
- obj.default = obj.computed.map((key) => v[key]);
153
+ const z = obj.computed.map((key) => v[key]);
154
+ obj.default = () => z;
143
155
  } else if (obj.computed.get) {
144
- obj.default = obj.computed.get(void 0, v, obj);
156
+ const z = obj.computed.get(void 0, v, obj);
157
+ obj.default = () => z;
145
158
  }
146
159
  }
147
160
  function setFormDefaultValue(obj, value) {
@@ -154,16 +167,16 @@ function setFormDefaultValue(obj, value) {
154
167
  if (prop) {
155
168
  if (v) {
156
169
  if (obj.pars) {
157
- objValue.setObjValue(v, prop, objValue.getObjValue(prop, v) ?? obj.default);
170
+ objValue.setObjValue(v, prop, objValue.getObjValue(prop, v) ?? getDefault(obj));
158
171
  } else {
159
- v[prop] = v[prop] ?? obj.default;
172
+ v[prop] = v[prop] ?? getDefault(obj);
160
173
  }
161
174
  } else {
162
175
  v = getFatherData(obj, value, true);
163
176
  if (obj.pars) {
164
- objValue.setObjValue(v, prop, objValue.getObjValue(prop, v) ?? obj.default);
177
+ objValue.setObjValue(v, prop, objValue.getObjValue(prop, v) ?? getDefault(obj));
165
178
  } else {
166
- v[prop] = v[prop] ?? obj.default;
179
+ v[prop] = v[prop] ?? getDefault(obj);
167
180
  }
168
181
  }
169
182
  }
@@ -207,7 +220,7 @@ function getValue(obj, data, index2) {
207
220
  if (obj.formatter) {
208
221
  return obj.formatter(data, obj, cellValue, index2, cdata);
209
222
  } else {
210
- return cellValue ?? obj.default;
223
+ return cellValue ?? getDefault(obj);
211
224
  }
212
225
  }
213
226
  function getListObjValue(value, obj, data, index2) {
@@ -41,9 +41,9 @@ function processFatherObject(obj, currentValue, row, is) {
41
41
  }
42
42
  function getFatherValue(obj, currentValue) {
43
43
  if (obj.pars) {
44
- return getObjValue(obj.prop, currentValue) ?? obj.default;
44
+ return getObjValue(obj.prop, currentValue) ?? getDefault(obj);
45
45
  }
46
- return (currentValue == null ? void 0 : currentValue[obj.prop]) ?? obj.default;
46
+ return (currentValue == null ? void 0 : currentValue[obj.prop]) ?? getDefault(obj);
47
47
  }
48
48
  function useVueValue(v, key) {
49
49
  if (key) {
@@ -101,6 +101,16 @@ function getFormRule(obj) {
101
101
  fps.push(prop);
102
102
  return fps.join(".");
103
103
  }
104
+ function getDefault(obj) {
105
+ if (obj.default) {
106
+ if (typeof obj.default == "function") {
107
+ return obj.default(obj);
108
+ } else {
109
+ return obj.default;
110
+ }
111
+ }
112
+ return void 0;
113
+ }
104
114
  function setComputed(obj, v) {
105
115
  if (!obj.computed) return;
106
116
  if (obj.default) {
@@ -110,7 +120,7 @@ function setComputed(obj, v) {
110
120
  }
111
121
  }
112
122
  function handleComputedWithDefault(obj, v) {
113
- const value = obj.default;
123
+ const value = getDefault(obj);
114
124
  if (Array.isArray(obj.computed)) {
115
125
  handleArrayComputedWithDefault(obj.computed, value, v);
116
126
  } else if (obj.computed.set) {
@@ -135,11 +145,14 @@ function handleComputedWithoutDefault(obj, v) {
135
145
  } else if (obj.computed.get) {
136
146
  v[obj.prop] = obj.computed.get(currentValue, v, obj);
137
147
  }
138
- obj.default = v[obj.prop];
148
+ const z = v[obj.prop];
149
+ obj.default = () => z;
139
150
  } else if (Array.isArray(obj.computed)) {
140
- obj.default = obj.computed.map((key) => v[key]);
151
+ const z = obj.computed.map((key) => v[key]);
152
+ obj.default = () => z;
141
153
  } else if (obj.computed.get) {
142
- obj.default = obj.computed.get(void 0, v, obj);
154
+ const z = obj.computed.get(void 0, v, obj);
155
+ obj.default = () => z;
143
156
  }
144
157
  }
145
158
  function setFormDefaultValue(obj, value) {
@@ -152,16 +165,16 @@ function setFormDefaultValue(obj, value) {
152
165
  if (prop) {
153
166
  if (v) {
154
167
  if (obj.pars) {
155
- setObjValue(v, prop, getObjValue(prop, v) ?? obj.default);
168
+ setObjValue(v, prop, getObjValue(prop, v) ?? getDefault(obj));
156
169
  } else {
157
- v[prop] = v[prop] ?? obj.default;
170
+ v[prop] = v[prop] ?? getDefault(obj);
158
171
  }
159
172
  } else {
160
173
  v = getFatherData(obj, value, true);
161
174
  if (obj.pars) {
162
- setObjValue(v, prop, getObjValue(prop, v) ?? obj.default);
175
+ setObjValue(v, prop, getObjValue(prop, v) ?? getDefault(obj));
163
176
  } else {
164
- v[prop] = v[prop] ?? obj.default;
177
+ v[prop] = v[prop] ?? getDefault(obj);
165
178
  }
166
179
  }
167
180
  }
@@ -205,7 +218,7 @@ function getValue(obj, data, index) {
205
218
  if (obj.formatter) {
206
219
  return obj.formatter(data, obj, cellValue, index, cdata);
207
220
  } else {
208
- return cellValue ?? obj.default;
221
+ return cellValue ?? getDefault(obj);
209
222
  }
210
223
  }
211
224
  function getListObjValue(value, obj, data, index) {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "prefix": "fang-ui",
3
3
  "info": {},
4
- "lastModified": 1770167738846,
4
+ "lastModified": 1770169436535,
5
5
  "icons": {
6
6
  "bar": {
7
7
  "body": " <path fill=\"currentColor\" d=\"M128 544h768a32 32 0 1 0 0-64H128a32 32 0 0 0 0 64z\" ></path> "
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fangzhongya/fang-ui",
3
3
  "private": false,
4
- "version": "0.1.81",
4
+ "version": "0.1.82",
5
5
  "type": "module",
6
6
  "description ": "fang-ui",
7
7
  "keywords": [
@@ -52,12 +52,12 @@
52
52
  "vue-tsc": "^3.2.2",
53
53
  "vxe-table": "4.6.20",
54
54
  "@fang-ui/components": "0.0.1-0",
55
- "@fang-ui/directives": "0.0.1-0",
56
- "@fang-ui/hooks": "0.0.1-0",
57
55
  "@fang-ui/icons": "0.0.1-0",
58
- "@fang-ui/locale": "0.0.1-0",
56
+ "@fang-ui/directives": "0.0.1-0",
59
57
  "@fang-ui/theme": "0.0.1-0",
58
+ "@fang-ui/hooks": "0.0.1-0",
60
59
  "@fang-ui/types": "0.0.1-0",
60
+ "@fang-ui/locale": "0.0.1-0",
61
61
  "@fang-ui/utils": "0.0.1-0"
62
62
  },
63
63
  "main": "./dist/index.cjs",
File without changes