UNPKG

y-design-ssr

Version:

SSR component library of YUI with Vue3

135 lines (134 loc) 3.2 kB
import { ref as p, reactive as l, inject as h, getCurrentInstance as u, watch as m, onUnmounted as g, provide as y, isVNode as C, defineComponent as v, createVNode as x } from "vue"; const c = (n, e) => e ? typeof e == "string" ? ` ${n}--${e}` : Array.isArray(e) ? e.reduce((t, r) => t + c(n, r), "") : Object.keys(e).reduce( (t, r) => t + (e[r] ? c(n, r) : ""), "" ) : "", $ = (n) => (e, t) => { let r = e, o = t; return r && typeof r != "string" && (o = r, r = ""), r = r ? `${n}__${r}` : n, `${r}${c(r, o)}`; }, V = () => (n, e) => e ? `${c(`y-${n}`, e)}` : `y-${n}`, _ = { "pull-refresh": { pulling: "下拉刷新...", loosing: "释放刷新...", loading: "数据加载中...", success: "数据已更新", failed: "数据跟新失败,请稍后再试" }, "form-item": { validateMessage: "请输入正确内容" } }; p("zh-CN"); l({ "zh-CN": _ }); const b = (n) => { const e = `y-${n}`; return [e, $(e), V()]; }, I = "y-form-item", O = () => { const n = h(I, null), e = u(); if (n && (e != null && e.proxy)) { const { setField: t } = n, { resetValidation: r, change: o, validateWithTrigger: a } = n; return m( () => e.proxy.modelValue, () => { n.instance && n.instance.exposed && (r(), o(), a("onChange")); } ), t(e), g(() => t(null)), { parent: n }; } return { parent: null }; }, N = (n) => { const e = [], t = (r) => { Array.isArray(r) && r.forEach((o) => { var a; C(o) && (e.push(o), (a = o.component) != null && a.subTree && t(o.component.subTree.children), o.children && t(o.children)); }); }; return t(n), e; }, R = (n, e) => { const t = N(e.subTree.children); n.sort((r, o) => t.indexOf(r.vnode) - t.indexOf(o.vnode)); }, z = (n) => { const e = u(), t = l([]); return { children: t, initProvide: (o) => { y(n, { addChild: (s) => { s.proxy && (t.push(s), e && R(t, e)); }, removeChild: (s) => { const f = t.indexOf(s); t.splice(f, 1); }, children: t, ...o }); } }; }, A = { modelValue: { type: [String, Number], default: "" }, disabled: { type: Boolean, default: !1 }, square: { type: Boolean, default: null }, horizontal: { type: Boolean, default: !1 }, checkedColor: { type: String, default: null } }, [d, B] = b("radio-group"), E = d, M = /* @__PURE__ */ v({ name: d, props: A, setup(n, { slots: e, emit: t }) { const { initProvide: r } = z(E); O(); const o = (i) => { t("update:modelValue", i), t("change", i); }; return r({ props: n, onItemChange: (i) => { n.modelValue !== i && o(i); } }), () => { var i; return x("div", { class: B({ horizontal: n.horizontal }), role: "radiogroup" }, [(i = e.default) == null ? void 0 : i.call(e)]); }; } }); function P(n) { const e = n; return e.install = (t) => { const { name: r } = n; r && t.component(r, n); }, e; } const G = P(M); export { G as default, A as radioGroupProps };