@form-create/element-ui 3.1.33 → 3.1.34

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.34
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,11 @@ 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
+ return _objectSpread2(_objectSpread2({}, api), invoke(function () {
5678
+ return fn(_objectSpread2({}, api), _this);
5679
+ }, {}));
5680
+ }, Api(this));
5687
5681
  }
5688
5682
  extend(Handler.prototype, {
5689
5683
  initData: function initData(rules) {
@@ -5707,6 +5701,23 @@ extend(Handler.prototype, {
5707
5701
  },
5708
5702
  isBreakWatch: function isBreakWatch() {
5709
5703
  return this.loading || this.noWatchFn || this.reloading;
5704
+ },
5705
+ beforeFetch: function beforeFetch(opt) {
5706
+ var _this2 = this;
5707
+
5708
+ return new Promise(function (resolve) {
5709
+ var source = _this2.options.beforeFetch && invoke(function () {
5710
+ return _this2.options.beforeFetch(opt, {
5711
+ api: _this2.api
5712
+ });
5713
+ });
5714
+
5715
+ if (source && is.Function(source.then)) {
5716
+ source.then(resolve);
5717
+ } else {
5718
+ resolve();
5719
+ }
5720
+ });
5710
5721
  }
5711
5722
  });
5712
5723
  useInject(Handler);
@@ -5921,7 +5932,7 @@ var loadData = function loadData(fc) {
5921
5932
  if (attr.attr) {
5922
5933
  value = fc.loadData[attr.attr] || attr["default"];
5923
5934
 
5924
- if (attr.copy) {
5935
+ if (attr.copy !== false) {
5925
5936
  value = deepCopy(value);
5926
5937
  }
5927
5938
  }
@@ -6060,7 +6071,7 @@ var fetch = function fetch(fc) {
6060
6071
  if (check()) return;
6061
6072
 
6062
6073
  var fn = function fn(v) {
6063
- return flag ? v : v.data;
6074
+ return flag ? v : hasProperty(v, 'data') ? v.data : v;
6064
6075
  };
6065
6076
 
6066
6077
  var parse = parseFn(option.parse);
@@ -6091,27 +6102,25 @@ var fetch = function fetch(fc) {
6091
6102
  }
6092
6103
  });
6093
6104
 
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
- }
6105
+ fc.$handle.beforeFetch(config, {
6106
+ rule: rule,
6107
+ api: api
6108
+ }).then(function () {
6109
+ if (is.Function(option.action)) {
6110
+ option.action(rule, api).then(function (val) {
6111
+ config.onSuccess(val, true);
6112
+ })["catch"](function (e) {
6113
+ config.onError(e);
6114
+ });
6115
+ return;
6116
+ }
6109
6117
 
6110
- invoke(function () {
6111
- return fc.create.fetch(config, {
6112
- inject: inject,
6113
- rule: rule,
6114
- api: api
6118
+ invoke(function () {
6119
+ return fc.create.fetch(config, {
6120
+ inject: inject,
6121
+ rule: rule,
6122
+ api: api
6123
+ });
6115
6124
  });
6116
6125
  });
6117
6126
  }
@@ -6192,6 +6201,7 @@ function FormCreateFactory(config) {
6192
6201
  var directives = {};
6193
6202
  var modelFields = {};
6194
6203
  var useApps = [];
6204
+ var extendApiFn = [config.extendApi];
6195
6205
 
6196
6206
  var providers = _objectSpread2({}, $provider);
6197
6207
 
@@ -6199,7 +6209,7 @@ function FormCreateFactory(config) {
6199
6209
  var globalConfig = {
6200
6210
  global: {}
6201
6211
  };
6202
- var loadData = {};
6212
+ var loadData = reactive({});
6203
6213
  var CreateNode = CreateNodeFactory();
6204
6214
  var formulas = {};
6205
6215
  exportAttrs(config.attrs || {});
@@ -6361,6 +6371,14 @@ function FormCreateFactory(config) {
6361
6371
  _emitData(id);
6362
6372
  }
6363
6373
 
6374
+ function getData(id, def) {
6375
+ return hasProperty(loadData, id) ? loadData[id] : def;
6376
+ }
6377
+
6378
+ function extendApi(fn) {
6379
+ extendApiFn.push(fn);
6380
+ }
6381
+
6364
6382
  function removeData(id) {
6365
6383
  delete loadData[id];
6366
6384
 
@@ -6386,14 +6404,14 @@ function FormCreateFactory(config) {
6386
6404
  components: components,
6387
6405
  directives: directives
6388
6406
  },
6407
+ setData: setData,
6408
+ getData: getData,
6389
6409
  loadData: loadData,
6390
6410
  CreateNode: CreateNode,
6391
6411
  bus: new Mitt(),
6392
6412
  unwatch: null,
6393
6413
  options: ref({}),
6394
- extendApi: config.extendApi || function (api) {
6395
- return api;
6396
- }
6414
+ extendApiFn: extendApiFn
6397
6415
  });
6398
6416
  nextTick(function () {
6399
6417
  watch(_this.options, function () {
@@ -6511,6 +6529,8 @@ function FormCreateFactory(config) {
6511
6529
  extend(formCreate, {
6512
6530
  version: config.version,
6513
6531
  ui: config.ui,
6532
+ extendApi: extendApi,
6533
+ getData: getData,
6514
6534
  setData: setData,
6515
6535
  removeData: removeData,
6516
6536
  maker: maker,
@@ -7228,7 +7248,7 @@ function tidyBtnProp(btn, def) {
7228
7248
  }
7229
7249
 
7230
7250
  function extendApi(api, h) {
7231
- extend(api, {
7251
+ return {
7232
7252
  formEl: function formEl() {
7233
7253
  return h.$manager.form();
7234
7254
  },
@@ -7387,8 +7407,7 @@ function extendApi(api, h) {
7387
7407
  });
7388
7408
  });
7389
7409
  }
7390
- });
7391
- return api;
7410
+ };
7392
7411
  }
7393
7412
 
7394
7413
  var required = {
@@ -7469,7 +7488,7 @@ function install(FormCreate) {
7469
7488
  function elmFormCreate() {
7470
7489
  return FormCreateFactory({
7471
7490
  ui: 'element-ui',
7472
- version: '3.1.33',
7491
+ version: '3.1.34',
7473
7492
  manager: manager,
7474
7493
  extendApi: extendApi,
7475
7494
  install: install,