index.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.prepareComponentToken = exports.default = void 0;
  6. var _cssinjs = require("@ant-design/cssinjs");
  7. var _useZIndex = require("../../_util/hooks/useZIndex");
  8. var _style = require("../../style");
  9. var _internal = require("../../theme/internal");
  10. const genMessageStyle = token => {
  11. const {
  12. componentCls,
  13. iconCls,
  14. boxShadow,
  15. colorText,
  16. colorSuccess,
  17. colorError,
  18. colorWarning,
  19. colorInfo,
  20. fontSizeLG,
  21. motionEaseInOutCirc,
  22. motionDurationSlow,
  23. marginXS,
  24. paddingXS,
  25. borderRadiusLG,
  26. zIndexPopup,
  27. // Custom token
  28. contentPadding,
  29. contentBg
  30. } = token;
  31. const noticeCls = `${componentCls}-notice`;
  32. const messageMoveIn = new _cssinjs.Keyframes('MessageMoveIn', {
  33. '0%': {
  34. padding: 0,
  35. transform: 'translateY(-100%)',
  36. opacity: 0
  37. },
  38. '100%': {
  39. padding: paddingXS,
  40. transform: 'translateY(0)',
  41. opacity: 1
  42. }
  43. });
  44. const messageMoveOut = new _cssinjs.Keyframes('MessageMoveOut', {
  45. '0%': {
  46. maxHeight: token.height,
  47. padding: paddingXS,
  48. opacity: 1
  49. },
  50. '100%': {
  51. maxHeight: 0,
  52. padding: 0,
  53. opacity: 0
  54. }
  55. });
  56. const noticeStyle = {
  57. padding: paddingXS,
  58. textAlign: 'center',
  59. [`${componentCls}-custom-content`]: {
  60. display: 'flex',
  61. alignItems: 'center'
  62. },
  63. [`${componentCls}-custom-content > ${iconCls}`]: {
  64. marginInlineEnd: marginXS,
  65. // affected by ltr or rtl
  66. fontSize: fontSizeLG
  67. },
  68. [`${noticeCls}-content`]: {
  69. display: 'inline-block',
  70. padding: contentPadding,
  71. background: contentBg,
  72. borderRadius: borderRadiusLG,
  73. boxShadow,
  74. pointerEvents: 'all'
  75. },
  76. [`${componentCls}-success > ${iconCls}`]: {
  77. color: colorSuccess
  78. },
  79. [`${componentCls}-error > ${iconCls}`]: {
  80. color: colorError
  81. },
  82. [`${componentCls}-warning > ${iconCls}`]: {
  83. color: colorWarning
  84. },
  85. [`${componentCls}-info > ${iconCls},
  86. ${componentCls}-loading > ${iconCls}`]: {
  87. color: colorInfo
  88. }
  89. };
  90. return [
  91. // ============================ Holder ============================
  92. {
  93. [componentCls]: Object.assign(Object.assign({}, (0, _style.resetComponent)(token)), {
  94. color: colorText,
  95. position: 'fixed',
  96. top: marginXS,
  97. width: '100%',
  98. pointerEvents: 'none',
  99. zIndex: zIndexPopup,
  100. [`${componentCls}-move-up`]: {
  101. animationFillMode: 'forwards'
  102. },
  103. [`
  104. ${componentCls}-move-up-appear,
  105. ${componentCls}-move-up-enter
  106. `]: {
  107. animationName: messageMoveIn,
  108. animationDuration: motionDurationSlow,
  109. animationPlayState: 'paused',
  110. animationTimingFunction: motionEaseInOutCirc
  111. },
  112. [`
  113. ${componentCls}-move-up-appear${componentCls}-move-up-appear-active,
  114. ${componentCls}-move-up-enter${componentCls}-move-up-enter-active
  115. `]: {
  116. animationPlayState: 'running'
  117. },
  118. [`${componentCls}-move-up-leave`]: {
  119. animationName: messageMoveOut,
  120. animationDuration: motionDurationSlow,
  121. animationPlayState: 'paused',
  122. animationTimingFunction: motionEaseInOutCirc
  123. },
  124. [`${componentCls}-move-up-leave${componentCls}-move-up-leave-active`]: {
  125. animationPlayState: 'running'
  126. },
  127. '&-rtl': {
  128. direction: 'rtl',
  129. span: {
  130. direction: 'rtl'
  131. }
  132. }
  133. })
  134. },
  135. // ============================ Notice ============================
  136. {
  137. [componentCls]: {
  138. [`${noticeCls}-wrapper`]: Object.assign({}, noticeStyle)
  139. }
  140. },
  141. // ============================= Pure =============================
  142. {
  143. [`${componentCls}-notice-pure-panel`]: Object.assign(Object.assign({}, noticeStyle), {
  144. padding: 0,
  145. textAlign: 'start'
  146. })
  147. }];
  148. };
  149. const prepareComponentToken = token => ({
  150. zIndexPopup: token.zIndexPopupBase + _useZIndex.CONTAINER_MAX_OFFSET + 10,
  151. contentBg: token.colorBgElevated,
  152. contentPadding: `${(token.controlHeightLG - token.fontSize * token.lineHeight) / 2}px ${token.paddingSM}px`
  153. });
  154. // ============================== Export ==============================
  155. exports.prepareComponentToken = prepareComponentToken;
  156. var _default = exports.default = (0, _internal.genStyleHooks)('Message', token => {
  157. // Gen-style functions here
  158. const combinedToken = (0, _internal.mergeToken)(token, {
  159. height: 150
  160. });
  161. return genMessageStyle(combinedToken);
  162. }, prepareComponentToken);