@form-create/element-ui 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/element-ui v2.5.13
3
- * (c) 2018-2021 xaboy
2
+ * @form-create/element-ui 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
  */
@@ -268,6 +268,12 @@
268
268
  type: String
269
269
  },
270
270
  watch: {
271
+ 'formCreateInject.options': {
272
+ handler: function handler() {
273
+ this.update();
274
+ },
275
+ deep: true
276
+ },
271
277
  value: function value() {
272
278
  this.update();
273
279
  }
@@ -859,6 +865,12 @@
859
865
  type: String
860
866
  },
861
867
  watch: {
868
+ 'formCreateInject.options': {
869
+ handler: function handler() {
870
+ this.update();
871
+ },
872
+ deep: true
873
+ },
862
874
  value: function value() {
863
875
  this.update();
864
876
  }
@@ -1101,7 +1113,8 @@
1101
1113
  return {
1102
1114
  uploadList: [],
1103
1115
  previewVisible: false,
1104
- previewImage: ''
1116
+ previewImage: '',
1117
+ cacheFiles: []
1105
1118
  };
1106
1119
  },
1107
1120
  created: function created() {
@@ -1252,7 +1265,11 @@
1252
1265
  }).filter(function (url) {
1253
1266
  return url !== undefined;
1254
1267
  });
1255
- this.$emit('input', this.limit === 1 ? files[0] || '' : files);
1268
+
1269
+ if (this.cacheFiles.length !== files.length) {
1270
+ this.cacheFiles = _toConsumableArray(files);
1271
+ this.$emit('input', this.limit === 1 ? files[0] || '' : files);
1272
+ }
1256
1273
  },
1257
1274
  handleCancel: function handleCancel() {
1258
1275
  this.previewVisible = false;
@@ -1998,6 +2015,20 @@
1998
2015
  return [].concat(keyAttrs, _toConsumableArray(normalMerge$1), _toConsumableArray(toArrayMerge$1), _toConsumableArray(functionalMerge$1), arrayAttrs, normalAttrs);
1999
2016
  }
2000
2017
 
2018
+ function format(type, msg, rule) {
2019
+ return "[form-create ".concat(type, "]: ").concat(msg) + (rule ? '\n\nrule: ' + JSON.stringify(rule.getRule ? rule.getRule() : rule) : '');
2020
+ }
2021
+ function tip(msg, rule) {
2022
+ console.warn(format('tip', msg, rule));
2023
+ }
2024
+ function err(msg, rule) {
2025
+ console.error(format('err', msg, rule));
2026
+ }
2027
+ function logError(e) {
2028
+ err(e.toString());
2029
+ console.error(e);
2030
+ }
2031
+
2001
2032
  function deepExtend(origin) {
2002
2033
  var target = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
2003
2034
  var mode = arguments.length > 2 ? arguments[2] : undefined;
@@ -2026,14 +2057,18 @@
2026
2057
  }
2027
2058
 
2028
2059
  origin[key] = deepExtend(origin[key], clone, mode);
2029
- } else if (is.Undef(clone)) {
2030
- $set(origin, key, clone);
2031
- } else if (clone.__json !== undefined) {
2032
- $set(origin, key, clone.__json);
2033
- } else if (clone.__origin !== undefined) {
2034
- $set(origin, key, clone.__origin);
2035
2060
  } else {
2036
2061
  $set(origin, key, clone);
2062
+
2063
+ if (!is.Undef(clone)) {
2064
+ if (!is.Undef(clone.__json)) {
2065
+ origin[key].__json = clone.__json;
2066
+ }
2067
+
2068
+ if (!is.Undef(clone.__origin)) {
2069
+ origin[key].__origin = clone.__origin;
2070
+ }
2071
+ }
2037
2072
  }
2038
2073
  }
2039
2074
  }
@@ -2048,20 +2083,6 @@
2048
2083
  }).value;
2049
2084
  }
2050
2085
 
2051
- function format(type, msg, rule) {
2052
- return "[form-create ".concat(type, "]: ").concat(msg) + (rule ? '\n\nrule: ' + JSON.stringify(rule.getRule ? rule.getRule() : rule) : '');
2053
- }
2054
- function tip(msg, rule) {
2055
- console.warn(format('tip', msg, rule));
2056
- }
2057
- function err(msg, rule) {
2058
- console.error(format('err', msg, rule));
2059
- }
2060
- function logError(e) {
2061
- err(e.toString());
2062
- console.error(e);
2063
- }
2064
-
2065
2086
  var PREFIX = '[[FORM-CREATE-PREFIX-';
2066
2087
  var SUFFIX = '-FORM-CREATE-SUFFIX]]';
2067
2088
  var $T = '$FN:';
@@ -2075,7 +2096,7 @@
2075
2096
  return val;
2076
2097
  }
2077
2098
 
2078
- if (hasProperty(val, '__json')) {
2099
+ if (val.__json) {
2079
2100
  return val.__json;
2080
2101
  }
2081
2102
 
@@ -2138,8 +2159,8 @@
2138
2159
  };
2139
2160
  } //todo 优化位置
2140
2161
 
2141
- function copyRule(rule, mode) {
2142
- return copyRules([rule], mode || false)[0];
2162
+ function copyRule(rule) {
2163
+ return copyRules([rule])[0];
2143
2164
  }
2144
2165
  function copyRules(rules, mode) {
2145
2166
  return deepExtend([], _toConsumableArray(rules), mode || false);
@@ -2186,39 +2207,6 @@
2186
2207
  return def;
2187
2208
  }
2188
2209
 
2189
- function toString(val) {
2190
- return val == null ? '' : _typeof(val) === 'object' ? JSON.stringify(val, null, 2) : String(val);
2191
- }
2192
-
2193
- function toLine(name) {
2194
- var line = name.replace(/([A-Z])/g, '-$1').toLocaleLowerCase();
2195
- if (line.indexOf('-') === 0) line = line.substr(1);
2196
- return line;
2197
- }
2198
-
2199
- var id = 0;
2200
- function uniqueId() {
2201
- return Math.random().toString(36).substr(3, 3) + Number("".concat(Date.now()).concat(++id)).toString(36);
2202
- }
2203
-
2204
- function deepSet(data, idx, val) {
2205
- var _data = data,
2206
- to;
2207
- (idx || '').split('.').forEach(function (v) {
2208
- if (to) {
2209
- if (!_data[to] || _typeof(_data[to]) != 'object') {
2210
- _data[to] = {};
2211
- }
2212
-
2213
- _data = _data[to];
2214
- }
2215
-
2216
- to = v;
2217
- });
2218
- _data[to] = val;
2219
- return _data;
2220
- }
2221
-
2222
2210
  function baseRule() {
2223
2211
  return {
2224
2212
  props: {},
@@ -2740,6 +2728,39 @@
2740
2728
  return str.replace(str[0], str[0].toLowerCase());
2741
2729
  }
2742
2730
 
2731
+ function toString(val) {
2732
+ return val == null ? '' : _typeof(val) === 'object' ? JSON.stringify(val, null, 2) : String(val);
2733
+ }
2734
+
2735
+ function toLine(name) {
2736
+ var line = name.replace(/([A-Z])/g, '-$1').toLocaleLowerCase();
2737
+ if (line.indexOf('-') === 0) line = line.substr(1);
2738
+ return line;
2739
+ }
2740
+
2741
+ var id = 0;
2742
+ function uniqueId() {
2743
+ return Math.random().toString(36).substr(3, 3) + Number("".concat(Date.now()).concat(++id)).toString(36);
2744
+ }
2745
+
2746
+ function deepSet(data, idx, val) {
2747
+ var _data = data,
2748
+ to;
2749
+ (idx || '').split('.').forEach(function (v) {
2750
+ if (to) {
2751
+ if (!_data[to] || _typeof(_data[to]) != 'object') {
2752
+ _data[to] = {};
2753
+ }
2754
+
2755
+ _data = _data[to];
2756
+ }
2757
+
2758
+ to = v;
2759
+ });
2760
+ _data[to] = val;
2761
+ return _data;
2762
+ }
2763
+
2743
2764
  function useRender(Render) {
2744
2765
  extend(Render.prototype, {
2745
2766
  initRender: function initRender() {
@@ -2760,6 +2781,23 @@
2760
2781
  clearOrgChildren: function clearOrgChildren() {
2761
2782
  this.orgChildren = {};
2762
2783
  },
2784
+ getTypeSlot: function getTypeSlot(type) {
2785
+ var name = 'type-' + toLine(type);
2786
+
2787
+ var _fn = function _fn(vm) {
2788
+ if (vm) {
2789
+ var slot = vm.$scopedSlots[name] || vm.$scopedSlots['type-' + type];
2790
+
2791
+ if (slot) {
2792
+ return slot;
2793
+ }
2794
+
2795
+ return _fn(vm.$pfc);
2796
+ }
2797
+ };
2798
+
2799
+ return _fn(this.vm);
2800
+ },
2763
2801
  render: function render() {
2764
2802
  var _this = this;
2765
2803
 
@@ -2955,10 +2993,10 @@
2955
2993
  children = this.renderChildren(ctx);
2956
2994
  }
2957
2995
 
2958
- var slot = 'type-' + toLine(ctx.type);
2996
+ var slot = this.getTypeSlot(ctx.type);
2959
2997
 
2960
- if (this.vm.$scopedSlots[slot]) {
2961
- vn = this.vm.$scopedSlots[slot]({
2998
+ if (slot) {
2999
+ vn = slot({
2962
3000
  rule: rule,
2963
3001
  prop: prop,
2964
3002
  preview: preview,
@@ -3038,6 +3076,10 @@
3038
3076
  subForm: function subForm(_subForm) {
3039
3077
  _this7.$handle.addSubForm(ctx, _subForm);
3040
3078
  },
3079
+ options: [],
3080
+ children: [],
3081
+ prop: {},
3082
+ preview: false,
3041
3083
  field: ctx.field,
3042
3084
  rule: ctx.rule
3043
3085
  });
@@ -4114,7 +4156,7 @@
4114
4156
  this.vm._updateValue(_objectSpread2({}, this.form));
4115
4157
  },
4116
4158
  isChange: function isChange(ctx, value) {
4117
- return JSON.stringify(ctx.rule.value) !== JSON.stringify(value);
4159
+ return JSON.stringify(ctx.rule.value, strFn) !== JSON.stringify(value, strFn);
4118
4160
  },
4119
4161
  isQuote: function isQuote(ctx, value) {
4120
4162
  return (is.Object(value) || Array.isArray(value)) && value === ctx.rule.value;
@@ -4166,6 +4208,10 @@
4166
4208
  });
4167
4209
  }
4168
4210
 
4211
+ function strFn(key, val) {
4212
+ return typeof val === 'function' ? '' + val : val;
4213
+ }
4214
+
4169
4215
  function toEmpty(obj) {
4170
4216
  Object.keys(obj).forEach(function (k) {
4171
4217
  return delete obj[k];
@@ -4269,7 +4315,7 @@
4269
4315
  var vm = this.vm;
4270
4316
  var none = ['field', 'value', 'vm', 'template', 'name', 'config', 'control', 'inject', 'sync', 'payload', 'optionsTo', 'update'];
4271
4317
  Object.keys(ctx.rule).filter(function (k) {
4272
- return none.indexOf(k) === -1;
4318
+ return k[0] !== '_' && none.indexOf(k) === -1;
4273
4319
  }).forEach(function (key) {
4274
4320
  var flag = key === 'children';
4275
4321
  ctx.watch.push(vm.$watch(function () {
@@ -4850,6 +4896,11 @@
4850
4896
 
4851
4897
  function run(inject, rule, api) {
4852
4898
  var option = inject.value;
4899
+
4900
+ if (is.Function(option)) {
4901
+ option = option(rule, api);
4902
+ }
4903
+
4853
4904
  option = parseOpt(option);
4854
4905
 
4855
4906
  if (!option || !option.action) {
@@ -5181,6 +5232,7 @@
5181
5232
  copyRules: copyRules,
5182
5233
  fetch: fetch,
5183
5234
  $form: $form,
5235
+ parseFn: parseFn,
5184
5236
  parseJson: parseJson,
5185
5237
  toJson: toJson,
5186
5238
  init: function init(rules) {
@@ -6037,7 +6089,7 @@
6037
6089
  function elmFormCreate() {
6038
6090
  return FormCreateFactory({
6039
6091
  ui: "".concat("element-ui"),
6040
- version: "".concat("2.5.13"),
6092
+ version: "".concat("2.5.17"),
6041
6093
  manager: manager,
6042
6094
  extendApi: extendApi,
6043
6095
  install: install,