panel.js 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.genPanelStyle = exports.default = void 0;
  6. var _cssinjs = require("@ant-design/cssinjs");
  7. var _fastColor = require("@ant-design/fast-color");
  8. const genPickerCellInnerStyle = token => {
  9. const {
  10. pickerCellCls,
  11. pickerCellInnerCls,
  12. cellHeight,
  13. borderRadiusSM,
  14. motionDurationMid,
  15. cellHoverBg,
  16. lineWidth,
  17. lineType,
  18. colorPrimary,
  19. cellActiveWithRangeBg,
  20. colorTextLightSolid,
  21. colorTextDisabled,
  22. cellBgDisabled,
  23. colorFillSecondary
  24. } = token;
  25. return {
  26. '&::before': {
  27. position: 'absolute',
  28. top: '50%',
  29. insetInlineStart: 0,
  30. insetInlineEnd: 0,
  31. zIndex: 1,
  32. height: cellHeight,
  33. transform: 'translateY(-50%)',
  34. content: '""',
  35. pointerEvents: 'none'
  36. },
  37. // >>> Default
  38. [pickerCellInnerCls]: {
  39. position: 'relative',
  40. zIndex: 2,
  41. display: 'inline-block',
  42. minWidth: cellHeight,
  43. height: cellHeight,
  44. lineHeight: (0, _cssinjs.unit)(cellHeight),
  45. borderRadius: borderRadiusSM,
  46. transition: `background ${motionDurationMid}`
  47. },
  48. // >>> Hover
  49. [`&:hover:not(${pickerCellCls}-in-view):not(${pickerCellCls}-disabled),
  50. &:hover:not(${pickerCellCls}-selected):not(${pickerCellCls}-range-start):not(${pickerCellCls}-range-end):not(${pickerCellCls}-disabled)`]: {
  51. [pickerCellInnerCls]: {
  52. background: cellHoverBg
  53. }
  54. },
  55. // >>> Today
  56. [`&-in-view${pickerCellCls}-today ${pickerCellInnerCls}`]: {
  57. '&::before': {
  58. position: 'absolute',
  59. top: 0,
  60. insetInlineEnd: 0,
  61. bottom: 0,
  62. insetInlineStart: 0,
  63. zIndex: 1,
  64. border: `${(0, _cssinjs.unit)(lineWidth)} ${lineType} ${colorPrimary}`,
  65. borderRadius: borderRadiusSM,
  66. content: '""'
  67. }
  68. },
  69. // >>> In Range
  70. [`&-in-view${pickerCellCls}-in-range,
  71. &-in-view${pickerCellCls}-range-start,
  72. &-in-view${pickerCellCls}-range-end`]: {
  73. position: 'relative',
  74. [`&:not(${pickerCellCls}-disabled):before`]: {
  75. background: cellActiveWithRangeBg
  76. }
  77. },
  78. // >>> Selected
  79. [`&-in-view${pickerCellCls}-selected,
  80. &-in-view${pickerCellCls}-range-start,
  81. &-in-view${pickerCellCls}-range-end`]: {
  82. [`&:not(${pickerCellCls}-disabled) ${pickerCellInnerCls}`]: {
  83. color: colorTextLightSolid,
  84. background: colorPrimary
  85. },
  86. [`&${pickerCellCls}-disabled ${pickerCellInnerCls}`]: {
  87. background: colorFillSecondary
  88. }
  89. },
  90. [`&-in-view${pickerCellCls}-range-start:not(${pickerCellCls}-disabled):before`]: {
  91. insetInlineStart: '50%'
  92. },
  93. [`&-in-view${pickerCellCls}-range-end:not(${pickerCellCls}-disabled):before`]: {
  94. insetInlineEnd: '50%'
  95. },
  96. // range start border-radius
  97. [`&-in-view${pickerCellCls}-range-start:not(${pickerCellCls}-range-end) ${pickerCellInnerCls}`]: {
  98. borderStartStartRadius: borderRadiusSM,
  99. borderEndStartRadius: borderRadiusSM,
  100. borderStartEndRadius: 0,
  101. borderEndEndRadius: 0
  102. },
  103. // range end border-radius
  104. [`&-in-view${pickerCellCls}-range-end:not(${pickerCellCls}-range-start) ${pickerCellInnerCls}`]: {
  105. borderStartStartRadius: 0,
  106. borderEndStartRadius: 0,
  107. borderStartEndRadius: borderRadiusSM,
  108. borderEndEndRadius: borderRadiusSM
  109. },
  110. // >>> Disabled
  111. '&-disabled': {
  112. color: colorTextDisabled,
  113. cursor: 'not-allowed',
  114. [pickerCellInnerCls]: {
  115. background: 'transparent'
  116. },
  117. '&::before': {
  118. background: cellBgDisabled
  119. }
  120. },
  121. [`&-disabled${pickerCellCls}-today ${pickerCellInnerCls}::before`]: {
  122. borderColor: colorTextDisabled
  123. }
  124. };
  125. };
  126. const genPanelStyle = token => {
  127. const {
  128. componentCls,
  129. pickerCellCls,
  130. pickerCellInnerCls,
  131. pickerYearMonthCellWidth,
  132. pickerControlIconSize,
  133. cellWidth,
  134. paddingSM,
  135. paddingXS,
  136. paddingXXS,
  137. colorBgContainer,
  138. lineWidth,
  139. lineType,
  140. borderRadiusLG,
  141. colorPrimary,
  142. colorTextHeading,
  143. colorSplit,
  144. pickerControlIconBorderWidth,
  145. colorIcon,
  146. textHeight,
  147. motionDurationMid,
  148. colorIconHover,
  149. fontWeightStrong,
  150. cellHeight,
  151. pickerCellPaddingVertical,
  152. colorTextDisabled,
  153. colorText,
  154. fontSize,
  155. motionDurationSlow,
  156. withoutTimeCellHeight,
  157. pickerQuarterPanelContentHeight,
  158. borderRadiusSM,
  159. colorTextLightSolid,
  160. cellHoverBg,
  161. timeColumnHeight,
  162. timeColumnWidth,
  163. timeCellHeight,
  164. controlItemBgActive,
  165. marginXXS,
  166. pickerDatePanelPaddingHorizontal,
  167. pickerControlIconMargin
  168. } = token;
  169. const pickerPanelWidth = token.calc(cellWidth).mul(7).add(token.calc(pickerDatePanelPaddingHorizontal).mul(2)).equal();
  170. return {
  171. [componentCls]: {
  172. '&-panel': {
  173. display: 'inline-flex',
  174. flexDirection: 'column',
  175. textAlign: 'center',
  176. background: colorBgContainer,
  177. borderRadius: borderRadiusLG,
  178. outline: 'none',
  179. '&-focused': {
  180. borderColor: colorPrimary
  181. },
  182. '&-rtl': {
  183. [`${componentCls}-prev-icon,
  184. ${componentCls}-super-prev-icon`]: {
  185. transform: 'rotate(45deg)'
  186. },
  187. [`${componentCls}-next-icon,
  188. ${componentCls}-super-next-icon`]: {
  189. transform: 'rotate(-135deg)'
  190. },
  191. [`${componentCls}-time-panel`]: {
  192. [`${componentCls}-content`]: {
  193. direction: 'ltr',
  194. '> *': {
  195. direction: 'rtl'
  196. }
  197. }
  198. }
  199. }
  200. },
  201. // ========================================================
  202. // = Shared Panel =
  203. // ========================================================
  204. [`&-decade-panel,
  205. &-year-panel,
  206. &-quarter-panel,
  207. &-month-panel,
  208. &-week-panel,
  209. &-date-panel,
  210. &-time-panel`]: {
  211. display: 'flex',
  212. flexDirection: 'column',
  213. width: pickerPanelWidth
  214. },
  215. // ======================= Header =======================
  216. '&-header': {
  217. display: 'flex',
  218. padding: `0 ${(0, _cssinjs.unit)(paddingXS)}`,
  219. color: colorTextHeading,
  220. borderBottom: `${(0, _cssinjs.unit)(lineWidth)} ${lineType} ${colorSplit}`,
  221. '> *': {
  222. flex: 'none'
  223. },
  224. button: {
  225. padding: 0,
  226. color: colorIcon,
  227. lineHeight: (0, _cssinjs.unit)(textHeight),
  228. background: 'transparent',
  229. border: 0,
  230. cursor: 'pointer',
  231. transition: `color ${motionDurationMid}`,
  232. fontSize: 'inherit',
  233. display: 'inline-flex',
  234. alignItems: 'center',
  235. justifyContent: 'center',
  236. '&:empty': {
  237. display: 'none'
  238. }
  239. },
  240. '> button': {
  241. minWidth: '1.6em',
  242. fontSize,
  243. '&:hover': {
  244. color: colorIconHover
  245. },
  246. '&:disabled': {
  247. opacity: 0.25,
  248. pointerEvents: 'none'
  249. }
  250. },
  251. '&-view': {
  252. flex: 'auto',
  253. fontWeight: fontWeightStrong,
  254. lineHeight: (0, _cssinjs.unit)(textHeight),
  255. '> button': {
  256. color: 'inherit',
  257. fontWeight: 'inherit',
  258. verticalAlign: 'top',
  259. '&:not(:first-child)': {
  260. marginInlineStart: paddingXS
  261. },
  262. '&:hover': {
  263. color: colorPrimary
  264. }
  265. }
  266. }
  267. },
  268. // Arrow button
  269. [`&-prev-icon,
  270. &-next-icon,
  271. &-super-prev-icon,
  272. &-super-next-icon`]: {
  273. position: 'relative',
  274. width: pickerControlIconSize,
  275. height: pickerControlIconSize,
  276. '&::before': {
  277. position: 'absolute',
  278. top: 0,
  279. insetInlineStart: 0,
  280. width: pickerControlIconSize,
  281. height: pickerControlIconSize,
  282. border: `0 solid currentcolor`,
  283. borderBlockStartWidth: pickerControlIconBorderWidth,
  284. borderInlineStartWidth: pickerControlIconBorderWidth,
  285. content: '""'
  286. }
  287. },
  288. [`&-super-prev-icon,
  289. &-super-next-icon`]: {
  290. '&::after': {
  291. position: 'absolute',
  292. top: pickerControlIconMargin,
  293. insetInlineStart: pickerControlIconMargin,
  294. display: 'inline-block',
  295. width: pickerControlIconSize,
  296. height: pickerControlIconSize,
  297. border: '0 solid currentcolor',
  298. borderBlockStartWidth: pickerControlIconBorderWidth,
  299. borderInlineStartWidth: pickerControlIconBorderWidth,
  300. content: '""'
  301. }
  302. },
  303. '&-prev-icon, &-super-prev-icon': {
  304. transform: 'rotate(-45deg)'
  305. },
  306. '&-next-icon, &-super-next-icon': {
  307. transform: 'rotate(135deg)'
  308. },
  309. // ======================== Body ========================
  310. '&-content': {
  311. width: '100%',
  312. tableLayout: 'fixed',
  313. borderCollapse: 'collapse',
  314. 'th, td': {
  315. position: 'relative',
  316. minWidth: cellHeight,
  317. fontWeight: 'normal'
  318. },
  319. th: {
  320. height: token.calc(cellHeight).add(token.calc(pickerCellPaddingVertical).mul(2)).equal(),
  321. color: colorText,
  322. verticalAlign: 'middle'
  323. }
  324. },
  325. '&-cell': Object.assign({
  326. padding: `${(0, _cssinjs.unit)(pickerCellPaddingVertical)} 0`,
  327. color: colorTextDisabled,
  328. cursor: 'pointer',
  329. // In view
  330. '&-in-view': {
  331. color: colorText
  332. }
  333. }, genPickerCellInnerStyle(token)),
  334. [`&-decade-panel,
  335. &-year-panel,
  336. &-quarter-panel,
  337. &-month-panel`]: {
  338. [`${componentCls}-content`]: {
  339. height: token.calc(withoutTimeCellHeight).mul(4).equal()
  340. },
  341. [pickerCellInnerCls]: {
  342. padding: `0 ${(0, _cssinjs.unit)(paddingXS)}`
  343. }
  344. },
  345. '&-quarter-panel': {
  346. [`${componentCls}-content`]: {
  347. height: pickerQuarterPanelContentHeight
  348. }
  349. },
  350. // ========================================================
  351. // = Special =
  352. // ========================================================
  353. // ===================== Decade Panel =====================
  354. '&-decade-panel': {
  355. [pickerCellInnerCls]: {
  356. padding: `0 ${(0, _cssinjs.unit)(token.calc(paddingXS).div(2).equal())}`
  357. },
  358. [`${componentCls}-cell::before`]: {
  359. display: 'none'
  360. }
  361. },
  362. // ============= Year & Quarter & Month Panel =============
  363. [`&-year-panel,
  364. &-quarter-panel,
  365. &-month-panel`]: {
  366. [`${componentCls}-body`]: {
  367. padding: `0 ${(0, _cssinjs.unit)(paddingXS)}`
  368. },
  369. [pickerCellInnerCls]: {
  370. width: pickerYearMonthCellWidth
  371. }
  372. },
  373. // ====================== Date Panel ======================
  374. '&-date-panel': {
  375. [`${componentCls}-body`]: {
  376. padding: `${(0, _cssinjs.unit)(paddingXS)} ${(0, _cssinjs.unit)(pickerDatePanelPaddingHorizontal)}`
  377. },
  378. [`${componentCls}-content th`]: {
  379. boxSizing: 'border-box',
  380. padding: 0
  381. }
  382. },
  383. // ====================== Week Panel ======================
  384. '&-week-panel-row': {
  385. td: {
  386. '&:before': {
  387. transition: `background ${motionDurationMid}`
  388. },
  389. '&:first-child:before': {
  390. borderStartStartRadius: borderRadiusSM,
  391. borderEndStartRadius: borderRadiusSM
  392. },
  393. '&:last-child:before': {
  394. borderStartEndRadius: borderRadiusSM,
  395. borderEndEndRadius: borderRadiusSM
  396. }
  397. },
  398. '&:hover td:before': {
  399. background: cellHoverBg
  400. },
  401. '&-range-start td, &-range-end td, &-selected td, &-hover td': {
  402. // Rise priority to override hover style
  403. [`&${pickerCellCls}`]: {
  404. '&:before': {
  405. background: colorPrimary
  406. },
  407. [`&${componentCls}-cell-week`]: {
  408. color: new _fastColor.FastColor(colorTextLightSolid).setA(0.5).toHexString()
  409. },
  410. [pickerCellInnerCls]: {
  411. color: colorTextLightSolid
  412. }
  413. }
  414. },
  415. '&-range-hover td:before': {
  416. background: controlItemBgActive
  417. }
  418. },
  419. // >>> ShowWeek
  420. '&-week-panel, &-date-panel-show-week': {
  421. [`${componentCls}-body`]: {
  422. padding: `${(0, _cssinjs.unit)(paddingXS)} ${(0, _cssinjs.unit)(paddingSM)}`
  423. },
  424. [`${componentCls}-content th`]: {
  425. width: 'auto'
  426. }
  427. },
  428. // ==================== Datetime Panel ====================
  429. '&-datetime-panel': {
  430. display: 'flex',
  431. [`${componentCls}-time-panel`]: {
  432. borderInlineStart: `${(0, _cssinjs.unit)(lineWidth)} ${lineType} ${colorSplit}`
  433. },
  434. [`${componentCls}-date-panel,
  435. ${componentCls}-time-panel`]: {
  436. transition: `opacity ${motionDurationSlow}`
  437. },
  438. // Keyboard
  439. '&-active': {
  440. [`${componentCls}-date-panel,
  441. ${componentCls}-time-panel`]: {
  442. opacity: 0.3,
  443. '&-active': {
  444. opacity: 1
  445. }
  446. }
  447. }
  448. },
  449. // ====================== Time Panel ======================
  450. '&-time-panel': {
  451. width: 'auto',
  452. minWidth: 'auto',
  453. [`${componentCls}-content`]: {
  454. display: 'flex',
  455. flex: 'auto',
  456. height: timeColumnHeight
  457. },
  458. '&-column': {
  459. flex: '1 0 auto',
  460. width: timeColumnWidth,
  461. margin: `${(0, _cssinjs.unit)(paddingXXS)} 0`,
  462. padding: 0,
  463. overflowY: 'hidden',
  464. textAlign: 'start',
  465. listStyle: 'none',
  466. transition: `background ${motionDurationMid}`,
  467. overflowX: 'hidden',
  468. '&::-webkit-scrollbar': {
  469. width: 8,
  470. backgroundColor: 'transparent'
  471. },
  472. '&::-webkit-scrollbar-thumb': {
  473. backgroundColor: token.colorTextTertiary,
  474. borderRadius: token.borderRadiusSM
  475. },
  476. // For Firefox
  477. '&': {
  478. scrollbarWidth: 'thin',
  479. scrollbarColor: `${token.colorTextTertiary} transparent`
  480. },
  481. '&::after': {
  482. display: 'block',
  483. height: `calc(100% - ${(0, _cssinjs.unit)(timeCellHeight)})`,
  484. content: '""'
  485. },
  486. '&:not(:first-child)': {
  487. borderInlineStart: `${(0, _cssinjs.unit)(lineWidth)} ${lineType} ${colorSplit}`
  488. },
  489. '&-active': {
  490. background: new _fastColor.FastColor(controlItemBgActive).setA(0.2).toHexString()
  491. },
  492. '&:hover': {
  493. overflowY: 'auto'
  494. },
  495. '> li': {
  496. margin: 0,
  497. padding: 0,
  498. [`&${componentCls}-time-panel-cell`]: {
  499. marginInline: marginXXS,
  500. [`${componentCls}-time-panel-cell-inner`]: {
  501. display: 'block',
  502. width: token.calc(timeColumnWidth).sub(token.calc(marginXXS).mul(2)).equal(),
  503. height: timeCellHeight,
  504. margin: 0,
  505. paddingBlock: 0,
  506. paddingInlineEnd: 0,
  507. paddingInlineStart: token.calc(timeColumnWidth).sub(timeCellHeight).div(2).equal(),
  508. color: colorText,
  509. lineHeight: (0, _cssinjs.unit)(timeCellHeight),
  510. borderRadius: borderRadiusSM,
  511. cursor: 'pointer',
  512. transition: `background ${motionDurationMid}`,
  513. '&:hover': {
  514. background: cellHoverBg
  515. }
  516. },
  517. '&-selected': {
  518. [`${componentCls}-time-panel-cell-inner`]: {
  519. background: controlItemBgActive
  520. }
  521. },
  522. '&-disabled': {
  523. [`${componentCls}-time-panel-cell-inner`]: {
  524. color: colorTextDisabled,
  525. background: 'transparent',
  526. cursor: 'not-allowed'
  527. }
  528. }
  529. }
  530. }
  531. }
  532. }
  533. }
  534. };
  535. };
  536. exports.genPanelStyle = genPanelStyle;
  537. const genPickerPanelStyle = token => {
  538. const {
  539. componentCls,
  540. textHeight,
  541. lineWidth,
  542. paddingSM,
  543. antCls,
  544. colorPrimary,
  545. cellActiveWithRangeBg,
  546. colorPrimaryBorder,
  547. lineType,
  548. colorSplit
  549. } = token;
  550. return {
  551. [`${componentCls}-dropdown`]: {
  552. // ======================== Footer ========================
  553. [`${componentCls}-footer`]: {
  554. borderTop: `${(0, _cssinjs.unit)(lineWidth)} ${lineType} ${colorSplit}`,
  555. '&-extra': {
  556. padding: `0 ${(0, _cssinjs.unit)(paddingSM)}`,
  557. lineHeight: (0, _cssinjs.unit)(token.calc(textHeight).sub(token.calc(lineWidth).mul(2)).equal()),
  558. textAlign: 'start',
  559. '&:not(:last-child)': {
  560. borderBottom: `${(0, _cssinjs.unit)(lineWidth)} ${lineType} ${colorSplit}`
  561. }
  562. }
  563. },
  564. // ==================== Footer > Ranges ===================
  565. [`${componentCls}-panels + ${componentCls}-footer ${componentCls}-ranges`]: {
  566. justifyContent: 'space-between'
  567. },
  568. [`${componentCls}-ranges`]: {
  569. marginBlock: 0,
  570. paddingInline: (0, _cssinjs.unit)(paddingSM),
  571. overflow: 'hidden',
  572. textAlign: 'start',
  573. listStyle: 'none',
  574. display: 'flex',
  575. justifyContent: 'center',
  576. alignItems: 'center',
  577. '> li': {
  578. lineHeight: (0, _cssinjs.unit)(token.calc(textHeight).sub(token.calc(lineWidth).mul(2)).equal()),
  579. display: 'inline-block'
  580. },
  581. [`${componentCls}-now-btn-disabled`]: {
  582. pointerEvents: 'none',
  583. color: token.colorTextDisabled
  584. },
  585. // https://github.com/ant-design/ant-design/issues/23687
  586. [`${componentCls}-preset > ${antCls}-tag-blue`]: {
  587. color: colorPrimary,
  588. background: cellActiveWithRangeBg,
  589. borderColor: colorPrimaryBorder,
  590. cursor: 'pointer'
  591. },
  592. [`${componentCls}-ok`]: {
  593. paddingBlock: token.calc(lineWidth).mul(2).equal(),
  594. marginInlineStart: 'auto'
  595. }
  596. }
  597. }
  598. };
  599. };
  600. var _default = exports.default = genPickerPanelStyle;