@wener/console
Version:
Base console UI toolkit
25 lines (24 loc) • 962 B
JavaScript
function _type_of(obj) {
"@swc/helpers - typeof";
return obj && typeof Symbol !== "undefined" && obj.constructor === Symbol ? "symbol" : typeof obj;
}
import React, { cloneElement, isValidElement } from "react";
import { cn } from "../utils/cn.js";
export function renderRegion(region) {
if (!region)
return null;
if (!((typeof region === "undefined" ? "undefined" : _type_of(region)) === "object" && "content" in region)) {
return region;
}
var className = region.className, content = region.content, tmp = region.as, As = tmp === void 0 ? "div" : tmp;
// 支持传入 ReactElement 作为容器,类似 render prop
if ( /*#__PURE__*/isValidElement(As)) {
return /*#__PURE__*/ cloneElement(As, {
className: cn(As.props.className, className),
children: content
});
}
return /*#__PURE__*/ React.createElement(As, {
className: cn(className)
}, content);
}