UNPKG

ucc-ui

Version:

ucc-ui components library

63 lines (62 loc) 2.24 kB
import { defineComponent as _, getCurrentInstance as b, inject as j, computed as o, shallowRef as N, openBlock as I, createElementBlock as k, normalizeClass as w, normalizeStyle as x, renderSlot as z } from "vue"; import { p as E } from "./utils-BzE2Aob-.js"; import "./ConfigProvider-C-6nRyrn.js"; import { C as y, a as O, b as B } from "./Layout-DIdxr2h1.js"; import { k as s, i as G } from "./vendors-PY6Ic9FA.js"; const q = /* @__PURE__ */ _({ name: y.REGION, __name: "Region", props: { region: { default: "center" }, style: {}, width: {}, span: {}, padding: {}, justify: {}, align: {} }, setup(v) { var m, f, g; const i = b(), n = v, a = j(O), l = o(() => { var e; return (e = a == null ? void 0 : a.maxSpan) == null ? void 0 : e.value; }), C = N((g = (f = (m = i == null ? void 0 : i.parent) == null ? void 0 : m.subTree.children) == null ? void 0 : f[0]) == null ? void 0 : g.children), r = o(() => C.value.filter((e) => { var t; return ((t = e.type) == null ? void 0 : t.name) === y.REGION; })), u = o(() => r.value.filter((e) => { var t; return s((t = e.props) == null ? void 0 : t.span); })), p = o(() => { if (n.span) return n.span; if (u.value.length === 0) return 0; const { surplus: e } = R(r.value); return e / u.value.length; }), h = o(() => { const e = { ...n.style }; return p.value && (e["--u-layout-flex-size"] = p.value), l.value && (a == null ? void 0 : a.mode.value) === B.ROW && (e["--u-layout-max-span"] = l.value), s(n.padding) || (e.padding = G(n.padding) ? E(n.padding, { unit: "rem" }) : n.padding), s(n.justify) || (e.justifyContent = n.justify), s(n.align) || (e.alignItems = n.align), e; }); function R(e) { var d; let t = 0, c = 0; for (const S of e) t += ((d = S.props) == null ? void 0 : d.span) || 0; return c = l.value - t, { total: t, surplus: c }; } return (e, t) => (I(), k("section", { class: w(["u-region", `u-region__${e.region}`, "u-region-container"]), style: x(h.value) }, [ z(e.$slots, "default") ], 6)); } }); export { q as _ };