@form-create/element-ui 3.1.5 → 3.1.8

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.8
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,20 @@ 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
+ var cache = _this4.getCache(ctx);
3177
+
3178
+ return cache && cache.apply(void 0, arguments);
3179
+ };
3156
3180
  } catch (e) {
3157
3181
  console.error(e);
3158
3182
  return;
@@ -3219,7 +3243,7 @@ function useRender$1(Render) {
3219
3243
 
3220
3244
  var inject = state.ctxInject[ctx.id];
3221
3245
  extend(inject, {
3222
- preview: this.options.preview || false,
3246
+ preview: ctx.prop.preview,
3223
3247
  options: ctx.prop.options,
3224
3248
  children: ctx.loadChildrenPending()
3225
3249
  });
@@ -3297,6 +3321,7 @@ function useRender$1(Render) {
3297
3321
  },
3298
3322
  defaultRender: function defaultRender(ctx, children) {
3299
3323
  var prop = ctx.prop;
3324
+ if (prop.component) return this.vNode.makeComponent(prop.component, prop, children);
3300
3325
  if (this.vNode[ctx.type]) return this.vNode[ctx.type](prop, children);
3301
3326
  if (this.vNode[ctx.originType]) return this.vNode[ctx.originType](prop, children);
3302
3327
  return this.vNode.make(lower(ctx.originType), prop, children);
@@ -3771,11 +3796,7 @@ extend(RuleContext.prototype, {
3771
3796
  this.$handle.appendLink(this);
3772
3797
  },
3773
3798
  watchTo: function watchTo() {
3774
- var _this4 = this;
3775
-
3776
- nextTick(function () {
3777
- _this4.$handle && _this4.$handle.watchCtx(_this4);
3778
- });
3799
+ this.$handle.watchCtx(this);
3779
3800
  },
3780
3801
  "delete": function _delete() {
3781
3802
  var undef = void 0;
@@ -3804,15 +3825,15 @@ extend(RuleContext.prototype, {
3804
3825
  this.ctrlRule = [];
3805
3826
  },
3806
3827
  rm: function rm() {
3807
- var _this5 = this;
3828
+ var _this4 = this;
3808
3829
 
3809
3830
  var _rm = function _rm() {
3810
- var index = _this5.root.indexOf(_this5.origin);
3831
+ var index = _this4.root.indexOf(_this4.origin);
3811
3832
 
3812
3833
  if (index > -1) {
3813
- _this5.root.splice(index, 1);
3834
+ _this4.root.splice(index, 1);
3814
3835
 
3815
- _this5.$handle && _this5.$handle.refresh();
3836
+ _this4.$handle && _this4.$handle.refresh();
3816
3837
  }
3817
3838
  };
3818
3839
 
@@ -3823,17 +3844,17 @@ extend(RuleContext.prototype, {
3823
3844
  }
3824
3845
 
3825
3846
  this.$handle.noWatch(function () {
3826
- _this5.$handle.deferSyncValue(function () {
3827
- _this5.rmCtrl();
3847
+ _this4.$handle.deferSyncValue(function () {
3848
+ _this4.rmCtrl();
3828
3849
 
3829
3850
  _rm();
3830
3851
 
3831
- _this5.$handle.rmCtx(_this5);
3852
+ _this4.$handle.rmCtx(_this4);
3832
3853
 
3833
- extend(_this5, {
3854
+ extend(_this4, {
3834
3855
  root: []
3835
3856
  });
3836
- }, _this5.input);
3857
+ }, _this4.input);
3837
3858
  });
3838
3859
  },
3839
3860
  update: function update(handle, init) {
@@ -3937,13 +3958,13 @@ function useLoader(Handler) {
3937
3958
  return _this5.loadRule();
3938
3959
  }
3939
3960
 
3961
+ _this5.syncForm();
3962
+
3940
3963
  if (_this5.pageEnd) {
3941
3964
  _this5.bus.$emit('load-end');
3942
3965
  }
3943
3966
 
3944
3967
  _this5.vm.setupState.renderRule();
3945
-
3946
- _this5.syncForm();
3947
3968
  });
3948
3969
  },
3949
3970
  loadChildren: function loadChildren(children, parent) {
@@ -3958,8 +3979,8 @@ function useLoader(Handler) {
3958
3979
  if (this.cycleLoad) {
3959
3980
  return this.loadRule();
3960
3981
  } else {
3961
- this.bus.$emit('load-end');
3962
3982
  this.syncForm();
3983
+ this.bus.$emit('load-end');
3963
3984
  }
3964
3985
 
3965
3986
  this.$render.clearCache(parent);
@@ -4203,19 +4224,27 @@ function useLoader(Handler) {
4203
4224
  this.clearNextTick();
4204
4225
  this.initData(rules);
4205
4226
  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]);
4227
+ this.deferSyncValue(function () {
4228
+ _this8.bus.$once('load-end', function () {
4229
+ Object.keys(ctxs).filter(function (id) {
4230
+ return _this8.ctxs[id] === undefined;
4231
+ }).forEach(function (id) {
4232
+ return _this8.rmCtx(ctxs[id]);
4233
+ });
4234
+
4235
+ _this8.$render.clearCacheAll();
4211
4236
  });
4212
4237
 
4213
- _this8.$render.clearCacheAll();
4238
+ _this8.reloading = true;
4239
+
4240
+ _this8.loadRule();
4241
+
4242
+ _this8.reloading = false;
4243
+
4244
+ _this8.refresh();
4245
+
4246
+ _this8.bus.$emit('reloading', _this8.api);
4214
4247
  });
4215
- this.reloading = true;
4216
- this.loadRule();
4217
- this.reloading = false;
4218
- this.refresh();
4219
4248
  this.bus.$off('next-tick', this.nextReload);
4220
4249
  this.bus.$once('next-tick', this.nextReload);
4221
4250
  this.bus.$emit('update', this.api);
@@ -4281,28 +4310,14 @@ function useInput(Handler) {
4281
4310
  syncForm: function syncForm() {
4282
4311
  var _this = this;
4283
4312
 
4313
+ var data = reactive({});
4284
4314
  this.fields().reduce(function (initial, field) {
4285
4315
  var ctx = _this.getCtx(field);
4286
4316
 
4287
4317
  initial[field] = toRef(ctx.rule, 'value');
4288
4318
  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));
4319
+ }, data);
4320
+ this.form = data;
4306
4321
  this.syncValue();
4307
4322
  },
4308
4323
  appendValue: function appendValue(rule) {
@@ -4409,11 +4424,46 @@ var BaseParser = {
4409
4424
  return ctx.$render.defaultRender(ctx, children);
4410
4425
  },
4411
4426
  preview: function preview(children, ctx) {
4412
- return ctx.$render.defaultRender(ctx, children);
4427
+ return this.render(children, ctx);
4413
4428
  },
4414
4429
  mergeProp: function mergeProp(ctx) {}
4415
4430
  };
4416
4431
 
4432
+ var _ = {
4433
+ sum: function sum(arr) {
4434
+ if (Array.isArray(arr)) {
4435
+ var val = 0;
4436
+ arr.map(function (v) {
4437
+ return val += v || 0;
4438
+ });
4439
+ return val;
4440
+ }
4441
+ },
4442
+ column: function column(arr, field) {
4443
+ if (Array.isArray(arr)) {
4444
+ return arr.map(function (v) {
4445
+ return v[field];
4446
+ });
4447
+ }
4448
+
4449
+ return [];
4450
+ },
4451
+ get: function get(obj, field, def) {
4452
+ var lst = field.split('.');
4453
+ var val = obj;
4454
+
4455
+ for (var i = 0; i < lst.length; i++) {
4456
+ if (hasProperty(val, lst[i])) {
4457
+ val = val[lst[i]];
4458
+ } else {
4459
+ return def === undefined ? 0 : def;
4460
+ }
4461
+ }
4462
+
4463
+ return val;
4464
+ }
4465
+ };
4466
+ var noneKey = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update', 'slotUpdate', 'computed', 'component', 'cache'];
4417
4467
  function useContext(Handler) {
4418
4468
  extend(Handler.prototype, {
4419
4469
  getCtx: function getCtx(id) {
@@ -4490,10 +4540,9 @@ function useContext(Handler) {
4490
4540
  watchCtx: function watchCtx(ctx) {
4491
4541
  var _this = this;
4492
4542
 
4493
- var none = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update', 'slotUpdate'];
4494
4543
  var all = attrs();
4495
4544
  all.filter(function (k) {
4496
- return k[0] !== '_' && k[0] !== '$' && none.indexOf(k) === -1;
4545
+ return k[0] !== '_' && k[0] !== '$' && noneKey.indexOf(k) === -1;
4497
4546
  }).forEach(function (key) {
4498
4547
  var ref = toRef(ctx.rule, key);
4499
4548
  var flag = key === 'children';
@@ -4556,11 +4605,36 @@ function useContext(Handler) {
4556
4605
  return val.value;
4557
4606
  }, function () {
4558
4607
  var formValue = ctx.parser.toFormValue(val.value, ctx);
4608
+ formValue = formValue === null ? undefined : formValue;
4559
4609
 
4560
4610
  if (_this.isChange(ctx, formValue)) {
4561
4611
  _this.setValue(ctx, val.value, formValue, true);
4562
4612
  }
4563
4613
  }));
4614
+ this.bus.$once('load-end', function () {
4615
+ var computedRef = toRef(ctx.rule, 'computed');
4616
+ ctx.watch.push(watch(function () {
4617
+ var computed = computedRef.value;
4618
+ if (!computed) return undefined;
4619
+ var fn;
4620
+
4621
+ if (is.Function(computed)) {
4622
+ fn = function fn() {
4623
+ return computed(_this.api.form, _this.api);
4624
+ };
4625
+ } else {
4626
+ fn = function fn() {
4627
+ return new Function('_', "with(this){ return ".concat(computed, " }")).call(_this.api.form, _);
4628
+ };
4629
+ }
4630
+
4631
+ return invoke(fn, undefined);
4632
+ }, function (n) {
4633
+ val.value = n;
4634
+ }, {
4635
+ immediate: !!computedRef.value
4636
+ }));
4637
+ });
4564
4638
  }
4565
4639
 
4566
4640
  this.watchEffect(ctx);
@@ -4601,6 +4675,7 @@ function useContext(Handler) {
4601
4675
  $del(this.formData, id);
4602
4676
  $del(this.subForm, id);
4603
4677
  $del(this.vm.setupState.ctxInject, id);
4678
+ input && $del(this.form, field);
4604
4679
  input && this.rmIdCtx(ctx, field, 'field');
4605
4680
  name && this.rmIdCtx(ctx, name, 'name');
4606
4681
  this.deferSyncValue(function () {
@@ -4997,6 +5072,14 @@ function CreateNodeFactory() {
4997
5072
  make: function make(tag, data, children) {
4998
5073
  return makeDirective(data, this.h(tag, toProps(data), children));
4999
5074
  },
5075
+ makeComponent: function makeComponent(type, data, children) {
5076
+ try {
5077
+ return makeDirective(data, createVNode(type, toProps(data), children));
5078
+ } catch (e) {
5079
+ console.error(e);
5080
+ return createVNode('');
5081
+ }
5082
+ },
5000
5083
  h: function h(tag, data, children) {
5001
5084
  var isNativeTag = getCurrentInstance().appContext.config.isNativeTag(tag);
5002
5085
 
@@ -5413,7 +5496,7 @@ function FormCreateFactory(config) {
5413
5496
  CreateNode: CreateNode,
5414
5497
  bus: new Mitt(),
5415
5498
  unwatch: null,
5416
- options: ref({}),
5499
+ options: ref(vm.props.option || {}),
5417
5500
  extendApi: config.extendApi || function (api) {
5418
5501
  return api;
5419
5502
  }
@@ -5457,7 +5540,7 @@ function FormCreateFactory(config) {
5457
5540
  });
5458
5541
  }
5459
5542
 
5460
- this.initOptions(this.vm.props.option || {});
5543
+ this.initOptions(this.options.value);
5461
5544
  this.$handle.init();
5462
5545
  },
5463
5546
  isSub: function isSub() {
@@ -5985,8 +6068,10 @@ var manager = {
5985
6068
  makeInfo: function makeInfo(rule, uni) {
5986
6069
  var _this4 = this;
5987
6070
 
5988
- var titleProp = rule.title;
5989
- var infoProp = rule.info;
6071
+ var titleProp = _objectSpread2({}, rule.title);
6072
+
6073
+ var infoProp = _objectSpread2({}, rule.info);
6074
+
5990
6075
  var isTip = isTooltip(infoProp);
5991
6076
  var form = this.options.form;
5992
6077
  var children = [(titleProp.title || '') + (form.labelSuffix || form['label-suffix'] || '')];
@@ -6000,6 +6085,8 @@ var manager = {
6000
6085
  delete prop.props.icon;
6001
6086
  delete prop.props.show;
6002
6087
  delete prop.props.info;
6088
+ delete prop.props.align;
6089
+ delete prop.props["native"];
6003
6090
  var field = 'content';
6004
6091
 
6005
6092
  if (infoProp.info && !hasProperty(prop.props, field)) {
@@ -6021,11 +6108,16 @@ var manager = {
6021
6108
  })));
6022
6109
  }
6023
6110
 
6024
- return this.$r(mergeProps([titleProp, {
6111
+ var _prop = mergeProps([titleProp, {
6025
6112
  props: titleProp,
6026
6113
  key: "".concat(uni, "tit"),
6027
6114
  type: titleProp.type || 'span'
6028
- }]), children);
6115
+ }]);
6116
+
6117
+ delete _prop.props.show;
6118
+ delete _prop.props.title;
6119
+ delete _prop.props["native"];
6120
+ return this.$r(_prop, children);
6029
6121
  },
6030
6122
  makeCol: function makeCol(rule, uni, children) {
6031
6123
  var col = rule.col;
@@ -6081,6 +6173,9 @@ var manager = {
6081
6173
 
6082
6174
  var innerText = resetBtn.innerText;
6083
6175
  delete resetBtn.innerText;
6176
+ delete resetBtn.click;
6177
+ delete resetBtn.col;
6178
+ delete resetBtn.show;
6084
6179
  return this.$r({
6085
6180
  type: 'button',
6086
6181
  props: resetBtn,
@@ -6090,7 +6185,7 @@ var manager = {
6090
6185
  on: {
6091
6186
  click: function click() {
6092
6187
  var fApi = _this5.$handle.api;
6093
- resetBtn.click ? resetBtn.click(fApi) : fApi.resetFields();
6188
+ _this5.options.resetBtn.click ? _this5.options.resetBtn.click(fApi) : fApi.resetFields();
6094
6189
  }
6095
6190
  },
6096
6191
  key: "".concat(this.key, "b2")
@@ -6103,6 +6198,9 @@ var manager = {
6103
6198
 
6104
6199
  var innerText = submitBtn.innerText;
6105
6200
  delete submitBtn.innerText;
6201
+ delete submitBtn.click;
6202
+ delete submitBtn.col;
6203
+ delete submitBtn.show;
6106
6204
  return this.$r({
6107
6205
  type: 'button',
6108
6206
  props: submitBtn,
@@ -6112,7 +6210,7 @@ var manager = {
6112
6210
  on: {
6113
6211
  click: function click() {
6114
6212
  var fApi = _this6.$handle.api;
6115
- submitBtn.click ? submitBtn.click(fApi) : fApi.submit();
6213
+ _this6.options.submitBtn.click ? _this6.options.submitBtn.click(fApi) : fApi.submit();
6116
6214
  }
6117
6215
  },
6118
6216
  key: "".concat(this.key, "b1")
@@ -6366,17 +6464,17 @@ function extendApi(api, h) {
6366
6464
  var required = {
6367
6465
  name: 'required',
6368
6466
  load: function load(inject, rule, api) {
6369
- var val = parseVa(inject.getValue());
6467
+ var val = parseVal(inject.getValue());
6370
6468
 
6371
6469
  if (val.required === false) {
6372
6470
  inject.clearProp();
6373
6471
  } else {
6374
- var validate = _objectSpread2(_objectSpread2({}, val), {}, {
6472
+ var validate = _objectSpread2({
6375
6473
  required: true,
6376
6474
  validator: function validator(_, v, call) {
6377
6475
  is.empty(v) ? call(validate.message) : call();
6378
6476
  }
6379
- });
6477
+ }, val);
6380
6478
 
6381
6479
  if (!validate.message) {
6382
6480
  validate.message = rule.title + ' is required';
@@ -6392,7 +6490,7 @@ var required = {
6392
6490
  }
6393
6491
  };
6394
6492
 
6395
- function parseVa(val) {
6493
+ function parseVal(val) {
6396
6494
  if (is.Boolean(val)) {
6397
6495
  return {
6398
6496
  required: val
@@ -6401,6 +6499,10 @@ function parseVa(val) {
6401
6499
  return {
6402
6500
  message: val
6403
6501
  };
6502
+ } else if (is.Function(val)) {
6503
+ return {
6504
+ validator: val
6505
+ };
6404
6506
  } else if (!is.Object(val)) {
6405
6507
  return {};
6406
6508
  } else {
@@ -6431,7 +6533,7 @@ function install(FormCreate) {
6431
6533
  function elmFormCreate() {
6432
6534
  return FormCreateFactory({
6433
6535
  ui: 'element-ui',
6434
- version: '3.1.4',
6536
+ version: '3.1.8',
6435
6537
  manager: manager,
6436
6538
  extendApi: extendApi,
6437
6539
  install: install,