index.js 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  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 _cssinjs = require("../../_util/cssinjs");
  9. var _internal = require("../../theme/internal");
  10. var _style = require("../../style");
  11. const antSpinMove = new _cssinjs.Keyframes('antSpinMove', {
  12. to: {
  13. opacity: 1
  14. }
  15. });
  16. const antRotate = new _cssinjs.Keyframes('antRotate', {
  17. to: {
  18. transform: 'rotate(405deg)'
  19. }
  20. });
  21. const genSpinStyle = token => ({
  22. [`${token.componentCls}`]: (0, _extends2.default)((0, _extends2.default)({}, (0, _style.resetComponent)(token)), {
  23. position: 'absolute',
  24. display: 'none',
  25. color: token.colorPrimary,
  26. textAlign: 'center',
  27. verticalAlign: 'middle',
  28. opacity: 0,
  29. transition: `transform ${token.motionDurationSlow} ${token.motionEaseInOutCirc}`,
  30. '&-spinning': {
  31. position: 'static',
  32. display: 'inline-block',
  33. opacity: 1
  34. },
  35. '&-nested-loading': {
  36. position: 'relative',
  37. [`> div > ${token.componentCls}`]: {
  38. position: 'absolute',
  39. top: 0,
  40. insetInlineStart: 0,
  41. zIndex: 4,
  42. display: 'block',
  43. width: '100%',
  44. height: '100%',
  45. maxHeight: token.contentHeight,
  46. [`${token.componentCls}-dot`]: {
  47. position: 'absolute',
  48. top: '50%',
  49. insetInlineStart: '50%',
  50. margin: -token.spinDotSize / 2
  51. },
  52. [`${token.componentCls}-text`]: {
  53. position: 'absolute',
  54. top: '50%',
  55. width: '100%',
  56. paddingTop: (token.spinDotSize - token.fontSize) / 2 + 2,
  57. textShadow: `0 1px 2px ${token.colorBgContainer}` // FIXME: shadow
  58. },
  59. [`&${token.componentCls}-show-text ${token.componentCls}-dot`]: {
  60. marginTop: -(token.spinDotSize / 2) - 10
  61. },
  62. '&-sm': {
  63. [`${token.componentCls}-dot`]: {
  64. margin: -token.spinDotSizeSM / 2
  65. },
  66. [`${token.componentCls}-text`]: {
  67. paddingTop: (token.spinDotSizeSM - token.fontSize) / 2 + 2
  68. },
  69. [`&${token.componentCls}-show-text ${token.componentCls}-dot`]: {
  70. marginTop: -(token.spinDotSizeSM / 2) - 10
  71. }
  72. },
  73. '&-lg': {
  74. [`${token.componentCls}-dot`]: {
  75. margin: -(token.spinDotSizeLG / 2)
  76. },
  77. [`${token.componentCls}-text`]: {
  78. paddingTop: (token.spinDotSizeLG - token.fontSize) / 2 + 2
  79. },
  80. [`&${token.componentCls}-show-text ${token.componentCls}-dot`]: {
  81. marginTop: -(token.spinDotSizeLG / 2) - 10
  82. }
  83. }
  84. },
  85. [`${token.componentCls}-container`]: {
  86. position: 'relative',
  87. transition: `opacity ${token.motionDurationSlow}`,
  88. '&::after': {
  89. position: 'absolute',
  90. top: 0,
  91. insetInlineEnd: 0,
  92. bottom: 0,
  93. insetInlineStart: 0,
  94. zIndex: 10,
  95. width: '100%',
  96. height: '100%',
  97. background: token.colorBgContainer,
  98. opacity: 0,
  99. transition: `all ${token.motionDurationSlow}`,
  100. content: '""',
  101. pointerEvents: 'none'
  102. }
  103. },
  104. [`${token.componentCls}-blur`]: {
  105. clear: 'both',
  106. opacity: 0.5,
  107. userSelect: 'none',
  108. pointerEvents: 'none',
  109. [`&::after`]: {
  110. opacity: 0.4,
  111. pointerEvents: 'auto'
  112. }
  113. }
  114. },
  115. // tip
  116. // ------------------------------
  117. [`&-tip`]: {
  118. color: token.spinDotDefault
  119. },
  120. // dots
  121. // ------------------------------
  122. [`${token.componentCls}-dot`]: {
  123. position: 'relative',
  124. display: 'inline-block',
  125. fontSize: token.spinDotSize,
  126. width: '1em',
  127. height: '1em',
  128. '&-item': {
  129. position: 'absolute',
  130. display: 'block',
  131. width: (token.spinDotSize - token.marginXXS / 2) / 2,
  132. height: (token.spinDotSize - token.marginXXS / 2) / 2,
  133. backgroundColor: token.colorPrimary,
  134. borderRadius: '100%',
  135. transform: 'scale(0.75)',
  136. transformOrigin: '50% 50%',
  137. opacity: 0.3,
  138. animationName: antSpinMove,
  139. animationDuration: '1s',
  140. animationIterationCount: 'infinite',
  141. animationTimingFunction: 'linear',
  142. animationDirection: 'alternate',
  143. '&:nth-child(1)': {
  144. top: 0,
  145. insetInlineStart: 0
  146. },
  147. '&:nth-child(2)': {
  148. top: 0,
  149. insetInlineEnd: 0,
  150. animationDelay: '0.4s'
  151. },
  152. '&:nth-child(3)': {
  153. insetInlineEnd: 0,
  154. bottom: 0,
  155. animationDelay: '0.8s'
  156. },
  157. '&:nth-child(4)': {
  158. bottom: 0,
  159. insetInlineStart: 0,
  160. animationDelay: '1.2s'
  161. }
  162. },
  163. '&-spin': {
  164. transform: 'rotate(45deg)',
  165. animationName: antRotate,
  166. animationDuration: '1.2s',
  167. animationIterationCount: 'infinite',
  168. animationTimingFunction: 'linear'
  169. }
  170. },
  171. // Sizes
  172. // ------------------------------
  173. // small
  174. [`&-sm ${token.componentCls}-dot`]: {
  175. fontSize: token.spinDotSizeSM,
  176. i: {
  177. width: (token.spinDotSizeSM - token.marginXXS / 2) / 2,
  178. height: (token.spinDotSizeSM - token.marginXXS / 2) / 2
  179. }
  180. },
  181. // large
  182. [`&-lg ${token.componentCls}-dot`]: {
  183. fontSize: token.spinDotSizeLG,
  184. i: {
  185. width: (token.spinDotSizeLG - token.marginXXS) / 2,
  186. height: (token.spinDotSizeLG - token.marginXXS) / 2
  187. }
  188. },
  189. [`&${token.componentCls}-show-text ${token.componentCls}-text`]: {
  190. display: 'block'
  191. }
  192. })
  193. });
  194. // ============================== Export ==============================
  195. var _default = exports.default = (0, _internal.genComponentStyleHook)('Spin', token => {
  196. const spinToken = (0, _internal.mergeToken)(token, {
  197. spinDotDefault: token.colorTextDescription,
  198. spinDotSize: token.controlHeightLG / 2,
  199. spinDotSizeSM: token.controlHeightLG * 0.35,
  200. spinDotSizeLG: token.controlHeight
  201. });
  202. return [genSpinStyle(spinToken)];
  203. }, {
  204. contentHeight: 400
  205. });