index.es.js 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /*!
  2. * FormCreate 低代码表单渲染器
  3. * @form-create/component-elm-tree 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 f(r) {
  10. return r && r.__esModule && Object.prototype.hasOwnProperty.call(r, "default") ? r.default : r;
  11. }
  12. function i() {
  13. return i = Object.assign ? Object.assign.bind() : function(r) {
  14. for (var t, n = 1; n < arguments.length; n++) for (var e in t = arguments[n], t) Object.prototype.hasOwnProperty.call(t, e) && (r[e] = t[e]);
  15. return r;
  16. }, i.apply(this, arguments);
  17. }
  18. var h = ["attrs", "props", "domProps"], c = ["class", "style", "directives"], d = ["on", "nativeOn"], y = function(r) {
  19. return r.reduce(function(t, n) {
  20. for (var e in n) if (!t[e]) t[e] = n[e];
  21. else if (h.indexOf(e) !== -1) t[e] = i({}, t[e], n[e]);
  22. else if (c.indexOf(e) !== -1) {
  23. var a = t[e] instanceof Array ? t[e] : [t[e]], u = n[e] instanceof Array ? n[e] : [n[e]];
  24. t[e] = [].concat(a, u);
  25. } else if (d.indexOf(e) !== -1)
  26. for (var s in n[e]) if (t[e][s]) {
  27. var l = t[e][s] instanceof Array ? t[e][s] : [t[e][s]], p = n[e][s] instanceof Array ? n[e][s] : [n[e][s]];
  28. t[e][s] = [].concat(l, p);
  29. } else t[e][s] = n[e][s];
  30. else if (e === "hook") for (var o in n[e]) t[e][o] = t[e][o] ? g(t[e][o], n[e][o]) : n[e][o];
  31. else t[e] = n[e];
  32. return t;
  33. }, {});
  34. }, g = function(r, t) {
  35. return function() {
  36. r && r.apply(this, arguments), t && t.apply(this, arguments);
  37. };
  38. }, m = y;
  39. const v = /* @__PURE__ */ f(m);
  40. function O(r) {
  41. return Array.isArray(r) ? r : [null, void 0, ""].indexOf(r) > -1 ? [] : [r];
  42. }
  43. function C(r, t) {
  44. return Object.keys(r).reduce((n, e) => (n.push(r[e]), n), []);
  45. }
  46. const A = "fcTree", j = {
  47. name: A,
  48. formCreateParser: {
  49. mergeProp(r) {
  50. const t = r.prop.props;
  51. t.nodeKey || (t.nodeKey = "id"), t.props || (t.props = {
  52. label: "title"
  53. });
  54. }
  55. },
  56. props: {
  57. formCreateInject: {
  58. type: Object,
  59. required: !0
  60. },
  61. type: {
  62. type: String,
  63. default: "checked"
  64. },
  65. value: {
  66. type: [Array, String, Number],
  67. default: () => []
  68. }
  69. },
  70. watch: {
  71. value() {
  72. this.setValue();
  73. }
  74. },
  75. methods: {
  76. onChange() {
  77. this.updateValue();
  78. },
  79. updateValue() {
  80. if (!this.$refs.tree) return;
  81. const r = this.type.toLocaleLowerCase();
  82. let t;
  83. r === "selected" ? t = this.$refs.tree.getCurrentKey() : t = this.$refs.tree.getCheckedKeys(), this.$emit("input", t);
  84. },
  85. setValue() {
  86. this.type.toLocaleLowerCase() === "selected" ? this.$refs.tree.setCurrentKey(this.value) : this.$refs.tree.setCheckedKeys(O(this.value));
  87. }
  88. },
  89. render() {
  90. const r = arguments[0];
  91. return r("ElTree", v([{}, this.formCreateInject.prop, {
  92. ref: "tree",
  93. on: {
  94. check: () => this.updateValue(),
  95. "node-click": () => this.updateValue()
  96. }
  97. }]), [C(this.$slots)]);
  98. },
  99. mounted() {
  100. this.setValue(), this.$emit("fc.el", this.$refs.tree);
  101. }
  102. };
  103. export {
  104. j as default
  105. };