component.js
2.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
function e(e, n, i) {
return n in e ? Object.defineProperty(e, n, {
value: i,
enumerable: !0,
configurable: !0,
writable: !0
}) : e[n] = i, e;
}
function n(e, n, i) {
Object.keys(i).forEach(function(t) {
e[t] && (n[i[t]] = e[t]);
});
}
function i(n, i, t) {
var r = t.type, a = t.name, o = t.linked, d = t.unlinked, l = t.linkChanged, c = i.beforeCreate, h = i.destroyed;
"descendant" === r && (n.created = function() {
c && c.bind(this)(), this.children = this.children || [];
}, n.detached = function() {
this.children = [], h && h.bind(this)();
}), n.relations = Object.assign(n.relations || {}, e({}, "../" + a + "/index", {
type: r,
linked: function(e) {
s[r].linked.bind(this)(e), o && o.bind(this)(e);
},
linkChanged: function(e) {
l && l.bind(this)(e);
},
unlinked: function(e) {
s[r].unlinked.bind(this)(e), d && d.bind(this)(e);
}
}));
}
Object.defineProperty(exports, "__esModule", {
value: !0
}), exports.VantComponent = void 0;
var t = require("../mixins/basic"), s = {
ancestor: {
linked: function(e) {
this.parent = e;
},
unlinked: function() {
this.parent = null;
}
},
descendant: {
linked: function(e) {
this.children = this.children || [], this.children.push(e);
},
unlinked: function(e) {
this.children = (this.children || []).filter(function(n) {
return n !== e;
});
}
}
};
exports.VantComponent = function() {
var e = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {}, s = {};
n(e, s, {
data: "data",
props: "properties",
mixins: "behaviors",
methods: "methods",
beforeCreate: "created",
created: "attached",
mounted: "ready",
relations: "relations",
destroyed: "detached",
classes: "externalClasses"
});
var r = e.relation;
r && i(s, e, r), s.externalClasses = s.externalClasses || [], s.externalClasses.push("custom-class"),
s.behaviors = s.behaviors || [], s.behaviors.push(t.basic), e.field && s.behaviors.push("wx://form-field"),
s.properties && Object.keys(s.properties).forEach(function(e) {
Array.isArray(s.properties[e]) && (s.properties[e] = null);
}), s.options = {
multipleSlots: !0,
addGlobalClass: !0
}, Component(s);
};