index.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. import _extends from "@babel/runtime/helpers/esm/extends";
  2. import { genActiveStyle, genBasicInputStyle, genDisabledStyle, genPlaceholderStyle, genStatusStyle, initInputToken } from '../../input/style';
  3. import { genComponentStyleHook } from '../../theme/internal';
  4. import { resetComponent, textEllipsis } from '../../style';
  5. const genMentionsStyle = token => {
  6. const {
  7. componentCls,
  8. colorTextDisabled,
  9. controlItemBgHover,
  10. controlPaddingHorizontal,
  11. colorText,
  12. motionDurationSlow,
  13. lineHeight,
  14. controlHeight,
  15. inputPaddingHorizontal,
  16. inputPaddingVertical,
  17. fontSize,
  18. colorBgElevated,
  19. borderRadiusLG,
  20. boxShadowSecondary
  21. } = token;
  22. const itemPaddingVertical = Math.round((token.controlHeight - token.fontSize * token.lineHeight) / 2);
  23. return {
  24. [componentCls]: _extends(_extends(_extends(_extends(_extends({}, resetComponent(token)), genBasicInputStyle(token)), {
  25. position: 'relative',
  26. display: 'inline-block',
  27. height: 'auto',
  28. padding: 0,
  29. overflow: 'hidden',
  30. lineHeight,
  31. whiteSpace: 'pre-wrap',
  32. verticalAlign: 'bottom'
  33. }), genStatusStyle(token, componentCls)), {
  34. '&-disabled': {
  35. '> textarea': _extends({}, genDisabledStyle(token))
  36. },
  37. '&-focused': _extends({}, genActiveStyle(token)),
  38. [`&-affix-wrapper ${componentCls}-suffix`]: {
  39. position: 'absolute',
  40. top: 0,
  41. insetInlineEnd: inputPaddingHorizontal,
  42. bottom: 0,
  43. zIndex: 1,
  44. display: 'inline-flex',
  45. alignItems: 'center',
  46. margin: 'auto'
  47. },
  48. // ================= Input Area =================
  49. [`> textarea, ${componentCls}-measure`]: {
  50. color: colorText,
  51. boxSizing: 'border-box',
  52. minHeight: controlHeight - 2,
  53. margin: 0,
  54. padding: `${inputPaddingVertical}px ${inputPaddingHorizontal}px`,
  55. overflow: 'inherit',
  56. overflowX: 'hidden',
  57. overflowY: 'auto',
  58. fontWeight: 'inherit',
  59. fontSize: 'inherit',
  60. fontFamily: 'inherit',
  61. fontStyle: 'inherit',
  62. fontVariant: 'inherit',
  63. fontSizeAdjust: 'inherit',
  64. fontStretch: 'inherit',
  65. lineHeight: 'inherit',
  66. direction: 'inherit',
  67. letterSpacing: 'inherit',
  68. whiteSpace: 'inherit',
  69. textAlign: 'inherit',
  70. verticalAlign: 'top',
  71. wordWrap: 'break-word',
  72. wordBreak: 'inherit',
  73. tabSize: 'inherit'
  74. },
  75. '> textarea': _extends({
  76. width: '100%',
  77. border: 'none',
  78. outline: 'none',
  79. resize: 'none',
  80. backgroundColor: 'inherit'
  81. }, genPlaceholderStyle(token.colorTextPlaceholder)),
  82. [`${componentCls}-measure`]: {
  83. position: 'absolute',
  84. top: 0,
  85. insetInlineEnd: 0,
  86. bottom: 0,
  87. insetInlineStart: 0,
  88. zIndex: -1,
  89. color: 'transparent',
  90. pointerEvents: 'none',
  91. '> span': {
  92. display: 'inline-block',
  93. minHeight: '1em'
  94. }
  95. },
  96. // ================== Dropdown ==================
  97. '&-dropdown': _extends(_extends({}, resetComponent(token)), {
  98. position: 'absolute',
  99. top: -9999,
  100. insetInlineStart: -9999,
  101. zIndex: token.zIndexPopup,
  102. boxSizing: 'border-box',
  103. fontSize,
  104. fontVariant: 'initial',
  105. backgroundColor: colorBgElevated,
  106. borderRadius: borderRadiusLG,
  107. outline: 'none',
  108. boxShadow: boxShadowSecondary,
  109. '&-hidden': {
  110. display: 'none'
  111. },
  112. [`${componentCls}-dropdown-menu`]: {
  113. maxHeight: token.dropdownHeight,
  114. marginBottom: 0,
  115. paddingInlineStart: 0,
  116. overflow: 'auto',
  117. listStyle: 'none',
  118. outline: 'none',
  119. '&-item': _extends(_extends({}, textEllipsis), {
  120. position: 'relative',
  121. display: 'block',
  122. minWidth: token.controlItemWidth,
  123. padding: `${itemPaddingVertical}px ${controlPaddingHorizontal}px`,
  124. color: colorText,
  125. fontWeight: 'normal',
  126. lineHeight,
  127. cursor: 'pointer',
  128. transition: `background ${motionDurationSlow} ease`,
  129. '&:hover': {
  130. backgroundColor: controlItemBgHover
  131. },
  132. '&:first-child': {
  133. borderStartStartRadius: borderRadiusLG,
  134. borderStartEndRadius: borderRadiusLG,
  135. borderEndStartRadius: 0,
  136. borderEndEndRadius: 0
  137. },
  138. '&:last-child': {
  139. borderStartStartRadius: 0,
  140. borderStartEndRadius: 0,
  141. borderEndStartRadius: borderRadiusLG,
  142. borderEndEndRadius: borderRadiusLG
  143. },
  144. '&-disabled': {
  145. color: colorTextDisabled,
  146. cursor: 'not-allowed',
  147. '&:hover': {
  148. color: colorTextDisabled,
  149. backgroundColor: controlItemBgHover,
  150. cursor: 'not-allowed'
  151. }
  152. },
  153. '&-selected': {
  154. color: colorText,
  155. fontWeight: token.fontWeightStrong,
  156. backgroundColor: controlItemBgHover
  157. },
  158. '&-active': {
  159. backgroundColor: controlItemBgHover
  160. }
  161. })
  162. }
  163. })
  164. })
  165. };
  166. };
  167. // ============================== Export ==============================
  168. export default genComponentStyleHook('Mentions', token => {
  169. const mentionsToken = initInputToken(token);
  170. return [genMentionsStyle(mentionsToken)];
  171. }, token => ({
  172. dropdownHeight: 250,
  173. controlItemWidth: 100,
  174. zIndexPopup: token.zIndexPopupBase + 50
  175. }));