UNPKG

y-design-ssr

Version:

SSR component library of YUI with Vue3

94 lines (93 loc) 2.68 kB
import { inject as h, getCurrentInstance as d, onUnmounted as g, computed as a, ref as f, reactive as x, defineComponent as y, createVNode as $ } from "vue"; const p = (n) => { const t = h(n, null), i = d(); if (t && i) { const { children: e, addChild: r, removeChild: u } = t; return r(i), g(() => u(i)), { index: a(() => e.indexOf(i)), parent: t }; } return { parent: null, index: f(-1) }; }, l = (n, t) => t ? typeof t == "string" ? ` ${n}--${t}` : Array.isArray(t) ? t.reduce((i, e) => i + l(n, e), "") : Object.keys(t).reduce( (i, e) => i + (t[e] ? l(n, e) : ""), "" ) : "", N = (n) => (t, i) => { let e = t, r = i; return e && typeof e != "string" && (r = e, e = ""), e = e ? `${n}__${e}` : n, `${e}${l(e, r)}`; }, v = () => (n, t) => t ? `${l(`y-${n}`, t)}` : `y-${n}`, w = { "pull-refresh": { pulling: "下拉刷新...", loosing: "释放刷新...", loading: "数据加载中...", success: "数据已更新", failed: "数据跟新失败,请稍后再试" }, "form-item": { validateMessage: "请输入正确内容" } }; f("zh-CN"); x({ "zh-CN": w }); const m = (n) => { const t = `y-${n}`; return [t, N(t), v()]; }, [I, j] = m("swipe"), _ = I, [b, C] = m("swipe-item"), S = /* @__PURE__ */ y({ name: b, props: { clonenNode: { type: Object, default: null }, index: { type: Number, default: -1 } }, setup(n, { slots: t }) { const i = d(), { parent: e } = p(_); !n.clonenNode && i && (e == null || e.children.push(i)); const r = a(() => n.clonenNode ? n.index : e == null ? void 0 : e.children.findIndex((c) => c.proxy === (i == null ? void 0 : i.proxy))), u = a(() => { const c = `${(e == null ? void 0 : e.itemDetail.size) || 0}px`; let o = "auto"; const s = `${(e == null ? void 0 : e.itemDetail.space) || 0}px`; return e != null && e.props.autoHeight && (e == null ? void 0 : e.activeIndex) !== r.value && (o = "0"), e != null && e.props.vertical ? { height: c, width: o, marginBottom: s } : { width: c, height: o, marginRight: s }; }); return () => { var o, s; const c = ((o = e == null ? void 0 : e.itemShowedList) == null ? void 0 : o.list[r.value || 0]) || !1; return $("div", { class: C(), style: u.value }, [c ? n.clonenNode || ((s = t.default) == null ? void 0 : s.call(t)) : null]); }; } }); function E(n) { const t = n; return t.install = (i) => { const { name: e } = n; e && i.component(e, n); }, t; } const z = E(S); export { z as default };