index.js 6.7 KB

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