@form-create/element-ui 3.2.6 → 3.2.8

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,10 +1,10 @@
1
1
  /*!
2
- * @form-create/element-ui v3.2.6
2
+ * @form-create/element-ui v3.2.8
3
3
  * (c) 2018-2024 xaboy
4
4
  * Github https://github.com/xaboy/form-create
5
5
  * Released under the MIT License.
6
6
  */
7
- import { defineComponent, toRef, ref, watch, createVNode, resolveComponent, mergeProps as mergeProps$1, openBlock, createElementBlock, createElementVNode, isVNode, nextTick, createTextVNode, markRaw, reactive, getCurrentInstance, provide, inject, toRefs, onBeforeMount, onMounted, onBeforeUnmount, onUpdated, computed, withDirectives, resolveDirective, createApp, h } from 'vue';
7
+ import { defineComponent, toRef, ref, watch, createVNode, resolveComponent, mergeProps as mergeProps$1, openBlock, createElementBlock, createElementVNode, isVNode, nextTick, createTextVNode, markRaw, reactive, getCurrentInstance, provide, inject, toRefs, onBeforeMount, watchEffect, onMounted, onBeforeUnmount, onUpdated, computed, withDirectives, resolveDirective, createApp, h } from 'vue';
8
8
 
9
9
  function ownKeys(object, enumerableOnly) {
10
10
  var keys = Object.keys(object);
@@ -277,11 +277,12 @@ var Checkbox = defineComponent({
277
277
  }
278
278
 
279
279
  return createVNode(Type, {
280
- "value": customValue.value,
281
- "label": customValue.value
280
+ "value": customValue.value || undefined,
281
+ "label": customValue.value || undefined
282
282
  }, {
283
283
  "default": function _default() {
284
284
  return [createVNode(resolveComponent("ElInput"), {
285
+ "size": "small",
285
286
  "modelValue": customValue.value,
286
287
  "onUpdate:modelValue": updateCustomValue
287
288
  }, null)];
@@ -1064,11 +1065,13 @@ var Radio = defineComponent({
1064
1065
  }
1065
1066
 
1066
1067
  return createVNode(Type, {
1067
- "value": customValue.value,
1068
- "label": customValue.value
1068
+ "checked": false,
1069
+ "value": customValue.value || undefined,
1070
+ "label": customValue.value || undefined
1069
1071
  }, {
1070
1072
  "default": function _default() {
1071
1073
  return [createVNode(resolveComponent("ElInput"), {
1074
+ "size": "small",
1072
1075
  "modelValue": customValue.value,
1073
1076
  "onUpdate:modelValue": updateCustomValue
1074
1077
  }, null)];
@@ -1345,6 +1348,7 @@ var Upload = defineComponent({
1345
1348
  previewMask: undefined,
1346
1349
  onPreview: Function,
1347
1350
  modalTitle: String,
1351
+ listType: String,
1348
1352
  modelValue: [Array, String]
1349
1353
  },
1350
1354
  emits: ['update:modelValue', 'change', 'remove', 'fc.el'],
@@ -1368,7 +1372,7 @@ var Upload = defineComponent({
1368
1372
  if (this.onPreview) {
1369
1373
  this.onPreview.apply(this, arguments);
1370
1374
  } else {
1371
- if ('text' === this.$attrs.listType) {
1375
+ if ('text' === this.listType) {
1372
1376
  window.open(file.url);
1373
1377
  } else {
1374
1378
  this.previewImage = file.url;
@@ -1408,9 +1412,9 @@ var Upload = defineComponent({
1408
1412
  return createVNode("div", {
1409
1413
  "class": "_fc-upload"
1410
1414
  }, [createVNode(resolveComponent("ElUpload"), mergeProps$1({
1411
- "key": len,
1412
- "list-type": "picture-card"
1415
+ "key": len
1413
1416
  }, this.$attrs, {
1417
+ "list-type": this.listType || 'picture-card',
1414
1418
  "class": {
1415
1419
  '_fc-exceed': this.$attrs.limit ? this.$attrs.limit <= len : false
1416
1420
  },
@@ -1421,7 +1425,7 @@ var Upload = defineComponent({
1421
1425
  "ref": "upload"
1422
1426
  }), _objectSpread2({
1423
1427
  "default": function _default() {
1424
- return [(_this$$slots$default = (_this$$slots = _this.$slots)["default"]) !== null && _this$$slots$default !== void 0 && _this$$slots$default.call(_this$$slots) || ['text', 'picture'].indexOf(_this.$attrs.listType) === -1 ? createVNode(resolveComponent("ElIcon"), null, {
1428
+ return [(_this$$slots$default = (_this$$slots = _this.$slots)["default"]) !== null && _this$$slots$default !== void 0 && _this$$slots$default.call(_this$$slots) || ['text', 'picture'].indexOf(_this.listType) === -1 ? createVNode(resolveComponent("ElIcon"), null, {
1425
1429
  "default": function _default() {
1426
1430
  return [createVNode(script$1, null, null)];
1427
1431
  }
@@ -1820,13 +1824,18 @@ var Group = defineComponent({
1820
1824
  }, null);
1821
1825
  },
1822
1826
  changeSort: function changeSort(index, sort) {
1827
+ var _this10 = this;
1828
+
1823
1829
  var a = this.sort[index];
1824
1830
  this.sort[index] = this.sort[index + sort];
1825
1831
  this.sort[index + sort] = a;
1832
+ this.formCreateInject.subForm(this.sort.map(function (k) {
1833
+ return _this10.cacheRule[k].$f;
1834
+ }));
1826
1835
  this.formData(0);
1827
1836
  },
1828
1837
  makeIcon: function makeIcon(total, index, key) {
1829
- var _this10 = this;
1838
+ var _this11 = this;
1830
1839
 
1831
1840
  if (this.$slots.button) {
1832
1841
  return this.$slots.button({
@@ -1835,7 +1844,7 @@ var Group = defineComponent({
1835
1844
  vm: this,
1836
1845
  key: key,
1837
1846
  del: function del() {
1838
- return _this10.del(index, key);
1847
+ return _this11.del(index, key);
1839
1848
  },
1840
1849
  add: this.add
1841
1850
  });
@@ -1871,12 +1880,12 @@ var Group = defineComponent({
1871
1880
  }
1872
1881
  },
1873
1882
  created: function created() {
1874
- var _this11 = this;
1883
+ var _this12 = this;
1875
1884
 
1876
1885
  watch(function () {
1877
- return _objectSpread2({}, _this11.cacheRule);
1886
+ return _objectSpread2({}, _this12.cacheRule);
1878
1887
  }, function (n) {
1879
- _this11.sort = Object.keys(n);
1888
+ _this12.sort = Object.keys(n);
1880
1889
  }, {
1881
1890
  immediate: true
1882
1891
  });
@@ -1891,7 +1900,7 @@ var Group = defineComponent({
1891
1900
  }
1892
1901
  },
1893
1902
  render: function render() {
1894
- var _this12 = this;
1903
+ var _this13 = this;
1895
1904
 
1896
1905
  var keys = this.sort;
1897
1906
  var button = this.button;
@@ -1905,10 +1914,10 @@ var Group = defineComponent({
1905
1914
  "class": "_fc-group-plus-minus _fc-group-add fc-clock",
1906
1915
  "onClick": this.add
1907
1916
  }, null) : keys.map(function (key, index) {
1908
- var _this12$cacheRule$key = _this12.cacheRule[key],
1909
- rule = _this12$cacheRule$key.rule,
1910
- options = _this12$cacheRule$key.options;
1911
- var btn = button && !disabled ? _this12.makeIcon(keys.length, index, key) : [];
1917
+ var _this13$cacheRule$key = _this13.cacheRule[key],
1918
+ rule = _this13$cacheRule$key.rule,
1919
+ options = _this13$cacheRule$key.options;
1920
+ var btn = button && !disabled ? _this13.makeIcon(keys.length, index, key) : [];
1912
1921
  return createVNode("div", {
1913
1922
  "class": "_fc-group-container",
1914
1923
  "key": key
@@ -1917,20 +1926,20 @@ var Group = defineComponent({
1917
1926
  }, {
1918
1927
  disabled: disabled,
1919
1928
  'onUpdate:modelValue': function onUpdateModelValue(formData) {
1920
- return _this12.formData(key, formData);
1929
+ return _this13.formData(key, formData);
1921
1930
  },
1922
1931
  'onEmit-event': function onEmitEvent(name) {
1923
1932
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1924
1933
  args[_key - 1] = arguments[_key];
1925
1934
  }
1926
1935
 
1927
- return _this12.emitEvent(name, args, index, key);
1936
+ return _this13.emitEvent(name, args, index, key);
1928
1937
  },
1929
1938
  'onUpdate:api': function onUpdateApi($f) {
1930
- return _this12.add$f(index, key, $f);
1939
+ return _this13.add$f(index, key, $f);
1931
1940
  },
1932
1941
  inFor: true,
1933
- modelValue: _this12.field ? _defineProperty({}, _this12.field, _this12._value(_this12.modelValue[index])) : _this12.modelValue[index],
1942
+ modelValue: _this13.field ? _defineProperty({}, _this13.field, _this13._value(_this13.modelValue[index])) : _this13.modelValue[index],
1934
1943
  rule: rule,
1935
1944
  option: options,
1936
1945
  extendOption: true
@@ -2079,7 +2088,7 @@ function upper(str) {
2079
2088
  return str.replace(str[0], str[0].toLocaleUpperCase());
2080
2089
  }
2081
2090
 
2082
- var getRuleInject = function getRuleInject(vm, parent) {
2091
+ var _getGroupInject = function getGroupInject(vm, parent) {
2083
2092
  if (!vm || vm === parent) {
2084
2093
  return;
2085
2094
  }
@@ -2089,7 +2098,7 @@ var getRuleInject = function getRuleInject(vm, parent) {
2089
2098
  }
2090
2099
 
2091
2100
  if (vm.parent) {
2092
- return getRuleInject(vm.parent, parent);
2101
+ return _getGroupInject(vm.parent, parent);
2093
2102
  }
2094
2103
  };
2095
2104
 
@@ -2113,7 +2122,7 @@ function $FormCreate(FormCreate, components, directives) {
2113
2122
  }
2114
2123
  },
2115
2124
  extendOption: Boolean,
2116
- driver: String,
2125
+ driver: [String, Object],
2117
2126
  modelValue: Object,
2118
2127
  disabled: {
2119
2128
  type: Boolean,
@@ -2123,6 +2132,7 @@ function $FormCreate(FormCreate, components, directives) {
2123
2132
  type: Boolean,
2124
2133
  "default": undefined
2125
2134
  },
2135
+ index: [String, Number],
2126
2136
  api: Object,
2127
2137
  name: String,
2128
2138
  subForm: {
@@ -2160,7 +2170,7 @@ function $FormCreate(FormCreate, components, directives) {
2160
2170
 
2161
2171
  var addSubForm = function addSubForm() {
2162
2172
  if (parent) {
2163
- var _inject = getRuleInject(vm, parent);
2173
+ var _inject = _getGroupInject(vm, parent);
2164
2174
 
2165
2175
  if (_inject) {
2166
2176
  var sub;
@@ -2178,7 +2188,7 @@ function $FormCreate(FormCreate, components, directives) {
2178
2188
  };
2179
2189
 
2180
2190
  var rmSubForm = function rmSubForm() {
2181
- var inject = getRuleInject(vm, parent);
2191
+ var inject = _getGroupInject(vm, parent);
2182
2192
 
2183
2193
  if (inject) {
2184
2194
  if (isMore) {
@@ -2196,33 +2206,36 @@ function $FormCreate(FormCreate, components, directives) {
2196
2206
 
2197
2207
  var styleEl = null;
2198
2208
  onBeforeMount(function () {
2199
- var content = '';
2200
- var globalClass = props.option && props.option.globalClass || {};
2201
- Object.keys(globalClass).forEach(function (k) {
2202
- var subCss = '';
2203
- globalClass[k].style && Object.keys(globalClass[k].style).forEach(function (key) {
2204
- subCss += toLine(key) + ':' + globalClass[k].style[key] + ';';
2209
+ watchEffect(function () {
2210
+ var content = '';
2211
+ var globalClass = props.option && props.option.globalClass || {};
2212
+ Object.keys(globalClass).forEach(function (k) {
2213
+ var subCss = '';
2214
+ globalClass[k].style && Object.keys(globalClass[k].style).forEach(function (key) {
2215
+ subCss += toLine(key) + ':' + globalClass[k].style[key] + ';';
2216
+ });
2217
+
2218
+ if (globalClass[k].content) {
2219
+ subCss += globalClass[k].content + ';';
2220
+ }
2221
+
2222
+ if (subCss) {
2223
+ content += ".".concat(k, "{").concat(subCss, "}");
2224
+ }
2205
2225
  });
2206
2226
 
2207
- if (globalClass[k].content) {
2208
- subCss += globalClass[k].content + ';';
2227
+ if (props.option && props.option.style) {
2228
+ content += props.option.style;
2209
2229
  }
2210
2230
 
2211
- if (subCss) {
2212
- content += ".".concat(k, "{").concat(subCss, "}");
2231
+ if (!styleEl) {
2232
+ styleEl = document.createElement('style');
2233
+ styleEl.type = 'text/css';
2234
+ document.head.appendChild(styleEl);
2213
2235
  }
2214
- });
2215
2236
 
2216
- if (props.option && props.option.style) {
2217
- content += props.option.style;
2218
- }
2219
-
2220
- if (content) {
2221
- styleEl = document.createElement('style');
2222
- styleEl.type = 'text/css';
2223
- styleEl.innerHTML = content;
2224
- document.head.appendChild(styleEl);
2225
- }
2237
+ styleEl.innerHTML = content || '';
2238
+ });
2226
2239
  });
2227
2240
  var emit$topForm = debounce(function () {
2228
2241
  fc.bus.$emit('$loadData.$topForm');
@@ -2288,7 +2301,6 @@ function $FormCreate(FormCreate, components, directives) {
2288
2301
  if (JSON.stringify(n || {}) === data.updateValue) return;
2289
2302
 
2290
2303
  if (fapi.config.forceCoverValue) {
2291
- fc.$handle.appendData = {};
2292
2304
  fapi.coverValue(n || {});
2293
2305
  } else {
2294
2306
  fapi.setValue(n || {});
@@ -2296,11 +2308,26 @@ function $FormCreate(FormCreate, components, directives) {
2296
2308
  }, {
2297
2309
  deep: true
2298
2310
  });
2311
+ watch(function () {
2312
+ return props.index;
2313
+ }, function () {
2314
+ fapi.coverValue({});
2315
+ nextTick(function () {
2316
+ nextTick(function () {
2317
+ fapi.clearValidateState();
2318
+ });
2319
+ });
2320
+ }, {
2321
+ flush: 'sync'
2322
+ });
2299
2323
  return _objectSpread2(_objectSpread2({
2300
2324
  fc: markRaw(fc),
2301
2325
  parent: parent ? markRaw(parent) : parent,
2302
2326
  fapi: markRaw(fapi)
2303
2327
  }, toRefs(data)), {}, {
2328
+ getGroupInject: function getGroupInject() {
2329
+ return _getGroupInject(vm, parent);
2330
+ },
2304
2331
  refresh: function refresh() {
2305
2332
  ++data.unique;
2306
2333
  },
@@ -2406,7 +2433,7 @@ var mergeFn = function mergeFn(fn1, fn2) {
2406
2433
 
2407
2434
  var keyAttrs = ['type', 'slot', 'emitPrefix', 'value', 'name', 'native', 'hidden', 'display', 'inject', 'options', 'emit', 'link', 'prefix', 'suffix', 'update', 'sync', 'optionsTo', 'key', 'slotUpdate', 'computed', 'preview', 'component', 'cache', 'modelEmit'];
2408
2435
  var arrayAttrs = ['validate', 'children', 'control'];
2409
- var normalAttrs = ['effect'];
2436
+ var normalAttrs = ['effect', 'deep'];
2410
2437
  function attrs() {
2411
2438
  return [].concat(keyAttrs, _toConsumableArray(normalMerge), _toConsumableArray(toArrayMerge), _toConsumableArray(functionalMerge), arrayAttrs, normalAttrs);
2412
2439
  }
@@ -2992,6 +3019,31 @@ function Api(h) {
2992
3019
  return allSubForm();
2993
3020
  },
2994
3021
 
3022
+ get siblings() {
3023
+ var inject = h.vm.setupState.getGroupInject();
3024
+
3025
+ if (inject) {
3026
+ var subForm = inject.getSubForm();
3027
+
3028
+ if (Array.isArray(subForm)) {
3029
+ return _toConsumableArray(subForm);
3030
+ }
3031
+ }
3032
+
3033
+ return undefined;
3034
+ },
3035
+
3036
+ get index() {
3037
+ var siblings = api.siblings;
3038
+
3039
+ if (siblings) {
3040
+ var idx = siblings.indexOf(api);
3041
+ return idx > -1 ? idx : undefined;
3042
+ }
3043
+
3044
+ return undefined;
3045
+ },
3046
+
2995
3047
  formData: function formData(fields) {
2996
3048
  return tidyFields(fields).reduce(function (initial, id) {
2997
3049
  var ctx = h.getFieldCtx(id);
@@ -3009,6 +3061,7 @@ function Api(h) {
3009
3061
  var data = _objectSpread2({}, formData || {});
3010
3062
 
3011
3063
  h.deferSyncValue(function () {
3064
+ h.appendData = {};
3012
3065
  api.fields().forEach(function (key) {
3013
3066
  var ctxs = h.fieldCtx[key];
3014
3067
 
@@ -3021,7 +3074,7 @@ function Api(h) {
3021
3074
  }
3022
3075
  });
3023
3076
  extend(h.appendData, data);
3024
- });
3077
+ }, true);
3025
3078
  },
3026
3079
  setValue: function setValue(field) {
3027
3080
  var formData = field;
@@ -3034,7 +3087,7 @@ function Api(h) {
3034
3087
  ctx.rule.value = formData[key];
3035
3088
  });
3036
3089
  });
3037
- });
3090
+ }, true);
3038
3091
  },
3039
3092
  removeField: function removeField(field) {
3040
3093
  var ctx = h.getCtx(field);
@@ -3306,6 +3359,9 @@ function Api(h) {
3306
3359
  ctx.rule.value = copy(ctx.defaultValue);
3307
3360
  });
3308
3361
  });
3362
+ nextTick(function () {
3363
+ api.clearValidateState();
3364
+ });
3309
3365
  },
3310
3366
  method: function method(id, name) {
3311
3367
  var el = api.el(id);
@@ -5215,7 +5271,7 @@ function useInput(Handler) {
5215
5271
  this.deferSyncFn = null;
5216
5272
 
5217
5273
  if (fn.sync) {
5218
- this.syncValue();
5274
+ this.syncForm();
5219
5275
  }
5220
5276
  }
5221
5277
  },
@@ -5538,7 +5594,9 @@ function useContext(Handler) {
5538
5594
  return or ? false : valid;
5539
5595
  };
5540
5596
 
5541
- return checkCondition(item);
5597
+ var _val = checkCondition(item);
5598
+
5599
+ return item.invert === true ? !_val : _val;
5542
5600
  } else if (is.Function(item)) {
5543
5601
  fn = function fn() {
5544
5602
  return item(_this.api.form, _this.api);
@@ -6840,7 +6898,7 @@ function FormCreateFactory(config) {
6840
6898
  }
6841
6899
 
6842
6900
  if (this.vm.props.driver) {
6843
- this.renderDriver = this.drivers[this.vm.props.driver];
6901
+ this.renderDriver = _typeof(this.vm.props.driver) === 'object' ? this.vm.props.driver : this.drivers[this.vm.props.driver];
6844
6902
  }
6845
6903
 
6846
6904
  if (!this.renderDriver && this.vm.setupState.parent) {
@@ -6969,6 +7027,8 @@ function FormCreateFactory(config) {
6969
7027
  unwatch();
6970
7028
 
6971
7029
  _this5.bus.$emit('$loadData.$var.' + key);
7030
+
7031
+ return val;
6972
7032
  }
6973
7033
 
6974
7034
  val = invoke(function () {
@@ -7614,11 +7674,12 @@ var manager = {
7614
7674
  var rule = ctx.prop;
7615
7675
  var uni = "".concat(this.key).concat(ctx.key);
7616
7676
  var col = rule.col;
7617
- var isTitle = this.isTitle(rule);
7677
+ var isTitle = this.isTitle(rule) && rule.wrap.title !== false;
7618
7678
  var labelWidth = !col.labelWidth && !isTitle ? 0 : col.labelWidth;
7619
7679
  var _this$rule$props = this.rule.props,
7620
7680
  inline = _this$rule$props.inline,
7621
7681
  _col = _this$rule$props.col;
7682
+ delete rule.wrap.title;
7622
7683
  var item = isFalse(rule.wrap.show) ? children : this.$r(mergeProps([rule.wrap, {
7623
7684
  props: _objectSpread2(_objectSpread2({
7624
7685
  labelWidth: labelWidth === void 0 ? labelWidth : toString(labelWidth),
@@ -8142,7 +8203,7 @@ function install(FormCreate) {
8142
8203
  function elmFormCreate() {
8143
8204
  return FormCreateFactory({
8144
8205
  ui: 'element-ui',
8145
- version: '3.2.6',
8206
+ version: '3.2.8',
8146
8207
  manager: manager,
8147
8208
  extendApi: extendApi,
8148
8209
  install: install,