@@ -15,34 +15,30 @@ import {
1515 useElement ,
1616 useUpdatePosition ,
1717} from '../../hooks' ;
18- import { ClockCircleOutlined , CloseCircleFilled , SwapRightOutlined } from '../../icons' ;
18+ import { CloseCircleFilled , SwapRightOutlined } from '../../icons' ;
1919import { getClassName , getNoTransformSize , getVerticalSidePosition } from '../../utils' ;
2020import { ICON_SIZE } from '../../utils/global' ;
2121import { DBaseDesign } from '../_base-design' ;
2222import { DBaseInput } from '../_base-input' ;
2323import { DTransition } from '../_transition' ;
2424
25- export type DExtendsTimeInputProps = Pick <
26- DTimeInputProps ,
27- 'dFormControl' | 'dPlacement' | 'dSize' | 'dRange' | 'dClearable' | 'dDisabled' | 'onClear' | 'onVisibleChange'
28- > ;
29-
30- export interface DTimeInputRef {
25+ export interface DDateInputRef {
3126 updatePosition : ( ) => void ;
3227}
3328
34- export interface DTimeInputRenderProps {
35- tiStyle : React . CSSProperties ;
36- 'data-time -input-popupid' : string ;
37- tiOnMouseDown : React . MouseEventHandler ;
38- tiOnMouseUp : React . MouseEventHandler ;
29+ export interface DDateInputRenderProps {
30+ diStyle : React . CSSProperties ;
31+ 'data-date -input-popupid' : string ;
32+ diOnMouseDown : React . MouseEventHandler ;
33+ diOnMouseUp : React . MouseEventHandler ;
3934}
4035
41- export interface DTimeInputProps extends Omit < React . HTMLAttributes < HTMLDivElement > , 'children' > {
42- children : ( props : DTimeInputRenderProps ) => JSX . Element | null ;
36+ export interface DDateInputProps extends Omit < React . HTMLAttributes < HTMLDivElement > , 'children' > {
37+ children : ( props : DDateInputRenderProps ) => JSX . Element | null ;
4338 dFormControl ?: DFormControl ;
4439 dVisible ?: boolean ;
4540 dPlacement ?: 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right' ;
41+ dSuffix ?: React . ReactNode ;
4642 dSize ?: DSize ;
4743 dRange ?: boolean ;
4844 dClearable ?: boolean ;
@@ -54,16 +50,17 @@ export interface DTimeInputProps extends Omit<React.HTMLAttributes<HTMLDivElemen
5450}
5551
5652const TTANSITION_DURING = 116 ;
57- function TimeInput ( props : DTimeInputProps , ref : React . ForwardedRef < DTimeInputRef > ) {
53+ function DateInput ( props : DDateInputProps , ref : React . ForwardedRef < DDateInputRef > ) {
5854 const {
5955 children,
6056 dFormControl,
61- dVisible = false ,
57+ dVisible,
58+ dSuffix,
6259 dPlacement = 'bottom-left' ,
6360 dSize,
64- dRange = false ,
65- dClearable = false ,
66- dDisabled = false ,
61+ dRange,
62+ dClearable,
63+ dDisabled,
6764 dInputProps,
6865 dInputRef,
6966 onVisibleChange,
@@ -117,10 +114,10 @@ function TimeInput(props: DTimeInputProps, ref: React.ForwardedRef<DTimeInputRef
117114 const clearable = dClearable && ! dVisible && ! dDisabled ;
118115
119116 const containerEl = useElement ( ( ) => {
120- let el = document . getElementById ( `${ dPrefix } time -input-root` ) ;
117+ let el = document . getElementById ( `${ dPrefix } date -input-root` ) ;
121118 if ( ! el ) {
122119 el = document . createElement ( 'div' ) ;
123- el . id = `${ dPrefix } time -input-root` ;
120+ el . id = `${ dPrefix } date -input-root` ;
124121 document . body . appendChild ( el ) ;
125122 }
126123 return el ;
@@ -134,7 +131,7 @@ function TimeInput(props: DTimeInputProps, ref: React.ForwardedRef<DTimeInputRef
134131 } ) ;
135132 const [ transformOrigin , setTransformOrigin ] = useState < string > ( ) ;
136133 const updatePosition = useEventCallback ( ( ) => {
137- const popupEl = document . querySelector ( `[data-time -input-popupid="${ uniqueId } "]` ) as HTMLElement | null ;
134+ const popupEl = document . querySelector ( `[data-date -input-popupid="${ uniqueId } "]` ) as HTMLElement | null ;
138135 if ( boxRef . current && popupEl ) {
139136 const { width, height } = getNoTransformSize ( popupEl ) ;
140137 const { top, left, transformOrigin } = getVerticalSidePosition ( boxRef . current , { width, height } , dPlacement , 8 ) ;
@@ -155,7 +152,7 @@ function TimeInput(props: DTimeInputProps, ref: React.ForwardedRef<DTimeInputRef
155152 } ) ;
156153 }
157154
158- const popupEl = document . querySelector ( `[data-time -input-popupid="${ uniqueId } "]` ) as HTMLElement | null ;
155+ const popupEl = document . querySelector ( `[data-date -input-popupid="${ uniqueId } "]` ) as HTMLElement | null ;
159156 if ( popupEl ) {
160157 asyncGroup . onResize ( popupEl , ( ) => {
161158 updatePosition ( ) ;
@@ -221,7 +218,7 @@ function TimeInput(props: DTimeInputProps, ref: React.ForwardedRef<DTimeInputRef
221218 < DBaseInput
222219 { ...inputProps }
223220 ref = { isLeft ? combineInputRefLeft : combineInputRefRight }
224- className = { getClassName ( inputProps ?. className , `${ dPrefix } time -input__input` ) }
221+ className = { getClassName ( inputProps ?. className , `${ dPrefix } date -input__input` ) }
225222 type = "text"
226223 autoComplete = "off"
227224 disabled = { dDisabled }
@@ -271,8 +268,8 @@ function TimeInput(props: DTimeInputProps, ref: React.ForwardedRef<DTimeInputRef
271268 < div
272269 { ...restProps }
273270 ref = { boxRef }
274- className = { getClassName ( className , `${ dPrefix } time -input` , {
275- [ `${ dPrefix } time -input--${ dSize } ` ] : dSize ,
271+ className = { getClassName ( className , `${ dPrefix } date -input` , {
272+ [ `${ dPrefix } date -input--${ dSize } ` ] : dSize ,
276273 'is-disabled' : dDisabled ,
277274 'is-focus' : isFocus ,
278275 } ) }
@@ -298,14 +295,14 @@ function TimeInput(props: DTimeInputProps, ref: React.ForwardedRef<DTimeInputRef
298295 { getInputNode ( true ) }
299296 { dRange && (
300297 < >
301- < div ref = { indicatorRef } className = { `${ dPrefix } time -input__indicator` } > </ div >
302- < SwapRightOutlined className = { `${ dPrefix } time -input__separator` } />
298+ < div ref = { indicatorRef } className = { `${ dPrefix } date -input__indicator` } > </ div >
299+ < SwapRightOutlined className = { `${ dPrefix } date -input__separator` } />
303300 { getInputNode ( false ) }
304301 </ >
305302 ) }
306303 { clearable && (
307304 < button
308- className = { getClassName ( `${ dPrefix } icon-button` , `${ dPrefix } time -input__clear` ) }
305+ className = { getClassName ( `${ dPrefix } icon-button` , `${ dPrefix } date -input__clear` ) }
309306 style = { { width : iconSize , height : iconSize } }
310307 aria-label = { t ( 'Common' , 'Clear' ) }
311308 onClick = { ( e ) => {
@@ -317,7 +314,11 @@ function TimeInput(props: DTimeInputProps, ref: React.ForwardedRef<DTimeInputRef
317314 < CloseCircleFilled dSize = { iconSize } />
318315 </ button >
319316 ) }
320- < ClockCircleOutlined className = { `${ dPrefix } time-input__icon` } style = { { opacity : clearable ? 0 : 1 } } dSize = { iconSize } />
317+ { dSuffix && (
318+ < div className = { `${ dPrefix } date-input__icon` } style = { { opacity : clearable ? 0 : 1 , fontSize : iconSize } } >
319+ { dSuffix }
320+ </ div >
321+ ) }
321322 </ div >
322323 </ DBaseDesign >
323324 { containerEl &&
@@ -355,14 +356,14 @@ function TimeInput(props: DTimeInputProps, ref: React.ForwardedRef<DTimeInputRef
355356 }
356357
357358 return children ( {
358- tiStyle : {
359+ diStyle : {
359360 ...popupPositionStyle ,
360361 ...transitionStyle ,
361362 zIndex : maxZIndex ,
362363 } ,
363- 'data-time -input-popupid' : uniqueId ,
364- tiOnMouseDown : preventBlur ,
365- tiOnMouseUp : preventBlur ,
364+ 'data-date -input-popupid' : uniqueId ,
365+ diOnMouseDown : preventBlur ,
366+ diOnMouseUp : preventBlur ,
366367 } ) ;
367368 } }
368369 </ DTransition > ,
@@ -372,4 +373,4 @@ function TimeInput(props: DTimeInputProps, ref: React.ForwardedRef<DTimeInputRef
372373 ) ;
373374}
374375
375- export const DTimeInput = React . forwardRef ( TimeInput ) ;
376+ export const DDateInput = React . forwardRef ( DateInput ) ;
0 commit comments