@form-create/element-ui 3.1.2 → 3.1.5

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.2
2
+ * @form-create/element-ui v3.1.4
3
3
  * (c) 2018-2022 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
@@ -799,6 +799,7 @@
799
799
  try {
800
800
  if (this.helper === true) {
801
801
  iframe['form_create_helper'] = {
802
+ api: this.formCreateInject.api,
802
803
  close: function close(field) {
803
804
  _this7.valid(field);
804
805
 
@@ -1271,9 +1272,28 @@
1271
1272
  },
1272
1273
  trueArray: function trueArray(data) {
1273
1274
  return Array.isArray(data) && data.length > 0;
1275
+ },
1276
+ Function: function Function(v) {
1277
+ var type = this.getType(v);
1278
+ return type === 'Function' || type === 'AsyncFunction';
1279
+ },
1280
+ getType: function getType(v) {
1281
+ var str = Object.prototype.toString.call(v);
1282
+ return /^\[object (.*)\]$/.exec(str)[1];
1283
+ },
1284
+ empty: function empty(value) {
1285
+ if (value === undefined || value === null) {
1286
+ return true;
1287
+ }
1288
+
1289
+ if (Array.isArray(value) && Array.isArray(value) && !value.length) {
1290
+ return true;
1291
+ }
1292
+
1293
+ return typeof value === 'string' && !value;
1274
1294
  }
1275
1295
  };
1276
- ['Date', 'Object', 'Function', 'String', 'Boolean', 'Array', 'Number'].forEach(function (t) {
1296
+ ['Date', 'Object', 'String', 'Boolean', 'Array', 'Number'].forEach(function (t) {
1277
1297
  is[t] = function (arg) {
1278
1298
  return is.type(arg, t);
1279
1299
  };
@@ -1341,6 +1361,81 @@
1341
1361
 
1342
1362
  script$1.render = render$1;
1343
1363
 
1364
+ function $set(target, field, value) {
1365
+ target[field] = value;
1366
+ }
1367
+ function $del(target, field) {
1368
+ delete target[field];
1369
+ }
1370
+
1371
+ function deepExtend(origin) {
1372
+ var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1373
+ var mode = arguments.length > 2 ? arguments[2] : undefined;
1374
+ var isArr = false;
1375
+
1376
+ for (var key in target) {
1377
+ if (Object.prototype.hasOwnProperty.call(target, key)) {
1378
+ var clone = target[key];
1379
+
1380
+ if ((isArr = Array.isArray(clone)) || is.Object(clone)) {
1381
+ var nst = origin[key] === undefined;
1382
+
1383
+ if (isArr) {
1384
+ isArr = false;
1385
+ nst && $set(origin, key, []);
1386
+ } else if (clone._clone && mode !== undefined) {
1387
+ if (mode) {
1388
+ clone = clone.getRule();
1389
+ nst && $set(origin, key, {});
1390
+ } else {
1391
+ $set(origin, key, clone._clone());
1392
+ continue;
1393
+ }
1394
+ } else {
1395
+ nst && $set(origin, key, {});
1396
+ }
1397
+
1398
+ origin[key] = deepExtend(origin[key], clone, mode);
1399
+ } else {
1400
+ $set(origin, key, clone);
1401
+
1402
+ if (!is.Undef(clone)) {
1403
+ if (!is.Undef(clone.__json)) {
1404
+ origin[key].__json = clone.__json;
1405
+ }
1406
+
1407
+ if (!is.Undef(clone.__origin)) {
1408
+ origin[key].__origin = clone.__origin;
1409
+ }
1410
+ }
1411
+ }
1412
+ }
1413
+ }
1414
+
1415
+ return mode !== undefined && Array.isArray(origin) ? origin.filter(function (v) {
1416
+ return !v || !v.__ctrl;
1417
+ }) : origin;
1418
+ }
1419
+ function deepCopy(value) {
1420
+ return deepExtend({}, {
1421
+ value: value
1422
+ }).value;
1423
+ }
1424
+
1425
+ var _extends = Object.assign || function (a) {
1426
+ for (var b, c = 1; c < arguments.length; c++) {
1427
+ for (var d in b = arguments[c], b) {
1428
+ Object.prototype.hasOwnProperty.call(b, d) && $set(a, d, b[d]);
1429
+ }
1430
+ }
1431
+
1432
+ return a;
1433
+ };
1434
+
1435
+ function extend() {
1436
+ return _extends.apply(this, arguments);
1437
+ }
1438
+
1344
1439
  function _isSlot(s) {
1345
1440
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !vue.isVNode(s);
1346
1441
  }
@@ -1371,6 +1466,7 @@
1371
1466
  return [];
1372
1467
  }
1373
1468
  },
1469
+ defaultValue: Object,
1374
1470
  disabled: {
1375
1471
  type: Boolean,
1376
1472
  "default": false
@@ -1440,8 +1536,6 @@
1440
1536
  for (var _i2 = 0; _i2 < len; _i2++) {
1441
1537
  this.removeRule(keys[total - _i2 - 1]);
1442
1538
  }
1443
-
1444
- this.subForm();
1445
1539
  }
1446
1540
 
1447
1541
  n.forEach(function (val, i) {
@@ -1449,8 +1543,7 @@
1449
1543
  });
1450
1544
  }
1451
1545
  },
1452
- deep: true,
1453
- flush: 'post'
1546
+ deep: true
1454
1547
  }
1455
1548
  },
1456
1549
  methods: {
@@ -1507,6 +1600,13 @@
1507
1600
  submitBtn: false,
1508
1601
  resetBtn: false
1509
1602
  };
1603
+
1604
+ if (this.defaultValue) {
1605
+ if (!options.formData) options.formData = {};
1606
+ var defVal = deepCopy(this.defaultValue);
1607
+ extend(options.formData, this.field ? _defineProperty({}, this.field, defVal) : defVal);
1608
+ }
1609
+
1510
1610
  this.cacheRule[++this.len] = {
1511
1611
  rule: rule,
1512
1612
  options: options
@@ -1522,7 +1622,7 @@
1522
1622
  var _this4 = this;
1523
1623
 
1524
1624
  this.cacheRule[key].$f = $f;
1525
- this.subForm();
1625
+ this.formData(key, $f.formData());
1526
1626
  vue.nextTick(function () {
1527
1627
  if (_this4.syncDisabled) {
1528
1628
  $f.disabled(_this4.disabled);
@@ -1531,15 +1631,8 @@
1531
1631
  _this4.$emit('itemMounted', $f, Object.keys(_this4.cacheRule).indexOf(key));
1532
1632
  });
1533
1633
  },
1534
- subForm: function subForm() {
1535
- var _this5 = this;
1536
-
1537
- this.formCreateInject.subForm(Object.keys(this.cacheRule).map(function (k) {
1538
- return _this5.cacheRule[k].$f;
1539
- }));
1540
- },
1541
1634
  removeRule: function removeRule(key, emit) {
1542
- var _this6 = this;
1635
+ var _this5 = this;
1543
1636
 
1544
1637
  var index = Object.keys(this.cacheRule).indexOf(key);
1545
1638
  delete this.cacheRule[key];
@@ -1547,7 +1640,7 @@
1547
1640
 
1548
1641
  if (emit) {
1549
1642
  vue.nextTick(function () {
1550
- return _this6.$emit('remove', index);
1643
+ return _this5.$emit('remove', index);
1551
1644
  });
1552
1645
  }
1553
1646
  },
@@ -1565,7 +1658,6 @@
1565
1658
  }
1566
1659
 
1567
1660
  this.removeRule(key, true);
1568
- this.subForm();
1569
1661
  this.modelValue.splice(index, 1);
1570
1662
  this.input(this.modelValue);
1571
1663
  },
@@ -1581,14 +1673,14 @@
1581
1673
  });
1582
1674
  },
1583
1675
  delIcon: function delIcon(index, key) {
1584
- var _this7 = this;
1676
+ var _this6 = this;
1585
1677
 
1586
1678
  return vue.createVNode(vue.resolveComponent("ElIcon"), {
1587
1679
  "key": "d".concat(key),
1588
1680
  "class": "el-icon-remove-outline",
1589
1681
  "style": "font-size:".concat(this.fontSize, "px;cursor:").concat(this.disabled ? 'not-allowed;color:#c9cdd4' : 'pointer;color:#606266', ";"),
1590
1682
  "onClick": function onClick() {
1591
- return _this7.del(index, key);
1683
+ return _this6.del(index, key);
1592
1684
  }
1593
1685
  }, {
1594
1686
  "default": function _default() {
@@ -1597,7 +1689,7 @@
1597
1689
  });
1598
1690
  },
1599
1691
  makeIcon: function makeIcon(total, index, key) {
1600
- var _this8 = this;
1692
+ var _this7 = this;
1601
1693
 
1602
1694
  if (this.$slots.button) {
1603
1695
  return this.$slots.button({
@@ -1606,7 +1698,7 @@
1606
1698
  vm: this,
1607
1699
  key: key,
1608
1700
  del: function del() {
1609
- return _this8.del(index, key);
1701
+ return _this7.del(index, key);
1610
1702
  },
1611
1703
  add: this.add
1612
1704
  });
@@ -1641,7 +1733,7 @@
1641
1733
  }
1642
1734
  },
1643
1735
  render: function render() {
1644
- var _this9 = this;
1736
+ var _this8 = this;
1645
1737
 
1646
1738
  var keys = Object.keys(this.cacheRule);
1647
1739
  var button = this.button;
@@ -1662,9 +1754,9 @@
1662
1754
  }, [keys.map(function (key, index) {
1663
1755
  var _slot;
1664
1756
 
1665
- var _this9$cacheRule$key = _this9.cacheRule[key],
1666
- rule = _this9$cacheRule$key.rule,
1667
- options = _this9$cacheRule$key.options;
1757
+ var _this8$cacheRule$key = _this8.cacheRule[key],
1758
+ rule = _this8$cacheRule$key.rule,
1759
+ options = _this8$cacheRule$key.options;
1668
1760
  return vue.createVNode(vue.resolveComponent("ElRow"), {
1669
1761
  "align": "middle",
1670
1762
  "type": "flex",
@@ -1680,19 +1772,20 @@
1680
1772
  "default": function _default() {
1681
1773
  return [vue.createVNode(Type, {
1682
1774
  "key": key,
1775
+ "inFor": true,
1683
1776
  "onUpdate:modelValue": function onUpdateModelValue(formData) {
1684
- return _this9.formData(key, formData);
1777
+ return _this8.formData(key, formData);
1685
1778
  },
1686
- "modelValue": _this9.field ? _defineProperty({}, _this9.field, _this9._value(_this9.modelValue[index])) : _this9.modelValue[index],
1779
+ "modelValue": _this8.field ? _defineProperty({}, _this8.field, _this8._value(_this8.modelValue[index])) : _this8.modelValue[index],
1687
1780
  "onEmit-event": function onEmitEvent(name) {
1688
1781
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1689
1782
  args[_key - 1] = arguments[_key];
1690
1783
  }
1691
1784
 
1692
- return _this9.emitEvent(name, args, index, key);
1785
+ return _this8.emitEvent(name, args, index, key);
1693
1786
  },
1694
1787
  "onUpdate:api": function onUpdateApi($f) {
1695
- return _this9.add$f(index, key, $f);
1788
+ return _this8.add$f(index, key, $f);
1696
1789
  },
1697
1790
  "rule": rule,
1698
1791
  "option": options,
@@ -1705,7 +1798,7 @@
1705
1798
  "span": 2,
1706
1799
  "pull": 1,
1707
1800
  "push": 1
1708
- }, _isSlot(_slot = _this9.makeIcon(keys.length, index, key)) ? _slot : {
1801
+ }, _isSlot(_slot = _this8.makeIcon(keys.length, index, key)) ? _slot : {
1709
1802
  "default": function _default() {
1710
1803
  return [_slot];
1711
1804
  }
@@ -1782,7 +1875,6 @@
1782
1875
  var _this = this;
1783
1876
 
1784
1877
  this.subApi = api;
1785
- this.formCreateInject.subForm(api);
1786
1878
  vue.nextTick(function () {
1787
1879
  _this.syncDisabled && api.disabled(_this.disabled);
1788
1880
 
@@ -1829,6 +1921,21 @@
1829
1921
  var components = [Checkbox, Frame, Radio, Select, Tree, Upload, Group, Sub, script];
1830
1922
 
1831
1923
  var NAME$1 = 'FormCreate';
1924
+
1925
+ var getRuleInject = function getRuleInject(vm, parent) {
1926
+ if (vm === parent) {
1927
+ return;
1928
+ }
1929
+
1930
+ if (vm.ctx.formCreateInject) {
1931
+ return vm.ctx.formCreateInject;
1932
+ }
1933
+
1934
+ if (vm.parent) {
1935
+ return getRuleInject(vm.parent, parent);
1936
+ }
1937
+ };
1938
+
1832
1939
  function $FormCreate(FormCreate) {
1833
1940
  return vue.defineComponent({
1834
1941
  name: NAME$1,
@@ -1849,7 +1956,12 @@
1849
1956
  extendOption: Boolean,
1850
1957
  modelValue: Object,
1851
1958
  api: Object,
1852
- name: String
1959
+ name: String,
1960
+ subForm: {
1961
+ type: Boolean,
1962
+ "default": true
1963
+ },
1964
+ inFor: Boolean
1853
1965
  },
1854
1966
  emits: ['update:api', 'update:modelValue', 'mounted', 'submit', 'change', 'emit-event', 'control', 'remove-rule', 'remove-field', 'sync', 'reload', 'repeat-field', 'update'],
1855
1967
  render: function render() {
@@ -1862,7 +1974,9 @@
1862
1974
 
1863
1975
  var _toRefs = vue.toRefs(props),
1864
1976
  rule = _toRefs.rule,
1865
- modelValue = _toRefs.modelValue;
1977
+ modelValue = _toRefs.modelValue,
1978
+ subForm = _toRefs.subForm,
1979
+ inFor = _toRefs.inFor;
1866
1980
 
1867
1981
  var data = vue.reactive({
1868
1982
  ctxInject: {},
@@ -1874,16 +1988,60 @@
1874
1988
  });
1875
1989
  var fc = new FormCreate(vm);
1876
1990
  var fapi = fc.api();
1991
+ var isMore = inFor.value;
1992
+
1993
+ var addSubForm = function addSubForm() {
1994
+ if (parent) {
1995
+ var _inject = getRuleInject(vm, parent);
1996
+
1997
+ if (_inject) {
1998
+ var sub;
1999
+
2000
+ if (isMore) {
2001
+ sub = toArray(_inject.getSubForm());
2002
+ sub.push(fapi);
2003
+ } else {
2004
+ sub = fapi;
2005
+ }
2006
+
2007
+ _inject.subForm(sub);
2008
+ }
2009
+ }
2010
+ };
2011
+
2012
+ var rmSubForm = function rmSubForm() {
2013
+ var inject = getRuleInject(vm, parent);
2014
+
2015
+ if (inject) {
2016
+ if (isMore) {
2017
+ var sub = toArray(inject.getSubForm());
2018
+ var idx = sub.indexOf(fapi);
2019
+
2020
+ if (idx > -1) {
2021
+ sub.splice(idx, 1);
2022
+ }
2023
+ } else {
2024
+ inject.subForm();
2025
+ }
2026
+ }
2027
+ };
2028
+
1877
2029
  vue.onMounted(function () {
1878
2030
  fc.mounted();
1879
2031
  });
1880
2032
  vue.onBeforeUnmount(function () {
2033
+ rmSubForm();
1881
2034
  data.destroyed = true;
1882
2035
  fc.unmount();
1883
2036
  });
1884
2037
  vue.onUpdated(function () {
1885
2038
  fc.updated();
1886
2039
  });
2040
+ vue.watch(subForm, function (n) {
2041
+ n ? addSubForm() : rmSubForm();
2042
+ }, {
2043
+ immediate: true
2044
+ });
1887
2045
  vue.watch(function () {
1888
2046
  return _toConsumableArray(rule.value);
1889
2047
  }, function (n) {
@@ -1898,8 +2056,8 @@
1898
2056
  fapi.refresh();
1899
2057
  });
1900
2058
  vue.watch(modelValue, function (n) {
1901
- if (JSON.stringify(n) === data.updateValue) return;
1902
- fapi.setValue(n);
2059
+ if (JSON.stringify(n || {}) === data.updateValue) return;
2060
+ fapi.setValue(n || {});
1903
2061
  }, {
1904
2062
  deep: true
1905
2063
  });
@@ -1929,27 +2087,6 @@
1929
2087
  });
1930
2088
  }
1931
2089
 
1932
- function $set(target, field, value) {
1933
- target[field] = value;
1934
- }
1935
- function $del(target, field) {
1936
- delete target[field];
1937
- }
1938
-
1939
- var _extends = Object.assign || function (a) {
1940
- for (var b, c = 1; c < arguments.length; c++) {
1941
- for (var d in b = arguments[c], b) {
1942
- Object.prototype.hasOwnProperty.call(b, d) && $set(a, d, b[d]);
1943
- }
1944
- }
1945
-
1946
- return a;
1947
- };
1948
-
1949
- function extend() {
1950
- return _extends.apply(this, arguments);
1951
- }
1952
-
1953
2090
  var normalMerge = ['props'];
1954
2091
  var toArrayMerge = ['class', 'style', 'directives'];
1955
2092
  var functionalMerge = ['on'];
@@ -2019,67 +2156,13 @@
2019
2156
  };
2020
2157
  };
2021
2158
 
2022
- var keyAttrs = ['type', 'slot', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key'];
2159
+ var keyAttrs = ['type', 'slot', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key', 'slotUpdate'];
2023
2160
  var arrayAttrs = ['validate', 'children', 'control'];
2024
2161
  var normalAttrs = ['effect'];
2025
2162
  function attrs() {
2026
2163
  return [].concat(keyAttrs, _toConsumableArray(normalMerge), _toConsumableArray(toArrayMerge), _toConsumableArray(functionalMerge), arrayAttrs, normalAttrs);
2027
2164
  }
2028
2165
 
2029
- function deepExtend(origin) {
2030
- var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2031
- var mode = arguments.length > 2 ? arguments[2] : undefined;
2032
- var isArr = false;
2033
-
2034
- for (var key in target) {
2035
- if (Object.prototype.hasOwnProperty.call(target, key)) {
2036
- var clone = target[key];
2037
-
2038
- if ((isArr = Array.isArray(clone)) || is.Object(clone)) {
2039
- var nst = origin[key] === undefined;
2040
-
2041
- if (isArr) {
2042
- isArr = false;
2043
- nst && $set(origin, key, []);
2044
- } else if (clone._clone && mode !== undefined) {
2045
- if (mode) {
2046
- clone = clone.getRule();
2047
- nst && $set(origin, key, {});
2048
- } else {
2049
- $set(origin, key, clone._clone());
2050
- continue;
2051
- }
2052
- } else {
2053
- nst && $set(origin, key, {});
2054
- }
2055
-
2056
- origin[key] = deepExtend(origin[key], clone, mode);
2057
- } else {
2058
- $set(origin, key, clone);
2059
-
2060
- if (!is.Undef(clone)) {
2061
- if (!is.Undef(clone.__json)) {
2062
- origin[key].__json = clone.__json;
2063
- }
2064
-
2065
- if (!is.Undef(clone.__origin)) {
2066
- origin[key].__origin = clone.__origin;
2067
- }
2068
- }
2069
- }
2070
- }
2071
- }
2072
-
2073
- return mode !== undefined && Array.isArray(origin) ? origin.filter(function (v) {
2074
- return !v || !v.__ctrl;
2075
- }) : origin;
2076
- }
2077
- function deepCopy(value) {
2078
- return deepExtend({}, {
2079
- value: value
2080
- }).value;
2081
- }
2082
-
2083
2166
  function format(type, msg, rule) {
2084
2167
  return "[form-create ".concat(type, "]: ").concat(msg) + (rule ? '\n\nrule: ' + JSON.stringify(rule.getRule ? rule.getRule() : rule) : '');
2085
2168
  }
@@ -2237,14 +2320,14 @@
2237
2320
  if (!slotBag[slot]) slotBag[slot] = [];
2238
2321
  slotBag[slot].push(vnFn);
2239
2322
  },
2240
- getSlot: function getSlot(slot) {
2323
+ getSlot: function getSlot(slot, val) {
2241
2324
  slot = slotName(slot);
2242
2325
  var children = [];
2243
2326
  (slotBag[slot] || []).forEach(function (fn) {
2244
2327
  if (Array.isArray(fn)) {
2245
2328
  children.push.apply(children, _toConsumableArray(fn));
2246
2329
  } else if (is.Function(fn)) {
2247
- var res = fn();
2330
+ var res = fn.apply(void 0, _toConsumableArray(val || []));
2248
2331
 
2249
2332
  if (Array.isArray(res)) {
2250
2333
  children.push.apply(children, _toConsumableArray(res));
@@ -2263,7 +2346,11 @@
2263
2346
  var slots = {};
2264
2347
  Object.keys(slotBag).forEach(function (k) {
2265
2348
  slots[k] = function () {
2266
- return _this.getSlot(k);
2349
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
2350
+ args[_key] = arguments[_key];
2351
+ }
2352
+
2353
+ return _this.getSlot(k, args);
2267
2354
  };
2268
2355
  });
2269
2356
  return slots;
@@ -2687,6 +2774,25 @@
2687
2774
  return origin ? ctx.origin : ctx.rule;
2688
2775
  }
2689
2776
  },
2777
+ setEffect: function setEffect(id, attr, value) {
2778
+ var ctx = h.getCtx(id);
2779
+
2780
+ if (ctx && attr) {
2781
+ if (attr[0] === '$') {
2782
+ attr = attr.substr(1);
2783
+ }
2784
+
2785
+ if (hasProperty(ctx.rule, '$' + attr)) {
2786
+ $set(ctx.rule, '$' + attr, value);
2787
+ }
2788
+
2789
+ if (!hasProperty(ctx.rule, 'effect')) {
2790
+ ctx.rule.effect = {};
2791
+ }
2792
+
2793
+ $set(ctx.rule.effect, attr, value);
2794
+ }
2795
+ },
2690
2796
  updateValidate: function updateValidate(id, validate, merge) {
2691
2797
  if (merge) {
2692
2798
  api.mergeRule(id, {
@@ -2989,6 +3095,25 @@
2989
3095
  }
2990
3096
 
2991
3097
  vn = function vn() {
3098
+ for (var _len = arguments.length, slotValue = new Array(_len), _key = 0; _key < _len; _key++) {
3099
+ slotValue[_key] = arguments[_key];
3100
+ }
3101
+
3102
+ var inject = {
3103
+ rule: rule,
3104
+ prop: prop,
3105
+ preview: preview,
3106
+ api: _this4.$handle.api,
3107
+ model: prop.model || {},
3108
+ slotValue: slotValue
3109
+ };
3110
+
3111
+ if (slotValue.length && rule.slotUpdate) {
3112
+ invoke(function () {
3113
+ return rule.slotUpdate(inject);
3114
+ });
3115
+ }
3116
+
2992
3117
  var children = {};
2993
3118
 
2994
3119
  var _load = ctx.loadChildrenPending();
@@ -3004,14 +3129,8 @@
3004
3129
  var _vn;
3005
3130
 
3006
3131
  if (slot) {
3007
- _vn = slot({
3008
- rule: rule,
3009
- prop: prop,
3010
- preview: preview,
3011
- children: children,
3012
- api: _this4.$handle.api,
3013
- model: prop.model || {}
3014
- });
3132
+ inject.children = children;
3133
+ _vn = slot(inject);
3015
3134
  } else {
3016
3135
  _vn = preview ? ctx.parser.preview(children, ctx) : ctx.parser.render(children, ctx);
3017
3136
  }
@@ -3090,11 +3209,15 @@
3090
3209
  subForm: function subForm(_subForm) {
3091
3210
  _this6.$handle.addSubForm(ctx, _subForm);
3092
3211
  },
3212
+ getSubForm: function getSubForm() {
3213
+ return _this6.$handle.subForm[ctx.id];
3214
+ },
3093
3215
  options: [],
3094
3216
  children: [],
3095
3217
  preview: false,
3096
3218
  field: ctx.field,
3097
- rule: ctx.rule
3219
+ rule: ctx.rule,
3220
+ input: ctx.input
3098
3221
  };
3099
3222
  }
3100
3223
 
@@ -3129,12 +3252,17 @@
3129
3252
 
3130
3253
  if (!custom && ctx.input) {
3131
3254
  var field = this.getModelField(ctx);
3132
- props.push({
3133
- on: _defineProperty({}, "update:".concat(field), function update(value) {
3255
+ var model = {
3256
+ callback: function callback(value) {
3134
3257
  _this7.onInput(ctx, value);
3135
- }),
3136
- props: _defineProperty({}, field, this.$handle.getFormData(ctx))
3258
+ },
3259
+ value: this.$handle.getFormData(ctx)
3260
+ };
3261
+ props.push({
3262
+ on: _defineProperty({}, "update:".concat(field), model.callback),
3263
+ props: _defineProperty({}, field, model.value)
3137
3264
  });
3265
+ ctx.prop.model = model;
3138
3266
  }
3139
3267
 
3140
3268
  mergeProps(props, ctx.prop);
@@ -4187,9 +4315,7 @@
4187
4315
  delete this.appendData[rule.field];
4188
4316
  },
4189
4317
  addSubForm: function addSubForm(ctx, subForm) {
4190
- if (ctx.input) {
4191
- this.subForm[ctx.id] = subForm;
4192
- }
4318
+ this.subForm[ctx.id] = subForm;
4193
4319
  },
4194
4320
  deferSyncValue: function deferSyncValue(fn, sync) {
4195
4321
  if (!this.deferSyncFn) {
@@ -4368,10 +4494,10 @@
4368
4494
  watchCtx: function watchCtx(ctx) {
4369
4495
  var _this = this;
4370
4496
 
4371
- var none = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update'];
4497
+ var none = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update', 'slotUpdate'];
4372
4498
  var all = attrs();
4373
4499
  all.filter(function (k) {
4374
- return k[0] !== '_' && none.indexOf(k) === -1;
4500
+ return k[0] !== '_' && k[0] !== '$' && none.indexOf(k) === -1;
4375
4501
  }).forEach(function (key) {
4376
4502
  var ref = vue.toRef(ctx.rule, key);
4377
4503
  var flag = key === 'children';
@@ -4576,10 +4702,21 @@
4576
4702
  watchEffect: function watchEffect(ctx) {
4577
4703
  var _this3 = this;
4578
4704
 
4705
+ var effect = {};
4579
4706
  Object.keys(ctx.rule.effect || {}).forEach(function (k) {
4580
- ctx.watch.push(vue.watch(function () {
4707
+ effect[k] = function () {
4581
4708
  return ctx.rule.effect[k];
4582
- }, function (n) {
4709
+ };
4710
+ });
4711
+ Object.keys(ctx.rule).forEach(function (k) {
4712
+ if (k[0] === '$') {
4713
+ effect[k.substr(1)] = function () {
4714
+ return ctx.rule[k];
4715
+ };
4716
+ }
4717
+ });
4718
+ Object.keys(effect).forEach(function (k) {
4719
+ ctx.watch.push(vue.watch(effect[k], function (n) {
4583
4720
  _this3.effect(ctx, 'watch', _defineProperty({}, k, n));
4584
4721
  }, {
4585
4722
  deep: true
@@ -4603,7 +4740,12 @@
4603
4740
  }, event);
4604
4741
  },
4605
4742
  getEffect: function getEffect(rule, name) {
4606
- if (hasProperty(rule, 'effect') && hasProperty(rule.effect, name)) return rule.effect[name];else return undefined;
4743
+ if (hasProperty(rule, '$' + name)) {
4744
+ return rule['$' + name];
4745
+ }
4746
+
4747
+ if (hasProperty(rule, 'effect') && hasProperty(rule.effect, name)) return rule.effect[name];
4748
+ return undefined;
4607
4749
  },
4608
4750
  emitEffect: function emitEffect(_ref, event, append) {
4609
4751
  var _this4 = this;
@@ -4614,7 +4756,13 @@
4614
4756
  type = _ref.type,
4615
4757
  custom = _ref.custom;
4616
4758
  if (!type || ['fcFragment', 'fragment'].indexOf(type) > -1) return;
4617
- var effect = custom ? custom : rule.effect || {};
4759
+ var effect = custom ? custom : Object.keys(rule).reduce(function (i, k) {
4760
+ if (k[0] === '$') {
4761
+ i[k.substr(1)] = rule[k];
4762
+ }
4763
+
4764
+ return i;
4765
+ }, _objectSpread2({}, rule.effect || {}));
4618
4766
  Object.keys(effect).forEach(function (attr) {
4619
4767
  var p = _this4.providers[attr];
4620
4768
  if (!p || p.input && !input) return;
@@ -5049,6 +5197,10 @@
5049
5197
  return true;
5050
5198
  }
5051
5199
 
5200
+ var $provider = {
5201
+ fetch: $fetch
5202
+ };
5203
+
5052
5204
  var name$6 = 'html';
5053
5205
  var html = {
5054
5206
  name: name$6,
@@ -5108,9 +5260,9 @@
5108
5260
  var directives = {};
5109
5261
  var modelFields = {};
5110
5262
  var useApps = [];
5111
- var providers = {
5112
- fetch: $fetch
5113
- };
5263
+
5264
+ var providers = _objectSpread2({}, $provider);
5265
+
5114
5266
  var maker = makerFactory();
5115
5267
  var globalConfig = {
5116
5268
  global: {}
@@ -5120,7 +5272,9 @@
5120
5272
  exportAttrs(config.attrs || {});
5121
5273
 
5122
5274
  function getApi(name) {
5123
- return instance[name];
5275
+ var val = instance[name];
5276
+ if (Array.isArray(val)) return _toConsumableArray(val);
5277
+ return val;
5124
5278
  }
5125
5279
 
5126
5280
  function useApp(fn) {
@@ -5217,8 +5371,25 @@
5217
5371
  return vm.$refs.fc.fapi;
5218
5372
  }
5219
5373
 
5220
- function factory() {
5221
- return FormCreateFactory(config);
5374
+ function factory(inherit) {
5375
+ var _config = _objectSpread2({}, config);
5376
+
5377
+ if (inherit) {
5378
+ _config.inherit = {
5379
+ components: components,
5380
+ parsers: parsers,
5381
+ directives: directives,
5382
+ modelFields: modelFields,
5383
+ providers: providers,
5384
+ useApps: useApps,
5385
+ maker: maker,
5386
+ data: data
5387
+ };
5388
+ } else {
5389
+ delete _config.inherit;
5390
+ }
5391
+
5392
+ return FormCreateFactory(_config);
5222
5393
  }
5223
5394
 
5224
5395
  function setModelField(name, field) {
@@ -5238,6 +5409,7 @@
5238
5409
  modelFields: modelFields,
5239
5410
  rules: vm.props.rule,
5240
5411
  name: vm.props.name,
5412
+ inFor: vm.props.inFor,
5241
5413
  prop: {
5242
5414
  components: components,
5243
5415
  directives: directives
@@ -5264,7 +5436,12 @@
5264
5436
  this.$handle = new Handler(this);
5265
5437
 
5266
5438
  if (this.name) {
5267
- instance[this.name] = this.api();
5439
+ if (this.inFor) {
5440
+ if (!instance[this.name]) instance[this.name] = [];
5441
+ instance[this.name].push(this.api());
5442
+ } else {
5443
+ instance[this.name] = this.api();
5444
+ }
5268
5445
  }
5269
5446
  }
5270
5447
 
@@ -5332,7 +5509,12 @@
5332
5509
  },
5333
5510
  unmount: function unmount() {
5334
5511
  if (this.name) {
5335
- delete instance[this.name];
5512
+ if (this.inFor) {
5513
+ var idx = instance[this.name].indexOf(this.api());
5514
+ instance[this.name].splice(idx, 1);
5515
+ } else {
5516
+ delete instance[this.name];
5517
+ }
5336
5518
  }
5337
5519
 
5338
5520
  this.unwatch && this.unwatch();
@@ -5411,6 +5593,19 @@
5411
5593
  });
5412
5594
  });
5413
5595
  parser(html);
5596
+
5597
+ if (config.inherit) {
5598
+ var inherit = config.inherit;
5599
+ inherit.components && extend(components, inherit.components);
5600
+ inherit.parsers && extend(parsers, inherit.parsers);
5601
+ inherit.directives && extend(directives, inherit.directives);
5602
+ inherit.modelFields && extend(modelFields, inherit.modelFields);
5603
+ inherit.providers && extend(providers, inherit.providers);
5604
+ inherit.useApps && extend(useApps, inherit.useApps);
5605
+ inherit.maker && extend(maker, inherit.maker);
5606
+ inherit.data && extend(data, inherit.data);
5607
+ }
5608
+
5414
5609
  return create;
5415
5610
  }
5416
5611
 
@@ -6172,11 +6367,57 @@
6172
6367
  return api;
6173
6368
  }
6174
6369
 
6370
+ var required = {
6371
+ name: 'required',
6372
+ load: function load(inject, rule, api) {
6373
+ var val = parseVa(inject.getValue());
6374
+
6375
+ if (val.required === false) {
6376
+ inject.clearProp();
6377
+ } else {
6378
+ var validate = _objectSpread2(_objectSpread2({}, val), {}, {
6379
+ required: true,
6380
+ validator: function validator(_, v, call) {
6381
+ is.empty(v) ? call(validate.message) : call();
6382
+ }
6383
+ });
6384
+
6385
+ if (!validate.message) {
6386
+ validate.message = rule.title + ' is required';
6387
+ }
6388
+
6389
+ inject.getProp().validate = [validate];
6390
+ }
6391
+
6392
+ api.sync(rule);
6393
+ },
6394
+ watch: function watch() {
6395
+ required.load.apply(required, arguments);
6396
+ }
6397
+ };
6398
+
6399
+ function parseVa(val) {
6400
+ if (is.Boolean(val)) {
6401
+ return {
6402
+ required: val
6403
+ };
6404
+ } else if (is.String(val)) {
6405
+ return {
6406
+ message: val
6407
+ };
6408
+ } else if (!is.Object(val)) {
6409
+ return {};
6410
+ } else {
6411
+ return val;
6412
+ }
6413
+ }
6414
+
6175
6415
  function install(FormCreate) {
6176
6416
  FormCreate.componentAlias(alias);
6177
6417
  components.forEach(function (component) {
6178
6418
  FormCreate.component(component.name, component);
6179
6419
  });
6420
+ FormCreate.register(required);
6180
6421
  parsers.forEach(function (parser) {
6181
6422
  FormCreate.parser(parser);
6182
6423
  });
@@ -6194,7 +6435,7 @@
6194
6435
  function elmFormCreate() {
6195
6436
  return FormCreateFactory({
6196
6437
  ui: 'element-ui',
6197
- version: '3.1.2',
6438
+ version: '3.1.4',
6198
6439
  manager: manager,
6199
6440
  extendApi: extendApi,
6200
6441
  install: install,