1 |
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.POPUP_SELECTOR=exports.DEFAULT_FIELD_NAMES=void 0,exports.convertValue=convertValue,exports.fillFieldNames=fillFieldNames,exports.flattenOptions=flattenOptions,exports.getNotFoundContent=exports.getDefaultProps=void 0,exports.getRealValue=getRealValue,exports.getSelectIndex=getSelectIndex,exports.notFoundContent=void 0;var _props=require("../prompt/props");function ownKeys(e,t){var r,o=Object.keys(e);return Object.getOwnPropertySymbols&&(r=Object.getOwnPropertySymbols(e),t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),o.push.apply(o,r)),o}function _objectSpread(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?ownKeys(Object(r),!0).forEach(function(t){_defineProperty(e,t,r[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ownKeys(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))})}return e}function _defineProperty(t,e,r){return(e=_toPropertyKey(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _toPropertyKey(t){t=_toPrimitive(t,"string");return"symbol"==_typeof(t)?t:String(t)}function _toPrimitive(t,e){if("object"!=_typeof(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0===r)return("string"===e?String:Number)(t);r=r.call(t,e||"default");if("object"!=_typeof(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}function _toConsumableArray(t){return _arrayWithoutHoles(t)||_iterableToArray(t)||_unsupportedIterableToArray(t)||_nonIterableSpread()}function _nonIterableSpread(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function _unsupportedIterableToArray(t,e){var r;if(t)return"string"==typeof t?_arrayLikeToArray(t,e):"Map"===(r="Object"===(r=Object.prototype.toString.call(t).slice(8,-1))&&t.constructor?t.constructor.name:r)||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?_arrayLikeToArray(t,e):void 0}function _iterableToArray(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}function _arrayWithoutHoles(t){if(Array.isArray(t))return _arrayLikeToArray(t)}function _arrayLikeToArray(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,o=new Array(e);r<e;r++)o[r]=t[r];return o}function _typeof(t){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}var POPUP_SELECTOR=exports.POPUP_SELECTOR="#wux-select",getDefaultProps=exports.getDefaultProps=function(){return{value:{type:[String,Array],value:""},options:{type:Array,value:[]},iconPosition:{type:String,value:""},multiple:{type:Boolean,value:!1},max:{type:Number,value:-1}}},notFoundContent=exports.notFoundContent={icon:_props.defaultIcon,title:"",text:"暂无数据"},getNotFoundContent=exports.getNotFoundContent=function(t){return null!==t&&"object"===_typeof(t)?Object.assign({},notFoundContent,t):"string"==typeof t?Object.assign({},notFoundContent,{text:t}):null===t||!1===t?null:notFoundContent};function convertValue(t){return Array.isArray(t)?_toConsumableArray(t):"string"==typeof t?[t]:[]}function getSelectIndex(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",r=2<arguments.length&&void 0!==arguments[2]&&arguments[2],e=convertValue(e),o=t.map(function(t){return t.value||t}).filter(function(t){return!!t});return r?e.map(function(t){return o.indexOf(t)}):o.indexOf(e[0])}function getRealValue(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:[],e=1<arguments.length&&void 0!==arguments[1]?arguments[1]:"",r=2<arguments.length&&void 0!==arguments[2]&&arguments[2],e=convertValue(e),o=t.map(function(t){return t.value||t}).filter(function(t){return!!t});return r?e.filter(function(t){return o.includes(t)}):o.includes(e[0])?e[0]:""}var DEFAULT_FIELD_NAMES=exports.DEFAULT_FIELD_NAMES={title:"title",value:"value",options:"options"};function fillFieldNames(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{},t=_objectSpread(_objectSpread({},DEFAULT_FIELD_NAMES),t),e=t.title,r=t.value,t=t.options;return{title:e||DEFAULT_FIELD_NAMES.title,value:r||DEFAULT_FIELD_NAMES.value,options:t||DEFAULT_FIELD_NAMES.options}}function flattenOptions(t){var e=(1<arguments.length&&void 0!==arguments[1]?arguments[1]:{}).fieldNames,i=[],e=fillFieldNames(void 0===e?DEFAULT_FIELD_NAMES:e),a=e.title,u=e.value,l=e.options;return function o(t,n){t.forEach(function(t){var e,r=(t="string"==typeof t?_defineProperty(_defineProperty({},a,t),u,t):t)[a];!n&&l in t?(void 0===(e=r)&&(e=t.title),i.push(_objectSpread(_objectSpread({},t),{},{isGroup:!0,data:t,title:e})),o(t[l],!0)):(e=t[u],i.push(_objectSpread(_objectSpread({},t),{},{isGroupOption:n,data:t,title:r,value:e})))})}(t,!1),i}
|