@form-create/element-ui 3.1.33 → 3.1.35

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.33
2
+ * @form-create/element-ui v3.1.35
3
3
  * (c) 2018-2024 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
@@ -1612,14 +1612,6 @@ var Group = defineComponent({
1612
1612
  },
1613
1613
  deep: true
1614
1614
  },
1615
- disabled: function disabled(n) {
1616
- if (this.syncDisabled) {
1617
- var lst = this.cacheRule;
1618
- Object.keys(lst).forEach(function (k) {
1619
- lst[k].$f.disabled(n);
1620
- });
1621
- }
1622
- },
1623
1615
  expand: function expand(n) {
1624
1616
  var d = n - this.modelValue.length;
1625
1617
 
@@ -1741,10 +1733,6 @@ var Group = defineComponent({
1741
1733
 
1742
1734
  this.cacheRule[key].$f = $f;
1743
1735
  nextTick(function () {
1744
- if (_this5.syncDisabled) {
1745
- $f.disabled(_this5.disabled);
1746
- }
1747
-
1748
1736
  _this5.$emit('itemMounted', $f, Object.keys(_this5.cacheRule).indexOf(key));
1749
1737
  });
1750
1738
  },
@@ -1915,6 +1903,7 @@ var Group = defineComponent({
1915
1903
  }, [createVNode(Type, mergeProps$1({
1916
1904
  "key": key
1917
1905
  }, {
1906
+ disabled: disabled,
1918
1907
  'onUpdate:modelValue': function onUpdateModelValue(formData) {
1919
1908
  return _this12.formData(key, formData);
1920
1909
  },
@@ -1985,9 +1974,6 @@ var Sub = defineComponent({
1985
1974
  },
1986
1975
  emits: ['fc:subform', 'update:modelValue', 'change', 'itemMounted'],
1987
1976
  watch: {
1988
- disabled: function disabled(n) {
1989
- this.syncDisabled && this.subApi.disabled(n);
1990
- },
1991
1977
  modelValue: function modelValue(n) {
1992
1978
  this.setValue(n);
1993
1979
  }
@@ -2013,8 +1999,6 @@ var Sub = defineComponent({
2013
1999
 
2014
2000
  this.subApi = api;
2015
2001
  nextTick(function () {
2016
- _this.syncDisabled && api.disabled(_this.disabled);
2017
-
2018
2002
  _this.$emit('itemMounted', api);
2019
2003
  });
2020
2004
  }
@@ -2022,6 +2006,7 @@ var Sub = defineComponent({
2022
2006
  render: function render() {
2023
2007
  var Type = this.form;
2024
2008
  return createVNode(Type, {
2009
+ "disabled": this.disabled,
2025
2010
  "onUpdate:modelValue": this.formData,
2026
2011
  "modelValue": this.modelValue,
2027
2012
  "onEmit-event": this.$emit,
@@ -2963,7 +2948,7 @@ function Api(h) {
2963
2948
  if (!ctx) return initial;
2964
2949
  initial[ctx.field] = copy(ctx.rule.value);
2965
2950
  return initial;
2966
- }, h.options.appendValue ? copy(h.appendData) : {});
2951
+ }, h.options.appendValue !== false ? copy(h.appendData) : {});
2967
2952
  },
2968
2953
  getValue: function getValue(field) {
2969
2954
  var ctx = h.getFieldCtx(field);
@@ -3408,12 +3393,17 @@ function Api(h) {
3408
3393
  },
3409
3394
  bus: h.bus,
3410
3395
  fetch: function fetch(opt) {
3411
- h.options.beforeFetch && invoke(function () {
3412
- return h.options.beforeFetch(opt, {
3413
- api: api
3396
+ return new Promise(function (resolve, reject) {
3397
+ h.beforeFetch(opt).then(function () {
3398
+ return asyncFetch(opt).then(resolve)["catch"](reject);
3414
3399
  });
3415
3400
  });
3416
- return asyncFetch(opt);
3401
+ },
3402
+ getData: function getData(id, def) {
3403
+ return h.fc.getData(id, def);
3404
+ },
3405
+ setData: function setData(id, data) {
3406
+ return h.fc.setData(id, data);
3417
3407
  },
3418
3408
  helper: {
3419
3409
  tidyFields: tidyFields,
@@ -3815,8 +3805,8 @@ function useRender$1(Render) {
3815
3805
  }];
3816
3806
 
3817
3807
  if (ctx.input) {
3818
- if (this.vm.props.disabled !== undefined) {
3819
- ctx.prop.props.disabled = !!this.vm.props.disabled;
3808
+ if (this.vm.props.disabled === true) {
3809
+ ctx.prop.props.disabled = true;
3820
3810
  }
3821
3811
 
3822
3812
  var field = this.getModelField(ctx);
@@ -5027,7 +5017,7 @@ function useInput(Handler) {
5027
5017
  return this.deferSyncFn.sync = true;
5028
5018
  }
5029
5019
 
5030
- this.vm.setupState.updateValue(_objectSpread2(_objectSpread2({}, this.options.appendValue ? this.appendData : {}), this.form));
5020
+ this.vm.setupState.updateValue(_objectSpread2(_objectSpread2({}, this.options.appendValue !== false ? this.appendData : {}), this.form));
5031
5021
  },
5032
5022
  isChange: function isChange(ctx, value) {
5033
5023
  return JSON.stringify(this.getFormData(ctx), strFn) !== JSON.stringify(value, strFn);
@@ -5683,7 +5673,12 @@ function Handler(fc) {
5683
5673
  this.initData(fc.rules);
5684
5674
  this.$manager = new fc.manager(this);
5685
5675
  this.$render = new Render(this);
5686
- this.api = fc.extendApi(Api(this), this);
5676
+ this.api = fc.extendApiFn.reduce(function (api, fn) {
5677
+ extend(api, invoke(function () {
5678
+ return fn(api, _this);
5679
+ }, {}));
5680
+ return api;
5681
+ }, Api(this));
5687
5682
  }
5688
5683
  extend(Handler.prototype, {
5689
5684
  initData: function initData(rules) {
@@ -5707,6 +5702,23 @@ extend(Handler.prototype, {
5707
5702
  },
5708
5703
  isBreakWatch: function isBreakWatch() {
5709
5704
  return this.loading || this.noWatchFn || this.reloading;
5705
+ },
5706
+ beforeFetch: function beforeFetch(opt) {
5707
+ var _this2 = this;
5708
+
5709
+ return new Promise(function (resolve) {
5710
+ var source = _this2.options.beforeFetch && invoke(function () {
5711
+ return _this2.options.beforeFetch(opt, {
5712
+ api: _this2.api
5713
+ });
5714
+ });
5715
+
5716
+ if (source && is.Function(source.then)) {
5717
+ source.then(resolve);
5718
+ } else {
5719
+ resolve();
5720
+ }
5721
+ });
5710
5722
  }
5711
5723
  });
5712
5724
  useInject(Handler);
@@ -5921,7 +5933,7 @@ var loadData = function loadData(fc) {
5921
5933
  if (attr.attr) {
5922
5934
  value = fc.loadData[attr.attr] || attr["default"];
5923
5935
 
5924
- if (attr.copy) {
5936
+ if (attr.copy !== false) {
5925
5937
  value = deepCopy(value);
5926
5938
  }
5927
5939
  }
@@ -6060,7 +6072,7 @@ var fetch = function fetch(fc) {
6060
6072
  if (check()) return;
6061
6073
 
6062
6074
  var fn = function fn(v) {
6063
- return flag ? v : v.data;
6075
+ return flag ? v : hasProperty(v, 'data') ? v.data : v;
6064
6076
  };
6065
6077
 
6066
6078
  var parse = parseFn(option.parse);
@@ -6091,27 +6103,25 @@ var fetch = function fetch(fc) {
6091
6103
  }
6092
6104
  });
6093
6105
 
6094
- fc.$handle.options.beforeFetch && invoke(function () {
6095
- return fc.$handle.options.beforeFetch(config, {
6096
- rule: rule,
6097
- api: api
6098
- });
6099
- });
6100
-
6101
- if (is.Function(option.action)) {
6102
- option.action(rule, api).then(function (val) {
6103
- config.onSuccess(val, true);
6104
- })["catch"](function (e) {
6105
- config.onError(e);
6106
- });
6107
- return;
6108
- }
6106
+ fc.$handle.beforeFetch(config, {
6107
+ rule: rule,
6108
+ api: api
6109
+ }).then(function () {
6110
+ if (is.Function(option.action)) {
6111
+ option.action(rule, api).then(function (val) {
6112
+ config.onSuccess(val, true);
6113
+ })["catch"](function (e) {
6114
+ config.onError(e);
6115
+ });
6116
+ return;
6117
+ }
6109
6118
 
6110
- invoke(function () {
6111
- return fc.create.fetch(config, {
6112
- inject: inject,
6113
- rule: rule,
6114
- api: api
6119
+ invoke(function () {
6120
+ return fc.create.fetch(config, {
6121
+ inject: inject,
6122
+ rule: rule,
6123
+ api: api
6124
+ });
6115
6125
  });
6116
6126
  });
6117
6127
  }
@@ -6192,6 +6202,7 @@ function FormCreateFactory(config) {
6192
6202
  var directives = {};
6193
6203
  var modelFields = {};
6194
6204
  var useApps = [];
6205
+ var extendApiFn = [config.extendApi];
6195
6206
 
6196
6207
  var providers = _objectSpread2({}, $provider);
6197
6208
 
@@ -6199,7 +6210,7 @@ function FormCreateFactory(config) {
6199
6210
  var globalConfig = {
6200
6211
  global: {}
6201
6212
  };
6202
- var loadData = {};
6213
+ var loadData = reactive({});
6203
6214
  var CreateNode = CreateNodeFactory();
6204
6215
  var formulas = {};
6205
6216
  exportAttrs(config.attrs || {});
@@ -6361,6 +6372,14 @@ function FormCreateFactory(config) {
6361
6372
  _emitData(id);
6362
6373
  }
6363
6374
 
6375
+ function getData(id, def) {
6376
+ return hasProperty(loadData, id) ? loadData[id] : def;
6377
+ }
6378
+
6379
+ function extendApi(fn) {
6380
+ extendApiFn.push(fn);
6381
+ }
6382
+
6364
6383
  function removeData(id) {
6365
6384
  delete loadData[id];
6366
6385
 
@@ -6386,14 +6405,14 @@ function FormCreateFactory(config) {
6386
6405
  components: components,
6387
6406
  directives: directives
6388
6407
  },
6408
+ setData: setData,
6409
+ getData: getData,
6389
6410
  loadData: loadData,
6390
6411
  CreateNode: CreateNode,
6391
6412
  bus: new Mitt(),
6392
6413
  unwatch: null,
6393
6414
  options: ref({}),
6394
- extendApi: config.extendApi || function (api) {
6395
- return api;
6396
- }
6415
+ extendApiFn: extendApiFn
6397
6416
  });
6398
6417
  nextTick(function () {
6399
6418
  watch(_this.options, function () {
@@ -6511,6 +6530,8 @@ function FormCreateFactory(config) {
6511
6530
  extend(formCreate, {
6512
6531
  version: config.version,
6513
6532
  ui: config.ui,
6533
+ extendApi: extendApi,
6534
+ getData: getData,
6514
6535
  setData: setData,
6515
6536
  removeData: removeData,
6516
6537
  maker: maker,
@@ -7228,7 +7249,7 @@ function tidyBtnProp(btn, def) {
7228
7249
  }
7229
7250
 
7230
7251
  function extendApi(api, h) {
7231
- extend(api, {
7252
+ return {
7232
7253
  formEl: function formEl() {
7233
7254
  return h.$manager.form();
7234
7255
  },
@@ -7387,8 +7408,7 @@ function extendApi(api, h) {
7387
7408
  });
7388
7409
  });
7389
7410
  }
7390
- });
7391
- return api;
7411
+ };
7392
7412
  }
7393
7413
 
7394
7414
  var required = {
@@ -7469,7 +7489,7 @@ function install(FormCreate) {
7469
7489
  function elmFormCreate() {
7470
7490
  return FormCreateFactory({
7471
7491
  ui: 'element-ui',
7472
- version: '3.1.33',
7492
+ version: '3.1.35',
7473
7493
  manager: manager,
7474
7494
  extendApi: extendApi,
7475
7495
  install: install,