UNPKG

tdesign-react

Version:
118 lines (114 loc) 5.09 kB
/** * tdesign v1.15.1 * (c) 2025 tdesign * @license MIT */ import { _ as _typeof } from '../_chunks/dep-eca3a3de.js'; import { _ as _defineProperty } from '../_chunks/dep-cb0a3966.js'; import { _ as _objectWithoutProperties } from '../_chunks/dep-6b660ef0.js'; import React, { useMemo } from 'react'; import classNames from 'classnames'; import useConfig from '../hooks/useConfig.js'; import Aside from './Aside.js'; import parseTNode from '../_util/parseTNode.js'; import '../config-provider/ConfigContext.js'; import 'lodash-es'; import '../locale/zh_CN.js'; import '../_chunks/dep-e29214cb.js'; import 'dayjs'; import '../_chunks/dep-3c9ab31a.js'; import '../hooks/useDefaultProps.js'; import '../_chunks/dep-f53c91cd.js'; import '../_chunks/dep-b908e1fe.js'; var _excluded = ["className", "style", "children", "height"], _excluded2 = ["className", "style", "children", "height"], _excluded3 = ["className", "style", "children", "content"], _excluded4 = ["direction", "className", "style", "children"]; function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; } function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; } var Header = function Header(props) { var _useConfig = useConfig(), classPrefix = _useConfig.classPrefix; var className = props.className, _props$style = props.style, style = _props$style === void 0 ? {} : _props$style, children = props.children, height = props.height, others = _objectWithoutProperties(props, _excluded); var renderHeight = isNaN(Number(height)) ? height : "".concat(height, "px"); var headerClassNames = classNames("".concat(classPrefix, "-layout__header"), className); return /* @__PURE__ */React.createElement("header", _objectSpread({ className: headerClassNames, style: _objectSpread({ height: renderHeight }, style) }, others), parseTNode(children)); }; var Footer = function Footer(props) { var _useConfig2 = useConfig(), classPrefix = _useConfig2.classPrefix; var className = props.className, _props$style2 = props.style, style = _props$style2 === void 0 ? {} : _props$style2, children = props.children, height = props.height, others = _objectWithoutProperties(props, _excluded2); var renderHeight = isNaN(Number(height)) ? height : "".concat(height, "px"); var footerClassNames = classNames("".concat(classPrefix, "-layout__footer"), className); return /* @__PURE__ */React.createElement("footer", _objectSpread({ className: footerClassNames, style: _objectSpread({ height: renderHeight }, style) }, others), parseTNode(children)); }; var Content = function Content(props) { var _useConfig3 = useConfig(), classPrefix = _useConfig3.classPrefix; var className = props.className, style = props.style, children = props.children, content = props.content, others = _objectWithoutProperties(props, _excluded3); var contentClassNames = classNames("".concat(classPrefix, "-layout__content"), className); return /* @__PURE__ */React.createElement("main", _objectSpread({ className: contentClassNames, style: style }, others), parseTNode(content) || parseTNode(children)); }; var Layout = function Layout(props) { var direction = props.direction, className = props.className, style = props.style, children = props.children, otherLayoutProps = _objectWithoutProperties(props, _excluded4); var shouldAsides = useMemo(function () { var asides = []; React.Children.forEach(children, function (child) { if (!child || _typeof(child) !== "object") { return; } if (child.type === Aside) { asides.push(child); } }); return !!asides.length; }, [children]); var _useConfig4 = useConfig(), classPrefix = _useConfig4.classPrefix; var layoutClassNames = classNames("".concat(classPrefix, "-layout"), _defineProperty(_defineProperty({}, "".concat(classPrefix, "-layout--with-sider"), shouldAsides), "".concat(classPrefix, "-layout__direction-").concat(direction), direction), className); return /* @__PURE__ */React.createElement("div", _objectSpread({ className: layoutClassNames, style: style }, otherLayoutProps), parseTNode(children)); }; Layout.Header = Header; Layout.Content = Content; Layout.Footer = Footer; Layout.Aside = Aside; Header.displayName = "Header"; Content.displayName = "Content"; Footer.displayName = "Footer"; Layout.displayName = "Layout"; export { Layout as default }; //# sourceMappingURL=Layout.js.map