UNPKG

fui-fancyui

Version:
116 lines (115 loc) 2.68 kB
"use client"; import { jsxs as d, jsx as F } from "react/jsx-runtime"; import s from "react"; import { OnlyTextWrapper as j, Wrapper as M } from "./FancyContent.style.js"; import O from "./utils/FancyContentIcon.js"; import P from "./utils/FancyContentText.js"; import W from "./utils/FancyContentDescription.js"; import A from "./utils/FancyContentImage.js"; function l(w) { const { children: I, layoutMode: c = "auto", gap: p, gapBetweenText: m = "", gapBetweenIcon: B, themeType: y, layer: $, externalStyle: g, alignIcon: f = "left", justify: u, align: h, ...T } = w; let i = null, n = null, t = null; const o = []; s.Children.forEach(I, (e) => { if (s.isValidElement(e)) { const a = e.props; e.type === l.Icon || e.type === l.Image ? i = s.cloneElement(e, { ...a, className: `${a.className || ""} icon`.trim() }) : e.type === l.Title ? n = s.cloneElement(e, { ...a, className: `${a.className || ""} title`.trim() }) : e.type === l.Description ? t = s.cloneElement(e, { ...a, className: `${a.className || ""} description`.trim() }) : o.push(e); } }); const r = i !== null, E = n !== null, N = t !== null, x = !E && N; if (x && t) { const e = t; t = s.cloneElement(e, { ...e.props, className: `${e.props.className || ""} title`.replace("description", "").trim() }); } const C = r && !n && !t && o.length === 0, D = n && !r && !t && o.length === 0, S = t && !r && !n && o.length === 0; return C || D || S ? /* @__PURE__ */ d( j, { $themeType: y, $layer: $, $gap: p, $gapBetweenText: m, $layoutMode: c, $externalStyle: g, $justify: u, $align: h, ...T, children: [ i, n, t ] } ) : r || n || t ? /* @__PURE__ */ d( M, { $layoutMode: c, $hasIcon: r, $hasTitle: E || x, $hasDescription: N && !x, $gap: p, $gapBetweenText: m, $gapBetweenIcon: B ?? "2xs", $themeType: y, $layer: $, $externalStyle: g, $alignIcon: f, $justify: u, $align: h, ...T, children: [ f === "left" && i, n, t, f === "right" && i, o.length > 0 && o ] } ) : /* @__PURE__ */ F( j, { $themeType: y, $layer: $, $gap: p, $gapBetweenText: m, $layoutMode: c, $externalStyle: g, $justify: u, $align: h, ...T, children: I } ); } l.Image = A; l.Icon = O; l.Title = P; l.Description = W; export { l as default };