@form-create/element-ui 3.2.15 → 3.2.16

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.
package/README.md CHANGED
@@ -77,19 +77,38 @@
77
77
 
78
78
  ## 包说明
79
79
 
80
- | 包名 | 说明 |
81
- |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------|
82
- | @form-create/element-ui [![version](https://img.shields.io/npm/v/@form-create/element-ui/next.svg)](https://www.npmjs.com/package/@form-create/element-ui) [![npm](https://img.shields.io/npm/dt/@form-create/element-ui.svg)](https://www.npmjs.com/package/@form-create/element-ui) | [element-plus 版本](http://form-create.com/v3/element-ui/) |
83
- | @form-create/ant-design-vue [![version](https://img.shields.io/npm/v/@form-create/ant-design-vue/next.svg)](https://www.npmjs.com/package/@form-create/ant-design-vue) [![npm](https://img.shields.io/npm/dt/@form-create/ant-design-vue.svg)](https://www.npmjs.com/package/@form-create/ant-design-vue) | [ant-design-vue 版本](http://form-create.com/v3/ant-design-vue/) |
84
- | @form-create/arco-design [![version](https://img.shields.io/npm/v/@form-create/arco-design/next.svg)](https://www.npmjs.com/package/@form-create/arco-design) [![npm](https://img.shields.io/npm/dt/@form-create/arco-design.svg)](https://www.npmjs.com/package/@form-create/arco-design) | [arco-design 版本](http://form-create.com/v3/arco-design/) |
85
- | @form-create/naive-ui [![version](https://img.shields.io/npm/v/@form-create/naive-ui/next.svg)](https://www.npmjs.com/package/@form-create/naive-ui) [![npm](https://img.shields.io/npm/dt/@form-create/naive-ui.svg)](https://www.npmjs.com/package/@form-create/naive-ui) | [naive-ui 版本](http://form-create.com/v3/naive-ui/) |
86
- | @form-create/tdesign [![version](https://img.shields.io/npm/v/@form-create/tdesign/next.svg)](https://www.npmjs.com/package/@form-create/tdesign) [![npm](https://img.shields.io/npm/dt/@form-create/tdesign.svg)](https://www.npmjs.com/package/@form-create/tdesign) | [tdesign 版本](http://form-create.com/v3/tdesign/) |
87
- | @form-create/iview [![version](https://img.shields.io/npm/v/@form-create/iview.svg)](https://www.npmjs.com/package/@form-create/iview) [![npm](https://img.shields.io/npm/dt/@form-create/iview.svg)](https://www.npmjs.com/package/@form-create/iview) | [iview 版本](http://form-create.com/v2/iview/) |
88
- | @form-create/view-design [![version](https://img.shields.io/npm/v/@form-create/view-design.svg)](https://www.npmjs.com/package/@form-create/view-design) [![npm](https://img.shields.io/npm/dt/@form-create/view-design.svg)](https://www.npmjs.com/package/@form-create/view-design) | [view-design 版本](http://form-create.com/v2/iview/) |
89
- | @form-create/vant [![version](https://img.shields.io/npm/v/@form-create/vant.svg)](https://www.npmjs.com/package/@form-create/vant) [![npm](https://img.shields.io/npm/dt/@form-create/vant.svg)](https://www.npmjs.com/package/@form-create/vant) | [vant 版本(移动端)](http://form-create.com/v3/vant/) |
90
- | @form-create/designer [![version](https://img.shields.io/npm/v/@form-create/designer.svg)](https://www.npmjs.com/package/@form-create/designer) [![npm](https://img.shields.io/npm/dt/@form-create/designer.svg)](https://www.npmjs.com/package/@form-create/designer) | [可视化表单设计器](http://form-create.com/v3/designer) |
91
- | @form-create/vant-designer [![version](https://img.shields.io/npm/v/@form-create/vant-designer.svg)](https://www.npmjs.com/package/@form-create/designer) [![npm](https://img.shields.io/npm/dt/@form-create/vant-designer.svg)](https://www.npmjs.com/package/@form-create/designer) | [移动端表单设计器](http://form-create.com/v3/vant-designer) |
92
-
80
+ | 包名 | 说明 |
81
+ |-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------|
82
+ | @form-create/element-ui [![version](https://img.shields.io/npm/v/@form-create/element-ui/next.svg)](https://www.npmjs.com/package/@form-create/element-ui) | [element-plus 版本](http://form-create.com/v3/element-ui/) |
83
+ | @form-create/ant-design-vue [![version](https://img.shields.io/npm/v/@form-create/ant-design-vue/next.svg)](https://www.npmjs.com/package/@form-create/ant-design-vue) | [ant-design-vue 版本](http://form-create.com/v3/ant-design-vue/) |
84
+ | @form-create/arco-design [![version](https://img.shields.io/npm/v/@form-create/arco-design/next.svg)](https://www.npmjs.com/package/@form-create/arco-design) | [arco-design 版本](http://form-create.com/v3/arco-design/) |
85
+ | @form-create/naive-ui [![version](https://img.shields.io/npm/v/@form-create/naive-ui/next.svg)](https://www.npmjs.com/package/@form-create/naive-ui) | [naive-ui 版本](http://form-create.com/v3/naive-ui/) |
86
+ | @form-create/tdesign [![version](https://img.shields.io/npm/v/@form-create/tdesign/next.svg)](https://www.npmjs.com/package/@form-create/tdesign) | [tdesign 版本](http://form-create.com/v3/tdesign/) |
87
+ | @form-create/iview [![version](https://img.shields.io/npm/v/@form-create/iview.svg)](https://www.npmjs.com/package/@form-create/iview) | [iview 版本](http://form-create.com/v2/iview/) |
88
+ | @form-create/view-design [![version](https://img.shields.io/npm/v/@form-create/view-design.svg)](https://www.npmjs.com/package/@form-create/view-design) | [view-design 版本](http://form-create.com/v2/iview/) |
89
+ | @form-create/vant [![version](https://img.shields.io/npm/v/@form-create/vant.svg)](https://www.npmjs.com/package/@form-create/vant) | [vant 版本(移动端)](http://form-create.com/v3/vant/) |
90
+ | @form-create/designer [![version](https://img.shields.io/npm/v/@form-create/designer.svg)](https://www.npmjs.com/package/@form-create/designer) | [可视化表单设计器](http://form-create.com/v3/designer) |
91
+ | @form-create/vant-designer [![version](https://img.shields.io/npm/v/@form-create/vant-designer.svg)](https://www.npmjs.com/package/@form-create/designer) | [移动端表单设计器](http://form-create.com/v3/mobile) |
92
+
93
+ **分支说明**
94
+
95
+ - **latest:** Vue2.0版本分支
96
+ - **super:** Vue2.7版本分支(该版本功能和next分支功能一致)
97
+ - **next:** Vue3.0版本分支
98
+
99
+ 例如:
100
+
101
+ 安装Vue2版本的@form-create/element-ui
102
+
103
+ ```sh
104
+ npm install @form-create/element-ui
105
+ ```
106
+
107
+ 安装Vue3版本的@form-create/element-ui
108
+
109
+ ```sh
110
+ npm install @form-create/element-ui@next
111
+ ```
93
112
 
94
113
  ## 示例
95
114
 
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @form-create/element-ui v3.2.15
2
+ * @form-create/element-ui v3.2.16
3
3
  * (c) 2018-2024 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
@@ -2878,6 +2878,21 @@ function extractVar(str) {
2878
2878
 
2879
2879
  return Object.keys(matches);
2880
2880
  }
2881
+ function convertFieldToConditions(field) {
2882
+ var parts = field.split('.');
2883
+ var conditions = [];
2884
+ var currentCondition = '';
2885
+ parts.forEach(function (part, index) {
2886
+ if (index === 0) {
2887
+ currentCondition = part;
2888
+ } else {
2889
+ currentCondition += '.' + part;
2890
+ }
2891
+
2892
+ conditions.push(currentCondition);
2893
+ });
2894
+ return conditions.join(' && ');
2895
+ }
2881
2896
 
2882
2897
  function baseRule() {
2883
2898
  return {
@@ -3670,11 +3685,16 @@ function Api(h) {
3670
3685
  });
3671
3686
  });
3672
3687
  },
3673
- watchFetch: function watchFetch(opt, callback, error) {
3688
+ watchFetch: function watchFetch(opt, callback, error, beforeFetch) {
3674
3689
  return h.fc.watchLoadData(function (get, change) {
3675
3690
  var _opt = deepCopy(opt);
3676
3691
 
3677
3692
  _opt = h.loadFetchVar(_opt, get);
3693
+
3694
+ if (beforeFetch && beforeFetch(_opt, change) === false) {
3695
+ return;
3696
+ }
3697
+
3678
3698
  h.beforeFetch(_opt).then(function () {
3679
3699
  return asyncFetch(_opt, h.fc.create.fetch, api).then(function (res) {
3680
3700
  invoke(function () {
@@ -3688,7 +3708,7 @@ function Api(h) {
3688
3708
  error && error(e);
3689
3709
  });
3690
3710
  });
3691
- });
3711
+ }, opt.wait == null ? 1000 : opt.wait);
3692
3712
  },
3693
3713
  getData: function getData(id, def) {
3694
3714
  return h.fc.getLoadData(id, def);
@@ -4905,8 +4925,8 @@ function useLoader(Handler) {
4905
4925
  var rule = ctx.rule;
4906
4926
  is.trueArray(rule.sync) && mergeProps([{
4907
4927
  on: rule.sync.reduce(function (pre, prop) {
4908
- pre["update:".concat(prop)] = function (val) {
4909
- rule.props[prop] = val;
4928
+ pre[_typeof(prop) === 'object' && prop.event || "update:".concat(prop)] = function (val) {
4929
+ rule.props[_typeof(prop) === 'object' && prop.prop || prop] = val;
4910
4930
 
4911
4931
  _this4.vm.emit('sync', prop, val, rule, _this4.fapi);
4912
4932
  };
@@ -5032,7 +5052,7 @@ function useLoader(Handler) {
5032
5052
  return;
5033
5053
  }
5034
5054
 
5035
- rules[index] = _rule = _rule._clone ? _rule._clone() : copyRule(_rule);
5055
+ rules[index] = _rule = _rule._clone ? _rule._clone() : parseJson(toJson(_rule));
5036
5056
  ctx = null;
5037
5057
  isCopy = true;
5038
5058
  }
@@ -5560,6 +5580,7 @@ var BaseParser = {
5560
5580
  };
5561
5581
 
5562
5582
  var noneKey = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update', 'slotUpdate', 'computed', 'component', 'cache'];
5583
+ var oldValueTag = Symbol('oldValue');
5563
5584
  function useContext(Handler) {
5564
5585
  extend(Handler.prototype, {
5565
5586
  getCtx: function getCtx(id) {
@@ -5829,7 +5850,7 @@ function useContext(Handler) {
5829
5850
 
5830
5851
  var value = _this.compute(ctx, item);
5831
5852
 
5832
- if (item.linkage && value === undefined) {
5853
+ if (item.linkage && value === oldValueTag) {
5833
5854
  return oldValue;
5834
5855
  }
5835
5856
 
@@ -5884,10 +5905,22 @@ function useContext(Handler) {
5884
5905
  var _loop = function _loop(i) {
5885
5906
  var one = item.group[i];
5886
5907
  var flag = void 0;
5887
- var field = one.field;
5908
+ var field = null;
5888
5909
 
5889
5910
  if (one.variable) {
5890
5911
  field = JSON.stringify(_this2.fc.getLoadData(one.variable) || '');
5912
+ } else if (one.field) {
5913
+ field = convertFieldToConditions(one.field || '');
5914
+ } else {
5915
+ return {
5916
+ v: true
5917
+ };
5918
+ }
5919
+
5920
+ var compare = one.compare;
5921
+
5922
+ if (compare) {
5923
+ compare = convertFieldToConditions(compare || '');
5891
5924
  }
5892
5925
 
5893
5926
  if (one.mode) {
@@ -5899,7 +5932,7 @@ function useContext(Handler) {
5899
5932
  return one.handler(_this2.api, ctx.rule);
5900
5933
  });
5901
5934
  } else {
5902
- flag = new Function('$condition', '$val', '$form', '$group', '$rule', "with($form){with(this){with($group){ return $condition['".concat(one.condition, "'](").concat(field, ", ").concat(one.compare ? one.compare : '$val', "); }}}")).call(_this2.api.form, condition, one.value, _this2.api.top.form, group ? _this2.subRuleData[group.id] || {} : {}, ctx.rule);
5935
+ flag = new Function('$condition', '$val', '$form', '$group', '$rule', "with($form){with(this){with($group){ return $condition['".concat(one.condition, "'](").concat(field, ", ").concat(compare ? compare : '$val', "); }}}")).call(_this2.api.form, condition, one.value, _this2.api.top.form, group ? _this2.subRuleData[group.id] || {} : {}, ctx.rule);
5903
5936
  }
5904
5937
 
5905
5938
  if (or && flag) {
@@ -5928,7 +5961,7 @@ function useContext(Handler) {
5928
5961
  if (item.linkage) {
5929
5962
  return val ? invoke(function () {
5930
5963
  return _this2.computeValue(item.linkage, ctx, group);
5931
- }, undefined) : undefined;
5964
+ }, undefined) : oldValueTag;
5932
5965
  }
5933
5966
 
5934
5967
  return val;
@@ -6325,9 +6358,14 @@ function Handler(fc) {
6325
6358
  this.$manager = new fc.manager(this);
6326
6359
  this.$render = new Render(this);
6327
6360
  this.api = fc.extendApiFn.reduce(function (api, fn) {
6328
- extend(api, invoke(function () {
6361
+ var extendApi = invoke(function () {
6329
6362
  return fn(api, _this);
6330
- }, {}));
6363
+ });
6364
+
6365
+ if (extendApi && extendApi !== api) {
6366
+ extend(api, extendApi);
6367
+ }
6368
+
6331
6369
  return api;
6332
6370
  }, Api(this));
6333
6371
  }
@@ -7030,7 +7068,8 @@ function exportAttrs(attrs) {
7030
7068
  }
7031
7069
 
7032
7070
  var id = 1;
7033
- var instance = {}; //todo 表单嵌套
7071
+ var instance = {};
7072
+ var defValueTag = Symbol('defValue'); //todo 表单嵌套
7034
7073
 
7035
7074
  function FormCreateFactory(config) {
7036
7075
  var components = _defineProperty({}, fragment.name, fragment);
@@ -7253,7 +7292,11 @@ function FormCreateFactory(config) {
7253
7292
  id = split.shift();
7254
7293
  var field = split.join('.');
7255
7294
 
7256
- if (hasProperty(loadData, id)) {
7295
+ if (!hasProperty(loadData, id)) {
7296
+ loadData[id] = defValueTag;
7297
+ }
7298
+
7299
+ if (loadData[id] !== defValueTag) {
7257
7300
  var val = loadData[id];
7258
7301
 
7259
7302
  if (val && val._driver) {
@@ -7306,6 +7349,7 @@ function FormCreateFactory(config) {
7306
7349
  },
7307
7350
  drivers: drivers,
7308
7351
  renderDriver: null,
7352
+ get: null,
7309
7353
  refreshData: refreshData,
7310
7354
  loadData: loadData,
7311
7355
  CreateNode: CreateNode,
@@ -7538,22 +7582,11 @@ function FormCreateFactory(config) {
7538
7582
  var handle = is.Function(option) ? option : option.handle;
7539
7583
 
7540
7584
  if (handle) {
7541
- var val;
7542
- var unwatch = this.watchLoadData(function (get, change) {
7543
- if (change) {
7544
- unwatch();
7545
-
7546
- _this5.bus.$emit('$loadData.$var.' + key);
7547
-
7548
- return val;
7549
- }
7550
-
7551
- val = invoke(function () {
7552
- return handle(get, _this5.$handle.api);
7553
- });
7554
- });
7555
- this.unwatch.push(unwatch);
7556
- return val;
7585
+ return deepGet(invoke(function () {
7586
+ return handle(_this5.get || function () {
7587
+ return _this5.getLoadData.apply(_this5, arguments);
7588
+ }, _this5.$handle.api);
7589
+ }), split);
7557
7590
  }
7558
7591
  }
7559
7592
  },
@@ -7592,7 +7625,12 @@ function FormCreateFactory(config) {
7592
7625
  split = [];
7593
7626
  } else {
7594
7627
  var tmpData = this.vm.setupState.top.setupState.fc.tmpData;
7595
- val = hasProperty(tmpData, key) ? deepGet(tmpData, id) : getData(id);
7628
+
7629
+ if (!hasProperty(tmpData, key)) {
7630
+ tmpData[key] = defValueTag;
7631
+ }
7632
+
7633
+ val = tmpData[key] !== defValueTag ? deepGet(tmpData, id) : getData(id);
7596
7634
  split = [];
7597
7635
  }
7598
7636
 
@@ -7603,15 +7641,23 @@ function FormCreateFactory(config) {
7603
7641
 
7604
7642
  return val == null || val === '' ? def : val;
7605
7643
  },
7606
- watchLoadData: function watchLoadData(fn) {
7644
+ watchLoadData: function watchLoadData(fn, wait) {
7607
7645
  var _this6 = this;
7608
7646
 
7609
7647
  var unwatch = {};
7610
7648
 
7611
7649
  var run = function run(flag) {
7650
+ if (!_this6.get) {
7651
+ _this6.get = get;
7652
+ }
7653
+
7612
7654
  invoke(function () {
7613
7655
  fn(get, flag);
7614
7656
  });
7657
+
7658
+ if (_this6.get === get) {
7659
+ _this6.get = undefined;
7660
+ }
7615
7661
  };
7616
7662
 
7617
7663
  var get = function get(id, def) {
@@ -7634,7 +7680,7 @@ function FormCreateFactory(config) {
7634
7680
  unwatch[id].val = temp;
7635
7681
  run(true);
7636
7682
  }
7637
- }, 0);
7683
+ }, wait || 0);
7638
7684
  var un = watch(data, function (n) {
7639
7685
  callback();
7640
7686
  });
@@ -7694,7 +7740,7 @@ function FormCreateFactory(config) {
7694
7740
  this.updateOptions(options);
7695
7741
  },
7696
7742
  mergeOptions: function mergeOptions(target, opt, parent) {
7697
- opt = deepCopy(opt);
7743
+ opt = _objectSpread2({}, opt || {});
7698
7744
  parent && ['page', 'onSubmit', 'onReset', 'onCreated', 'onChange', 'onMounted', 'mounted', 'onReload', 'reload', 'formData', 'el', 'globalClass', 'style'].forEach(function (n) {
7699
7745
  delete opt[n];
7700
7746
  });
@@ -8751,7 +8797,7 @@ function install(FormCreate) {
8751
8797
  function elmFormCreate() {
8752
8798
  return FormCreateFactory({
8753
8799
  ui: 'element-ui',
8754
- version: '3.2.15',
8800
+ version: '3.2.16',
8755
8801
  manager: manager,
8756
8802
  extendApi: extendApi,
8757
8803
  install: install,