| | import { FastColor } from '@ant-design/fast-color'; |
| |
|
| | import type { SharedComponentToken, SharedInputToken } from '../../input/style/token'; |
| | import { initComponentToken } from '../../input/style/token'; |
| | import type { MultipleSelectorToken, SelectorToken } from '../../select/style/token'; |
| | import type { ArrowToken } from '../../style/roundedArrow'; |
| | import { getArrowToken } from '../../style/roundedArrow'; |
| | import type { |
| | FullToken, |
| | GetDefaultToken, |
| | GlobalToken, |
| | TokenWithCommonCls, |
| | } from '../../theme/internal'; |
| |
|
| | export interface PanelComponentToken extends MultipleSelectorToken { |
| | |
| | |
| | |
| | |
| | cellHoverBg: string; |
| | |
| | |
| | |
| | |
| | cellActiveWithRangeBg: string; |
| | |
| | |
| | |
| | |
| | cellHoverWithRangeBg: string; |
| | |
| | |
| | |
| | |
| | cellBgDisabled: string; |
| | |
| | |
| | |
| | |
| | cellRangeBorderColor: string; |
| | |
| | |
| | |
| | |
| | timeColumnWidth: number; |
| | |
| | |
| | |
| | |
| | timeColumnHeight: number; |
| | |
| | |
| | |
| | |
| | timeCellHeight: number; |
| | |
| | |
| | |
| | |
| | cellHeight: number; |
| | |
| | |
| | |
| | |
| | cellWidth: number; |
| | |
| | |
| | |
| | |
| | textHeight: number; |
| | |
| | |
| | |
| | |
| | withoutTimeCellHeight: number; |
| | } |
| |
|
| | export interface ComponentToken |
| | extends Exclude<SharedComponentToken, 'addonBg'>, |
| | PanelComponentToken, |
| | ArrowToken { |
| | |
| | |
| | |
| | |
| | presetsWidth: number; |
| | |
| | |
| | |
| | |
| | presetsMaxWidth: number; |
| | |
| | |
| | |
| | |
| | zIndexPopup: number; |
| | } |
| |
|
| | export type PickerPanelToken = { |
| | pickerCellCls: string; |
| | pickerCellInnerCls: string; |
| | pickerDatePanelPaddingHorizontal: number | string; |
| | pickerYearMonthCellWidth: number | string; |
| | pickerCellPaddingVertical: number | string; |
| | pickerQuarterPanelContentHeight: number | string; |
| | pickerCellBorderGap: number; |
| | pickerControlIconSize: number; |
| | pickerControlIconMargin: number; |
| | pickerControlIconBorderWidth: number; |
| | }; |
| |
|
| | export interface PickerToken |
| | extends FullToken<'DatePicker'>, |
| | PickerPanelToken, |
| | SharedInputToken, |
| | SelectorToken { |
| | |
| | INTERNAL_FIXED_ITEM_MARGIN: number; |
| | } |
| |
|
| | export type SharedPickerToken = TokenWithCommonCls<GlobalToken> & |
| | PickerPanelToken & |
| | PanelComponentToken; |
| |
|
| | export const initPickerPanelToken = (token: TokenWithCommonCls<GlobalToken>): PickerPanelToken => { |
| | const { componentCls, controlHeightLG, paddingXXS, padding } = token; |
| |
|
| | return { |
| | pickerCellCls: `${componentCls}-cell`, |
| | pickerCellInnerCls: `${componentCls}-cell-inner`, |
| | pickerYearMonthCellWidth: token.calc(controlHeightLG).mul(1.5).equal(), |
| | pickerQuarterPanelContentHeight: token.calc(controlHeightLG).mul(1.4).equal(), |
| | pickerCellPaddingVertical: token.calc(paddingXXS).add(token.calc(paddingXXS).div(2)).equal(), |
| | pickerCellBorderGap: 2, |
| | pickerControlIconSize: 7, |
| | pickerControlIconMargin: 4, |
| | pickerControlIconBorderWidth: 1.5, |
| | pickerDatePanelPaddingHorizontal: token |
| | .calc(padding) |
| | .add(token.calc(paddingXXS).div(2)) |
| | .equal(), |
| | }; |
| | }; |
| |
|
| | export const initPanelComponentToken = (token: GlobalToken): PanelComponentToken => { |
| | const { |
| | colorBgContainerDisabled, |
| | controlHeight, |
| | controlHeightSM, |
| | controlHeightLG, |
| | paddingXXS, |
| | lineWidth, |
| | } = token; |
| |
|
| | |
| | |
| | |
| | const dblPaddingXXS = paddingXXS * 2; |
| | const dblLineWidth = lineWidth * 2; |
| |
|
| | const multipleItemHeight = Math.min(controlHeight - dblPaddingXXS, controlHeight - dblLineWidth); |
| | const multipleItemHeightSM = Math.min( |
| | controlHeightSM - dblPaddingXXS, |
| | controlHeightSM - dblLineWidth, |
| | ); |
| | const multipleItemHeightLG = Math.min( |
| | controlHeightLG - dblPaddingXXS, |
| | controlHeightLG - dblLineWidth, |
| | ); |
| |
|
| | |
| | const INTERNAL_FIXED_ITEM_MARGIN = Math.floor(paddingXXS / 2); |
| |
|
| | const filledToken = { |
| | INTERNAL_FIXED_ITEM_MARGIN, |
| | cellHoverBg: token.controlItemBgHover, |
| | cellActiveWithRangeBg: token.controlItemBgActive, |
| | cellHoverWithRangeBg: new FastColor(token.colorPrimary).lighten(35).toHexString(), |
| | cellRangeBorderColor: new FastColor(token.colorPrimary).lighten(20).toHexString(), |
| | cellBgDisabled: colorBgContainerDisabled, |
| | timeColumnWidth: controlHeightLG * 1.4, |
| | timeColumnHeight: 28 * 8, |
| | timeCellHeight: 28, |
| | cellWidth: controlHeightSM * 1.5, |
| | cellHeight: controlHeightSM, |
| | textHeight: controlHeightLG, |
| | withoutTimeCellHeight: controlHeightLG * 1.65, |
| | multipleItemBg: token.colorFillSecondary, |
| | multipleItemBorderColor: 'transparent', |
| | multipleItemHeight, |
| | multipleItemHeightSM, |
| | multipleItemHeightLG, |
| | multipleSelectorBgDisabled: colorBgContainerDisabled, |
| | multipleItemColorDisabled: token.colorTextDisabled, |
| | multipleItemBorderColorDisabled: 'transparent', |
| | }; |
| |
|
| | return filledToken; |
| | }; |
| |
|
| | export const prepareComponentToken: GetDefaultToken<'DatePicker'> = (token) => ({ |
| | ...initComponentToken(token), |
| | ...initPanelComponentToken(token), |
| | ...getArrowToken(token), |
| | presetsWidth: 120, |
| | presetsMaxWidth: 200, |
| | zIndexPopup: token.zIndexPopupBase + 50, |
| | }); |
| |
|