1 | ;(function(){
|
2 | (function (global, factory) {
|
3 | if (typeof define === "function" && define.amd) {
|
4 | define(['exports', '../_locale', '../icon', '../popup', '../popup/title-bar', '../popup/mixins', '../popup/mixins/title-bar', '../radio-list', '../radio/mixins', '../scroll-view', '../check-list', '../_style/global.css', './style/index.css'], factory);
|
5 | } else if (typeof exports !== "undefined") {
|
6 | factory(exports, require('../_locale'), require('../icon'), require('../popup'), require('../popup/title-bar'), require('../popup/mixins'), require('../popup/mixins/title-bar'), require('../radio-list'), require('../radio/mixins'), require('../scroll-view'), require('../check-list'), require('../_style/global.css'), require('./style/index.css'));
|
7 | } else {
|
8 | var mod = {
|
9 | exports: {}
|
10 | };
|
11 | factory(mod.exports, global._locale, global.icon, global.popup, global.titleBar, global.mixins, global.titleBar, global.radioList, global.mixins, global.scrollView, global.checkList, global.global, global.index);
|
12 | global.index = mod.exports;
|
13 | }
|
14 | })(this, function (exports, _locale, _icon, _popup, _titleBar, _mixins, _titleBar3, _radioList, _mixins3, _scrollView, _checkList) {
|
15 | 'use strict';
|
16 |
|
17 | Object.defineProperty(exports, "__esModule", {
|
18 | value: true
|
19 | });
|
20 |
|
21 | var _icon2 = _interopRequireDefault(_icon);
|
22 |
|
23 | var _popup2 = _interopRequireDefault(_popup);
|
24 |
|
25 | var _titleBar2 = _interopRequireDefault(_titleBar);
|
26 |
|
27 | var _mixins2 = _interopRequireDefault(_mixins);
|
28 |
|
29 | var _titleBar4 = _interopRequireDefault(_titleBar3);
|
30 |
|
31 | var _radioList2 = _interopRequireDefault(_radioList);
|
32 |
|
33 | var _mixins4 = _interopRequireDefault(_mixins3);
|
34 |
|
35 | var _scrollView2 = _interopRequireDefault(_scrollView);
|
36 |
|
37 | var _checkList2 = _interopRequireDefault(_checkList);
|
38 |
|
39 | function _interopRequireDefault(obj) {
|
40 | return obj && obj.__esModule ? obj : {
|
41 | default: obj
|
42 | };
|
43 | }
|
44 |
|
45 | var _components;
|
46 |
|
47 | function _defineProperty(obj, key, value) {
|
48 | if (key in obj) {
|
49 | Object.defineProperty(obj, key, {
|
50 | value: value,
|
51 | enumerable: true,
|
52 | configurable: true,
|
53 | writable: true
|
54 | });
|
55 | } else {
|
56 | obj[key] = value;
|
57 | }
|
58 |
|
59 | return obj;
|
60 | }
|
61 |
|
62 | exports.default = {
|
63 | name: 'md-selector',
|
64 |
|
65 | mixins: [_mixins2.default, _titleBar4.default, _mixins4.default],
|
66 |
|
67 | components: (_components = {}, _defineProperty(_components, _icon2.default.name, _icon2.default), _defineProperty(_components, _radioList2.default.name, _radioList2.default), _defineProperty(_components, _checkList2.default.name, _checkList2.default), _defineProperty(_components, _popup2.default.name, _popup2.default), _defineProperty(_components, _titleBar2.default.name, _titleBar2.default), _defineProperty(_components, _scrollView2.default.name, _scrollView2.default), _components),
|
68 |
|
69 | props: {
|
70 | data: {
|
71 | type: Array,
|
72 | default: function _default() {
|
73 | return [];
|
74 | }
|
75 | },
|
76 | defaultValue: {
|
77 | default: ''
|
78 | },
|
79 | isCheck: {
|
80 | type: Boolean,
|
81 | default: false
|
82 | },
|
83 | maxHeight: {
|
84 | type: [Number, String],
|
85 | default: 'auto'
|
86 | },
|
87 | minHeight: {
|
88 | type: [Number, String],
|
89 | default: 'auto'
|
90 | },
|
91 | cancelText: {
|
92 | default: function _default() {
|
93 | return this.okText ? (0, _locale.t)('md.selector.cancel') : '';
|
94 | }
|
95 | },
|
96 | iconPosition: {
|
97 | default: 'right'
|
98 | },
|
99 | multi: {
|
100 | type: Boolean,
|
101 | default: false
|
102 | },
|
103 | hideTitleBar: {
|
104 | type: Boolean,
|
105 | default: false
|
106 | }
|
107 |
|
108 | },
|
109 |
|
110 | data: function data() {
|
111 | return {
|
112 | isSelectorShow: this.value,
|
113 | radioKey: Date.now(),
|
114 | checkKey: Date.now() + 1,
|
115 | activeIndex: -1,
|
116 | tmpActiveIndex: -1,
|
117 | multiDefaultValue: []
|
118 | };
|
119 | },
|
120 |
|
121 |
|
122 | computed: {
|
123 | isNeedConfirm: function isNeedConfirm() {
|
124 | return this.okText !== '';
|
125 | },
|
126 | hasSlot: function hasSlot() {
|
127 | return !!this.$scopedSlots.default;
|
128 | }
|
129 | },
|
130 |
|
131 | watch: {
|
132 | value: function value(val) {
|
133 | this.isSelectorShow = val;
|
134 | },
|
135 | isSelectorShow: function isSelectorShow(val) {
|
136 | this.$emit('input', val);
|
137 | },
|
138 |
|
139 | defaultValue: {
|
140 | handler: function handler(val) {
|
141 | if (!this.multi || val === '') {
|
142 | return;
|
143 | }
|
144 |
|
145 | this.multiDefaultValue = !Array.isArray(val) ? [val] : val;
|
146 | },
|
147 |
|
148 | immediate: true
|
149 | }
|
150 | },
|
151 |
|
152 | methods: {
|
153 | $_setScroller: function $_setScroller() {
|
154 | this.$refs.scroll.reflowScroller();
|
155 | },
|
156 | $_onSelectorConfirm: function $_onSelectorConfirm() {
|
157 | if (this.multi) {
|
158 | this.$emit('confirm', this.multiDefaultValue.slice());
|
159 | this.isSelectorShow = false;
|
160 | return;
|
161 | }
|
162 |
|
163 | if (this.tmpActiveIndex > -1) {
|
164 | this.activeIndex = this.tmpActiveIndex;
|
165 | this.isSelectorShow = false;
|
166 | this.$emit('confirm', this.data[this.activeIndex]);
|
167 | }
|
168 | },
|
169 | $_onSelectorCancel: function $_onSelectorCancel() {
|
170 | this.isSelectorShow = false;
|
171 | this.tmpActiveIndex = this.activeIndex;
|
172 |
|
173 | if (this.tmpActiveIndex !== -1) {
|
174 | this.$refs.radio.selectByIndex(this.tmpActiveIndex);
|
175 | } else {
|
176 | this.radioKey = Date.now();
|
177 | this.checkKey = Date.now() + 1;
|
178 | }
|
179 |
|
180 | this.$emit('cancel');
|
181 | },
|
182 | $_onSelectorChoose: function $_onSelectorChoose(item, index) {
|
183 | this.tmpActiveIndex = index;
|
184 | if (!this.isNeedConfirm) {
|
185 | this.activeIndex = index;
|
186 | this.isSelectorShow = false;
|
187 | }
|
188 |
|
189 | this.$emit('choose', item);
|
190 | },
|
191 | $_onSelectorShow: function $_onSelectorShow() {
|
192 | this.$_setScroller();
|
193 | this.$emit('show');
|
194 | },
|
195 | $_onSelectorHide: function $_onSelectorHide() {
|
196 | this.$emit('hide');
|
197 | }
|
198 | }
|
199 | };
|
200 | });
|
201 | })()
|
202 | if (module.exports.__esModule) module.exports = module.exports.default
|
203 | var __vue__options__ = (typeof module.exports === "function"? module.exports.options: module.exports)
|
204 | __vue__options__.render = function render () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{staticClass:"md-selector",class:{
|
205 | 'is-normal': !_vm.isCheck,
|
206 | 'is-check': _vm.isCheck
|
207 | }},[_c('md-popup',{staticClass:"inner-popup",attrs:{"position":"bottom","mask-closable":_vm.maskClosable},on:{"show":_vm.$_onSelectorShow,"hide":_vm.$_onSelectorHide,"maskClick":_vm.$_onSelectorCancel},model:{value:(_vm.isSelectorShow),callback:function ($$v) {_vm.isSelectorShow=$$v},expression:"isSelectorShow"}},[_c('md-popup-title-bar',{directives:[{name:"show",rawName:"v-show",value:(!_vm.hideTitleBar || _vm.isNeedConfirm),expression:"!hideTitleBar || isNeedConfirm"}],attrs:{"title":_vm.title,"describe":_vm.describe,"ok-text":_vm.okText,"cancel-text":_vm.cancelText,"large-radius":_vm.largeRadius,"only-close":!_vm.isCheck && !_vm.isNeedConfirm && !_vm.cancelText},on:{"confirm":_vm.$_onSelectorConfirm,"cancel":_vm.$_onSelectorCancel}}),_vm._v(" "),_c('div',{staticClass:"md-selector-container"},[_c('md-scroll-view',{ref:"scroll",style:({
|
208 | maxHeight: ("" + _vm.maxHeight),
|
209 | minHeight: ("" + _vm.minHeight)
|
210 | }),attrs:{"scrolling-x":false}},[_vm._t("header"),_vm._v(" "),(!_vm.multi)?[_c('md-radio-list',{key:_vm.radioKey,ref:"radio",staticClass:"md-selector-list",attrs:{"value":_vm.defaultValue,"options":_vm.data,"is-slot-scope":_vm.hasSlot,"icon":_vm.icon,"icon-disabled":_vm.iconDisabled,"icon-inverse":_vm.iconInverse,"icon-position":_vm.iconPosition,"icon-size":_vm.iconSize,"icon-svg":_vm.iconSvg},on:{"change":_vm.$_onSelectorChoose},scopedSlots:_vm._u([{key:"default",fn:function(ref){
|
211 | var option = ref.option;
|
212 | var index = ref.index;
|
213 | var selected = ref.selected;
|
214 | return [_vm._t("default",null,{"option":option,"index":index,"selected":selected})]}}],null,true)})]:[_c('md-check-list',{key:_vm.checkKey,ref:"check",staticClass:"md-selector-list",attrs:{"options":_vm.data,"is-slot-scope":_vm.hasSlot,"icon":_vm.icon,"icon-disabled":_vm.iconDisabled,"icon-inverse":_vm.iconInverse,"icon-position":_vm.iconPosition,"icon-size":_vm.iconSize,"icon-svg":_vm.iconSvg},scopedSlots:_vm._u([{key:"default",fn:function(ref){
|
215 | var option = ref.option;
|
216 | var index = ref.index;
|
217 | var selected = ref.selected;
|
218 | return [_vm._t("default",null,{"option":option,"index":index,"selected":selected})]}}],null,true),model:{value:(_vm.multiDefaultValue),callback:function ($$v) {_vm.multiDefaultValue=$$v},expression:"multiDefaultValue"}})],_vm._v(" "),_vm._t("footer")],2)],1)],1)],1)}
|
219 | __vue__options__.staticRenderFns = []
|