index.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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 _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
  8. var _internal = require("../../theme/internal");
  9. var _style = require("../../style");
  10. const genBorderedStyle = token => {
  11. const {
  12. componentCls,
  13. descriptionsSmallPadding,
  14. descriptionsDefaultPadding,
  15. descriptionsMiddlePadding,
  16. descriptionsBg
  17. } = token;
  18. return {
  19. [`&${componentCls}-bordered`]: {
  20. [`${componentCls}-view`]: {
  21. border: `${token.lineWidth}px ${token.lineType} ${token.colorSplit}`,
  22. '> table': {
  23. tableLayout: 'auto',
  24. borderCollapse: 'collapse'
  25. }
  26. },
  27. [`${componentCls}-item-label, ${componentCls}-item-content`]: {
  28. padding: descriptionsDefaultPadding,
  29. borderInlineEnd: `${token.lineWidth}px ${token.lineType} ${token.colorSplit}`,
  30. '&:last-child': {
  31. borderInlineEnd: 'none'
  32. }
  33. },
  34. [`${componentCls}-item-label`]: {
  35. backgroundColor: descriptionsBg,
  36. '&::after': {
  37. display: 'none'
  38. }
  39. },
  40. [`${componentCls}-row`]: {
  41. borderBottom: `${token.lineWidth}px ${token.lineType} ${token.colorSplit}`,
  42. '&:last-child': {
  43. borderBottom: 'none'
  44. }
  45. },
  46. [`&${componentCls}-middle`]: {
  47. [`${componentCls}-item-label, ${componentCls}-item-content`]: {
  48. padding: descriptionsMiddlePadding
  49. }
  50. },
  51. [`&${componentCls}-small`]: {
  52. [`${componentCls}-item-label, ${componentCls}-item-content`]: {
  53. padding: descriptionsSmallPadding
  54. }
  55. }
  56. }
  57. };
  58. };
  59. const genDescriptionStyles = token => {
  60. const {
  61. componentCls,
  62. descriptionsExtraColor,
  63. descriptionItemPaddingBottom,
  64. descriptionsItemLabelColonMarginRight,
  65. descriptionsItemLabelColonMarginLeft,
  66. descriptionsTitleMarginBottom
  67. } = token;
  68. return {
  69. [componentCls]: (0, _extends2.default)((0, _extends2.default)((0, _extends2.default)({}, (0, _style.resetComponent)(token)), genBorderedStyle(token)), {
  70. [`&-rtl`]: {
  71. direction: 'rtl'
  72. },
  73. [`${componentCls}-header`]: {
  74. display: 'flex',
  75. alignItems: 'center',
  76. marginBottom: descriptionsTitleMarginBottom
  77. },
  78. [`${componentCls}-title`]: (0, _extends2.default)((0, _extends2.default)({}, _style.textEllipsis), {
  79. flex: 'auto',
  80. color: token.colorText,
  81. fontWeight: token.fontWeightStrong,
  82. fontSize: token.fontSizeLG,
  83. lineHeight: token.lineHeightLG
  84. }),
  85. [`${componentCls}-extra`]: {
  86. marginInlineStart: 'auto',
  87. color: descriptionsExtraColor,
  88. fontSize: token.fontSize
  89. },
  90. [`${componentCls}-view`]: {
  91. width: '100%',
  92. borderRadius: token.borderRadiusLG,
  93. table: {
  94. width: '100%',
  95. tableLayout: 'fixed'
  96. }
  97. },
  98. [`${componentCls}-row`]: {
  99. '> th, > td': {
  100. paddingBottom: descriptionItemPaddingBottom
  101. },
  102. '&:last-child': {
  103. borderBottom: 'none'
  104. }
  105. },
  106. [`${componentCls}-item-label`]: {
  107. color: token.colorText,
  108. fontWeight: 'normal',
  109. fontSize: token.fontSize,
  110. lineHeight: token.lineHeight,
  111. textAlign: `start`,
  112. '&::after': {
  113. content: '":"',
  114. position: 'relative',
  115. top: -0.5,
  116. marginInline: `${descriptionsItemLabelColonMarginLeft}px ${descriptionsItemLabelColonMarginRight}px`
  117. },
  118. [`&${componentCls}-item-no-colon::after`]: {
  119. content: '""'
  120. }
  121. },
  122. [`${componentCls}-item-no-label`]: {
  123. '&::after': {
  124. margin: 0,
  125. content: '""'
  126. }
  127. },
  128. [`${componentCls}-item-content`]: {
  129. display: 'table-cell',
  130. flex: 1,
  131. color: token.colorText,
  132. fontSize: token.fontSize,
  133. lineHeight: token.lineHeight,
  134. wordBreak: 'break-word',
  135. overflowWrap: 'break-word'
  136. },
  137. [`${componentCls}-item`]: {
  138. paddingBottom: 0,
  139. verticalAlign: 'top',
  140. '&-container': {
  141. display: 'flex',
  142. [`${componentCls}-item-label`]: {
  143. display: 'inline-flex',
  144. alignItems: 'baseline'
  145. },
  146. [`${componentCls}-item-content`]: {
  147. display: 'inline-flex',
  148. alignItems: 'baseline'
  149. }
  150. }
  151. },
  152. '&-middle': {
  153. [`${componentCls}-row`]: {
  154. '> th, > td': {
  155. paddingBottom: token.paddingSM
  156. }
  157. }
  158. },
  159. '&-small': {
  160. [`${componentCls}-row`]: {
  161. '> th, > td': {
  162. paddingBottom: token.paddingXS
  163. }
  164. }
  165. }
  166. })
  167. };
  168. };
  169. // ============================== Export ==============================
  170. var _default = exports.default = (0, _internal.genComponentStyleHook)('Descriptions', token => {
  171. const descriptionsBg = token.colorFillAlter;
  172. const descriptionsTitleMarginBottom = token.fontSizeSM * token.lineHeightSM;
  173. const descriptionsExtraColor = token.colorText;
  174. const descriptionsSmallPadding = `${token.paddingXS}px ${token.padding}px`;
  175. const descriptionsDefaultPadding = `${token.padding}px ${token.paddingLG}px`;
  176. const descriptionsMiddlePadding = `${token.paddingSM}px ${token.paddingLG}px`;
  177. const descriptionItemPaddingBottom = token.padding;
  178. const descriptionsItemLabelColonMarginRight = token.marginXS;
  179. const descriptionsItemLabelColonMarginLeft = token.marginXXS / 2;
  180. const descriptionToken = (0, _internal.mergeToken)(token, {
  181. descriptionsBg,
  182. descriptionsTitleMarginBottom,
  183. descriptionsExtraColor,
  184. descriptionItemPaddingBottom,
  185. descriptionsSmallPadding,
  186. descriptionsDefaultPadding,
  187. descriptionsMiddlePadding,
  188. descriptionsItemLabelColonMarginRight,
  189. descriptionsItemLabelColonMarginLeft
  190. });
  191. return [genDescriptionStyles(descriptionToken)];
  192. });