UNPKG

ucc-ui

Version:

ucc-ui components library

291 lines (290 loc) 6.1 kB
import { computed as u, h as o, Fragment as n, defineComponent as M, useSlots as S, provide as k, openBlock as _, createElementBlock as U, normalizeClass as H, normalizeStyle as N, unref as B, createBlock as G, resolveDynamicComponent as I, renderSlot as A } from "vue"; import { p as C } from "./utils-BzE2Aob-.js"; import "./ConfigProvider-C-6nRyrn.js"; import { k as v, i as F } from "./vendors-PY6Ic9FA.js"; const D = 24, E = { LEFT: "left", RIGHT: "right", TOP: "top", CENTER: "center", BOTTOM: "bottom" }, x = { ROW: "row", COLUMN: "column", DEFAULT: "default" }, c = { LEFT_TOP: "left-top", RIGHT_TOP: "right-top", LEFT_BOTTOM: "left-bottom", RIGHT_BOTTOM: "right-bottom", LEFT: "left", RIGHT: "right", BOTH: "both" }, P = { LAYOUT: "ULayout", REGION: "URegion", LAYOUT_MODE: "ULayoutMode" }, Y = Symbol("c-layout-context"); function $({ props: t, slots: e }) { const d = u(() => !t.extend), g = u(() => t.extend === c.LEFT_TOP), R = u(() => t.extend === c.LEFT_BOTTOM), s = u(() => t.extend === c.RIGHT_TOP), f = u(() => t.extend === c.RIGHT_BOTTOM), y = u(() => t.extend === c.LEFT), T = u(() => t.extend === c.RIGHT), i = u(() => t.extend === c.BOTH); return { processedSlot: u(() => { var b; const p = ((b = e.default) == null ? void 0 : b.call(e)) || []; if (!p || t.mode !== x.DEFAULT) return () => p; const l = V(p); return d.value ? w(l) : g.value ? z(t, l) : s.value ? W(t, l) : R.value ? j(t, l) : f.value ? q(t, l) : y.value ? J(t, l) : T.value ? K(t, l) : i.value ? Q(t, l) : p; }) }; } function w(t) { return O( [ o(n, null, t.topRegions), r( [ o(n, null, t.leftRegions), o(n, null, t.centerRegions), o(n, null, t.rightRegions) ] ), o(n, null, t.bottomRegions) ] ); } function z(t, e) { return O( [ a( t.mode, [ o(n, null, e.leftRegions), r( [ o(n, null, e.topRegions), m(o(n, null, [...e.centerRegions, ...e.rightRegions])) ] ) ] ), o(n, null, e.bottomRegions) ] ); } function W(t, e) { return O( [ a( t.mode, [ r( [ o(n, null, e.topRegions), m(o(n, null, [...e.leftRegions, ...e.centerRegions])) ] ), o(n, null, e.rightRegions) ] ), o(n, null, e.bottomRegions) ] ); } function j(t, e) { return a( t.mode, [ o(n, null, e.topRegions), r( [ o(n, null, e.leftRegions), m( [ h(o(n, null, [...e.centerRegions, ...e.rightRegions])), o(n, null, e.bottomRegions) ] ) ] ) ] ); } function q(t, e) { return a( t.mode, [ o(n, null, e.topRegions), r( [ m( [ h(o(n, null, [...e.leftRegions, ...e.centerRegions])), o(n, null, e.bottomRegions) ] ), o(n, null, e.rightRegions) ] ) ] ); } function J(t, e) { return a( t.mode, [ o(n, null, e.leftRegions), r( [ o(n, null, e.topRegions), m( [ h(o(n, null, [...e.centerRegions, ...e.rightRegions])), o(n, null, e.bottomRegions) ] ) ] ) ] ); } function K(t, e) { return a( t.mode, [ r( [ o(n, null, e.topRegions), m( [ h(o(n, null, [...e.leftRegions, ...e.centerRegions])), o(n, null, e.bottomRegions) ] ) ] ), o(n, null, e.rightRegions) ] ); } function Q(t, e) { return a( t.mode, [ o(n, null, e.leftRegions), r(o(n, null, [...e.topRegions, ...e.centerRegions, ...e.bottomRegions])), o(n, null, e.rightRegions) ] ); } function V(t) { var y; const e = [], d = [], g = [], R = [], s = [], f = []; for (let T = 0; T < t.length; T++) { const i = t[T], L = (y = i.props) == null ? void 0 : y.region; if (!L) { f.push(i); continue; } switch (L) { case E.TOP: e.push(i); break; case E.LEFT: d.push(i); break; case E.CENTER: g.push(i); break; case E.RIGHT: R.push(i); break; case E.BOTTOM: s.push(i); break; } } return { topRegions: e, leftRegions: d, centerRegions: g, rightRegions: R, bottomRegions: s, others: f }; } function O(t) { return () => o( n, null, t ); } function a(t, e) { return o( "div", { class: `u-layout-mode u-layout-mode__${t}` }, e ); } function r(t) { return o( "div", { class: "u-layout__body" }, t ); } function m(t) { return o( "div", { class: "u-layout__body-center" }, t ); } function h(t) { return o( "div", { class: "u-layout__body-center-content" }, t ); } const oe = /* @__PURE__ */ M({ name: P.LAYOUT, __name: "Layout", props: { mode: { default: x.DEFAULT }, extend: {}, padding: {}, gutter: {}, maxSpan: {} }, setup(t) { const e = t, d = S(), { processedSlot: g } = $({ props: e, slots: d }), R = u(() => { const s = {}; return v(e.padding) || (s.padding = F(e.padding) ? C(e.padding, { unit: "rem" }) : e.padding), v(e.gutter) || (s.gap = F(e.gutter) ? C(e.gutter, { unit: "rem" }) : e.gutter), s; }); return k(Y, { mode: u(() => e.mode), maxSpan: u(() => e.maxSpan ?? D) }), (s, f) => (_(), U("main", { class: H(["u-layout", `u-layout__${s.mode}`]), style: N(R.value) }, [ s.mode === B(x).DEFAULT ? (_(), G(I(B(g)), { key: 0 })) : A(s.$slots, "default", { key: 1 }) ], 6)); } }); export { P as C, oe as _, Y as a, x as b };