@form-create/component-antdv-group 3.2.0 → 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.
package/dist/index.esm.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @form-create/component-antdv-group v3.2.0
2
+ * @form-create/component-antdv-group v3.2.8
3
3
  * (c) 2018-2024 xaboy
4
4
  * Github https://github.com/xaboy/form-create with group
5
5
  * Released under the MIT License.
@@ -353,7 +353,7 @@ var Group = defineComponent({
353
353
  var _this2 = this;
354
354
 
355
355
  n = n || [];
356
- var keys = Object.keys(this.sort),
356
+ var keys = this.sort,
357
357
  total = keys.length,
358
358
  len = total - n.length;
359
359
 
@@ -537,13 +537,18 @@ var Group = defineComponent({
537
537
  }, null);
538
538
  },
539
539
  changeSort: function changeSort(index, sort) {
540
+ var _this10 = this;
541
+
540
542
  var a = this.sort[index];
541
543
  this.sort[index] = this.sort[index + sort];
542
544
  this.sort[index + sort] = a;
545
+ this.formCreateInject.subForm(this.sort.map(function (k) {
546
+ return _this10.cacheRule[k].$f;
547
+ }));
543
548
  this.formData(0);
544
549
  },
545
550
  makeIcon: function makeIcon(total, index, key) {
546
- var _this10 = this;
551
+ var _this11 = this;
547
552
 
548
553
  if (this.$slots.button) {
549
554
  return this.$slots.button({
@@ -552,7 +557,7 @@ var Group = defineComponent({
552
557
  vm: this,
553
558
  key: key,
554
559
  del: function del() {
555
- return _this10.del(index, key);
560
+ return _this11.del(index, key);
556
561
  },
557
562
  add: this.add
558
563
  });
@@ -588,12 +593,12 @@ var Group = defineComponent({
588
593
  }
589
594
  },
590
595
  created: function created() {
591
- var _this11 = this;
596
+ var _this12 = this;
592
597
 
593
598
  watch(function () {
594
- return _objectSpread2({}, _this11.cacheRule);
599
+ return _objectSpread2({}, _this12.cacheRule);
595
600
  }, function (n) {
596
- _this11.sort = Object.keys(n);
601
+ _this12.sort = Object.keys(n);
597
602
  }, {
598
603
  immediate: true
599
604
  });
@@ -608,7 +613,7 @@ var Group = defineComponent({
608
613
  }
609
614
  },
610
615
  render: function render() {
611
- var _this12 = this;
616
+ var _this13 = this;
612
617
 
613
618
  var keys = this.sort;
614
619
  var button = this.button;
@@ -622,10 +627,10 @@ var Group = defineComponent({
622
627
  "class": "_fc-group-plus-minus _fc-group-add fc-clock",
623
628
  "onClick": this.add
624
629
  }, null) : keys.map(function (key, index) {
625
- var _this12$cacheRule$key = _this12.cacheRule[key],
626
- rule = _this12$cacheRule$key.rule,
627
- options = _this12$cacheRule$key.options;
628
- var btn = button && !disabled ? _this12.makeIcon(keys.length, index, key) : [];
630
+ var _this13$cacheRule$key = _this13.cacheRule[key],
631
+ rule = _this13$cacheRule$key.rule,
632
+ options = _this13$cacheRule$key.options;
633
+ var btn = button && !disabled ? _this13.makeIcon(keys.length, index, key) : [];
629
634
  return createVNode("div", {
630
635
  "class": "_fc-group-container",
631
636
  "key": key
@@ -634,20 +639,20 @@ var Group = defineComponent({
634
639
  }, {
635
640
  disabled: disabled,
636
641
  'onUpdate:modelValue': function onUpdateModelValue(formData) {
637
- return _this12.formData(key, formData);
642
+ return _this13.formData(key, formData);
638
643
  },
639
644
  'onEmit-event': function onEmitEvent(name) {
640
645
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
641
646
  args[_key - 1] = arguments[_key];
642
647
  }
643
648
 
644
- return _this12.emitEvent(name, args, index, key);
649
+ return _this13.emitEvent(name, args, index, key);
645
650
  },
646
651
  'onUpdate:api': function onUpdateApi($f) {
647
- return _this12.add$f(index, key, $f);
652
+ return _this13.add$f(index, key, $f);
648
653
  },
649
654
  inFor: true,
650
- modelValue: _this12.field ? _defineProperty({}, _this12.field, _this12._value(_this12.modelValue[index])) : _this12.modelValue[index],
655
+ modelValue: _this13.field ? _defineProperty({}, _this13.field, _this13._value(_this13.modelValue[index])) : _this13.modelValue[index],
651
656
  rule: rule,
652
657
  option: options,
653
658
  extendOption: true
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * @form-create/component-antdv-group v3.2.0
2
+ * @form-create/component-antdv-group v3.2.8
3
3
  * (c) 2018-2024 xaboy
4
4
  * Github https://github.com/xaboy/form-create with group
5
5
  * Released under the MIT License.
6
6
  */
7
- import{defineComponent as t,markRaw as e,nextTick as r,createVNode as n,watch as o,mergeProps as i}from"vue";function u(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function a(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?u(Object(r),!0).forEach((function(e){c(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function l(t){return l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},l(t)}function c(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function s(t){return function(t){if(Array.isArray(t))return f(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return f(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return f(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var d={type:function(t,e){return Object.prototype.toString.call(t)==="[object "+e+"]"},Undef:function(t){return null==t},Element:function(t){return"object"===l(t)&&null!==t&&1===t.nodeType&&!d.Object(t)},trueArray:function(t){return Array.isArray(t)&&t.length>0},Function:function(t){var e=this.getType(t);return"Function"===e||"AsyncFunction"===e},getType:function(t){var e=Object.prototype.toString.call(t);return/^\[object (.*)\]$/.exec(e)[1]},empty:function(t){return null==t||(!(!Array.isArray(t)||!Array.isArray(t)||t.length)||"string"==typeof t&&!t)}};function p(t,e,r){t[e]=r}function h(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0,n=!1;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var i=e[o];if((n=Array.isArray(i))||d.Object(i)){var u=void 0===t[o];if(n)n=!1,u&&p(t,o,[]);else if(i._clone&&void 0!==r){if(!r){p(t,o,i._clone());continue}i=i.getRule(),u&&p(t,o,{})}else u&&p(t,o,{});t[o]=h(t[o],i,r)}else p(t,o,i),d.Undef(i)||(d.Undef(i.__json)||(t[o].__json=i.__json),d.Undef(i.__origin)||(t[o].__origin=i.__origin))}return void 0!==r&&Array.isArray(t)?t.filter((function(t){return!t||!t.__ctrl})):t}function m(t){return h({},{value:t}).value}["Date","Object","String","Boolean","Array","Number"].forEach((function(t){d[t]=function(e){return d.type(e,t)}}));var g=Object.assign||function(t){for(var e,r=1;r<arguments.length;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&p(t,n,e[n]);return t};!function(t,e){void 0===e&&(e={});var r=e.insertAt;if(t&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===r&&n.firstChild?n.insertBefore(o,n.firstChild):n.appendChild(o),o.styleSheet?o.styleSheet.cssText=t:o.appendChild(document.createTextNode(t))}}('._fc-group{display:flex;flex-direction:column;justify-content:center;min-height:38px;width:100%}._fc-group-disabled ._fc-group-add,._fc-group-disabled ._fc-group-btn{cursor:not-allowed}._fc-group-handle{background-color:#fff;border:1px dashed #d9d9d9;border-radius:15px;bottom:-15px;display:flex;flex-direction:row;padding:3px 8px;position:absolute;right:30px}._fc-group-btn{cursor:pointer}._fc-group-idx{align-items:center;background:#eee;border-radius:15px;bottom:-15px;display:flex;font-weight:700;height:30px;justify-content:center;left:10px;position:absolute;width:30px}._fc-group-handle ._fc-group-btn+._fc-group-btn{margin-left:7px}._fc-group-container{border:1px dashed #d9d9d9;border-radius:5px;display:flex;flex-direction:column;margin:5px 5px 25px;padding:20px 20px 25px;position:relative}._fc-group-arrow{height:20px;position:relative;width:20px}._fc-group-arrow:before{border-left:2px solid #999;border-top:2px solid #999;content:"";height:9px;left:5px;position:absolute;top:8px;transform:rotate(45deg);width:9px}._fc-group-arrow._fc-group-down{transform:rotate(180deg)}._fc-group-plus-minus{cursor:pointer;height:20px;position:relative;width:20px}._fc-group-plus-minus:after,._fc-group-plus-minus:before{background-color:#409eff;content:"";height:2px;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:60%}._fc-group-plus-minus:before{transform:translate(-50%,-50%) rotate(90deg)}._fc-group-plus-minus._fc-group-minus:before{display:none}._fc-group-plus-minus._fc-group-minus:after{background-color:#f56c6c}._fc-group-add{border:1px solid rgba(64,158,255,.5);border-radius:15px;cursor:pointer;height:25px;width:25px}._fc-group-add._fc-group-plus-minus:after,._fc-group-add._fc-group-plus-minus:before{width:50%}');var y=t({name:"fcGroup",props:{field:String,rule:Array,expand:Number,options:Object,button:{type:Boolean,default:!0},max:{type:Number,default:0},min:{type:Number,default:0},modelValue:{type:Array,default:function(){return[]}},defaultValue:Object,sortBtn:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},syncDisabled:{type:Boolean,default:!0},onBeforeRemove:{type:Function,default:function(){}},onBeforeAdd:{type:Function,default:function(){}},formCreateInject:Object,parse:Function},data:function(){return{len:0,cacheRule:{},cacheValue:{},sort:[],form:e(this.formCreateInject.form.$form())}},emits:["update:modelValue","change","itemMounted","remove","add"],watch:{rule:{handler:function(t,e){var r=this;Object.keys(this.cacheRule).forEach((function(n){var o=r.cacheRule[n];if(o.$f){var i=o.$f.formData();if(t===e)o.$f.deferSyncValue((function(){h(o.rule,t),o.$f.setValue(i)}),!0);else{var u=o.$f.formData();o.$f.once("reloading",(function(){o.$f.setValue(u)})),o.rule=m(t)}}}))},deep:!0},expand:function(t){var e=t-this.modelValue.length;e>0&&this.expandRule(e)},modelValue:{handler:function(t){var e=this;t=t||[];var r=Object.keys(this.sort),n=r.length,o=n-t.length;if(o<0){for(var i=o;i<0;i++)this.addRule(t.length+i,!0);for(var u=0;u<n;u++)this.setValue(r[u],t[u])}else{if(o>0)for(var a=0;a<o;a++)this.removeRule(r[n-a-1]);t.forEach((function(n,o){e.setValue(r[o],t[o])}))}},deep:!0}},methods:{_value:function(t){return t&&(e=t,r=this.field,{}.hasOwnProperty.call(e,r))?t[this.field]:t;var e,r},cache:function(t,e){this.cacheValue[t]=JSON.stringify(e)},input:function(t){this.$emit("update:modelValue",t),this.$emit("change",t)},formData:function(t,e){var r=this,n=this.cacheRule,o=this.sort;if(o.filter((function(t){return n[t].$f})).length===o.length){var i=o.map((function(n){var o=t===n?e:a({},r.cacheRule[n].$f.form),i=r.field?o[r.field]||null:o;return r.cache(n,i),i}));this.input(i)}},setValue:function(t,e){var r=this.field;r&&(e=c({},r,this._value(e))),this.cacheValue[t]!==JSON.stringify(r?e[r]:e)&&this.cache(t,e)},addRule:function(t,e){var n=this,o=this.formCreateInject.form.copyRules(this.rule||[]),i=this.options?a({},this.options):{submitBtn:!1,resetBtn:!1};if(this.defaultValue){i.formData||(i.formData={});var u=m(this.defaultValue);!function(){g.apply(this,arguments)}(i.formData,this.field?c({},this.field,u):u)}this.parse&&this.parse({rule:o,options:i,index:this.sort.length}),this.cacheRule[++this.len]={rule:o,options:i},e&&r((function(){return n.$emit("add",o,Object.keys(n.cacheRule).length-1)}))},add$f:function(t,e,n){var o=this;this.cacheRule[e].$f=n,r((function(){o.$emit("itemMounted",n,Object.keys(o.cacheRule).indexOf(e))}))},removeRule:function(t,e){var n=this,o=Object.keys(this.cacheRule).indexOf(t);delete this.cacheRule[t],delete this.cacheValue[t],e&&r((function(){return n.$emit("remove",o)}))},add:function(t){if(!this.disabled&&!1!==this.onBeforeAdd(this.modelValue)){var e=s(this.modelValue);e.push(this.defaultValue?m(this.defaultValue):this.field?null:{}),this.input(e)}},del:function(t,e){if(!this.disabled&&!1!==this.onBeforeRemove(this.modelValue,t)){this.removeRule(e,!0);var r=s(this.modelValue);r.splice(t,1),this.input(r)}},addIcon:function(t){return n("div",{class:"_fc-group-btn _fc-group-plus-minus",onClick:this.add},null)},delIcon:function(t,e){var r=this;return n("div",{class:"_fc-group-btn _fc-group-plus-minus _fc-group-minus",onClick:function(){return r.del(t,e)}},null)},sortUpIcon:function(t){var e=this;return n("div",{class:"_fc-group-btn _fc-group-arrow _fc-group-up",onClick:function(){return e.changeSort(t,-1)}},null)},sortDownIcon:function(t){var e=this;return n("div",{class:"_fc-group-btn _fc-group-arrow _fc-group-down",onClick:function(){return e.changeSort(t,1)}},null)},changeSort:function(t,e){var r=this.sort[t];this.sort[t]=this.sort[t+e],this.sort[t+e]=r,this.formData(0)},makeIcon:function(t,e,r){var n=this;if(this.$slots.button)return this.$slots.button({total:t,index:e,vm:this,key:r,del:function(){return n.del(e,r)},add:this.add});var o=[];return(!this.max||t<this.max)&&t===e+1&&o.push(this.addIcon(r)),t>this.min&&o.push(this.delIcon(e,r)),this.sortBtn&&e&&o.push(this.sortUpIcon(e)),this.sortBtn&&e!==t-1&&o.push(this.sortDownIcon(e)),o},emitEvent:function(t,e,r,n){this.$emit.apply(this,[t].concat(s(e),[this.cacheRule[n].$f,r]))},expandRule:function(t){for(var e=0;e<t;e++)this.addRule(e)}},created:function(){var t=this;o((function(){return a({},t.cacheRule)}),(function(e){t.sort=Object.keys(e)}),{immediate:!0});for(var e=(this.expand||0)-this.modelValue.length,r=0;r<this.modelValue.length;r++)this.addRule(r);e>0&&this.expandRule(e)},render:function(){var t=this,e=this.sort,r=this.button,o=this.form,u=this.disabled,a=0===e.length?this.$slots.default?this.$slots.default({vm:this,add:this.add}):n("div",{key:"a_def",class:"_fc-group-plus-minus _fc-group-add fc-clock",onClick:this.add},null):e.map((function(a,l){var s=t.cacheRule[a],f=s.rule,d=s.options,p=r&&!u?t.makeIcon(e.length,l,a):[];return n("div",{class:"_fc-group-container",key:a},[n(o,i({key:a},{disabled:u,"onUpdate:modelValue":function(e){return t.formData(a,e)},"onEmit-event":function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];return t.emitEvent(e,n,l,a)},"onUpdate:api":function(e){return t.add$f(l,a,e)},inFor:!0,modelValue:t.field?c({},t.field,t._value(t.modelValue[l])):t.modelValue[l],rule:f,option:d,extendOption:!0}),null),n("div",{class:"_fc-group-idx"},[l+1]),p.length?n("div",{class:"_fc-group-handle fc-clock"},[p]):null])}));return n("div",{key:"con",class:"_fc-group "+(u?"_fc-group-disabled":"")},[a])}});export{y as default};
7
+ import{defineComponent as t,markRaw as e,nextTick as r,createVNode as n,watch as o,mergeProps as i}from"vue";function u(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function a(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?u(Object(r),!0).forEach((function(e){l(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):u(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function c(t){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},c(t)}function l(t,e,r){return e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function s(t){return function(t){if(Array.isArray(t))return f(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(!t)return;if("string"==typeof t)return f(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return f(t,e)}(t)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}var d={type:function(t,e){return Object.prototype.toString.call(t)==="[object "+e+"]"},Undef:function(t){return null==t},Element:function(t){return"object"===c(t)&&null!==t&&1===t.nodeType&&!d.Object(t)},trueArray:function(t){return Array.isArray(t)&&t.length>0},Function:function(t){var e=this.getType(t);return"Function"===e||"AsyncFunction"===e},getType:function(t){var e=Object.prototype.toString.call(t);return/^\[object (.*)\]$/.exec(e)[1]},empty:function(t){return null==t||(!(!Array.isArray(t)||!Array.isArray(t)||t.length)||"string"==typeof t&&!t)}};function p(t,e,r){t[e]=r}function h(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0,n=!1;for(var o in e)if(Object.prototype.hasOwnProperty.call(e,o)){var i=e[o];if((n=Array.isArray(i))||d.Object(i)){var u=void 0===t[o];if(n)n=!1,u&&p(t,o,[]);else if(i._clone&&void 0!==r){if(!r){p(t,o,i._clone());continue}i=i.getRule(),u&&p(t,o,{})}else u&&p(t,o,{});t[o]=h(t[o],i,r)}else p(t,o,i),d.Undef(i)||(d.Undef(i.__json)||(t[o].__json=i.__json),d.Undef(i.__origin)||(t[o].__origin=i.__origin))}return void 0!==r&&Array.isArray(t)?t.filter((function(t){return!t||!t.__ctrl})):t}function m(t){return h({},{value:t}).value}["Date","Object","String","Boolean","Array","Number"].forEach((function(t){d[t]=function(e){return d.type(e,t)}}));var g=Object.assign||function(t){for(var e,r=1;r<arguments.length;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&p(t,n,e[n]);return t};!function(t,e){void 0===e&&(e={});var r=e.insertAt;if(t&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===r&&n.firstChild?n.insertBefore(o,n.firstChild):n.appendChild(o),o.styleSheet?o.styleSheet.cssText=t:o.appendChild(document.createTextNode(t))}}('._fc-group{display:flex;flex-direction:column;justify-content:center;min-height:38px;width:100%}._fc-group-disabled ._fc-group-add,._fc-group-disabled ._fc-group-btn{cursor:not-allowed}._fc-group-handle{background-color:#fff;border:1px dashed #d9d9d9;border-radius:15px;bottom:-15px;display:flex;flex-direction:row;padding:3px 8px;position:absolute;right:30px}._fc-group-btn{cursor:pointer}._fc-group-idx{align-items:center;background:#eee;border-radius:15px;bottom:-15px;display:flex;font-weight:700;height:30px;justify-content:center;left:10px;position:absolute;width:30px}._fc-group-handle ._fc-group-btn+._fc-group-btn{margin-left:7px}._fc-group-container{border:1px dashed #d9d9d9;border-radius:5px;display:flex;flex-direction:column;margin:5px 5px 25px;padding:20px 20px 25px;position:relative}._fc-group-arrow{height:20px;position:relative;width:20px}._fc-group-arrow:before{border-left:2px solid #999;border-top:2px solid #999;content:"";height:9px;left:5px;position:absolute;top:8px;transform:rotate(45deg);width:9px}._fc-group-arrow._fc-group-down{transform:rotate(180deg)}._fc-group-plus-minus{cursor:pointer;height:20px;position:relative;width:20px}._fc-group-plus-minus:after,._fc-group-plus-minus:before{background-color:#409eff;content:"";height:2px;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:60%}._fc-group-plus-minus:before{transform:translate(-50%,-50%) rotate(90deg)}._fc-group-plus-minus._fc-group-minus:before{display:none}._fc-group-plus-minus._fc-group-minus:after{background-color:#f56c6c}._fc-group-add{border:1px solid rgba(64,158,255,.5);border-radius:15px;cursor:pointer;height:25px;width:25px}._fc-group-add._fc-group-plus-minus:after,._fc-group-add._fc-group-plus-minus:before{width:50%}');var y=t({name:"fcGroup",props:{field:String,rule:Array,expand:Number,options:Object,button:{type:Boolean,default:!0},max:{type:Number,default:0},min:{type:Number,default:0},modelValue:{type:Array,default:function(){return[]}},defaultValue:Object,sortBtn:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},syncDisabled:{type:Boolean,default:!0},onBeforeRemove:{type:Function,default:function(){}},onBeforeAdd:{type:Function,default:function(){}},formCreateInject:Object,parse:Function},data:function(){return{len:0,cacheRule:{},cacheValue:{},sort:[],form:e(this.formCreateInject.form.$form())}},emits:["update:modelValue","change","itemMounted","remove","add"],watch:{rule:{handler:function(t,e){var r=this;Object.keys(this.cacheRule).forEach((function(n){var o=r.cacheRule[n];if(o.$f){var i=o.$f.formData();if(t===e)o.$f.deferSyncValue((function(){h(o.rule,t),o.$f.setValue(i)}),!0);else{var u=o.$f.formData();o.$f.once("reloading",(function(){o.$f.setValue(u)})),o.rule=m(t)}}}))},deep:!0},expand:function(t){var e=t-this.modelValue.length;e>0&&this.expandRule(e)},modelValue:{handler:function(t){var e=this;t=t||[];var r=this.sort,n=r.length,o=n-t.length;if(o<0){for(var i=o;i<0;i++)this.addRule(t.length+i,!0);for(var u=0;u<n;u++)this.setValue(r[u],t[u])}else{if(o>0)for(var a=0;a<o;a++)this.removeRule(r[n-a-1]);t.forEach((function(n,o){e.setValue(r[o],t[o])}))}},deep:!0}},methods:{_value:function(t){return t&&(e=t,r=this.field,{}.hasOwnProperty.call(e,r))?t[this.field]:t;var e,r},cache:function(t,e){this.cacheValue[t]=JSON.stringify(e)},input:function(t){this.$emit("update:modelValue",t),this.$emit("change",t)},formData:function(t,e){var r=this,n=this.cacheRule,o=this.sort;if(o.filter((function(t){return n[t].$f})).length===o.length){var i=o.map((function(n){var o=t===n?e:a({},r.cacheRule[n].$f.form),i=r.field?o[r.field]||null:o;return r.cache(n,i),i}));this.input(i)}},setValue:function(t,e){var r=this.field;r&&(e=l({},r,this._value(e))),this.cacheValue[t]!==JSON.stringify(r?e[r]:e)&&this.cache(t,e)},addRule:function(t,e){var n=this,o=this.formCreateInject.form.copyRules(this.rule||[]),i=this.options?a({},this.options):{submitBtn:!1,resetBtn:!1};if(this.defaultValue){i.formData||(i.formData={});var u=m(this.defaultValue);!function(){g.apply(this,arguments)}(i.formData,this.field?l({},this.field,u):u)}this.parse&&this.parse({rule:o,options:i,index:this.sort.length}),this.cacheRule[++this.len]={rule:o,options:i},e&&r((function(){return n.$emit("add",o,Object.keys(n.cacheRule).length-1)}))},add$f:function(t,e,n){var o=this;this.cacheRule[e].$f=n,r((function(){o.$emit("itemMounted",n,Object.keys(o.cacheRule).indexOf(e))}))},removeRule:function(t,e){var n=this,o=Object.keys(this.cacheRule).indexOf(t);delete this.cacheRule[t],delete this.cacheValue[t],e&&r((function(){return n.$emit("remove",o)}))},add:function(t){if(!this.disabled&&!1!==this.onBeforeAdd(this.modelValue)){var e=s(this.modelValue);e.push(this.defaultValue?m(this.defaultValue):this.field?null:{}),this.input(e)}},del:function(t,e){if(!this.disabled&&!1!==this.onBeforeRemove(this.modelValue,t)){this.removeRule(e,!0);var r=s(this.modelValue);r.splice(t,1),this.input(r)}},addIcon:function(t){return n("div",{class:"_fc-group-btn _fc-group-plus-minus",onClick:this.add},null)},delIcon:function(t,e){var r=this;return n("div",{class:"_fc-group-btn _fc-group-plus-minus _fc-group-minus",onClick:function(){return r.del(t,e)}},null)},sortUpIcon:function(t){var e=this;return n("div",{class:"_fc-group-btn _fc-group-arrow _fc-group-up",onClick:function(){return e.changeSort(t,-1)}},null)},sortDownIcon:function(t){var e=this;return n("div",{class:"_fc-group-btn _fc-group-arrow _fc-group-down",onClick:function(){return e.changeSort(t,1)}},null)},changeSort:function(t,e){var r=this,n=this.sort[t];this.sort[t]=this.sort[t+e],this.sort[t+e]=n,this.formCreateInject.subForm(this.sort.map((function(t){return r.cacheRule[t].$f}))),this.formData(0)},makeIcon:function(t,e,r){var n=this;if(this.$slots.button)return this.$slots.button({total:t,index:e,vm:this,key:r,del:function(){return n.del(e,r)},add:this.add});var o=[];return(!this.max||t<this.max)&&t===e+1&&o.push(this.addIcon(r)),t>this.min&&o.push(this.delIcon(e,r)),this.sortBtn&&e&&o.push(this.sortUpIcon(e)),this.sortBtn&&e!==t-1&&o.push(this.sortDownIcon(e)),o},emitEvent:function(t,e,r,n){this.$emit.apply(this,[t].concat(s(e),[this.cacheRule[n].$f,r]))},expandRule:function(t){for(var e=0;e<t;e++)this.addRule(e)}},created:function(){var t=this;o((function(){return a({},t.cacheRule)}),(function(e){t.sort=Object.keys(e)}),{immediate:!0});for(var e=(this.expand||0)-this.modelValue.length,r=0;r<this.modelValue.length;r++)this.addRule(r);e>0&&this.expandRule(e)},render:function(){var t=this,e=this.sort,r=this.button,o=this.form,u=this.disabled,a=0===e.length?this.$slots.default?this.$slots.default({vm:this,add:this.add}):n("div",{key:"a_def",class:"_fc-group-plus-minus _fc-group-add fc-clock",onClick:this.add},null):e.map((function(a,c){var s=t.cacheRule[a],f=s.rule,d=s.options,p=r&&!u?t.makeIcon(e.length,c,a):[];return n("div",{class:"_fc-group-container",key:a},[n(o,i({key:a},{disabled:u,"onUpdate:modelValue":function(e){return t.formData(a,e)},"onEmit-event":function(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];return t.emitEvent(e,n,c,a)},"onUpdate:api":function(e){return t.add$f(c,a,e)},inFor:!0,modelValue:t.field?l({},t.field,t._value(t.modelValue[c])):t.modelValue[c],rule:f,option:d,extendOption:!0}),null),n("div",{class:"_fc-group-idx"},[c+1]),p.length?n("div",{class:"_fc-group-handle fc-clock"},[p]):null])}));return n("div",{key:"con",class:"_fc-group "+(u?"_fc-group-disabled":"")},[a])}});export{y as default};
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /*!
2
- * @form-create/component-antdv-group v3.2.0
2
+ * @form-create/component-antdv-group v3.2.8
3
3
  * (c) 2018-2024 xaboy
4
4
  * Github https://github.com/xaboy/form-create with group
5
5
  * Released under the MIT License.
@@ -357,7 +357,7 @@
357
357
  var _this2 = this;
358
358
 
359
359
  n = n || [];
360
- var keys = Object.keys(this.sort),
360
+ var keys = this.sort,
361
361
  total = keys.length,
362
362
  len = total - n.length;
363
363
 
@@ -541,13 +541,18 @@
541
541
  }, null);
542
542
  },
543
543
  changeSort: function changeSort(index, sort) {
544
+ var _this10 = this;
545
+
544
546
  var a = this.sort[index];
545
547
  this.sort[index] = this.sort[index + sort];
546
548
  this.sort[index + sort] = a;
549
+ this.formCreateInject.subForm(this.sort.map(function (k) {
550
+ return _this10.cacheRule[k].$f;
551
+ }));
547
552
  this.formData(0);
548
553
  },
549
554
  makeIcon: function makeIcon(total, index, key) {
550
- var _this10 = this;
555
+ var _this11 = this;
551
556
 
552
557
  if (this.$slots.button) {
553
558
  return this.$slots.button({
@@ -556,7 +561,7 @@
556
561
  vm: this,
557
562
  key: key,
558
563
  del: function del() {
559
- return _this10.del(index, key);
564
+ return _this11.del(index, key);
560
565
  },
561
566
  add: this.add
562
567
  });
@@ -592,12 +597,12 @@
592
597
  }
593
598
  },
594
599
  created: function created() {
595
- var _this11 = this;
600
+ var _this12 = this;
596
601
 
597
602
  vue.watch(function () {
598
- return _objectSpread2({}, _this11.cacheRule);
603
+ return _objectSpread2({}, _this12.cacheRule);
599
604
  }, function (n) {
600
- _this11.sort = Object.keys(n);
605
+ _this12.sort = Object.keys(n);
601
606
  }, {
602
607
  immediate: true
603
608
  });
@@ -612,7 +617,7 @@
612
617
  }
613
618
  },
614
619
  render: function render() {
615
- var _this12 = this;
620
+ var _this13 = this;
616
621
 
617
622
  var keys = this.sort;
618
623
  var button = this.button;
@@ -626,10 +631,10 @@
626
631
  "class": "_fc-group-plus-minus _fc-group-add fc-clock",
627
632
  "onClick": this.add
628
633
  }, null) : keys.map(function (key, index) {
629
- var _this12$cacheRule$key = _this12.cacheRule[key],
630
- rule = _this12$cacheRule$key.rule,
631
- options = _this12$cacheRule$key.options;
632
- var btn = button && !disabled ? _this12.makeIcon(keys.length, index, key) : [];
634
+ var _this13$cacheRule$key = _this13.cacheRule[key],
635
+ rule = _this13$cacheRule$key.rule,
636
+ options = _this13$cacheRule$key.options;
637
+ var btn = button && !disabled ? _this13.makeIcon(keys.length, index, key) : [];
633
638
  return vue.createVNode("div", {
634
639
  "class": "_fc-group-container",
635
640
  "key": key
@@ -638,20 +643,20 @@
638
643
  }, {
639
644
  disabled: disabled,
640
645
  'onUpdate:modelValue': function onUpdateModelValue(formData) {
641
- return _this12.formData(key, formData);
646
+ return _this13.formData(key, formData);
642
647
  },
643
648
  'onEmit-event': function onEmitEvent(name) {
644
649
  for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
645
650
  args[_key - 1] = arguments[_key];
646
651
  }
647
652
 
648
- return _this12.emitEvent(name, args, index, key);
653
+ return _this13.emitEvent(name, args, index, key);
649
654
  },
650
655
  'onUpdate:api': function onUpdateApi($f) {
651
- return _this12.add$f(index, key, $f);
656
+ return _this13.add$f(index, key, $f);
652
657
  },
653
658
  inFor: true,
654
- modelValue: _this12.field ? _defineProperty({}, _this12.field, _this12._value(_this12.modelValue[index])) : _this12.modelValue[index],
659
+ modelValue: _this13.field ? _defineProperty({}, _this13.field, _this13._value(_this13.modelValue[index])) : _this13.modelValue[index],
655
660
  rule: rule,
656
661
  option: options,
657
662
  extendOption: true
package/dist/index.min.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * @form-create/component-antdv-group v3.2.0
2
+ * @form-create/component-antdv-group v3.2.8
3
3
  * (c) 2018-2024 xaboy
4
4
  * Github https://github.com/xaboy/form-create with group
5
5
  * Released under the MIT License.
6
6
  */
7
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).FcGroup={},e.Vue)}(this,(function(e,t){"use strict";function r(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function n(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){i(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function u(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return a(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return a(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var c={type:function(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"},Undef:function(e){return null==e},Element:function(e){return"object"===o(e)&&null!==e&&1===e.nodeType&&!c.Object(e)},trueArray:function(e){return Array.isArray(e)&&e.length>0},Function:function(e){var t=this.getType(e);return"Function"===t||"AsyncFunction"===t},getType:function(e){var t=Object.prototype.toString.call(e);return/^\[object (.*)\]$/.exec(t)[1]},empty:function(e){return null==e||(!(!Array.isArray(e)||!Array.isArray(e)||e.length)||"string"==typeof e&&!e)}};function l(e,t,r){e[t]=r}function s(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0,n=!1;for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o)){var i=t[o];if((n=Array.isArray(i))||c.Object(i)){var u=void 0===e[o];if(n)n=!1,u&&l(e,o,[]);else if(i._clone&&void 0!==r){if(!r){l(e,o,i._clone());continue}i=i.getRule(),u&&l(e,o,{})}else u&&l(e,o,{});e[o]=s(e[o],i,r)}else l(e,o,i),c.Undef(i)||(c.Undef(i.__json)||(e[o].__json=i.__json),c.Undef(i.__origin)||(e[o].__origin=i.__origin))}return void 0!==r&&Array.isArray(e)?e.filter((function(e){return!e||!e.__ctrl})):e}function f(e){return s({},{value:e}).value}["Date","Object","String","Boolean","Array","Number"].forEach((function(e){c[e]=function(t){return c.type(t,e)}}));var d=Object.assign||function(e){for(var t,r=1;r<arguments.length;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&l(e,n,t[n]);return e};!function(e,t){void 0===t&&(t={});var r=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===r&&n.firstChild?n.insertBefore(o,n.firstChild):n.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}('._fc-group{display:flex;flex-direction:column;justify-content:center;min-height:38px;width:100%}._fc-group-disabled ._fc-group-add,._fc-group-disabled ._fc-group-btn{cursor:not-allowed}._fc-group-handle{background-color:#fff;border:1px dashed #d9d9d9;border-radius:15px;bottom:-15px;display:flex;flex-direction:row;padding:3px 8px;position:absolute;right:30px}._fc-group-btn{cursor:pointer}._fc-group-idx{align-items:center;background:#eee;border-radius:15px;bottom:-15px;display:flex;font-weight:700;height:30px;justify-content:center;left:10px;position:absolute;width:30px}._fc-group-handle ._fc-group-btn+._fc-group-btn{margin-left:7px}._fc-group-container{border:1px dashed #d9d9d9;border-radius:5px;display:flex;flex-direction:column;margin:5px 5px 25px;padding:20px 20px 25px;position:relative}._fc-group-arrow{height:20px;position:relative;width:20px}._fc-group-arrow:before{border-left:2px solid #999;border-top:2px solid #999;content:"";height:9px;left:5px;position:absolute;top:8px;transform:rotate(45deg);width:9px}._fc-group-arrow._fc-group-down{transform:rotate(180deg)}._fc-group-plus-minus{cursor:pointer;height:20px;position:relative;width:20px}._fc-group-plus-minus:after,._fc-group-plus-minus:before{background-color:#409eff;content:"";height:2px;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:60%}._fc-group-plus-minus:before{transform:translate(-50%,-50%) rotate(90deg)}._fc-group-plus-minus._fc-group-minus:before{display:none}._fc-group-plus-minus._fc-group-minus:after{background-color:#f56c6c}._fc-group-add{border:1px solid rgba(64,158,255,.5);border-radius:15px;cursor:pointer;height:25px;width:25px}._fc-group-add._fc-group-plus-minus:after,._fc-group-add._fc-group-plus-minus:before{width:50%}');var p=t.defineComponent({name:"fcGroup",props:{field:String,rule:Array,expand:Number,options:Object,button:{type:Boolean,default:!0},max:{type:Number,default:0},min:{type:Number,default:0},modelValue:{type:Array,default:function(){return[]}},defaultValue:Object,sortBtn:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},syncDisabled:{type:Boolean,default:!0},onBeforeRemove:{type:Function,default:function(){}},onBeforeAdd:{type:Function,default:function(){}},formCreateInject:Object,parse:Function},data:function(){return{len:0,cacheRule:{},cacheValue:{},sort:[],form:t.markRaw(this.formCreateInject.form.$form())}},emits:["update:modelValue","change","itemMounted","remove","add"],watch:{rule:{handler:function(e,t){var r=this;Object.keys(this.cacheRule).forEach((function(n){var o=r.cacheRule[n];if(o.$f){var i=o.$f.formData();if(e===t)o.$f.deferSyncValue((function(){s(o.rule,e),o.$f.setValue(i)}),!0);else{var u=o.$f.formData();o.$f.once("reloading",(function(){o.$f.setValue(u)})),o.rule=f(e)}}}))},deep:!0},expand:function(e){var t=e-this.modelValue.length;t>0&&this.expandRule(t)},modelValue:{handler:function(e){var t=this;e=e||[];var r=Object.keys(this.sort),n=r.length,o=n-e.length;if(o<0){for(var i=o;i<0;i++)this.addRule(e.length+i,!0);for(var u=0;u<n;u++)this.setValue(r[u],e[u])}else{if(o>0)for(var a=0;a<o;a++)this.removeRule(r[n-a-1]);e.forEach((function(n,o){t.setValue(r[o],e[o])}))}},deep:!0}},methods:{_value:function(e){return e&&(t=e,r=this.field,{}.hasOwnProperty.call(t,r))?e[this.field]:e;var t,r},cache:function(e,t){this.cacheValue[e]=JSON.stringify(t)},input:function(e){this.$emit("update:modelValue",e),this.$emit("change",e)},formData:function(e,t){var r=this,o=this.cacheRule,i=this.sort;if(i.filter((function(e){return o[e].$f})).length===i.length){var u=i.map((function(o){var i=e===o?t:n({},r.cacheRule[o].$f.form),u=r.field?i[r.field]||null:i;return r.cache(o,u),u}));this.input(u)}},setValue:function(e,t){var r=this.field;r&&(t=i({},r,this._value(t))),this.cacheValue[e]!==JSON.stringify(r?t[r]:t)&&this.cache(e,t)},addRule:function(e,r){var o=this,u=this.formCreateInject.form.copyRules(this.rule||[]),a=this.options?n({},this.options):{submitBtn:!1,resetBtn:!1};if(this.defaultValue){a.formData||(a.formData={});var c=f(this.defaultValue);!function(){d.apply(this,arguments)}(a.formData,this.field?i({},this.field,c):c)}this.parse&&this.parse({rule:u,options:a,index:this.sort.length}),this.cacheRule[++this.len]={rule:u,options:a},r&&t.nextTick((function(){return o.$emit("add",u,Object.keys(o.cacheRule).length-1)}))},add$f:function(e,r,n){var o=this;this.cacheRule[r].$f=n,t.nextTick((function(){o.$emit("itemMounted",n,Object.keys(o.cacheRule).indexOf(r))}))},removeRule:function(e,r){var n=this,o=Object.keys(this.cacheRule).indexOf(e);delete this.cacheRule[e],delete this.cacheValue[e],r&&t.nextTick((function(){return n.$emit("remove",o)}))},add:function(e){if(!this.disabled&&!1!==this.onBeforeAdd(this.modelValue)){var t=u(this.modelValue);t.push(this.defaultValue?f(this.defaultValue):this.field?null:{}),this.input(t)}},del:function(e,t){if(!this.disabled&&!1!==this.onBeforeRemove(this.modelValue,e)){this.removeRule(t,!0);var r=u(this.modelValue);r.splice(e,1),this.input(r)}},addIcon:function(e){return t.createVNode("div",{class:"_fc-group-btn _fc-group-plus-minus",onClick:this.add},null)},delIcon:function(e,r){var n=this;return t.createVNode("div",{class:"_fc-group-btn _fc-group-plus-minus _fc-group-minus",onClick:function(){return n.del(e,r)}},null)},sortUpIcon:function(e){var r=this;return t.createVNode("div",{class:"_fc-group-btn _fc-group-arrow _fc-group-up",onClick:function(){return r.changeSort(e,-1)}},null)},sortDownIcon:function(e){var r=this;return t.createVNode("div",{class:"_fc-group-btn _fc-group-arrow _fc-group-down",onClick:function(){return r.changeSort(e,1)}},null)},changeSort:function(e,t){var r=this.sort[e];this.sort[e]=this.sort[e+t],this.sort[e+t]=r,this.formData(0)},makeIcon:function(e,t,r){var n=this;if(this.$slots.button)return this.$slots.button({total:e,index:t,vm:this,key:r,del:function(){return n.del(t,r)},add:this.add});var o=[];return(!this.max||e<this.max)&&e===t+1&&o.push(this.addIcon(r)),e>this.min&&o.push(this.delIcon(t,r)),this.sortBtn&&t&&o.push(this.sortUpIcon(t)),this.sortBtn&&t!==e-1&&o.push(this.sortDownIcon(t)),o},emitEvent:function(e,t,r,n){this.$emit.apply(this,[e].concat(u(t),[this.cacheRule[n].$f,r]))},expandRule:function(e){for(var t=0;t<e;t++)this.addRule(t)}},created:function(){var e=this;t.watch((function(){return n({},e.cacheRule)}),(function(t){e.sort=Object.keys(t)}),{immediate:!0});for(var r=(this.expand||0)-this.modelValue.length,o=0;o<this.modelValue.length;o++)this.addRule(o);r>0&&this.expandRule(r)},render:function(){var e=this,r=this.sort,n=this.button,o=this.form,u=this.disabled,a=0===r.length?this.$slots.default?this.$slots.default({vm:this,add:this.add}):t.createVNode("div",{key:"a_def",class:"_fc-group-plus-minus _fc-group-add fc-clock",onClick:this.add},null):r.map((function(a,c){var l=e.cacheRule[a],s=l.rule,f=l.options,d=n&&!u?e.makeIcon(r.length,c,a):[];return t.createVNode("div",{class:"_fc-group-container",key:a},[t.createVNode(o,t.mergeProps({key:a},{disabled:u,"onUpdate:modelValue":function(t){return e.formData(a,t)},"onEmit-event":function(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];return e.emitEvent(t,n,c,a)},"onUpdate:api":function(t){return e.add$f(c,a,t)},inFor:!0,modelValue:e.field?i({},e.field,e._value(e.modelValue[c])):e.modelValue[c],rule:s,option:f,extendOption:!0}),null),t.createVNode("div",{class:"_fc-group-idx"},[c+1]),d.length?t.createVNode("div",{class:"_fc-group-handle fc-clock"},[d]):null])}));return t.createVNode("div",{key:"con",class:"_fc-group "+(u?"_fc-group-disabled":"")},[a])}});e.default=p,Object.defineProperty(e,"__esModule",{value:!0})}));
7
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("vue")):"function"==typeof define&&define.amd?define(["exports","vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).FcGroup={},e.Vue)}(this,(function(e,t){"use strict";function r(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function n(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((function(t){i(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function o(e){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o(e)}function i(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function u(e){return function(e){if(Array.isArray(e))return a(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||function(e,t){if(!e)return;if("string"==typeof e)return a(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);"Object"===r&&e.constructor&&(r=e.constructor.name);if("Map"===r||"Set"===r)return Array.from(e);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return a(e,t)}(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}var c={type:function(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"},Undef:function(e){return null==e},Element:function(e){return"object"===o(e)&&null!==e&&1===e.nodeType&&!c.Object(e)},trueArray:function(e){return Array.isArray(e)&&e.length>0},Function:function(e){var t=this.getType(e);return"Function"===t||"AsyncFunction"===t},getType:function(e){var t=Object.prototype.toString.call(e);return/^\[object (.*)\]$/.exec(t)[1]},empty:function(e){return null==e||(!(!Array.isArray(e)||!Array.isArray(e)||e.length)||"string"==typeof e&&!e)}};function l(e,t,r){e[t]=r}function s(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=arguments.length>2?arguments[2]:void 0,n=!1;for(var o in t)if(Object.prototype.hasOwnProperty.call(t,o)){var i=t[o];if((n=Array.isArray(i))||c.Object(i)){var u=void 0===e[o];if(n)n=!1,u&&l(e,o,[]);else if(i._clone&&void 0!==r){if(!r){l(e,o,i._clone());continue}i=i.getRule(),u&&l(e,o,{})}else u&&l(e,o,{});e[o]=s(e[o],i,r)}else l(e,o,i),c.Undef(i)||(c.Undef(i.__json)||(e[o].__json=i.__json),c.Undef(i.__origin)||(e[o].__origin=i.__origin))}return void 0!==r&&Array.isArray(e)?e.filter((function(e){return!e||!e.__ctrl})):e}function f(e){return s({},{value:e}).value}["Date","Object","String","Boolean","Array","Number"].forEach((function(e){c[e]=function(t){return c.type(t,e)}}));var d=Object.assign||function(e){for(var t,r=1;r<arguments.length;r++)for(var n in t=arguments[r])Object.prototype.hasOwnProperty.call(t,n)&&l(e,n,t[n]);return e};!function(e,t){void 0===t&&(t={});var r=t.insertAt;if(e&&"undefined"!=typeof document){var n=document.head||document.getElementsByTagName("head")[0],o=document.createElement("style");o.type="text/css","top"===r&&n.firstChild?n.insertBefore(o,n.firstChild):n.appendChild(o),o.styleSheet?o.styleSheet.cssText=e:o.appendChild(document.createTextNode(e))}}('._fc-group{display:flex;flex-direction:column;justify-content:center;min-height:38px;width:100%}._fc-group-disabled ._fc-group-add,._fc-group-disabled ._fc-group-btn{cursor:not-allowed}._fc-group-handle{background-color:#fff;border:1px dashed #d9d9d9;border-radius:15px;bottom:-15px;display:flex;flex-direction:row;padding:3px 8px;position:absolute;right:30px}._fc-group-btn{cursor:pointer}._fc-group-idx{align-items:center;background:#eee;border-radius:15px;bottom:-15px;display:flex;font-weight:700;height:30px;justify-content:center;left:10px;position:absolute;width:30px}._fc-group-handle ._fc-group-btn+._fc-group-btn{margin-left:7px}._fc-group-container{border:1px dashed #d9d9d9;border-radius:5px;display:flex;flex-direction:column;margin:5px 5px 25px;padding:20px 20px 25px;position:relative}._fc-group-arrow{height:20px;position:relative;width:20px}._fc-group-arrow:before{border-left:2px solid #999;border-top:2px solid #999;content:"";height:9px;left:5px;position:absolute;top:8px;transform:rotate(45deg);width:9px}._fc-group-arrow._fc-group-down{transform:rotate(180deg)}._fc-group-plus-minus{cursor:pointer;height:20px;position:relative;width:20px}._fc-group-plus-minus:after,._fc-group-plus-minus:before{background-color:#409eff;content:"";height:2px;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%);width:60%}._fc-group-plus-minus:before{transform:translate(-50%,-50%) rotate(90deg)}._fc-group-plus-minus._fc-group-minus:before{display:none}._fc-group-plus-minus._fc-group-minus:after{background-color:#f56c6c}._fc-group-add{border:1px solid rgba(64,158,255,.5);border-radius:15px;cursor:pointer;height:25px;width:25px}._fc-group-add._fc-group-plus-minus:after,._fc-group-add._fc-group-plus-minus:before{width:50%}');var p=t.defineComponent({name:"fcGroup",props:{field:String,rule:Array,expand:Number,options:Object,button:{type:Boolean,default:!0},max:{type:Number,default:0},min:{type:Number,default:0},modelValue:{type:Array,default:function(){return[]}},defaultValue:Object,sortBtn:{type:Boolean,default:!0},disabled:{type:Boolean,default:!1},syncDisabled:{type:Boolean,default:!0},onBeforeRemove:{type:Function,default:function(){}},onBeforeAdd:{type:Function,default:function(){}},formCreateInject:Object,parse:Function},data:function(){return{len:0,cacheRule:{},cacheValue:{},sort:[],form:t.markRaw(this.formCreateInject.form.$form())}},emits:["update:modelValue","change","itemMounted","remove","add"],watch:{rule:{handler:function(e,t){var r=this;Object.keys(this.cacheRule).forEach((function(n){var o=r.cacheRule[n];if(o.$f){var i=o.$f.formData();if(e===t)o.$f.deferSyncValue((function(){s(o.rule,e),o.$f.setValue(i)}),!0);else{var u=o.$f.formData();o.$f.once("reloading",(function(){o.$f.setValue(u)})),o.rule=f(e)}}}))},deep:!0},expand:function(e){var t=e-this.modelValue.length;t>0&&this.expandRule(t)},modelValue:{handler:function(e){var t=this;e=e||[];var r=this.sort,n=r.length,o=n-e.length;if(o<0){for(var i=o;i<0;i++)this.addRule(e.length+i,!0);for(var u=0;u<n;u++)this.setValue(r[u],e[u])}else{if(o>0)for(var a=0;a<o;a++)this.removeRule(r[n-a-1]);e.forEach((function(n,o){t.setValue(r[o],e[o])}))}},deep:!0}},methods:{_value:function(e){return e&&(t=e,r=this.field,{}.hasOwnProperty.call(t,r))?e[this.field]:e;var t,r},cache:function(e,t){this.cacheValue[e]=JSON.stringify(t)},input:function(e){this.$emit("update:modelValue",e),this.$emit("change",e)},formData:function(e,t){var r=this,o=this.cacheRule,i=this.sort;if(i.filter((function(e){return o[e].$f})).length===i.length){var u=i.map((function(o){var i=e===o?t:n({},r.cacheRule[o].$f.form),u=r.field?i[r.field]||null:i;return r.cache(o,u),u}));this.input(u)}},setValue:function(e,t){var r=this.field;r&&(t=i({},r,this._value(t))),this.cacheValue[e]!==JSON.stringify(r?t[r]:t)&&this.cache(e,t)},addRule:function(e,r){var o=this,u=this.formCreateInject.form.copyRules(this.rule||[]),a=this.options?n({},this.options):{submitBtn:!1,resetBtn:!1};if(this.defaultValue){a.formData||(a.formData={});var c=f(this.defaultValue);!function(){d.apply(this,arguments)}(a.formData,this.field?i({},this.field,c):c)}this.parse&&this.parse({rule:u,options:a,index:this.sort.length}),this.cacheRule[++this.len]={rule:u,options:a},r&&t.nextTick((function(){return o.$emit("add",u,Object.keys(o.cacheRule).length-1)}))},add$f:function(e,r,n){var o=this;this.cacheRule[r].$f=n,t.nextTick((function(){o.$emit("itemMounted",n,Object.keys(o.cacheRule).indexOf(r))}))},removeRule:function(e,r){var n=this,o=Object.keys(this.cacheRule).indexOf(e);delete this.cacheRule[e],delete this.cacheValue[e],r&&t.nextTick((function(){return n.$emit("remove",o)}))},add:function(e){if(!this.disabled&&!1!==this.onBeforeAdd(this.modelValue)){var t=u(this.modelValue);t.push(this.defaultValue?f(this.defaultValue):this.field?null:{}),this.input(t)}},del:function(e,t){if(!this.disabled&&!1!==this.onBeforeRemove(this.modelValue,e)){this.removeRule(t,!0);var r=u(this.modelValue);r.splice(e,1),this.input(r)}},addIcon:function(e){return t.createVNode("div",{class:"_fc-group-btn _fc-group-plus-minus",onClick:this.add},null)},delIcon:function(e,r){var n=this;return t.createVNode("div",{class:"_fc-group-btn _fc-group-plus-minus _fc-group-minus",onClick:function(){return n.del(e,r)}},null)},sortUpIcon:function(e){var r=this;return t.createVNode("div",{class:"_fc-group-btn _fc-group-arrow _fc-group-up",onClick:function(){return r.changeSort(e,-1)}},null)},sortDownIcon:function(e){var r=this;return t.createVNode("div",{class:"_fc-group-btn _fc-group-arrow _fc-group-down",onClick:function(){return r.changeSort(e,1)}},null)},changeSort:function(e,t){var r=this,n=this.sort[e];this.sort[e]=this.sort[e+t],this.sort[e+t]=n,this.formCreateInject.subForm(this.sort.map((function(e){return r.cacheRule[e].$f}))),this.formData(0)},makeIcon:function(e,t,r){var n=this;if(this.$slots.button)return this.$slots.button({total:e,index:t,vm:this,key:r,del:function(){return n.del(t,r)},add:this.add});var o=[];return(!this.max||e<this.max)&&e===t+1&&o.push(this.addIcon(r)),e>this.min&&o.push(this.delIcon(t,r)),this.sortBtn&&t&&o.push(this.sortUpIcon(t)),this.sortBtn&&t!==e-1&&o.push(this.sortDownIcon(t)),o},emitEvent:function(e,t,r,n){this.$emit.apply(this,[e].concat(u(t),[this.cacheRule[n].$f,r]))},expandRule:function(e){for(var t=0;t<e;t++)this.addRule(t)}},created:function(){var e=this;t.watch((function(){return n({},e.cacheRule)}),(function(t){e.sort=Object.keys(t)}),{immediate:!0});for(var r=(this.expand||0)-this.modelValue.length,o=0;o<this.modelValue.length;o++)this.addRule(o);r>0&&this.expandRule(r)},render:function(){var e=this,r=this.sort,n=this.button,o=this.form,u=this.disabled,a=0===r.length?this.$slots.default?this.$slots.default({vm:this,add:this.add}):t.createVNode("div",{key:"a_def",class:"_fc-group-plus-minus _fc-group-add fc-clock",onClick:this.add},null):r.map((function(a,c){var l=e.cacheRule[a],s=l.rule,f=l.options,d=n&&!u?e.makeIcon(r.length,c,a):[];return t.createVNode("div",{class:"_fc-group-container",key:a},[t.createVNode(o,t.mergeProps({key:a},{disabled:u,"onUpdate:modelValue":function(t){return e.formData(a,t)},"onEmit-event":function(t){for(var r=arguments.length,n=new Array(r>1?r-1:0),o=1;o<r;o++)n[o-1]=arguments[o];return e.emitEvent(t,n,c,a)},"onUpdate:api":function(t){return e.add$f(c,a,t)},inFor:!0,modelValue:e.field?i({},e.field,e._value(e.modelValue[c])):e.modelValue[c],rule:s,option:f,extendOption:!0}),null),t.createVNode("div",{class:"_fc-group-idx"},[c+1]),d.length?t.createVNode("div",{class:"_fc-group-handle fc-clock"},[d]):null])}));return t.createVNode("div",{key:"con",class:"_fc-group "+(u?"_fc-group-disabled":"")},[a])}});e.default=p,Object.defineProperty(e,"__esModule",{value:!0})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@form-create/component-antdv-group",
3
- "version": "3.2.0",
3
+ "version": "3.2.8",
4
4
  "description": "@form-create/ant-design-vue 内置组件",
5
5
  "main": "./dist/index.min.js",
6
6
  "module": "./dist/index.esm.js",
@@ -56,5 +56,5 @@
56
56
  "esm"
57
57
  ]
58
58
  },
59
- "gitHead": "551b0e9acfcfd4e9a583880dc4fb5f96fe65d6a5"
59
+ "gitHead": "a64cd14badae9148882fd1b0ceedca3cdb51957b"
60
60
  }
package/src/component.jsx CHANGED
@@ -99,7 +99,7 @@ export default defineComponent({
99
99
  modelValue: {
100
100
  handler(n) {
101
101
  n = n || [];
102
- let keys = Object.keys(this.sort), total = keys.length, len = total - n.length;
102
+ let keys = this.sort, total = keys.length, len = total - n.length;
103
103
  if (len < 0) {
104
104
  for (let i = len; i < 0; i++) {
105
105
  this.addRule(n.length + i, true);
@@ -223,6 +223,9 @@ export default defineComponent({
223
223
  const a = this.sort[index];
224
224
  this.sort[index] = this.sort[index + sort];
225
225
  this.sort[index + sort] = a;
226
+ this.formCreateInject.subForm(this.sort.map(k=>{
227
+ return this.cacheRule[k].$f;
228
+ }));
226
229
  this.formData(0);
227
230
  },
228
231
  makeIcon(total, index, key) {