index.js 6.0 KB

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