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
85
| import { createNamespace } from '../utils';
| import { ParentMixin } from '../mixins/relation';
|
| var _createNamespace = createNamespace('row'),
| createComponent = _createNamespace[0],
| bem = _createNamespace[1];
|
| export default createComponent({
| mixins: [ParentMixin('vanRow')],
| props: {
| type: String,
| align: String,
| justify: String,
| tag: {
| type: String,
| default: 'div'
| },
| gutter: {
| type: [Number, String],
| default: 0
| }
| },
| computed: {
| spaces: function spaces() {
| var gutter = Number(this.gutter);
|
| if (!gutter) {
| return;
| }
|
| var spaces = [];
| var groups = [[]];
| var totalSpan = 0;
| this.children.forEach(function (item, index) {
| totalSpan += Number(item.span);
|
| if (totalSpan > 24) {
| groups.push([index]);
| totalSpan -= 24;
| } else {
| groups[groups.length - 1].push(index);
| }
| });
| groups.forEach(function (group) {
| var averagePadding = gutter * (group.length - 1) / group.length;
| group.forEach(function (item, index) {
| if (index === 0) {
| spaces.push({
| right: averagePadding
| });
| } else {
| var left = gutter - spaces[item - 1].right;
| var right = averagePadding - left;
| spaces.push({
| left: left,
| right: right
| });
| }
| });
| });
| return spaces;
| }
| },
| methods: {
| onClick: function onClick(event) {
| this.$emit('click', event);
| }
| },
| render: function render() {
| var _bem;
|
| var h = arguments[0];
| var align = this.align,
| justify = this.justify;
| var flex = this.type === 'flex';
| return h(this.tag, {
| "class": bem((_bem = {
| flex: flex
| }, _bem["align-" + align] = flex && align, _bem["justify-" + justify] = flex && justify, _bem)),
| "on": {
| "click": this.onClick
| }
| }, [this.slots()]);
| }
| });
|
|