@cmtlyt/chlorine-ui
Version:
一个令人窒息的组件库?
1 lines • 9.22 kB
JavaScript
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("lib/switch",[],e):"object"==typeof exports?exports["lib/switch"]=e():t["lib/switch"]=e()}(self,(function(){return function(){var t={797:function(t,e,n){"use strict";n.r(e);var i=n(81),o=n.n(i),r=n(645),c=n.n(r)()(o());c.push([t.id,'\n.cl-switch[data-v-7931cfd2]{--active-color: var(--primary-color);--inactive-color: #c0ccdaa0;--active-text-color: var(--active-color);--inactive-text-color: currentColor;--switch-width: 40px;--switch-height: 25px\n}\n.cl-switch .cl-switch__content[data-v-7931cfd2]{width:max-content;height:var(--switch-height);display:flex;gap:10px\n}\n.cl-switch .cl-switch__content .cl-switch-box[data-v-7931cfd2]{position:relative;height:100%;width:var(--switch-width);background-color:var(--inactive-color);border-radius:999px;transition:background-color 300ms;overflow:hidden\n}\n.cl-switch .cl-switch__content .cl-switch-box[data-v-7931cfd2]::before{position:absolute;top:50%;left:3px;right:0;transform:translate(0, -50%);content:"";width:calc(var(--switch-height) - 6px);height:calc(var(--switch-height) - 6px);border-radius:50%;background-color:#fff;transition:transform 300ms,left 300ms\n}\n.cl-switch .cl-switch__content .inactive-text[data-v-7931cfd2]{color:var(--active-text-color);transition:color 300ms\n}\n.cl-switch .cl-switch__content .active-text[data-v-7931cfd2]{color:var(--inactive-text-color);transition:color 300ms\n}\n.cl-switch .cl-switch__content.active .cl-switch-box[data-v-7931cfd2]{background-color:var(--active-color)\n}\n.cl-switch .cl-switch__content.active .cl-switch-box[data-v-7931cfd2]::before{left:calc(100% - 3px);transform:translate(-100%, -50%)\n}\n.cl-switch .cl-switch__content.active .active-text[data-v-7931cfd2]{color:var(--active-text-color)\n}\n.cl-switch .cl-switch__content.active .inactive-text[data-v-7931cfd2]{color:var(--inactive-text-color)\n}\n.cl-switch .cl-switch__content.disabled .cl-switch-box[data-v-7931cfd2]::after{position:absolute;top:0;left:0;z-index:10;content:"";width:100%;height:100%;background-color:rgba(255,255,255,.3764705882)\n}',""]),e.default=c},645:function(t){"use strict";t.exports=function(t){var e=[];return e.toString=function(){return this.map((function(e){var n="",i=void 0!==e[5];return e[4]&&(n+="@supports (".concat(e[4],") {")),e[2]&&(n+="@media ".concat(e[2]," {")),i&&(n+="@layer".concat(e[5].length>0?" ".concat(e[5]):""," {")),n+=t(e),i&&(n+="}"),e[2]&&(n+="}"),e[4]&&(n+="}"),n})).join("")},e.i=function(t,n,i,o,r){"string"==typeof t&&(t=[[null,t,void 0]]);var c={};if(i)for(var a=0;a<this.length;a++){var s=this[a][0];null!=s&&(c[s]=!0)}for(var l=0;l<t.length;l++){var d=[].concat(t[l]);i&&c[d[0]]||(void 0!==r&&(void 0===d[5]||(d[1]="@layer".concat(d[5].length>0?" ".concat(d[5]):""," {").concat(d[1],"}")),d[5]=r),n&&(d[2]?(d[1]="@media ".concat(d[2]," {").concat(d[1],"}"),d[2]=n):d[2]=n),o&&(d[4]?(d[1]="@supports (".concat(d[4],") {").concat(d[1],"}"),d[4]=o):d[4]="".concat(o)),e.push(d))}},e}},81:function(t){"use strict";t.exports=function(t){return t[1]}},236:function(t,e,n){"use strict";function i(t,e,n,i,o,r,c,a){var s=typeof(t=t||{}).default;"object"!==s&&"function"!==s||(t=t.default);var l,d="function"==typeof t?t.options:t;if(e&&(d.render=e,d.staticRenderFns=n,d._compiled=!0),i&&(d.functional=!0),r&&(d._scopeId=r),c?(l=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__),o&&o.call(this,t),t&&t._registeredComponents&&t._registeredComponents.add(c)},d._ssrRegister=l):o&&(l=a?function(){o.call(this,this.$root.$options.shadowRoot)}:o),l)if(d.functional){d._injectStyles=l;var u=d.render;d.render=function(t,e){return l.call(e),u(t,e)}}else{var f=d.beforeCreate;d.beforeCreate=f?[].concat(f,l):[l]}return{exports:t,options:d}}n.d(e,{Z:function(){return i}})},86:function(t,e,n){var i=n(797);i.__esModule&&(i=i.default),"string"==typeof i&&(i=[[t.id,i,""]]),i.locals&&(t.exports=i.locals),(0,n(346).Z)("dc3fe9ec",i,!1,{})},346:function(t,e,n){"use strict";function i(t,e){for(var n=[],i={},o=0;o<e.length;o++){var r=e[o],c=r[0],a={id:t+":"+o,css:r[1],media:r[2],sourceMap:r[3]};i[c]?i[c].parts.push(a):n.push(i[c]={id:c,parts:[a]})}return n}n.d(e,{Z:function(){return v}});var o="undefined"!=typeof document;if("undefined"!=typeof DEBUG&&DEBUG&&!o)throw new Error("vue-style-loader cannot be used in a non-browser environment. Use { target: 'node' } in your Webpack config to indicate a server-rendering environment.");var r={},c=o&&(document.head||document.getElementsByTagName("head")[0]),a=null,s=0,l=!1,d=function(){},u=null,f="data-vue-ssr-id",h="undefined"!=typeof navigator&&/msie [6-9]\b/.test(navigator.userAgent.toLowerCase());function v(t,e,n,o){l=n,u=o||{};var c=i(t,e);return p(c),function(e){for(var n=[],o=0;o<c.length;o++){var a=c[o];(s=r[a.id]).refs--,n.push(s)}for(e?p(c=i(t,e)):c=[],o=0;o<n.length;o++){var s;if(0===(s=n[o]).refs){for(var l=0;l<s.parts.length;l++)s.parts[l]();delete r[s.id]}}}}function p(t){for(var e=0;e<t.length;e++){var n=t[e],i=r[n.id];if(i){i.refs++;for(var o=0;o<i.parts.length;o++)i.parts[o](n.parts[o]);for(;o<n.parts.length;o++)i.parts.push(m(n.parts[o]));i.parts.length>n.parts.length&&(i.parts.length=n.parts.length)}else{var c=[];for(o=0;o<n.parts.length;o++)c.push(m(n.parts[o]));r[n.id]={id:n.id,refs:1,parts:c}}}}function g(){var t=document.createElement("style");return t.type="text/css",c.appendChild(t),t}function m(t){var e,n,i=document.querySelector("style["+f+'~="'+t.id+'"]');if(i){if(l)return d;i.parentNode.removeChild(i)}if(h){var o=s++;i=a||(a=g()),e=b.bind(null,i,o,!1),n=b.bind(null,i,o,!0)}else i=g(),e=_.bind(null,i),n=function(){i.parentNode.removeChild(i)};return e(t),function(i){if(i){if(i.css===t.css&&i.media===t.media&&i.sourceMap===t.sourceMap)return;e(t=i)}else n()}}var x,w=(x=[],function(t,e){return x[t]=e,x.filter(Boolean).join("\n")});function b(t,e,n,i){var o=n?"":i.css;if(t.styleSheet)t.styleSheet.cssText=w(e,o);else{var r=document.createTextNode(o),c=t.childNodes;c[e]&&t.removeChild(c[e]),c.length?t.insertBefore(r,c[e]):t.appendChild(r)}}function _(t,e){var n=e.css,i=e.media,o=e.sourceMap;if(i&&t.setAttribute("media",i),u.ssrId&&t.setAttribute(f,e.id),o&&(n+="\n/*# sourceURL="+o.sources[0]+" */",n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */"),t.styleSheet)t.styleSheet.cssText=n;else{for(;t.firstChild;)t.removeChild(t.firstChild);t.appendChild(document.createTextNode(n))}}}},e={};function n(i){var o=e[i];if(void 0!==o)return o.exports;var r=e[i]={id:i,exports:{}};return t[i](r,r.exports,n),r.exports}n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,{a:e}),e},n.d=function(t,e){for(var i in e)n.o(e,i)&&!n.o(t,i)&&Object.defineProperty(t,i,{enumerable:!0,get:e[i]})},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var i={};return function(){"use strict";n.r(i),n.d(i,{default:function(){return c}});var t={name:"clSwitch",props:{value:{type:[String,Boolean,Number],default:!1},disabled:{type:Boolean,default:!1},activeText:String,inactiveText:String,activeValue:{type:[String,Boolean,Number],default:void 0},inactiveValue:{type:[String,Boolean,Number],default:void 0},activeColor:String,inactiveColor:String,activeTextColor:String,inactiveTextColor:String,width:{type:[String,Number],default:40},height:{type:[String,Number],default:25}},data(){return{selfValue:null}},methods:{change(t){if(this.disabled)return;this.selfValue="boolean"==typeof t?t:!this.selfValue;const e=this.activeValue??this.selfValue,n=this.inactiveValue??this.selfValue,i=this.selfValue?e:n;this.$emit("input",i),this.$emit("change",i)},formatUnit(t){const e=["px","pt","pc","vh","vw","vmin","vmax","cm","%","em","ex","rem"];for(const n of e)if(2==t.toString().split(n).length)return t;return t+"px"}},mounted(){this.selfValue=this.value}},e=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("section",{staticClass:"cl-switch",style:{"--active-color":t.activeColor,"--inactive-color":t.inactiveColor,"--active-text-color":t.activeTextColor,"--inactive-text-color":t.inactiveTextColor,"--switch-width":t.formatUnit(t.width),"--switch-height":t.formatUnit(t.height)}},[n("div",{staticClass:"cl-switch__content",class:{disabled:t.disabled,active:t.selfValue},on:{click:t.change}},[n("span",{staticClass:"inactive-text",on:{click:function(e){return e.stopPropagation(),t.change(!1)}}},[t._v(t._s(t.inactiveText))]),t._v(" "),n("div",{staticClass:"cl-switch-box"}),t._v(" "),n("span",{staticClass:"active-text",on:{click:function(e){return e.stopPropagation(),t.change(!0)}}},[t._v(t._s(t.activeText))])])])};e._withStripped=!0;var o=(0,n(236).Z)(t,e,[],!1,(function(t){n(86)}),"data-v-7931cfd2",null);o.options.__file="components\\lib\\switch\\main.vue";var r=o.exports;r.install=t=>{t.component(r.name,r)};var c=r}(),i}()}));