UNPKG

y-design-ssr

Version:

SSR component library of YUI with Vue3

306 lines (305 loc) 10.1 kB
import { inject as M, getCurrentInstance as S, onUnmounted as V, computed as w, ref as X, reactive as P, defineComponent as _, createVNode as $, onBeforeUnmount as D, isVNode as H } from "vue"; const I = (r) => { const n = M(r, null), o = S(); if (n && o) { const { children: e, addChild: s, removeChild: u } = n; return s(o), V(() => u(o)), { index: w(() => e.indexOf(o)), parent: n }; } return { parent: null, index: X(-1) }; }, y = (r, n) => n ? typeof n == "string" ? ` ${r}--${n}` : Array.isArray(n) ? n.reduce((o, e) => o + y(r, e), "") : Object.keys(n).reduce( (o, e) => o + (n[e] ? y(r, e) : ""), "" ) : "", z = (r) => (n, o) => { let e = n, s = o; return e && typeof e != "string" && (s = e, e = ""), e = e ? `${r}__${e}` : r, `${e}${y(e, s)}`; }, U = () => (r, n) => n ? `${y(`y-${r}`, n)}` : `y-${r}`, W = { "pull-refresh": { pulling: "下拉刷新...", loosing: "释放刷新...", loading: "数据加载中...", success: "数据已更新", failed: "数据跟新失败,请稍后再试" }, "form-item": { validateMessage: "请输入正确内容" } }; X("zh-CN"); P({ "zh-CN": W }); const v = (r) => { const n = `y-${r}`; return [n, z(n), U()]; }, [G, oe] = v("swipe"), K = G, [q, F] = v("swipe-item"), k = /* @__PURE__ */ _({ name: q, props: { clonenNode: { type: Object, default: null }, index: { type: Number, default: -1 } }, setup(r, { slots: n }) { const o = S(), { parent: e } = I(K); !r.clonenNode && o && (e == null || e.children.push(o)); const s = w(() => r.clonenNode ? r.index : e == null ? void 0 : e.children.findIndex((c) => c.proxy === (o == null ? void 0 : o.proxy))), u = w(() => { const c = `${(e == null ? void 0 : e.itemDetail.size) || 0}px`; let i = "auto"; const f = `${(e == null ? void 0 : e.itemDetail.space) || 0}px`; return e != null && e.props.autoHeight && (e == null ? void 0 : e.activeIndex) !== s.value && (i = "0"), e != null && e.props.vertical ? { height: c, width: i, marginBottom: f } : { width: c, height: i, marginRight: f }; }); return () => { var i, f; const c = ((i = e == null ? void 0 : e.itemShowedList) == null ? void 0 : i.list[s.value || 0]) || !1; return $("div", { class: F(), style: u.value }, [c ? r.clonenNode || ((f = n.default) == null ? void 0 : f.call(n)) : null]); }; } }); var x = {}, A = { get exports() { return x; }, set exports(r) { x = r; } }; (function(r, n) { (function() { function o() { var e = window, s = document; if ("scrollBehavior" in s.documentElement.style && e.__forceSmoothScrollPolyfill__ !== !0) return; var u = e.HTMLElement || e.Element, c = 468, i = { scroll: e.scroll || e.scrollTo, scrollBy: e.scrollBy, elementScroll: u.prototype.scroll || O, scrollIntoView: u.prototype.scrollIntoView }, f = e.performance && e.performance.now ? e.performance.now.bind(e.performance) : Date.now; function N(t) { var l = ["MSIE ", "Trident/", "Edge/"]; return new RegExp(l.join("|")).test(t); } var T = N(e.navigator.userAgent) ? 1 : 0; function O(t, l) { this.scrollLeft = t, this.scrollTop = l; } function L(t) { return 0.5 * (1 - Math.cos(Math.PI * t)); } function g(t) { if (t === null || typeof t != "object" || t.behavior === void 0 || t.behavior === "auto" || t.behavior === "instant") return !0; if (typeof t == "object" && t.behavior === "smooth") return !1; throw new TypeError( "behavior member of ScrollOptions " + t.behavior + " is not a valid value for enumeration ScrollBehavior." ); } function B(t, l) { if (l === "Y") return t.clientHeight + T < t.scrollHeight; if (l === "X") return t.clientWidth + T < t.scrollWidth; } function E(t, l) { var a = e.getComputedStyle(t, null)["overflow" + l]; return a === "auto" || a === "scroll"; } function j(t) { var l = B(t, "Y") && E(t, "Y"), a = B(t, "X") && E(t, "X"); return l || a; } function C(t) { for (; t !== s.body && j(t) === !1; ) t = t.parentNode || t.host; return t; } function Y(t) { var l = f(), a, m, p, d = (l - t.startTime) / c; d = d > 1 ? 1 : d, a = L(d), m = t.startX + (t.x - t.startX) * a, p = t.startY + (t.y - t.startY) * a, t.method.call(t.scrollable, m, p), (m !== t.x || p !== t.y) && e.requestAnimationFrame(Y.bind(e, t)); } function h(t, l, a) { var m, p, d, b, R = f(); t === s.body ? (m = e, p = e.scrollX || e.pageXOffset, d = e.scrollY || e.pageYOffset, b = i.scroll) : (m = t, p = t.scrollLeft, d = t.scrollTop, b = O), Y({ scrollable: m, method: b, startTime: R, startX: p, startY: d, x: l, y: a }); } e.scroll = e.scrollTo = function() { if (arguments[0] !== void 0) { if (g(arguments[0]) === !0) { i.scroll.call( e, arguments[0].left !== void 0 ? arguments[0].left : typeof arguments[0] != "object" ? arguments[0] : e.scrollX || e.pageXOffset, // use top prop, second argument if present or fallback to scrollY arguments[0].top !== void 0 ? arguments[0].top : arguments[1] !== void 0 ? arguments[1] : e.scrollY || e.pageYOffset ); return; } h.call( e, s.body, arguments[0].left !== void 0 ? ~~arguments[0].left : e.scrollX || e.pageXOffset, arguments[0].top !== void 0 ? ~~arguments[0].top : e.scrollY || e.pageYOffset ); } }, e.scrollBy = function() { if (arguments[0] !== void 0) { if (g(arguments[0])) { i.scrollBy.call( e, arguments[0].left !== void 0 ? arguments[0].left : typeof arguments[0] != "object" ? arguments[0] : 0, arguments[0].top !== void 0 ? arguments[0].top : arguments[1] !== void 0 ? arguments[1] : 0 ); return; } h.call( e, s.body, ~~arguments[0].left + (e.scrollX || e.pageXOffset), ~~arguments[0].top + (e.scrollY || e.pageYOffset) ); } }, u.prototype.scroll = u.prototype.scrollTo = function() { if (arguments[0] !== void 0) { if (g(arguments[0]) === !0) { if (typeof arguments[0] == "number" && arguments[1] === void 0) throw new SyntaxError("Value could not be converted"); i.elementScroll.call( this, // use left prop, first number argument or fallback to scrollLeft arguments[0].left !== void 0 ? ~~arguments[0].left : typeof arguments[0] != "object" ? ~~arguments[0] : this.scrollLeft, // use top prop, second argument or fallback to scrollTop arguments[0].top !== void 0 ? ~~arguments[0].top : arguments[1] !== void 0 ? ~~arguments[1] : this.scrollTop ); return; } var t = arguments[0].left, l = arguments[0].top; h.call( this, this, typeof t > "u" ? this.scrollLeft : ~~t, typeof l > "u" ? this.scrollTop : ~~l ); } }, u.prototype.scrollBy = function() { if (arguments[0] !== void 0) { if (g(arguments[0]) === !0) { i.elementScroll.call( this, arguments[0].left !== void 0 ? ~~arguments[0].left + this.scrollLeft : ~~arguments[0] + this.scrollLeft, arguments[0].top !== void 0 ? ~~arguments[0].top + this.scrollTop : ~~arguments[1] + this.scrollTop ); return; } this.scroll({ left: ~~arguments[0].left + this.scrollLeft, top: ~~arguments[0].top + this.scrollTop, behavior: arguments[0].behavior }); } }, u.prototype.scrollIntoView = function() { if (g(arguments[0]) === !0) { i.scrollIntoView.call( this, arguments[0] === void 0 ? !0 : arguments[0] ); return; } var t = C(this), l = t.getBoundingClientRect(), a = this.getBoundingClientRect(); t !== s.body ? (h.call( this, t, t.scrollLeft + a.left - l.left, t.scrollTop + a.top - l.top ), e.getComputedStyle(t).position !== "fixed" && e.scrollBy({ left: l.left, top: l.top, behavior: "smooth" })) : e.scrollBy({ left: a.left, top: a.top, behavior: "smooth" }); }; } r.exports = { polyfill: o }; })(); })(A); const [J, le] = v("tabs"), Q = J; function Z(r) { return typeof r == "function" || Object.prototype.toString.call(r) === "[object Object]" && !H(r); } const [ee] = v("tab"), te = /* @__PURE__ */ _({ name: ee, props: { title: { type: String, default: "" }, name: { type: [String, Number], default: "" }, disabled: { type: Boolean, default: !1 } }, setup(r, { slots: n }) { const { parent: o } = I(Q), e = S(); return e.proxy && (o == null || o.children.push(e.proxy)), D(() => { o && (o.children = o.children.filter((s) => s !== e.proxy)); }), () => { let s; return n.default ? $(k, null, Z(s = n.default()) ? s : { default: () => [s] }) : null; }; } }); function re(r) { const n = r; return n.install = (o) => { const { name: e } = r; e && o.component(e, r); }, n; } const se = re(te); export { se as default };