@form-create/element-ui 3.1.12 → 3.1.13

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.
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @form-create/element-ui v3.1.12
2
+ * @form-create/element-ui v3.1.13
3
3
  * (c) 2018-2022 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
@@ -1796,31 +1796,27 @@
1796
1796
  "span": button ? 20 : 24
1797
1797
  }, {
1798
1798
  "default": function _default() {
1799
- return [vue.createVNode(vue.resolveComponent("ElFormItem"), null, {
1800
- "default": function _default() {
1801
- return [vue.createVNode(Type, {
1802
- "key": key,
1803
- "inFor": true,
1804
- "onUpdate:modelValue": function onUpdateModelValue(formData) {
1805
- return _this9.formData(key, formData);
1806
- },
1807
- "modelValue": _this9.field ? _defineProperty({}, _this9.field, _this9._value(_this9.modelValue[index])) : _this9.modelValue[index],
1808
- "onEmit-event": function onEmitEvent(name) {
1809
- for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1810
- args[_key - 1] = arguments[_key];
1811
- }
1812
-
1813
- return _this9.emitEvent(name, args, index, key);
1814
- },
1815
- "onUpdate:api": function onUpdateApi($f) {
1816
- return _this9.add$f(index, key, $f);
1817
- },
1818
- "rule": rule,
1819
- "option": options,
1820
- "extendOption": true
1821
- }, null)];
1822
- }
1823
- })];
1799
+ return [vue.createVNode(Type, {
1800
+ "key": key,
1801
+ "inFor": true,
1802
+ "onUpdate:modelValue": function onUpdateModelValue(formData) {
1803
+ return _this9.formData(key, formData);
1804
+ },
1805
+ "modelValue": _this9.field ? _defineProperty({}, _this9.field, _this9._value(_this9.modelValue[index])) : _this9.modelValue[index],
1806
+ "onEmit-event": function onEmitEvent(name) {
1807
+ for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1808
+ args[_key - 1] = arguments[_key];
1809
+ }
1810
+
1811
+ return _this9.emitEvent(name, args, index, key);
1812
+ },
1813
+ "onUpdate:api": function onUpdateApi($f) {
1814
+ return _this9.add$f(index, key, $f);
1815
+ },
1816
+ "rule": rule,
1817
+ "option": options,
1818
+ "extendOption": true
1819
+ }, null)];
1824
1820
  }
1825
1821
  }), button ? vue.createVNode(vue.resolveComponent("ElCol"), {
1826
1822
  "span": 2,
@@ -2084,10 +2080,12 @@
2084
2080
  }, function (n) {
2085
2081
  fc.initOptions(n);
2086
2082
  fapi.refresh();
2083
+ }, {
2084
+ deep: true
2087
2085
  });
2088
2086
  vue.watch(modelValue, function (n) {
2089
2087
  if (JSON.stringify(n || {}) === data.updateValue) return;
2090
- fapi.setValue(n || {});
2088
+ fapi.config.forceCoverValue ? fapi.coverValue(n || {}) : fapi.setValue(n || {});
2091
2089
  }, {
2092
2090
  deep: true
2093
2091
  });
@@ -2303,7 +2301,13 @@
2303
2301
  return rule;
2304
2302
  }
2305
2303
  function getRule(rule) {
2306
- return is.Function(rule.getRule) ? rule.getRule() : rule;
2304
+ var r = is.Function(rule.getRule) ? rule.getRule() : rule;
2305
+
2306
+ if (!r.type) {
2307
+ r.type = 'input';
2308
+ }
2309
+
2310
+ return r;
2307
2311
  }
2308
2312
  function mergeGlobal(target, merge) {
2309
2313
  if (!target) return merge;
@@ -2582,15 +2586,21 @@
2582
2586
  return copy(ctx.rule.value);
2583
2587
  },
2584
2588
  coverValue: function coverValue(formData) {
2589
+ var data = _objectSpread2({}, formData || {});
2590
+
2585
2591
  h.deferSyncValue(function () {
2586
2592
  api.fields().forEach(function (key) {
2587
2593
  var ctxs = h.fieldCtx[key];
2588
- if (!ctxs) return h.appendData[key] = formData[key];
2589
- var flag = hasProperty(formData, key);
2590
- ctxs.forEach(function (ctx) {
2591
- ctx.rule.value = flag ? formData[key] : undefined;
2592
- });
2594
+
2595
+ if (ctxs) {
2596
+ var flag = hasProperty(formData, key);
2597
+ ctxs.forEach(function (ctx) {
2598
+ ctx.rule.value = flag ? formData[key] : undefined;
2599
+ });
2600
+ delete data[key];
2601
+ }
2593
2602
  });
2603
+ extend(h.appendData, data);
2594
2604
  });
2595
2605
  },
2596
2606
  setValue: function setValue(field) {
@@ -2823,6 +2833,18 @@
2823
2833
  $set(ctx.rule.effect, attr, value);
2824
2834
  }
2825
2835
  },
2836
+ clearEffectData: function clearEffectData(id, attr) {
2837
+ var ctx = h.getCtx(id);
2838
+
2839
+ if (ctx) {
2840
+ if (attr && attr[0] === '$') {
2841
+ attr = attr.substr(1);
2842
+ }
2843
+
2844
+ ctx.clearEffectData(attr);
2845
+ api.sync(id);
2846
+ }
2847
+ },
2826
2848
  updateValidate: function updateValidate(id, validate, merge) {
2827
2849
  if (merge) {
2828
2850
  api.mergeRule(id, {
@@ -3632,7 +3654,7 @@
3632
3654
  });
3633
3655
  }
3634
3656
 
3635
- function RuleContext(handle, rule) {
3657
+ function RuleContext(handle, rule, defaultValue) {
3636
3658
  var id = uniqueId();
3637
3659
  var isInput = !!rule.field;
3638
3660
  extend(this, {
@@ -3656,7 +3678,7 @@
3656
3678
  refRule: {},
3657
3679
  input: isInput,
3658
3680
  el: undefined,
3659
- defaultValue: isInput ? deepCopy(rule.value) : undefined,
3681
+ defaultValue: isInput ? deepCopy(defaultValue) : undefined,
3660
3682
  field: rule.field || undefined
3661
3683
  });
3662
3684
  this.updateType();
@@ -3769,7 +3791,11 @@
3769
3791
  return this.payload[name];
3770
3792
  },
3771
3793
  clearEffectData: function clearEffectData(name) {
3772
- delete this.payload[name];
3794
+ if (name === undefined) {
3795
+ this.payload = {};
3796
+ } else {
3797
+ delete this.payload[name];
3798
+ }
3773
3799
  },
3774
3800
  updateKey: function updateKey(flag) {
3775
3801
  this.key = uniqueId();
@@ -4030,7 +4056,6 @@
4030
4056
  rules.map(function (_rule, index) {
4031
4057
  if (parent && (is.String(_rule) || is.Undef(_rule))) return;
4032
4058
  if (!_this6.pageEnd && !parent && index >= _this6.first) return;
4033
- if (!is.Object(_rule) || !getRule(_rule).type) return err('未定义生成规则的 type 字段', _rule);
4034
4059
 
4035
4060
  if (_rule.__fc__ && _rule.__fc__.root === rules && _this6.ctxs[_rule.__fc__.id]) {
4036
4061
  loadChildren(_rule.__fc__.loadChildrenPending(), _rule.__fc__);
@@ -4054,9 +4079,11 @@
4054
4079
  var ctx;
4055
4080
  var isCopy = false;
4056
4081
  var isInit = !!_rule.__fc__;
4082
+ var defaultValue = rule.value;
4057
4083
 
4058
4084
  if (isInit) {
4059
4085
  ctx = _rule.__fc__;
4086
+ defaultValue = ctx.defaultValue;
4060
4087
  var check = !ctx.check(_this6);
4061
4088
 
4062
4089
  if (ctx.deleted) {
@@ -4081,7 +4108,9 @@
4081
4108
  }
4082
4109
 
4083
4110
  if (!ctx) {
4084
- ctx = new RuleContext(_this6, _this6.parseRule(_rule));
4111
+ var _rule2 = _this6.parseRule(_rule);
4112
+
4113
+ ctx = new RuleContext(_this6, _rule2, isInit ? defaultValue : _rule2.value);
4085
4114
 
4086
4115
  _this6.bindParser(ctx);
4087
4116
  } else {
@@ -4779,6 +4808,11 @@
4779
4808
  var ps = this.fc.providers;
4780
4809
  Object.keys(ps).forEach(function (k) {
4781
4810
  var prop = ps[k];
4811
+
4812
+ if (is.Function(prop)) {
4813
+ prop = prop(_this.fc);
4814
+ }
4815
+
4782
4816
  prop._c = getComponent(prop);
4783
4817
 
4784
4818
  _this.onEffect(prop);
@@ -5012,7 +5046,7 @@
5012
5046
  }
5013
5047
  }
5014
5048
 
5015
- function fetch(option) {
5049
+ function fetch$1(option) {
5016
5050
  if (typeof XMLHttpRequest === 'undefined') {
5017
5051
  return;
5018
5052
  }
@@ -5225,97 +5259,103 @@
5225
5259
  render: function render(children) {}
5226
5260
  });
5227
5261
 
5228
- var $fetch = {
5229
- name: 'fetch',
5230
- loaded: function loaded() {
5231
- run.apply(void 0, arguments);
5232
- },
5233
- watch: function watch(inject, rule, api) {
5234
- if (!run(inject, rule, api)) {
5235
- inject.clearProp();
5236
- api.sync(rule);
5262
+ var fetch = function fetch(fc) {
5263
+ function parseOpt(option) {
5264
+ if (is.String(option)) {
5265
+ option = {
5266
+ action: option,
5267
+ to: 'options'
5268
+ };
5237
5269
  }
5238
- }
5239
- };
5240
5270
 
5241
- function parseOpt(option) {
5242
- if (is.String(option)) {
5243
- option = {
5244
- action: option,
5245
- to: 'options'
5246
- };
5271
+ return option;
5247
5272
  }
5248
5273
 
5249
- return option;
5250
- }
5274
+ function run(inject, rule, api) {
5275
+ var option = inject.value;
5251
5276
 
5252
- function run(inject, rule, api) {
5253
- var option = inject.value;
5277
+ if (is.Function(option)) {
5278
+ option = option(rule, api);
5279
+ }
5254
5280
 
5255
- if (is.Function(option)) {
5256
- option = option(rule, api);
5257
- }
5281
+ option = parseOpt(option);
5258
5282
 
5259
- option = parseOpt(option);
5283
+ if (!option || !option.action) {
5284
+ return false;
5285
+ }
5260
5286
 
5261
- if (!option || !option.action) {
5262
- return false;
5263
- }
5287
+ if (!option.to) {
5288
+ option.to = 'options';
5289
+ }
5264
5290
 
5265
- if (!option.to) {
5266
- option.to = 'options';
5267
- }
5291
+ var _onError = option.onError;
5268
5292
 
5269
- var _onError = option.onError;
5293
+ var check = function check() {
5294
+ if (!inject.getValue()) {
5295
+ inject.clearProp();
5296
+ api.sync(rule);
5297
+ return true;
5298
+ }
5299
+ };
5270
5300
 
5271
- var check = function check() {
5272
- if (!inject.getValue()) {
5273
- inject.clearProp();
5274
- api.sync(rule);
5275
- return true;
5276
- }
5277
- };
5301
+ var set = function set(val) {
5302
+ if (val === undefined) {
5303
+ inject.clearProp();
5304
+ api.sync(rule);
5305
+ } else {
5306
+ deepSet(inject.getProp(), option.to, val);
5307
+ }
5308
+ };
5278
5309
 
5279
- var set = function set(val) {
5280
- if (val === undefined) {
5281
- inject.clearProp();
5282
- api.sync(rule);
5283
- } else {
5284
- deepSet(inject.getProp(), option.to, val);
5285
- }
5286
- };
5310
+ invoke(function () {
5311
+ return fc.create.fetch(_objectSpread2(_objectSpread2({}, option), {}, {
5312
+ onSuccess: function onSuccess(body) {
5313
+ if (check()) return;
5287
5314
 
5288
- invoke(function () {
5289
- return fetch(_objectSpread2(_objectSpread2({}, option), {}, {
5290
- onSuccess: function onSuccess(body) {
5291
- if (check()) return;
5315
+ var fn = function fn(v) {
5316
+ return v.data;
5317
+ };
5292
5318
 
5293
- var fn = function fn(v) {
5294
- return v.data;
5295
- };
5319
+ if (is.Function(option.parse)) {
5320
+ fn = option.parse;
5321
+ }
5322
+
5323
+ set(fn(body, rule, api));
5324
+ api.sync(rule);
5325
+ },
5326
+ onError: function onError(e) {
5327
+ set(undefined);
5328
+ if (check()) return;
5296
5329
 
5297
- if (is.Function(option.parse)) {
5298
- fn = option.parse;
5330
+ (_onError || function (e) {
5331
+ return err(e.message || 'fetch fail ' + option.action);
5332
+ })(e, rule, api);
5299
5333
  }
5334
+ }), {
5335
+ inject: inject,
5336
+ rule: rule,
5337
+ api: api
5338
+ });
5339
+ });
5340
+ return true;
5341
+ }
5300
5342
 
5301
- set(fn(body, rule, api));
5343
+ return {
5344
+ name: 'fetch',
5345
+ loaded: function loaded() {
5346
+ run.apply(void 0, arguments);
5347
+ },
5348
+ watch: function watch(inject, rule, api) {
5349
+ if (!run(inject, rule, api)) {
5350
+ inject.clearProp();
5302
5351
  api.sync(rule);
5303
- },
5304
- onError: function onError(e) {
5305
- set(undefined);
5306
- if (check()) return;
5307
-
5308
- (_onError || function (e) {
5309
- return err(e.message || 'fetch fail ' + option.action);
5310
- })(e, rule, api);
5311
5352
  }
5312
- }));
5313
- });
5314
- return true;
5315
- }
5353
+ }
5354
+ };
5355
+ };
5316
5356
 
5317
5357
  var $provider = {
5318
- fetch: $fetch
5358
+ fetch: fetch
5319
5359
  };
5320
5360
 
5321
5361
  var name$6 = 'html';
@@ -5663,7 +5703,7 @@
5663
5703
  componentAlias: componentAlias,
5664
5704
  copyRule: copyRule,
5665
5705
  copyRules: copyRules,
5666
- fetch: fetch,
5706
+ fetch: fetch$1,
5667
5707
  $form: $form,
5668
5708
  parseFn: parseFn,
5669
5709
  parseJson: parseJson,
@@ -6572,7 +6612,7 @@
6572
6612
  function elmFormCreate() {
6573
6613
  return FormCreateFactory({
6574
6614
  ui: 'element-ui',
6575
- version: '3.1.12',
6615
+ version: '3.1.13',
6576
6616
  manager: manager,
6577
6617
  extendApi: extendApi,
6578
6618
  install: install,