@elliemae/ds-props-helpers 2.3.1 → 3.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/defaultProps/index.js +28 -0
- package/dist/cjs/defaultProps/index.js.map +7 -0
- package/dist/cjs/defaultProps/useMemoMergePropsWithDefault.js +62 -0
- package/dist/cjs/defaultProps/useMemoMergePropsWithDefault.js.map +7 -0
- package/dist/cjs/getProps/index.js +37 -0
- package/dist/cjs/getProps/index.js.map +7 -0
- package/dist/cjs/globalProps/constants.js +397 -0
- package/dist/cjs/globalProps/constants.js.map +7 -0
- package/dist/cjs/globalProps/globalAttributesPropTypes.js +398 -0
- package/dist/cjs/globalProps/globalAttributesPropTypes.js.map +7 -0
- package/dist/cjs/globalProps/index.js +29 -0
- package/dist/cjs/globalProps/index.js.map +7 -0
- package/dist/cjs/globalProps/useGetGlobalAttributes.js +56 -0
- package/dist/cjs/globalProps/useGetGlobalAttributes.js.map +7 -0
- package/dist/cjs/index.js +33 -0
- package/dist/cjs/index.js.map +7 -0
- package/dist/cjs/propTypes/PropTypes.js +149 -0
- package/dist/cjs/propTypes/PropTypes.js.map +7 -0
- package/dist/cjs/propTypes/customPropTypes.js +38 -0
- package/dist/cjs/propTypes/customPropTypes.js.map +7 -0
- package/dist/cjs/propTypes/describe.js +81 -0
- package/dist/cjs/propTypes/describe.js.map +7 -0
- package/dist/cjs/propTypes/describeConversions.js +96 -0
- package/dist/cjs/propTypes/describeConversions.js.map +7 -0
- package/dist/cjs/propTypes/describeGuards.js +49 -0
- package/dist/cjs/propTypes/describeGuards.js.map +7 -0
- package/dist/cjs/propTypes/index.js +37 -0
- package/dist/cjs/propTypes/index.js.map +7 -0
- package/dist/cjs/propTypes/toTypescript.js +154 -0
- package/dist/cjs/propTypes/toTypescript.js.map +7 -0
- package/dist/cjs/propTypes/types.js +27 -0
- package/dist/cjs/propTypes/types.js.map +7 -0
- package/dist/cjs/tests/globalProps/TestComponent.js +54 -0
- package/dist/cjs/tests/globalProps/TestComponent.js.map +7 -0
- package/dist/cjs/tests/validation/test.schema.js +67 -0
- package/dist/cjs/tests/validation/test.schema.js.map +7 -0
- package/dist/cjs/validation/errorTemplates.js +48 -0
- package/dist/cjs/validation/errorTemplates.js.map +7 -0
- package/dist/cjs/validation/index.js +30 -0
- package/dist/cjs/validation/index.js.map +7 -0
- package/dist/cjs/validation/typescriptGuards.js +65 -0
- package/dist/cjs/validation/typescriptGuards.js.map +7 -0
- package/dist/cjs/validation/typescriptParsers.js +76 -0
- package/dist/cjs/validation/typescriptParsers.js.map +7 -0
- package/dist/cjs/validation/typescriptValidator.js +171 -0
- package/dist/cjs/validation/typescriptValidator.js.map +7 -0
- package/dist/cjs/validation/validator.js +55 -0
- package/dist/cjs/validation/validator.js.map +7 -0
- package/dist/cjs/xstyledProps/constants.js +88 -0
- package/dist/cjs/xstyledProps/constants.js.map +7 -0
- package/dist/cjs/xstyledProps/index.js +29 -0
- package/dist/cjs/xstyledProps/index.js.map +7 -0
- package/dist/cjs/xstyledProps/useGetXstyledProps.js +48 -0
- package/dist/cjs/xstyledProps/useGetXstyledProps.js.map +7 -0
- package/dist/cjs/xstyledProps/xstyledPropTypes.js +92 -0
- package/dist/cjs/xstyledProps/xstyledPropTypes.js.map +7 -0
- package/dist/esm/defaultProps/index.js +3 -0
- package/dist/esm/defaultProps/index.js.map +7 -0
- package/dist/esm/defaultProps/useMemoMergePropsWithDefault.js +35 -0
- package/dist/esm/defaultProps/useMemoMergePropsWithDefault.js.map +7 -0
- package/dist/esm/getProps/index.js +8 -0
- package/dist/esm/getProps/index.js.map +7 -0
- package/dist/esm/globalProps/constants.js +368 -0
- package/dist/esm/globalProps/constants.js.map +7 -0
- package/{esm → dist/esm}/globalProps/globalAttributesPropTypes.js +58 -67
- package/dist/esm/globalProps/globalAttributesPropTypes.js.map +7 -0
- package/dist/esm/globalProps/index.js +4 -0
- package/dist/esm/globalProps/index.js.map +7 -0
- package/dist/esm/globalProps/useGetGlobalAttributes.js +27 -0
- package/dist/esm/globalProps/useGetGlobalAttributes.js.map +7 -0
- package/dist/esm/index.js +8 -0
- package/dist/esm/index.js.map +7 -0
- package/dist/esm/propTypes/PropTypes.js +122 -0
- package/dist/esm/propTypes/PropTypes.js.map +7 -0
- package/dist/esm/propTypes/customPropTypes.js +9 -0
- package/dist/esm/propTypes/customPropTypes.js.map +7 -0
- package/dist/esm/propTypes/describe.js +52 -0
- package/dist/esm/propTypes/describe.js.map +7 -0
- package/dist/esm/propTypes/describeConversions.js +76 -0
- package/dist/esm/propTypes/describeConversions.js.map +7 -0
- package/dist/esm/propTypes/describeGuards.js +20 -0
- package/dist/esm/propTypes/describeGuards.js.map +7 -0
- package/dist/esm/propTypes/index.js +8 -0
- package/dist/esm/propTypes/index.js.map +7 -0
- package/dist/esm/propTypes/toTypescript.js +127 -0
- package/dist/esm/propTypes/toTypescript.js.map +7 -0
- package/dist/esm/propTypes/types.js +2 -0
- package/dist/esm/propTypes/types.js.map +7 -0
- package/dist/esm/tests/globalProps/TestComponent.js +27 -0
- package/dist/esm/tests/globalProps/TestComponent.js.map +7 -0
- package/dist/esm/tests/validation/test.schema.js +38 -0
- package/dist/esm/tests/validation/test.schema.js.map +7 -0
- package/dist/esm/validation/errorTemplates.js +19 -0
- package/dist/esm/validation/errorTemplates.js.map +7 -0
- package/dist/esm/validation/index.js +5 -0
- package/dist/esm/validation/index.js.map +7 -0
- package/dist/esm/validation/typescriptGuards.js +36 -0
- package/dist/esm/validation/typescriptGuards.js.map +7 -0
- package/dist/esm/validation/typescriptParsers.js +47 -0
- package/dist/esm/validation/typescriptParsers.js.map +7 -0
- package/dist/esm/validation/typescriptValidator.js +153 -0
- package/dist/esm/validation/typescriptValidator.js.map +7 -0
- package/dist/esm/validation/validator.js +26 -0
- package/dist/esm/validation/validator.js.map +7 -0
- package/dist/esm/xstyledProps/constants.js +59 -0
- package/dist/esm/xstyledProps/constants.js.map +7 -0
- package/dist/esm/xstyledProps/index.js +4 -0
- package/dist/esm/xstyledProps/index.js.map +7 -0
- package/dist/esm/xstyledProps/useGetXstyledProps.js +19 -0
- package/dist/esm/xstyledProps/useGetXstyledProps.js.map +7 -0
- package/dist/esm/xstyledProps/xstyledPropTypes.js +63 -0
- package/dist/esm/xstyledProps/xstyledPropTypes.js.map +7 -0
- package/package.json +72 -81
- package/cjs/defaultProps/index.js +0 -9
- package/cjs/defaultProps/useMemoMergePropsWithDefault.js +0 -48
- package/cjs/getProps/index.js +0 -20
- package/cjs/globalProps/constants.js +0 -16
- package/cjs/globalProps/globalAttributesPropTypes.js +0 -382
- package/cjs/globalProps/index.js +0 -11
- package/cjs/globalProps/useGetGlobalAttributes.js +0 -37
- package/cjs/index.js +0 -32
- package/cjs/propTypes/PropTypes.js +0 -131
- package/cjs/propTypes/customPropTypes.js +0 -21
- package/cjs/propTypes/describe.js +0 -64
- package/cjs/propTypes/describeConversions.js +0 -104
- package/cjs/propTypes/describeGuards.js +0 -21
- package/cjs/propTypes/index.js +0 -11
- package/cjs/propTypes/toTypescript.js +0 -160
- package/cjs/propTypes/types.js +0 -2
- package/cjs/validation/errorTemplates.js +0 -16
- package/cjs/validation/index.js +0 -15
- package/cjs/validation/typescriptGuards.js +0 -36
- package/cjs/validation/typescriptParsers.js +0 -45
- package/cjs/validation/typescriptValidator.js +0 -208
- package/cjs/validation/validator.js +0 -36
- package/cjs/xstyledProps/constants.js +0 -21
- package/cjs/xstyledProps/index.js +0 -11
- package/cjs/xstyledProps/useGetXstyledProps.js +0 -27
- package/cjs/xstyledProps/xstyledPropTypes.js +0 -75
- package/esm/defaultProps/index.js +0 -1
- package/esm/defaultProps/useMemoMergePropsWithDefault.js +0 -39
- package/esm/getProps/index.js +0 -15
- package/esm/globalProps/constants.js +0 -12
- package/esm/globalProps/index.js +0 -2
- package/esm/globalProps/useGetGlobalAttributes.js +0 -33
- package/esm/index.js +0 -11
- package/esm/propTypes/PropTypes.js +0 -125
- package/esm/propTypes/customPropTypes.js +0 -17
- package/esm/propTypes/describe.js +0 -62
- package/esm/propTypes/describeConversions.js +0 -96
- package/esm/propTypes/describeGuards.js +0 -10
- package/esm/propTypes/index.js +0 -2
- package/esm/propTypes/toTypescript.js +0 -154
- package/esm/propTypes/types.js +0 -1
- package/esm/validation/errorTemplates.js +0 -11
- package/esm/validation/index.js +0 -3
- package/esm/validation/typescriptGuards.js +0 -23
- package/esm/validation/typescriptParsers.js +0 -41
- package/esm/validation/typescriptValidator.js +0 -203
- package/esm/validation/validator.js +0 -32
- package/esm/xstyledProps/constants.js +0 -16
- package/esm/xstyledProps/index.js +0 -2
- package/esm/xstyledProps/useGetXstyledProps.js +0 -23
- package/esm/xstyledProps/xstyledPropTypes.js +0 -71
- package/types/defaultProps/index.d.ts +0 -1
- package/types/defaultProps/useMemoMergePropsWithDefault.d.ts +0 -1
- package/types/getProps/index.d.ts +0 -2
- package/types/globalProps/constants.d.ts +0 -3
- package/types/globalProps/globalAttributesPropTypes.d.ts +0 -363
- package/types/globalProps/index.d.ts +0 -2
- package/types/globalProps/useGetGlobalAttributes.d.ts +0 -4
- package/types/index.d.ts +0 -6
- package/types/propTypes/PropTypes.d.ts +0 -3
- package/types/propTypes/customPropTypes.d.ts +0 -2
- package/types/propTypes/describe.d.ts +0 -3
- package/types/propTypes/describeConversions.d.ts +0 -3
- package/types/propTypes/describeGuards.d.ts +0 -9
- package/types/propTypes/index.d.ts +0 -3
- package/types/propTypes/toTypescript.d.ts +0 -3
- package/types/propTypes/types.d.ts +0 -99
- package/types/tests/globalProps/TestComponent.d.ts +0 -1
- package/types/tests/globalProps/globalAttributes.test.d.ts +0 -1
- package/types/tests/validation/any.validation.test.d.ts +0 -1
- package/types/tests/validation/array.validation.test.d.ts +0 -1
- package/types/tests/validation/boolean.validation.test.d.ts +0 -1
- package/types/tests/validation/function.validation.test.d.ts +0 -1
- package/types/tests/validation/number.validation.test.d.ts +0 -1
- package/types/tests/validation/object.validation.test.d.ts +0 -1
- package/types/tests/validation/schema.validation.test.d.ts +0 -1
- package/types/tests/validation/string.validation.test.d.ts +0 -1
- package/types/tests/validation/test.schema.d.ts +0 -1
- package/types/tests/validation/union.validation.test.d.ts +0 -1
- package/types/validation/errorTemplates.d.ts +0 -2
- package/types/validation/index.d.ts +0 -3
- package/types/validation/typescriptGuards.d.ts +0 -12
- package/types/validation/typescriptParsers.d.ts +0 -1
- package/types/validation/typescriptValidator.d.ts +0 -15
- package/types/validation/validator.d.ts +0 -1
- package/types/xstyledProps/constants.d.ts +0 -2
- package/types/xstyledProps/index.d.ts +0 -2
- package/types/xstyledProps/useGetXstyledProps.d.ts +0 -5
- package/types/xstyledProps/xstyledPropTypes.d.ts +0 -57
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
6
|
-
require('core-js/modules/esnext.async-iterator.map.js');
|
|
7
|
-
require('core-js/modules/esnext.iterator.map.js');
|
|
8
|
-
|
|
9
|
-
const marginKeys = ['margin', 'marginTop', 'marginRight', 'marginBottom', 'marginLeft', 'm', 'mt', 'mr', 'mb', 'ml', 'mx', 'my'];
|
|
10
|
-
const paddingKeys = ['padding', 'p', 'paddingTop', 'pt', 'paddingRight', 'pr', 'paddingBottom', 'pb', 'paddingLeft', 'pl', 'px', 'py'];
|
|
11
|
-
const spaceKeys = ['spaceY', 'spaceX', 'spaceXReverse', 'spaceYReverse'];
|
|
12
|
-
const widthKeys = ['w', 'maxWidth', 'maxW', 'minWidth', 'minW'];
|
|
13
|
-
const heightKeys = ['h', 'maxHeight', 'maxH', 'minHeight', 'minH'];
|
|
14
|
-
const maskSizeKeys = ['maskSize'];
|
|
15
|
-
const spacingKeys = [...marginKeys, ...paddingKeys, ...spaceKeys];
|
|
16
|
-
const sizingKeys = [...widthKeys, ...heightKeys, ...maskSizeKeys];
|
|
17
|
-
const layoutKeys = ['display', 'float', 'boxSizing', 'container', 'overflow', 'overflowX', 'overflowY', 'zIndex', 'position', 'top', 'right', 'bottom', 'left', 'visibility', 'overscrollBehavior', 'objectFit'];
|
|
18
|
-
const xstyledKeys = Object.fromEntries([...spacingKeys, ...sizingKeys, ...layoutKeys].map(item => [item, true]));
|
|
19
|
-
|
|
20
|
-
exports.layoutKeys = layoutKeys;
|
|
21
|
-
exports.xstyledKeys = xstyledKeys;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var useGetXstyledProps = require('./useGetXstyledProps.js');
|
|
6
|
-
var xstyledPropTypes = require('./xstyledPropTypes.js');
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
exports.useGetXstyledProps = useGetXstyledProps.useGetXstyledProps;
|
|
11
|
-
exports.xstyledPropTypes = xstyledPropTypes.xstyledPropTypes;
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
6
|
-
require('core-js/modules/esnext.iterator.constructor.js');
|
|
7
|
-
require('core-js/modules/esnext.iterator.for-each.js');
|
|
8
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
9
|
-
var react = require('react');
|
|
10
|
-
var constants = require('./constants.js');
|
|
11
|
-
|
|
12
|
-
const useGetXstyledProps = props => {
|
|
13
|
-
const componentXstyledProps = react.useMemo(() => {
|
|
14
|
-
const xstyledPropsObject = {};
|
|
15
|
-
Object.entries(props).forEach(_ref => {
|
|
16
|
-
let [key, value] = _ref;
|
|
17
|
-
|
|
18
|
-
if (key in constants.xstyledKeys) {
|
|
19
|
-
xstyledPropsObject[key] = value;
|
|
20
|
-
}
|
|
21
|
-
});
|
|
22
|
-
return xstyledPropsObject;
|
|
23
|
-
}, [props]);
|
|
24
|
-
return componentXstyledProps;
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
exports.useGetXstyledProps = useGetXstyledProps;
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var PropTypes = require('../propTypes/PropTypes.js');
|
|
6
|
-
require('core-js/modules/esnext.async-iterator.for-each.js');
|
|
7
|
-
require('core-js/modules/esnext.iterator.constructor.js');
|
|
8
|
-
require('core-js/modules/esnext.iterator.for-each.js');
|
|
9
|
-
require('core-js/modules/web.dom-collections.iterator.js');
|
|
10
|
-
require('core-js/modules/esnext.async-iterator.map.js');
|
|
11
|
-
require('core-js/modules/esnext.iterator.map.js');
|
|
12
|
-
require('prop-types');
|
|
13
|
-
require('@babel/runtime/helpers/defineProperty');
|
|
14
|
-
require('core-js/modules/esnext.async-iterator.filter.js');
|
|
15
|
-
require('core-js/modules/esnext.iterator.filter.js');
|
|
16
|
-
|
|
17
|
-
const xstyledPropTypes = {
|
|
18
|
-
margin: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
19
|
-
m: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
20
|
-
marginTop: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
21
|
-
mt: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
22
|
-
marginRight: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
23
|
-
mr: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
24
|
-
marginBottom: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
25
|
-
mb: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
26
|
-
marginLeft: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
27
|
-
ml: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
28
|
-
mx: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
29
|
-
my: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
30
|
-
padding: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
31
|
-
p: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
32
|
-
paddingTop: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
33
|
-
pt: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
34
|
-
paddingRight: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
35
|
-
pr: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
36
|
-
paddingBottom: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
37
|
-
pb: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
38
|
-
paddingLeft: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
39
|
-
pl: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
40
|
-
px: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
41
|
-
py: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
42
|
-
spaceY: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
43
|
-
spaceX: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
44
|
-
spaceXReverse: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
45
|
-
spaceYReverse: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
46
|
-
w: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
47
|
-
maxWidth: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
48
|
-
maxW: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
49
|
-
minWidth: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
50
|
-
minW: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
51
|
-
h: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
52
|
-
maxHeight: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
53
|
-
maxH: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
54
|
-
minHeight: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
55
|
-
minH: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
56
|
-
maskSize: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
57
|
-
display: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
58
|
-
float: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
59
|
-
boxSizing: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
60
|
-
container: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
61
|
-
overflow: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
62
|
-
overflowX: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
63
|
-
overflowY: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
64
|
-
zIndex: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
65
|
-
position: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
66
|
-
top: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
67
|
-
right: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
68
|
-
bottom: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
69
|
-
left: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
70
|
-
visibility: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
71
|
-
overscrollBehavior: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled(),
|
|
72
|
-
objectFit: PropTypes.any.description('Applies to the root container. For more info read xstyled docs').xstyled()
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
exports.xstyledPropTypes = xstyledPropTypes;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { useMemoMergePropsWithDefault } from './useMemoMergePropsWithDefault.js';
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
-
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
-
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
-
import { useRef } from 'react';
|
|
8
|
-
import deepequal from 'fast-deep-equal/react';
|
|
9
|
-
|
|
10
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
11
|
-
|
|
12
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
13
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
14
|
-
|
|
15
|
-
const useMemoCompare = (next, compare) => {
|
|
16
|
-
// Ref for storing previous value
|
|
17
|
-
const previousRef = useRef(next);
|
|
18
|
-
const previous = previousRef.current; // Pass previous and next value to compare function
|
|
19
|
-
// to determine whether to consider them equal.
|
|
20
|
-
|
|
21
|
-
const isEqual = compare(previous, next); // If not equal update previousRef to next value.
|
|
22
|
-
// We only update if not equal so that this hook continues to return
|
|
23
|
-
// the same old value if compare keeps returning true.
|
|
24
|
-
|
|
25
|
-
if (!isEqual) previousRef.current = next; // Finally, if equal then return the previous value
|
|
26
|
-
|
|
27
|
-
return isEqual ? previous : next;
|
|
28
|
-
}; // eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const useMemoMergePropsWithDefault = function (props, defaultProps) {
|
|
32
|
-
let compare = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : deepequal;
|
|
33
|
-
|
|
34
|
-
const mergedProps = _objectSpread(_objectSpread({}, defaultProps), props);
|
|
35
|
-
|
|
36
|
-
return useMemoCompare(mergedProps, compare);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export { useMemoMergePropsWithDefault };
|
package/esm/getProps/index.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
-
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
5
|
-
|
|
6
|
-
const getAriaProps = props => Object.fromEntries(Object.entries(props).filter(_ref => {
|
|
7
|
-
let [key] = _ref;
|
|
8
|
-
return key.includes('aria-');
|
|
9
|
-
}));
|
|
10
|
-
const getDataProps = props => Object.fromEntries(Object.entries(props).filter(_ref2 => {
|
|
11
|
-
let [key] = _ref2;
|
|
12
|
-
return key.includes('data-');
|
|
13
|
-
}));
|
|
14
|
-
|
|
15
|
-
export { getAriaProps, getDataProps };
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
2
|
-
import 'core-js/modules/esnext.iterator.map.js';
|
|
3
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
4
|
-
|
|
5
|
-
/* eslint-disable max-lines */
|
|
6
|
-
const ariaAttributes = ['aria-activedescendant', 'aria-atomic', 'aria-autocomplete', 'aria-busy', 'aria-checked', 'aria-colcount', 'aria-colindex', 'aria-colspan', 'aria-controls', 'aria-current', 'aria-describedby', 'aria-details', 'aria-disabled', 'aria-dropeffect', 'aria-errormessage', 'aria-expanded', 'aria-flowto', 'aria-grabbed', 'aria-haspopup', 'aria-hidden', 'aria-invalid', 'aria-keyshortcuts', 'aria-label', 'aria-labelledby', 'aria-level', 'aria-live', 'aria-modal', 'aria-multiline', 'aria-multiselectable', 'aria-orientation', 'aria-owns', 'aria-placeholder', 'aria-posinset', 'aria-pressed', 'aria-readonly', 'aria-relevant', 'aria-required', 'aria-roledescription', 'aria-rowcount', 'aria-rowindex', 'aria-rowspan', 'aria-selected', 'aria-setsize', 'aria-sort', 'aria-valuemax', 'aria-valuemin', 'aria-valuenow', 'aria-valuetext'];
|
|
7
|
-
const domAttributes = ['onCopy', 'onCopyCapture', 'onCut', 'onCutCapture', 'onPaste', 'onPasteCapture', 'onCompositionEnd', 'onCompositionEndCapture', 'onCompositionStart', 'onCompositionStartCapture', 'onCompositionUpdate', 'onCompositionUpdateCapture', 'onFocus', 'onFocusCapture', 'onBlur', 'onBlurCapture', 'onChange', 'onChangeCapture', 'onBeforeInput', 'onBeforeInputCapture', 'onInput', 'onInputCapture', 'onReset', 'onResetCapture', 'onSubmit', 'onSubmitCapture', 'onInvalid', 'onInvalidCapture', 'onLoad', 'onLoadCapture', 'onError', 'onErrorCapture', 'onKeyDown', 'onKeyDownCapture', 'onKeyPress', 'onKeyPressCapture', 'onKeyUp', 'onKeyUpCapture', 'onAbort', 'onAbortCapture', 'onCanPlay', 'onCanPlayCapture', 'onCanPlayThrough', 'onCanPlayThroughCapture', 'onDurationChange', 'onDurationChangeCapture', 'onEmptied', 'onEmptiedCapture', 'onEncrypted', 'onEncryptedCapture', 'onEnded', 'onEndedCapture', 'onLoadedData', 'onLoadedDataCapture', 'onLoadedMetadata', 'onLoadedMetadataCapture', 'onLoadStart', 'onLoadStartCapture', 'onPause', 'onPauseCapture', 'onPlay', 'onPlayCapture', 'onPlaying', 'onPlayingCapture', 'onProgress', 'onProgressCapture', 'onRateChange', 'onRateChangeCapture', 'onSeeked', 'onSeekedCapture', 'onSeeking', 'onSeekingCapture', 'onStalled', 'onStalledCapture', 'onSuspend', 'onSuspendCapture', 'onTimeUpdate', 'onTimeUpdateCapture', 'onVolumeChange', 'onVolumeChangeCapture', 'onWaiting', 'onWaitingCapture', 'onAuxClick', 'onAuxClickCapture', 'onClick', 'onClickCapture', 'onContextMenu', 'onContextMenuCapture', 'onDoubleClick', 'onDoubleClickCapture', 'onDrag', 'onDragCapture', 'onDragEnd', 'onDragEndCapture', 'onDragEnter', 'onDragEnterCapture', 'onDragExit', 'onDragExitCapture', 'onDragLeave', 'onDragLeaveCapture', 'onDragOver', 'onDragOverCapture', 'onDragStart', 'onDragStartCapture', 'onDrop', 'onDropCapture', 'onMouseDown', 'onMouseDownCapture', 'onMouseEnter', 'onMouseLeave', 'onMouseMove', 'onMouseMoveCapture', 'onMouseOut', 'onMouseOutCapture', 'onMouseOver', 'onMouseOverCapture', 'onMouseUp', 'onMouseUpCapture', 'onSelect', 'onSelectCapture', 'onTouchCancel', 'onTouchCancelCapture', 'onTouchEnd', 'onTouchEndCapture', 'onTouchMove', 'onTouchMoveCapture', 'onTouchStart', 'onTouchStartCapture', 'onPointerDown', 'onPointerDownCapture', 'onPointerMove', 'onPointerMoveCapture', 'onPointerUp', 'onPointerUpCapture', 'onPointerCancel', 'onPointerCancelCapture', 'onPointerEnter', 'onPointerEnterCapture', 'onPointerLeave', 'onPointerLeaveCapture', 'onPointerOver', 'onPointerOverCapture', 'onPointerOut', 'onPointerOutCapture', 'onGotPointerCapture', 'onGotPointerCaptureCapture', 'onLostPointerCapture', 'onLostPointerCaptureCapture', 'onScroll', 'onScrollCapture', 'onWheel', 'onWheelCapture', 'onAnimationStart', 'onAnimationStartCapture', 'onAnimationEnd', 'onAnimationEndCapture', 'onAnimationIteration', 'onAnimationIterationCapture', 'onTransitionEnd', 'onTransitionEndCapture'];
|
|
8
|
-
const htmlAttributes = ['about', 'accept', 'acceptCharset', 'accessKey', 'action', 'allowFullScreen', 'allowTransparency', 'alt', // 'as', This property causes trouble in TS. This is actually not an HTML Attribute, leaving it here for the record
|
|
9
|
-
'async', 'autoCapitalize', 'autoComplete', 'autoCorrect', 'autoFocus', 'autoPlay', 'autoSave', 'capture', 'cellPadding', 'cellSpacing', 'challenge', 'charSet', 'checked', 'cite', 'classID', 'className', 'color', 'cols', 'colSpan', 'content', 'contentEditable', 'contextMenu', 'controls', 'coords', 'crossOrigin', 'data', 'datatype', 'dateTime', 'default', 'defaultChecked', 'defaultValue', 'defer', 'dir', 'disabled', 'download', 'draggable', 'encType', 'form', 'formAction', 'formEncType', 'formMethod', 'formNoValidate', 'formTarget', 'frameBorder', 'headers', 'height', 'hidden', 'high', 'href', 'hrefLang', 'htmlFor', 'httpEquiv', 'id', 'inlist', 'inputMode', 'integrity', 'is', 'itemID', 'itemProp', 'itemRef', 'itemScope', 'itemType', 'keyParams', 'keyType', 'kind', 'label', 'lang', 'list', 'loop', 'low', 'manifest', 'marginHeight', 'marginWidth', 'max', 'maxLength', 'media', 'mediaGroup', 'method', 'min', 'minLength', 'multiple', 'muted', 'name', 'nonce', 'noValidate', 'open', 'optimum', 'pattern', 'placeholder', 'playsInline', 'poster', 'prefix', 'preload', 'property', 'radioGroup', 'readOnly', 'rel', 'required', 'resource', 'results', 'reversed', 'role', 'rows', 'rowSpan', 'sandbox', 'scope', 'scoped', 'scrolling', 'seamless', 'security', 'selected', 'shape', 'size', 'sizes', 'slot', 'span', 'spellCheck', 'src', 'srcDoc', 'srcLang', 'srcSet', 'start', 'step', 'style', 'summary', 'suppressContentEditableWarning', 'suppressHydrationWarning', 'tabIndex', 'target', 'title', 'translate', 'type', 'typeof', 'unselectable', 'useMap', 'value', 'vocab', 'width', 'wmode', 'wrap'];
|
|
10
|
-
const globalAttributes = Object.fromEntries([...ariaAttributes, ...domAttributes, ...htmlAttributes].map(entry => [entry, true]));
|
|
11
|
-
|
|
12
|
-
export { globalAttributes };
|
package/esm/globalProps/index.js
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
2
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
4
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
5
|
-
import { useMemo } from 'react';
|
|
6
|
-
import { globalAttributes } from './constants.js';
|
|
7
|
-
|
|
8
|
-
const useGetGlobalAttributes = (props, overrides) => {
|
|
9
|
-
const componentGlobalAttributes = useMemo(() => {
|
|
10
|
-
const globalAttributesObject = {};
|
|
11
|
-
Object.entries(props).forEach(_ref => {
|
|
12
|
-
let [key, value] = _ref;
|
|
13
|
-
|
|
14
|
-
if (key in globalAttributes || key.startsWith('data-')) {
|
|
15
|
-
if (overrides && key in overrides && typeof value === 'function' && typeof overrides[key] === 'function') {
|
|
16
|
-
const newFunc = function () {
|
|
17
|
-
value(...arguments);
|
|
18
|
-
overrides[key](...arguments);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
globalAttributesObject[key] = newFunc;
|
|
22
|
-
} else {
|
|
23
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
|
|
24
|
-
globalAttributesObject[key] = value;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
});
|
|
28
|
-
return globalAttributesObject;
|
|
29
|
-
}, [props, overrides]);
|
|
30
|
-
return componentGlobalAttributes;
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
export { useGetGlobalAttributes };
|
package/esm/index.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export { useMemoMergePropsWithDefault } from './defaultProps/useMemoMergePropsWithDefault.js';
|
|
2
|
-
export { getAriaProps, getDataProps } from './getProps/index.js';
|
|
3
|
-
export { useGetGlobalAttributes } from './globalProps/useGetGlobalAttributes.js';
|
|
4
|
-
export { globalAttributesPropTypes } from './globalProps/globalAttributesPropTypes.js';
|
|
5
|
-
export { default as PropTypes } from './propTypes/PropTypes.js';
|
|
6
|
-
export { default as describe } from './propTypes/describe.js';
|
|
7
|
-
export { useValidatePropTypes } from './validation/validator.js';
|
|
8
|
-
export { throwRequiredError, throwTypeError } from './validation/errorTemplates.js';
|
|
9
|
-
export { useValidateTypescriptPropTypes, validateTypescriptPropTypesImplementation } from './validation/typescriptValidator.js';
|
|
10
|
-
export { useGetXstyledProps } from './xstyledProps/useGetXstyledProps.js';
|
|
11
|
-
export { xstyledPropTypes } from './xstyledProps/xstyledPropTypes.js';
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
-
import 'core-js/modules/esnext.iterator.filter.js';
|
|
3
|
-
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
4
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
6
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
7
|
-
|
|
8
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
9
|
-
|
|
10
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
11
|
-
|
|
12
|
-
const addPropTypeDocumentationField = fieldName => function addFieldToReactDesc(value) {
|
|
13
|
-
if (!this.reactDesc) {
|
|
14
|
-
this.reactDesc = {};
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
let realValue = value;
|
|
18
|
-
if (fieldName === 'global' || fieldName === 'hidden' || fieldName === 'xstyled') realValue = true;
|
|
19
|
-
this.reactDesc[fieldName] = realValue;
|
|
20
|
-
return this;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
const documentedPropType = {
|
|
24
|
-
defaultValue: addPropTypeDocumentationField('defaultValue'),
|
|
25
|
-
description: addPropTypeDocumentationField('description'),
|
|
26
|
-
deprecated: addPropTypeDocumentationField('deprecated'),
|
|
27
|
-
format: addPropTypeDocumentationField('format'),
|
|
28
|
-
global: addPropTypeDocumentationField('global'),
|
|
29
|
-
hidden: addPropTypeDocumentationField('hidden'),
|
|
30
|
-
xstyled: addPropTypeDocumentationField('hidden')
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const createPropType = type => {
|
|
34
|
-
const propTypeObj = _objectSpread({
|
|
35
|
-
type
|
|
36
|
-
}, documentedPropType);
|
|
37
|
-
|
|
38
|
-
Object.defineProperty(propTypeObj, 'isRequired', {
|
|
39
|
-
get: function getRequired() {
|
|
40
|
-
if (!this.reactDesc) {
|
|
41
|
-
this.reactDesc = {};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
this.reactDesc.required = true;
|
|
45
|
-
return this;
|
|
46
|
-
},
|
|
47
|
-
enumerable: true,
|
|
48
|
-
configurable: true
|
|
49
|
-
});
|
|
50
|
-
return propTypeObj;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const createPropTypeWithArgs = type => args => {
|
|
54
|
-
const propTypeObj = _objectSpread({
|
|
55
|
-
args,
|
|
56
|
-
type
|
|
57
|
-
}, documentedPropType);
|
|
58
|
-
|
|
59
|
-
Object.defineProperty(propTypeObj, 'isRequired', {
|
|
60
|
-
get: function getRequired() {
|
|
61
|
-
if (!this.reactDesc) {
|
|
62
|
-
this.reactDesc = {};
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
this.reactDesc.required = true;
|
|
66
|
-
return this;
|
|
67
|
-
},
|
|
68
|
-
enumerable: true,
|
|
69
|
-
configurable: true
|
|
70
|
-
});
|
|
71
|
-
return propTypeObj;
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
const PropTypes = {
|
|
75
|
-
custom: callback => {
|
|
76
|
-
const target = callback.bind(null);
|
|
77
|
-
target.type = 'func';
|
|
78
|
-
Object.keys(documentedPropType).forEach(fieldName => {
|
|
79
|
-
const fieldNameCasted = fieldName; // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
|
|
80
|
-
|
|
81
|
-
target[fieldNameCasted] = documentedPropType[fieldNameCasted];
|
|
82
|
-
});
|
|
83
|
-
return target;
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
function definePropType(type) {
|
|
88
|
-
Object.defineProperty(PropTypes, type, {
|
|
89
|
-
get: function getPropType() {
|
|
90
|
-
return createPropType(type);
|
|
91
|
-
},
|
|
92
|
-
enumerable: true,
|
|
93
|
-
configurable: true
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function definePropTypeWithArgs(type) {
|
|
98
|
-
Object.defineProperty(PropTypes, type, {
|
|
99
|
-
get: function getPropType() {
|
|
100
|
-
return createPropTypeWithArgs(type);
|
|
101
|
-
},
|
|
102
|
-
enumerable: true,
|
|
103
|
-
configurable: true
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
definePropType('any');
|
|
108
|
-
definePropType('array');
|
|
109
|
-
definePropType('bool');
|
|
110
|
-
definePropType('element');
|
|
111
|
-
definePropType('func');
|
|
112
|
-
definePropType('node');
|
|
113
|
-
definePropType('number');
|
|
114
|
-
definePropType('object');
|
|
115
|
-
definePropType('symbol');
|
|
116
|
-
definePropType('string');
|
|
117
|
-
definePropTypeWithArgs('arrayOf');
|
|
118
|
-
definePropTypeWithArgs('instanceOf');
|
|
119
|
-
definePropTypeWithArgs('objectOf');
|
|
120
|
-
definePropTypeWithArgs('oneOfType');
|
|
121
|
-
definePropTypeWithArgs('oneOf');
|
|
122
|
-
definePropTypeWithArgs('shape');
|
|
123
|
-
definePropTypeWithArgs('tuple');
|
|
124
|
-
|
|
125
|
-
export { PropTypes as default };
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
|
-
|
|
3
|
-
/* eslint-disable max-params */
|
|
4
|
-
const tupleValidator = tupleShape => {
|
|
5
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
|
|
6
|
-
const func = function (value, index) {
|
|
7
|
-
for (var _len = arguments.length, rest = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
8
|
-
rest[_key - 2] = arguments[_key];
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return tupleShape[index](value, index, ...rest);
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
return func;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export { tupleValidator };
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
2
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
4
|
-
import { convertPropType } from './describeConversions.js';
|
|
5
|
-
import descToTypescript from './toTypescript.js';
|
|
6
|
-
|
|
7
|
-
function describe(ComponentInstance) {
|
|
8
|
-
if (!ComponentInstance) {
|
|
9
|
-
throw new Error('react-desc: component is required');
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
const documentation = {
|
|
13
|
-
propTypes: {}
|
|
14
|
-
};
|
|
15
|
-
const DocumentedComponent = ComponentInstance;
|
|
16
|
-
|
|
17
|
-
const addDocumentationProp = propName => {
|
|
18
|
-
const func = value => {
|
|
19
|
-
documentation[propName] = value;
|
|
20
|
-
return DocumentedComponent;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
return func;
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
DocumentedComponent.availableAt = addDocumentationProp('availableAt');
|
|
27
|
-
DocumentedComponent.description = addDocumentationProp('description');
|
|
28
|
-
DocumentedComponent.details = addDocumentationProp('details');
|
|
29
|
-
DocumentedComponent.deprecated = addDocumentationProp('deprecated');
|
|
30
|
-
DocumentedComponent.usage = addDocumentationProp('usage');
|
|
31
|
-
DocumentedComponent.intrinsicElement = addDocumentationProp('intrinsicElement');
|
|
32
|
-
|
|
33
|
-
DocumentedComponent.toTypescript = () => descToTypescript(ComponentInstance, documentation);
|
|
34
|
-
|
|
35
|
-
Object.defineProperty(DocumentedComponent, 'propTypes', {
|
|
36
|
-
get: () => DocumentedComponent.propTypesValue,
|
|
37
|
-
set: value => {
|
|
38
|
-
if (!DocumentedComponent.propTypesValue) {
|
|
39
|
-
DocumentedComponent.propTypesValue = {};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
Object.keys(value).forEach(name => {
|
|
43
|
-
const propType = value[name];
|
|
44
|
-
let realPropType;
|
|
45
|
-
documentation.propTypes[name] = propType;
|
|
46
|
-
realPropType = convertPropType(propType);
|
|
47
|
-
|
|
48
|
-
if (value[name].reactDesc.required) {
|
|
49
|
-
realPropType = realPropType.isRequired;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
DocumentedComponent.propTypesValue[name] = realPropType;
|
|
53
|
-
return propType;
|
|
54
|
-
});
|
|
55
|
-
},
|
|
56
|
-
enumerable: true,
|
|
57
|
-
configurable: true
|
|
58
|
-
});
|
|
59
|
-
return DocumentedComponent;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export { describe as default };
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
2
|
-
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
3
|
-
import 'core-js/modules/esnext.iterator.map.js';
|
|
4
|
-
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
-
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
6
|
-
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
7
|
-
import PropTypes from 'prop-types';
|
|
8
|
-
import { tupleValidator } from './customPropTypes.js';
|
|
9
|
-
import { hasArguments, isOneOfType, isArrayOf, isShape, isInstanceOf, isOneOf, isObjectOf, isExact } from './describeGuards.js';
|
|
10
|
-
|
|
11
|
-
const enrichPropType = (propType, reactDesc) => {
|
|
12
|
-
const func = function (props, propName, componentName) {
|
|
13
|
-
if (reactDesc && reactDesc.deprecated && propName in props && !reactDesc.warned) {
|
|
14
|
-
const {
|
|
15
|
-
version = '',
|
|
16
|
-
message = ''
|
|
17
|
-
} = reactDesc.deprecated;
|
|
18
|
-
const warning = "\"".concat(propName, "\" property of \"").concat(componentName, "\" will be deprecated on VERSION: ").concat(version, ".\n").concat(message);
|
|
19
|
-
console.warn(warning);
|
|
20
|
-
reactDesc.warned = true;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
for (var _len = arguments.length, rest = new Array(_len > 3 ? _len - 3 : 0), _key = 3; _key < _len; _key++) {
|
|
24
|
-
rest[_key - 3] = arguments[_key];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return propType(props, propName, componentName, ...rest);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
Object.defineProperty(func, 'isRequired', Object.getOwnPropertyDescriptor(propType, 'isRequired'));
|
|
31
|
-
return func;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
const convertArray = array => array.map(type => convertPropType(type));
|
|
35
|
-
|
|
36
|
-
const convertShape = _shape => {
|
|
37
|
-
const result = {};
|
|
38
|
-
Object.keys(_shape).forEach(key => {
|
|
39
|
-
result[key] = convertPropType(_shape[key]);
|
|
40
|
-
});
|
|
41
|
-
return result;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const convertPropType = propType => {
|
|
45
|
-
if (!propType || !propType.type) {
|
|
46
|
-
throw new Error("react-desc: unknown error -- proptype is not well defined");
|
|
47
|
-
} // DimSum PropTypes conversion
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (propType.type === 'tuple') {
|
|
51
|
-
return enrichPropType(PropTypes.arrayOf(tupleValidator(convertArray(propType.args))), propType.reactDesc);
|
|
52
|
-
} // Default PropType conversion
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const realPropType = PropTypes[propType.type];
|
|
56
|
-
|
|
57
|
-
if (!realPropType) {
|
|
58
|
-
throw new Error("react-desc: unknown type ".concat(propType.type));
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
if (hasArguments(propType)) {
|
|
62
|
-
if (isOneOfType(propType)) {
|
|
63
|
-
return enrichPropType(realPropType(convertArray(propType.args)), propType.reactDesc);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
if (isArrayOf(propType)) {
|
|
67
|
-
return enrichPropType(realPropType(convertPropType(propType.args)), propType.reactDesc);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
if (isShape(propType)) {
|
|
71
|
-
return enrichPropType(realPropType(convertShape(propType.args)), propType.reactDesc);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
if (isInstanceOf(propType)) {
|
|
75
|
-
return enrichPropType(realPropType(propType.args), propType.reactDesc);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
if (isOneOf(propType)) {
|
|
79
|
-
return enrichPropType(realPropType(propType.args), propType.reactDesc);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
if (isObjectOf(propType)) {
|
|
83
|
-
return enrichPropType(realPropType(propType.args), propType.reactDesc);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
if (isExact(propType)) {
|
|
87
|
-
return enrichPropType(realPropType(propType.args), propType.reactDesc);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
throw new Error("react-desc: unknown error -- proptype with args is not matching");
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
return enrichPropType(realPropType, propType.reactDesc);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
export { convertPropType };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
const hasArguments = (propType, realPropType) => !!propType.args;
|
|
2
|
-
const isOneOfType = (propType, realPropType) => propType.type === 'oneOfType';
|
|
3
|
-
const isArrayOf = (propType, realPropType) => propType.type === 'arrayOf';
|
|
4
|
-
const isShape = (propType, realPropType) => propType.type === 'shape';
|
|
5
|
-
const isInstanceOf = (propType, realPropType) => propType.type === 'instanceOf';
|
|
6
|
-
const isOneOf = (propType, realPropType) => propType.type === 'oneOf';
|
|
7
|
-
const isObjectOf = (propType, realPropType) => propType.type === 'objectOf';
|
|
8
|
-
const isExact = (propType, realPropType) => propType.type === 'exact';
|
|
9
|
-
|
|
10
|
-
export { hasArguments, isArrayOf, isExact, isInstanceOf, isObjectOf, isOneOf, isOneOfType, isShape };
|
package/esm/propTypes/index.js
DELETED