index.es.js 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*!
  2. * FormCreate 低代码表单渲染器
  3. * @form-create/component-elm-checkbox v2.6.3
  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 y = Object.defineProperty;
  10. var a = Object.getOwnPropertySymbols;
  11. var m = Object.prototype.hasOwnProperty, v = Object.prototype.propertyIsEnumerable;
  12. var p = (n, e, r) => e in n ? y(n, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : n[e] = r, l = (n, e) => {
  13. for (var r in e || (e = {}))
  14. m.call(e, r) && p(n, r, e[r]);
  15. if (a)
  16. for (var r of a(e))
  17. v.call(e, r) && p(n, r, e[r]);
  18. return n;
  19. };
  20. function g(n) {
  21. return n && n.__esModule && Object.prototype.hasOwnProperty.call(n, "default") ? n.default : n;
  22. }
  23. function u() {
  24. return u = Object.assign ? Object.assign.bind() : function(n) {
  25. for (var e, r = 1; r < arguments.length; r++) for (var t in e = arguments[r], e) Object.prototype.hasOwnProperty.call(e, t) && (n[t] = e[t]);
  26. return n;
  27. }, u.apply(this, arguments);
  28. }
  29. var O = ["attrs", "props", "domProps"], j = ["class", "style", "directives"], x = ["on", "nativeOn"], A = function(n) {
  30. return n.reduce(function(e, r) {
  31. for (var t in r) if (!e[t]) e[t] = r[t];
  32. else if (O.indexOf(t) !== -1) e[t] = u({}, e[t], r[t]);
  33. else if (j.indexOf(t) !== -1) {
  34. var i = e[t] instanceof Array ? e[t] : [e[t]], f = r[t] instanceof Array ? r[t] : [r[t]];
  35. e[t] = [].concat(i, f);
  36. } else if (x.indexOf(t) !== -1)
  37. for (var o in r[t]) if (e[t][o]) {
  38. var c = e[t][o] instanceof Array ? e[t][o] : [e[t][o]], d = r[t][o] instanceof Array ? r[t][o] : [r[t][o]];
  39. e[t][o] = [].concat(c, d);
  40. } else e[t][o] = r[t][o];
  41. else if (t === "hook") for (var s in r[t]) e[t][s] = e[t][s] ? C(e[t][s], r[t][s]) : r[t][s];
  42. else e[t] = r[t];
  43. return e;
  44. }, {});
  45. }, C = function(n, e) {
  46. return function() {
  47. n && n.apply(this, arguments), e && e.apply(this, arguments);
  48. };
  49. }, k = A;
  50. const h = /* @__PURE__ */ g(k);
  51. function I(n, e) {
  52. return Object.keys(n).reduce((r, t) => (r.push(n[t]), r), []);
  53. }
  54. const E = "fcCheckbox", P = {
  55. name: E,
  56. props: {
  57. formCreateInject: {
  58. type: Object,
  59. required: !0
  60. },
  61. value: {
  62. type: Array,
  63. default: () => []
  64. },
  65. type: String
  66. },
  67. watch: {
  68. "formCreateInject.options": {
  69. handler() {
  70. this.update();
  71. },
  72. deep: !0
  73. },
  74. value() {
  75. this.update();
  76. }
  77. },
  78. data() {
  79. return {
  80. trueValue: []
  81. };
  82. },
  83. methods: {
  84. options() {
  85. const n = this.formCreateInject.options;
  86. return Array.isArray(n) ? n : [];
  87. },
  88. onInput(n) {
  89. this.$emit("input", this.options().filter((e) => n.indexOf(e.label) !== -1).map((e) => e.value).filter((e) => e !== void 0));
  90. },
  91. update() {
  92. const n = Array.isArray(this.value) ? this.value : [this.value];
  93. this.trueValue = this.options().filter((e) => n.indexOf(e.value) !== -1).map((e) => e.label);
  94. }
  95. },
  96. created() {
  97. this.update();
  98. },
  99. render() {
  100. const n = arguments[0];
  101. return n("ElCheckboxGroup", h([{}, this.formCreateInject.prop, {}, {
  102. props: {
  103. value: this.trueValue
  104. }
  105. }, {
  106. ref: "el",
  107. on: {
  108. input: this.onInput
  109. }
  110. }]), [this.options().map((e, r) => {
  111. const t = l({}, e), i = this.type === "button" ? "ElCheckboxButton" : "ElCheckbox";
  112. return delete t.value, n(i, h([{}, {
  113. props: t
  114. }, {
  115. key: i + r + "-" + e.value
  116. }]));
  117. }), I(this.$slots)]);
  118. },
  119. mounted() {
  120. this.$emit("fc.el", this.$refs.el);
  121. }
  122. };
  123. export {
  124. P as default
  125. };