File tree Expand file tree Collapse file tree 4 files changed +38
-9
lines changed
src/PickerInput/Selector/SingleSelector Expand file tree Collapse file tree 4 files changed +38
-9
lines changed Original file line number Diff line number Diff line change 109109 border : none ;
110110 outline : none ;
111111 cursor : pointer ;
112- transition : background 0.3s , border 0.3s ;
112+ transition :
113+ background 0.3s ,
114+ border 0.3s ;
113115
114116 & :hover {
115117 background : fade (blue , 30% );
547549 box-sizing : border-box ;
548550 width : 100% ;
549551 border : 1px solid green ;
552+ min-height : 1em ;
550553
551554 &-item {
552555 flex : none ;
558561 border : 1px solid blue ;
559562 }
560563
564+ &-selection-placeholder {
565+ pointer-events : none ;
566+ position : absolute ;
567+ left : 0 ;
568+ top : 0 ;
569+ }
570+
561571 &-multiple-input {
562572 width : 10px ;
563573 opacity : 0.1 ;
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import 'dayjs/locale/zh-cn';
1111import buddhistEra from 'dayjs/plugin/buddhistEra' ;
1212import LocalizedFormat from 'dayjs/plugin/localizedFormat' ;
1313import dayjsGenerateConfig from '../../src/generate/dayjs' ;
14+ import dateFnsGenerateConfig from '../../src/generate/dateFns' ;
1415import zhCN from '../../src/locale/zh_CN' ;
1516
1617dayjs . locale ( 'zh-cn' ) ;
@@ -36,19 +37,18 @@ const sharedLocale = {
3637 generateConfig : dayjsGenerateConfig ,
3738} ;
3839
40+ const dateFnsSharedLocale = {
41+ locale : myLocale ,
42+ generateConfig : dateFnsGenerateConfig ,
43+ } ;
44+
3945export default ( ) => {
4046 return (
4147 < div >
4248 { /* <RangePicker {...sharedLocale} style={{ width: 400 }} showTime />
4349 <RangePicker {...sharedLocale} style={{ width: 400 }} showTime showMinute={false} /> */ }
44- < SinglePicker
45- { ...sharedLocale }
46- style = { { width : 400 } }
47- showTime
48- showHour
49- showMinute
50- // showSecond={false}
51- />
50+ < SinglePicker { ...dateFnsSharedLocale } style = { { width : 400 } } multiple placeholder = "good" />
51+ < SinglePicker { ...dateFnsSharedLocale } style = { { width : 400 } } placeholder = "good" />
5252 </ div >
5353 ) ;
5454} ;
Original file line number Diff line number Diff line change @@ -171,6 +171,7 @@ function SingleSelector<DateType extends object = any>(
171171 disabled = { disabled }
172172 removeIcon = { removeIcon }
173173 />
174+ { ! value . length && < span className = { `${ prefixCls } -selection-placeholder` } > { placeholder } </ span > }
174175 < input
175176 className = { `${ prefixCls } -multiple-input` }
176177 value = { value . map ( getText ) . join ( ',' ) }
Original file line number Diff line number Diff line change @@ -137,4 +137,22 @@ describe('Picker.Multiple', () => {
137137
138138 expect ( container . querySelector ( '.custom-remove' ) ) . toBeTruthy ( ) ;
139139 } ) ;
140+
141+ describe ( 'placeholder' , ( ) => {
142+ it ( 'show placeholder' , ( ) => {
143+ const { container } = render ( < DayPicker multiple placeholder = "bamboo" /> ) ;
144+ expect (
145+ container . querySelector < HTMLSpanElement > ( '.rc-picker-selection-placeholder' ) . textContent ,
146+ ) . toBe ( 'bamboo' ) ;
147+ } ) ;
148+
149+ it ( 'hide if has value' , ( ) => {
150+ const { container } = render (
151+ < DayPicker multiple defaultValue = { [ getDay ( '2000-01-01' ) ] } placeholder = "bamboo" /> ,
152+ ) ;
153+ expect (
154+ container . querySelector < HTMLSpanElement > ( '.rc-picker-selection-placeholder' ) ,
155+ ) . toBeFalsy ( ) ;
156+ } ) ;
157+ } ) ;
140158} ) ;
You can’t perform that action at this time.
0 commit comments