@form-create/iview 2.5.12 → 2.5.13

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/iview v2.5.12
2
+ * @form-create/iview v2.5.13
3
3
  * (c) 2018-2021 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
@@ -276,15 +276,13 @@
276
276
  trueValue: []
277
277
  };
278
278
  },
279
- computed: {
279
+ methods: {
280
280
  options: function options() {
281
281
  var opt = this.formCreateInject.options;
282
282
  return Array.isArray(opt) ? opt : [];
283
- }
284
- },
285
- methods: {
283
+ },
286
284
  onInput: function onInput(n) {
287
- this.$emit('input', this.options.filter(function (opt) {
285
+ this.$emit('input', this.options().filter(function (opt) {
288
286
  return n.indexOf(opt.label) !== -1;
289
287
  }).map(function (opt) {
290
288
  return opt.value;
@@ -295,7 +293,7 @@
295
293
  update: function update() {
296
294
  var _this = this;
297
295
 
298
- this.trueValue = this.value ? this.options.filter(function (opt) {
296
+ this.trueValue = this.value ? this.options().filter(function (opt) {
299
297
  return _this.value.indexOf(opt.value) !== -1;
300
298
  }).map(function (option) {
301
299
  return option.label;
@@ -314,7 +312,7 @@
314
312
  "on": {
315
313
  "input": this.onInput
316
314
  }
317
- }]), [this.options.map(function (opt, index) {
315
+ }]), [this.options().map(function (opt, index) {
318
316
  var props = _objectSpread2({}, opt);
319
317
 
320
318
  delete props.value;
@@ -846,15 +844,13 @@
846
844
  trueValue: []
847
845
  };
848
846
  },
849
- computed: {
847
+ methods: {
850
848
  options: function options() {
851
849
  var opt = this.formCreateInject.options;
852
850
  return Array.isArray(opt) ? opt : [];
853
- }
854
- },
855
- methods: {
851
+ },
856
852
  onInput: function onInput(n) {
857
- this.$emit('input', this.options.filter(function (opt) {
853
+ this.$emit('input', this.options().filter(function (opt) {
858
854
  return opt.label === n;
859
855
  }).reduce(function (initial, opt) {
860
856
  return opt.value;
@@ -863,7 +859,7 @@
863
859
  update: function update() {
864
860
  var _this = this;
865
861
 
866
- this.trueValue = this.options.filter(function (opt) {
862
+ this.trueValue = this.options().filter(function (opt) {
867
863
  return opt.value === _this.value;
868
864
  }).reduce(function (initial, opt) {
869
865
  return opt.label;
@@ -882,7 +878,7 @@
882
878
  "on": {
883
879
  "input": this.onInput
884
880
  }
885
- }]), [this.options.map(function (opt, index) {
881
+ }]), [this.options().map(function (opt, index) {
886
882
  var props = _objectSpread2({}, opt);
887
883
 
888
884
  delete props.value;
@@ -1907,6 +1903,7 @@
1907
1903
  Object.keys(this.formCreate.prop).forEach(function (k) {
1908
1904
  extend(_this2.$options[k], _this2.formCreate.prop[k]);
1909
1905
  });
1906
+ this.$emit('beforeCreate', this.formCreate.api());
1910
1907
  }
1911
1908
  };
1912
1909
  }
@@ -2319,11 +2316,6 @@
2319
2316
  }
2320
2317
 
2321
2318
  var api = {
2322
- helper: {
2323
- tidyFields: tidyFields,
2324
- props: props
2325
- },
2326
-
2327
2319
  get config() {
2328
2320
  return h.options;
2329
2321
  },
@@ -2467,6 +2459,12 @@
2467
2459
  });
2468
2460
  h.refresh();
2469
2461
  },
2462
+ all: function all(origin) {
2463
+ return Object.keys(h.ctxs).map(function (k) {
2464
+ var ctx = h.ctxs[k];
2465
+ return origin ? ctx.origin : ctx.rule;
2466
+ });
2467
+ },
2470
2468
  model: function model(origin) {
2471
2469
  return h.fields().reduce(function (initial, key) {
2472
2470
  var ctx = h.fieldCtx[key][0];
@@ -2654,13 +2652,26 @@
2654
2652
  nextRefresh: function nextRefresh(fn) {
2655
2653
  h.nextRefresh();
2656
2654
  fn && invoke(fn);
2655
+ },
2656
+ emit: function emit(name) {
2657
+ var _h$vm;
2658
+
2659
+ for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
2660
+ args[_key3 - 1] = arguments[_key3];
2661
+ }
2662
+
2663
+ (_h$vm = h.vm).$emit.apply(_h$vm, [name].concat(args));
2664
+ },
2665
+ helper: {
2666
+ tidyFields: tidyFields,
2667
+ props: props
2657
2668
  }
2658
2669
  };
2659
2670
  ['on', 'once', 'off', 'set'].forEach(function (n) {
2660
2671
  api[n] = function () {
2661
- var _h$vm;
2672
+ var _h$vm2;
2662
2673
 
2663
- (_h$vm = h.vm)["$".concat(n)].apply(_h$vm, arguments);
2674
+ (_h$vm2 = h.vm)["$".concat(n)].apply(_h$vm2, arguments);
2664
2675
  };
2665
2676
  });
2666
2677
  api.changeValue = api.changeField = api.setValue;
@@ -2885,6 +2896,7 @@
2885
2896
  renderCtx: function renderCtx(ctx, parent) {
2886
2897
  if (ctx.type === 'hidden') return;
2887
2898
  var rule = ctx.rule;
2899
+ var preview = this.options.preview || false;
2888
2900
 
2889
2901
  if (!this.cache[ctx.id] || this.cache[ctx.id].slot !== rule.slot) {
2890
2902
  var vn;
@@ -2935,12 +2947,13 @@
2935
2947
  vn = this.vm.$scopedSlots[slot]({
2936
2948
  rule: rule,
2937
2949
  prop: prop,
2950
+ preview: preview,
2938
2951
  children: children,
2939
2952
  api: this.$handle.api,
2940
2953
  model: prop.model || {}
2941
2954
  });
2942
2955
  } else {
2943
- vn = ctx.parser.render(children, ctx);
2956
+ vn = preview ? ctx.parser.preview(children, ctx) : ctx.parser.render(children, ctx);
2944
2957
  }
2945
2958
  }
2946
2959
 
@@ -3005,20 +3018,22 @@
3005
3018
  var _this7 = this;
3006
3019
 
3007
3020
  if (!this.vm.ctxInject[ctx.id]) {
3008
- $set(this.vm.ctxInject, ctx.id, {});
3021
+ $set(this.vm.ctxInject, ctx.id, {
3022
+ api: this.$handle.api,
3023
+ form: this.fc.create,
3024
+ subForm: function subForm(_subForm) {
3025
+ _this7.$handle.addSubForm(ctx, _subForm);
3026
+ },
3027
+ field: ctx.field,
3028
+ rule: ctx.rule
3029
+ });
3009
3030
  }
3010
3031
 
3011
3032
  var inject = this.vm.ctxInject[ctx.id];
3012
3033
  extend(inject, {
3013
- api: this.$handle.api,
3014
- form: this.fc.create,
3015
- subForm: function subForm(_subForm) {
3016
- _this7.$handle.addSubForm(ctx, _subForm);
3017
- },
3018
- field: ctx.field,
3034
+ preview: this.options.preview || false,
3019
3035
  options: ctx.prop.options,
3020
3036
  children: ctx.rule.children,
3021
- rule: ctx.rule,
3022
3037
  prop: function () {
3023
3038
  var temp = _objectSpread2({}, ctx.prop);
3024
3039
 
@@ -3928,6 +3943,7 @@
3928
3943
  this.refresh();
3929
3944
  this.bus.$off('next-tick', this.nextReload);
3930
3945
  this.bus.$once('next-tick', this.nextReload);
3946
+ this.vm.$emit('update', this.api);
3931
3947
  },
3932
3948
  //todo 组件生成全部通过 alias
3933
3949
  refresh: function refresh() {
@@ -3963,7 +3979,7 @@
3963
3979
  function useInput(Handler) {
3964
3980
  extend(Handler.prototype, {
3965
3981
  getValue: function getValue(ctx) {
3966
- if (!hasProperty(ctx, 'cacheValue')) {
3982
+ if (is.Undef(ctx.cacheValue)) {
3967
3983
  ctx.cacheValue = ctx.parser.toValue(this.getFormData(ctx), ctx);
3968
3984
  }
3969
3985
 
@@ -4108,6 +4124,7 @@
4108
4124
  if (this.refreshControl(ctx)) {
4109
4125
  this.$render.clearCacheAll();
4110
4126
  this.loadRule();
4127
+ this.vm.$emit('update', this.api);
4111
4128
  this.refresh();
4112
4129
  }
4113
4130
 
@@ -4153,6 +4170,9 @@
4153
4170
  render: function render(children, ctx) {
4154
4171
  return ctx.$render.defaultRender(ctx, children);
4155
4172
  },
4173
+ preview: function preview(children, ctx) {
4174
+ return ctx.$render.defaultRender(ctx, children);
4175
+ },
4156
4176
  mergeProp: function mergeProp(ctx) {}
4157
4177
  };
4158
4178
 
@@ -4279,6 +4299,8 @@
4279
4299
  }
4280
4300
 
4281
4301
  _flag && _this.loadChildren(n, ctx);
4302
+
4303
+ _this.vm.$emit('update', _this.api);
4282
4304
  });
4283
4305
  }
4284
4306
 
@@ -5114,6 +5136,7 @@
5114
5136
  },
5115
5137
  created: function created() {
5116
5138
  this.$handle.init();
5139
+ this.vm.$emit('created', this.api());
5117
5140
  },
5118
5141
  api: function api() {
5119
5142
  return this.$handle.api;
@@ -5578,34 +5601,12 @@
5578
5601
  return !(!title.title && !title["native"] || isFalse(title.show));
5579
5602
  },
5580
5603
  makeInfo: function makeInfo(rule, uni) {
5581
- var _this = this;
5582
5604
 
5583
5605
  var titleProp = rule.title;
5584
5606
  var infoProp = rule.info;
5585
5607
  var children = [titleProp.title];
5586
5608
 
5587
- var titleFn = function titleFn(pop) {
5588
- return _this.$r(mergeProps([titleProp, {
5589
- props: titleProp,
5590
- slot: titleProp.slot || (pop ? 'default' : 'label'),
5591
- key: "".concat(uni, "tit"),
5592
- type: titleProp.type || 'span'
5593
- }]), children);
5594
- };
5595
-
5596
- if (!isFalse(infoProp.show) && (infoProp.info || infoProp["native"])) {
5597
- if (infoProp.icon !== false) {
5598
- children[infoProp.align !== 'left' ? 'unshift' : 'push'](this.$r({
5599
- type: 'icon',
5600
- props: {
5601
- type: infoProp.icon === true ? iviewConfig.infoIcon : infoProp.icon,
5602
- size: 16
5603
- },
5604
- style: 'margin-top: -1px',
5605
- key: "".concat(uni, "i")
5606
- }));
5607
- }
5608
-
5609
+ if (!isFalse(infoProp.show) && (infoProp.info || infoProp["native"]) && !isFalse(infoProp.icon)) {
5609
5610
  var prop = {
5610
5611
  type: infoProp.type || 'poptip',
5611
5612
  props: _objectSpread2({}, infoProp),
@@ -5618,10 +5619,23 @@
5618
5619
  prop.props[field] = infoProp.info;
5619
5620
  }
5620
5621
 
5621
- return this.$r(mergeProps([infoProp, prop]), [titleFn(true)]);
5622
+ children[infoProp.align !== 'left' ? 'unshift' : 'push'](this.$r(mergeProps([infoProp, prop]), [this.$r({
5623
+ type: 'icon',
5624
+ props: {
5625
+ type: infoProp.icon === true ? iviewConfig.infoIcon : infoProp.icon,
5626
+ size: 16
5627
+ },
5628
+ style: 'margin-top: -1px',
5629
+ key: "".concat(uni, "i")
5630
+ })]));
5622
5631
  }
5623
5632
 
5624
- return titleFn();
5633
+ return this.$r(mergeProps([titleProp, {
5634
+ props: titleProp,
5635
+ slot: titleProp.slot || 'label',
5636
+ key: "".concat(uni, "tit"),
5637
+ type: titleProp.type || 'span'
5638
+ }]), children);
5625
5639
  },
5626
5640
  makeCol: function makeCol(rule, uni, children) {
5627
5641
  var col = rule.col;
@@ -6051,7 +6065,7 @@
6051
6065
  function ivuFormCreate() {
6052
6066
  return FormCreateFactory({
6053
6067
  ui: "".concat("iview"),
6054
- version: "".concat("2.5.12"),
6068
+ version: "".concat("2.5.13"),
6055
6069
  manager: manager,
6056
6070
  install: install,
6057
6071
  extendApi: extendApi,