index.js 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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 _internal = require("../../theme/internal");
  8. var _motion = _interopRequireDefault(require("./motion"));
  9. // =============================== Base ===============================
  10. const genDrawerStyle = token => {
  11. const {
  12. componentCls,
  13. zIndexPopup,
  14. colorBgMask,
  15. colorBgElevated,
  16. motionDurationSlow,
  17. motionDurationMid,
  18. padding,
  19. paddingLG,
  20. fontSizeLG,
  21. lineHeightLG,
  22. lineWidth,
  23. lineType,
  24. colorSplit,
  25. marginSM,
  26. colorIcon,
  27. colorIconHover,
  28. colorText,
  29. fontWeightStrong,
  30. drawerFooterPaddingVertical,
  31. drawerFooterPaddingHorizontal
  32. } = token;
  33. const wrapperCls = `${componentCls}-content-wrapper`;
  34. return {
  35. [componentCls]: {
  36. position: 'fixed',
  37. inset: 0,
  38. zIndex: zIndexPopup,
  39. pointerEvents: 'none',
  40. '&-pure': {
  41. position: 'relative',
  42. background: colorBgElevated,
  43. [`&${componentCls}-left`]: {
  44. boxShadow: token.boxShadowDrawerLeft
  45. },
  46. [`&${componentCls}-right`]: {
  47. boxShadow: token.boxShadowDrawerRight
  48. },
  49. [`&${componentCls}-top`]: {
  50. boxShadow: token.boxShadowDrawerUp
  51. },
  52. [`&${componentCls}-bottom`]: {
  53. boxShadow: token.boxShadowDrawerDown
  54. }
  55. },
  56. '&-inline': {
  57. position: 'absolute'
  58. },
  59. // ====================== Mask ======================
  60. [`${componentCls}-mask`]: {
  61. position: 'absolute',
  62. inset: 0,
  63. zIndex: zIndexPopup,
  64. background: colorBgMask,
  65. pointerEvents: 'auto'
  66. },
  67. // ==================== Content =====================
  68. [wrapperCls]: {
  69. position: 'absolute',
  70. zIndex: zIndexPopup,
  71. transition: `all ${motionDurationSlow}`,
  72. '&-hidden': {
  73. display: 'none'
  74. }
  75. },
  76. // Placement
  77. [`&-left > ${wrapperCls}`]: {
  78. top: 0,
  79. bottom: 0,
  80. left: {
  81. _skip_check_: true,
  82. value: 0
  83. },
  84. boxShadow: token.boxShadowDrawerLeft
  85. },
  86. [`&-right > ${wrapperCls}`]: {
  87. top: 0,
  88. right: {
  89. _skip_check_: true,
  90. value: 0
  91. },
  92. bottom: 0,
  93. boxShadow: token.boxShadowDrawerRight
  94. },
  95. [`&-top > ${wrapperCls}`]: {
  96. top: 0,
  97. insetInline: 0,
  98. boxShadow: token.boxShadowDrawerUp
  99. },
  100. [`&-bottom > ${wrapperCls}`]: {
  101. bottom: 0,
  102. insetInline: 0,
  103. boxShadow: token.boxShadowDrawerDown
  104. },
  105. [`${componentCls}-content`]: {
  106. width: '100%',
  107. height: '100%',
  108. overflow: 'auto',
  109. background: colorBgElevated,
  110. pointerEvents: 'auto'
  111. },
  112. // ===================== Panel ======================
  113. [`${componentCls}-wrapper-body`]: {
  114. display: 'flex',
  115. flexDirection: 'column',
  116. width: '100%',
  117. height: '100%'
  118. },
  119. // Header
  120. [`${componentCls}-header`]: {
  121. display: 'flex',
  122. flex: 0,
  123. alignItems: 'center',
  124. padding: `${padding}px ${paddingLG}px`,
  125. fontSize: fontSizeLG,
  126. lineHeight: lineHeightLG,
  127. borderBottom: `${lineWidth}px ${lineType} ${colorSplit}`,
  128. '&-title': {
  129. display: 'flex',
  130. flex: 1,
  131. alignItems: 'center',
  132. minWidth: 0,
  133. minHeight: 0
  134. }
  135. },
  136. [`${componentCls}-extra`]: {
  137. flex: 'none'
  138. },
  139. [`${componentCls}-close`]: {
  140. display: 'inline-block',
  141. marginInlineEnd: marginSM,
  142. color: colorIcon,
  143. fontWeight: fontWeightStrong,
  144. fontSize: fontSizeLG,
  145. fontStyle: 'normal',
  146. lineHeight: 1,
  147. textAlign: 'center',
  148. textTransform: 'none',
  149. textDecoration: 'none',
  150. background: 'transparent',
  151. border: 0,
  152. outline: 0,
  153. cursor: 'pointer',
  154. transition: `color ${motionDurationMid}`,
  155. textRendering: 'auto',
  156. '&:focus, &:hover': {
  157. color: colorIconHover,
  158. textDecoration: 'none'
  159. }
  160. },
  161. [`${componentCls}-title`]: {
  162. flex: 1,
  163. margin: 0,
  164. color: colorText,
  165. fontWeight: token.fontWeightStrong,
  166. fontSize: fontSizeLG,
  167. lineHeight: lineHeightLG
  168. },
  169. // Body
  170. [`${componentCls}-body`]: {
  171. flex: 1,
  172. minWidth: 0,
  173. minHeight: 0,
  174. padding: paddingLG,
  175. overflow: 'auto'
  176. },
  177. // Footer
  178. [`${componentCls}-footer`]: {
  179. flexShrink: 0,
  180. padding: `${drawerFooterPaddingVertical}px ${drawerFooterPaddingHorizontal}px`,
  181. borderTop: `${lineWidth}px ${lineType} ${colorSplit}`
  182. },
  183. // ====================== RTL =======================
  184. '&-rtl': {
  185. direction: 'rtl'
  186. }
  187. }
  188. };
  189. };
  190. // ============================== Export ==============================
  191. var _default = exports.default = (0, _internal.genComponentStyleHook)('Drawer', token => {
  192. const drawerToken = (0, _internal.mergeToken)(token, {
  193. drawerFooterPaddingVertical: token.paddingXS,
  194. drawerFooterPaddingHorizontal: token.padding
  195. });
  196. return [genDrawerStyle(drawerToken), (0, _motion.default)(drawerToken)];
  197. }, token => ({
  198. zIndexPopup: token.zIndexPopupBase
  199. }));