@form-create/element-ui 3.1.5 → 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,10 +1,10 @@
1
1
  /*!
2
- * @form-create/element-ui v3.1.4
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.
6
6
  */
7
- import { defineComponent, toRef, resolveComponent, createVNode, mergeProps as mergeProps$1, openBlock, createElementBlock, createElementVNode, isVNode, nextTick, Fragment, markRaw, reactive, getCurrentInstance, provide, inject, toRefs, onMounted, onBeforeUnmount, onUpdated, watch, computed, customRef, withDirectives, resolveDirective, createApp, h, ref } from 'vue';
7
+ import { defineComponent, toRef, resolveComponent, createVNode, mergeProps as mergeProps$1, openBlock, createElementBlock, createElementVNode, isVNode, nextTick, Fragment, markRaw, reactive, getCurrentInstance, provide, inject, toRefs, onMounted, onBeforeUnmount, onUpdated, watch, computed, withDirectives, resolveDirective, createApp, h, ref } from 'vue';
8
8
 
9
9
  function ownKeys(object, enumerableOnly) {
10
10
  var keys = Object.keys(object);
@@ -1495,6 +1495,26 @@ var Group = defineComponent({
1495
1495
  },
1496
1496
  emits: ['update:modelValue', 'change', 'itemMounted', 'remove'],
1497
1497
  watch: {
1498
+ rule: {
1499
+ handler: function handler(n, o) {
1500
+ var _this = this;
1501
+
1502
+ Object.keys(this.cacheRule).forEach(function (v) {
1503
+ var item = _this.cacheRule[v];
1504
+
1505
+ if (n === o) {
1506
+ deepExtend(item.rule, n);
1507
+ } else {
1508
+ var val = item.$f.formData();
1509
+ item.$f.once('reloading', function () {
1510
+ item.$f.setValue(val);
1511
+ });
1512
+ item.rule = deepCopy(n);
1513
+ }
1514
+ });
1515
+ },
1516
+ deep: true
1517
+ },
1498
1518
  disabled: function disabled(n) {
1499
1519
  if (this.syncDisabled) {
1500
1520
  var lst = this.cacheRule;
@@ -1512,7 +1532,7 @@ var Group = defineComponent({
1512
1532
  },
1513
1533
  modelValue: {
1514
1534
  handler: function handler(n) {
1515
- var _this = this;
1535
+ var _this2 = this;
1516
1536
 
1517
1537
  n = n || [];
1518
1538
  var keys = Object.keys(this.cacheRule),
@@ -1535,7 +1555,7 @@ var Group = defineComponent({
1535
1555
  }
1536
1556
 
1537
1557
  n.forEach(function (val, i) {
1538
- _this.setValue(keys[i], n[i]);
1558
+ _this2.setValue(keys[i], n[i]);
1539
1559
  });
1540
1560
  }
1541
1561
  },
@@ -1554,7 +1574,7 @@ var Group = defineComponent({
1554
1574
  this.$emit('change', value);
1555
1575
  },
1556
1576
  formData: function formData(key, _formData) {
1557
- var _this2 = this;
1577
+ var _this3 = this;
1558
1578
 
1559
1579
  var cacheRule = this.cacheRule;
1560
1580
  var keys = Object.keys(cacheRule);
@@ -1566,10 +1586,10 @@ var Group = defineComponent({
1566
1586
  }
1567
1587
 
1568
1588
  var value = keys.map(function (k) {
1569
- var data = key === k ? _formData : _objectSpread2({}, _this2.cacheRule[k].$f.form);
1570
- var value = _this2.field ? data[_this2.field] || null : data;
1589
+ var data = key === k ? _formData : _objectSpread2({}, _this3.cacheRule[k].$f.form);
1590
+ var value = _this3.field ? data[_this3.field] || null : data;
1571
1591
 
1572
- _this2.cache(k, value);
1592
+ _this3.cache(k, value);
1573
1593
 
1574
1594
  return value;
1575
1595
  });
@@ -1589,7 +1609,7 @@ var Group = defineComponent({
1589
1609
  this.cache(key, value);
1590
1610
  },
1591
1611
  addRule: function addRule(i, emit) {
1592
- var _this3 = this;
1612
+ var _this4 = this;
1593
1613
 
1594
1614
  var rule = this.formCreateInject.form.copyRules(this.rule || []);
1595
1615
  var options = this.options ? _objectSpread2({}, this.options) : {
@@ -1610,25 +1630,25 @@ var Group = defineComponent({
1610
1630
 
1611
1631
  if (emit) {
1612
1632
  nextTick(function () {
1613
- return _this3.$emit('add', rule, Object.keys(_this3.cacheRule).length - 1);
1633
+ return _this4.$emit('add', rule, Object.keys(_this4.cacheRule).length - 1);
1614
1634
  });
1615
1635
  }
1616
1636
  },
1617
1637
  add$f: function add$f(i, key, $f) {
1618
- var _this4 = this;
1638
+ var _this5 = this;
1619
1639
 
1620
1640
  this.cacheRule[key].$f = $f;
1621
1641
  this.formData(key, $f.formData());
1622
1642
  nextTick(function () {
1623
- if (_this4.syncDisabled) {
1624
- $f.disabled(_this4.disabled);
1643
+ if (_this5.syncDisabled) {
1644
+ $f.disabled(_this5.disabled);
1625
1645
  }
1626
1646
 
1627
- _this4.$emit('itemMounted', $f, Object.keys(_this4.cacheRule).indexOf(key));
1647
+ _this5.$emit('itemMounted', $f, Object.keys(_this5.cacheRule).indexOf(key));
1628
1648
  });
1629
1649
  },
1630
1650
  removeRule: function removeRule(key, emit) {
1631
- var _this5 = this;
1651
+ var _this6 = this;
1632
1652
 
1633
1653
  var index = Object.keys(this.cacheRule).indexOf(key);
1634
1654
  delete this.cacheRule[key];
@@ -1636,7 +1656,7 @@ var Group = defineComponent({
1636
1656
 
1637
1657
  if (emit) {
1638
1658
  nextTick(function () {
1639
- return _this5.$emit('remove', index);
1659
+ return _this6.$emit('remove', index);
1640
1660
  });
1641
1661
  }
1642
1662
  },
@@ -1669,14 +1689,14 @@ var Group = defineComponent({
1669
1689
  });
1670
1690
  },
1671
1691
  delIcon: function delIcon(index, key) {
1672
- var _this6 = this;
1692
+ var _this7 = this;
1673
1693
 
1674
1694
  return createVNode(resolveComponent("ElIcon"), {
1675
1695
  "key": "d".concat(key),
1676
1696
  "class": "el-icon-remove-outline",
1677
1697
  "style": "font-size:".concat(this.fontSize, "px;cursor:").concat(this.disabled ? 'not-allowed;color:#c9cdd4' : 'pointer;color:#606266', ";"),
1678
1698
  "onClick": function onClick() {
1679
- return _this6.del(index, key);
1699
+ return _this7.del(index, key);
1680
1700
  }
1681
1701
  }, {
1682
1702
  "default": function _default() {
@@ -1685,7 +1705,7 @@ var Group = defineComponent({
1685
1705
  });
1686
1706
  },
1687
1707
  makeIcon: function makeIcon(total, index, key) {
1688
- var _this7 = this;
1708
+ var _this8 = this;
1689
1709
 
1690
1710
  if (this.$slots.button) {
1691
1711
  return this.$slots.button({
@@ -1694,7 +1714,7 @@ var Group = defineComponent({
1694
1714
  vm: this,
1695
1715
  key: key,
1696
1716
  del: function del() {
1697
- return _this7.del(index, key);
1717
+ return _this8.del(index, key);
1698
1718
  },
1699
1719
  add: this.add
1700
1720
  });
@@ -1729,7 +1749,7 @@ var Group = defineComponent({
1729
1749
  }
1730
1750
  },
1731
1751
  render: function render() {
1732
- var _this8 = this;
1752
+ var _this9 = this;
1733
1753
 
1734
1754
  var keys = Object.keys(this.cacheRule);
1735
1755
  var button = this.button;
@@ -1750,9 +1770,9 @@ var Group = defineComponent({
1750
1770
  }, [keys.map(function (key, index) {
1751
1771
  var _slot;
1752
1772
 
1753
- var _this8$cacheRule$key = _this8.cacheRule[key],
1754
- rule = _this8$cacheRule$key.rule,
1755
- options = _this8$cacheRule$key.options;
1773
+ var _this9$cacheRule$key = _this9.cacheRule[key],
1774
+ rule = _this9$cacheRule$key.rule,
1775
+ options = _this9$cacheRule$key.options;
1756
1776
  return createVNode(resolveComponent("ElRow"), {
1757
1777
  "align": "middle",
1758
1778
  "type": "flex",
@@ -1770,18 +1790,18 @@ var Group = defineComponent({
1770
1790
  "key": key,
1771
1791
  "inFor": true,
1772
1792
  "onUpdate:modelValue": function onUpdateModelValue(formData) {
1773
- return _this8.formData(key, formData);
1793
+ return _this9.formData(key, formData);
1774
1794
  },
1775
- "modelValue": _this8.field ? _defineProperty({}, _this8.field, _this8._value(_this8.modelValue[index])) : _this8.modelValue[index],
1795
+ "modelValue": _this9.field ? _defineProperty({}, _this9.field, _this9._value(_this9.modelValue[index])) : _this9.modelValue[index],
1776
1796
  "onEmit-event": function onEmitEvent(name) {
1777
1797
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1778
1798
  args[_key - 1] = arguments[_key];
1779
1799
  }
1780
1800
 
1781
- return _this8.emitEvent(name, args, index, key);
1801
+ return _this9.emitEvent(name, args, index, key);
1782
1802
  },
1783
1803
  "onUpdate:api": function onUpdateApi($f) {
1784
- return _this8.add$f(index, key, $f);
1804
+ return _this9.add$f(index, key, $f);
1785
1805
  },
1786
1806
  "rule": rule,
1787
1807
  "option": options,
@@ -1794,7 +1814,7 @@ var Group = defineComponent({
1794
1814
  "span": 2,
1795
1815
  "pull": 1,
1796
1816
  "push": 1
1797
- }, _isSlot(_slot = _this8.makeIcon(keys.length, index, key)) ? _slot : {
1817
+ }, _isSlot(_slot = _this9.makeIcon(keys.length, index, key)) ? _slot : {
1798
1818
  "default": function _default() {
1799
1819
  return [_slot];
1800
1820
  }
@@ -1919,7 +1939,7 @@ var components = [Checkbox, Frame, Radio, Select, Tree, Upload, Group, Sub, scri
1919
1939
  var NAME$1 = 'FormCreate';
1920
1940
 
1921
1941
  var getRuleInject = function getRuleInject(vm, parent) {
1922
- if (vm === parent) {
1942
+ if (!vm || vm === parent) {
1923
1943
  return;
1924
1944
  }
1925
1945
 
@@ -1980,7 +2000,7 @@ function $FormCreate(FormCreate) {
1980
2000
  isShow: true,
1981
2001
  unique: 1,
1982
2002
  renderRule: _toConsumableArray(rule.value || []),
1983
- updateValue: JSON.stringify(modelValue)
2003
+ updateValue: JSON.stringify(modelValue || {})
1984
2004
  });
1985
2005
  var fc = new FormCreate(vm);
1986
2006
  var fapi = fc.api();
@@ -2152,7 +2172,7 @@ var mergeFn = function mergeFn(fn1, fn2) {
2152
2172
  };
2153
2173
  };
2154
2174
 
2155
- var keyAttrs = ['type', 'slot', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key', 'slotUpdate'];
2175
+ 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'];
2156
2176
  var arrayAttrs = ['validate', 'children', 'control'];
2157
2177
  var normalAttrs = ['effect'];
2158
2178
  function attrs() {
@@ -2540,7 +2560,7 @@ function Api(h) {
2540
2560
  if (!ctx) return initial;
2541
2561
  initial[ctx.field] = copy(ctx.rule.value);
2542
2562
  return initial;
2543
- }, copy(h.appendData));
2563
+ }, {});
2544
2564
  },
2545
2565
  getValue: function getValue(field) {
2546
2566
  var ctx = h.getFieldCtx(field);
@@ -3071,7 +3091,6 @@ function useRender$1(Render) {
3071
3091
  try {
3072
3092
  if (ctx.type === 'hidden') return;
3073
3093
  var rule = ctx.rule;
3074
- var preview = this.options.preview || false;
3075
3094
 
3076
3095
  if (!this.cache[ctx.id] || this.cache[ctx.id].slot !== rule.slot) {
3077
3096
  var vn;
@@ -3083,7 +3102,10 @@ function useRender$1(Render) {
3083
3102
  this.setOptions(ctx);
3084
3103
  this.ctxProp(ctx);
3085
3104
  var prop = ctx.prop;
3105
+ prop.preview = !!(hasProperty(prop, 'preview') ? prop.preview : this.options.preview || false);
3086
3106
  prop.props.formCreateInject = this.injectProp(ctx);
3107
+ var cacheFlag = prop.cache !== false;
3108
+ var preview = prop.preview;
3087
3109
 
3088
3110
  if (prop.hidden) {
3089
3111
  this.setCache(ctx, undefined, parent);
@@ -3141,18 +3163,18 @@ function useRender$1(Render) {
3141
3163
  _vn = _this4.display(_vn);
3142
3164
  }
3143
3165
 
3144
- _this4.setCache(ctx, function () {
3166
+ cacheFlag && _this4.setCache(ctx, function () {
3145
3167
  return _vn;
3146
3168
  }, parent);
3147
-
3148
3169
  return _vn;
3149
3170
  };
3150
3171
 
3151
3172
  this.setCache(ctx, vn, parent);
3152
- return vn;
3153
3173
  }
3154
3174
 
3155
- return this.getCache(ctx);
3175
+ return function () {
3176
+ return _this4.getCache(ctx).apply(void 0, arguments);
3177
+ };
3156
3178
  } catch (e) {
3157
3179
  console.error(e);
3158
3180
  return;
@@ -3219,7 +3241,7 @@ function useRender$1(Render) {
3219
3241
 
3220
3242
  var inject = state.ctxInject[ctx.id];
3221
3243
  extend(inject, {
3222
- preview: this.options.preview || false,
3244
+ preview: ctx.prop.preview,
3223
3245
  options: ctx.prop.options,
3224
3246
  children: ctx.loadChildrenPending()
3225
3247
  });
@@ -3297,6 +3319,7 @@ function useRender$1(Render) {
3297
3319
  },
3298
3320
  defaultRender: function defaultRender(ctx, children) {
3299
3321
  var prop = ctx.prop;
3322
+ if (prop.component) return this.vNode.makeComponent(prop.component, prop, children);
3300
3323
  if (this.vNode[ctx.type]) return this.vNode[ctx.type](prop, children);
3301
3324
  if (this.vNode[ctx.originType]) return this.vNode[ctx.originType](prop, children);
3302
3325
  return this.vNode.make(lower(ctx.originType), prop, children);
@@ -3771,11 +3794,7 @@ extend(RuleContext.prototype, {
3771
3794
  this.$handle.appendLink(this);
3772
3795
  },
3773
3796
  watchTo: function watchTo() {
3774
- var _this4 = this;
3775
-
3776
- nextTick(function () {
3777
- _this4.$handle && _this4.$handle.watchCtx(_this4);
3778
- });
3797
+ this.$handle.watchCtx(this);
3779
3798
  },
3780
3799
  "delete": function _delete() {
3781
3800
  var undef = void 0;
@@ -3804,15 +3823,15 @@ extend(RuleContext.prototype, {
3804
3823
  this.ctrlRule = [];
3805
3824
  },
3806
3825
  rm: function rm() {
3807
- var _this5 = this;
3826
+ var _this4 = this;
3808
3827
 
3809
3828
  var _rm = function _rm() {
3810
- var index = _this5.root.indexOf(_this5.origin);
3829
+ var index = _this4.root.indexOf(_this4.origin);
3811
3830
 
3812
3831
  if (index > -1) {
3813
- _this5.root.splice(index, 1);
3832
+ _this4.root.splice(index, 1);
3814
3833
 
3815
- _this5.$handle && _this5.$handle.refresh();
3834
+ _this4.$handle && _this4.$handle.refresh();
3816
3835
  }
3817
3836
  };
3818
3837
 
@@ -3823,17 +3842,17 @@ extend(RuleContext.prototype, {
3823
3842
  }
3824
3843
 
3825
3844
  this.$handle.noWatch(function () {
3826
- _this5.$handle.deferSyncValue(function () {
3827
- _this5.rmCtrl();
3845
+ _this4.$handle.deferSyncValue(function () {
3846
+ _this4.rmCtrl();
3828
3847
 
3829
3848
  _rm();
3830
3849
 
3831
- _this5.$handle.rmCtx(_this5);
3850
+ _this4.$handle.rmCtx(_this4);
3832
3851
 
3833
- extend(_this5, {
3852
+ extend(_this4, {
3834
3853
  root: []
3835
3854
  });
3836
- }, _this5.input);
3855
+ }, _this4.input);
3837
3856
  });
3838
3857
  },
3839
3858
  update: function update(handle, init) {
@@ -3937,13 +3956,13 @@ function useLoader(Handler) {
3937
3956
  return _this5.loadRule();
3938
3957
  }
3939
3958
 
3959
+ _this5.syncForm();
3960
+
3940
3961
  if (_this5.pageEnd) {
3941
3962
  _this5.bus.$emit('load-end');
3942
3963
  }
3943
3964
 
3944
3965
  _this5.vm.setupState.renderRule();
3945
-
3946
- _this5.syncForm();
3947
3966
  });
3948
3967
  },
3949
3968
  loadChildren: function loadChildren(children, parent) {
@@ -3958,8 +3977,8 @@ function useLoader(Handler) {
3958
3977
  if (this.cycleLoad) {
3959
3978
  return this.loadRule();
3960
3979
  } else {
3961
- this.bus.$emit('load-end');
3962
3980
  this.syncForm();
3981
+ this.bus.$emit('load-end');
3963
3982
  }
3964
3983
 
3965
3984
  this.$render.clearCache(parent);
@@ -4203,19 +4222,27 @@ function useLoader(Handler) {
4203
4222
  this.clearNextTick();
4204
4223
  this.initData(rules);
4205
4224
  this.fc.rules = rules;
4206
- this.bus.$once('load-end', function () {
4207
- Object.keys(ctxs).filter(function (id) {
4208
- return _this8.ctxs[id] === undefined;
4209
- }).forEach(function (id) {
4210
- return _this8.rmCtx(ctxs[id]);
4225
+ this.deferSyncValue(function () {
4226
+ _this8.bus.$once('load-end', function () {
4227
+ Object.keys(ctxs).filter(function (id) {
4228
+ return _this8.ctxs[id] === undefined;
4229
+ }).forEach(function (id) {
4230
+ return _this8.rmCtx(ctxs[id]);
4231
+ });
4232
+
4233
+ _this8.$render.clearCacheAll();
4211
4234
  });
4212
4235
 
4213
- _this8.$render.clearCacheAll();
4236
+ _this8.reloading = true;
4237
+
4238
+ _this8.loadRule();
4239
+
4240
+ _this8.reloading = false;
4241
+
4242
+ _this8.refresh();
4243
+
4244
+ _this8.bus.$emit('reloading', _this8.api);
4214
4245
  });
4215
- this.reloading = true;
4216
- this.loadRule();
4217
- this.reloading = false;
4218
- this.refresh();
4219
4246
  this.bus.$off('next-tick', this.nextReload);
4220
4247
  this.bus.$once('next-tick', this.nextReload);
4221
4248
  this.bus.$emit('update', this.api);
@@ -4281,28 +4308,14 @@ function useInput(Handler) {
4281
4308
  syncForm: function syncForm() {
4282
4309
  var _this = this;
4283
4310
 
4311
+ var data = reactive({});
4284
4312
  this.fields().reduce(function (initial, field) {
4285
4313
  var ctx = _this.getCtx(field);
4286
4314
 
4287
4315
  initial[field] = toRef(ctx.rule, 'value');
4288
4316
  return initial;
4289
- }, Object.keys(this.appendData).reduce(function (initial, field) {
4290
- initial[field] = customRef(function (track, trigger) {
4291
- return {
4292
- get: function get() {
4293
- track();
4294
- return _this.appendData[field];
4295
- },
4296
- set: function set(val) {
4297
- trigger();
4298
- _this.appendData[field] = val;
4299
-
4300
- _this.syncValue();
4301
- }
4302
- };
4303
- });
4304
- return initial;
4305
- }, this.form));
4317
+ }, data);
4318
+ this.form = data;
4306
4319
  this.syncValue();
4307
4320
  },
4308
4321
  appendValue: function appendValue(rule) {
@@ -4409,11 +4422,46 @@ var BaseParser = {
4409
4422
  return ctx.$render.defaultRender(ctx, children);
4410
4423
  },
4411
4424
  preview: function preview(children, ctx) {
4412
- return ctx.$render.defaultRender(ctx, children);
4425
+ return this.render(children, ctx);
4413
4426
  },
4414
4427
  mergeProp: function mergeProp(ctx) {}
4415
4428
  };
4416
4429
 
4430
+ var _ = {
4431
+ sum: function sum(arr) {
4432
+ if (Array.isArray(arr)) {
4433
+ var val = 0;
4434
+ arr.map(function (v) {
4435
+ return val += v || 0;
4436
+ });
4437
+ return val;
4438
+ }
4439
+ },
4440
+ column: function column(arr, field) {
4441
+ if (Array.isArray(arr)) {
4442
+ return arr.map(function (v) {
4443
+ return v[field];
4444
+ });
4445
+ }
4446
+
4447
+ return [];
4448
+ },
4449
+ get: function get(obj, field, def) {
4450
+ var lst = field.split('.');
4451
+ var val = obj;
4452
+
4453
+ for (var i = 0; i < lst.length; i++) {
4454
+ if (hasProperty(val, lst[i])) {
4455
+ val = val[lst[i]];
4456
+ } else {
4457
+ return def === undefined ? 0 : def;
4458
+ }
4459
+ }
4460
+
4461
+ return val;
4462
+ }
4463
+ };
4464
+ var noneKey = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update', 'slotUpdate', 'computed', 'component', 'cache'];
4417
4465
  function useContext(Handler) {
4418
4466
  extend(Handler.prototype, {
4419
4467
  getCtx: function getCtx(id) {
@@ -4490,10 +4538,9 @@ function useContext(Handler) {
4490
4538
  watchCtx: function watchCtx(ctx) {
4491
4539
  var _this = this;
4492
4540
 
4493
- var none = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update', 'slotUpdate'];
4494
4541
  var all = attrs();
4495
4542
  all.filter(function (k) {
4496
- return k[0] !== '_' && k[0] !== '$' && none.indexOf(k) === -1;
4543
+ return k[0] !== '_' && k[0] !== '$' && noneKey.indexOf(k) === -1;
4497
4544
  }).forEach(function (key) {
4498
4545
  var ref = toRef(ctx.rule, key);
4499
4546
  var flag = key === 'children';
@@ -4556,11 +4603,36 @@ function useContext(Handler) {
4556
4603
  return val.value;
4557
4604
  }, function () {
4558
4605
  var formValue = ctx.parser.toFormValue(val.value, ctx);
4606
+ formValue = formValue === null ? undefined : formValue;
4559
4607
 
4560
4608
  if (_this.isChange(ctx, formValue)) {
4561
4609
  _this.setValue(ctx, val.value, formValue, true);
4562
4610
  }
4563
4611
  }));
4612
+ this.bus.$once('load-end', function () {
4613
+ var computedRef = toRef(ctx.rule, 'computed');
4614
+ ctx.watch.push(watch(function () {
4615
+ var computed = computedRef.value;
4616
+ if (!computed) return undefined;
4617
+ var fn;
4618
+
4619
+ if (is.Function(computed)) {
4620
+ fn = function fn() {
4621
+ return computed(_this.api.form, _this.api);
4622
+ };
4623
+ } else {
4624
+ fn = function fn() {
4625
+ return new Function('_', "with(this){ return ".concat(computed, " }")).call(_this.api.form, _);
4626
+ };
4627
+ }
4628
+
4629
+ return invoke(fn, undefined);
4630
+ }, function (n) {
4631
+ val.value = n;
4632
+ }, {
4633
+ immediate: !!computedRef.value
4634
+ }));
4635
+ });
4564
4636
  }
4565
4637
 
4566
4638
  this.watchEffect(ctx);
@@ -4601,6 +4673,7 @@ function useContext(Handler) {
4601
4673
  $del(this.formData, id);
4602
4674
  $del(this.subForm, id);
4603
4675
  $del(this.vm.setupState.ctxInject, id);
4676
+ input && $del(this.form, field);
4604
4677
  input && this.rmIdCtx(ctx, field, 'field');
4605
4678
  name && this.rmIdCtx(ctx, name, 'name');
4606
4679
  this.deferSyncValue(function () {
@@ -4997,6 +5070,14 @@ function CreateNodeFactory() {
4997
5070
  make: function make(tag, data, children) {
4998
5071
  return makeDirective(data, this.h(tag, toProps(data), children));
4999
5072
  },
5073
+ makeComponent: function makeComponent(type, data, children) {
5074
+ try {
5075
+ return makeDirective(data, createVNode(type, toProps(data), children));
5076
+ } catch (e) {
5077
+ console.error(e);
5078
+ return createVNode('');
5079
+ }
5080
+ },
5000
5081
  h: function h(tag, data, children) {
5001
5082
  var isNativeTag = getCurrentInstance().appContext.config.isNativeTag(tag);
5002
5083
 
@@ -5413,7 +5494,7 @@ function FormCreateFactory(config) {
5413
5494
  CreateNode: CreateNode,
5414
5495
  bus: new Mitt(),
5415
5496
  unwatch: null,
5416
- options: ref({}),
5497
+ options: ref(vm.props.option || {}),
5417
5498
  extendApi: config.extendApi || function (api) {
5418
5499
  return api;
5419
5500
  }
@@ -5457,7 +5538,7 @@ function FormCreateFactory(config) {
5457
5538
  });
5458
5539
  }
5459
5540
 
5460
- this.initOptions(this.vm.props.option || {});
5541
+ this.initOptions(this.options || {});
5461
5542
  this.$handle.init();
5462
5543
  },
5463
5544
  isSub: function isSub() {
@@ -6366,17 +6447,17 @@ function extendApi(api, h) {
6366
6447
  var required = {
6367
6448
  name: 'required',
6368
6449
  load: function load(inject, rule, api) {
6369
- var val = parseVa(inject.getValue());
6450
+ var val = parseVal(inject.getValue());
6370
6451
 
6371
6452
  if (val.required === false) {
6372
6453
  inject.clearProp();
6373
6454
  } else {
6374
- var validate = _objectSpread2(_objectSpread2({}, val), {}, {
6455
+ var validate = _objectSpread2({
6375
6456
  required: true,
6376
6457
  validator: function validator(_, v, call) {
6377
6458
  is.empty(v) ? call(validate.message) : call();
6378
6459
  }
6379
- });
6460
+ }, val);
6380
6461
 
6381
6462
  if (!validate.message) {
6382
6463
  validate.message = rule.title + ' is required';
@@ -6392,7 +6473,7 @@ var required = {
6392
6473
  }
6393
6474
  };
6394
6475
 
6395
- function parseVa(val) {
6476
+ function parseVal(val) {
6396
6477
  if (is.Boolean(val)) {
6397
6478
  return {
6398
6479
  required: val
@@ -6401,6 +6482,10 @@ function parseVa(val) {
6401
6482
  return {
6402
6483
  message: val
6403
6484
  };
6485
+ } else if (is.Function(val)) {
6486
+ return {
6487
+ validator: val
6488
+ };
6404
6489
  } else if (!is.Object(val)) {
6405
6490
  return {};
6406
6491
  } else {
@@ -6431,7 +6516,7 @@ function install(FormCreate) {
6431
6516
  function elmFormCreate() {
6432
6517
  return FormCreateFactory({
6433
6518
  ui: 'element-ui',
6434
- version: '3.1.4',
6519
+ version: '3.1.6',
6435
6520
  manager: manager,
6436
6521
  extendApi: extendApi,
6437
6522
  install: install,