@form-create/component-elm-group 2.6.0 → 2.6.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/dist/index.es.js CHANGED
@@ -1,25 +1,55 @@
1
1
  /*!
2
2
  * FormCreate 低代码表单渲染器
3
- * @form-create/component-elm-group v2.6.0
3
+ * @form-create/component-elm-group v2.6.2
4
4
  * (c) 2018-2024 xaboy
5
5
  * Github https://github.com/xaboy/form-create
6
6
  * Site https://form-create.com/
7
7
  * Released under the MIT License.
8
8
  */
9
9
  (function(){"use strict";try{if(typeof document!="undefined"){var o=document.createElement("style");o.appendChild(document.createTextNode('._fc-group{display:flex;min-height:42px;justify-content:center;flex-direction:column}._fc-group-disabled ._fc-group-btn,._fc-group-disabled ._fc-group-add{cursor:not-allowed}._fc-group-handle{display:flex;flex-direction:row;position:absolute;bottom:-15px;right:30px;border-radius:15px;border:1px dashed #d9d9d9;padding:3px 8px;background-color:#fff}._fc-group-btn{cursor:pointer}._fc-group-idx{position:absolute;bottom:-15px;left:10px;width:30px;height:30px;display:flex;align-items:center;justify-content:center;background:#eee;border-radius:15px;font-weight:700}._fc-group-handle ._fc-group-btn+._fc-group-btn{margin-left:7px}._fc-group-container{position:relative;display:flex;flex-direction:column;border:1px dashed #d9d9d9;padding:20px 20px 25px;margin:5px 5px 25px;border-radius:5px}._fc-group-arrow{position:relative;width:20px;height:20px}._fc-group-arrow:before{content:"";position:absolute;top:8px;left:5px;width:9px;height:9px;border-left:2px solid #999;border-top:2px solid #999}._fc-group-arrow:before{transform:rotate(45deg)}._fc-group-arrow._fc-group-down{transform:rotate(180deg)}._fc-group-plus-minus{width:20px;height:20px;position:relative;cursor:pointer}._fc-group-plus-minus:before,._fc-group-plus-minus:after{content:"";position:absolute;top:50%;left:50%;width:60%;height:2px;background-color:#409eff;transform:translate(-50%,-50%)}._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{cursor:pointer;width:25px;height:25px;border:1px solid rgb(64 158 255 / 50%);border-radius:15px}._fc-group-add._fc-group-plus-minus:before,._fc-group-add._fc-group-plus-minus:after{width:50%}')),document.head.appendChild(o)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}})();
10
- var g = Object.defineProperty;
11
- var p = Object.getOwnPropertySymbols;
12
- var _ = Object.prototype.hasOwnProperty, $ = Object.prototype.propertyIsEnumerable;
13
- var m = (e, t, s) => t in e ? g(e, t, { enumerable: !0, configurable: !0, writable: !0, value: s }) : e[t] = s, h = (e, t) => {
14
- for (var s in t || (t = {}))
15
- _.call(t, s) && m(e, s, t[s]);
16
- if (p)
17
- for (var s of p(t))
18
- $.call(t, s) && m(e, s, t[s]);
10
+ var O = Object.defineProperty;
11
+ var g = Object.getOwnPropertySymbols;
12
+ var R = Object.prototype.hasOwnProperty, j = Object.prototype.propertyIsEnumerable;
13
+ var _ = (e, t, r) => t in e ? O(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r, d = (e, t) => {
14
+ for (var r in t || (t = {}))
15
+ R.call(t, r) && _(e, r, t[r]);
16
+ if (g)
17
+ for (var r of g(t))
18
+ j.call(t, r) && _(e, r, t[r]);
19
19
  return e;
20
20
  };
21
- import v from "vue";
22
- const c = {
21
+ import A from "vue";
22
+ function V(e) {
23
+ return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
24
+ }
25
+ function p() {
26
+ return p = Object.assign ? Object.assign.bind() : function(e) {
27
+ for (var t, r = 1; r < arguments.length; r++) for (var s in t = arguments[r], t) Object.prototype.hasOwnProperty.call(t, s) && (e[s] = t[s]);
28
+ return e;
29
+ }, p.apply(this, arguments);
30
+ }
31
+ var S = ["attrs", "props", "domProps"], B = ["class", "style", "directives"], D = ["on", "nativeOn"], E = function(e) {
32
+ return e.reduce(function(t, r) {
33
+ for (var s in r) if (!t[s]) t[s] = r[s];
34
+ else if (S.indexOf(s) !== -1) t[s] = p({}, t[s], r[s]);
35
+ else if (B.indexOf(s) !== -1) {
36
+ var i = t[s] instanceof Array ? t[s] : [t[s]], n = r[s] instanceof Array ? r[s] : [r[s]];
37
+ t[s] = [].concat(i, n);
38
+ } else if (D.indexOf(s) !== -1)
39
+ for (var o in r[s]) if (t[s][o]) {
40
+ var l = t[s][o] instanceof Array ? t[s][o] : [t[s][o]], f = r[s][o] instanceof Array ? r[s][o] : [r[s][o]];
41
+ t[s][o] = [].concat(l, f);
42
+ } else t[s][o] = r[s][o];
43
+ else if (s === "hook") for (var u in r[s]) t[s][u] = t[s][u] ? I(t[s][u], r[s][u]) : r[s][u];
44
+ else t[s] = r[s];
45
+ return t;
46
+ }, {});
47
+ }, I = function(e, t) {
48
+ return function() {
49
+ e && e.apply(this, arguments), t && t.apply(this, arguments);
50
+ };
51
+ }, b = E;
52
+ const k = /* @__PURE__ */ V(b), a = {
23
53
  type(e, t) {
24
54
  return Object.prototype.toString.call(e) === "[object " + t + "]";
25
55
  },
@@ -27,7 +57,7 @@ const c = {
27
57
  return e == null;
28
58
  },
29
59
  Element(e) {
30
- return typeof e == "object" && e !== null && e.nodeType === 1 && !c.Object(e);
60
+ return typeof e == "object" && e !== null && e.nodeType === 1 && !a.Object(e);
31
61
  },
32
62
  trueArray(e) {
33
63
  return Array.isArray(e) && e.length > 0;
@@ -45,50 +75,50 @@ const c = {
45
75
  }
46
76
  };
47
77
  ["Date", "Object", "String", "Boolean", "Array", "Number"].forEach((e) => {
48
- c[e] = function(t) {
49
- return c.type(t, e);
78
+ a[e] = function(t) {
79
+ return a.type(t, e);
50
80
  };
51
81
  });
52
- function j(e, t) {
82
+ function w(e, t) {
53
83
  return {}.hasOwnProperty.call(e, t);
54
84
  }
55
- function a(e, t, s) {
56
- v.set(e, t, s);
85
+ function h(e, t, r) {
86
+ A.set(e, t, r);
57
87
  }
58
- function f(e, t = {}, s) {
59
- let i = !1;
60
- for (let n in t)
61
- if (Object.prototype.hasOwnProperty.call(t, n)) {
62
- let r = t[n];
63
- if ((i = Array.isArray(r)) || c.Object(r)) {
64
- let l = e[n] === void 0;
65
- if (i)
66
- i = !1, l && a(e, n, []);
67
- else if (r._clone && s !== void 0) {
68
- a(e, n, r._clone());
88
+ function m(e, t = {}, r) {
89
+ let s = !1;
90
+ for (let i in t)
91
+ if (Object.prototype.hasOwnProperty.call(t, i)) {
92
+ let n = t[i];
93
+ if ((s = Array.isArray(n)) || a.Object(n)) {
94
+ let o = e[i] === void 0;
95
+ if (s)
96
+ s = !1, o && h(e, i, []);
97
+ else if (n._clone && r !== void 0) {
98
+ h(e, i, n._clone());
69
99
  continue;
70
100
  } else
71
- l && a(e, n, {});
72
- e[n] = f(e[n], r, s);
101
+ o && h(e, i, {});
102
+ e[i] = m(e[i], n, r);
73
103
  } else
74
- a(e, n, r), c.Undef(r) || (c.Undef(r.__json) || (e[n].__json = r.__json), c.Undef(r.__origin) || (e[n].__origin = r.__origin));
104
+ h(e, i, n), a.Undef(n) || (a.Undef(n.__json) || (e[i].__json = n.__json), a.Undef(n.__origin) || (e[i].__origin = n.__origin));
75
105
  }
76
106
  return e;
77
107
  }
78
- function y(e) {
79
- return f({}, { value: e }).value;
108
+ function v(e) {
109
+ return m({}, { value: e }).value;
80
110
  }
81
- const O = Object.assign || function(e) {
82
- for (let t, s = 1; s < arguments.length; s++)
83
- for (let i in t = arguments[s], t)
84
- Object.prototype.hasOwnProperty.call(t, i) && a(e, i, t[i]);
111
+ const x = Object.assign || function(e) {
112
+ for (let t, r = 1; r < arguments.length; r++)
113
+ for (let s in t = arguments[r], t)
114
+ Object.prototype.hasOwnProperty.call(t, s) && h(e, s, t[s]);
85
115
  return e;
86
116
  };
87
- function A() {
88
- return O.apply(this, arguments);
117
+ function F() {
118
+ return x.apply(this, arguments);
89
119
  }
90
- const E = "fcGroup", S = {
91
- name: E,
120
+ const P = "fcGroup", M = {
121
+ name: P,
92
122
  props: {
93
123
  field: String,
94
124
  rule: [Array, Object],
@@ -163,19 +193,19 @@ const E = "fcGroup", S = {
163
193
  },
164
194
  formRule: {
165
195
  handler(e, t) {
166
- Object.keys(this.cacheRule).forEach((s) => {
167
- const i = this.cacheRule[s];
168
- if (i.$f) {
169
- const n = i.$f.formData();
196
+ Object.keys(this.cacheRule).forEach((r) => {
197
+ const s = this.cacheRule[r];
198
+ if (s.$f) {
199
+ const i = s.$f.formData();
170
200
  if (e === t)
171
- i.$f.deferSyncValue(() => {
172
- f(i.rule, e), i.$f.setValue(n);
201
+ s.$f.deferSyncValue(() => {
202
+ m(s.rule, e), s.$f.setValue(i);
173
203
  }, !0);
174
204
  else {
175
- const r = i.$f.formData();
176
- i.$f.once("reloading", () => {
177
- i.$f.setValue(r);
178
- }), i.rule = y(e);
205
+ const n = s.$f.formData();
206
+ s.$f.once("reloading", () => {
207
+ s.$f.setValue(n);
208
+ }), s.rule = v(e);
179
209
  }
180
210
  }
181
211
  });
@@ -188,28 +218,28 @@ const E = "fcGroup", S = {
188
218
  },
189
219
  value(e, t) {
190
220
  e = e || [];
191
- let s = this.sort, i = s.length, n = i - e.length;
192
- if (n < 0) {
193
- for (let r = n; r < 0; r++)
194
- this.addRule(e.length + r);
221
+ let r = this.sort, s = r.length, i = s - e.length;
222
+ if (i < 0) {
223
+ for (let n = i; n < 0; n++)
224
+ this.addRule(e.length + n);
195
225
  this.sort = Object.keys(this.cacheRule);
196
- for (let r = 0; r < i; r++)
197
- this.setValue(s[r], e[r]);
226
+ for (let n = 0; n < s; n++)
227
+ this.setValue(r[n], e[n]);
198
228
  } else {
199
- if (n > 0) {
200
- for (let r = 0; r < n; r++)
201
- this.removeRule(s[i - r - 1]);
229
+ if (i > 0) {
230
+ for (let n = 0; n < i; n++)
231
+ this.removeRule(r[s - n - 1]);
202
232
  this.sort = Object.keys(this.cacheRule);
203
233
  }
204
- e.forEach((r, l) => {
205
- this.setValue(s[l], e[l]);
234
+ e.forEach((n, o) => {
235
+ this.setValue(r[o], e[o]);
206
236
  });
207
237
  }
208
238
  }
209
239
  },
210
240
  methods: {
211
241
  _value(e) {
212
- return e && j(e, this.field) ? e[this.field] : e;
242
+ return e && w(e, this.field) ? e[this.field] : e;
213
243
  },
214
244
  cache(e, t) {
215
245
  this.cacheValue[e] = JSON.stringify(t);
@@ -218,39 +248,50 @@ const E = "fcGroup", S = {
218
248
  this.$emit("input", e), this.$emit("change", e);
219
249
  },
220
250
  formData(e, t) {
221
- const s = this.cacheRule, i = this.sort;
222
- if (i.filter((r) => s[r].$f).length !== i.length)
251
+ const r = this.cacheRule, s = this.sort;
252
+ if (s.filter((n) => r[n].$f).length !== s.length)
223
253
  return;
224
- const n = i.map((r) => {
225
- const l = e === r ? t : h({}, this.cacheRule[r].$f.form), u = this.field ? l[this.field] || null : l;
226
- return this.cache(r, u), u;
254
+ const i = s.map((n) => {
255
+ const o = e === n ? t : d({}, this.cacheRule[n].$f.form), l = this.field ? o[this.field] || null : o;
256
+ return this.cache(n, l), l;
227
257
  });
228
- this.input(n);
258
+ this.input(i);
229
259
  },
230
260
  setValue(e, t) {
231
- const s = this.field, i = this.cacheRule[e].$f;
232
- s && (t = { [s]: this._value(t) }), this.cacheValue[e] !== JSON.stringify(s ? t[s] : t) && (this.cache(e, t), i && i.coverValue(t || {}));
261
+ const r = this.field, s = this.cacheRule[e].$f;
262
+ r && (t = {
263
+ [r]: this._value(t)
264
+ }), this.cacheValue[e] !== JSON.stringify(r ? t[r] : t) && (this.cache(e, t), s && s.coverValue(t || {}));
233
265
  },
234
266
  addRule(e, t) {
235
- const s = this.formCreateInject.form.copyRules(this.formRule), i = this.options ? h({}, this.options) : {
267
+ const r = this.formCreateInject.form.copyRules(this.formRule), s = this.options ? d({}, this.options) : {
236
268
  submitBtn: !1,
237
269
  resetBtn: !1
238
270
  };
239
271
  if (this.defaultValue) {
240
- i.formData || (i.formData = {});
241
- const n = y(this.defaultValue);
242
- A(i.formData, this.field ? { [this.field]: n } : n);
272
+ s.formData || (s.formData = {});
273
+ const i = v(this.defaultValue);
274
+ F(s.formData, this.field ? {
275
+ [this.field]: i
276
+ } : i);
243
277
  }
244
- this.parse && this.parse({ rule: s, options: i, index: this.sort.length }), this.$set(this.cacheRule, ++this.len, { rule: s, options: i }), t && this.$nextTick(() => this.$emit("add", s, Object.keys(this.cacheRule).length - 1));
278
+ this.parse && this.parse({
279
+ rule: r,
280
+ options: s,
281
+ index: this.sort.length
282
+ }), this.$set(this.cacheRule, ++this.len, {
283
+ rule: r,
284
+ options: s
285
+ }), t && this.$nextTick(() => this.$emit("add", r, Object.keys(this.cacheRule).length - 1));
245
286
  },
246
- add$f(e, t, s) {
247
- this.cacheRule[t].$f = s, this.$nextTick(() => {
248
- this.$emit("itemMounted", s, Object.keys(this.cacheRule).indexOf(t));
287
+ add$f(e, t, r) {
288
+ this.cacheRule[t].$f = r, this.$nextTick(() => {
289
+ this.$emit("itemMounted", r, Object.keys(this.cacheRule).indexOf(t));
249
290
  });
250
291
  },
251
292
  removeRule(e, t) {
252
- const s = Object.keys(this.cacheRule).indexOf(e);
253
- this.$delete(this.cacheRule, e), this.$delete(this.cacheValue, e), t && this.$nextTick(() => this.$emit("remove", s));
293
+ const r = Object.keys(this.cacheRule).indexOf(e);
294
+ this.$delete(this.cacheRule, e), this.$delete(this.cacheValue, e), t && this.$nextTick(() => this.$emit("remove", r));
254
295
  },
255
296
  add(e) {
256
297
  this.disabled || this.onBeforeAdd(this.value) === !1 || this.addRule(e, !0);
@@ -259,58 +300,64 @@ const E = "fcGroup", S = {
259
300
  if (this.disabled || this.onBeforeRemove(this.value, e) === !1)
260
301
  return;
261
302
  this.removeRule(t, !0);
262
- const s = [...this.value];
263
- s.splice(e, 1), this.input(s);
303
+ const r = [...this.value];
304
+ r.splice(e, 1), this.input(r);
264
305
  },
265
306
  addIcon(e) {
266
- return /* @__PURE__ */ React.createElement("div", { class: "_fc-group-btn _fc-group-plus-minus", "on-click": this.add });
307
+ const t = this.$createElement;
308
+ return t("div", {
309
+ class: "_fc-group-btn _fc-group-plus-minus",
310
+ on: {
311
+ click: this.add
312
+ }
313
+ });
267
314
  },
268
315
  delIcon(e, t) {
269
- return /* @__PURE__ */ React.createElement(
270
- "div",
271
- {
272
- class: "_fc-group-btn _fc-group-plus-minus _fc-group-minus",
273
- onClick: () => this.del(e, t)
316
+ const r = this.$createElement;
317
+ return r("div", {
318
+ class: "_fc-group-btn _fc-group-plus-minus _fc-group-minus",
319
+ on: {
320
+ click: () => this.del(e, t)
274
321
  }
275
- );
322
+ });
276
323
  },
277
324
  sortUpIcon(e) {
278
- return /* @__PURE__ */ React.createElement(
279
- "div",
280
- {
281
- class: "_fc-group-btn _fc-group-arrow _fc-group-up",
282
- onClick: () => this.changeSort(e, -1)
325
+ const t = this.$createElement;
326
+ return t("div", {
327
+ class: "_fc-group-btn _fc-group-arrow _fc-group-up",
328
+ on: {
329
+ click: () => this.changeSort(e, -1)
283
330
  }
284
- );
331
+ });
285
332
  },
286
333
  sortDownIcon(e) {
287
- return /* @__PURE__ */ React.createElement(
288
- "div",
289
- {
290
- class: "_fc-group-btn _fc-group-arrow _fc-group-down",
291
- onClick: () => this.changeSort(e, 1)
334
+ const t = this.$createElement;
335
+ return t("div", {
336
+ class: "_fc-group-btn _fc-group-arrow _fc-group-down",
337
+ on: {
338
+ click: () => this.changeSort(e, 1)
292
339
  }
293
- );
340
+ });
294
341
  },
295
342
  changeSort(e, t) {
296
- const s = this.sort[e];
297
- this.$set(this.sort, e, this.sort[e + t]), this.sort[e + t] = s, this.formData(0);
343
+ const r = this.sort[e];
344
+ this.$set(this.sort, e, this.sort[e + t]), this.sort[e + t] = r, this.formData(0);
298
345
  },
299
- makeIcon(e, t, s) {
346
+ makeIcon(e, t, r) {
300
347
  if (this.$scopedSlots.button)
301
348
  return this.$scopedSlots.button({
302
349
  total: e,
303
350
  index: t,
304
351
  vm: this,
305
- key: s,
306
- del: () => this.del(t, s),
352
+ key: r,
353
+ del: () => this.del(t, r),
307
354
  add: this.add
308
355
  });
309
- const i = [];
310
- return (!this.max || e < this.max) && e === t + 1 && i.push(this.addIcon(s)), e > this.min && i.push(this.delIcon(t, s)), this.sortBtn && t && i.push(this.sortUpIcon(t)), this.sortBtn && t !== e - 1 && i.push(this.sortDownIcon(t)), i;
356
+ const s = [];
357
+ return (!this.max || e < this.max) && e === t + 1 && s.push(this.addIcon(r)), e > this.min && s.push(this.delIcon(t, r)), this.sortBtn && t && s.push(this.sortUpIcon(t)), this.sortBtn && t !== e - 1 && s.push(this.sortDownIcon(t)), s;
311
358
  },
312
- emitEvent(e, t, s, i) {
313
- this.$emit(e, ...t, this.cacheRule[i].$f, s);
359
+ emitEvent(e, t, r, s) {
360
+ this.$emit(e, ...t, this.cacheRule[s].$f, r);
314
361
  },
315
362
  expandRule(e) {
316
363
  for (let t = 0; t < e; t++)
@@ -325,41 +372,54 @@ const E = "fcGroup", S = {
325
372
  this.addRule(t);
326
373
  },
327
374
  render() {
328
- const e = this.sort, t = this.button, s = this.type, i = this.disabled, n = e.length === 0 ? this.$scopedSlots.default ? this.$scopedSlots.default({
375
+ const e = arguments[0], t = this.sort, r = this.button, s = this.type, i = this.disabled, n = t.length === 0 ? this.$scopedSlots.default ? this.$scopedSlots.default({
329
376
  vm: this,
330
377
  add: this.add
331
- }) : /* @__PURE__ */ React.createElement(
332
- "div",
333
- {
334
- key: "a_def",
335
- class: "_fc-group-plus-minus _fc-group-add",
336
- "on-click": this.add
378
+ }) : e("div", {
379
+ key: "a_def",
380
+ class: "_fc-group-plus-minus _fc-group-add",
381
+ on: {
382
+ click: this.add
337
383
  }
338
- ) : e.map((r, l) => {
339
- const { rule: u, options: b } = this.cacheRule[r], d = t && !i ? this.makeIcon(e.length, l, r) : [];
340
- return /* @__PURE__ */ React.createElement("div", { class: "_fc-group-container", key: r }, /* @__PURE__ */ React.createElement(
341
- s,
342
- {
343
- key: r,
344
- on: {
345
- "update:value": (o) => this.formData(r, o),
346
- "emit-event": (o, ...R) => this.emitEvent(o, R, l, r),
347
- input: (o) => this.add$f(l, r, o)
348
- },
349
- props: {
350
- disabled: i,
351
- inFor: !0,
352
- value: this.field ? { [this.field]: this._value(this.value[l]) } : this.value[l],
353
- rule: u,
354
- option: b,
355
- extendOption: !0
356
- }
384
+ }) : t.map((o, l) => {
385
+ const {
386
+ rule: f,
387
+ options: u
388
+ } = this.cacheRule[o], y = r && !i ? this.makeIcon(t.length, l, o) : [];
389
+ return e("div", {
390
+ class: "_fc-group-container",
391
+ key: o
392
+ }, [e(s, k([{
393
+ key: o
394
+ }, {
395
+ on: {
396
+ "update:value": (c) => this.formData(o, c),
397
+ "emit-event": (c, ...$) => this.emitEvent(c, $, l, o),
398
+ input: (c) => this.add$f(l, o, c)
399
+ }
400
+ }, {}, {
401
+ props: {
402
+ disabled: i,
403
+ inFor: !0,
404
+ value: this.field ? {
405
+ [this.field]: this._value(this.value[l])
406
+ } : this.value[l],
407
+ rule: f,
408
+ option: u,
409
+ extendOption: !0
357
410
  }
358
- ), /* @__PURE__ */ React.createElement("div", { class: "_fc-group-idx" }, l + 1), d.length ? /* @__PURE__ */ React.createElement("div", { class: "_fc-group-handle" }, d) : null);
411
+ }])), e("div", {
412
+ class: "_fc-group-idx"
413
+ }, [l + 1]), y.length ? e("div", {
414
+ class: "_fc-group-handle"
415
+ }, [y]) : null]);
359
416
  });
360
- return /* @__PURE__ */ React.createElement("div", { key: "con", class: "_fc-group " + (i ? "_fc-group-disabled" : "") }, n);
417
+ return e("div", {
418
+ key: "con",
419
+ class: "_fc-group " + (i ? "_fc-group-disabled" : "")
420
+ }, [n]);
361
421
  }
362
422
  };
363
423
  export {
364
- S as default
424
+ M as default
365
425
  };
package/dist/index.js CHANGED
@@ -1,10 +1,10 @@
1
1
  /*!
2
2
  * FormCreate 低代码表单渲染器
3
- * @form-create/component-elm-group v2.6.0
3
+ * @form-create/component-elm-group v2.6.2
4
4
  * (c) 2018-2024 xaboy
5
5
  * Github https://github.com/xaboy/form-create
6
6
  * Site https://form-create.com/
7
7
  * Released under the MIT License.
8
8
  */
9
9
  (function(){"use strict";try{if(typeof document!="undefined"){var o=document.createElement("style");o.appendChild(document.createTextNode('._fc-group{display:flex;min-height:42px;justify-content:center;flex-direction:column}._fc-group-disabled ._fc-group-btn,._fc-group-disabled ._fc-group-add{cursor:not-allowed}._fc-group-handle{display:flex;flex-direction:row;position:absolute;bottom:-15px;right:30px;border-radius:15px;border:1px dashed #d9d9d9;padding:3px 8px;background-color:#fff}._fc-group-btn{cursor:pointer}._fc-group-idx{position:absolute;bottom:-15px;left:10px;width:30px;height:30px;display:flex;align-items:center;justify-content:center;background:#eee;border-radius:15px;font-weight:700}._fc-group-handle ._fc-group-btn+._fc-group-btn{margin-left:7px}._fc-group-container{position:relative;display:flex;flex-direction:column;border:1px dashed #d9d9d9;padding:20px 20px 25px;margin:5px 5px 25px;border-radius:5px}._fc-group-arrow{position:relative;width:20px;height:20px}._fc-group-arrow:before{content:"";position:absolute;top:8px;left:5px;width:9px;height:9px;border-left:2px solid #999;border-top:2px solid #999}._fc-group-arrow:before{transform:rotate(45deg)}._fc-group-arrow._fc-group-down{transform:rotate(180deg)}._fc-group-plus-minus{width:20px;height:20px;position:relative;cursor:pointer}._fc-group-plus-minus:before,._fc-group-plus-minus:after{content:"";position:absolute;top:50%;left:50%;width:60%;height:2px;background-color:#409eff;transform:translate(-50%,-50%)}._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{cursor:pointer;width:25px;height:25px;border:1px solid rgb(64 158 255 / 50%);border-radius:15px}._fc-group-add._fc-group-plus-minus:before,._fc-group-add._fc-group-plus-minus:after{width:50%}')),document.head.appendChild(o)}}catch(r){console.error("vite-plugin-css-injected-by-js",r)}})();
10
- (function(l,o){typeof exports=="object"&&typeof module!="undefined"?module.exports=o(require("vue")):typeof define=="function"&&define.amd?define(["vue"],o):(l=typeof globalThis!="undefined"?globalThis:l||self,l.FcGroup=o(l.Vue))})(this,function(l){"use strict";var j=Object.defineProperty;var b=Object.getOwnPropertySymbols;var O=Object.prototype.hasOwnProperty,A=Object.prototype.propertyIsEnumerable;var R=(l,o,u)=>o in l?j(l,o,{enumerable:!0,configurable:!0,writable:!0,value:u}):l[o]=u,p=(l,o)=>{for(var u in o||(o={}))O.call(o,u)&&R(l,u,o[u]);if(b)for(var u of b(o))A.call(o,u)&&R(l,u,o[u]);return l};const o={type(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"},Undef(e){return e==null},Element(e){return typeof e=="object"&&e!==null&&e.nodeType===1&&!o.Object(e)},trueArray(e){return Array.isArray(e)&&e.length>0},Function(e){const t=this.getType(e);return t==="Function"||t==="AsyncFunction"},getType(e){const t=Object.prototype.toString.call(e);return/^\[object (.*)\]$/.exec(t)[1]},empty(e){return e==null||Array.isArray(e)&&Array.isArray(e)&&!e.length?!0:typeof e=="string"&&!e}};["Date","Object","String","Boolean","Array","Number"].forEach(e=>{o[e]=function(t){return o.type(t,e)}});function u(e,t){return{}.hasOwnProperty.call(e,t)}function a(e,t,i){l.set(e,t,i)}function d(e,t={},i){let s=!1;for(let n in t)if(Object.prototype.hasOwnProperty.call(t,n)){let r=t[n];if((s=Array.isArray(r))||o.Object(r)){let c=e[n]===void 0;if(s)s=!1,c&&a(e,n,[]);else if(r._clone&&i!==void 0){a(e,n,r._clone());continue}else c&&a(e,n,{});e[n]=d(e[n],r,i)}else a(e,n,r),o.Undef(r)||(o.Undef(r.__json)||(e[n].__json=r.__json),o.Undef(r.__origin)||(e[n].__origin=r.__origin))}return e}function m(e){return d({},{value:e}).value}const g=Object.assign||function(e){for(let t,i=1;i<arguments.length;i++)for(let s in t=arguments[i],t)Object.prototype.hasOwnProperty.call(t,s)&&a(e,s,t[s]);return e};function _(){return g.apply(this,arguments)}return{name:"fcGroup",props:{field:String,rule:[Array,Object],rules:Array,expand:Number,options:Object,formCreateInject:{type:Object,required:!0},button:{type:Boolean,default:!0},max:{type:Number,default:0},min:{type:Number,default:0},value:{type:Array,default:()=>[]},sortBtn:{type:Boolean,default:!0},defaultValue:Object,disabled:{type:Boolean,default:!1},syncDisabled:{type:Boolean,default:!0},onBeforeRemove:{type:Function,default:()=>{}},onBeforeAdd:{type:Function,default:()=>{}},parse:Function},data(){return{len:0,cacheRule:{},cacheValue:{},sort:[],type:void 0}},computed:{formRule(){return this.rules?this.rules:this.rule?Array.isArray(this.rule)?this.rule:[this.rule]:[]}},watch:{cacheRule:{handler(e){this.sort=Object.keys(e)},immediate:!0},formRule:{handler(e,t){Object.keys(this.cacheRule).forEach(i=>{const s=this.cacheRule[i];if(s.$f){const n=s.$f.formData();if(e===t)s.$f.deferSyncValue(()=>{d(s.rule,e),s.$f.setValue(n)},!0);else{const r=s.$f.formData();s.$f.once("reloading",()=>{s.$f.setValue(r)}),s.rule=m(e)}}})},deep:!0},expand(e){let t=e-this.value.length;t>0&&this.expandRule(t)},value(e,t){e=e||[];let i=this.sort,s=i.length,n=s-e.length;if(n<0){for(let r=n;r<0;r++)this.addRule(e.length+r);this.sort=Object.keys(this.cacheRule);for(let r=0;r<s;r++)this.setValue(i[r],e[r])}else{if(n>0){for(let r=0;r<n;r++)this.removeRule(i[s-r-1]);this.sort=Object.keys(this.cacheRule)}e.forEach((r,c)=>{this.setValue(i[c],e[c])})}}},methods:{_value(e){return e&&u(e,this.field)?e[this.field]:e},cache(e,t){this.cacheValue[e]=JSON.stringify(t)},input(e){this.$emit("input",e),this.$emit("change",e)},formData(e,t){const i=this.cacheRule,s=this.sort;if(s.filter(r=>i[r].$f).length!==s.length)return;const n=s.map(r=>{const c=e===r?t:p({},this.cacheRule[r].$f.form),f=this.field?c[this.field]||null:c;return this.cache(r,f),f});this.input(n)},setValue(e,t){const i=this.field,s=this.cacheRule[e].$f;i&&(t={[i]:this._value(t)}),this.cacheValue[e]!==JSON.stringify(i?t[i]:t)&&(this.cache(e,t),s&&s.coverValue(t||{}))},addRule(e,t){const i=this.formCreateInject.form.copyRules(this.formRule),s=this.options?p({},this.options):{submitBtn:!1,resetBtn:!1};if(this.defaultValue){s.formData||(s.formData={});const n=m(this.defaultValue);_(s.formData,this.field?{[this.field]:n}:n)}this.parse&&this.parse({rule:i,options:s,index:this.sort.length}),this.$set(this.cacheRule,++this.len,{rule:i,options:s}),t&&this.$nextTick(()=>this.$emit("add",i,Object.keys(this.cacheRule).length-1))},add$f(e,t,i){this.cacheRule[t].$f=i,this.$nextTick(()=>{this.$emit("itemMounted",i,Object.keys(this.cacheRule).indexOf(t))})},removeRule(e,t){const i=Object.keys(this.cacheRule).indexOf(e);this.$delete(this.cacheRule,e),this.$delete(this.cacheValue,e),t&&this.$nextTick(()=>this.$emit("remove",i))},add(e){this.disabled||this.onBeforeAdd(this.value)===!1||this.addRule(e,!0)},del(e,t){if(this.disabled||this.onBeforeRemove(this.value,e)===!1)return;this.removeRule(t,!0);const i=[...this.value];i.splice(e,1),this.input(i)},addIcon(e){return React.createElement("div",{class:"_fc-group-btn _fc-group-plus-minus","on-click":this.add})},delIcon(e,t){return React.createElement("div",{class:"_fc-group-btn _fc-group-plus-minus _fc-group-minus",onClick:()=>this.del(e,t)})},sortUpIcon(e){return React.createElement("div",{class:"_fc-group-btn _fc-group-arrow _fc-group-up",onClick:()=>this.changeSort(e,-1)})},sortDownIcon(e){return React.createElement("div",{class:"_fc-group-btn _fc-group-arrow _fc-group-down",onClick:()=>this.changeSort(e,1)})},changeSort(e,t){const i=this.sort[e];this.$set(this.sort,e,this.sort[e+t]),this.sort[e+t]=i,this.formData(0)},makeIcon(e,t,i){if(this.$scopedSlots.button)return this.$scopedSlots.button({total:e,index:t,vm:this,key:i,del:()=>this.del(t,i),add:this.add});const s=[];return(!this.max||e<this.max)&&e===t+1&&s.push(this.addIcon(i)),e>this.min&&s.push(this.delIcon(t,i)),this.sortBtn&&t&&s.push(this.sortUpIcon(t)),this.sortBtn&&t!==e-1&&s.push(this.sortDownIcon(t)),s},emitEvent(e,t,i,s){this.$emit(e,...t,this.cacheRule[s].$f,i)},expandRule(e){for(let t=0;t<e;t++)this.value.push(this.field?null:{})}},created(){this.type=this.formCreateInject.form.$form();const e=(this.expand||0)-this.value.length;e>0&&this.expandRule(e);for(let t=0;t<this.value.length;t++)this.addRule(t)},render(){const e=this.sort,t=this.button,i=this.type,s=this.disabled,n=e.length===0?this.$scopedSlots.default?this.$scopedSlots.default({vm:this,add:this.add}):React.createElement("div",{key:"a_def",class:"_fc-group-plus-minus _fc-group-add","on-click":this.add}):e.map((r,c)=>{const{rule:f,options:$}=this.cacheRule[r],y=t&&!s?this.makeIcon(e.length,c,r):[];return React.createElement("div",{class:"_fc-group-container",key:r},React.createElement(i,{key:r,on:{"update:value":h=>this.formData(r,h),"emit-event":(h,...v)=>this.emitEvent(h,v,c,r),input:h=>this.add$f(c,r,h)},props:{disabled:s,inFor:!0,value:this.field?{[this.field]:this._value(this.value[c])}:this.value[c],rule:f,option:$,extendOption:!0}}),React.createElement("div",{class:"_fc-group-idx"},c+1),y.length?React.createElement("div",{class:"_fc-group-handle"},y):null)});return React.createElement("div",{key:"con",class:"_fc-group "+(s?"_fc-group-disabled":"")},n)}}});
10
+ (function(l,u){typeof exports=="object"&&typeof module!="undefined"?module.exports=u(require("vue")):typeof define=="function"&&define.amd?define(["vue"],u):(l=typeof globalThis!="undefined"?globalThis:l||self,l.FcGroup=u(l.Vue))})(this,function(l){"use strict";var w=Object.defineProperty;var $=Object.getOwnPropertySymbols;var x=Object.prototype.hasOwnProperty,F=Object.prototype.propertyIsEnumerable;var O=(l,u,c)=>u in l?w(l,u,{enumerable:!0,configurable:!0,writable:!0,value:c}):l[u]=c,g=(l,u)=>{for(var c in u||(u={}))x.call(u,c)&&O(l,c,u[c]);if($)for(var c of $(u))F.call(u,c)&&O(l,c,u[c]);return l};function u(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}function c(){return c=Object.assign?Object.assign.bind():function(e){for(var t,r=1;r<arguments.length;r++)for(var s in t=arguments[r],t)Object.prototype.hasOwnProperty.call(t,s)&&(e[s]=t[s]);return e},c.apply(this,arguments)}var j=["attrs","props","domProps"],R=["class","style","directives"],A=["on","nativeOn"],V=function(e){return e.reduce(function(t,r){for(var s in r)if(!t[s])t[s]=r[s];else if(j.indexOf(s)!==-1)t[s]=c({},t[s],r[s]);else if(R.indexOf(s)!==-1){var i=t[s]instanceof Array?t[s]:[t[s]],n=r[s]instanceof Array?r[s]:[r[s]];t[s]=[].concat(i,n)}else if(A.indexOf(s)!==-1)for(var o in r[s])if(t[s][o]){var a=t[s][o]instanceof Array?t[s][o]:[t[s][o]],y=r[s][o]instanceof Array?r[s][o]:[r[s][o]];t[s][o]=[].concat(a,y)}else t[s][o]=r[s][o];else if(s==="hook")for(var f in r[s])t[s][f]=t[s][f]?S(t[s][f],r[s][f]):r[s][f];else t[s]=r[s];return t},{})},S=function(e,t){return function(){e&&e.apply(this,arguments),t&&t.apply(this,arguments)}},B=V;const E=u(B),h={type(e,t){return Object.prototype.toString.call(e)==="[object "+t+"]"},Undef(e){return e==null},Element(e){return typeof e=="object"&&e!==null&&e.nodeType===1&&!h.Object(e)},trueArray(e){return Array.isArray(e)&&e.length>0},Function(e){const t=this.getType(e);return t==="Function"||t==="AsyncFunction"},getType(e){const t=Object.prototype.toString.call(e);return/^\[object (.*)\]$/.exec(t)[1]},empty(e){return e==null||Array.isArray(e)&&Array.isArray(e)&&!e.length?!0:typeof e=="string"&&!e}};["Date","Object","String","Boolean","Array","Number"].forEach(e=>{h[e]=function(t){return h.type(t,e)}});function D(e,t){return{}.hasOwnProperty.call(e,t)}function d(e,t,r){l.set(e,t,r)}function m(e,t={},r){let s=!1;for(let i in t)if(Object.prototype.hasOwnProperty.call(t,i)){let n=t[i];if((s=Array.isArray(n))||h.Object(n)){let o=e[i]===void 0;if(s)s=!1,o&&d(e,i,[]);else if(n._clone&&r!==void 0){d(e,i,n._clone());continue}else o&&d(e,i,{});e[i]=m(e[i],n,r)}else d(e,i,n),h.Undef(n)||(h.Undef(n.__json)||(e[i].__json=n.__json),h.Undef(n.__origin)||(e[i].__origin=n.__origin))}return e}function v(e){return m({},{value:e}).value}const I=Object.assign||function(e){for(let t,r=1;r<arguments.length;r++)for(let s in t=arguments[r],t)Object.prototype.hasOwnProperty.call(t,s)&&d(e,s,t[s]);return e};function b(){return I.apply(this,arguments)}return{name:"fcGroup",props:{field:String,rule:[Array,Object],rules:Array,expand:Number,options:Object,formCreateInject:{type:Object,required:!0},button:{type:Boolean,default:!0},max:{type:Number,default:0},min:{type:Number,default:0},value:{type:Array,default:()=>[]},sortBtn:{type:Boolean,default:!0},defaultValue:Object,disabled:{type:Boolean,default:!1},syncDisabled:{type:Boolean,default:!0},onBeforeRemove:{type:Function,default:()=>{}},onBeforeAdd:{type:Function,default:()=>{}},parse:Function},data(){return{len:0,cacheRule:{},cacheValue:{},sort:[],type:void 0}},computed:{formRule(){return this.rules?this.rules:this.rule?Array.isArray(this.rule)?this.rule:[this.rule]:[]}},watch:{cacheRule:{handler(e){this.sort=Object.keys(e)},immediate:!0},formRule:{handler(e,t){Object.keys(this.cacheRule).forEach(r=>{const s=this.cacheRule[r];if(s.$f){const i=s.$f.formData();if(e===t)s.$f.deferSyncValue(()=>{m(s.rule,e),s.$f.setValue(i)},!0);else{const n=s.$f.formData();s.$f.once("reloading",()=>{s.$f.setValue(n)}),s.rule=v(e)}}})},deep:!0},expand(e){let t=e-this.value.length;t>0&&this.expandRule(t)},value(e,t){e=e||[];let r=this.sort,s=r.length,i=s-e.length;if(i<0){for(let n=i;n<0;n++)this.addRule(e.length+n);this.sort=Object.keys(this.cacheRule);for(let n=0;n<s;n++)this.setValue(r[n],e[n])}else{if(i>0){for(let n=0;n<i;n++)this.removeRule(r[s-n-1]);this.sort=Object.keys(this.cacheRule)}e.forEach((n,o)=>{this.setValue(r[o],e[o])})}}},methods:{_value(e){return e&&D(e,this.field)?e[this.field]:e},cache(e,t){this.cacheValue[e]=JSON.stringify(t)},input(e){this.$emit("input",e),this.$emit("change",e)},formData(e,t){const r=this.cacheRule,s=this.sort;if(s.filter(n=>r[n].$f).length!==s.length)return;const i=s.map(n=>{const o=e===n?t:g({},this.cacheRule[n].$f.form),a=this.field?o[this.field]||null:o;return this.cache(n,a),a});this.input(i)},setValue(e,t){const r=this.field,s=this.cacheRule[e].$f;r&&(t={[r]:this._value(t)}),this.cacheValue[e]!==JSON.stringify(r?t[r]:t)&&(this.cache(e,t),s&&s.coverValue(t||{}))},addRule(e,t){const r=this.formCreateInject.form.copyRules(this.formRule),s=this.options?g({},this.options):{submitBtn:!1,resetBtn:!1};if(this.defaultValue){s.formData||(s.formData={});const i=v(this.defaultValue);b(s.formData,this.field?{[this.field]:i}:i)}this.parse&&this.parse({rule:r,options:s,index:this.sort.length}),this.$set(this.cacheRule,++this.len,{rule:r,options:s}),t&&this.$nextTick(()=>this.$emit("add",r,Object.keys(this.cacheRule).length-1))},add$f(e,t,r){this.cacheRule[t].$f=r,this.$nextTick(()=>{this.$emit("itemMounted",r,Object.keys(this.cacheRule).indexOf(t))})},removeRule(e,t){const r=Object.keys(this.cacheRule).indexOf(e);this.$delete(this.cacheRule,e),this.$delete(this.cacheValue,e),t&&this.$nextTick(()=>this.$emit("remove",r))},add(e){this.disabled||this.onBeforeAdd(this.value)===!1||this.addRule(e,!0)},del(e,t){if(this.disabled||this.onBeforeRemove(this.value,e)===!1)return;this.removeRule(t,!0);const r=[...this.value];r.splice(e,1),this.input(r)},addIcon(e){const t=this.$createElement;return t("div",{class:"_fc-group-btn _fc-group-plus-minus",on:{click:this.add}})},delIcon(e,t){const r=this.$createElement;return r("div",{class:"_fc-group-btn _fc-group-plus-minus _fc-group-minus",on:{click:()=>this.del(e,t)}})},sortUpIcon(e){const t=this.$createElement;return t("div",{class:"_fc-group-btn _fc-group-arrow _fc-group-up",on:{click:()=>this.changeSort(e,-1)}})},sortDownIcon(e){const t=this.$createElement;return t("div",{class:"_fc-group-btn _fc-group-arrow _fc-group-down",on:{click:()=>this.changeSort(e,1)}})},changeSort(e,t){const r=this.sort[e];this.$set(this.sort,e,this.sort[e+t]),this.sort[e+t]=r,this.formData(0)},makeIcon(e,t,r){if(this.$scopedSlots.button)return this.$scopedSlots.button({total:e,index:t,vm:this,key:r,del:()=>this.del(t,r),add:this.add});const s=[];return(!this.max||e<this.max)&&e===t+1&&s.push(this.addIcon(r)),e>this.min&&s.push(this.delIcon(t,r)),this.sortBtn&&t&&s.push(this.sortUpIcon(t)),this.sortBtn&&t!==e-1&&s.push(this.sortDownIcon(t)),s},emitEvent(e,t,r,s){this.$emit(e,...t,this.cacheRule[s].$f,r)},expandRule(e){for(let t=0;t<e;t++)this.value.push(this.field?null:{})}},created(){this.type=this.formCreateInject.form.$form();const e=(this.expand||0)-this.value.length;e>0&&this.expandRule(e);for(let t=0;t<this.value.length;t++)this.addRule(t)},render(){const e=arguments[0],t=this.sort,r=this.button,s=this.type,i=this.disabled,n=t.length===0?this.$scopedSlots.default?this.$scopedSlots.default({vm:this,add:this.add}):e("div",{key:"a_def",class:"_fc-group-plus-minus _fc-group-add",on:{click:this.add}}):t.map((o,a)=>{const{rule:y,options:f}=this.cacheRule[o],_=r&&!i?this.makeIcon(t.length,a,o):[];return e("div",{class:"_fc-group-container",key:o},[e(s,E([{key:o},{on:{"update:value":p=>this.formData(o,p),"emit-event":(p,...k)=>this.emitEvent(p,k,a,o),input:p=>this.add$f(a,o,p)}},{},{props:{disabled:i,inFor:!0,value:this.field?{[this.field]:this._value(this.value[a])}:this.value[a],rule:y,option:f,extendOption:!0}}])),e("div",{class:"_fc-group-idx"},[a+1]),_.length?e("div",{class:"_fc-group-handle"},[_]):null])});return e("div",{key:"con",class:"_fc-group "+(i?"_fc-group-disabled":"")},[n])}}});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@form-create/component-elm-group",
3
- "version": "2.6.0",
3
+ "version": "2.6.2",
4
4
  "description": "@form-create/element-ui 内置组件",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.es.js",
@@ -33,7 +33,7 @@
33
33
  "author": "xaboy",
34
34
  "license": "MIT",
35
35
  "dependencies": {
36
- "@form-create/utils": "^2.6.0"
36
+ "@form-create/utils": "^2.6.2"
37
37
  },
38
38
  "bugs": {
39
39
  "url": "https://github.com/xaboy/form-create/issues"
@@ -42,5 +42,5 @@
42
42
  "publishConfig": {
43
43
  "access": "public"
44
44
  },
45
- "gitHead": "845ebec86aadbc25added53f03a4506990131486"
45
+ "gitHead": "f823ecdf3757d841d21d2489e85c5153772cde91"
46
46
  }