index.es.js 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*!
  2. * FormCreate 低代码表单渲染器
  3. * @form-create/component-elm-select 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. function p(e) {
  10. return e && e.__esModule && Object.prototype.hasOwnProperty.call(e, "default") ? e.default : e;
  11. }
  12. function y() {
  13. return y = Object.assign ? Object.assign.bind() : function(e) {
  14. for (var t, n = 1; n < arguments.length; n++) for (var r in t = arguments[n], t) Object.prototype.hasOwnProperty.call(t, r) && (e[r] = t[r]);
  15. return e;
  16. }, y.apply(this, arguments);
  17. }
  18. var m = ["attrs", "props", "domProps"], d = ["class", "style", "directives"], g = ["on", "nativeOn"], O = function(e) {
  19. return e.reduce(function(t, n) {
  20. for (var r in n) if (!t[r]) t[r] = n[r];
  21. else if (m.indexOf(r) !== -1) t[r] = y({}, t[r], n[r]);
  22. else if (d.indexOf(r) !== -1) {
  23. var a = t[r] instanceof Array ? t[r] : [t[r]], s = n[r] instanceof Array ? n[r] : [n[r]];
  24. t[r] = [].concat(a, s);
  25. } else if (g.indexOf(r) !== -1)
  26. for (var o in n[r]) if (t[r][o]) {
  27. var i = t[r][o] instanceof Array ? t[r][o] : [t[r][o]], c = n[r][o] instanceof Array ? n[r][o] : [n[r][o]];
  28. t[r][o] = [].concat(i, c);
  29. } else t[r][o] = n[r][o];
  30. else if (r === "hook") for (var l in n[r]) t[r][l] = t[r][l] ? A(t[r][l], n[r][l]) : n[r][l];
  31. else t[r] = n[r];
  32. return t;
  33. }, {});
  34. }, A = function(e, t) {
  35. return function() {
  36. e && e.apply(this, arguments), t && t.apply(this, arguments);
  37. };
  38. }, j = O;
  39. const f = /* @__PURE__ */ p(j), u = {
  40. type(e, t) {
  41. return Object.prototype.toString.call(e) === "[object " + t + "]";
  42. },
  43. Undef(e) {
  44. return e == null;
  45. },
  46. Element(e) {
  47. return typeof e == "object" && e !== null && e.nodeType === 1 && !u.Object(e);
  48. },
  49. trueArray(e) {
  50. return Array.isArray(e) && e.length > 0;
  51. },
  52. Function(e) {
  53. const t = this.getType(e);
  54. return t === "Function" || t === "AsyncFunction";
  55. },
  56. getType(e) {
  57. const t = Object.prototype.toString.call(e);
  58. return /^\[object (.*)\]$/.exec(t)[1];
  59. },
  60. empty(e) {
  61. return e == null || Array.isArray(e) && Array.isArray(e) && !e.length ? !0 : typeof e == "string" && !e;
  62. }
  63. };
  64. ["Date", "Object", "String", "Boolean", "Array", "Number"].forEach((e) => {
  65. u[e] = function(t) {
  66. return u.type(t, e);
  67. };
  68. });
  69. function h(e, t) {
  70. return {}.hasOwnProperty.call(e, t);
  71. }
  72. const E = "fcSelect", P = {
  73. name: E,
  74. functional: !0,
  75. props: {
  76. formCreateInject: {
  77. type: Object,
  78. required: !0
  79. }
  80. },
  81. render(e, t) {
  82. const n = (s, o) => {
  83. const i = s.slot;
  84. return e("ElOption", f([{}, {
  85. props: s
  86. }, {
  87. key: "" + o + "-" + s.value
  88. }]), [i ? e("template", {
  89. slot: s.slotName || "default"
  90. }, [u.Function(i) ? s.slot(e) : i]) : null]);
  91. }, r = (s, o) => e("ElOptionGroup", {
  92. attrs: {
  93. label: s.label
  94. },
  95. key: "" + o + "-" + s.label
  96. }, [u.trueArray(s.options) && s.options.map((i, c) => n(i, c))]), a = t.props.formCreateInject.options;
  97. return e("ElSelect", f([{}, t.data, {
  98. ref: "el"
  99. }]), [(Array.isArray(a) ? a : []).map((s, o) => h(s || "", "options") ? r(s, o) : n(s, o)), t.children]);
  100. },
  101. mounted() {
  102. this.$emit("fc.el", this.$refs.el);
  103. }
  104. };
  105. export {
  106. P as default
  107. };