-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpicker.min.js
executable file
·1 lines (1 loc) · 4.74 KB
/
picker.min.js
1
Object.defineProperty(exports,'__esModule',{value:!0});var _stringify=__webpack_require__("mvHQ"),_stringify2=_interopRequireDefault(_stringify),_typeof2=__webpack_require__("pFYg"),_typeof3=_interopRequireDefault(_typeof2),_scroller=__webpack_require__("+geU"),_scroller2=_interopRequireDefault(_scroller),_flexbox=__webpack_require__("F3HL"),_chain=__webpack_require__("zDi5"),_chain2=_interopRequireDefault(_chain),_value2name=__webpack_require__("NE4E"),_value2name2=_interopRequireDefault(_value2name),_isArray=__webpack_require__("cEdU"),_isArray2=_interopRequireDefault(_isArray);function _interopRequireDefault(a){return a&&a.__esModule?a:{default:a}}exports.default={name:'picker',components:{Flexbox:_flexbox.Flexbox,FlexboxItem:_flexbox.FlexboxItem},created:function created(){if(0!==this.columns){var a=this.columns;this.store=new _chain2.default(this.data,a,this.fixedColumns||this.columns),this.currentData=this.store.getColumns(this.value)}},mounted:function mounted(){var a=this;this.uuid=Math.random().toString(36).substring(3,8),this.$nextTick(function(){a.render(a.currentData,a.currentValue)})},props:{data:Array,columns:{type:Number,default:0},fixedColumns:{type:Number,default:0},value:Array,itemClass:{type:String,default:'scroller-item'},columnWidth:Array},methods:{getNameValues:function getNameValues(){return(0,_value2name2.default)(this.currentValue,this.data)},getId:function getId(a){return'#vux-picker-'+this.uuid+'-'+a},render:function render(a,b){this.count=this.currentData.length;var c=this;if(a&&a.length){var d=this.currentData.length;if(b.length<d)for(var h=0;h<d;h++)'development'==="production"&&'undefined'==typeof a[h][0]&&(0,_isArray2.default)(this.data)&&this.data[0]&&'undefined'!=typeof this.data[0].value&&!this.columns&&console.error('[VUX error] \u6E32\u67D3\u51FA\u9519\uFF0C\u5982\u679C\u4E3A\u8054\u52A8\u6A21\u5F0F\uFF0C\u9700\u8981\u6307\u5B9A columns(\u5217\u6570)'),this.$set(c.currentValue,h,a[h][0].value||a[h][0]);for(var e,f=function(d){return document.querySelector(c.getId(d))?void(c.scroller[d]&&c.scroller[d].destroy(),c.scroller[d]=new _scroller2.default(c.getId(d),{data:a[d],defaultValue:b[d]||a[d][0].value,itemClass:c.itemClass,onSelect:function onSelect(a){c.$set(c.currentValue,d,a),(!this.columns||this.columns&&c.getValue().length===c.store.count)&&c.$nextTick(function(){c.$emit('on-change',c.getValue())}),0!==c.columns&&c.renderChain(d+1)}}),c.currentValue&&c.scroller[d].select(b[d])):{v:void 0}},d=0;d<a.length;d++)if(e=f(d),'object'===('undefined'==typeof e?'undefined':(0,_typeof3.default)(e)))return e.v}},renderChain:function renderChain(a){if(this.columns&&!(a>this.count-1)){var b=this,c=this.getId(a);this.scroller[a].destroy();var d=this.store.getChildren(b.getValue()[a-1]);this.scroller[a]=new _scroller2.default(c,{data:d,itemClass:b.item_class,onSelect:function onSelect(c){b.$set(b.currentValue,a,c),b.$nextTick(function(){b.$emit('on-change',b.getValue())}),b.renderChain(a+1)}}),d.length?(this.$set(this.currentValue,a,d[0].value),this.renderChain(a+1)):this.$set(this.currentValue,a,null)}},getValue:function getValue(){for(var a=[],b=0;b<this.currentData.length;b++)if(this.scroller[b])a.push(this.scroller[b].value);else return[];return a},emitValueChange:function emitValueChange(a){(!this.columns||this.columns&&a.length===this.store.count)&&this.$emit('on-change',a)}},data:function data(){return{scroller:[],count:0,uuid:'',currentData:this.data,currentValue:this.value}},watch:{value:function value(a){(0,_stringify2.default)(a)!==(0,_stringify2.default)(this.currentValue)&&(this.currentValue=a)},currentValue:function currentValue(a,b){if(this.$emit('input',a),0!==this.columns)0<a.length&&(0,_stringify2.default)(a)!==(0,_stringify2.default)(b)&&(this.currentData=this.store.getColumns(a),this.$nextTick(function(){this.render(this.currentData,a)}));else if(a.length)for(var c=0;c<a.length;c++)this.scroller[c]&&this.scroller[c].value!==a[c]&&this.scroller[c].select(a[c]);else this.render(this.currentData,[])},data:function data(a){(0,_stringify2.default)(a)!==(0,_stringify2.default)(this.currentData)&&(this.currentData=a)},currentData:function currentData(a){var b=this;if('[object Array]'===Object.prototype.toString.call(a[0]))this.$nextTick(function(){b.render(a,b.currentValue),b.$nextTick(function(){b.emitValueChange(b.getValue()),(0,_stringify2.default)(b.getValue())!==(0,_stringify2.default)(b.currentValue)&&(!b.columns||b.columns&&b.getValue().length===b.store.count)&&(b.currentValue=b.getValue())})});else if(0!==this.columns){if(!a.length)return;var c=this.columns;this.store=new _chain2.default(a,c,this.fixedColumns||this.columns),this.currentData=this.store.getColumns(this.currentValue)}}},beforeDestroy:function beforeDestroy(){for(var a=0;a<this.count;a++)this.scroller[a]&&this.scroller[a].destroy(),this.scroller[a]=null}};