UNPKG

tdesign-react

Version:
99 lines (95 loc) 3.8 kB
/** * tdesign v1.15.1 * (c) 2025 tdesign * @license MIT */ import { _ as _slicedToArray } from '../_chunks/dep-48805ab8.js'; import React, { useContext } from 'react'; import useConfig from '../hooks/useConfig.js'; import { DescriptionsContext } from './DescriptionsContext.js'; import { useLocaleReceiver } from '../locale/LocalReceiver.js'; import '../_chunks/dep-026a4c6b.js'; import '../config-provider/ConfigContext.js'; import '../_chunks/dep-cb0a3966.js'; import '../_chunks/dep-eca3a3de.js'; import 'lodash-es'; import '../_chunks/dep-f97636ce.js'; import '../_chunks/dep-9dbbf468.js'; import 'dayjs'; import '../config-provider/ConfigProvider.js'; var Row = function Row(props) { var row = props.row; var _useConfig = useConfig(), classPrefix = _useConfig.classPrefix; var _useLocaleReceiver = useLocaleReceiver("descriptions"), _useLocaleReceiver2 = _slicedToArray(_useLocaleReceiver, 2), locale = _useLocaleReceiver2[0], t = _useLocaleReceiver2[1]; var descriptionsContext = useContext(DescriptionsContext); var COMPONENT_NAME = "".concat(classPrefix, "-descriptions"); var label = function label(node) { var layout = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "horizontal"; var rowKey = arguments.length > 2 ? arguments[2] : undefined; var span = node.span; var labelSpan = layout === "horizontal" ? 1 : span; return /* @__PURE__ */React.createElement("td", { key: rowKey, colSpan: labelSpan, className: "".concat(COMPONENT_NAME, "__label"), style: descriptionsContext.labelStyle }, node.label, descriptionsContext.colon && t(locale.colonText)); }; var content = function content(node) { var layout = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "horizontal"; var rowKey = arguments.length > 2 ? arguments[2] : undefined; var span = node.span; var contentSpan = span > 1 && layout === "horizontal" ? span * 2 - 1 : span; return /* @__PURE__ */React.createElement("td", { key: rowKey, colSpan: contentSpan, className: "".concat(COMPONENT_NAME, "__content"), style: descriptionsContext.contentStyle }, node.content); }; var hh = function hh() { return /* @__PURE__ */React.createElement("tr", null, row.map(function (node, i) { return /* @__PURE__ */React.createElement(React.Fragment, { key: i }, label(node), content(node)); })); }; var hv = function hv() { return /* @__PURE__ */React.createElement(React.Fragment, null, /* @__PURE__ */React.createElement("tr", null, row.map(function (node, i) { return label(node, "vertical", "top_".concat(i)); })), /* @__PURE__ */React.createElement("tr", null, row.map(function (node, i) { return content(node, "vertical", "bottom_".concat(i)); }))); }; var vh = function vh() { return /* @__PURE__ */React.createElement(React.Fragment, null, row.map(function (node, i) { return /* @__PURE__ */React.createElement("tr", { key: i }, label(node), content(node)); })); }; var vv = function vv() { return /* @__PURE__ */React.createElement(React.Fragment, null, row.map(function (node, i) { return /* @__PURE__ */React.createElement(React.Fragment, { key: i }, /* @__PURE__ */React.createElement("tr", null, label(node)), /* @__PURE__ */React.createElement("tr", null, content(node))); })); }; if (descriptionsContext.layout === "horizontal") { if (descriptionsContext.itemLayout === "horizontal") { return hh(); } return hv(); } if (descriptionsContext.itemLayout === "horizontal") { return vh(); } return vv(); }; Row.displayName = "DescriptionsRow"; export { Row as default }; //# sourceMappingURL=Row.js.map