@form-create/component-antdv-group 3.0.0-alpha.4 → 3.1.2

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/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2021 xaboy
3
+ Copyright (c) 2022 xaboy
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  @form-create/ant-design-vue 内置组件
4
4
 
5
- [GitHub](https://github.com/xaboy/form-create) | [文档](http://form-create.com/v2/) | [Document](http://form-create.com/en/v2/)
5
+ [GitHub](https://github.com/xaboy/form-create) | [文档](http://form-create.com/v3/) | [Document](http://form-create.com/v3/)
6
6
 
package/dist/index.esm.js CHANGED
@@ -1,11 +1,10 @@
1
1
  /*!
2
- * @form-create/component-antdv-group v3.0.0-alpha.4
2
+ * @form-create/component-antdv-group v3.1.2
3
3
  * (c) 2018-2022 xaboy
4
4
  * Github https://github.com/xaboy/form-create with group
5
5
  * Released under the MIT License.
6
6
  */
7
- import { defineComponent, markRaw, nextTick, createVNode, resolveComponent, isVNode } from 'vue';
8
- import { PlusCircleOutlined, MinusCircleOutlined } from '@ant-design/icons-vue';
7
+ import { openBlock, createElementBlock, createElementVNode, defineComponent, markRaw, nextTick, createVNode, resolveComponent, isVNode } from 'vue';
9
8
 
10
9
  function ownKeys(object, enumerableOnly) {
11
10
  var keys = Object.keys(object);
@@ -132,6 +131,62 @@ function hasProperty(rule, k) {
132
131
  return {}.hasOwnProperty.call(rule, k);
133
132
  }
134
133
 
134
+ var script$1 = {
135
+ name: 'MinusCircleOutlined'
136
+ };
137
+
138
+ var _hoisted_1$1 = {
139
+ "class": "anticon"
140
+ };
141
+
142
+ var _hoisted_2$1 = /*#__PURE__*/createElementVNode("svg", {
143
+ height: "1em",
144
+ width: "1em",
145
+ xmlns: "http://www.w3.org/2000/svg",
146
+ viewBox: "0 0 1024 1024"
147
+ }, [/*#__PURE__*/createElementVNode("path", {
148
+ d: "M696 480H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h368c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z",
149
+ fill: "currentColor"
150
+ }), /*#__PURE__*/createElementVNode("path", {
151
+ d: "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448s448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372s372 166.6 372 372s-166.6 372-372 372z",
152
+ fill: "currentColor"
153
+ })], -1);
154
+
155
+ var _hoisted_3$1 = [_hoisted_2$1];
156
+ function render$1(_ctx, _cache, $props, $setup, $data, $options) {
157
+ return openBlock(), createElementBlock("span", _hoisted_1$1, _hoisted_3$1);
158
+ }
159
+
160
+ script$1.render = render$1;
161
+
162
+ var script = {
163
+ name: 'PlusCircleOutlined'
164
+ };
165
+
166
+ var _hoisted_1 = {
167
+ "class": "anticon"
168
+ };
169
+
170
+ var _hoisted_2 = /*#__PURE__*/createElementVNode("svg", {
171
+ height: "1em",
172
+ width: "1em",
173
+ xmlns: "http://www.w3.org/2000/svg",
174
+ viewBox: "0 0 1024 1024"
175
+ }, [/*#__PURE__*/createElementVNode("path", {
176
+ d: "M696 480H544V328c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v152H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h152v152c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V544h152c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z",
177
+ fill: "currentColor"
178
+ }), /*#__PURE__*/createElementVNode("path", {
179
+ d: "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448s448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372s372 166.6 372 372s-166.6 372-372 372z",
180
+ fill: "currentColor"
181
+ })], -1);
182
+
183
+ var _hoisted_3 = [_hoisted_2];
184
+ function render(_ctx, _cache, $props, $setup, $data, $options) {
185
+ return openBlock(), createElementBlock("span", _hoisted_1, _hoisted_3);
186
+ }
187
+
188
+ script.render = render;
189
+
135
190
  function _isSlot(s) {
136
191
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
137
192
  }
@@ -181,9 +236,9 @@ var Group = defineComponent({
181
236
  onBeforeAdd: {
182
237
  type: Function,
183
238
  "default": function _default() {}
184
- }
239
+ },
240
+ formCreateInject: Object
185
241
  },
186
- inject: ['formCreateInject'],
187
242
  data: function data() {
188
243
  return {
189
244
  len: 0,
@@ -361,7 +416,7 @@ var Group = defineComponent({
361
416
  this.input(this.modelValue);
362
417
  },
363
418
  addIcon: function addIcon(key) {
364
- return createVNode(PlusCircleOutlined, {
419
+ return createVNode(script, {
365
420
  "key": "a".concat(key),
366
421
  "style": "font-size:".concat(this.fontSize, "px;cursor:").concat(this.disabled ? 'not-allowed;color:#c9cdd4' : 'pointer', ";"),
367
422
  "onClick": this.add
@@ -370,7 +425,7 @@ var Group = defineComponent({
370
425
  delIcon: function delIcon(index, key) {
371
426
  var _this7 = this;
372
427
 
373
- return createVNode(MinusCircleOutlined, {
428
+ return createVNode(script$1, {
374
429
  "key": "d".concat(key),
375
430
  "style": "font-size:".concat(this.fontSize, "px;cursor:").concat(this.disabled ? 'not-allowed;color:#c9cdd4' : 'pointer;color:#606266', ";"),
376
431
  "onClick": function onClick() {
@@ -431,12 +486,12 @@ var Group = defineComponent({
431
486
  return keys.length === 0 ? this.$slots["default"] ? this.$slots["default"]({
432
487
  vm: this,
433
488
  add: this.add
434
- }) : createVNode(PlusCircleOutlined, {
435
- "key": 'a_def',
489
+ }) : createVNode(script, {
490
+ "key": 1,
436
491
  "style": "font-size:".concat(this.fontSize, "px;vertical-align:middle;color:").concat(this.disabled ? '#c9cdd4;cursor: not-allowed' : '#606266;cursor:pointer', ";"),
437
492
  "onClick": this.add
438
493
  }, null) : createVNode("div", {
439
- "key": 'con'
494
+ "key": 2
440
495
  }, [keys.map(function (key, index) {
441
496
  var _slot;
442
497
 
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * @form-create/component-antdv-group v3.0.0-alpha.4
2
+ * @form-create/component-antdv-group v3.1.2
3
3
  * (c) 2018-2022 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 e,markRaw as t,nextTick as n,createVNode as o,resolveComponent as r,isVNode as i}from"vue";import{PlusCircleOutlined as l,MinusCircleOutlined as u}from"@ant-design/icons-vue";function a(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function c(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?a(Object(n),!0).forEach((function(t){f(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):a(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function s(e){return s="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},s(e)}function f(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function d(e){return function(e){if(Array.isArray(e))return h(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 h(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return h(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 h(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}var m={type:function(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"},Undef:function(e){return null==e},Element:function(e){return"object"===s(e)&&null!==e&&1===e.nodeType&&!m.Object(e)},trueArray:function(e){return Array.isArray(e)&&e.length>0}};["Date","Object","Function","String","Boolean","Array","Number"].forEach((function(e){m[e]=function(t){return m.type(t,e)}}));var p=e({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[]}},disabled:{type:Boolean,default:!1},syncDisabled:{type:Boolean,default:!0},fontSize:{type:Number,default:28},onBeforeRemove:{type:Function,default:function(){}},onBeforeAdd:{type:Function,default:function(){}}},inject:["formCreateInject"],data:function(){return{len:0,cacheRule:{},cacheValue:{},form:t(this.formCreateInject.form.$form())}},emits:["update:modelValue","change","itemMounted","remove"],watch:{disabled:function(e){if(this.syncDisabled){var t=this.cacheRule;Object.keys(t).forEach((function(n){t[n].$f.disabled(e)}))}},expand:function(e){var t=e-this.modelValue.length;t>0&&this.expandRule(t)},modelValue:{handler:function(e){var t=this;e=e||[];var n=Object.keys(this.cacheRule),o=n.length,r=o-e.length;if(r<0){for(var i=r;i<0;i++)this.addRule(e.length+i);for(var l=0;l<o;l++)this.setValue(n[l],e[l])}else{if(r>0){for(var u=0;u<r;u++)this.removeRule(n[o-u-1]);this.subForm()}e.forEach((function(o,r){t.setValue(n[r],e[r])}))}},deep:!0,flush:"post"}},methods:{_value:function(e){return e&&(t=e,n=this.field,{}.hasOwnProperty.call(t,n))?e[this.field]:e;var t,n},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 n=this,o=this.cacheRule,r=Object.keys(o);if(r.filter((function(e){return o[e].$f})).length===r.length){var i=r.map((function(o){var r=e===o?t:c({},n.cacheRule[o].$f.form),i=n.field?r[n.field]||null:r;return n.cache(o,i),i}));this.input(i)}},setValue:function(e,t){var n=this.field;n&&(t=f({},n,this._value(t))),this.cacheValue[e]!==JSON.stringify(n?t[n]:t)&&this.cache(e,t)},addRule:function(e,t){var o=this,r=this.formCreateInject.form.copyRules(this.rule||[]),i=this.options?c({},this.options):{submitBtn:!1,resetBtn:!1};this.cacheRule[++this.len]={rule:r,options:i},t&&n((function(){return o.$emit("add",r,Object.keys(o.cacheRule).length-1)}))},add$f:function(e,t,o){var r=this;this.cacheRule[t].$f=o,this.subForm(),n((function(){r.syncDisabled&&o.disabled(r.disabled),r.$emit("itemMounted",o,Object.keys(r.cacheRule).indexOf(t))}))},subForm:function(){var e=this;this.formCreateInject.subForm(Object.keys(this.cacheRule).map((function(t){return e.cacheRule[t].$f})))},removeRule:function(e,t){var o=this,r=Object.keys(this.cacheRule).indexOf(e);delete this.cacheRule[e],delete this.cacheValue[e],t&&n((function(){return o.$emit("remove",r)}))},add:function(){this.disabled||!1===this.onBeforeAdd(this.modelValue)||(this.modelValue.push(this.field?null:{}),this.$emit("update:modelValue",this.modelValue))},del:function(e,t){this.disabled||!1===this.onBeforeRemove(this.modelValue,e)||(this.removeRule(t,!0),this.subForm(),this.modelValue.splice(e,1),this.input(this.modelValue))},addIcon:function(e){return o(l,{key:"a".concat(e),style:"font-size:".concat(this.fontSize,"px;cursor:").concat(this.disabled?"not-allowed;color:#c9cdd4":"pointer",";"),onClick:this.add},null)},delIcon:function(e,t){var n=this;return o(u,{key:"d".concat(t),style:"font-size:".concat(this.fontSize,"px;cursor:").concat(this.disabled?"not-allowed;color:#c9cdd4":"pointer;color:#606266",";"),onClick:function(){return n.del(e,t)}},null)},makeIcon:function(e,t,n){var o=this;return this.$slots.button?this.$slots.button({total:e,index:t,vm:this,key:n,del:function(){return o.del(t,n)},add:this.add}):0===t?[0!==this.max&&e>=this.max?null:this.addIcon(n),0===this.min||e>this.min?this.delIcon(t,n):null]:t>=this.min?this.delIcon(t,n):void 0},emitEvent:function(e,t,n,o){this.$emit.apply(this,[e].concat(d(t),[this.cacheRule[o].$f,n]))},expandRule:function(e){for(var t=0;t<e;t++)this.modelValue.push(this.field?null:{})}},created:function(){for(var e=(this.expand||0)-this.modelValue.length,t=0;t<this.modelValue.length;t++)this.addRule(t);e>0&&this.expandRule(e)},render:function(){var e=this,t=Object.keys(this.cacheRule),n=this.button,u=this.form;return 0===t.length?this.$slots.default?this.$slots.default({vm:this,add:this.add}):o(l,{key:"a_def",style:"font-size:".concat(this.fontSize,"px;vertical-align:middle;color:").concat(this.disabled?"#c9cdd4;cursor: not-allowed":"#606266;cursor:pointer",";"),onClick:this.add},null):o("div",{key:"con"},[t.map((function(l,a){var c,s=e.cacheRule[l],d=s.rule,h=s.options;return o(r("aRow"),{align:"middle",type:"flex",key:l,style:"border-bottom:1px dashed #DCDFE6;margin-bottom:10px;"},{default:function(){return[o(r("aCol"),{span:n?20:24},{default:function(){return[o(u,{key:l,"onUpdate:modelValue":function(t){return e.formData(l,t)},modelValue:e.field?f({},e.field,e._value(e.modelValue[a])):e.modelValue[a],"onEmit-event":function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return e.emitEvent(t,o,a,l)},"onUpdate:api":function(t){return e.add$f(a,l,t)},rule:d,option:h,extendOption:!0},null)]}}),n?o(r("aCol"),{span:2,pull:1,push:1},(s=c=e.makeIcon(t.length,a,l),"function"==typeof s||"[object Object]"===Object.prototype.toString.call(s)&&!i(s)?c:{default:function(){return[c]}})):null];var s}})}))])}});export{p as default};
7
+ import{openBlock as e,createElementBlock as t,createElementVNode as n,defineComponent as r,markRaw as o,nextTick as i,createVNode as l,resolveComponent as u,isVNode as a}from"vue";function c(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function s(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?c(Object(n),!0).forEach((function(t){d(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):c(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function f(e){return f="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},f(e)}function d(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function h(e){return function(e){if(Array.isArray(e))return m(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 m(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return m(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 m(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}var p={type:function(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"},Undef:function(e){return null==e},Element:function(e){return"object"===f(e)&&null!==e&&1===e.nodeType&&!p.Object(e)},trueArray:function(e){return Array.isArray(e)&&e.length>0}};["Date","Object","Function","String","Boolean","Array","Number"].forEach((function(e){p[e]=function(t){return p.type(t,e)}}));var y={name:"MinusCircleOutlined"},b={class:"anticon"},v=[n("svg",{height:"1em",width:"1em",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[n("path",{d:"M696 480H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h368c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z",fill:"currentColor"}),n("path",{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448s448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372s372 166.6 372 372s-166.6 372-372 372z",fill:"currentColor"})],-1)];y.render=function(n,r,o,i,l,u){return e(),t("span",b,v)};var g={name:"PlusCircleOutlined"},O={class:"anticon"},j=[n("svg",{height:"1em",width:"1em",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[n("path",{d:"M696 480H544V328c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v152H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h152v152c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V544h152c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z",fill:"currentColor"}),n("path",{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448s448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372s372 166.6 372 372s-166.6 372-372 372z",fill:"currentColor"})],-1)];g.render=function(n,r,o,i,l,u){return e(),t("span",O,j)};var w=r({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[]}},disabled:{type:Boolean,default:!1},syncDisabled:{type:Boolean,default:!0},fontSize:{type:Number,default:28},onBeforeRemove:{type:Function,default:function(){}},onBeforeAdd:{type:Function,default:function(){}},formCreateInject:Object},data:function(){return{len:0,cacheRule:{},cacheValue:{},form:o(this.formCreateInject.form.$form())}},emits:["update:modelValue","change","itemMounted","remove"],watch:{disabled:function(e){if(this.syncDisabled){var t=this.cacheRule;Object.keys(t).forEach((function(n){t[n].$f.disabled(e)}))}},expand:function(e){var t=e-this.modelValue.length;t>0&&this.expandRule(t)},modelValue:{handler:function(e){var t=this;e=e||[];var n=Object.keys(this.cacheRule),r=n.length,o=r-e.length;if(o<0){for(var i=o;i<0;i++)this.addRule(e.length+i);for(var l=0;l<r;l++)this.setValue(n[l],e[l])}else{if(o>0){for(var u=0;u<o;u++)this.removeRule(n[r-u-1]);this.subForm()}e.forEach((function(r,o){t.setValue(n[o],e[o])}))}},deep:!0,flush:"post"}},methods:{_value:function(e){return e&&(t=e,n=this.field,{}.hasOwnProperty.call(t,n))?e[this.field]:e;var t,n},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 n=this,r=this.cacheRule,o=Object.keys(r);if(o.filter((function(e){return r[e].$f})).length===o.length){var i=o.map((function(r){var o=e===r?t:s({},n.cacheRule[r].$f.form),i=n.field?o[n.field]||null:o;return n.cache(r,i),i}));this.input(i)}},setValue:function(e,t){var n=this.field;n&&(t=d({},n,this._value(t))),this.cacheValue[e]!==JSON.stringify(n?t[n]:t)&&this.cache(e,t)},addRule:function(e,t){var n=this,r=this.formCreateInject.form.copyRules(this.rule||[]),o=this.options?s({},this.options):{submitBtn:!1,resetBtn:!1};this.cacheRule[++this.len]={rule:r,options:o},t&&i((function(){return n.$emit("add",r,Object.keys(n.cacheRule).length-1)}))},add$f:function(e,t,n){var r=this;this.cacheRule[t].$f=n,this.subForm(),i((function(){r.syncDisabled&&n.disabled(r.disabled),r.$emit("itemMounted",n,Object.keys(r.cacheRule).indexOf(t))}))},subForm:function(){var e=this;this.formCreateInject.subForm(Object.keys(this.cacheRule).map((function(t){return e.cacheRule[t].$f})))},removeRule:function(e,t){var n=this,r=Object.keys(this.cacheRule).indexOf(e);delete this.cacheRule[e],delete this.cacheValue[e],t&&i((function(){return n.$emit("remove",r)}))},add:function(){this.disabled||!1===this.onBeforeAdd(this.modelValue)||(this.modelValue.push(this.field?null:{}),this.$emit("update:modelValue",this.modelValue))},del:function(e,t){this.disabled||!1===this.onBeforeRemove(this.modelValue,e)||(this.removeRule(t,!0),this.subForm(),this.modelValue.splice(e,1),this.input(this.modelValue))},addIcon:function(e){return l(g,{key:"a".concat(e),style:"font-size:".concat(this.fontSize,"px;cursor:").concat(this.disabled?"not-allowed;color:#c9cdd4":"pointer",";"),onClick:this.add},null)},delIcon:function(e,t){var n=this;return l(y,{key:"d".concat(t),style:"font-size:".concat(this.fontSize,"px;cursor:").concat(this.disabled?"not-allowed;color:#c9cdd4":"pointer;color:#606266",";"),onClick:function(){return n.del(e,t)}},null)},makeIcon:function(e,t,n){var r=this;return this.$slots.button?this.$slots.button({total:e,index:t,vm:this,key:n,del:function(){return r.del(t,n)},add:this.add}):0===t?[0!==this.max&&e>=this.max?null:this.addIcon(n),0===this.min||e>this.min?this.delIcon(t,n):null]:t>=this.min?this.delIcon(t,n):void 0},emitEvent:function(e,t,n,r){this.$emit.apply(this,[e].concat(h(t),[this.cacheRule[r].$f,n]))},expandRule:function(e){for(var t=0;t<e;t++)this.modelValue.push(this.field?null:{})}},created:function(){for(var e=(this.expand||0)-this.modelValue.length,t=0;t<this.modelValue.length;t++)this.addRule(t);e>0&&this.expandRule(e)},render:function(){var e=this,t=Object.keys(this.cacheRule),n=this.button,r=this.form;return 0===t.length?this.$slots.default?this.$slots.default({vm:this,add:this.add}):l(g,{key:1,style:"font-size:".concat(this.fontSize,"px;vertical-align:middle;color:").concat(this.disabled?"#c9cdd4;cursor: not-allowed":"#606266;cursor:pointer",";"),onClick:this.add},null):l("div",{key:2},[t.map((function(o,i){var c,s=e.cacheRule[o],f=s.rule,h=s.options;return l(u("aRow"),{align:"middle",type:"flex",key:o,style:"border-bottom:1px dashed #DCDFE6;margin-bottom:10px;"},{default:function(){return[l(u("aCol"),{span:n?20:24},{default:function(){return[l(r,{key:o,"onUpdate:modelValue":function(t){return e.formData(o,t)},modelValue:e.field?d({},e.field,e._value(e.modelValue[i])):e.modelValue[i],"onEmit-event":function(t){for(var n=arguments.length,r=new Array(n>1?n-1:0),l=1;l<n;l++)r[l-1]=arguments[l];return e.emitEvent(t,r,i,o)},"onUpdate:api":function(t){return e.add$f(i,o,t)},rule:f,option:h,extendOption:!0},null)]}}),n?l(u("aCol"),{span:2,pull:1,push:1},(s=c=e.makeIcon(t.length,i,o),"function"==typeof s||"[object Object]"===Object.prototype.toString.call(s)&&!a(s)?c:{default:function(){return[c]}})):null];var s}})}))])}});export{w as default};
package/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  /*!
2
- * @form-create/component-antdv-group v3.0.0-alpha.4
2
+ * @form-create/component-antdv-group v3.1.2
3
3
  * (c) 2018-2022 xaboy
4
4
  * Github https://github.com/xaboy/form-create with group
5
5
  * Released under the MIT License.
6
6
  */
7
7
  (function (global, factory) {
8
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue'), require('@ant-design/icons-vue')) :
9
- typeof define === 'function' && define.amd ? define(['exports', 'vue', '@ant-design/icons-vue'], factory) :
10
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.FcGroup = {}, global.Vue, global.iconsVue));
11
- })(this, (function (exports, vue, iconsVue) { 'use strict';
8
+ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vue')) :
9
+ typeof define === 'function' && define.amd ? define(['exports', 'vue'], factory) :
10
+ (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.FcGroup = {}, global.Vue));
11
+ })(this, (function (exports, vue) { 'use strict';
12
12
 
13
13
  function ownKeys(object, enumerableOnly) {
14
14
  var keys = Object.keys(object);
@@ -135,6 +135,62 @@
135
135
  return {}.hasOwnProperty.call(rule, k);
136
136
  }
137
137
 
138
+ var script$1 = {
139
+ name: 'MinusCircleOutlined'
140
+ };
141
+
142
+ var _hoisted_1$1 = {
143
+ "class": "anticon"
144
+ };
145
+
146
+ var _hoisted_2$1 = /*#__PURE__*/vue.createElementVNode("svg", {
147
+ height: "1em",
148
+ width: "1em",
149
+ xmlns: "http://www.w3.org/2000/svg",
150
+ viewBox: "0 0 1024 1024"
151
+ }, [/*#__PURE__*/vue.createElementVNode("path", {
152
+ d: "M696 480H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h368c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z",
153
+ fill: "currentColor"
154
+ }), /*#__PURE__*/vue.createElementVNode("path", {
155
+ d: "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448s448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372s372 166.6 372 372s-166.6 372-372 372z",
156
+ fill: "currentColor"
157
+ })], -1);
158
+
159
+ var _hoisted_3$1 = [_hoisted_2$1];
160
+ function render$1(_ctx, _cache, $props, $setup, $data, $options) {
161
+ return vue.openBlock(), vue.createElementBlock("span", _hoisted_1$1, _hoisted_3$1);
162
+ }
163
+
164
+ script$1.render = render$1;
165
+
166
+ var script = {
167
+ name: 'PlusCircleOutlined'
168
+ };
169
+
170
+ var _hoisted_1 = {
171
+ "class": "anticon"
172
+ };
173
+
174
+ var _hoisted_2 = /*#__PURE__*/vue.createElementVNode("svg", {
175
+ height: "1em",
176
+ width: "1em",
177
+ xmlns: "http://www.w3.org/2000/svg",
178
+ viewBox: "0 0 1024 1024"
179
+ }, [/*#__PURE__*/vue.createElementVNode("path", {
180
+ d: "M696 480H544V328c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v152H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h152v152c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V544h152c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z",
181
+ fill: "currentColor"
182
+ }), /*#__PURE__*/vue.createElementVNode("path", {
183
+ d: "M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448s448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372s372 166.6 372 372s-166.6 372-372 372z",
184
+ fill: "currentColor"
185
+ })], -1);
186
+
187
+ var _hoisted_3 = [_hoisted_2];
188
+ function render(_ctx, _cache, $props, $setup, $data, $options) {
189
+ return vue.openBlock(), vue.createElementBlock("span", _hoisted_1, _hoisted_3);
190
+ }
191
+
192
+ script.render = render;
193
+
138
194
  function _isSlot(s) {
139
195
  return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !vue.isVNode(s);
140
196
  }
@@ -184,9 +240,9 @@
184
240
  onBeforeAdd: {
185
241
  type: Function,
186
242
  "default": function _default() {}
187
- }
243
+ },
244
+ formCreateInject: Object
188
245
  },
189
- inject: ['formCreateInject'],
190
246
  data: function data() {
191
247
  return {
192
248
  len: 0,
@@ -364,7 +420,7 @@
364
420
  this.input(this.modelValue);
365
421
  },
366
422
  addIcon: function addIcon(key) {
367
- return vue.createVNode(iconsVue.PlusCircleOutlined, {
423
+ return vue.createVNode(script, {
368
424
  "key": "a".concat(key),
369
425
  "style": "font-size:".concat(this.fontSize, "px;cursor:").concat(this.disabled ? 'not-allowed;color:#c9cdd4' : 'pointer', ";"),
370
426
  "onClick": this.add
@@ -373,7 +429,7 @@
373
429
  delIcon: function delIcon(index, key) {
374
430
  var _this7 = this;
375
431
 
376
- return vue.createVNode(iconsVue.MinusCircleOutlined, {
432
+ return vue.createVNode(script$1, {
377
433
  "key": "d".concat(key),
378
434
  "style": "font-size:".concat(this.fontSize, "px;cursor:").concat(this.disabled ? 'not-allowed;color:#c9cdd4' : 'pointer;color:#606266', ";"),
379
435
  "onClick": function onClick() {
@@ -434,12 +490,12 @@
434
490
  return keys.length === 0 ? this.$slots["default"] ? this.$slots["default"]({
435
491
  vm: this,
436
492
  add: this.add
437
- }) : vue.createVNode(iconsVue.PlusCircleOutlined, {
438
- "key": 'a_def',
493
+ }) : vue.createVNode(script, {
494
+ "key": 1,
439
495
  "style": "font-size:".concat(this.fontSize, "px;vertical-align:middle;color:").concat(this.disabled ? '#c9cdd4;cursor: not-allowed' : '#606266;cursor:pointer', ";"),
440
496
  "onClick": this.add
441
497
  }, null) : vue.createVNode("div", {
442
- "key": 'con'
498
+ "key": 2
443
499
  }, [keys.map(function (key, index) {
444
500
  var _slot;
445
501
 
package/dist/index.min.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /*!
2
- * @form-create/component-antdv-group v3.0.0-alpha.4
2
+ * @form-create/component-antdv-group v3.1.2
3
3
  * (c) 2018-2022 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"),require("@ant-design/icons-vue")):"function"==typeof define&&define.amd?define(["exports","vue","@ant-design/icons-vue"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).FcGroup={},e.Vue,e.iconsVue)}(this,(function(e,t,n){"use strict";function o(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function i(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?o(Object(n),!0).forEach((function(t){l(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):o(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function r(e){return r="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},r(e)}function l(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,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 n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))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 n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}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"===r(e)&&null!==e&&1===e.nodeType&&!c.Object(e)},trueArray:function(e){return Array.isArray(e)&&e.length>0}};["Date","Object","Function","String","Boolean","Array","Number"].forEach((function(e){c[e]=function(t){return c.type(t,e)}}));var s=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[]}},disabled:{type:Boolean,default:!1},syncDisabled:{type:Boolean,default:!0},fontSize:{type:Number,default:28},onBeforeRemove:{type:Function,default:function(){}},onBeforeAdd:{type:Function,default:function(){}}},inject:["formCreateInject"],data:function(){return{len:0,cacheRule:{},cacheValue:{},form:t.markRaw(this.formCreateInject.form.$form())}},emits:["update:modelValue","change","itemMounted","remove"],watch:{disabled:function(e){if(this.syncDisabled){var t=this.cacheRule;Object.keys(t).forEach((function(n){t[n].$f.disabled(e)}))}},expand:function(e){var t=e-this.modelValue.length;t>0&&this.expandRule(t)},modelValue:{handler:function(e){var t=this;e=e||[];var n=Object.keys(this.cacheRule),o=n.length,i=o-e.length;if(i<0){for(var r=i;r<0;r++)this.addRule(e.length+r);for(var l=0;l<o;l++)this.setValue(n[l],e[l])}else{if(i>0){for(var u=0;u<i;u++)this.removeRule(n[o-u-1]);this.subForm()}e.forEach((function(o,i){t.setValue(n[i],e[i])}))}},deep:!0,flush:"post"}},methods:{_value:function(e){return e&&(t=e,n=this.field,{}.hasOwnProperty.call(t,n))?e[this.field]:e;var t,n},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 n=this,o=this.cacheRule,r=Object.keys(o);if(r.filter((function(e){return o[e].$f})).length===r.length){var l=r.map((function(o){var r=e===o?t:i({},n.cacheRule[o].$f.form),l=n.field?r[n.field]||null:r;return n.cache(o,l),l}));this.input(l)}},setValue:function(e,t){var n=this.field;n&&(t=l({},n,this._value(t))),this.cacheValue[e]!==JSON.stringify(n?t[n]:t)&&this.cache(e,t)},addRule:function(e,n){var o=this,r=this.formCreateInject.form.copyRules(this.rule||[]),l=this.options?i({},this.options):{submitBtn:!1,resetBtn:!1};this.cacheRule[++this.len]={rule:r,options:l},n&&t.nextTick((function(){return o.$emit("add",r,Object.keys(o.cacheRule).length-1)}))},add$f:function(e,n,o){var i=this;this.cacheRule[n].$f=o,this.subForm(),t.nextTick((function(){i.syncDisabled&&o.disabled(i.disabled),i.$emit("itemMounted",o,Object.keys(i.cacheRule).indexOf(n))}))},subForm:function(){var e=this;this.formCreateInject.subForm(Object.keys(this.cacheRule).map((function(t){return e.cacheRule[t].$f})))},removeRule:function(e,n){var o=this,i=Object.keys(this.cacheRule).indexOf(e);delete this.cacheRule[e],delete this.cacheValue[e],n&&t.nextTick((function(){return o.$emit("remove",i)}))},add:function(){this.disabled||!1===this.onBeforeAdd(this.modelValue)||(this.modelValue.push(this.field?null:{}),this.$emit("update:modelValue",this.modelValue))},del:function(e,t){this.disabled||!1===this.onBeforeRemove(this.modelValue,e)||(this.removeRule(t,!0),this.subForm(),this.modelValue.splice(e,1),this.input(this.modelValue))},addIcon:function(e){return t.createVNode(n.PlusCircleOutlined,{key:"a".concat(e),style:"font-size:".concat(this.fontSize,"px;cursor:").concat(this.disabled?"not-allowed;color:#c9cdd4":"pointer",";"),onClick:this.add},null)},delIcon:function(e,o){var i=this;return t.createVNode(n.MinusCircleOutlined,{key:"d".concat(o),style:"font-size:".concat(this.fontSize,"px;cursor:").concat(this.disabled?"not-allowed;color:#c9cdd4":"pointer;color:#606266",";"),onClick:function(){return i.del(e,o)}},null)},makeIcon:function(e,t,n){var o=this;return this.$slots.button?this.$slots.button({total:e,index:t,vm:this,key:n,del:function(){return o.del(t,n)},add:this.add}):0===t?[0!==this.max&&e>=this.max?null:this.addIcon(n),0===this.min||e>this.min?this.delIcon(t,n):null]:t>=this.min?this.delIcon(t,n):void 0},emitEvent:function(e,t,n,o){this.$emit.apply(this,[e].concat(u(t),[this.cacheRule[o].$f,n]))},expandRule:function(e){for(var t=0;t<e;t++)this.modelValue.push(this.field?null:{})}},created:function(){for(var e=(this.expand||0)-this.modelValue.length,t=0;t<this.modelValue.length;t++)this.addRule(t);e>0&&this.expandRule(e)},render:function(){var e=this,o=Object.keys(this.cacheRule),i=this.button,r=this.form;return 0===o.length?this.$slots.default?this.$slots.default({vm:this,add:this.add}):t.createVNode(n.PlusCircleOutlined,{key:"a_def",style:"font-size:".concat(this.fontSize,"px;vertical-align:middle;color:").concat(this.disabled?"#c9cdd4;cursor: not-allowed":"#606266;cursor:pointer",";"),onClick:this.add},null):t.createVNode("div",{key:"con"},[o.map((function(n,u){var a,c=e.cacheRule[n],s=c.rule,d=c.options;return t.createVNode(t.resolveComponent("aRow"),{align:"middle",type:"flex",key:n,style:"border-bottom:1px dashed #DCDFE6;margin-bottom:10px;"},{default:function(){return[t.createVNode(t.resolveComponent("aCol"),{span:i?20:24},{default:function(){return[t.createVNode(r,{key:n,"onUpdate:modelValue":function(t){return e.formData(n,t)},modelValue:e.field?l({},e.field,e._value(e.modelValue[u])):e.modelValue[u],"onEmit-event":function(t){for(var o=arguments.length,i=new Array(o>1?o-1:0),r=1;r<o;r++)i[r-1]=arguments[r];return e.emitEvent(t,i,u,n)},"onUpdate:api":function(t){return e.add$f(u,n,t)},rule:s,option:d,extendOption:!0},null)]}}),i?t.createVNode(t.resolveComponent("aCol"),{span:2,pull:1,push:1},(c=a=e.makeIcon(o.length,u,n),"function"==typeof c||"[object Object]"===Object.prototype.toString.call(c)&&!t.isVNode(c)?a:{default:function(){return[a]}})):null];var c}})}))])}});e.default=s,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 n(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function o(e){for(var t=1;t<arguments.length;t++){var o=null!=arguments[t]?arguments[t]:{};t%2?n(Object(o),!0).forEach((function(t){i(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):n(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}function r(e){return r="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},r(e)}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function l(e){return function(e){if(Array.isArray(e))return c(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 c(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);"Object"===n&&e.constructor&&(n=e.constructor.name);if("Map"===n||"Set"===n)return Array.from(e);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return c(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 c(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}var a={type:function(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"},Undef:function(e){return null==e},Element:function(e){return"object"===r(e)&&null!==e&&1===e.nodeType&&!a.Object(e)},trueArray:function(e){return Array.isArray(e)&&e.length>0}};["Date","Object","Function","String","Boolean","Array","Number"].forEach((function(e){a[e]=function(t){return a.type(t,e)}}));var u={name:"MinusCircleOutlined"},s={class:"anticon"},d=[t.createElementVNode("svg",{height:"1em",width:"1em",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[t.createElementVNode("path",{d:"M696 480H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h368c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z",fill:"currentColor"}),t.createElementVNode("path",{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448s448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372s372 166.6 372 372s-166.6 372-372 372z",fill:"currentColor"})],-1)];u.render=function(e,n,o,r,i,l){return t.openBlock(),t.createElementBlock("span",s,d)};var f={name:"PlusCircleOutlined"},h={class:"anticon"},m=[t.createElementVNode("svg",{height:"1em",width:"1em",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 1024 1024"},[t.createElementVNode("path",{d:"M696 480H544V328c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v152H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h152v152c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V544h152c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z",fill:"currentColor"}),t.createElementVNode("path",{d:"M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448s448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372s372 166.6 372 372s-166.6 372-372 372z",fill:"currentColor"})],-1)];f.render=function(e,n,o,r,i,l){return t.openBlock(),t.createElementBlock("span",h,m)};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[]}},disabled:{type:Boolean,default:!1},syncDisabled:{type:Boolean,default:!0},fontSize:{type:Number,default:28},onBeforeRemove:{type:Function,default:function(){}},onBeforeAdd:{type:Function,default:function(){}},formCreateInject:Object},data:function(){return{len:0,cacheRule:{},cacheValue:{},form:t.markRaw(this.formCreateInject.form.$form())}},emits:["update:modelValue","change","itemMounted","remove"],watch:{disabled:function(e){if(this.syncDisabled){var t=this.cacheRule;Object.keys(t).forEach((function(n){t[n].$f.disabled(e)}))}},expand:function(e){var t=e-this.modelValue.length;t>0&&this.expandRule(t)},modelValue:{handler:function(e){var t=this;e=e||[];var n=Object.keys(this.cacheRule),o=n.length,r=o-e.length;if(r<0){for(var i=r;i<0;i++)this.addRule(e.length+i);for(var l=0;l<o;l++)this.setValue(n[l],e[l])}else{if(r>0){for(var c=0;c<r;c++)this.removeRule(n[o-c-1]);this.subForm()}e.forEach((function(o,r){t.setValue(n[r],e[r])}))}},deep:!0,flush:"post"}},methods:{_value:function(e){return e&&(t=e,n=this.field,{}.hasOwnProperty.call(t,n))?e[this.field]:e;var t,n},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 n=this,r=this.cacheRule,i=Object.keys(r);if(i.filter((function(e){return r[e].$f})).length===i.length){var l=i.map((function(r){var i=e===r?t:o({},n.cacheRule[r].$f.form),l=n.field?i[n.field]||null:i;return n.cache(r,l),l}));this.input(l)}},setValue:function(e,t){var n=this.field;n&&(t=i({},n,this._value(t))),this.cacheValue[e]!==JSON.stringify(n?t[n]:t)&&this.cache(e,t)},addRule:function(e,n){var r=this,i=this.formCreateInject.form.copyRules(this.rule||[]),l=this.options?o({},this.options):{submitBtn:!1,resetBtn:!1};this.cacheRule[++this.len]={rule:i,options:l},n&&t.nextTick((function(){return r.$emit("add",i,Object.keys(r.cacheRule).length-1)}))},add$f:function(e,n,o){var r=this;this.cacheRule[n].$f=o,this.subForm(),t.nextTick((function(){r.syncDisabled&&o.disabled(r.disabled),r.$emit("itemMounted",o,Object.keys(r.cacheRule).indexOf(n))}))},subForm:function(){var e=this;this.formCreateInject.subForm(Object.keys(this.cacheRule).map((function(t){return e.cacheRule[t].$f})))},removeRule:function(e,n){var o=this,r=Object.keys(this.cacheRule).indexOf(e);delete this.cacheRule[e],delete this.cacheValue[e],n&&t.nextTick((function(){return o.$emit("remove",r)}))},add:function(){this.disabled||!1===this.onBeforeAdd(this.modelValue)||(this.modelValue.push(this.field?null:{}),this.$emit("update:modelValue",this.modelValue))},del:function(e,t){this.disabled||!1===this.onBeforeRemove(this.modelValue,e)||(this.removeRule(t,!0),this.subForm(),this.modelValue.splice(e,1),this.input(this.modelValue))},addIcon:function(e){return t.createVNode(f,{key:"a".concat(e),style:"font-size:".concat(this.fontSize,"px;cursor:").concat(this.disabled?"not-allowed;color:#c9cdd4":"pointer",";"),onClick:this.add},null)},delIcon:function(e,n){var o=this;return t.createVNode(u,{key:"d".concat(n),style:"font-size:".concat(this.fontSize,"px;cursor:").concat(this.disabled?"not-allowed;color:#c9cdd4":"pointer;color:#606266",";"),onClick:function(){return o.del(e,n)}},null)},makeIcon:function(e,t,n){var o=this;return this.$slots.button?this.$slots.button({total:e,index:t,vm:this,key:n,del:function(){return o.del(t,n)},add:this.add}):0===t?[0!==this.max&&e>=this.max?null:this.addIcon(n),0===this.min||e>this.min?this.delIcon(t,n):null]:t>=this.min?this.delIcon(t,n):void 0},emitEvent:function(e,t,n,o){this.$emit.apply(this,[e].concat(l(t),[this.cacheRule[o].$f,n]))},expandRule:function(e){for(var t=0;t<e;t++)this.modelValue.push(this.field?null:{})}},created:function(){for(var e=(this.expand||0)-this.modelValue.length,t=0;t<this.modelValue.length;t++)this.addRule(t);e>0&&this.expandRule(e)},render:function(){var e=this,n=Object.keys(this.cacheRule),o=this.button,r=this.form;return 0===n.length?this.$slots.default?this.$slots.default({vm:this,add:this.add}):t.createVNode(f,{key:1,style:"font-size:".concat(this.fontSize,"px;vertical-align:middle;color:").concat(this.disabled?"#c9cdd4;cursor: not-allowed":"#606266;cursor:pointer",";"),onClick:this.add},null):t.createVNode("div",{key:2},[n.map((function(l,c){var a,u=e.cacheRule[l],s=u.rule,d=u.options;return t.createVNode(t.resolveComponent("aRow"),{align:"middle",type:"flex",key:l,style:"border-bottom:1px dashed #DCDFE6;margin-bottom:10px;"},{default:function(){return[t.createVNode(t.resolveComponent("aCol"),{span:o?20:24},{default:function(){return[t.createVNode(r,{key:l,"onUpdate:modelValue":function(t){return e.formData(l,t)},modelValue:e.field?i({},e.field,e._value(e.modelValue[c])):e.modelValue[c],"onEmit-event":function(t){for(var n=arguments.length,o=new Array(n>1?n-1:0),r=1;r<n;r++)o[r-1]=arguments[r];return e.emitEvent(t,o,c,l)},"onUpdate:api":function(t){return e.add$f(c,l,t)},rule:s,option:d,extendOption:!0},null)]}}),o?t.createVNode(t.resolveComponent("aCol"),{span:2,pull:1,push:1},(u=a=e.makeIcon(n.length,c,l),"function"==typeof u||"[object Object]"===Object.prototype.toString.call(u)&&!t.isVNode(u)?a:{default:function(){return[a]}})):null];var u}})}))])}});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.0.0-alpha.4",
3
+ "version": "3.1.2",
4
4
  "description": "@form-create/ant-design-vue 内置组件",
5
5
  "main": "./dist/index.min.js",
6
6
  "module": "./dist/index.esm.js",
@@ -30,7 +30,7 @@
30
30
  "author": "xaboy",
31
31
  "license": "MIT",
32
32
  "dependencies": {
33
- "@form-create/utils": "^3.0.0-alpha.4"
33
+ "@form-create/utils": "^3.1.2"
34
34
  },
35
35
  "devDependencies": {
36
36
  "@ant-design/icons-vue": "^6.0.1"
@@ -55,5 +55,6 @@
55
55
  "umd",
56
56
  "esm"
57
57
  ]
58
- }
58
+ },
59
+ "gitHead": "e95ebb3f256032d0a7bb64e739b721fbf58b80ff"
59
60
  }
@@ -0,0 +1,17 @@
1
+ <template>
2
+ <span class="anticon">
3
+ <svg height="1em" width="1em" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
4
+ <path d="M696 480H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h368c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z"
5
+ fill="currentColor"></path>
6
+ <path
7
+ d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448s448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372s372 166.6 372 372s-166.6 372-372 372z"
8
+ fill="currentColor"></path>
9
+ </svg>
10
+ </span>
11
+ </template>
12
+
13
+ <script>
14
+ export default {
15
+ name: 'MinusCircleOutlined'
16
+ }
17
+ </script>
@@ -0,0 +1,18 @@
1
+ <template>
2
+ <span class="anticon">
3
+ <svg height="1em" width="1em" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 1024 1024">
4
+ <path
5
+ d="M696 480H544V328c0-4.4-3.6-8-8-8h-48c-4.4 0-8 3.6-8 8v152H328c-4.4 0-8 3.6-8 8v48c0 4.4 3.6 8 8 8h152v152c0 4.4 3.6 8 8 8h48c4.4 0 8-3.6 8-8V544h152c4.4 0 8-3.6 8-8v-48c0-4.4-3.6-8-8-8z"
6
+ fill="currentColor"></path>
7
+ <path
8
+ d="M512 64C264.6 64 64 264.6 64 512s200.6 448 448 448s448-200.6 448-448S759.4 64 512 64zm0 820c-205.4 0-372-166.6-372-372s166.6-372 372-372s372 166.6 372 372s-166.6 372-372 372z"
9
+ fill="currentColor"></path>
10
+ </svg>
11
+ </span>
12
+ </template>
13
+
14
+ <script>
15
+ export default {
16
+ name: 'PlusCircleOutlined'
17
+ }
18
+ </script>
package/src/component.jsx CHANGED
@@ -1,6 +1,7 @@
1
1
  import {hasProperty} from '@form-create/utils/lib/type';
2
2
  import {defineComponent, markRaw, nextTick} from 'vue';
3
- import {PlusCircleOutlined, MinusCircleOutlined} from '@ant-design/icons-vue';
3
+ import MinusCircleOutlined from './MinusCircleOutlined.vue';
4
+ import PlusCircleOutlined from './PlusCircleOutlined.vue';
4
5
 
5
6
  const NAME = 'fcGroup';
6
7
 
@@ -49,8 +50,8 @@ export default defineComponent({
49
50
  default: () => {
50
51
  }
51
52
  },
53
+ formCreateInject: Object,
52
54
  },
53
- inject: ['formCreateInject'],
54
55
  data() {
55
56
  return {
56
57
  len: 0,
@@ -239,10 +240,10 @@ export default defineComponent({
239
240
  (this.$slots.default ? (this.$slots.default({
240
241
  vm: this,
241
242
  add: this.add
242
- })) : <PlusCircleOutlined key={'a_def'}
243
+ })) : <PlusCircleOutlined key={1}
243
244
  style={`font-size:${this.fontSize}px;vertical-align:middle;color:${this.disabled ? '#c9cdd4;cursor: not-allowed' : '#606266;cursor:pointer'};`}
244
245
  onClick={this.add}/>) :
245
- <div key={'con'}>{keys.map((key, index) => {
246
+ <div key={2}>{keys.map((key, index) => {
246
247
  const {rule, options} = this.cacheRule[key];
247
248
  return <aRow align="middle" type="flex" key={key}
248
249
  style="border-bottom:1px dashed #DCDFE6;margin-bottom:10px;">