Row.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3. Object.defineProperty(exports, "__esModule", {
  4. value: true
  5. });
  6. exports.default = void 0;
  7. var _vue = require("vue");
  8. var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
  9. var _Cell = _interopRequireDefault(require("./Cell"));
  10. var _propsUtil = require("../_util/props-util");
  11. var _index = require("./index");
  12. const Row = props => {
  13. const renderCells = (items, _ref, _ref2) => {
  14. let {
  15. colon,
  16. prefixCls,
  17. bordered
  18. } = _ref;
  19. let {
  20. component,
  21. type,
  22. showLabel,
  23. showContent,
  24. labelStyle: rootLabelStyle,
  25. contentStyle: rootContentStyle
  26. } = _ref2;
  27. return items.map((item, index) => {
  28. var _a, _b;
  29. const itemProps = item.props || {};
  30. const {
  31. prefixCls: itemPrefixCls = prefixCls,
  32. span = 1,
  33. labelStyle = itemProps['label-style'],
  34. contentStyle = itemProps['content-style'],
  35. label = (_b = (_a = item.children) === null || _a === void 0 ? void 0 : _a.label) === null || _b === void 0 ? void 0 : _b.call(_a)
  36. } = itemProps;
  37. const children = (0, _propsUtil.getSlot)(item);
  38. const className = (0, _propsUtil.getClass)(item);
  39. const style = (0, _propsUtil.getStyle)(item);
  40. const {
  41. key
  42. } = item;
  43. if (typeof component === 'string') {
  44. return (0, _vue.createVNode)(_Cell.default, {
  45. "key": `${type}-${String(key) || index}`,
  46. "class": className,
  47. "style": style,
  48. "labelStyle": (0, _extends2.default)((0, _extends2.default)({}, rootLabelStyle), labelStyle),
  49. "contentStyle": (0, _extends2.default)((0, _extends2.default)({}, rootContentStyle), contentStyle),
  50. "span": span,
  51. "colon": colon,
  52. "component": component,
  53. "itemPrefixCls": itemPrefixCls,
  54. "bordered": bordered,
  55. "label": showLabel ? label : null,
  56. "content": showContent ? children : null
  57. }, null);
  58. }
  59. return [(0, _vue.createVNode)(_Cell.default, {
  60. "key": `label-${String(key) || index}`,
  61. "class": className,
  62. "style": (0, _extends2.default)((0, _extends2.default)((0, _extends2.default)({}, rootLabelStyle), style), labelStyle),
  63. "span": 1,
  64. "colon": colon,
  65. "component": component[0],
  66. "itemPrefixCls": itemPrefixCls,
  67. "bordered": bordered,
  68. "label": label
  69. }, null), (0, _vue.createVNode)(_Cell.default, {
  70. "key": `content-${String(key) || index}`,
  71. "class": className,
  72. "style": (0, _extends2.default)((0, _extends2.default)((0, _extends2.default)({}, rootContentStyle), style), contentStyle),
  73. "span": span * 2 - 1,
  74. "component": component[1],
  75. "itemPrefixCls": itemPrefixCls,
  76. "bordered": bordered,
  77. "content": children
  78. }, null)];
  79. });
  80. };
  81. const {
  82. prefixCls,
  83. vertical,
  84. row,
  85. index,
  86. bordered
  87. } = props;
  88. const {
  89. labelStyle,
  90. contentStyle
  91. } = (0, _vue.inject)(_index.descriptionsContext, {
  92. labelStyle: (0, _vue.ref)({}),
  93. contentStyle: (0, _vue.ref)({})
  94. });
  95. if (vertical) {
  96. return (0, _vue.createVNode)(_vue.Fragment, null, [(0, _vue.createVNode)("tr", {
  97. "key": `label-${index}`,
  98. "class": `${prefixCls}-row`
  99. }, [renderCells(row, props, {
  100. component: 'th',
  101. type: 'label',
  102. showLabel: true,
  103. labelStyle: labelStyle.value,
  104. contentStyle: contentStyle.value
  105. })]), (0, _vue.createVNode)("tr", {
  106. "key": `content-${index}`,
  107. "class": `${prefixCls}-row`
  108. }, [renderCells(row, props, {
  109. component: 'td',
  110. type: 'content',
  111. showContent: true,
  112. labelStyle: labelStyle.value,
  113. contentStyle: contentStyle.value
  114. })])]);
  115. }
  116. return (0, _vue.createVNode)("tr", {
  117. "key": index,
  118. "class": `${prefixCls}-row`
  119. }, [renderCells(row, props, {
  120. component: bordered ? ['th', 'td'] : 'td',
  121. type: 'item',
  122. showLabel: true,
  123. showContent: true,
  124. labelStyle: labelStyle.value,
  125. contentStyle: contentStyle.value
  126. })]);
  127. };
  128. var _default = exports.default = Row;