index.js 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. "use strict";
  2. var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
  3. Object.defineProperty(exports, "__esModule", {
  4. value: true
  5. });
  6. exports.genCalendarStyles = exports.default = void 0;
  7. var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
  8. var _style = require("../../style");
  9. var _style2 = require("../../date-picker/style");
  10. var _style3 = require("../../input/style");
  11. var _internal = require("../../theme/internal");
  12. const genCalendarStyles = token => {
  13. const {
  14. calendarCls,
  15. componentCls,
  16. calendarFullBg,
  17. calendarFullPanelBg,
  18. calendarItemActiveBg
  19. } = token;
  20. return {
  21. [calendarCls]: (0, _extends2.default)((0, _extends2.default)((0, _extends2.default)({}, (0, _style2.genPanelStyle)(token)), (0, _style.resetComponent)(token)), {
  22. background: calendarFullBg,
  23. '&-rtl': {
  24. direction: 'rtl'
  25. },
  26. [`${calendarCls}-header`]: {
  27. display: 'flex',
  28. justifyContent: 'flex-end',
  29. padding: `${token.paddingSM}px 0`,
  30. [`${calendarCls}-year-select`]: {
  31. minWidth: token.yearControlWidth
  32. },
  33. [`${calendarCls}-month-select`]: {
  34. minWidth: token.monthControlWidth,
  35. marginInlineStart: token.marginXS
  36. },
  37. [`${calendarCls}-mode-switch`]: {
  38. marginInlineStart: token.marginXS
  39. }
  40. }
  41. }),
  42. [`${calendarCls} ${componentCls}-panel`]: {
  43. background: calendarFullPanelBg,
  44. border: 0,
  45. borderTop: `${token.lineWidth}px ${token.lineType} ${token.colorSplit}`,
  46. borderRadius: 0,
  47. [`${componentCls}-month-panel, ${componentCls}-date-panel`]: {
  48. width: 'auto'
  49. },
  50. [`${componentCls}-body`]: {
  51. padding: `${token.paddingXS}px 0`
  52. },
  53. [`${componentCls}-content`]: {
  54. width: '100%'
  55. }
  56. },
  57. [`${calendarCls}-mini`]: {
  58. borderRadius: token.borderRadiusLG,
  59. [`${calendarCls}-header`]: {
  60. paddingInlineEnd: token.paddingXS,
  61. paddingInlineStart: token.paddingXS
  62. },
  63. [`${componentCls}-panel`]: {
  64. borderRadius: `0 0 ${token.borderRadiusLG}px ${token.borderRadiusLG}px`
  65. },
  66. [`${componentCls}-content`]: {
  67. height: token.miniContentHeight,
  68. th: {
  69. height: 'auto',
  70. padding: 0,
  71. lineHeight: `${token.weekHeight}px`
  72. }
  73. },
  74. [`${componentCls}-cell::before`]: {
  75. pointerEvents: 'none'
  76. }
  77. },
  78. [`${calendarCls}${calendarCls}-full`]: {
  79. [`${componentCls}-panel`]: {
  80. display: 'block',
  81. width: '100%',
  82. textAlign: 'end',
  83. background: calendarFullBg,
  84. border: 0,
  85. [`${componentCls}-body`]: {
  86. 'th, td': {
  87. padding: 0
  88. },
  89. th: {
  90. height: 'auto',
  91. paddingInlineEnd: token.paddingSM,
  92. paddingBottom: token.paddingXXS,
  93. lineHeight: `${token.weekHeight}px`
  94. }
  95. }
  96. },
  97. [`${componentCls}-cell`]: {
  98. '&::before': {
  99. display: 'none'
  100. },
  101. '&:hover': {
  102. [`${calendarCls}-date`]: {
  103. background: token.controlItemBgHover
  104. }
  105. },
  106. [`${calendarCls}-date-today::before`]: {
  107. display: 'none'
  108. },
  109. // >>> Selected
  110. [`&-in-view${componentCls}-cell-selected`]: {
  111. [`${calendarCls}-date, ${calendarCls}-date-today`]: {
  112. background: calendarItemActiveBg
  113. }
  114. },
  115. '&-selected, &-selected:hover': {
  116. [`${calendarCls}-date, ${calendarCls}-date-today`]: {
  117. [`${calendarCls}-date-value`]: {
  118. color: token.colorPrimary
  119. }
  120. }
  121. }
  122. },
  123. [`${calendarCls}-date`]: {
  124. display: 'block',
  125. width: 'auto',
  126. height: 'auto',
  127. margin: `0 ${token.marginXS / 2}px`,
  128. padding: `${token.paddingXS / 2}px ${token.paddingXS}px 0`,
  129. border: 0,
  130. borderTop: `${token.lineWidthBold}px ${token.lineType} ${token.colorSplit}`,
  131. borderRadius: 0,
  132. transition: `background ${token.motionDurationSlow}`,
  133. '&-value': {
  134. lineHeight: `${token.dateValueHeight}px`,
  135. transition: `color ${token.motionDurationSlow}`
  136. },
  137. '&-content': {
  138. position: 'static',
  139. width: 'auto',
  140. height: token.dateContentHeight,
  141. overflowY: 'auto',
  142. color: token.colorText,
  143. lineHeight: token.lineHeight,
  144. textAlign: 'start'
  145. },
  146. '&-today': {
  147. borderColor: token.colorPrimary,
  148. [`${calendarCls}-date-value`]: {
  149. color: token.colorText
  150. }
  151. }
  152. }
  153. },
  154. [`@media only screen and (max-width: ${token.screenXS}px) `]: {
  155. [`${calendarCls}`]: {
  156. [`${calendarCls}-header`]: {
  157. display: 'block',
  158. [`${calendarCls}-year-select`]: {
  159. width: '50%'
  160. },
  161. [`${calendarCls}-month-select`]: {
  162. width: `calc(50% - ${token.paddingXS}px)`
  163. },
  164. [`${calendarCls}-mode-switch`]: {
  165. width: '100%',
  166. marginTop: token.marginXS,
  167. marginInlineStart: 0,
  168. '> label': {
  169. width: '50%',
  170. textAlign: 'center'
  171. }
  172. }
  173. }
  174. }
  175. }
  176. };
  177. };
  178. exports.genCalendarStyles = genCalendarStyles;
  179. var _default = exports.default = (0, _internal.genComponentStyleHook)('Calendar', token => {
  180. const calendarCls = `${token.componentCls}-calendar`;
  181. const calendarToken = (0, _internal.mergeToken)((0, _style3.initInputToken)(token), (0, _style2.initPickerPanelToken)(token), {
  182. calendarCls,
  183. pickerCellInnerCls: `${token.componentCls}-cell-inner`,
  184. calendarFullBg: token.colorBgContainer,
  185. calendarFullPanelBg: token.colorBgContainer,
  186. calendarItemActiveBg: token.controlItemBgActive,
  187. dateValueHeight: token.controlHeightSM,
  188. weekHeight: token.controlHeightSM * 0.75,
  189. dateContentHeight: (token.fontSizeSM * token.lineHeightSM + token.marginXS) * 3 + token.lineWidth * 2
  190. });
  191. return [genCalendarStyles(calendarToken)];
  192. }, {
  193. yearControlWidth: 80,
  194. monthControlWidth: 70,
  195. miniContentHeight: 256
  196. });