@form-create/element-ui 3.2.7 → 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.7
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)];
@@ -1821,13 +1824,18 @@ var Group = defineComponent({
1821
1824
  }, null);
1822
1825
  },
1823
1826
  changeSort: function changeSort(index, sort) {
1827
+ var _this10 = this;
1828
+
1824
1829
  var a = this.sort[index];
1825
1830
  this.sort[index] = this.sort[index + sort];
1826
1831
  this.sort[index + sort] = a;
1832
+ this.formCreateInject.subForm(this.sort.map(function (k) {
1833
+ return _this10.cacheRule[k].$f;
1834
+ }));
1827
1835
  this.formData(0);
1828
1836
  },
1829
1837
  makeIcon: function makeIcon(total, index, key) {
1830
- var _this10 = this;
1838
+ var _this11 = this;
1831
1839
 
1832
1840
  if (this.$slots.button) {
1833
1841
  return this.$slots.button({
@@ -1836,7 +1844,7 @@ var Group = defineComponent({
1836
1844
  vm: this,
1837
1845
  key: key,
1838
1846
  del: function del() {
1839
- return _this10.del(index, key);
1847
+ return _this11.del(index, key);
1840
1848
  },
1841
1849
  add: this.add
1842
1850
  });
@@ -1872,12 +1880,12 @@ var Group = defineComponent({
1872
1880
  }
1873
1881
  },
1874
1882
  created: function created() {
1875
- var _this11 = this;
1883
+ var _this12 = this;
1876
1884
 
1877
1885
  watch(function () {
1878
- return _objectSpread2({}, _this11.cacheRule);
1886
+ return _objectSpread2({}, _this12.cacheRule);
1879
1887
  }, function (n) {
1880
- _this11.sort = Object.keys(n);
1888
+ _this12.sort = Object.keys(n);
1881
1889
  }, {
1882
1890
  immediate: true
1883
1891
  });
@@ -1892,7 +1900,7 @@ var Group = defineComponent({
1892
1900
  }
1893
1901
  },
1894
1902
  render: function render() {
1895
- var _this12 = this;
1903
+ var _this13 = this;
1896
1904
 
1897
1905
  var keys = this.sort;
1898
1906
  var button = this.button;
@@ -1906,10 +1914,10 @@ var Group = defineComponent({
1906
1914
  "class": "_fc-group-plus-minus _fc-group-add fc-clock",
1907
1915
  "onClick": this.add
1908
1916
  }, null) : keys.map(function (key, index) {
1909
- var _this12$cacheRule$key = _this12.cacheRule[key],
1910
- rule = _this12$cacheRule$key.rule,
1911
- options = _this12$cacheRule$key.options;
1912
- 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) : [];
1913
1921
  return createVNode("div", {
1914
1922
  "class": "_fc-group-container",
1915
1923
  "key": key
@@ -1918,20 +1926,20 @@ var Group = defineComponent({
1918
1926
  }, {
1919
1927
  disabled: disabled,
1920
1928
  'onUpdate:modelValue': function onUpdateModelValue(formData) {
1921
- return _this12.formData(key, formData);
1929
+ return _this13.formData(key, formData);
1922
1930
  },
1923
1931
  'onEmit-event': function onEmitEvent(name) {
1924
1932
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1925
1933
  args[_key - 1] = arguments[_key];
1926
1934
  }
1927
1935
 
1928
- return _this12.emitEvent(name, args, index, key);
1936
+ return _this13.emitEvent(name, args, index, key);
1929
1937
  },
1930
1938
  'onUpdate:api': function onUpdateApi($f) {
1931
- return _this12.add$f(index, key, $f);
1939
+ return _this13.add$f(index, key, $f);
1932
1940
  },
1933
1941
  inFor: true,
1934
- 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],
1935
1943
  rule: rule,
1936
1944
  option: options,
1937
1945
  extendOption: true
@@ -2080,7 +2088,7 @@ function upper(str) {
2080
2088
  return str.replace(str[0], str[0].toLocaleUpperCase());
2081
2089
  }
2082
2090
 
2083
- var getRuleInject = function getRuleInject(vm, parent) {
2091
+ var _getGroupInject = function getGroupInject(vm, parent) {
2084
2092
  if (!vm || vm === parent) {
2085
2093
  return;
2086
2094
  }
@@ -2090,7 +2098,7 @@ var getRuleInject = function getRuleInject(vm, parent) {
2090
2098
  }
2091
2099
 
2092
2100
  if (vm.parent) {
2093
- return getRuleInject(vm.parent, parent);
2101
+ return _getGroupInject(vm.parent, parent);
2094
2102
  }
2095
2103
  };
2096
2104
 
@@ -2162,7 +2170,7 @@ function $FormCreate(FormCreate, components, directives) {
2162
2170
 
2163
2171
  var addSubForm = function addSubForm() {
2164
2172
  if (parent) {
2165
- var _inject = getRuleInject(vm, parent);
2173
+ var _inject = _getGroupInject(vm, parent);
2166
2174
 
2167
2175
  if (_inject) {
2168
2176
  var sub;
@@ -2180,7 +2188,7 @@ function $FormCreate(FormCreate, components, directives) {
2180
2188
  };
2181
2189
 
2182
2190
  var rmSubForm = function rmSubForm() {
2183
- var inject = getRuleInject(vm, parent);
2191
+ var inject = _getGroupInject(vm, parent);
2184
2192
 
2185
2193
  if (inject) {
2186
2194
  if (isMore) {
@@ -2198,33 +2206,36 @@ function $FormCreate(FormCreate, components, directives) {
2198
2206
 
2199
2207
  var styleEl = null;
2200
2208
  onBeforeMount(function () {
2201
- var content = '';
2202
- var globalClass = props.option && props.option.globalClass || {};
2203
- Object.keys(globalClass).forEach(function (k) {
2204
- var subCss = '';
2205
- globalClass[k].style && Object.keys(globalClass[k].style).forEach(function (key) {
2206
- 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
+ }
2207
2225
  });
2208
2226
 
2209
- if (globalClass[k].content) {
2210
- subCss += globalClass[k].content + ';';
2227
+ if (props.option && props.option.style) {
2228
+ content += props.option.style;
2211
2229
  }
2212
2230
 
2213
- if (subCss) {
2214
- content += ".".concat(k, "{").concat(subCss, "}");
2231
+ if (!styleEl) {
2232
+ styleEl = document.createElement('style');
2233
+ styleEl.type = 'text/css';
2234
+ document.head.appendChild(styleEl);
2215
2235
  }
2216
- });
2217
-
2218
- if (props.option && props.option.style) {
2219
- content += props.option.style;
2220
- }
2221
2236
 
2222
- if (content) {
2223
- styleEl = document.createElement('style');
2224
- styleEl.type = 'text/css';
2225
- styleEl.innerHTML = content;
2226
- document.head.appendChild(styleEl);
2227
- }
2237
+ styleEl.innerHTML = content || '';
2238
+ });
2228
2239
  });
2229
2240
  var emit$topForm = debounce(function () {
2230
2241
  fc.bus.$emit('$loadData.$topForm');
@@ -2314,6 +2325,9 @@ function $FormCreate(FormCreate, components, directives) {
2314
2325
  parent: parent ? markRaw(parent) : parent,
2315
2326
  fapi: markRaw(fapi)
2316
2327
  }, toRefs(data)), {}, {
2328
+ getGroupInject: function getGroupInject() {
2329
+ return _getGroupInject(vm, parent);
2330
+ },
2317
2331
  refresh: function refresh() {
2318
2332
  ++data.unique;
2319
2333
  },
@@ -2419,7 +2433,7 @@ var mergeFn = function mergeFn(fn1, fn2) {
2419
2433
 
2420
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'];
2421
2435
  var arrayAttrs = ['validate', 'children', 'control'];
2422
- var normalAttrs = ['effect'];
2436
+ var normalAttrs = ['effect', 'deep'];
2423
2437
  function attrs() {
2424
2438
  return [].concat(keyAttrs, _toConsumableArray(normalMerge), _toConsumableArray(toArrayMerge), _toConsumableArray(functionalMerge), arrayAttrs, normalAttrs);
2425
2439
  }
@@ -3005,6 +3019,31 @@ function Api(h) {
3005
3019
  return allSubForm();
3006
3020
  },
3007
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
+
3008
3047
  formData: function formData(fields) {
3009
3048
  return tidyFields(fields).reduce(function (initial, id) {
3010
3049
  var ctx = h.getFieldCtx(id);
@@ -3320,6 +3359,9 @@ function Api(h) {
3320
3359
  ctx.rule.value = copy(ctx.defaultValue);
3321
3360
  });
3322
3361
  });
3362
+ nextTick(function () {
3363
+ api.clearValidateState();
3364
+ });
3323
3365
  },
3324
3366
  method: function method(id, name) {
3325
3367
  var el = api.el(id);
@@ -5552,7 +5594,9 @@ function useContext(Handler) {
5552
5594
  return or ? false : valid;
5553
5595
  };
5554
5596
 
5555
- return checkCondition(item);
5597
+ var _val = checkCondition(item);
5598
+
5599
+ return item.invert === true ? !_val : _val;
5556
5600
  } else if (is.Function(item)) {
5557
5601
  fn = function fn() {
5558
5602
  return item(_this.api.form, _this.api);
@@ -6983,6 +7027,8 @@ function FormCreateFactory(config) {
6983
7027
  unwatch();
6984
7028
 
6985
7029
  _this5.bus.$emit('$loadData.$var.' + key);
7030
+
7031
+ return val;
6986
7032
  }
6987
7033
 
6988
7034
  val = invoke(function () {
@@ -7628,11 +7674,12 @@ var manager = {
7628
7674
  var rule = ctx.prop;
7629
7675
  var uni = "".concat(this.key).concat(ctx.key);
7630
7676
  var col = rule.col;
7631
- var isTitle = this.isTitle(rule);
7677
+ var isTitle = this.isTitle(rule) && rule.wrap.title !== false;
7632
7678
  var labelWidth = !col.labelWidth && !isTitle ? 0 : col.labelWidth;
7633
7679
  var _this$rule$props = this.rule.props,
7634
7680
  inline = _this$rule$props.inline,
7635
7681
  _col = _this$rule$props.col;
7682
+ delete rule.wrap.title;
7636
7683
  var item = isFalse(rule.wrap.show) ? children : this.$r(mergeProps([rule.wrap, {
7637
7684
  props: _objectSpread2(_objectSpread2({
7638
7685
  labelWidth: labelWidth === void 0 ? labelWidth : toString(labelWidth),
@@ -8156,7 +8203,7 @@ function install(FormCreate) {
8156
8203
  function elmFormCreate() {
8157
8204
  return FormCreateFactory({
8158
8205
  ui: 'element-ui',
8159
- version: '3.2.7',
8206
+ version: '3.2.8',
8160
8207
  manager: manager,
8161
8208
  extendApi: extendApi,
8162
8209
  install: install,