@@ -7,8 +7,30 @@ import {
7
7
addToDate ,
8
8
generateInitialDate ,
9
9
subtractFromDate ,
10
+ objectKeyFilter
10
11
} from "./helpers"
11
12
13
+ const propTypes = {
14
+ element : PropTypes . any ,
15
+ date : PropTypes . oneOfType ( [
16
+ PropTypes . string ,
17
+ PropTypes . number ,
18
+ PropTypes . array ,
19
+ PropTypes . object ,
20
+ ] ) ,
21
+ format : PropTypes . string ,
22
+ toJSON : PropTypes . bool ,
23
+ toISOString : PropTypes . bool ,
24
+ asString : PropTypes . bool ,
25
+ unixSeconds : PropTypes . bool ,
26
+ unixMilliseconds : PropTypes . bool ,
27
+ daysInMonth : PropTypes . bool ,
28
+ displayIsValid : PropTypes . bool ,
29
+ add : PropTypes . object ,
30
+ subtract : PropTypes . object ,
31
+ children : PropTypes . string ,
32
+ }
33
+
12
34
const DayJS = ( props ) => {
13
35
const [ state , setState ] = useState ( {
14
36
value : "" ,
@@ -106,30 +128,15 @@ const DayJS = (props) => {
106
128
update ( props )
107
129
} , [ ] )
108
130
109
- const Element = props . element
110
- return < Element > { state . value } </ Element >
131
+ const elementProps = objectKeyFilter ( props , propTypes )
132
+ return React . createElement (
133
+ props . element ,
134
+ elementProps ,
135
+ state . value
136
+ )
111
137
}
112
138
113
- DayJS . propTypes = {
114
- element : PropTypes . any ,
115
- date : PropTypes . oneOfType ( [
116
- PropTypes . string ,
117
- PropTypes . number ,
118
- PropTypes . array ,
119
- PropTypes . object ,
120
- ] ) ,
121
- format : PropTypes . string ,
122
- toJSON : PropTypes . bool ,
123
- toISOString : PropTypes . bool ,
124
- asString : PropTypes . bool ,
125
- unixSeconds : PropTypes . bool ,
126
- unixMilliseconds : PropTypes . bool ,
127
- daysInMonth : PropTypes . bool ,
128
- displayIsValid : PropTypes . bool ,
129
- add : PropTypes . object ,
130
- subtract : PropTypes . object ,
131
- children : PropTypes . string ,
132
- }
139
+ DayJS . propTypes = propTypes
133
140
134
141
DayJS . defaultProps = {
135
142
element : "time" ,
0 commit comments