205 lines
5.1 KiB
JavaScript
205 lines
5.1 KiB
JavaScript
|
import {
|
||
|
an as e,
|
||
|
J as a,
|
||
|
I as l,
|
||
|
a5 as o,
|
||
|
ac as n,
|
||
|
K as i,
|
||
|
j as t,
|
||
|
c as d,
|
||
|
v as s,
|
||
|
P as r,
|
||
|
ag as c,
|
||
|
H as u,
|
||
|
ao as b,
|
||
|
w as p,
|
||
|
ad as m,
|
||
|
aQ as h,
|
||
|
ax as v,
|
||
|
aw as g,
|
||
|
Q as k,
|
||
|
} from "./index-476be0bb.js";
|
||
|
const f = {
|
||
|
name: e,
|
||
|
disabled: Boolean,
|
||
|
iconSize: a,
|
||
|
modelValue: e,
|
||
|
checkedColor: String,
|
||
|
labelPosition: String,
|
||
|
labelDisabled: Boolean,
|
||
|
};
|
||
|
var x = l({
|
||
|
props: o({}, f, {
|
||
|
bem: n(Function),
|
||
|
role: String,
|
||
|
shape: String,
|
||
|
parent: Object,
|
||
|
checked: Boolean,
|
||
|
bindGroup: i,
|
||
|
indeterminate: { type: Boolean, default: null },
|
||
|
}),
|
||
|
emits: ["click", "toggle"],
|
||
|
setup(e, { emit: a, slots: l }) {
|
||
|
const o = t(),
|
||
|
n = (a) => {
|
||
|
if (e.parent && e.bindGroup) return e.parent.props[a];
|
||
|
},
|
||
|
i = d(() => {
|
||
|
if (e.parent && e.bindGroup) {
|
||
|
const a = n("disabled") || e.disabled;
|
||
|
if ("checkbox" === e.role) {
|
||
|
const l = n("modelValue").length,
|
||
|
o = n("max");
|
||
|
return a || (o && l >= +o && !e.checked);
|
||
|
}
|
||
|
return a;
|
||
|
}
|
||
|
return e.disabled;
|
||
|
}),
|
||
|
u = d(() => n("direction")),
|
||
|
b = d(() => {
|
||
|
const a = e.checkedColor || n("checkedColor");
|
||
|
if (a && e.checked && !i.value)
|
||
|
return { borderColor: a, backgroundColor: a };
|
||
|
}),
|
||
|
p = d(() => e.shape || n("shape") || "round"),
|
||
|
m = (l) => {
|
||
|
const { target: n } = l,
|
||
|
t = o.value,
|
||
|
d = t === n || (null == t ? void 0 : t.contains(n));
|
||
|
i.value || (!d && e.labelDisabled) || a("toggle"), a("click", l);
|
||
|
},
|
||
|
h = () => {
|
||
|
var a, t;
|
||
|
const { bem: d, checked: u, indeterminate: m } = e,
|
||
|
h = e.iconSize || n("iconSize");
|
||
|
return s(
|
||
|
"div",
|
||
|
{
|
||
|
ref: o,
|
||
|
class: d("icon", [
|
||
|
p.value,
|
||
|
{ disabled: i.value, checked: u, indeterminate: m },
|
||
|
]),
|
||
|
style:
|
||
|
"dot" !== p.value
|
||
|
? { fontSize: c(h) }
|
||
|
: {
|
||
|
width: c(h),
|
||
|
height: c(h),
|
||
|
borderColor: null == (a = b.value) ? void 0 : a.borderColor,
|
||
|
},
|
||
|
},
|
||
|
[
|
||
|
l.icon
|
||
|
? l.icon({ checked: u, disabled: i.value })
|
||
|
: "dot" !== p.value
|
||
|
? s(r, { name: m ? "minus" : "success", style: b.value }, null)
|
||
|
: s(
|
||
|
"div",
|
||
|
{
|
||
|
class: d("icon--dot__icon"),
|
||
|
style: {
|
||
|
backgroundColor:
|
||
|
null == (t = b.value) ? void 0 : t.backgroundColor,
|
||
|
},
|
||
|
},
|
||
|
null
|
||
|
),
|
||
|
]
|
||
|
);
|
||
|
},
|
||
|
v = () => {
|
||
|
if (l.default)
|
||
|
return s(
|
||
|
"span",
|
||
|
{ class: e.bem("label", [e.labelPosition, { disabled: i.value }]) },
|
||
|
[l.default()]
|
||
|
);
|
||
|
};
|
||
|
return () => {
|
||
|
const a = "left" === e.labelPosition ? [v(), h()] : [h(), v()];
|
||
|
return s(
|
||
|
"div",
|
||
|
{
|
||
|
role: e.role,
|
||
|
class: e.bem([
|
||
|
{ disabled: i.value, "label-disabled": e.labelDisabled },
|
||
|
u.value,
|
||
|
]),
|
||
|
tabindex: i.value ? void 0 : 0,
|
||
|
"aria-checked": e.checked,
|
||
|
onClick: m,
|
||
|
},
|
||
|
[a]
|
||
|
);
|
||
|
};
|
||
|
},
|
||
|
});
|
||
|
const [C, V] = u("checkbox-group"),
|
||
|
S = Symbol(C),
|
||
|
[G, y] = u("checkbox");
|
||
|
const B = k(
|
||
|
l({
|
||
|
name: G,
|
||
|
props: o({}, f, {
|
||
|
shape: String,
|
||
|
bindGroup: i,
|
||
|
indeterminate: { type: Boolean, default: null },
|
||
|
}),
|
||
|
emits: ["change", "update:modelValue"],
|
||
|
setup(e, { emit: a, slots: l }) {
|
||
|
const { parent: o } = b(S),
|
||
|
n = d(() =>
|
||
|
o && e.bindGroup
|
||
|
? -1 !== o.props.modelValue.indexOf(e.name)
|
||
|
: !!e.modelValue
|
||
|
),
|
||
|
i = (l = !n.value) => {
|
||
|
o && e.bindGroup
|
||
|
? ((a) => {
|
||
|
const { name: l } = e,
|
||
|
{ max: n, modelValue: i } = o.props,
|
||
|
t = i.slice();
|
||
|
if (a)
|
||
|
(n && t.length >= +n) ||
|
||
|
t.includes(l) ||
|
||
|
(t.push(l), e.bindGroup && o.updateValue(t));
|
||
|
else {
|
||
|
const a = t.indexOf(l);
|
||
|
-1 !== a && (t.splice(a, 1), e.bindGroup && o.updateValue(t));
|
||
|
}
|
||
|
})(l)
|
||
|
: a("update:modelValue", l),
|
||
|
null !== e.indeterminate && a("change", l);
|
||
|
};
|
||
|
return (
|
||
|
p(
|
||
|
() => e.modelValue,
|
||
|
(l) => {
|
||
|
null === e.indeterminate && a("change", l);
|
||
|
}
|
||
|
),
|
||
|
m({ toggle: i, props: e, checked: n }),
|
||
|
h(() => e.modelValue),
|
||
|
() =>
|
||
|
s(
|
||
|
x,
|
||
|
g(
|
||
|
{
|
||
|
bem: y,
|
||
|
role: "checkbox",
|
||
|
parent: o,
|
||
|
checked: n.value,
|
||
|
onToggle: i,
|
||
|
},
|
||
|
e
|
||
|
),
|
||
|
v(l, ["default", "icon"])
|
||
|
)
|
||
|
);
|
||
|
},
|
||
|
})
|
||
|
);
|
||
|
export { B as C };
|