@minix-iot/ui
Version:
基于Vue的移动端轻量级UI组件库
7 lines • 12.3 kB
JavaScript
/*!
* @minix-iot/ui v0.2.4 - tag.js, 2709badeb34a699cd765, Wed Nov 24 2021 14:21:12 GMT+0800 (中国标准时间)
* (c) 2017-2020 JDC
* Released under the MIT License.
*/
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e(require("vue")):"function"==typeof define&&define.amd?define("tag",["vue"],e):"object"==typeof exports?exports.tag=e(require("vue")):t.tag=e(t.Vue)}("undefined"!=typeof self?self:this,(function(t){return function(t){var e={};function n(r){if(e[r])return e[r].exports;var o=e[r]={i:r,l:!1,exports:{}};return t[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=t,n.c=e,n.d=function(t,e,r){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:r})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)n.d(r,o,function(e){return t[e]}.bind(null,o));return r},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="./",n(n.s=56)}([function(t,e){t.exports=function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){t.exports=function(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){function n(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}t.exports=function(t,e,r){return e&&n(t.prototype,e),r&&n(t,r),t},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,n){"use strict";n.d(e,"a",(function(){return s}));var r=n(0),o=n.n(r),u=n(2),i=n.n(u),a=n(1),l=n.n(a),s=function(){function t(e){o()(this,t),this._name=e}return i()(t,[{key:"name",get:function(){return"".concat(t.ROOT,"-").concat(this._name)}},{key:"derive",value:function(t,e){return t&&"string"!=typeof t&&(e=t,t=""),t=t?this.sub(t):this.name,"".concat(t).concat(this.mod(t,e))}},{key:"sub",value:function(t){var e=Array.isArray(t)?t:[t];return e.reduce((function(t,e){return"".concat(t,"-").concat(e)}),e.length?this.name:"")}},{key:"mod",value:function(t,e){var n=this;return e?"string"==typeof e?" ".concat(t,"--").concat(e):Array.isArray(e)?e.reduce((function(e,r){return e+n.mod(t,r)}),""):Object.keys(e).reduce((function(r,o){return r+(e[o]?n.mod(t,o):"")}),""):""}}],[{key:"Create",value:function(e){return new t(e)}}]),t}();l()(s,"ROOT","mx")},function(t,e,n){var r=n(12),o=n(13),u=n(10),i=n(14);t.exports=function(t){return r(t)||o(t)||u(t)||i()},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,n){"use strict";n.d(e,"a",(function(){return h}));var r=n(4),o=n.n(r),u=n(6),i=n.n(u),a=n(0),l=n.n(a),s=n(2),c=n.n(s),f=n(8),p=n.n(f);function d(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return y(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return y(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u,i=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return i=t.done,t},e:function(t){a=!0,u=t},f:function(){try{i||null==n.return||n.return()}finally{if(a)throw u}}}}function y(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var h=function(){function t(){l()(this,t)}return c()(t,null,[{key:"WithInstall",value:function(t,e){if("object"!==i()(t)&&!t.name)throw new Error("could not install,because it is not a vue component!");t.install=function(n){n.component(t.name,t),e&&(n.prototype["$".concat(t.name.replace("mx-",""))]=e)}}},{key:"SortChildren",value:function(t,e){var n=e.$vnode.componentOptions;if(n&&n.children&&n.children.length){var r=this.FlattenVNode(n.children);return t.sort((function(t,e){return r.indexOf(t.$vnode)-r.indexOf(e.$vnode)})),t}}},{key:"FlattenVNode",value:function(t){return this.TraverseVNode(t)}},{key:"TraverseVNode",value:function(t){var e,n=[],r=d(t);try{for(r.s();!(e=r.n()).done;){var u=e.value;n.push(u),u.componentInstance&&n.push.apply(n,o()(this.TraverseVNode(u.componentInstance.$children.map((function(t){return t.$vnode}))))),u.children&&n.push.apply(n,o()(this.TraverseVNode(u.children)))}}catch(t){r.e(t)}finally{r.f()}return n}},{key:"InvokeComponent",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=[],r=function(){var e=t((function(){r.$destroy(),document.body.removeChild(r.$el),n=n.filter((function(t){return t!==r}))})),r=new p.a(e),o=document.createElement("div");return document.body.appendChild(o),r.$mount(o),r},o=function(){return n.length&&!e||n.push(r()),n[n.length-1]};return function(t){o().open(t)}}}]),t}()},function(t,e){function n(e){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?(t.exports=n=function(t){return typeof t},t.exports.default=t.exports,t.exports.__esModule=!0):(t.exports=n=function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t.exports.default=t.exports,t.exports.__esModule=!0),n(e)}t.exports=n,t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r},t.exports.default=t.exports,t.exports.__esModule=!0},function(e,n){e.exports=t},function(t,e,n){"use strict";n.d(e,"a",(function(){return d}));var r=n(11),o=n.n(r),u=n(0),i=n.n(u),a=n(2),l=n.n(a),s=n(1),c=n.n(s);function f(t,e){var n="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!n){if(Array.isArray(t)||(n=function(t,e){if(!t)return;if("string"==typeof t)return p(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);"Object"===n&&t.constructor&&(n=t.constructor.name);if("Map"===n||"Set"===n)return Array.from(t);if("Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return p(t,e)}(t))||e&&t&&"number"==typeof t.length){n&&(t=n);var r=0,o=function(){};return{s:o,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:o}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u,i=!0,a=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return i=t.done,t},e:function(t){a=!0,u=t},f:function(){try{i||null==n.return||n.return()}finally{if(a)throw u}}}}function p(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}var d=function(){function t(e,n){i()(this,t),this._channels=e,this._alpha=n}return l()(t,[{key:"r",get:function(){return this._channels[0]}},{key:"g",get:function(){return this._channels[1]}},{key:"b",get:function(){return this._channels[2]}},{key:"a",get:function(){return this._alpha}},{key:"luminosity",get:function(){var t,e=[],n=f(this._channels.entries());try{for(n.s();!(t=n.n()).done;){var r=o()(t.value,2),u=r[0],i=r[1]/255;e[u]=i<=.03928?i/12.92:Math.pow((i+.055)/1.055,2.4)}}catch(t){n.e(t)}finally{n.f()}return.2126*e[0]+.7152*e[1]+.0722*e[2]}},{key:"isDark",get:function(){return this.luminosity<.5}},{key:"isLight",get:function(){return!this.isDark}},{key:"isNone",get:function(){return!this._channels||!this._channels.length}},{key:"toString",value:function(){return this.isNone?"":Number.isNaN(this._alpha)?"rgb(".concat(this._channels.map((function(t){return Math.round(t)})).join(","),")"):"rgba(".concat([this._channels,this._alpha].map((function(t){return Math.round(t)})).join(","),")")}}],[{key:"FromHex",value:function(e){if(!e.startsWith("#"))return new t(null,NaN);var n=e.length>5?function(e){for(var n=e.match(t.REG_HEX),r=[0,0,0],o=n[1],u=0;u<3;u++)r[u]=parseInt(o.slice(2*u,2*u+2),16);return{channels:r,alpha:n[2]?parseFloat(n[2],16)/255:NaN}}(e):function(e){for(var n=e.match(t.REG_HEX_ABBR)[1],r=[0,0,0],o=0;o<3;o++)r[o]=parseInt(n[o]+n[o],16);return{channels:r,alpha:n[4]?parseFloat(n[4],16)/255:NaN}}(e);return new t(n.channels,n.alpha)}},{key:"Mix",value:function(e,n,r){var o=void 0===r?.5:r,u=2*o-1,i=(e.a||1)-(n.a||1),a=((u*i==-1?u:(u+i)/(1+u*i))+1)/2,l=1-a;return new t([a*e.r+l*n.r,a*e.g+l*n.g,a*e.b+l*n.b],e.a*o+n.a*(1-o))}},{key:"Shift",value:function(e,n){return n>0?t.Shade(e,n):t.Tint(e,-n)}},{key:"Tint",value:function(e,n){return t.Mix(t.WHITE,e,n)}},{key:"Shade",value:function(e,n){return t.Mix(t.BLACK,e,n)}}]),t}();c()(d,"WHITE",new d([255,255,255],1)),c()(d,"BLACK",new d([0,0,0],1)),c()(d,"REG_HEX",/^#([a-f0-9]{6})([a-f0-9]{2})?$/i),c()(d,"REG_HEX_ABBR",/^#([a-f0-9]{3,4})$/i)},function(t,e,n){var r=n(7);t.exports=function(t,e){if(t){if("string"==typeof t)return r(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);return"Object"===n&&t.constructor&&(n=t.constructor.name),"Map"===n||"Set"===n?Array.from(t):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?r(t,e):void 0}},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,n){var r=n(19),o=n(20),u=n(10),i=n(21);t.exports=function(t,e){return r(t)||o(t,e)||u(t,e)||i()},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e,n){var r=n(7);t.exports=function(t){if(Array.isArray(t))return r(t)},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){t.exports=function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){t.exports=function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")},t.exports.default=t.exports,t.exports.__esModule=!0},,,,,function(t,e){t.exports=function(t){if(Array.isArray(t))return t},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){t.exports=function(t,e){var n=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=n){var r,o,u=[],i=!0,a=!1;try{for(n=n.call(t);!(i=(r=n.next()).done)&&(u.push(r.value),!e||u.length!==e);i=!0);}catch(t){a=!0,o=t}finally{try{i||null==n.return||n.return()}finally{if(a)throw o}}return u}},t.exports.default=t.exports,t.exports.__esModule=!0},function(t,e){t.exports=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.")},t.exports.default=t.exports,t.exports.__esModule=!0},,,,,,,,,,,function(t,e,n){"use strict";var r=n(3),o=n(9),u=r.a.Create("tag");e.a={name:u.name,props:{theme:{type:String,default:"brand"},size:{type:String,default:"middle"},round:{type:Boolean,default:!0},plain:{type:Boolean,default:!1},mark:{type:Boolean,default:!1},color:{type:String},textColor:{type:String}},computed:{cls:function(){return u.derive([this.theme,this.size,{round:this.round,plain:this.plain,mark:this.mark}])},style:function(){var t={};if(this.color)if(this.plain)t.borderColor=this.color,t.color=this.color;else{var e=o.a.FromHex(this.color);t.backgroundColor=this.color,t.color=e.isDark?o.a.WHITE:o.a.BLACK}return this.textColor&&(t.color=this.textColor),t}},render:function(){var t=arguments[0];return t("span",{class:this.cls,style:this.style},[this.$slots.default])}}},,,,,,,,,,,,,,,,,,,,,,,,function(t,e,n){"use strict";n.r(e);var r=n(5),o=n(32);n(57);r.a.WithInstall(o.a),e.default=o.a},function(t,e,n){}])}));
//# sourceMappingURL=tag.js.map