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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
| "use strict";
|
| exports.__esModule = true;
| exports.default = void 0;
|
| var _utils = require("../utils");
|
| var _scroll = require("../utils/dom/scroll");
|
| var _relation = require("../mixins/relation");
|
| var _clickOutside = require("../mixins/click-outside");
|
| // Utils
| // Mixins
| var _createNamespace = (0, _utils.createNamespace)('dropdown-menu'),
| createComponent = _createNamespace[0],
| bem = _createNamespace[1];
|
| var _default = createComponent({
| mixins: [(0, _relation.ParentMixin)('vanDropdownMenu'), (0, _clickOutside.ClickOutsideMixin)({
| event: 'click',
| method: 'onClickOutside'
| })],
| props: {
| zIndex: [Number, String],
| activeColor: String,
| overlay: {
| type: Boolean,
| default: true
| },
| duration: {
| type: [Number, String],
| default: 0.2
| },
| direction: {
| type: String,
| default: 'down'
| },
| closeOnClickOverlay: {
| type: Boolean,
| default: true
| }
| },
| data: function data() {
| return {
| offset: 0
| };
| },
| computed: {
| scroller: function scroller() {
| return (0, _scroll.getScroller)(this.$el);
| },
| opened: function opened() {
| return this.children.some(function (item) {
| return item.showWrapper;
| });
| },
| barStyle: function barStyle() {
| if (this.opened && (0, _utils.isDef)(this.zIndex)) {
| return {
| zIndex: 1 + this.zIndex
| };
| }
| }
| },
| methods: {
| updateOffset: function updateOffset() {
| if (!this.$refs.bar) {
| return;
| }
|
| var rect = this.$refs.bar.getBoundingClientRect();
|
| if (this.direction === 'down') {
| this.offset = rect.bottom;
| } else {
| this.offset = window.innerHeight - rect.top;
| }
| },
| toggleItem: function toggleItem(active) {
| this.children.forEach(function (item, index) {
| if (index === active) {
| item.toggle();
| } else if (item.showPopup) {
| item.toggle(false, {
| immediate: true
| });
| }
| });
| },
| onClickOutside: function onClickOutside() {
| this.children.forEach(function (item) {
| item.toggle(false);
| });
| }
| },
| render: function render() {
| var _this = this;
|
| var h = arguments[0];
| var Titles = this.children.map(function (item, index) {
| return h("div", {
| "attrs": {
| "role": "button",
| "tabindex": item.disabled ? -1 : 0
| },
| "class": bem('item', {
| disabled: item.disabled
| }),
| "on": {
| "click": function click() {
| if (!item.disabled) {
| _this.toggleItem(index);
| }
| }
| }
| }, [h("span", {
| "class": [bem('title', {
| active: item.showPopup,
| down: item.showPopup === (_this.direction === 'down')
| }), item.titleClass],
| "style": {
| color: item.showPopup ? _this.activeColor : ''
| }
| }, [h("div", {
| "class": "van-ellipsis"
| }, [item.slots('title') || item.displayTitle])])]);
| });
| return h("div", {
| "class": bem()
| }, [h("div", {
| "ref": "bar",
| "style": this.barStyle,
| "class": bem('bar', {
| opened: this.opened
| })
| }, [Titles]), this.slots('default')]);
| }
| });
|
| exports.default = _default;
|
|