forked from coreui/coreui-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelper.js
75 lines (67 loc) · 1.86 KB
/
helper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import PropTypes from 'prop-types'
// Duplicated Transition.propType keys to ensure that Reactstrap builds
// for distribution properly exclude these keys for nested child HTML attributes
// since `react-transition-group` removes propTypes in production builds.
export const TransitionPropTypeKeys = [
'in',
'mountOnEnter',
'unmountOnExit',
'appear',
'enter',
'exit',
'timeout',
'onEnter',
'onEntering',
'onEntered',
'onExit',
'onExiting',
'onExited'
];
export const CFadeProps = [
...TransitionPropTypeKeys,
'baseClass',
'baseClassActive',
'tag'
]
export const canUseDOM = !!(
typeof window !== 'undefined' &&
window.document &&
window.document.createElement
);
export const targetPropType = PropTypes.oneOfType([
PropTypes.string,
PropTypes.func,
DOMElement,
PropTypes.shape({ current: PropTypes.any }),
]);
export const tagPropType = PropTypes.oneOfType([
PropTypes.func,
PropTypes.string,
PropTypes.shape({ $$typeof: PropTypes.symbol, render: PropTypes.func }),
PropTypes.arrayOf(PropTypes.oneOfType([
PropTypes.func,
PropTypes.string,
PropTypes.shape({ $$typeof: PropTypes.symbol, render: PropTypes.func }),
]))
]);
export function DOMElement(props, propName, componentName) {
if (!(props[propName] instanceof Element)) {
return new Error(
'Invalid prop `' +
propName +
'` supplied to `' +
componentName +
'`. Expected prop to be an instance of Element. Validation failed.'
);
}
}
export function deprecated(propType, explanation) {
return function validate(props, propName, componentName, ...rest) {
if (props[propName] !== null && typeof props[propName] !== 'undefined') {
console.error(
`"${propName}" property of "${componentName}" has been deprecated.\n${explanation}`
)
}
return propType(props, propName, componentName, ...rest);
}
}