ideaz-element
Version:
<p align="center"> <a href="" target="_blank" rel="noopener noreferrer"> <img src="./docs/public/logo.svg" alt="Ideaz Element" width="180" style="width: 180px;" /> </a> </p>
107 lines (106 loc) • 3.6 kB
JavaScript
import { defineComponent as w, computed as z, createVNode as o, mergeProps as A, provide as N } from "vue";
import "../../../hooks/index.mjs";
import "../../../node_modules/.pnpm/lodash-unified@1.0.3_@types_lodash-es@4.17.12_lodash-es@4.17.21_lodash@4.17.21/node_modules/lodash-unified/import.mjs";
import "../../../utils/index.mjs";
import b from "./CheckCardItem.mjs";
import { checkCardGroupProps as P } from "./props.mjs";
import { useFormSize as S } from "../../../hooks/useFormSize.mjs";
import { useNamespace as Z } from "../../../hooks/useNamespace.mjs";
import s from "../../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/get.mjs";
import { isValid as B } from "../../../utils/is.mjs";
const L = /* @__PURE__ */ w({
name: "ZCheckCard",
components: {
ZCheckCardItem: b
},
props: P,
emits: ["change", "update:modelValue"],
setup(a, {
slots: n,
expose: y,
emit: k
}) {
const I = Z("check-card"), C = S(), c = z({
get() {
return a.modelValue || a.value;
},
set(l) {
k("update:modelValue", l), k("change", l);
}
}), V = () => {
var l;
return (l = a.options) == null ? void 0 : l.map((e) => typeof e == "string" ? {
title: e,
value: e
} : e);
}, x = (l) => {
if (!a.multiple) {
let e;
e = c.value, e === l.value ? e = void 0 : e = l.value, c.value = e;
}
if (a.multiple) {
let e = [];
const t = c.value, v = t.includes(l.value);
e = [...t || []], v || e.push(l.value), v && (e = e.filter((r) => r !== l.value));
const f = V(), g = e == null ? void 0 : e.sort((r, u) => {
const m = f.findIndex((d) => {
var i;
return d.value === r || s(d, ((i = a.alias) == null ? void 0 : i.value) || "value", "") === r;
}), h = f.findIndex((d) => {
var i;
return d.value === u || s(d, ((i = a.alias) == null ? void 0 : i.value) || "value", "") === u;
});
return m - h;
});
c.value = g;
}
}, O = () => {
var v, f, g;
const {
loading: l,
multiple: e,
options: t
} = a;
if (l)
return new Array((t == null ? void 0 : t.length) || ((f = (v = n.default) == null ? void 0 : v.call(n)) == null ? void 0 : f.length) || 1).fill(0).map((r, u) => o(b, {
key: u,
loading: !0
}, null));
if (t && t.length > 0) {
const r = c.value;
return V().map((u) => {
var h, d, i;
const m = s(u, ((h = a.alias) == null ? void 0 : h.value) || "value", "");
return o(b, A({
key: m.toString()
}, u, {
disabled: s(u, ((d = a.alias) == null ? void 0 : d.disabled) || "disabled", !1),
size: u.size || C.value,
value: m,
bordered: B(u.bordered) ? u.bordered : a.bordered,
checked: e ? r == null ? void 0 : r.includes(m) : r === m,
title: s(u, ((i = a.alias) == null ? void 0 : i.title) || "title", "")
}), null);
});
}
return (g = n.default) == null ? void 0 : g.call(n);
};
return N("check-card-group", z(() => ({
toggleOption: x,
bordered: a.bordered,
value: c.value,
disabled: a.disabled,
size: C.value,
loading: a.loading,
multiple: a.multiple
}))), y({
toggleOption: x
}), () => o("div", {
class: I.b("group")
}, [O()]);
}
});
export {
L as default
};
//# sourceMappingURL=index.mjs.map