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 109
109
border : none ;
110
110
outline : none ;
111
111
cursor : pointer ;
112
- transition : background 0.3s , border 0.3s ;
112
+ transition :
113
+ background 0.3s ,
114
+ border 0.3s ;
113
115
114
116
& :hover {
115
117
background : fade (blue , 30% );
547
549
box-sizing : border-box ;
548
550
width : 100% ;
549
551
border : 1px solid green ;
552
+ min-height : 1em ;
550
553
551
554
&-item {
552
555
flex : none ;
558
561
border : 1px solid blue ;
559
562
}
560
563
564
+ &-selection-placeholder {
565
+ pointer-events : none ;
566
+ position : absolute ;
567
+ left : 0 ;
568
+ top : 0 ;
569
+ }
570
+
561
571
&-multiple-input {
562
572
width : 10px ;
563
573
opacity : 0.1 ;
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import 'dayjs/locale/zh-cn';
11
11
import buddhistEra from 'dayjs/plugin/buddhistEra' ;
12
12
import LocalizedFormat from 'dayjs/plugin/localizedFormat' ;
13
13
import dayjsGenerateConfig from '../../src/generate/dayjs' ;
14
+ import dateFnsGenerateConfig from '../../src/generate/dateFns' ;
14
15
import zhCN from '../../src/locale/zh_CN' ;
15
16
16
17
dayjs . locale ( 'zh-cn' ) ;
@@ -36,19 +37,18 @@ const sharedLocale = {
36
37
generateConfig : dayjsGenerateConfig ,
37
38
} ;
38
39
40
+ const dateFnsSharedLocale = {
41
+ locale : myLocale ,
42
+ generateConfig : dateFnsGenerateConfig ,
43
+ } ;
44
+
39
45
export default ( ) => {
40
46
return (
41
47
< div >
42
48
{ /* <RangePicker {...sharedLocale} style={{ width: 400 }} showTime />
43
49
<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" />
52
52
</ div >
53
53
) ;
54
54
} ;
Original file line number Diff line number Diff line change @@ -171,6 +171,7 @@ function SingleSelector<DateType extends object = any>(
171
171
disabled = { disabled }
172
172
removeIcon = { removeIcon }
173
173
/>
174
+ { ! value . length && < span className = { `${ prefixCls } -selection-placeholder` } > { placeholder } </ span > }
174
175
< input
175
176
className = { `${ prefixCls } -multiple-input` }
176
177
value = { value . map ( getText ) . join ( ',' ) }
Original file line number Diff line number Diff line change @@ -137,4 +137,22 @@ describe('Picker.Multiple', () => {
137
137
138
138
expect ( container . querySelector ( '.custom-remove' ) ) . toBeTruthy ( ) ;
139
139
} ) ;
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
+ } ) ;
140
158
} ) ;
You can’t perform that action at this time.
0 commit comments