UNPKG

mealcomes

Version:

MealComes 用于学习前端的组件库

86 lines (85 loc) 2.26 kB
import { c as f, w as k } from "./utils-aznwSRCL.mjs"; import { defineComponent as g, computed as y, createElementBlock as d, openBlock as i, normalizeClass as r, unref as t, createElementVNode as c, createCommentVNode as u, withDirectives as v, vModelCheckbox as V, renderSlot as C, Fragment as B, createTextVNode as N, toDisplayString as w } from "vue"; const S = { /** * 是否选中 */ modelValue: { type: [Boolean, String, Number] }, /** * 是否半选 */ indeterminate: Boolean, /** * 是否禁用 */ disabled: { type: Boolean, default: !1 }, label: { type: String } }, E = { "update:modelValue": (l) => typeof l == "boolean", change: (l) => typeof l == "boolean" }, M = ["disabled", "value"], $ = { key: 0 }, D = /* @__PURE__ */ g({ name: "mc-checkbox", __name: "checkbox", props: S, emits: E, setup(l, { emit: p }) { const a = f("checkbox"), s = l, m = p, o = y({ get() { return s.modelValue; }, set(e) { s.disabled || m("update:modelValue", e); } }); function b(e) { if (s.disabled) return; const n = e.target; m("change", n.checked); } return (e, n) => (i(), d("label", { class: r([t(a).b("wrapper"), t(a).is("checked", o.value), t(a).is("disabled", e.disabled)]) }, [ c("span", { class: r([ t(a).b(), t(a).is("checked", o.value), t(a).is("disabled", e.disabled), t(a).is("indeterminate", e.indeterminate) ]) }, [ v(c("input", { type: "checkbox", "onUpdate:modelValue": n[0] || (n[0] = (h) => o.value = h), ref: "inputRef", disabled: e.disabled, value: e.label, onChange: b }, null, 40, M), [ [V, o.value] ]), c("span", { class: r(t(a).m("inner")) }, null, 2) ], 2), e.$slots.default || e.label ? (i(), d("span", $, [ C(e.$slots, "default"), e.$slots.default ? u("", !0) : (i(), d(B, { key: 0 }, [ N(w(e.label), 1) ], 64)) ])) : u("", !0) ], 2)); } }), F = k(D); export { F as M, E as a, S as c }; //# sourceMappingURL=checkbox-Bxqb1mwr.mjs.map