@form-create/element-ui 3.1.3 → 3.1.6

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.3
2
+ * @form-create/element-ui v3.1.6
3
3
  * (c) 2018-2022 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
@@ -1499,6 +1499,26 @@
1499
1499
  },
1500
1500
  emits: ['update:modelValue', 'change', 'itemMounted', 'remove'],
1501
1501
  watch: {
1502
+ rule: {
1503
+ handler: function handler(n, o) {
1504
+ var _this = this;
1505
+
1506
+ Object.keys(this.cacheRule).forEach(function (v) {
1507
+ var item = _this.cacheRule[v];
1508
+
1509
+ if (n === o) {
1510
+ deepExtend(item.rule, n);
1511
+ } else {
1512
+ var val = item.$f.formData();
1513
+ item.$f.once('reloading', function () {
1514
+ item.$f.setValue(val);
1515
+ });
1516
+ item.rule = deepCopy(n);
1517
+ }
1518
+ });
1519
+ },
1520
+ deep: true
1521
+ },
1502
1522
  disabled: function disabled(n) {
1503
1523
  if (this.syncDisabled) {
1504
1524
  var lst = this.cacheRule;
@@ -1516,7 +1536,7 @@
1516
1536
  },
1517
1537
  modelValue: {
1518
1538
  handler: function handler(n) {
1519
- var _this = this;
1539
+ var _this2 = this;
1520
1540
 
1521
1541
  n = n || [];
1522
1542
  var keys = Object.keys(this.cacheRule),
@@ -1536,17 +1556,14 @@
1536
1556
  for (var _i2 = 0; _i2 < len; _i2++) {
1537
1557
  this.removeRule(keys[total - _i2 - 1]);
1538
1558
  }
1539
-
1540
- this.subForm();
1541
1559
  }
1542
1560
 
1543
1561
  n.forEach(function (val, i) {
1544
- _this.setValue(keys[i], n[i]);
1562
+ _this2.setValue(keys[i], n[i]);
1545
1563
  });
1546
1564
  }
1547
1565
  },
1548
- deep: true,
1549
- flush: 'post'
1566
+ deep: true
1550
1567
  }
1551
1568
  },
1552
1569
  methods: {
@@ -1561,7 +1578,7 @@
1561
1578
  this.$emit('change', value);
1562
1579
  },
1563
1580
  formData: function formData(key, _formData) {
1564
- var _this2 = this;
1581
+ var _this3 = this;
1565
1582
 
1566
1583
  var cacheRule = this.cacheRule;
1567
1584
  var keys = Object.keys(cacheRule);
@@ -1573,10 +1590,10 @@
1573
1590
  }
1574
1591
 
1575
1592
  var value = keys.map(function (k) {
1576
- var data = key === k ? _formData : _objectSpread2({}, _this2.cacheRule[k].$f.form);
1577
- var value = _this2.field ? data[_this2.field] || null : data;
1593
+ var data = key === k ? _formData : _objectSpread2({}, _this3.cacheRule[k].$f.form);
1594
+ var value = _this3.field ? data[_this3.field] || null : data;
1578
1595
 
1579
- _this2.cache(k, value);
1596
+ _this3.cache(k, value);
1580
1597
 
1581
1598
  return value;
1582
1599
  });
@@ -1596,7 +1613,7 @@
1596
1613
  this.cache(key, value);
1597
1614
  },
1598
1615
  addRule: function addRule(i, emit) {
1599
- var _this3 = this;
1616
+ var _this4 = this;
1600
1617
 
1601
1618
  var rule = this.formCreateInject.form.copyRules(this.rule || []);
1602
1619
  var options = this.options ? _objectSpread2({}, this.options) : {
@@ -1617,31 +1634,23 @@
1617
1634
 
1618
1635
  if (emit) {
1619
1636
  vue.nextTick(function () {
1620
- return _this3.$emit('add', rule, Object.keys(_this3.cacheRule).length - 1);
1637
+ return _this4.$emit('add', rule, Object.keys(_this4.cacheRule).length - 1);
1621
1638
  });
1622
1639
  }
1623
1640
  },
1624
1641
  add$f: function add$f(i, key, $f) {
1625
- var _this4 = this;
1642
+ var _this5 = this;
1626
1643
 
1627
1644
  this.cacheRule[key].$f = $f;
1628
- this.subForm();
1629
1645
  this.formData(key, $f.formData());
1630
1646
  vue.nextTick(function () {
1631
- if (_this4.syncDisabled) {
1632
- $f.disabled(_this4.disabled);
1647
+ if (_this5.syncDisabled) {
1648
+ $f.disabled(_this5.disabled);
1633
1649
  }
1634
1650
 
1635
- _this4.$emit('itemMounted', $f, Object.keys(_this4.cacheRule).indexOf(key));
1651
+ _this5.$emit('itemMounted', $f, Object.keys(_this5.cacheRule).indexOf(key));
1636
1652
  });
1637
1653
  },
1638
- subForm: function subForm() {
1639
- var _this5 = this;
1640
-
1641
- this.formCreateInject.subForm(Object.keys(this.cacheRule).map(function (k) {
1642
- return _this5.cacheRule[k].$f;
1643
- }));
1644
- },
1645
1654
  removeRule: function removeRule(key, emit) {
1646
1655
  var _this6 = this;
1647
1656
 
@@ -1669,7 +1678,6 @@
1669
1678
  }
1670
1679
 
1671
1680
  this.removeRule(key, true);
1672
- this.subForm();
1673
1681
  this.modelValue.splice(index, 1);
1674
1682
  this.input(this.modelValue);
1675
1683
  },
@@ -1784,6 +1792,7 @@
1784
1792
  "default": function _default() {
1785
1793
  return [vue.createVNode(Type, {
1786
1794
  "key": key,
1795
+ "inFor": true,
1787
1796
  "onUpdate:modelValue": function onUpdateModelValue(formData) {
1788
1797
  return _this9.formData(key, formData);
1789
1798
  },
@@ -1886,7 +1895,6 @@
1886
1895
  var _this = this;
1887
1896
 
1888
1897
  this.subApi = api;
1889
- this.formCreateInject.subForm(api);
1890
1898
  vue.nextTick(function () {
1891
1899
  _this.syncDisabled && api.disabled(_this.disabled);
1892
1900
 
@@ -1933,6 +1941,21 @@
1933
1941
  var components = [Checkbox, Frame, Radio, Select, Tree, Upload, Group, Sub, script];
1934
1942
 
1935
1943
  var NAME$1 = 'FormCreate';
1944
+
1945
+ var getRuleInject = function getRuleInject(vm, parent) {
1946
+ if (!vm || vm === parent) {
1947
+ return;
1948
+ }
1949
+
1950
+ if (vm.ctx.formCreateInject) {
1951
+ return vm.ctx.formCreateInject;
1952
+ }
1953
+
1954
+ if (vm.parent) {
1955
+ return getRuleInject(vm.parent, parent);
1956
+ }
1957
+ };
1958
+
1936
1959
  function $FormCreate(FormCreate) {
1937
1960
  return vue.defineComponent({
1938
1961
  name: NAME$1,
@@ -1953,7 +1976,12 @@
1953
1976
  extendOption: Boolean,
1954
1977
  modelValue: Object,
1955
1978
  api: Object,
1956
- name: String
1979
+ name: String,
1980
+ subForm: {
1981
+ type: Boolean,
1982
+ "default": true
1983
+ },
1984
+ inFor: Boolean
1957
1985
  },
1958
1986
  emits: ['update:api', 'update:modelValue', 'mounted', 'submit', 'change', 'emit-event', 'control', 'remove-rule', 'remove-field', 'sync', 'reload', 'repeat-field', 'update'],
1959
1987
  render: function render() {
@@ -1966,7 +1994,9 @@
1966
1994
 
1967
1995
  var _toRefs = vue.toRefs(props),
1968
1996
  rule = _toRefs.rule,
1969
- modelValue = _toRefs.modelValue;
1997
+ modelValue = _toRefs.modelValue,
1998
+ subForm = _toRefs.subForm,
1999
+ inFor = _toRefs.inFor;
1970
2000
 
1971
2001
  var data = vue.reactive({
1972
2002
  ctxInject: {},
@@ -1974,20 +2004,64 @@
1974
2004
  isShow: true,
1975
2005
  unique: 1,
1976
2006
  renderRule: _toConsumableArray(rule.value || []),
1977
- updateValue: JSON.stringify(modelValue)
2007
+ updateValue: JSON.stringify(modelValue || {})
1978
2008
  });
1979
2009
  var fc = new FormCreate(vm);
1980
2010
  var fapi = fc.api();
2011
+ var isMore = inFor.value;
2012
+
2013
+ var addSubForm = function addSubForm() {
2014
+ if (parent) {
2015
+ var _inject = getRuleInject(vm, parent);
2016
+
2017
+ if (_inject) {
2018
+ var sub;
2019
+
2020
+ if (isMore) {
2021
+ sub = toArray(_inject.getSubForm());
2022
+ sub.push(fapi);
2023
+ } else {
2024
+ sub = fapi;
2025
+ }
2026
+
2027
+ _inject.subForm(sub);
2028
+ }
2029
+ }
2030
+ };
2031
+
2032
+ var rmSubForm = function rmSubForm() {
2033
+ var inject = getRuleInject(vm, parent);
2034
+
2035
+ if (inject) {
2036
+ if (isMore) {
2037
+ var sub = toArray(inject.getSubForm());
2038
+ var idx = sub.indexOf(fapi);
2039
+
2040
+ if (idx > -1) {
2041
+ sub.splice(idx, 1);
2042
+ }
2043
+ } else {
2044
+ inject.subForm();
2045
+ }
2046
+ }
2047
+ };
2048
+
1981
2049
  vue.onMounted(function () {
1982
2050
  fc.mounted();
1983
2051
  });
1984
2052
  vue.onBeforeUnmount(function () {
2053
+ rmSubForm();
1985
2054
  data.destroyed = true;
1986
2055
  fc.unmount();
1987
2056
  });
1988
2057
  vue.onUpdated(function () {
1989
2058
  fc.updated();
1990
2059
  });
2060
+ vue.watch(subForm, function (n) {
2061
+ n ? addSubForm() : rmSubForm();
2062
+ }, {
2063
+ immediate: true
2064
+ });
1991
2065
  vue.watch(function () {
1992
2066
  return _toConsumableArray(rule.value);
1993
2067
  }, function (n) {
@@ -2002,8 +2076,8 @@
2002
2076
  fapi.refresh();
2003
2077
  });
2004
2078
  vue.watch(modelValue, function (n) {
2005
- if (JSON.stringify(n) === data.updateValue) return;
2006
- fapi.setValue(n);
2079
+ if (JSON.stringify(n || {}) === data.updateValue) return;
2080
+ fapi.setValue(n || {});
2007
2081
  }, {
2008
2082
  deep: true
2009
2083
  });
@@ -2102,7 +2176,7 @@
2102
2176
  };
2103
2177
  };
2104
2178
 
2105
- var keyAttrs = ['type', 'slot', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key', 'slotUpdate'];
2179
+ var keyAttrs = ['type', 'slot', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key', 'slotUpdate', 'computed', 'preview', 'component', 'cache'];
2106
2180
  var arrayAttrs = ['validate', 'children', 'control'];
2107
2181
  var normalAttrs = ['effect'];
2108
2182
  function attrs() {
@@ -2490,7 +2564,7 @@
2490
2564
  if (!ctx) return initial;
2491
2565
  initial[ctx.field] = copy(ctx.rule.value);
2492
2566
  return initial;
2493
- }, copy(h.appendData));
2567
+ }, {});
2494
2568
  },
2495
2569
  getValue: function getValue(field) {
2496
2570
  var ctx = h.getFieldCtx(field);
@@ -2720,6 +2794,25 @@
2720
2794
  return origin ? ctx.origin : ctx.rule;
2721
2795
  }
2722
2796
  },
2797
+ setEffect: function setEffect(id, attr, value) {
2798
+ var ctx = h.getCtx(id);
2799
+
2800
+ if (ctx && attr) {
2801
+ if (attr[0] === '$') {
2802
+ attr = attr.substr(1);
2803
+ }
2804
+
2805
+ if (hasProperty(ctx.rule, '$' + attr)) {
2806
+ $set(ctx.rule, '$' + attr, value);
2807
+ }
2808
+
2809
+ if (!hasProperty(ctx.rule, 'effect')) {
2810
+ ctx.rule.effect = {};
2811
+ }
2812
+
2813
+ $set(ctx.rule.effect, attr, value);
2814
+ }
2815
+ },
2723
2816
  updateValidate: function updateValidate(id, validate, merge) {
2724
2817
  if (merge) {
2725
2818
  api.mergeRule(id, {
@@ -3002,7 +3095,6 @@
3002
3095
  try {
3003
3096
  if (ctx.type === 'hidden') return;
3004
3097
  var rule = ctx.rule;
3005
- var preview = this.options.preview || false;
3006
3098
 
3007
3099
  if (!this.cache[ctx.id] || this.cache[ctx.id].slot !== rule.slot) {
3008
3100
  var vn;
@@ -3014,7 +3106,10 @@
3014
3106
  this.setOptions(ctx);
3015
3107
  this.ctxProp(ctx);
3016
3108
  var prop = ctx.prop;
3109
+ prop.preview = !!(hasProperty(prop, 'preview') ? prop.preview : this.options.preview || false);
3017
3110
  prop.props.formCreateInject = this.injectProp(ctx);
3111
+ var cacheFlag = prop.cache !== false;
3112
+ var preview = prop.preview;
3018
3113
 
3019
3114
  if (prop.hidden) {
3020
3115
  this.setCache(ctx, undefined, parent);
@@ -3072,18 +3167,18 @@
3072
3167
  _vn = _this4.display(_vn);
3073
3168
  }
3074
3169
 
3075
- _this4.setCache(ctx, function () {
3170
+ cacheFlag && _this4.setCache(ctx, function () {
3076
3171
  return _vn;
3077
3172
  }, parent);
3078
-
3079
3173
  return _vn;
3080
3174
  };
3081
3175
 
3082
3176
  this.setCache(ctx, vn, parent);
3083
- return vn;
3084
3177
  }
3085
3178
 
3086
- return this.getCache(ctx);
3179
+ return function () {
3180
+ return _this4.getCache(ctx).apply(void 0, arguments);
3181
+ };
3087
3182
  } catch (e) {
3088
3183
  console.error(e);
3089
3184
  return;
@@ -3136,17 +3231,21 @@
3136
3231
  subForm: function subForm(_subForm) {
3137
3232
  _this6.$handle.addSubForm(ctx, _subForm);
3138
3233
  },
3234
+ getSubForm: function getSubForm() {
3235
+ return _this6.$handle.subForm[ctx.id];
3236
+ },
3139
3237
  options: [],
3140
3238
  children: [],
3141
3239
  preview: false,
3142
3240
  field: ctx.field,
3143
- rule: ctx.rule
3241
+ rule: ctx.rule,
3242
+ input: ctx.input
3144
3243
  };
3145
3244
  }
3146
3245
 
3147
3246
  var inject = state.ctxInject[ctx.id];
3148
3247
  extend(inject, {
3149
- preview: this.options.preview || false,
3248
+ preview: ctx.prop.preview,
3150
3249
  options: ctx.prop.options,
3151
3250
  children: ctx.loadChildrenPending()
3152
3251
  });
@@ -3224,6 +3323,7 @@
3224
3323
  },
3225
3324
  defaultRender: function defaultRender(ctx, children) {
3226
3325
  var prop = ctx.prop;
3326
+ if (prop.component) return this.vNode.makeComponent(prop.component, prop, children);
3227
3327
  if (this.vNode[ctx.type]) return this.vNode[ctx.type](prop, children);
3228
3328
  if (this.vNode[ctx.originType]) return this.vNode[ctx.originType](prop, children);
3229
3329
  return this.vNode.make(lower(ctx.originType), prop, children);
@@ -3698,11 +3798,7 @@
3698
3798
  this.$handle.appendLink(this);
3699
3799
  },
3700
3800
  watchTo: function watchTo() {
3701
- var _this4 = this;
3702
-
3703
- vue.nextTick(function () {
3704
- _this4.$handle && _this4.$handle.watchCtx(_this4);
3705
- });
3801
+ this.$handle.watchCtx(this);
3706
3802
  },
3707
3803
  "delete": function _delete() {
3708
3804
  var undef = void 0;
@@ -3731,15 +3827,15 @@
3731
3827
  this.ctrlRule = [];
3732
3828
  },
3733
3829
  rm: function rm() {
3734
- var _this5 = this;
3830
+ var _this4 = this;
3735
3831
 
3736
3832
  var _rm = function _rm() {
3737
- var index = _this5.root.indexOf(_this5.origin);
3833
+ var index = _this4.root.indexOf(_this4.origin);
3738
3834
 
3739
3835
  if (index > -1) {
3740
- _this5.root.splice(index, 1);
3836
+ _this4.root.splice(index, 1);
3741
3837
 
3742
- _this5.$handle && _this5.$handle.refresh();
3838
+ _this4.$handle && _this4.$handle.refresh();
3743
3839
  }
3744
3840
  };
3745
3841
 
@@ -3750,17 +3846,17 @@
3750
3846
  }
3751
3847
 
3752
3848
  this.$handle.noWatch(function () {
3753
- _this5.$handle.deferSyncValue(function () {
3754
- _this5.rmCtrl();
3849
+ _this4.$handle.deferSyncValue(function () {
3850
+ _this4.rmCtrl();
3755
3851
 
3756
3852
  _rm();
3757
3853
 
3758
- _this5.$handle.rmCtx(_this5);
3854
+ _this4.$handle.rmCtx(_this4);
3759
3855
 
3760
- extend(_this5, {
3856
+ extend(_this4, {
3761
3857
  root: []
3762
3858
  });
3763
- }, _this5.input);
3859
+ }, _this4.input);
3764
3860
  });
3765
3861
  },
3766
3862
  update: function update(handle, init) {
@@ -3864,13 +3960,13 @@
3864
3960
  return _this5.loadRule();
3865
3961
  }
3866
3962
 
3963
+ _this5.syncForm();
3964
+
3867
3965
  if (_this5.pageEnd) {
3868
3966
  _this5.bus.$emit('load-end');
3869
3967
  }
3870
3968
 
3871
3969
  _this5.vm.setupState.renderRule();
3872
-
3873
- _this5.syncForm();
3874
3970
  });
3875
3971
  },
3876
3972
  loadChildren: function loadChildren(children, parent) {
@@ -3885,8 +3981,8 @@
3885
3981
  if (this.cycleLoad) {
3886
3982
  return this.loadRule();
3887
3983
  } else {
3888
- this.bus.$emit('load-end');
3889
3984
  this.syncForm();
3985
+ this.bus.$emit('load-end');
3890
3986
  }
3891
3987
 
3892
3988
  this.$render.clearCache(parent);
@@ -4130,19 +4226,27 @@
4130
4226
  this.clearNextTick();
4131
4227
  this.initData(rules);
4132
4228
  this.fc.rules = rules;
4133
- this.bus.$once('load-end', function () {
4134
- Object.keys(ctxs).filter(function (id) {
4135
- return _this8.ctxs[id] === undefined;
4136
- }).forEach(function (id) {
4137
- return _this8.rmCtx(ctxs[id]);
4229
+ this.deferSyncValue(function () {
4230
+ _this8.bus.$once('load-end', function () {
4231
+ Object.keys(ctxs).filter(function (id) {
4232
+ return _this8.ctxs[id] === undefined;
4233
+ }).forEach(function (id) {
4234
+ return _this8.rmCtx(ctxs[id]);
4235
+ });
4236
+
4237
+ _this8.$render.clearCacheAll();
4138
4238
  });
4139
4239
 
4140
- _this8.$render.clearCacheAll();
4240
+ _this8.reloading = true;
4241
+
4242
+ _this8.loadRule();
4243
+
4244
+ _this8.reloading = false;
4245
+
4246
+ _this8.refresh();
4247
+
4248
+ _this8.bus.$emit('reloading', _this8.api);
4141
4249
  });
4142
- this.reloading = true;
4143
- this.loadRule();
4144
- this.reloading = false;
4145
- this.refresh();
4146
4250
  this.bus.$off('next-tick', this.nextReload);
4147
4251
  this.bus.$once('next-tick', this.nextReload);
4148
4252
  this.bus.$emit('update', this.api);
@@ -4208,28 +4312,14 @@
4208
4312
  syncForm: function syncForm() {
4209
4313
  var _this = this;
4210
4314
 
4315
+ var data = vue.reactive({});
4211
4316
  this.fields().reduce(function (initial, field) {
4212
4317
  var ctx = _this.getCtx(field);
4213
4318
 
4214
4319
  initial[field] = vue.toRef(ctx.rule, 'value');
4215
4320
  return initial;
4216
- }, Object.keys(this.appendData).reduce(function (initial, field) {
4217
- initial[field] = vue.customRef(function (track, trigger) {
4218
- return {
4219
- get: function get() {
4220
- track();
4221
- return _this.appendData[field];
4222
- },
4223
- set: function set(val) {
4224
- trigger();
4225
- _this.appendData[field] = val;
4226
-
4227
- _this.syncValue();
4228
- }
4229
- };
4230
- });
4231
- return initial;
4232
- }, this.form));
4321
+ }, data);
4322
+ this.form = data;
4233
4323
  this.syncValue();
4234
4324
  },
4235
4325
  appendValue: function appendValue(rule) {
@@ -4238,9 +4328,7 @@
4238
4328
  delete this.appendData[rule.field];
4239
4329
  },
4240
4330
  addSubForm: function addSubForm(ctx, subForm) {
4241
- if (ctx.input) {
4242
- this.subForm[ctx.id] = subForm;
4243
- }
4331
+ this.subForm[ctx.id] = subForm;
4244
4332
  },
4245
4333
  deferSyncValue: function deferSyncValue(fn, sync) {
4246
4334
  if (!this.deferSyncFn) {
@@ -4338,11 +4426,46 @@
4338
4426
  return ctx.$render.defaultRender(ctx, children);
4339
4427
  },
4340
4428
  preview: function preview(children, ctx) {
4341
- return ctx.$render.defaultRender(ctx, children);
4429
+ return this.render(children, ctx);
4342
4430
  },
4343
4431
  mergeProp: function mergeProp(ctx) {}
4344
4432
  };
4345
4433
 
4434
+ var _ = {
4435
+ sum: function sum(arr) {
4436
+ if (Array.isArray(arr)) {
4437
+ var val = 0;
4438
+ arr.map(function (v) {
4439
+ return val += v || 0;
4440
+ });
4441
+ return val;
4442
+ }
4443
+ },
4444
+ column: function column(arr, field) {
4445
+ if (Array.isArray(arr)) {
4446
+ return arr.map(function (v) {
4447
+ return v[field];
4448
+ });
4449
+ }
4450
+
4451
+ return [];
4452
+ },
4453
+ get: function get(obj, field, def) {
4454
+ var lst = field.split('.');
4455
+ var val = obj;
4456
+
4457
+ for (var i = 0; i < lst.length; i++) {
4458
+ if (hasProperty(val, lst[i])) {
4459
+ val = val[lst[i]];
4460
+ } else {
4461
+ return def === undefined ? 0 : def;
4462
+ }
4463
+ }
4464
+
4465
+ return val;
4466
+ }
4467
+ };
4468
+ var noneKey = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update', 'slotUpdate', 'computed', 'component', 'cache'];
4346
4469
  function useContext(Handler) {
4347
4470
  extend(Handler.prototype, {
4348
4471
  getCtx: function getCtx(id) {
@@ -4419,10 +4542,9 @@
4419
4542
  watchCtx: function watchCtx(ctx) {
4420
4543
  var _this = this;
4421
4544
 
4422
- var none = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update', 'slotUpdate'];
4423
4545
  var all = attrs();
4424
4546
  all.filter(function (k) {
4425
- return k[0] !== '_' && k[0] !== '$' && none.indexOf(k) === -1;
4547
+ return k[0] !== '_' && k[0] !== '$' && noneKey.indexOf(k) === -1;
4426
4548
  }).forEach(function (key) {
4427
4549
  var ref = vue.toRef(ctx.rule, key);
4428
4550
  var flag = key === 'children';
@@ -4485,11 +4607,36 @@
4485
4607
  return val.value;
4486
4608
  }, function () {
4487
4609
  var formValue = ctx.parser.toFormValue(val.value, ctx);
4610
+ formValue = formValue === null ? undefined : formValue;
4488
4611
 
4489
4612
  if (_this.isChange(ctx, formValue)) {
4490
4613
  _this.setValue(ctx, val.value, formValue, true);
4491
4614
  }
4492
4615
  }));
4616
+ this.bus.$once('load-end', function () {
4617
+ var computedRef = vue.toRef(ctx.rule, 'computed');
4618
+ ctx.watch.push(vue.watch(function () {
4619
+ var computed = computedRef.value;
4620
+ if (!computed) return undefined;
4621
+ var fn;
4622
+
4623
+ if (is.Function(computed)) {
4624
+ fn = function fn() {
4625
+ return computed(_this.api.form, _this.api);
4626
+ };
4627
+ } else {
4628
+ fn = function fn() {
4629
+ return new Function('_', "with(this){ return ".concat(computed, " }")).call(_this.api.form, _);
4630
+ };
4631
+ }
4632
+
4633
+ return invoke(fn, undefined);
4634
+ }, function (n) {
4635
+ val.value = n;
4636
+ }, {
4637
+ immediate: !!computedRef.value
4638
+ }));
4639
+ });
4493
4640
  }
4494
4641
 
4495
4642
  this.watchEffect(ctx);
@@ -4530,6 +4677,7 @@
4530
4677
  $del(this.formData, id);
4531
4678
  $del(this.subForm, id);
4532
4679
  $del(this.vm.setupState.ctxInject, id);
4680
+ input && $del(this.form, field);
4533
4681
  input && this.rmIdCtx(ctx, field, 'field');
4534
4682
  name && this.rmIdCtx(ctx, name, 'name');
4535
4683
  this.deferSyncValue(function () {
@@ -4926,6 +5074,14 @@
4926
5074
  make: function make(tag, data, children) {
4927
5075
  return makeDirective(data, this.h(tag, toProps(data), children));
4928
5076
  },
5077
+ makeComponent: function makeComponent(type, data, children) {
5078
+ try {
5079
+ return makeDirective(data, vue.createVNode(type, toProps(data), children));
5080
+ } catch (e) {
5081
+ console.error(e);
5082
+ return vue.createVNode('');
5083
+ }
5084
+ },
4929
5085
  h: function h(tag, data, children) {
4930
5086
  var isNativeTag = vue.getCurrentInstance().appContext.config.isNativeTag(tag);
4931
5087
 
@@ -5052,44 +5208,6 @@
5052
5208
  }
5053
5209
  }
5054
5210
  };
5055
- var $required = {
5056
- name: 'required',
5057
- load: function load(inject, rule) {
5058
- var val = parseVa(inject.getValue());
5059
-
5060
- var validate = _objectSpread2(_objectSpread2({}, val), {}, {
5061
- required: true,
5062
- validator: function validator(_, v) {
5063
- return new Promise(function (resolve, reject) {
5064
- is.empty(v) ? reject(validate.message) : resolve();
5065
- });
5066
- }
5067
- });
5068
-
5069
- if (!validate.message) {
5070
- validate.message = rule.title + ' is required';
5071
- }
5072
-
5073
- inject.getProp().validate = [validate];
5074
- },
5075
- watch: function watch() {
5076
- $required.load.apply($required, arguments);
5077
- }
5078
- };
5079
-
5080
- function parseVa(val) {
5081
- if (is.Boolean(val)) {
5082
- return {};
5083
- } else if (is.String(val)) {
5084
- return {
5085
- message: val
5086
- };
5087
- } else if (!is.Object(val)) {
5088
- return {};
5089
- } else {
5090
- return val;
5091
- }
5092
- }
5093
5211
 
5094
5212
  function parseOpt(option) {
5095
5213
  if (is.String(option)) {
@@ -5161,8 +5279,7 @@
5161
5279
  }
5162
5280
 
5163
5281
  var $provider = {
5164
- fetch: $fetch,
5165
- required: $required
5282
+ fetch: $fetch
5166
5283
  };
5167
5284
 
5168
5285
  var name$6 = 'html';
@@ -5236,7 +5353,9 @@
5236
5353
  exportAttrs(config.attrs || {});
5237
5354
 
5238
5355
  function getApi(name) {
5239
- return instance[name];
5356
+ var val = instance[name];
5357
+ if (Array.isArray(val)) return _toConsumableArray(val);
5358
+ return val;
5240
5359
  }
5241
5360
 
5242
5361
  function useApp(fn) {
@@ -5371,6 +5490,7 @@
5371
5490
  modelFields: modelFields,
5372
5491
  rules: vm.props.rule,
5373
5492
  name: vm.props.name,
5493
+ inFor: vm.props.inFor,
5374
5494
  prop: {
5375
5495
  components: components,
5376
5496
  directives: directives
@@ -5378,7 +5498,7 @@
5378
5498
  CreateNode: CreateNode,
5379
5499
  bus: new Mitt(),
5380
5500
  unwatch: null,
5381
- options: vue.ref({}),
5501
+ options: vue.ref(vm.props.option || {}),
5382
5502
  extendApi: config.extendApi || function (api) {
5383
5503
  return api;
5384
5504
  }
@@ -5397,7 +5517,12 @@
5397
5517
  this.$handle = new Handler(this);
5398
5518
 
5399
5519
  if (this.name) {
5400
- instance[this.name] = this.api();
5520
+ if (this.inFor) {
5521
+ if (!instance[this.name]) instance[this.name] = [];
5522
+ instance[this.name].push(this.api());
5523
+ } else {
5524
+ instance[this.name] = this.api();
5525
+ }
5401
5526
  }
5402
5527
  }
5403
5528
 
@@ -5417,7 +5542,7 @@
5417
5542
  });
5418
5543
  }
5419
5544
 
5420
- this.initOptions(this.vm.props.option || {});
5545
+ this.initOptions(this.options || {});
5421
5546
  this.$handle.init();
5422
5547
  },
5423
5548
  isSub: function isSub() {
@@ -5465,7 +5590,12 @@
5465
5590
  },
5466
5591
  unmount: function unmount() {
5467
5592
  if (this.name) {
5468
- delete instance[this.name];
5593
+ if (this.inFor) {
5594
+ var idx = instance[this.name].indexOf(this.api());
5595
+ instance[this.name].splice(idx, 1);
5596
+ } else {
5597
+ delete instance[this.name];
5598
+ }
5469
5599
  }
5470
5600
 
5471
5601
  this.unwatch && this.unwatch();
@@ -6318,11 +6448,61 @@
6318
6448
  return api;
6319
6449
  }
6320
6450
 
6451
+ var required = {
6452
+ name: 'required',
6453
+ load: function load(inject, rule, api) {
6454
+ var val = parseVal(inject.getValue());
6455
+
6456
+ if (val.required === false) {
6457
+ inject.clearProp();
6458
+ } else {
6459
+ var validate = _objectSpread2({
6460
+ required: true,
6461
+ validator: function validator(_, v, call) {
6462
+ is.empty(v) ? call(validate.message) : call();
6463
+ }
6464
+ }, val);
6465
+
6466
+ if (!validate.message) {
6467
+ validate.message = rule.title + ' is required';
6468
+ }
6469
+
6470
+ inject.getProp().validate = [validate];
6471
+ }
6472
+
6473
+ api.sync(rule);
6474
+ },
6475
+ watch: function watch() {
6476
+ required.load.apply(required, arguments);
6477
+ }
6478
+ };
6479
+
6480
+ function parseVal(val) {
6481
+ if (is.Boolean(val)) {
6482
+ return {
6483
+ required: val
6484
+ };
6485
+ } else if (is.String(val)) {
6486
+ return {
6487
+ message: val
6488
+ };
6489
+ } else if (is.Function(val)) {
6490
+ return {
6491
+ validator: val
6492
+ };
6493
+ } else if (!is.Object(val)) {
6494
+ return {};
6495
+ } else {
6496
+ return val;
6497
+ }
6498
+ }
6499
+
6321
6500
  function install(FormCreate) {
6322
6501
  FormCreate.componentAlias(alias);
6323
6502
  components.forEach(function (component) {
6324
6503
  FormCreate.component(component.name, component);
6325
6504
  });
6505
+ FormCreate.register(required);
6326
6506
  parsers.forEach(function (parser) {
6327
6507
  FormCreate.parser(parser);
6328
6508
  });
@@ -6340,7 +6520,7 @@
6340
6520
  function elmFormCreate() {
6341
6521
  return FormCreateFactory({
6342
6522
  ui: 'element-ui',
6343
- version: '3.1.3',
6523
+ version: '3.1.6',
6344
6524
  manager: manager,
6345
6525
  extendApi: extendApi,
6346
6526
  install: install,