You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
1 lines
3.2 KiB
1 lines
3.2 KiB
"use strict";var _baseComponent=_interopRequireDefault(require("../helpers/baseComponent")),_popupMixin=_interopRequireDefault(require("../helpers/popupMixin")),_utils=require("./utils");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e}}function ownKeys(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),n.push.apply(n,i)}return n}function _objectSpread(t){for(var e=1;e<arguments.length;e++){var n=null!=arguments[e]?arguments[e]:{};e%2?ownKeys(n,!0).forEach(function(e){_defineProperty(t,e,n[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):ownKeys(n).forEach(function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(n,e))})}return t}function _defineProperty(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}(0,_baseComponent.default)({behaviors:[(0,_popupMixin.default)("#wux-select")],properties:{prefixCls:{type:String,value:"wux-select"},value:{type:[String,Array],value:""},options:{type:Array,value:[]},multiple:{type:Boolean,value:!1},max:{type:Number,value:-1},notFoundContent:{type:null,value:_utils.notFoundContent,observer:function(e){this.setData({mergedNotFoundContent:(0,_utils.getNotFoundContent)(e)})}}},data:{scrollTop:0,mergedOptions:[],mergedNotFoundContent:null},observers:_defineProperty({},"options, multiple",function(e,t){var n=(0,_utils.flattenOptions)(e),i=this.getRealValue(n,this.data.inputValue,t);this.setData({inputValue:i,mergedOptions:n})}),methods:{getRealValue:function(e,t,n){var i=0<arguments.length&&void 0!==e?e:this.data.mergedOptions,o=1<arguments.length&&void 0!==t?t:this.data.inputValue,a=2<arguments.length&&void 0!==n?n:this.data.multiple;return(0,_utils.getRealValue)(i,o,a)},updated:function(e,t){if(!this.hasFieldDecorator||t){var n=this.getRealValue(this.data.mergedOptions,e);this.data.inputValue!==n&&this.setData({inputValue:n})}},setVisibleState:function(n,e){var i=this,o=1<arguments.length&&void 0!==e?e:function(){};if(this.data.popupVisible!==n){var a={mounted:!0,inputValue:this.getRealValue(this.data.mergedOptions,this.data.value),popupVisible:n};this.setData(n?a:{popupVisible:n},function(){if(n){var t=a.inputValue,e=i.getFieldElem();i.hasFieldDecorator&&e&&(t=e.data.value,e.changeValue(t)),i.getBoundingClientRect(function(e){i.scrollIntoView(t,e)})}o()})}},onValueChange:function(e){if(this.data.mounted){var t=this.data,n=(t.options,t.max),i=t.multiple,o=e.detail.selectedValue;i&&1<=n&&n<o.length||(this.setScrollValue(o),this.updated(o,!0),this.triggerEvent("valueChange",this.formatPickerValue(_objectSpread({},e.detail,{value:o}))))}},scrollIntoView:function(e,t){var n=this.data,i=n.options,o=n.multiple,a=(0,_utils.getSelectIndex)(i,e,o),r=i.length,u=Array.isArray(a)?a[a.length-1]:a;-1!==u&&void 0!==u||(u=0);var l=1<=r?parseFloat(t/r*u):0;this.data.scrollTop!==l&&this.setData({scrollTop:l})},getBoundingClientRect:function(e){return this.selectComponent("#wux-select").getBoundingClientRect(e)}},ready:function(){this.setData({mergedNotFoundContent:(0,_utils.getNotFoundContent)(this.data.notFoundContent)})}});
|