mirror of
https://github.com/ant-design/ant-design.git
synced 2025-06-07 17:44:35 +08:00
refactor: DatePicker support css var (#45753)
* chore: add token * refactor: arrow style * chore: update style
This commit is contained in:
parent
9aac9415a5
commit
9670a30281
@ -19,6 +19,7 @@ import { useLocale } from '../../locale';
|
|||||||
import { useCompactItemContext } from '../../space/Compact';
|
import { useCompactItemContext } from '../../space/Compact';
|
||||||
import enUS from '../locale/en_US';
|
import enUS from '../locale/en_US';
|
||||||
import useStyle from '../style';
|
import useStyle from '../style';
|
||||||
|
import useCSSVar from '../style/cssVar';
|
||||||
import {
|
import {
|
||||||
getRangePlaceholder,
|
getRangePlaceholder,
|
||||||
getTimeProps,
|
getTimeProps,
|
||||||
@ -28,6 +29,7 @@ import {
|
|||||||
import Components from './Components';
|
import Components from './Components';
|
||||||
import type { CommonPickerMethods, PickerComponentClass } from './interface';
|
import type { CommonPickerMethods, PickerComponentClass } from './interface';
|
||||||
import { useZIndex } from '../../_util/hooks/useZIndex';
|
import { useZIndex } from '../../_util/hooks/useZIndex';
|
||||||
|
import useCSSVarCls from '../../config-provider/hooks/useCSSVarCls';
|
||||||
|
|
||||||
export default function generateRangePicker<DateType>(generateConfig: GenerateConfig<DateType>) {
|
export default function generateRangePicker<DateType>(generateConfig: GenerateConfig<DateType>) {
|
||||||
type InternalRangePickerProps = RangePickerProps<DateType> & {};
|
type InternalRangePickerProps = RangePickerProps<DateType> & {};
|
||||||
@ -71,7 +73,9 @@ export default function generateRangePicker<DateType>(generateConfig: GenerateCo
|
|||||||
const { format, showTime, picker } = props as any;
|
const { format, showTime, picker } = props as any;
|
||||||
const rootPrefixCls = getPrefixCls();
|
const rootPrefixCls = getPrefixCls();
|
||||||
|
|
||||||
const [wrapSSR, hashId] = useStyle(prefixCls);
|
const [, hashId] = useStyle(prefixCls);
|
||||||
|
const cssVarCls = useCSSVarCls(prefixCls);
|
||||||
|
const wrapCSSVar = useCSSVar(cssVarCls);
|
||||||
|
|
||||||
const additionalOverrideProps: any = {
|
const additionalOverrideProps: any = {
|
||||||
...(showTime ? getTimeProps({ format, picker, ...showTime }) : {}),
|
...(showTime ? getTimeProps({ format, picker, ...showTime }) : {}),
|
||||||
@ -115,7 +119,7 @@ export default function generateRangePicker<DateType>(generateConfig: GenerateCo
|
|||||||
// ============================ zIndex ============================
|
// ============================ zIndex ============================
|
||||||
const [zIndex] = useZIndex('DatePicker', props.popupStyle?.zIndex as number);
|
const [zIndex] = useZIndex('DatePicker', props.popupStyle?.zIndex as number);
|
||||||
|
|
||||||
return wrapSSR(
|
return wrapCSSVar(
|
||||||
<RCRangePicker<DateType>
|
<RCRangePicker<DateType>
|
||||||
separator={
|
separator={
|
||||||
<span aria-label="to" className={`${prefixCls}-separator`}>
|
<span aria-label="to" className={`${prefixCls}-separator`}>
|
||||||
@ -144,6 +148,7 @@ export default function generateRangePicker<DateType>(generateConfig: GenerateCo
|
|||||||
compactItemClassnames,
|
compactItemClassnames,
|
||||||
className,
|
className,
|
||||||
rangePicker?.className,
|
rangePicker?.className,
|
||||||
|
cssVarCls,
|
||||||
rootClassName,
|
rootClassName,
|
||||||
)}
|
)}
|
||||||
style={{ ...rangePicker?.style, ...style }}
|
style={{ ...rangePicker?.style, ...style }}
|
||||||
@ -153,7 +158,12 @@ export default function generateRangePicker<DateType>(generateConfig: GenerateCo
|
|||||||
generateConfig={generateConfig}
|
generateConfig={generateConfig}
|
||||||
components={Components}
|
components={Components}
|
||||||
direction={direction}
|
direction={direction}
|
||||||
dropdownClassName={classNames(hashId, popupClassName || dropdownClassName, rootClassName)}
|
dropdownClassName={classNames(
|
||||||
|
hashId,
|
||||||
|
popupClassName || dropdownClassName,
|
||||||
|
cssVarCls,
|
||||||
|
rootClassName,
|
||||||
|
)}
|
||||||
popupStyle={{
|
popupStyle={{
|
||||||
...props.popupStyle,
|
...props.popupStyle,
|
||||||
zIndex,
|
zIndex,
|
||||||
|
@ -20,6 +20,7 @@ import { useLocale } from '../../locale';
|
|||||||
import { useCompactItemContext } from '../../space/Compact';
|
import { useCompactItemContext } from '../../space/Compact';
|
||||||
import enUS from '../locale/en_US';
|
import enUS from '../locale/en_US';
|
||||||
import useStyle from '../style';
|
import useStyle from '../style';
|
||||||
|
import useCSSVar from '../style/cssVar';
|
||||||
import {
|
import {
|
||||||
getPlaceholder,
|
getPlaceholder,
|
||||||
getTimeProps,
|
getTimeProps,
|
||||||
@ -29,6 +30,7 @@ import {
|
|||||||
import Components from './Components';
|
import Components from './Components';
|
||||||
import type { CommonPickerMethods, DatePickRef, PickerComponentClass } from './interface';
|
import type { CommonPickerMethods, DatePickRef, PickerComponentClass } from './interface';
|
||||||
import { useZIndex } from '../../_util/hooks/useZIndex';
|
import { useZIndex } from '../../_util/hooks/useZIndex';
|
||||||
|
import useCSSVarCls from '../../config-provider/hooks/useCSSVarCls';
|
||||||
|
|
||||||
export default function generatePicker<DateType>(generateConfig: GenerateConfig<DateType>) {
|
export default function generatePicker<DateType>(generateConfig: GenerateConfig<DateType>) {
|
||||||
type CustomPickerProps = {
|
type CustomPickerProps = {
|
||||||
@ -79,7 +81,9 @@ export default function generatePicker<DateType>(generateConfig: GenerateConfig<
|
|||||||
const innerRef = React.useRef<RCPicker<DateType>>(null);
|
const innerRef = React.useRef<RCPicker<DateType>>(null);
|
||||||
const { format, showTime } = props as any;
|
const { format, showTime } = props as any;
|
||||||
|
|
||||||
const [wrapSSR, hashId] = useStyle(prefixCls);
|
const [, hashId] = useStyle(prefixCls);
|
||||||
|
const cssVarCls = useCSSVarCls(prefixCls);
|
||||||
|
const wrapCSSVar = useCSSVar(cssVarCls);
|
||||||
|
|
||||||
useImperativeHandle(ref, () => ({
|
useImperativeHandle(ref, () => ({
|
||||||
focus: () => innerRef.current?.focus(),
|
focus: () => innerRef.current?.focus(),
|
||||||
@ -142,7 +146,7 @@ export default function generatePicker<DateType>(generateConfig: GenerateConfig<
|
|||||||
// ============================ zIndex ============================
|
// ============================ zIndex ============================
|
||||||
const [zIndex] = useZIndex('DatePicker', props.popupStyle?.zIndex as number);
|
const [zIndex] = useZIndex('DatePicker', props.popupStyle?.zIndex as number);
|
||||||
|
|
||||||
return wrapSSR(
|
return wrapCSSVar(
|
||||||
<RCPicker<DateType>
|
<RCPicker<DateType>
|
||||||
ref={innerRef}
|
ref={innerRef}
|
||||||
placeholder={getPlaceholder(locale, mergedPicker, placeholder)}
|
placeholder={getPlaceholder(locale, mergedPicker, placeholder)}
|
||||||
@ -171,6 +175,7 @@ export default function generatePicker<DateType>(generateConfig: GenerateConfig<
|
|||||||
compactItemClassnames,
|
compactItemClassnames,
|
||||||
consumerStyle?.className,
|
consumerStyle?.className,
|
||||||
className,
|
className,
|
||||||
|
cssVarCls,
|
||||||
rootClassName,
|
rootClassName,
|
||||||
)}
|
)}
|
||||||
style={{ ...consumerStyle?.style, ...style }}
|
style={{ ...consumerStyle?.style, ...style }}
|
||||||
@ -182,6 +187,7 @@ export default function generatePicker<DateType>(generateConfig: GenerateConfig<
|
|||||||
disabled={mergedDisabled}
|
disabled={mergedDisabled}
|
||||||
dropdownClassName={classNames(
|
dropdownClassName={classNames(
|
||||||
hashId,
|
hashId,
|
||||||
|
cssVarCls,
|
||||||
rootClassName,
|
rootClassName,
|
||||||
popupClassName || dropdownClassName,
|
popupClassName || dropdownClassName,
|
||||||
)}
|
)}
|
||||||
|
4
components/date-picker/style/cssVar.ts
Normal file
4
components/date-picker/style/cssVar.ts
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
import { genCSSVarRegister } from '../../theme/internal';
|
||||||
|
import { prepareComponentToken } from '.';
|
||||||
|
|
||||||
|
export default genCSSVarRegister('DatePicker', prepareComponentToken);
|
@ -1,4 +1,5 @@
|
|||||||
import type { CSSObject } from '@ant-design/cssinjs';
|
import type { CSSObject } from '@ant-design/cssinjs';
|
||||||
|
import { unit } from '@ant-design/cssinjs';
|
||||||
import { TinyColor } from '@ctrl/tinycolor';
|
import { TinyColor } from '@ctrl/tinycolor';
|
||||||
|
|
||||||
import type { SharedComponentToken, SharedInputToken } from '../../input/style';
|
import type { SharedComponentToken, SharedInputToken } from '../../input/style';
|
||||||
@ -9,7 +10,7 @@ import {
|
|||||||
initComponentToken,
|
initComponentToken,
|
||||||
initInputToken,
|
initInputToken,
|
||||||
} from '../../input/style';
|
} from '../../input/style';
|
||||||
import { resetComponent, roundedArrow, textEllipsis } from '../../style';
|
import { resetComponent, textEllipsis } from '../../style';
|
||||||
import { genCompactItemStyle } from '../../style/compact-item';
|
import { genCompactItemStyle } from '../../style/compact-item';
|
||||||
import {
|
import {
|
||||||
initMoveMotion,
|
initMoveMotion,
|
||||||
@ -20,9 +21,11 @@ import {
|
|||||||
slideUpOut,
|
slideUpOut,
|
||||||
} from '../../style/motion';
|
} from '../../style/motion';
|
||||||
import type { GlobalToken } from '../../theme/interface';
|
import type { GlobalToken } from '../../theme/interface';
|
||||||
import type { FullToken, GenerateStyle } from '../../theme/internal';
|
import type { FullToken, GenerateStyle, GetDefaultToken } from '../../theme/internal';
|
||||||
import { genComponentStyleHook, mergeToken } from '../../theme/internal';
|
import { genComponentStyleHook, mergeToken } from '../../theme/internal';
|
||||||
import type { TokenWithCommonCls } from '../../theme/util/genComponentStyleHook';
|
import type { TokenWithCommonCls } from '../../theme/util/genComponentStyleHook';
|
||||||
|
import type { ArrowToken } from '../../style/roundedArrow';
|
||||||
|
import { genRoundedArrow, getArrowToken } from '../../style/roundedArrow';
|
||||||
|
|
||||||
export interface PanelComponentToken {
|
export interface PanelComponentToken {
|
||||||
/**
|
/**
|
||||||
@ -89,7 +92,8 @@ export interface PanelComponentToken {
|
|||||||
|
|
||||||
export interface ComponentToken
|
export interface ComponentToken
|
||||||
extends Exclude<SharedComponentToken, 'addonBg'>,
|
extends Exclude<SharedComponentToken, 'addonBg'>,
|
||||||
PanelComponentToken {
|
PanelComponentToken,
|
||||||
|
ArrowToken {
|
||||||
/**
|
/**
|
||||||
* @desc 预设区域宽度
|
* @desc 预设区域宽度
|
||||||
* @descEN Width of preset area
|
* @descEN Width of preset area
|
||||||
@ -110,12 +114,13 @@ export interface ComponentToken
|
|||||||
export type PickerPanelToken = {
|
export type PickerPanelToken = {
|
||||||
pickerCellCls: string;
|
pickerCellCls: string;
|
||||||
pickerCellInnerCls: string;
|
pickerCellInnerCls: string;
|
||||||
pickerDatePanelPaddingHorizontal: number;
|
pickerDatePanelPaddingHorizontal: number | string;
|
||||||
pickerYearMonthCellWidth: number;
|
pickerYearMonthCellWidth: number | string;
|
||||||
pickerCellPaddingVertical: number;
|
pickerCellPaddingVertical: number | string;
|
||||||
pickerQuarterPanelContentHeight: number;
|
pickerQuarterPanelContentHeight: number | string;
|
||||||
pickerCellBorderGap: number;
|
pickerCellBorderGap: number;
|
||||||
pickerControlIconSize: number;
|
pickerControlIconSize: number;
|
||||||
|
pickerControlIconMargin: number;
|
||||||
pickerControlIconBorderWidth: number;
|
pickerControlIconBorderWidth: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -126,17 +131,15 @@ type SharedPickerToken = TokenWithCommonCls<GlobalToken> & PickerPanelToken & Pa
|
|||||||
const genPikerPadding = (
|
const genPikerPadding = (
|
||||||
token: PickerToken,
|
token: PickerToken,
|
||||||
inputHeight: number,
|
inputHeight: number,
|
||||||
fontSize: number,
|
fontHeight: number,
|
||||||
paddingHorizontal: number,
|
paddingHorizontal: number,
|
||||||
): CSSObject => {
|
): CSSObject => {
|
||||||
const { lineHeight } = token;
|
const height = token.calc(fontHeight).add(2).equal();
|
||||||
|
const paddingTop = token.max(token.calc(inputHeight).sub(height).div(2).equal(), 0);
|
||||||
const fontHeight = Math.floor(fontSize * lineHeight) + 2;
|
const paddingBottom = token.max(token.calc(inputHeight).sub(height).sub(paddingTop).equal(), 0);
|
||||||
const paddingTop = Math.max((inputHeight - fontHeight) / 2, 0);
|
|
||||||
const paddingBottom = Math.max(inputHeight - fontHeight - paddingTop, 0);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
padding: `${paddingTop}px ${paddingHorizontal}px ${paddingBottom}px`,
|
padding: `${unit(paddingTop)} ${unit(paddingHorizontal)} ${unit(paddingBottom)}`,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -184,7 +187,7 @@ const genPickerCellInnerStyle = (token: SharedPickerToken): CSSObject => {
|
|||||||
display: 'inline-block',
|
display: 'inline-block',
|
||||||
minWidth: cellHeight,
|
minWidth: cellHeight,
|
||||||
height: cellHeight,
|
height: cellHeight,
|
||||||
lineHeight: `${cellHeight}px`,
|
lineHeight: unit(cellHeight),
|
||||||
borderRadius: borderRadiusSM,
|
borderRadius: borderRadiusSM,
|
||||||
transition: `background ${motionDurationMid}, border ${motionDurationMid}`,
|
transition: `background ${motionDurationMid}, border ${motionDurationMid}`,
|
||||||
},
|
},
|
||||||
@ -213,7 +216,7 @@ const genPickerCellInnerStyle = (token: SharedPickerToken): CSSObject => {
|
|||||||
bottom: 0,
|
bottom: 0,
|
||||||
insetInlineStart: 0,
|
insetInlineStart: 0,
|
||||||
zIndex: 1,
|
zIndex: 1,
|
||||||
border: `${lineWidth}px ${lineType} ${colorPrimary}`,
|
border: `${unit(lineWidth)} ${lineType} ${colorPrimary}`,
|
||||||
borderRadius: borderRadiusSM,
|
borderRadius: borderRadiusSM,
|
||||||
content: '""',
|
content: '""',
|
||||||
},
|
},
|
||||||
@ -264,8 +267,8 @@ const genPickerCellInnerStyle = (token: SharedPickerToken): CSSObject => {
|
|||||||
top: '50%',
|
top: '50%',
|
||||||
zIndex: 0,
|
zIndex: 0,
|
||||||
height: controlHeightSM,
|
height: controlHeightSM,
|
||||||
borderTop: `${lineWidth}px dashed ${cellRangeBorderColor}`,
|
borderTop: `${unit(lineWidth)} dashed ${cellRangeBorderColor}`,
|
||||||
borderBottom: `${lineWidth}px dashed ${cellRangeBorderColor}`,
|
borderBottom: `${unit(lineWidth)} dashed ${cellRangeBorderColor}`,
|
||||||
transform: 'translateY(-50%)',
|
transform: 'translateY(-50%)',
|
||||||
transition: `all ${motionDurationSlow}`,
|
transition: `all ${motionDurationSlow}`,
|
||||||
content: '""',
|
content: '""',
|
||||||
@ -325,8 +328,8 @@ const genPickerCellInnerStyle = (token: SharedPickerToken): CSSObject => {
|
|||||||
&-in-view${pickerCellCls}-start${pickerCellCls}-range-hover-edge-start${pickerCellCls}-range-hover-edge-start-near-range::after,
|
&-in-view${pickerCellCls}-start${pickerCellCls}-range-hover-edge-start${pickerCellCls}-range-hover-edge-start-near-range::after,
|
||||||
&-in-view${pickerCellCls}-range-hover-edge-start:not(${pickerCellCls}-range-hover-edge-start-near-range)::after,
|
&-in-view${pickerCellCls}-range-hover-edge-start:not(${pickerCellCls}-range-hover-edge-start-near-range)::after,
|
||||||
&-in-view${pickerCellCls}-range-hover-start::after`]: {
|
&-in-view${pickerCellCls}-range-hover-start::after`]: {
|
||||||
insetInlineStart: (cellWidth - cellHeight) / 2,
|
insetInlineStart: token.calc(cellWidth).sub(cellHeight).div(2).equal(),
|
||||||
borderInlineStart: `${lineWidth}px dashed ${cellRangeBorderColor}`,
|
borderInlineStart: `${unit(lineWidth)} dashed ${cellRangeBorderColor}`,
|
||||||
borderStartStartRadius: borderRadiusSM,
|
borderStartStartRadius: borderRadiusSM,
|
||||||
borderEndStartRadius: borderRadiusSM,
|
borderEndStartRadius: borderRadiusSM,
|
||||||
},
|
},
|
||||||
@ -337,8 +340,8 @@ const genPickerCellInnerStyle = (token: SharedPickerToken): CSSObject => {
|
|||||||
&-in-view${pickerCellCls}-end${pickerCellCls}-range-hover-edge-end${pickerCellCls}-range-hover-edge-end-near-range::after,
|
&-in-view${pickerCellCls}-end${pickerCellCls}-range-hover-edge-end${pickerCellCls}-range-hover-edge-end-near-range::after,
|
||||||
&-in-view${pickerCellCls}-range-hover-edge-end:not(${pickerCellCls}-range-hover-edge-end-near-range)::after,
|
&-in-view${pickerCellCls}-range-hover-edge-end:not(${pickerCellCls}-range-hover-edge-end-near-range)::after,
|
||||||
&-in-view${pickerCellCls}-range-hover-end::after`]: {
|
&-in-view${pickerCellCls}-range-hover-end::after`]: {
|
||||||
insetInlineEnd: (cellWidth - cellHeight) / 2,
|
insetInlineEnd: token.calc(cellWidth).sub(cellHeight).div(2).equal(),
|
||||||
borderInlineEnd: `${lineWidth}px dashed ${cellRangeBorderColor}`,
|
borderInlineEnd: `${unit(lineWidth)} dashed ${cellRangeBorderColor}`,
|
||||||
borderStartEndRadius: borderRadiusSM,
|
borderStartEndRadius: borderRadiusSM,
|
||||||
borderEndEndRadius: borderRadiusSM,
|
borderEndEndRadius: borderRadiusSM,
|
||||||
},
|
},
|
||||||
@ -408,14 +411,27 @@ export const genPanelStyle = (token: SharedPickerToken): CSSObject => {
|
|||||||
controlItemBgActive,
|
controlItemBgActive,
|
||||||
marginXXS,
|
marginXXS,
|
||||||
pickerDatePanelPaddingHorizontal,
|
pickerDatePanelPaddingHorizontal,
|
||||||
|
pickerControlIconMargin,
|
||||||
} = token;
|
} = token;
|
||||||
|
|
||||||
const pickerPanelWidth = cellWidth * 7 + pickerDatePanelPaddingHorizontal * 2;
|
const pickerPanelWidth = token
|
||||||
const commonHoverCellFixedDistance =
|
.calc(cellWidth)
|
||||||
(pickerPanelWidth - paddingXS * 2) / 3 - pickerYearMonthCellWidth - paddingSM;
|
.mul(7)
|
||||||
|
.add(token.calc(pickerDatePanelPaddingHorizontal).mul(2))
|
||||||
const quarterHoverCellFixedDistance =
|
.equal();
|
||||||
(pickerPanelWidth - paddingXS * 2) / 4 - pickerYearMonthCellWidth;
|
const commonHoverCellFixedDistance = token
|
||||||
|
.calc(pickerPanelWidth)
|
||||||
|
.sub(token.calc(paddingXS).mul(2))
|
||||||
|
.div(3)
|
||||||
|
.sub(token.pickerYearMonthCellWidth)
|
||||||
|
.sub(paddingSM)
|
||||||
|
.equal();
|
||||||
|
const quarterHoverCellFixedDistance = token
|
||||||
|
.calc(pickerPanelWidth)
|
||||||
|
.sub(token.calc(paddingXS).mul(2))
|
||||||
|
.div(4)
|
||||||
|
.sub(token.pickerYearMonthCellWidth)
|
||||||
|
.equal();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
[componentCls]: {
|
[componentCls]: {
|
||||||
@ -424,7 +440,7 @@ export const genPanelStyle = (token: SharedPickerToken): CSSObject => {
|
|||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
background: colorBgContainer,
|
background: colorBgContainer,
|
||||||
border: `${lineWidth}px ${lineType} ${colorSplit}`,
|
border: `${unit(lineWidth)} ${lineType} ${colorSplit}`,
|
||||||
borderRadius: borderRadiusLG,
|
borderRadius: borderRadiusLG,
|
||||||
outline: 'none',
|
outline: 'none',
|
||||||
|
|
||||||
@ -465,9 +481,9 @@ export const genPanelStyle = (token: SharedPickerToken): CSSObject => {
|
|||||||
// ======================= Header =======================
|
// ======================= Header =======================
|
||||||
'&-header': {
|
'&-header': {
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
padding: `0 ${paddingXS}px`,
|
padding: `0 ${unit(paddingXS)}`,
|
||||||
color: colorTextHeading,
|
color: colorTextHeading,
|
||||||
borderBottom: `${lineWidth}px ${lineType} ${colorSplit}`,
|
borderBottom: `${unit(lineWidth)} ${lineType} ${colorSplit}`,
|
||||||
|
|
||||||
'> *': {
|
'> *': {
|
||||||
flex: 'none',
|
flex: 'none',
|
||||||
@ -476,7 +492,7 @@ export const genPanelStyle = (token: SharedPickerToken): CSSObject => {
|
|||||||
button: {
|
button: {
|
||||||
padding: 0,
|
padding: 0,
|
||||||
color: colorIcon,
|
color: colorIcon,
|
||||||
lineHeight: `${textHeight}px`,
|
lineHeight: unit(textHeight),
|
||||||
background: 'transparent',
|
background: 'transparent',
|
||||||
border: 0,
|
border: 0,
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
@ -496,7 +512,7 @@ export const genPanelStyle = (token: SharedPickerToken): CSSObject => {
|
|||||||
'&-view': {
|
'&-view': {
|
||||||
flex: 'auto',
|
flex: 'auto',
|
||||||
fontWeight: fontWeightStrong,
|
fontWeight: fontWeightStrong,
|
||||||
lineHeight: `${textHeight}px`,
|
lineHeight: unit(textHeight),
|
||||||
|
|
||||||
button: {
|
button: {
|
||||||
color: 'inherit',
|
color: 'inherit',
|
||||||
@ -543,8 +559,8 @@ export const genPanelStyle = (token: SharedPickerToken): CSSObject => {
|
|||||||
&-super-next-icon`]: {
|
&-super-next-icon`]: {
|
||||||
'&::after': {
|
'&::after': {
|
||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
top: Math.ceil(pickerControlIconSize / 2),
|
top: pickerControlIconMargin,
|
||||||
insetInlineStart: Math.ceil(pickerControlIconSize / 2),
|
insetInlineStart: pickerControlIconMargin,
|
||||||
display: 'inline-block',
|
display: 'inline-block',
|
||||||
width: pickerControlIconSize,
|
width: pickerControlIconSize,
|
||||||
height: pickerControlIconSize,
|
height: pickerControlIconSize,
|
||||||
@ -580,14 +596,14 @@ export const genPanelStyle = (token: SharedPickerToken): CSSObject => {
|
|||||||
},
|
},
|
||||||
|
|
||||||
th: {
|
th: {
|
||||||
height: cellHeight + pickerCellPaddingVertical * 2,
|
height: token.calc(cellHeight).add(token.calc(pickerCellPaddingVertical).mul(2)).equal(),
|
||||||
color: colorText,
|
color: colorText,
|
||||||
verticalAlign: 'middle',
|
verticalAlign: 'middle',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
'&-cell': {
|
'&-cell': {
|
||||||
padding: `${pickerCellPaddingVertical}px 0`,
|
padding: `${unit(pickerCellPaddingVertical)} 0`,
|
||||||
color: colorTextDisabled,
|
color: colorTextDisabled,
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
|
|
||||||
@ -617,14 +633,14 @@ export const genPanelStyle = (token: SharedPickerToken): CSSObject => {
|
|||||||
[`&-date-panel
|
[`&-date-panel
|
||||||
${componentCls}-cell-in-view${componentCls}-cell-in-range${componentCls}-cell-range-hover-start
|
${componentCls}-cell-in-view${componentCls}-cell-in-range${componentCls}-cell-range-hover-start
|
||||||
${pickerCellInnerCls}::after`]: {
|
${pickerCellInnerCls}::after`]: {
|
||||||
insetInlineEnd: -(cellWidth - cellHeight) / 2,
|
insetInlineEnd: token.calc(cellWidth).sub(cellHeight).mul(-1).div(2).equal(),
|
||||||
insetInlineStart: 0,
|
insetInlineStart: 0,
|
||||||
},
|
},
|
||||||
|
|
||||||
[`&-date-panel ${componentCls}-cell-in-view${componentCls}-cell-in-range${componentCls}-cell-range-hover-end ${pickerCellInnerCls}::after`]:
|
[`&-date-panel ${componentCls}-cell-in-view${componentCls}-cell-in-range${componentCls}-cell-range-hover-end ${pickerCellInnerCls}::after`]:
|
||||||
{
|
{
|
||||||
insetInlineEnd: 0,
|
insetInlineEnd: 0,
|
||||||
insetInlineStart: -(cellWidth - cellHeight) / 2,
|
insetInlineStart: token.calc(cellWidth).sub(cellHeight).mul(-1).div(2).equal(),
|
||||||
},
|
},
|
||||||
|
|
||||||
// Hover with range start & end
|
// Hover with range start & end
|
||||||
@ -637,11 +653,11 @@ export const genPanelStyle = (token: SharedPickerToken): CSSObject => {
|
|||||||
&-quarter-panel,
|
&-quarter-panel,
|
||||||
&-month-panel`]: {
|
&-month-panel`]: {
|
||||||
[`${componentCls}-content`]: {
|
[`${componentCls}-content`]: {
|
||||||
height: withoutTimeCellHeight * 4,
|
height: token.calc(withoutTimeCellHeight).mul(4).equal(),
|
||||||
},
|
},
|
||||||
|
|
||||||
[pickerCellInnerCls]: {
|
[pickerCellInnerCls]: {
|
||||||
padding: `0 ${paddingXS}px`,
|
padding: `0 ${unit(paddingXS)}`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -653,42 +669,42 @@ export const genPanelStyle = (token: SharedPickerToken): CSSObject => {
|
|||||||
// Quarter Panel Special Style
|
// Quarter Panel Special Style
|
||||||
[`${componentCls}-cell-range-hover-start::after`]: {
|
[`${componentCls}-cell-range-hover-start::after`]: {
|
||||||
insetInlineStart: quarterHoverCellFixedDistance,
|
insetInlineStart: quarterHoverCellFixedDistance,
|
||||||
borderInlineStart: `${lineWidth}px dashed ${cellRangeBorderColor}`,
|
borderInlineStart: `${unit(lineWidth)} dashed ${cellRangeBorderColor}`,
|
||||||
|
|
||||||
[`${componentCls}-panel-rtl &`]: {
|
[`${componentCls}-panel-rtl &`]: {
|
||||||
insetInlineEnd: quarterHoverCellFixedDistance,
|
insetInlineEnd: quarterHoverCellFixedDistance,
|
||||||
borderInlineEnd: `${lineWidth}px dashed ${cellRangeBorderColor}`,
|
borderInlineEnd: `${unit(lineWidth)} dashed ${cellRangeBorderColor}`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[`${componentCls}-cell-range-hover-end::after`]: {
|
[`${componentCls}-cell-range-hover-end::after`]: {
|
||||||
insetInlineEnd: quarterHoverCellFixedDistance,
|
insetInlineEnd: quarterHoverCellFixedDistance,
|
||||||
borderInlineEnd: `${lineWidth}px dashed ${cellRangeBorderColor}`,
|
borderInlineEnd: `${unit(lineWidth)} dashed ${cellRangeBorderColor}`,
|
||||||
|
|
||||||
[`${componentCls}-panel-rtl &`]: {
|
[`${componentCls}-panel-rtl &`]: {
|
||||||
insetInlineStart: quarterHoverCellFixedDistance,
|
insetInlineStart: quarterHoverCellFixedDistance,
|
||||||
borderInlineStart: `${lineWidth}px dashed ${cellRangeBorderColor}`,
|
borderInlineStart: `${unit(lineWidth)} dashed ${cellRangeBorderColor}`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
// ======================== Footer ========================
|
// ======================== Footer ========================
|
||||||
[`&-panel ${componentCls}-footer`]: {
|
[`&-panel ${componentCls}-footer`]: {
|
||||||
borderTop: `${lineWidth}px ${lineType} ${colorSplit}`,
|
borderTop: `${unit(lineWidth)} ${lineType} ${colorSplit}`,
|
||||||
},
|
},
|
||||||
|
|
||||||
'&-footer': {
|
'&-footer': {
|
||||||
width: 'min-content',
|
width: 'min-content',
|
||||||
minWidth: '100%',
|
minWidth: '100%',
|
||||||
lineHeight: `${textHeight - 2 * lineWidth}px`,
|
lineHeight: unit(token.calc(textHeight).sub(token.calc(lineWidth).mul(2)).equal()),
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
|
|
||||||
'&-extra': {
|
'&-extra': {
|
||||||
padding: `0 ${paddingSM}px`,
|
padding: `0 ${unit(paddingSM)}`,
|
||||||
lineHeight: `${textHeight - 2 * lineWidth}px`,
|
lineHeight: unit(token.calc(textHeight).sub(token.calc(lineWidth).mul(2)).equal()),
|
||||||
textAlign: 'start',
|
textAlign: 'start',
|
||||||
|
|
||||||
'&:not(:last-child)': {
|
'&:not(:last-child)': {
|
||||||
borderBottom: `${lineWidth}px ${lineType} ${colorSplit}`,
|
borderBottom: `${unit(lineWidth)} ${lineType} ${colorSplit}`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -721,7 +737,7 @@ export const genPanelStyle = (token: SharedPickerToken): CSSObject => {
|
|||||||
// ===================== Decade Panel =====================
|
// ===================== Decade Panel =====================
|
||||||
'&-decade-panel': {
|
'&-decade-panel': {
|
||||||
[pickerCellInnerCls]: {
|
[pickerCellInnerCls]: {
|
||||||
padding: `0 ${paddingXS / 2}px`,
|
padding: `0 ${unit(token.calc(paddingXS).div(2).equal())}`,
|
||||||
},
|
},
|
||||||
|
|
||||||
[`${componentCls}-cell::before`]: {
|
[`${componentCls}-cell::before`]: {
|
||||||
@ -734,7 +750,7 @@ export const genPanelStyle = (token: SharedPickerToken): CSSObject => {
|
|||||||
&-quarter-panel,
|
&-quarter-panel,
|
||||||
&-month-panel`]: {
|
&-month-panel`]: {
|
||||||
[`${componentCls}-body`]: {
|
[`${componentCls}-body`]: {
|
||||||
padding: `0 ${paddingXS}px`,
|
padding: `0 ${unit(paddingXS)}`,
|
||||||
},
|
},
|
||||||
|
|
||||||
[pickerCellInnerCls]: {
|
[pickerCellInnerCls]: {
|
||||||
@ -773,20 +789,20 @@ export const genPanelStyle = (token: SharedPickerToken): CSSObject => {
|
|||||||
&-month-panel`]: {
|
&-month-panel`]: {
|
||||||
[`${componentCls}-cell-range-hover-start::after`]: {
|
[`${componentCls}-cell-range-hover-start::after`]: {
|
||||||
insetInlineStart: commonHoverCellFixedDistance,
|
insetInlineStart: commonHoverCellFixedDistance,
|
||||||
borderInlineStart: `${lineWidth}px dashed ${cellRangeBorderColor}`,
|
borderInlineStart: `${unit(lineWidth)} dashed ${cellRangeBorderColor}`,
|
||||||
|
|
||||||
[`${componentCls}-panel-rtl &`]: {
|
[`${componentCls}-panel-rtl &`]: {
|
||||||
insetInlineEnd: commonHoverCellFixedDistance,
|
insetInlineEnd: commonHoverCellFixedDistance,
|
||||||
borderInlineEnd: `${lineWidth}px dashed ${cellRangeBorderColor}`,
|
borderInlineEnd: `${unit(lineWidth)} dashed ${cellRangeBorderColor}`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
[`${componentCls}-cell-range-hover-end::after`]: {
|
[`${componentCls}-cell-range-hover-end::after`]: {
|
||||||
insetInlineEnd: commonHoverCellFixedDistance,
|
insetInlineEnd: commonHoverCellFixedDistance,
|
||||||
borderInlineEnd: `${lineWidth}px dashed ${cellRangeBorderColor}`,
|
borderInlineEnd: `${unit(lineWidth)} dashed ${cellRangeBorderColor}`,
|
||||||
|
|
||||||
[`${componentCls}-panel-rtl &`]: {
|
[`${componentCls}-panel-rtl &`]: {
|
||||||
insetInlineStart: commonHoverCellFixedDistance,
|
insetInlineStart: commonHoverCellFixedDistance,
|
||||||
borderInlineStart: `${lineWidth}px dashed ${cellRangeBorderColor}`,
|
borderInlineStart: `${unit(lineWidth)} dashed ${cellRangeBorderColor}`,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -794,7 +810,7 @@ export const genPanelStyle = (token: SharedPickerToken): CSSObject => {
|
|||||||
// ====================== Week Panel ======================
|
// ====================== Week Panel ======================
|
||||||
'&-week-panel': {
|
'&-week-panel': {
|
||||||
[`${componentCls}-body`]: {
|
[`${componentCls}-body`]: {
|
||||||
padding: `${paddingXS}px ${paddingSM}px`,
|
padding: `${unit(paddingXS)} ${unit(paddingSM)}`,
|
||||||
},
|
},
|
||||||
|
|
||||||
// Clear cell style
|
// Clear cell style
|
||||||
@ -857,11 +873,11 @@ export const genPanelStyle = (token: SharedPickerToken): CSSObject => {
|
|||||||
// ====================== Date Panel ======================
|
// ====================== Date Panel ======================
|
||||||
'&-date-panel': {
|
'&-date-panel': {
|
||||||
[`${componentCls}-body`]: {
|
[`${componentCls}-body`]: {
|
||||||
padding: `${paddingXS}px ${pickerDatePanelPaddingHorizontal}px`,
|
padding: `${unit(paddingXS)} ${unit(pickerDatePanelPaddingHorizontal)}`,
|
||||||
},
|
},
|
||||||
|
|
||||||
[`${componentCls}-content`]: {
|
[`${componentCls}-content`]: {
|
||||||
width: cellWidth * 7,
|
width: token.calc(cellWidth).mul(7).equal(),
|
||||||
|
|
||||||
th: {
|
th: {
|
||||||
width: cellWidth,
|
width: cellWidth,
|
||||||
@ -876,7 +892,7 @@ export const genPanelStyle = (token: SharedPickerToken): CSSObject => {
|
|||||||
display: 'flex',
|
display: 'flex',
|
||||||
|
|
||||||
[`${componentCls}-time-panel`]: {
|
[`${componentCls}-time-panel`]: {
|
||||||
borderInlineStart: `${lineWidth}px ${lineType} ${colorSplit}`,
|
borderInlineStart: `${unit(lineWidth)} ${lineType} ${colorSplit}`,
|
||||||
},
|
},
|
||||||
|
|
||||||
[`${componentCls}-date-panel,
|
[`${componentCls}-date-panel,
|
||||||
@ -912,7 +928,7 @@ export const genPanelStyle = (token: SharedPickerToken): CSSObject => {
|
|||||||
'&-column': {
|
'&-column': {
|
||||||
flex: '1 0 auto',
|
flex: '1 0 auto',
|
||||||
width: timeColumnWidth,
|
width: timeColumnWidth,
|
||||||
margin: `${paddingXXS}px 0`,
|
margin: `${unit(paddingXXS)} 0`,
|
||||||
padding: 0,
|
padding: 0,
|
||||||
overflowY: 'hidden',
|
overflowY: 'hidden',
|
||||||
textAlign: 'start',
|
textAlign: 'start',
|
||||||
@ -938,12 +954,12 @@ export const genPanelStyle = (token: SharedPickerToken): CSSObject => {
|
|||||||
|
|
||||||
'&::after': {
|
'&::after': {
|
||||||
display: 'block',
|
display: 'block',
|
||||||
height: timeColumnHeight - timeCellHeight,
|
height: token.calc(timeColumnHeight).sub(timeCellHeight).equal(),
|
||||||
content: '""',
|
content: '""',
|
||||||
},
|
},
|
||||||
|
|
||||||
'&:not(:first-child)': {
|
'&:not(:first-child)': {
|
||||||
borderInlineStart: `${lineWidth}px ${lineType} ${colorSplit}`,
|
borderInlineStart: `${unit(lineWidth)} ${lineType} ${colorSplit}`,
|
||||||
},
|
},
|
||||||
|
|
||||||
'&-active': {
|
'&-active': {
|
||||||
@ -962,14 +978,14 @@ export const genPanelStyle = (token: SharedPickerToken): CSSObject => {
|
|||||||
marginInline: marginXXS,
|
marginInline: marginXXS,
|
||||||
[`${componentCls}-time-panel-cell-inner`]: {
|
[`${componentCls}-time-panel-cell-inner`]: {
|
||||||
display: 'block',
|
display: 'block',
|
||||||
width: timeColumnWidth - 2 * marginXXS,
|
width: token.calc(timeColumnWidth).sub(token.calc(marginXXS).mul(2)).equal(),
|
||||||
height: timeCellHeight,
|
height: timeCellHeight,
|
||||||
margin: 0,
|
margin: 0,
|
||||||
paddingBlock: 0,
|
paddingBlock: 0,
|
||||||
paddingInlineEnd: 0,
|
paddingInlineEnd: 0,
|
||||||
paddingInlineStart: (timeColumnWidth - timeCellHeight) / 2,
|
paddingInlineStart: token.calc(timeColumnWidth).sub(timeCellHeight).div(2).equal(),
|
||||||
color: colorText,
|
color: colorText,
|
||||||
lineHeight: `${timeCellHeight}px`,
|
lineHeight: unit(timeCellHeight),
|
||||||
borderRadius: borderRadiusSM,
|
borderRadius: borderRadiusSM,
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
transition: `background ${motionDurationMid}`,
|
transition: `background ${motionDurationMid}`,
|
||||||
@ -998,7 +1014,11 @@ export const genPanelStyle = (token: SharedPickerToken): CSSObject => {
|
|||||||
},
|
},
|
||||||
// https://github.com/ant-design/ant-design/issues/39227
|
// https://github.com/ant-design/ant-design/issues/39227
|
||||||
[`&-datetime-panel ${componentCls}-time-panel-column:after`]: {
|
[`&-datetime-panel ${componentCls}-time-panel-column:after`]: {
|
||||||
height: timeColumnHeight - timeCellHeight + paddingXXS * 2,
|
height: token
|
||||||
|
.calc(timeColumnHeight)
|
||||||
|
.sub(timeCellHeight)
|
||||||
|
.add(token.calc(paddingXXS).mul(2))
|
||||||
|
.equal(),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@ -1070,7 +1090,6 @@ const genPickerStyle: GenerateStyle<PickerToken> = (token) => {
|
|||||||
componentCls,
|
componentCls,
|
||||||
antCls,
|
antCls,
|
||||||
controlHeight,
|
controlHeight,
|
||||||
fontSize,
|
|
||||||
paddingInline,
|
paddingInline,
|
||||||
colorBgContainer,
|
colorBgContainer,
|
||||||
lineWidth,
|
lineWidth,
|
||||||
@ -1089,7 +1108,6 @@ const genPickerStyle: GenerateStyle<PickerToken> = (token) => {
|
|||||||
marginXS,
|
marginXS,
|
||||||
colorTextDescription,
|
colorTextDescription,
|
||||||
lineWidthBold,
|
lineWidthBold,
|
||||||
lineHeight,
|
|
||||||
colorPrimary,
|
colorPrimary,
|
||||||
motionDurationSlow,
|
motionDurationSlow,
|
||||||
zIndexPopup,
|
zIndexPopup,
|
||||||
@ -1099,8 +1117,6 @@ const genPickerStyle: GenerateStyle<PickerToken> = (token) => {
|
|||||||
cellActiveWithRangeBg,
|
cellActiveWithRangeBg,
|
||||||
colorPrimaryBorder,
|
colorPrimaryBorder,
|
||||||
sizePopupArrow,
|
sizePopupArrow,
|
||||||
borderRadiusXS,
|
|
||||||
borderRadiusOuter,
|
|
||||||
colorBgElevated,
|
colorBgElevated,
|
||||||
borderRadiusLG,
|
borderRadiusLG,
|
||||||
boxShadowSecondary,
|
boxShadowSecondary,
|
||||||
@ -1111,19 +1127,22 @@ const genPickerStyle: GenerateStyle<PickerToken> = (token) => {
|
|||||||
presetsMaxWidth,
|
presetsMaxWidth,
|
||||||
boxShadowPopoverArrow,
|
boxShadowPopoverArrow,
|
||||||
colorTextQuaternary,
|
colorTextQuaternary,
|
||||||
|
fontHeight,
|
||||||
|
fontHeightLG,
|
||||||
|
lineHeightLG,
|
||||||
} = token;
|
} = token;
|
||||||
|
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
[componentCls]: {
|
[componentCls]: {
|
||||||
...resetComponent(token),
|
...resetComponent(token),
|
||||||
...genPikerPadding(token, controlHeight, fontSize, paddingInline),
|
...genPikerPadding(token, controlHeight, fontHeight, paddingInline),
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
display: 'inline-flex',
|
display: 'inline-flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
background: colorBgContainer,
|
background: colorBgContainer,
|
||||||
lineHeight: 1,
|
lineHeight: 1,
|
||||||
border: `${lineWidth}px ${lineType} ${colorBorder}`,
|
border: `${unit(lineWidth)} ${lineType} ${colorBorder}`,
|
||||||
borderRadius,
|
borderRadius,
|
||||||
transition: `border ${motionDurationMid}, box-shadow ${motionDurationMid}`,
|
transition: `border ${motionDurationMid}, box-shadow ${motionDurationMid}`,
|
||||||
|
|
||||||
@ -1196,22 +1215,23 @@ const genPickerStyle: GenerateStyle<PickerToken> = (token) => {
|
|||||||
|
|
||||||
// Size
|
// Size
|
||||||
'&-large': {
|
'&-large': {
|
||||||
...genPikerPadding(token, controlHeightLG, fontSizeLG, paddingInline),
|
...genPikerPadding(token, controlHeightLG, fontHeightLG, paddingInline),
|
||||||
|
|
||||||
[`${componentCls}-input > input`]: {
|
[`${componentCls}-input > input`]: {
|
||||||
fontSize: fontSizeLG,
|
fontSize: fontSizeLG,
|
||||||
|
lineHeight: lineHeightLG,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
'&-small': {
|
'&-small': {
|
||||||
...genPikerPadding(token, controlHeightSM, fontSize, paddingInlineSM),
|
...genPikerPadding(token, controlHeightSM, fontHeight, paddingInlineSM),
|
||||||
},
|
},
|
||||||
|
|
||||||
[`${componentCls}-suffix`]: {
|
[`${componentCls}-suffix`]: {
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flex: 'none',
|
flex: 'none',
|
||||||
alignSelf: 'center',
|
alignSelf: 'center',
|
||||||
marginInlineStart: paddingXS / 2,
|
marginInlineStart: token.calc(paddingXS).div(2).equal(),
|
||||||
color: colorTextDisabled,
|
color: colorTextDisabled,
|
||||||
lineHeight: 1,
|
lineHeight: 1,
|
||||||
pointerEvents: 'none',
|
pointerEvents: 'none',
|
||||||
@ -1285,7 +1305,7 @@ const genPickerStyle: GenerateStyle<PickerToken> = (token) => {
|
|||||||
|
|
||||||
// Active bar
|
// Active bar
|
||||||
[`${componentCls}-active-bar`]: {
|
[`${componentCls}-active-bar`]: {
|
||||||
bottom: -lineWidth,
|
bottom: token.calc(lineWidth).mul(-1).equal(),
|
||||||
height: lineWidthBold,
|
height: lineWidthBold,
|
||||||
marginInlineStart: paddingInline,
|
marginInlineStart: paddingInline,
|
||||||
background: colorPrimary,
|
background: colorPrimary,
|
||||||
@ -1302,7 +1322,7 @@ const genPickerStyle: GenerateStyle<PickerToken> = (token) => {
|
|||||||
|
|
||||||
[`${componentCls}-range-separator`]: {
|
[`${componentCls}-range-separator`]: {
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
padding: `0 ${paddingXS}px`,
|
padding: `0 ${unit(paddingXS)}`,
|
||||||
lineHeight: 1,
|
lineHeight: 1,
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -1387,9 +1407,15 @@ const genPickerStyle: GenerateStyle<PickerToken> = (token) => {
|
|||||||
// ======================== Ranges ========================
|
// ======================== Ranges ========================
|
||||||
[`${componentCls}-ranges`]: {
|
[`${componentCls}-ranges`]: {
|
||||||
marginBottom: 0,
|
marginBottom: 0,
|
||||||
padding: `${paddingXXS}px ${paddingSM}px`,
|
padding: `${unit(paddingXXS)} ${unit(paddingSM)}`,
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
lineHeight: `${textHeight - 2 * lineWidth - paddingXS / 2}px`,
|
lineHeight: unit(
|
||||||
|
token
|
||||||
|
.calc(textHeight)
|
||||||
|
.sub(token.calc(lineWidth).mul(2))
|
||||||
|
.sub(token.calc(paddingXS).div(2))
|
||||||
|
.equal(),
|
||||||
|
),
|
||||||
textAlign: 'start',
|
textAlign: 'start',
|
||||||
listStyle: 'none',
|
listStyle: 'none',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
@ -1421,15 +1447,9 @@ const genPickerStyle: GenerateStyle<PickerToken> = (token) => {
|
|||||||
position: 'absolute',
|
position: 'absolute',
|
||||||
zIndex: 1,
|
zIndex: 1,
|
||||||
display: 'none',
|
display: 'none',
|
||||||
marginInlineStart: paddingInline * 1.5,
|
marginInlineStart: token.calc(paddingInline).mul(1.5).equal(),
|
||||||
transition: `left ${motionDurationSlow} ease-out`,
|
transition: `left ${motionDurationSlow} ease-out`,
|
||||||
...roundedArrow(
|
...genRoundedArrow(token, colorBgElevated, boxShadowPopoverArrow),
|
||||||
sizePopupArrow,
|
|
||||||
borderRadiusXS,
|
|
||||||
borderRadiusOuter,
|
|
||||||
colorBgElevated,
|
|
||||||
boxShadowPopoverArrow,
|
|
||||||
),
|
|
||||||
},
|
},
|
||||||
|
|
||||||
[`${componentCls}-panel-container`]: {
|
[`${componentCls}-panel-container`]: {
|
||||||
@ -1461,13 +1481,13 @@ const genPickerStyle: GenerateStyle<PickerToken> = (token) => {
|
|||||||
overflow: 'auto',
|
overflow: 'auto',
|
||||||
margin: 0,
|
margin: 0,
|
||||||
padding: paddingXS,
|
padding: paddingXS,
|
||||||
borderInlineEnd: `${lineWidth}px ${lineType} ${colorSplit}`,
|
borderInlineEnd: `${unit(lineWidth)} ${lineType} ${colorSplit}`,
|
||||||
|
|
||||||
li: {
|
li: {
|
||||||
...textEllipsis,
|
...textEllipsis,
|
||||||
borderRadius: borderRadiusSM,
|
borderRadius: borderRadiusSM,
|
||||||
paddingInline: paddingXS,
|
paddingInline: paddingXS,
|
||||||
paddingBlock: (controlHeightSM - Math.round(fontSize * lineHeight)) / 2,
|
paddingBlock: token.calc(controlHeightSM).sub(fontHeight).div(2).equal(),
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
transition: `all ${motionDurationSlow}`,
|
transition: `all ${motionDurationSlow}`,
|
||||||
|
|
||||||
@ -1489,7 +1509,7 @@ const genPickerStyle: GenerateStyle<PickerToken> = (token) => {
|
|||||||
direction: 'ltr',
|
direction: 'ltr',
|
||||||
|
|
||||||
[`${componentCls}-panel`]: {
|
[`${componentCls}-panel`]: {
|
||||||
borderWidth: `0 0 ${lineWidth}px`,
|
borderWidth: `0 0 ${unit(lineWidth)}`,
|
||||||
},
|
},
|
||||||
|
|
||||||
'&:last-child': {
|
'&:last-child': {
|
||||||
@ -1518,7 +1538,7 @@ const genPickerStyle: GenerateStyle<PickerToken> = (token) => {
|
|||||||
},
|
},
|
||||||
|
|
||||||
'&-dropdown-range': {
|
'&-dropdown-range': {
|
||||||
padding: `${(sizePopupArrow * 2) / 3}px 0`,
|
padding: `${unit(token.calc(sizePopupArrow).mul(2).div(3).equal())} 0`,
|
||||||
|
|
||||||
'&-hidden': {
|
'&-hidden': {
|
||||||
display: 'none',
|
display: 'none',
|
||||||
@ -1555,13 +1575,17 @@ export const initPickerPanelToken = (token: TokenWithCommonCls<GlobalToken>): Pi
|
|||||||
return {
|
return {
|
||||||
pickerCellCls: `${componentCls}-cell`,
|
pickerCellCls: `${componentCls}-cell`,
|
||||||
pickerCellInnerCls: `${componentCls}-cell-inner`,
|
pickerCellInnerCls: `${componentCls}-cell-inner`,
|
||||||
pickerYearMonthCellWidth: controlHeightLG * 1.5,
|
pickerYearMonthCellWidth: token.calc(controlHeightLG).mul(1.5).equal(),
|
||||||
pickerQuarterPanelContentHeight: controlHeightLG * 1.4,
|
pickerQuarterPanelContentHeight: token.calc(controlHeightLG).mul(1.4).equal(),
|
||||||
pickerCellPaddingVertical: paddingXXS + paddingXXS / 2,
|
pickerCellPaddingVertical: token.calc(paddingXXS).add(token.calc(paddingXXS).div(2)).equal(),
|
||||||
pickerCellBorderGap: 2, // Magic for gap between cells
|
pickerCellBorderGap: 2, // Magic for gap between cells
|
||||||
pickerControlIconSize: 7,
|
pickerControlIconSize: 7,
|
||||||
|
pickerControlIconMargin: 4,
|
||||||
pickerControlIconBorderWidth: 1.5,
|
pickerControlIconBorderWidth: 1.5,
|
||||||
pickerDatePanelPaddingHorizontal: padding + paddingXXS / 2, // 18 in normal
|
pickerDatePanelPaddingHorizontal: token
|
||||||
|
.calc(padding)
|
||||||
|
.add(token.calc(paddingXXS).div(2))
|
||||||
|
.equal(), // 18 in normal
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1580,6 +1604,15 @@ export const initPanelComponentToken = (token: GlobalToken): PanelComponentToken
|
|||||||
withoutTimeCellHeight: token.controlHeightLG * 1.65,
|
withoutTimeCellHeight: token.controlHeightLG * 1.65,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const prepareComponentToken: GetDefaultToken<'DatePicker'> = (token) => ({
|
||||||
|
...initComponentToken(token),
|
||||||
|
...initPanelComponentToken(token),
|
||||||
|
...getArrowToken(token),
|
||||||
|
presetsWidth: 120,
|
||||||
|
presetsMaxWidth: 200,
|
||||||
|
zIndexPopup: token.zIndexPopupBase + 50,
|
||||||
|
});
|
||||||
|
|
||||||
// ============================== Export ==============================
|
// ============================== Export ==============================
|
||||||
export default genComponentStyleHook(
|
export default genComponentStyleHook(
|
||||||
'DatePicker',
|
'DatePicker',
|
||||||
@ -1596,11 +1629,5 @@ export default genComponentStyleHook(
|
|||||||
}),
|
}),
|
||||||
];
|
];
|
||||||
},
|
},
|
||||||
(token) => ({
|
prepareComponentToken,
|
||||||
...initComponentToken(token),
|
|
||||||
...initPanelComponentToken(token),
|
|
||||||
presetsWidth: 120,
|
|
||||||
presetsMaxWidth: 200,
|
|
||||||
zIndexPopup: token.zIndexPopupBase + 50,
|
|
||||||
}),
|
|
||||||
);
|
);
|
||||||
|
@ -3,7 +3,6 @@ import type { CSSObject } from '@ant-design/cssinjs';
|
|||||||
import type { AliasToken, DerivativeToken } from '../theme/internal';
|
import type { AliasToken, DerivativeToken } from '../theme/internal';
|
||||||
|
|
||||||
export { operationUnit } from './operationUnit';
|
export { operationUnit } from './operationUnit';
|
||||||
export { roundedArrow } from './roundedArrow';
|
|
||||||
|
|
||||||
export const textEllipsis: CSSObject = {
|
export const textEllipsis: CSSObject = {
|
||||||
overflow: 'hidden',
|
overflow: 'hidden',
|
||||||
|
@ -46,76 +46,6 @@ export function getArrowToken(token: AliasToken): ArrowToken {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
export const roundedArrow = (
|
|
||||||
width: number,
|
|
||||||
innerRadius: number,
|
|
||||||
outerRadius: number,
|
|
||||||
bgColor: string,
|
|
||||||
boxShadow: string,
|
|
||||||
): CSSObject => {
|
|
||||||
const unitWidth = width / 2;
|
|
||||||
|
|
||||||
const ax = 0;
|
|
||||||
const ay = unitWidth;
|
|
||||||
const bx = (outerRadius * 1) / Math.sqrt(2);
|
|
||||||
const by = unitWidth - outerRadius * (1 - 1 / Math.sqrt(2));
|
|
||||||
const cx = unitWidth - innerRadius * (1 / Math.sqrt(2));
|
|
||||||
const cy = outerRadius * (Math.sqrt(2) - 1) + innerRadius * (1 / Math.sqrt(2));
|
|
||||||
const dx = 2 * unitWidth - cx;
|
|
||||||
const dy = cy;
|
|
||||||
const ex = 2 * unitWidth - bx;
|
|
||||||
const ey = by;
|
|
||||||
const fx = 2 * unitWidth - ax;
|
|
||||||
const fy = ay;
|
|
||||||
|
|
||||||
const shadowWidth = unitWidth * Math.sqrt(2) + outerRadius * (Math.sqrt(2) - 2);
|
|
||||||
const polygonOffset = outerRadius * (Math.sqrt(2) - 1);
|
|
||||||
|
|
||||||
return {
|
|
||||||
pointerEvents: 'none',
|
|
||||||
width,
|
|
||||||
height: width,
|
|
||||||
overflow: 'hidden',
|
|
||||||
|
|
||||||
'&::before': {
|
|
||||||
position: 'absolute',
|
|
||||||
bottom: 0,
|
|
||||||
insetInlineStart: 0,
|
|
||||||
width,
|
|
||||||
height: width / 2,
|
|
||||||
background: bgColor,
|
|
||||||
clipPath: {
|
|
||||||
_multi_value_: true,
|
|
||||||
value: [
|
|
||||||
`polygon(${polygonOffset}px 100%, 50% ${polygonOffset}px, ${
|
|
||||||
2 * unitWidth - polygonOffset
|
|
||||||
}px 100%, ${polygonOffset}px 100%)`,
|
|
||||||
`path('M ${ax} ${ay} A ${outerRadius} ${outerRadius} 0 0 0 ${bx} ${by} L ${cx} ${cy} A ${innerRadius} ${innerRadius} 0 0 1 ${dx} ${dy} L ${ex} ${ey} A ${outerRadius} ${outerRadius} 0 0 0 ${fx} ${fy} Z')`,
|
|
||||||
],
|
|
||||||
},
|
|
||||||
content: '""',
|
|
||||||
},
|
|
||||||
|
|
||||||
'&::after': {
|
|
||||||
content: '""',
|
|
||||||
position: 'absolute',
|
|
||||||
width: shadowWidth,
|
|
||||||
height: shadowWidth,
|
|
||||||
bottom: 0,
|
|
||||||
insetInline: 0,
|
|
||||||
margin: 'auto',
|
|
||||||
borderRadius: {
|
|
||||||
_skip_check_: true,
|
|
||||||
value: `0 0 ${innerRadius}px 0`,
|
|
||||||
},
|
|
||||||
transform: 'translateY(50%) rotate(-135deg)',
|
|
||||||
boxShadow,
|
|
||||||
zIndex: 0,
|
|
||||||
background: 'transparent',
|
|
||||||
},
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
export const genRoundedArrow = <T extends AliasToken & ArrowToken & CSSUtil>(
|
export const genRoundedArrow = <T extends AliasToken & ArrowToken & CSSUtil>(
|
||||||
token: T,
|
token: T,
|
||||||
bgColor: string,
|
bgColor: string,
|
||||||
|
@ -79,6 +79,23 @@ export interface FontMapToken {
|
|||||||
*/
|
*/
|
||||||
lineHeightSM: number;
|
lineHeightSM: number;
|
||||||
|
|
||||||
|
// TextHeight
|
||||||
|
/**
|
||||||
|
* Round of fontSize * lineHeight
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
fontHeight: number;
|
||||||
|
/**
|
||||||
|
* Round of fontSizeSM * lineHeightSM
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
fontHeightSM: number;
|
||||||
|
/**
|
||||||
|
* Round of fontSizeLG * lineHeightLG
|
||||||
|
* @internal
|
||||||
|
*/
|
||||||
|
fontHeightLG: number;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @nameZH 一级标题行高
|
* @nameZH 一级标题行高
|
||||||
* @nameEN Line height of heading level 1
|
* @nameEN Line height of heading level 1
|
||||||
|
@ -6,10 +6,17 @@ const genFontMapToken = (fontSize: number): FontMapToken => {
|
|||||||
const fontSizes = fontSizePairs.map((pair) => pair.size);
|
const fontSizes = fontSizePairs.map((pair) => pair.size);
|
||||||
const lineHeights = fontSizePairs.map((pair) => pair.lineHeight);
|
const lineHeights = fontSizePairs.map((pair) => pair.lineHeight);
|
||||||
|
|
||||||
|
const fontSizeMD = fontSizes[1];
|
||||||
|
const fontSizeSM = fontSizes[0];
|
||||||
|
const fontSizeLG = fontSizes[2];
|
||||||
|
const lineHeight = lineHeights[1];
|
||||||
|
const lineHeightSM = lineHeights[0];
|
||||||
|
const lineHeightLG = lineHeights[2];
|
||||||
|
|
||||||
return {
|
return {
|
||||||
fontSizeSM: fontSizes[0],
|
fontSizeSM,
|
||||||
fontSize: fontSizes[1],
|
fontSize: fontSizeMD,
|
||||||
fontSizeLG: fontSizes[2],
|
fontSizeLG,
|
||||||
fontSizeXL: fontSizes[3],
|
fontSizeXL: fontSizes[3],
|
||||||
|
|
||||||
fontSizeHeading1: fontSizes[6],
|
fontSizeHeading1: fontSizes[6],
|
||||||
@ -18,9 +25,13 @@ const genFontMapToken = (fontSize: number): FontMapToken => {
|
|||||||
fontSizeHeading4: fontSizes[3],
|
fontSizeHeading4: fontSizes[3],
|
||||||
fontSizeHeading5: fontSizes[2],
|
fontSizeHeading5: fontSizes[2],
|
||||||
|
|
||||||
lineHeight: lineHeights[1],
|
lineHeight,
|
||||||
lineHeightLG: lineHeights[2],
|
lineHeightLG,
|
||||||
lineHeightSM: lineHeights[0],
|
lineHeightSM,
|
||||||
|
|
||||||
|
fontHeight: Math.round(lineHeight * fontSizeMD),
|
||||||
|
fontHeightLG: Math.round(lineHeightLG * fontSizeLG),
|
||||||
|
fontHeightSM: Math.round(lineHeightSM * fontSizeSM),
|
||||||
|
|
||||||
lineHeightHeading1: lineHeights[6],
|
lineHeightHeading1: lineHeights[6],
|
||||||
lineHeightHeading2: lineHeights[5],
|
lineHeightHeading2: lineHeights[5],
|
||||||
|
Loading…
Reference in New Issue
Block a user