index.es.js 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. /*!
  2. * FormCreate 低代码表单渲染器
  3. * @form-create/component-elm-radio 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 m = Object.defineProperty;
  10. var a = Object.getOwnPropertySymbols;
  11. var y = Object.prototype.hasOwnProperty, v = Object.prototype.propertyIsEnumerable;
  12. var l = (n, e, r) => e in n ? m(n, e, { enumerable: !0, configurable: !0, writable: !0, value: r }) : n[e] = r, p = (n, e) => {
  13. for (var r in e || (e = {}))
  14. y.call(e, r) && l(n, r, e[r]);
  15. if (a)
  16. for (var r of a(e))
  17. v.call(e, r) && l(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"], A = ["on", "nativeOn"], I = 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 (A.indexOf(t) !== -1)
  37. for (var o in r[t]) if (e[t][o]) {
  38. var h = e[t][o] instanceof Array ? e[t][o] : [e[t][o]], c = r[t][o] instanceof Array ? r[t][o] : [r[t][o]];
  39. e[t][o] = [].concat(h, c);
  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. }, E = I;
  50. const d = /* @__PURE__ */ g(E);
  51. function M(n, e) {
  52. return Object.keys(n).reduce((r, t) => (r.push(n[t]), r), []);
  53. }
  54. const P = "fcRadio", x = {
  55. name: P,
  56. props: {
  57. formCreateInject: {
  58. type: Object,
  59. required: !0
  60. },
  61. value: {},
  62. type: String
  63. },
  64. watch: {
  65. "formCreateInject.options": {
  66. handler() {
  67. this.update();
  68. },
  69. deep: !0
  70. },
  71. value() {
  72. this.update();
  73. }
  74. },
  75. data() {
  76. return {
  77. trueValue: []
  78. };
  79. },
  80. methods: {
  81. options() {
  82. const n = this.formCreateInject.options;
  83. return Array.isArray(n) ? n : [];
  84. },
  85. onInput(n) {
  86. this.$emit("input", this.options().filter((e) => e.label === n).reduce((e, r) => r.value, ""));
  87. },
  88. update() {
  89. this.trueValue = this.options().filter((n) => n.value === this.value).reduce((n, e) => e.label, "");
  90. }
  91. },
  92. created() {
  93. this.update();
  94. },
  95. render() {
  96. const n = arguments[0];
  97. return n("ElRadioGroup", d([{}, this.formCreateInject.prop, {
  98. ref: "el"
  99. }, {
  100. props: {
  101. value: this.trueValue
  102. }
  103. }, {
  104. on: {
  105. input: this.onInput
  106. }
  107. }]), [this.options().map((e, r) => {
  108. const t = p({}, e), i = this.type === "button" ? "ElRadioButton" : "ElRadio";
  109. return delete t.value, n(i, d([{}, {
  110. props: t
  111. }, {
  112. key: i + r + "-" + e.value
  113. }]));
  114. }), M(this.$slots)]);
  115. },
  116. mounted() {
  117. this.$emit("fc.el", this.$refs.el);
  118. }
  119. };
  120. export {
  121. x as default
  122. };