@@ -7,8 +7,30 @@ import {
77 addToDate ,
88 generateInitialDate ,
99 subtractFromDate ,
10+ objectKeyFilter
1011} from "./helpers"
1112
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+
1234const DayJS = ( props ) => {
1335 const [ state , setState ] = useState ( {
1436 value : "" ,
@@ -106,30 +128,15 @@ const DayJS = (props) => {
106128 update ( props )
107129 } , [ ] )
108130
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+ )
111137}
112138
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
133140
134141DayJS . defaultProps = {
135142 element : "time" ,
0 commit comments