@form-create/view-design 2.5.33 → 2.5.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,6 +1,6 @@
1
1
  /*!
2
- * @form-create/view-design v2.5.33
3
- * (c) 2018-2023 xaboy
2
+ * @form-create/view-design v2.5.35
3
+ * (c) 2018-2024 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
6
6
  */
@@ -1497,6 +1497,7 @@
1497
1497
  for (var i = len; i < 0; i++) {
1498
1498
  this.addRule(n.length + i);
1499
1499
  }
1500
+ this.sort = Object.keys(this.cacheRule);
1500
1501
  for (var _i = 0; _i < total; _i++) {
1501
1502
  this.setValue(keys[_i], n[_i]);
1502
1503
  }
@@ -1506,6 +1507,7 @@
1506
1507
  this.removeRule(keys[total - _i2 - 1]);
1507
1508
  }
1508
1509
  }
1510
+ this.sort = Object.keys(this.cacheRule);
1509
1511
  n.forEach(function (val, i) {
1510
1512
  _this2.setValue(keys[i], n[i]);
1511
1513
  });
@@ -1925,6 +1927,7 @@
1925
1927
  }
1926
1928
  },
1927
1929
  extendOption: Boolean,
1930
+ disabled: Boolean,
1928
1931
  value: Object,
1929
1932
  api: Object,
1930
1933
  name: String,
@@ -1973,8 +1976,8 @@
1973
1976
  deep: true
1974
1977
  },
1975
1978
  option: {
1976
- handler: function handler(n) {
1977
- this.formCreate.initOptions(n);
1979
+ handler: function handler() {
1980
+ this.formCreate.initOptions();
1978
1981
  this.$f.refresh();
1979
1982
  },
1980
1983
  deep: true
@@ -1986,14 +1989,14 @@
1986
1989
  })) return;
1987
1990
  this.formCreate.$handle.reloadRule(n);
1988
1991
  this._renderRule();
1992
+ },
1993
+ disabled: function disabled(n) {
1994
+ this.$f.disabled(!!n);
1989
1995
  }
1990
1996
  },
1991
1997
  beforeCreate: function beforeCreate() {
1992
1998
  var _this2 = this;
1993
- var _this$$options$propsD = this.$options.propsData,
1994
- rule = _this$$options$propsD.rule,
1995
- option = _this$$options$propsD.option;
1996
- this.formCreate = new FormCreate(this, rule, option);
1999
+ this.formCreate = new FormCreate(this);
1997
2000
  Object.keys(this.formCreate.prop).forEach(function (k) {
1998
2001
  extend(_this2.$options[k], _this2.formCreate.prop[k]);
1999
2002
  });
@@ -2366,6 +2369,12 @@
2366
2369
  get parent() {
2367
2370
  return h.vm.$pfc && h.vm.$pfc.$f;
2368
2371
  },
2372
+ get top() {
2373
+ if (api.parent) {
2374
+ return api.parent.top;
2375
+ }
2376
+ return api;
2377
+ },
2369
2378
  get children() {
2370
2379
  return allSubForm();
2371
2380
  },
@@ -2785,7 +2794,8 @@
2785
2794
 
2786
2795
  var id = 0;
2787
2796
  function uniqueId() {
2788
- return 'F' + Math.random().toString(36).substr(3, 3) + Number("".concat(Date.now()).concat(++id)).toString(36);
2797
+ var num = 370 + ++id;
2798
+ return 'F' + Math.random().toString(36).substr(3, 3) + Number("".concat(Date.now())).toString(36) + num.toString(36) + 'c';
2789
2799
  }
2790
2800
 
2791
2801
  function deepSet(data, idx, val) {
@@ -4763,6 +4773,19 @@
4763
4773
  form: function form() {
4764
4774
  return this.vm.$refs[this.ref];
4765
4775
  },
4776
+ getSlot: function getSlot(name) {
4777
+ var _fn = function _fn(vm) {
4778
+ if (vm) {
4779
+ var slot = vm.$scopedSlots[name];
4780
+ if (slot) {
4781
+ return slot;
4782
+ }
4783
+ return _fn(vm.$pfc);
4784
+ }
4785
+ return undefined;
4786
+ };
4787
+ return _fn(this.vm);
4788
+ },
4766
4789
  mergeOptions: function mergeOptions(args, opt) {
4767
4790
  var _this2 = this;
4768
4791
  return mergeProps(args.map(function (v) {
@@ -5122,11 +5145,12 @@
5122
5145
  }
5123
5146
  function parser() {
5124
5147
  var data = nameProp.apply(void 0, arguments);
5125
- if (!data.id || !data.prop) return;
5148
+ if (!data.id || !data.prop) return BaseParser;
5126
5149
  var name = toCase(data.id);
5127
5150
  var parser = data.prop;
5128
5151
  var base = parser.merge === true ? parsers[name] : undefined;
5129
- parsers[name] = _objectSpread2(_objectSpread2({}, base || BaseParser), parser);
5152
+ parsers[name] = parser;
5153
+ Object.setPrototypeOf(parser, base || BaseParser);
5130
5154
  maker[name] = creatorFactory(name);
5131
5155
  parser.maker && extend(maker, parser.maker);
5132
5156
  }
@@ -5145,6 +5169,8 @@
5145
5169
  }
5146
5170
  if (!name || !component) return;
5147
5171
  components[name] = component;
5172
+ delete CreateNode.aliasMap[name];
5173
+ delete parsers[name];
5148
5174
  if (component.formCreateParser) parser(name, component.formCreateParser);
5149
5175
  }
5150
5176
  function _emitData(id) {
@@ -5196,7 +5222,8 @@
5196
5222
  }
5197
5223
  return FormCreateFactory(_config);
5198
5224
  }
5199
- function FormCreate(vm, rules, options) {
5225
+ function FormCreate(vm) {
5226
+ var rules = vm.$options.propsData.rule;
5200
5227
  extend(this, {
5201
5228
  id: id$1++,
5202
5229
  vm: vm,
@@ -5215,13 +5242,13 @@
5215
5242
  CreateNode: CreateNode,
5216
5243
  bus: new _vue(),
5217
5244
  unwatch: null,
5218
- options: options || {},
5245
+ options: {},
5219
5246
  extendApi: config.extendApi || function (api) {
5220
5247
  return api;
5221
5248
  }
5222
5249
  });
5223
5250
  this.init();
5224
- this.initOptions(this.options);
5251
+ this.initOptions();
5225
5252
  if (this.name) {
5226
5253
  if (this.inFor) {
5227
5254
  if (!instance[this.name]) instance[this.name] = [];
@@ -5244,14 +5271,15 @@
5244
5271
  _this2.unwatch = vm.$watch(function () {
5245
5272
  return vm.$pfc.option;
5246
5273
  }, function () {
5247
- _this2.initOptions(_this2.options);
5274
+ _this2.initOptions();
5248
5275
  vm.$f.refresh();
5249
5276
  }, {
5250
5277
  deep: true
5251
5278
  });
5252
- _this2.initOptions(_this2.options);
5279
+ _this2.initOptions();
5253
5280
  }
5254
5281
  _this2.created();
5282
+ vm.disabled && vm.$f.disabled(true);
5255
5283
  });
5256
5284
  vm.$on('hook:mounted', function () {
5257
5285
  _this2.mounted();
@@ -5281,8 +5309,9 @@
5281
5309
  isSub: function isSub() {
5282
5310
  return this.vm.$pfc && this.vm.extendOption;
5283
5311
  },
5284
- initOptions: function initOptions(options) {
5285
- this.options = _objectSpread2({
5312
+ initOptions: function initOptions() {
5313
+ this.options = {};
5314
+ var options = _objectSpread2({
5286
5315
  formData: {},
5287
5316
  submitBtn: {},
5288
5317
  resetBtn: {}
@@ -5290,6 +5319,7 @@
5290
5319
  if (this.isSub()) {
5291
5320
  this.mergeOptions(this.options, this.vm.$pfc.$f.config || {}, true);
5292
5321
  }
5322
+ options = this.mergeOptions(options, this.vm.$options.propsData.option);
5293
5323
  this.updateOptions(options);
5294
5324
  },
5295
5325
  mergeOptions: function mergeOptions(target, opt, parent) {
@@ -5687,7 +5717,7 @@
5687
5717
  }
5688
5718
  },
5689
5719
  tidyOptions: function tidyOptions(options) {
5690
- ['submitBtn', 'resetBtn', 'row', 'info', 'wrap', 'col'].forEach(function (name) {
5720
+ ['submitBtn', 'resetBtn', 'row', 'info', 'wrap', 'col', 'title'].forEach(function (name) {
5691
5721
  tidyBool(options, name);
5692
5722
  });
5693
5723
  return options;
@@ -5702,7 +5732,8 @@
5702
5732
  ctx.prop = mergeProps([{
5703
5733
  info: this.options.info || {},
5704
5734
  wrap: this.options.wrap || {},
5705
- col: this.options.col || {}
5735
+ col: this.options.col || {},
5736
+ title: this.options.title || {}
5706
5737
  }, ctx.prop], {
5707
5738
  info: info(),
5708
5739
  title: {},
@@ -5776,7 +5807,7 @@
5776
5807
  key: "".concat(uni, "fi"),
5777
5808
  ref: ctx.wrapRef,
5778
5809
  type: 'formItem'
5779
- }]), [children, isTitle ? this.makeInfo(rule, uni) : null]);
5810
+ }]), [children, isTitle ? this.makeInfo(rule, uni, ctx) : null]);
5780
5811
  return inline === true || isFalse(_col) || isFalse(col.show) ? item : this.makeCol(rule, uni, [item]);
5781
5812
  },
5782
5813
  isTitle: function isTitle(rule) {
@@ -5784,10 +5815,15 @@
5784
5815
  var title = rule.title;
5785
5816
  return !(!title.title && !title["native"] || isFalse(title.show));
5786
5817
  },
5787
- makeInfo: function makeInfo(rule, uni) {
5818
+ makeInfo: function makeInfo(rule, uni, ctx) {
5788
5819
  var titleProp = rule.title;
5789
5820
  var infoProp = rule.info;
5790
- var children = [titleProp.title];
5821
+ var titleSlot = this.getSlot('title');
5822
+ var children = [titleSlot ? titleSlot({
5823
+ title: titleProp.title || '',
5824
+ rule: ctx.rule,
5825
+ options: this.options
5826
+ }) : titleProp.title];
5791
5827
  if (!isFalse(infoProp.show) && (infoProp.info || infoProp["native"]) && !isFalse(infoProp.icon)) {
5792
5828
  var prop = {
5793
5829
  type: infoProp.type || 'poptip',
@@ -5860,7 +5896,7 @@
5860
5896
  }, [item]);
5861
5897
  },
5862
5898
  makeResetBtn: function makeResetBtn() {
5863
- var _this2 = this;
5899
+ var _this = this;
5864
5900
  var resetBtn = this.options.resetBtn;
5865
5901
  this.setSize(resetBtn);
5866
5902
  return this.$r({
@@ -5872,7 +5908,7 @@
5872
5908
  },
5873
5909
  on: {
5874
5910
  click: function click() {
5875
- var fApi = _this2.$handle.api;
5911
+ var fApi = _this.$handle.api;
5876
5912
  resetBtn.click ? resetBtn.click(fApi) : fApi.resetFields();
5877
5913
  }
5878
5914
  },
@@ -5880,7 +5916,7 @@
5880
5916
  }, [resetBtn.innerText]);
5881
5917
  },
5882
5918
  makeSubmitBtn: function makeSubmitBtn() {
5883
- var _this3 = this;
5919
+ var _this2 = this;
5884
5920
  var submitBtn = this.options.submitBtn;
5885
5921
  this.setSize(submitBtn);
5886
5922
  return this.$r({
@@ -5891,7 +5927,7 @@
5891
5927
  },
5892
5928
  on: {
5893
5929
  click: function click() {
5894
- var fApi = _this3.$handle.api;
5930
+ var fApi = _this2.$handle.api;
5895
5931
  submitBtn.click ? submitBtn.click(fApi) : fApi.submit();
5896
5932
  }
5897
5933
  },
@@ -6174,7 +6210,7 @@
6174
6210
  function ivuFormCreate() {
6175
6211
  return FormCreateFactory({
6176
6212
  ui: "".concat("view-design"),
6177
- version: "".concat("2.5.33"),
6213
+ version: "".concat("2.5.35"),
6178
6214
  manager: manager,
6179
6215
  install: install,
6180
6216
  extendApi: extendApi,