@form-create/view-design 2.5.13 → 2.5.17

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.13
3
- * (c) 2018-2021 xaboy
2
+ * @form-create/view-design v2.5.17
3
+ * (c) 2018-2022 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
6
6
  */
@@ -267,6 +267,12 @@
267
267
  }
268
268
  },
269
269
  watch: {
270
+ 'formCreateInject.options': {
271
+ handler: function handler() {
272
+ this.update();
273
+ },
274
+ deep: true
275
+ },
270
276
  value: function value() {
271
277
  this.update();
272
278
  }
@@ -835,6 +841,12 @@
835
841
  value: {}
836
842
  },
837
843
  watch: {
844
+ 'formCreateInject.options': {
845
+ handler: function handler() {
846
+ this.update();
847
+ },
848
+ deep: true
849
+ },
838
850
  value: function value() {
839
851
  this.update();
840
852
  }
@@ -1064,7 +1076,8 @@
1064
1076
  return {
1065
1077
  uploadList: [],
1066
1078
  previewVisible: false,
1067
- previewImage: ''
1079
+ previewImage: '',
1080
+ cacheFiles: []
1068
1081
  };
1069
1082
  },
1070
1083
  created: function created() {
@@ -1211,7 +1224,11 @@
1211
1224
  }).filter(function (url) {
1212
1225
  return url !== undefined;
1213
1226
  });
1214
- this.$emit('input', this.maxLength === 1 ? files[0] || '' : files);
1227
+
1228
+ if (this.cacheFiles.length !== files.length) {
1229
+ this.cacheFiles = _toConsumableArray(files);
1230
+ this.$emit('input', this.maxLength === 1 ? files[0] || '' : files);
1231
+ }
1215
1232
  },
1216
1233
  handleCancel: function handleCancel() {
1217
1234
  this.previewVisible = false;
@@ -1984,6 +2001,20 @@
1984
2001
  return [].concat(keyAttrs, _toConsumableArray(normalMerge$1), _toConsumableArray(toArrayMerge$1), _toConsumableArray(functionalMerge$1), arrayAttrs, normalAttrs);
1985
2002
  }
1986
2003
 
2004
+ function format(type, msg, rule) {
2005
+ return "[form-create ".concat(type, "]: ").concat(msg) + (rule ? '\n\nrule: ' + JSON.stringify(rule.getRule ? rule.getRule() : rule) : '');
2006
+ }
2007
+ function tip(msg, rule) {
2008
+ console.warn(format('tip', msg, rule));
2009
+ }
2010
+ function err(msg, rule) {
2011
+ console.error(format('err', msg, rule));
2012
+ }
2013
+ function logError(e) {
2014
+ err(e.toString());
2015
+ console.error(e);
2016
+ }
2017
+
1987
2018
  function deepExtend(origin) {
1988
2019
  var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
1989
2020
  var mode = arguments.length > 2 ? arguments[2] : undefined;
@@ -2012,14 +2043,18 @@
2012
2043
  }
2013
2044
 
2014
2045
  origin[key] = deepExtend(origin[key], clone, mode);
2015
- } else if (is.Undef(clone)) {
2016
- $set(origin, key, clone);
2017
- } else if (clone.__json !== undefined) {
2018
- $set(origin, key, clone.__json);
2019
- } else if (clone.__origin !== undefined) {
2020
- $set(origin, key, clone.__origin);
2021
2046
  } else {
2022
2047
  $set(origin, key, clone);
2048
+
2049
+ if (!is.Undef(clone)) {
2050
+ if (!is.Undef(clone.__json)) {
2051
+ origin[key].__json = clone.__json;
2052
+ }
2053
+
2054
+ if (!is.Undef(clone.__origin)) {
2055
+ origin[key].__origin = clone.__origin;
2056
+ }
2057
+ }
2023
2058
  }
2024
2059
  }
2025
2060
  }
@@ -2034,20 +2069,6 @@
2034
2069
  }).value;
2035
2070
  }
2036
2071
 
2037
- function format(type, msg, rule) {
2038
- return "[form-create ".concat(type, "]: ").concat(msg) + (rule ? '\n\nrule: ' + JSON.stringify(rule.getRule ? rule.getRule() : rule) : '');
2039
- }
2040
- function tip(msg, rule) {
2041
- console.warn(format('tip', msg, rule));
2042
- }
2043
- function err(msg, rule) {
2044
- console.error(format('err', msg, rule));
2045
- }
2046
- function logError(e) {
2047
- err(e.toString());
2048
- console.error(e);
2049
- }
2050
-
2051
2072
  var PREFIX = '[[FORM-CREATE-PREFIX-';
2052
2073
  var SUFFIX = '-FORM-CREATE-SUFFIX]]';
2053
2074
  var $T = '$FN:';
@@ -2061,7 +2082,7 @@
2061
2082
  return val;
2062
2083
  }
2063
2084
 
2064
- if (hasProperty(val, '__json')) {
2085
+ if (val.__json) {
2065
2086
  return val.__json;
2066
2087
  }
2067
2088
 
@@ -2124,8 +2145,8 @@
2124
2145
  };
2125
2146
  } //todo 优化位置
2126
2147
 
2127
- function copyRule(rule, mode) {
2128
- return copyRules([rule], mode || false)[0];
2148
+ function copyRule(rule) {
2149
+ return copyRules([rule])[0];
2129
2150
  }
2130
2151
  function copyRules(rules, mode) {
2131
2152
  return deepExtend([], _toConsumableArray(rules), mode || false);
@@ -2172,39 +2193,6 @@
2172
2193
  return def;
2173
2194
  }
2174
2195
 
2175
- function toString$1(val) {
2176
- return val == null ? '' : _typeof(val) === 'object' ? JSON.stringify(val, null, 2) : String(val);
2177
- }
2178
-
2179
- function toLine(name) {
2180
- var line = name.replace(/([A-Z])/g, '-$1').toLocaleLowerCase();
2181
- if (line.indexOf('-') === 0) line = line.substr(1);
2182
- return line;
2183
- }
2184
-
2185
- var id = 0;
2186
- function uniqueId() {
2187
- return Math.random().toString(36).substr(3, 3) + Number("".concat(Date.now()).concat(++id)).toString(36);
2188
- }
2189
-
2190
- function deepSet(data, idx, val) {
2191
- var _data = data,
2192
- to;
2193
- (idx || '').split('.').forEach(function (v) {
2194
- if (to) {
2195
- if (!_data[to] || _typeof(_data[to]) != 'object') {
2196
- _data[to] = {};
2197
- }
2198
-
2199
- _data = _data[to];
2200
- }
2201
-
2202
- to = v;
2203
- });
2204
- _data[to] = val;
2205
- return _data;
2206
- }
2207
-
2208
2196
  function baseRule() {
2209
2197
  return {
2210
2198
  props: {},
@@ -2726,6 +2714,39 @@
2726
2714
  return str.replace(str[0], str[0].toLowerCase());
2727
2715
  }
2728
2716
 
2717
+ function toString$1(val) {
2718
+ return val == null ? '' : _typeof(val) === 'object' ? JSON.stringify(val, null, 2) : String(val);
2719
+ }
2720
+
2721
+ function toLine(name) {
2722
+ var line = name.replace(/([A-Z])/g, '-$1').toLocaleLowerCase();
2723
+ if (line.indexOf('-') === 0) line = line.substr(1);
2724
+ return line;
2725
+ }
2726
+
2727
+ var id = 0;
2728
+ function uniqueId() {
2729
+ return Math.random().toString(36).substr(3, 3) + Number("".concat(Date.now()).concat(++id)).toString(36);
2730
+ }
2731
+
2732
+ function deepSet(data, idx, val) {
2733
+ var _data = data,
2734
+ to;
2735
+ (idx || '').split('.').forEach(function (v) {
2736
+ if (to) {
2737
+ if (!_data[to] || _typeof(_data[to]) != 'object') {
2738
+ _data[to] = {};
2739
+ }
2740
+
2741
+ _data = _data[to];
2742
+ }
2743
+
2744
+ to = v;
2745
+ });
2746
+ _data[to] = val;
2747
+ return _data;
2748
+ }
2749
+
2729
2750
  function useRender(Render) {
2730
2751
  extend(Render.prototype, {
2731
2752
  initRender: function initRender() {
@@ -2746,6 +2767,23 @@
2746
2767
  clearOrgChildren: function clearOrgChildren() {
2747
2768
  this.orgChildren = {};
2748
2769
  },
2770
+ getTypeSlot: function getTypeSlot(type) {
2771
+ var name = 'type-' + toLine(type);
2772
+
2773
+ var _fn = function _fn(vm) {
2774
+ if (vm) {
2775
+ var slot = vm.$scopedSlots[name] || vm.$scopedSlots['type-' + type];
2776
+
2777
+ if (slot) {
2778
+ return slot;
2779
+ }
2780
+
2781
+ return _fn(vm.$pfc);
2782
+ }
2783
+ };
2784
+
2785
+ return _fn(this.vm);
2786
+ },
2749
2787
  render: function render() {
2750
2788
  var _this = this;
2751
2789
 
@@ -2941,10 +2979,10 @@
2941
2979
  children = this.renderChildren(ctx);
2942
2980
  }
2943
2981
 
2944
- var slot = 'type-' + toLine(ctx.type);
2982
+ var slot = this.getTypeSlot(ctx.type);
2945
2983
 
2946
- if (this.vm.$scopedSlots[slot]) {
2947
- vn = this.vm.$scopedSlots[slot]({
2984
+ if (slot) {
2985
+ vn = slot({
2948
2986
  rule: rule,
2949
2987
  prop: prop,
2950
2988
  preview: preview,
@@ -3024,6 +3062,10 @@
3024
3062
  subForm: function subForm(_subForm) {
3025
3063
  _this7.$handle.addSubForm(ctx, _subForm);
3026
3064
  },
3065
+ options: [],
3066
+ children: [],
3067
+ prop: {},
3068
+ preview: false,
3027
3069
  field: ctx.field,
3028
3070
  rule: ctx.rule
3029
3071
  });
@@ -4100,7 +4142,7 @@
4100
4142
  this.vm._updateValue(_objectSpread2({}, this.form));
4101
4143
  },
4102
4144
  isChange: function isChange(ctx, value) {
4103
- return JSON.stringify(ctx.rule.value) !== JSON.stringify(value);
4145
+ return JSON.stringify(ctx.rule.value, strFn) !== JSON.stringify(value, strFn);
4104
4146
  },
4105
4147
  isQuote: function isQuote(ctx, value) {
4106
4148
  return (is.Object(value) || Array.isArray(value)) && value === ctx.rule.value;
@@ -4152,6 +4194,10 @@
4152
4194
  });
4153
4195
  }
4154
4196
 
4197
+ function strFn(key, val) {
4198
+ return typeof val === 'function' ? '' + val : val;
4199
+ }
4200
+
4155
4201
  function toEmpty(obj) {
4156
4202
  Object.keys(obj).forEach(function (k) {
4157
4203
  return delete obj[k];
@@ -4255,7 +4301,7 @@
4255
4301
  var vm = this.vm;
4256
4302
  var none = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update'];
4257
4303
  Object.keys(ctx.rule).filter(function (k) {
4258
- return none.indexOf(k) === -1;
4304
+ return k[0] !== '_' && none.indexOf(k) === -1;
4259
4305
  }).forEach(function (key) {
4260
4306
  var flag = key === 'children';
4261
4307
  ctx.watch.push(vm.$watch(function () {
@@ -4836,6 +4882,11 @@
4836
4882
 
4837
4883
  function run(inject, rule, api) {
4838
4884
  var option = inject.value;
4885
+
4886
+ if (is.Function(option)) {
4887
+ option = option(rule, api);
4888
+ }
4889
+
4839
4890
  option = parseOpt(option);
4840
4891
 
4841
4892
  if (!option || !option.action) {
@@ -5167,6 +5218,7 @@
5167
5218
  copyRules: copyRules,
5168
5219
  fetch: fetch,
5169
5220
  $form: $form,
5221
+ parseFn: parseFn,
5170
5222
  parseJson: parseJson,
5171
5223
  toJson: toJson,
5172
5224
  init: function init(rules) {
@@ -6065,7 +6117,7 @@
6065
6117
  function ivuFormCreate() {
6066
6118
  return FormCreateFactory({
6067
6119
  ui: "".concat("view-design"),
6068
- version: "".concat("2.5.13"),
6120
+ version: "".concat("2.5.17"),
6069
6121
  manager: manager,
6070
6122
  install: install,
6071
6123
  extendApi: extendApi,