UNPKG

el-button-to-dropdown

Version:

基于element ui 2.x 的按钮转换插件 将按钮转换为el-dropdown

1 lines 3.92 kB
var ButtonToDropdown=function(){"use strict";function t(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function e(e){for(var n=1;n<arguments.length;n++){var o=null!=arguments[n]?arguments[n]:{};n%2?t(Object(o),!0).forEach((function(t){r(e,t,o[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):t(Object(o)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(o,t))}))}return e}function r(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,e||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===e?String:Number)(t)}(t,"string");return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,i,u,l=[],c=!0,a=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;c=!1}else for(;!(c=(n=i.call(r)).done)&&(l.push(n.value),l.length!==e);c=!0);}catch(t){a=!0,o=t}finally{try{if(!c&&null!=r.return&&(u=r.return(),Object(u)!==u))return}finally{if(a)throw o}}return l}}(t,e)||function(t,e){if(!t)return;if("string"==typeof t)return o(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);"Object"===r&&t.constructor&&(r=t.constructor.name);if("Map"===r||"Set"===r)return Array.from(t);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return o(t,e)}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function i(t,e,r,n,o,i,u,l,c,a){"boolean"!=typeof u&&(c=l,l=u,u=!1);const f="function"==typeof r?r.options:r;let s;if(t&&t.render&&(f.render=t.render,f.staticRenderFns=t.staticRenderFns,f._compiled=!0,o&&(f.functional=!0)),n&&(f._scopeId=n),i?(s=function(t){(t=t||this.$vnode&&this.$vnode.ssrContext||this.parent&&this.parent.$vnode&&this.parent.$vnode.ssrContext)||"undefined"==typeof __VUE_SSR_CONTEXT__||(t=__VUE_SSR_CONTEXT__),e&&e.call(this,c(t)),t&&t._registeredComponents&&t._registeredComponents.add(i)},f._ssrRegister=s):e&&(s=u?function(t){e.call(this,a(t,this.$root.$options.shadowRoot))}:function(t){e.call(this,l(t))}),s)if(f.functional){const t=f.render;f.render=function(e,r){return s.call(r),t(e,r)}}else{const t=f.beforeCreate;f.beforeCreate=t?[].concat(t,s):[s]}return r}var u=i({},undefined,{name:"ButtonToDropdown",props:{sliceNumber:{type:Number,default:3},moreText:{type:String,default:"更多"}},render:function(t){var r=this.$slots.default,n=[],o=[];if(null!=r&&r.length){var i=r.filter((function(t){if(t.tag)return t})),u=this.sliceNumber||0;i.length<=u?n=i.slice(0,u):(n=i.slice(0,u-1),o=i.slice(u-1));var l=[];if(o.length){var c=o.map((function(e){return t("el-dropdown-item",{},[e])}));l=t("el-dropdown",{style:{"margin-left":"24px"},props:e({},this.$attrs)},[t("el-button",{props:{type:"text"},domProps:{innerHTML:"".concat(this.moreText,' <i class="el-icon-arrow-down "></i>')}}),t("el-dropdown-menu",{slot:"dropdown"},c)])}return t("div",[n,l])}return t(r)}},undefined,undefined,undefined,!1,void 0,void 0,void 0),l=function(){var t=u;return t.install=function(e){e.component("ButtonToDropdown",t)},t}(),c=Object.freeze({__proto__:null,default:l});return Object.entries(c).forEach((function(t){var e=n(t,2),r=e[0],o=e[1];"default"!==r&&(l[r]=o)})),l}();