UNPKG

@vuesax-alpha/nightly

Version:
121 lines (116 loc) 4.5 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); var vue = require('vue'); require('../../../hooks/index.js'); var index$3 = require('../../icon/index.js'); require('../../../utils/index.js'); var _switch = require('./switch.js'); var useSwitch = require('./use-switch.js'); var pluginVue_exportHelper = require('../../../_virtual/plugin-vue_export-helper.js'); var index = require('../../../hooks/use-namespace/index.js'); var index$1 = require('../../../hooks/use-common-props/index.js'); var index$2 = require('../../../hooks/use-base-component/index.js'); var color = require('../../../utils/color.js'); const _hoisted_1 = ["checked", "disabled", "readonly"]; const __default__ = vue.defineComponent({ name: "VsSwitch", inheritAttrs: false }); const _sfc_main = vue.defineComponent({ ...__default__, props: _switch.switchProps, emits: _switch.switchEmits, setup(__props, { expose: __expose, emit }) { const props = __props; const ns = index.useNamespace("switch"); const color$1 = index$1.useColor("primary"); const { isLoading, checked, isDisabled, handleChange, switchValue } = useSwitch.useSwitch( props, emit ); const vsBaseClasses = index$2.useVuesaxBaseComponent(color$1); const switchKls = vue.computed(() => [ vsBaseClasses, ns.b(), ns.is("loading", isLoading.value), ns.is(props.shape), ns.is("indeterminate", props.indeterminate), ns.is("icon", props.icon), ns.is("disabled", isDisabled.value) ]); const switchStyles = vue.computed(() => [ ns.cssVar({ color: color.getVsColor(color$1.value) }) ]); __expose({ checked }); return (_ctx, _cache) => { return vue.openBlock(), vue.createElementBlock( "div", { type: "checkbox", class: vue.normalizeClass(switchKls.value), style: vue.normalizeStyle(switchStyles.value), onClick: _cache[1] || (_cache[1] = (...args) => vue.unref(switchValue) && vue.unref(switchValue)(...args)) }, [ vue.createElementVNode("input", { type: "checkbox", checked: vue.unref(checked), disabled: vue.unref(isDisabled), readonly: vue.unref(isDisabled), class: vue.normalizeClass(vue.unref(ns).e("input")), onChange: _cache[0] || (_cache[0] = (...args) => vue.unref(handleChange) && vue.unref(handleChange)(...args)) }, null, 42, _hoisted_1), vue.createElementVNode( "div", { class: vue.normalizeClass(vue.unref(ns).e("circle")) }, [ vue.renderSlot(_ctx.$slots, "circle"), vue.unref(isLoading) ? (vue.openBlock(), vue.createBlock(vue.unref(index$3.IconLoading), { key: 0 })) : vue.createCommentVNode("v-if", true) ], 2 ), _ctx.$slots.on || _ctx.$slots.default ? (vue.openBlock(), vue.createElementBlock( "div", { key: 0, class: vue.normalizeClass([vue.unref(ns).e("text"), vue.unref(ns).is("on")]) }, [ _ctx.$slots.on ? vue.renderSlot(_ctx.$slots, "on", { key: 0 }) : _ctx.$slots.default ? vue.renderSlot(_ctx.$slots, "default", { key: 1 }) : vue.createCommentVNode("v-if", true) ], 2 )) : vue.createCommentVNode("v-if", true), _ctx.$slots.off || _ctx.$slots.default ? (vue.openBlock(), vue.createElementBlock( "div", { key: 1, class: vue.normalizeClass([vue.unref(ns).e("text"), vue.unref(ns).is("off")]) }, [ _ctx.$slots.off ? vue.renderSlot(_ctx.$slots, "off", { key: 0 }) : _ctx.$slots.default ? vue.renderSlot(_ctx.$slots, "default", { key: 1 }) : vue.createCommentVNode("v-if", true) ], 2 )) : vue.createCommentVNode("v-if", true), vue.createElementVNode( "div", { class: vue.normalizeClass(vue.unref(ns).e("background")) }, null, 2 ) ], 6 ); }; } }); var Switch = /* @__PURE__ */ pluginVue_exportHelper["default"](_sfc_main, [["__file", "/home/runner/work/vuesax-alpha/vuesax-alpha/packages/components/switch/src/switch.vue"]]); exports["default"] = Switch; //# sourceMappingURL=switch2.js.map