@aplus-frontend/ui
Version:
69 lines (68 loc) • 2.26 kB
JavaScript
import { defineComponent as C, ref as k, isVNode as S, h as r, watch as b, createElementBlock as i, openBlock as l, normalizeClass as c, unref as o, createVNode as V, withCtx as _, Fragment as w, renderList as B, normalizeStyle as N, createBlock as z, resolveDynamicComponent as F } from "vue";
import { Flex as L } from "@aplus-frontend/antdv";
import "../../config-provider/index.mjs";
import "../../hooks/index.mjs";
import x from "./style/index.mjs";
import { useNamespace as A } from "../../config-provider/hooks/use-namespace.mjs";
import { useControllableValue as D } from "../../hooks/useControllableValue.mjs";
const E = ["onClick"], K = /* @__PURE__ */ C({
name: "ApRadioGroup",
__name: "ap-radio-group",
props: {
value: { default: "" },
delay: { default: 0 },
options: { default: () => [] },
optionStyle: { default: () => ({
height: 28,
gap: 8
}) }
},
emits: ["update:value", "change"],
setup(m, { emit: d }) {
const { b: f, e: n } = A("ap-radio-group"), h = x("ap-radio-group"), p = m, s = d, { value: u, updateValue: g } = D(
p,
s
), a = k(u.value), y = (e) => S(e) ? r(e) : typeof e == "function" ? r("span", e()) : r("span", e);
b(
() => u.value,
(e) => {
e !== a.value && (a.value = e);
}
);
const v = (e) => {
a.value = e, setTimeout(() => {
g(e), s("change", e);
}, p.delay);
};
return (e, G) => (l(), i("div", {
class: c([o(f)(), o(h)])
}, [
V(o(L), {
gap: e.optionStyle?.gap,
wrap: "wrap"
}, {
default: _(() => [
(l(!0), i(w, null, B(e.options.filter((t) => t.visible !== !1), (t) => (l(), i("div", {
key: t.value,
class: c([
o(n)("item"),
a.value === t.value ? o(n)("item--active") : ""
]),
style: N({
height: e.optionStyle?.height + "px",
lineHeight: e.optionStyle?.height + "px",
color: e.optionStyle?.color
}),
onClick: (H) => v(t.value)
}, [
(l(), z(F(y(t.label))))
], 14, E))), 128))
]),
_: 1
}, 8, ["gap"])
], 2));
}
});
export {
K as default
};