index.es.js 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*!
  2. * FormCreate 低代码表单渲染器
  3. * @form-create/component-subform v2.6.2
  4. * (c) 2018-2024 xaboy
  5. * Github https://github.com/xaboy/form-create
  6. * Site https://form-create.com/
  7. * Released under the MIT License.
  8. */
  9. var d = Object.defineProperty;
  10. var o = Object.getOwnPropertySymbols;
  11. var m = Object.prototype.hasOwnProperty, y = Object.prototype.propertyIsEnumerable;
  12. var u = (r, e, n) => e in r ? d(r, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : r[e] = n, l = (r, e) => {
  13. for (var n in e || (e = {}))
  14. m.call(e, n) && u(r, n, e[n]);
  15. if (o)
  16. for (var n of o(e))
  17. y.call(e, n) && u(r, n, e[n]);
  18. return r;
  19. };
  20. function g(r) {
  21. return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
  22. }
  23. function a() {
  24. return a = Object.assign ? Object.assign.bind() : function(r) {
  25. for (var e, n = 1; n < arguments.length; n++) for (var t in e = arguments[n], e) Object.prototype.hasOwnProperty.call(e, t) && (r[t] = e[t]);
  26. return r;
  27. }, a.apply(this, arguments);
  28. }
  29. var v = ["attrs", "props", "domProps"], O = ["class", "style", "directives"], j = ["on", "nativeOn"], $ = function(r) {
  30. return r.reduce(function(e, n) {
  31. for (var t in n) if (!e[t]) e[t] = n[t];
  32. else if (v.indexOf(t) !== -1) e[t] = a({}, e[t], n[t]);
  33. else if (O.indexOf(t) !== -1) {
  34. var h = e[t] instanceof Array ? e[t] : [e[t]], c = n[t] instanceof Array ? n[t] : [n[t]];
  35. e[t] = [].concat(h, c);
  36. } else if (j.indexOf(t) !== -1)
  37. for (var s in n[t]) if (e[t][s]) {
  38. var f = e[t][s] instanceof Array ? e[t][s] : [e[t][s]], p = n[t][s] instanceof Array ? n[t][s] : [n[t][s]];
  39. e[t][s] = [].concat(f, p);
  40. } else e[t][s] = n[t][s];
  41. else if (t === "hook") for (var i in n[t]) e[t][i] = e[t][i] ? A(e[t][i], n[t][i]) : n[t][i];
  42. else e[t] = n[t];
  43. return e;
  44. }, {});
  45. }, A = function(r, e) {
  46. return function() {
  47. r && r.apply(this, arguments), e && e.apply(this, arguments);
  48. };
  49. }, R = $;
  50. const V = /* @__PURE__ */ g(R), M = "fcSubForm", D = {
  51. name: M,
  52. props: {
  53. rule: Array,
  54. options: Object,
  55. formCreateInject: {
  56. type: Object,
  57. required: !0
  58. },
  59. value: {
  60. type: Object,
  61. default: () => ({})
  62. },
  63. disabled: {
  64. type: Boolean,
  65. default: !1
  66. },
  67. syncDisabled: {
  68. type: Boolean,
  69. default: !0
  70. }
  71. },
  72. data() {
  73. return {
  74. cacheRule: {},
  75. cacheValue: {},
  76. type: void 0
  77. };
  78. },
  79. watch: {
  80. value(r) {
  81. this.setValue(r);
  82. }
  83. },
  84. methods: {
  85. formData(r) {
  86. this.cacheValue = JSON.stringify(r), this.$emit("input", r), this.$emit("change", r);
  87. },
  88. setValue(r) {
  89. const e = JSON.stringify(r);
  90. this.cacheValue !== e && (this.cacheValue = e, this.cacheRule.$f.coverValue(r || {}));
  91. },
  92. addRule() {
  93. const r = this.options ? this.options : {
  94. submitBtn: !1,
  95. resetBtn: !1
  96. };
  97. r.formData = l({}, this.value || {}), this.cacheRule = {
  98. rule: this.rule,
  99. options: r
  100. };
  101. },
  102. add$f(r) {
  103. this.cacheRule.$f = r, this.$nextTick(() => {
  104. this.$emit("itemMounted", r);
  105. });
  106. },
  107. emitEvent(r, ...e) {
  108. this.$emit(r, ...e);
  109. }
  110. },
  111. created() {
  112. this.addRule(), this.type = this.formCreateInject.form.$form();
  113. },
  114. render() {
  115. const r = arguments[0], {
  116. rule: e,
  117. options: n
  118. } = this.cacheRule, t = this.type;
  119. return r(t, V([{}, {
  120. on: {
  121. "update:value": this.formData,
  122. "emit-event": this.emitEvent,
  123. input: this.add$f
  124. }
  125. }, {}, {
  126. props: {
  127. rule: e,
  128. option: n,
  129. disabled: this.disabled,
  130. extendOption: !0
  131. }
  132. }]));
  133. }
  134. };
  135. export {
  136. D as default
  137. };