@elliemae/ds-utilities 3.0.0-next.5 → 3.0.0-next.53
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/capitalize.js +9 -16
- package/dist/cjs/capitalize.js.map +1 -1
- package/dist/cjs/compose.js +9 -16
- package/dist/cjs/compose.js.map +2 -2
- package/dist/cjs/deprecated/deprecatedMsg.js +28 -0
- package/dist/cjs/deprecated/deprecatedMsg.js.map +7 -0
- package/dist/cjs/deprecated/index.js +27 -0
- package/dist/cjs/deprecated/index.js.map +7 -0
- package/dist/cjs/deprecated/reactTypesUtility.js +53 -0
- package/dist/cjs/deprecated/reactTypesUtility.js.map +7 -0
- package/dist/cjs/deprecated/scrollingTimer.js +41 -0
- package/dist/cjs/deprecated/scrollingTimer.js.map +7 -0
- package/dist/cjs/deprecated/useParentElement.js +36 -0
- package/dist/cjs/deprecated/useParentElement.js.map +7 -0
- package/dist/cjs/deprecated/useSetRef.js +37 -0
- package/dist/cjs/deprecated/useSetRef.js.map +7 -0
- package/dist/cjs/deprecated/useUncontrolled.js +33 -0
- package/dist/cjs/deprecated/useUncontrolled.js.map +7 -0
- package/dist/cjs/{hooks → deprecated}/useWindowSize.js +15 -18
- package/dist/cjs/deprecated/useWindowSize.js.map +7 -0
- package/dist/cjs/getComponentFromProps.js +10 -17
- package/dist/cjs/getComponentFromProps.js.map +2 -2
- package/dist/cjs/hooks/index.js +13 -25
- package/dist/cjs/hooks/index.js.map +2 -2
- package/dist/cjs/hooks/useCallbackAfterRender.js +10 -17
- package/dist/cjs/hooks/useCallbackAfterRender.js.map +2 -2
- package/dist/cjs/hooks/useCancellableDelayedCallback.js +9 -16
- package/dist/cjs/hooks/useCancellableDelayedCallback.js.map +2 -2
- package/dist/cjs/hooks/useDerivedStateFromProps.js +9 -16
- package/dist/cjs/hooks/useDerivedStateFromProps.js.map +2 -2
- package/dist/cjs/hooks/useExecutionTimer.js +13 -18
- package/dist/cjs/hooks/useExecutionTimer.js.map +2 -2
- package/dist/cjs/hooks/useExpandState.js +9 -16
- package/dist/cjs/hooks/useExpandState.js.map +2 -2
- package/dist/cjs/hooks/useFocusTrap.js +75 -28
- package/dist/cjs/hooks/useFocusTrap.js.map +2 -2
- package/dist/cjs/hooks/useHotkeys.js +10 -17
- package/dist/cjs/hooks/useHotkeys.js.map +2 -2
- package/dist/cjs/hooks/useHoverHandlersDelay.js +15 -20
- package/dist/cjs/hooks/useHoverHandlersDelay.js.map +2 -2
- package/dist/cjs/hooks/useIsMobile.js +50 -0
- package/dist/cjs/hooks/useIsMobile.js.map +7 -0
- package/dist/cjs/hooks/useIsShowingEllipsis.js +9 -16
- package/dist/cjs/hooks/useIsShowingEllipsis.js.map +1 -1
- package/dist/cjs/hooks/useOnElementResize.js +9 -16
- package/dist/cjs/hooks/useOnElementResize.js.map +1 -1
- package/dist/cjs/hooks/usePrevious.js +9 -16
- package/dist/cjs/hooks/usePrevious.js.map +2 -2
- package/dist/cjs/hooks/useResizeObserver.js +12 -19
- package/dist/cjs/hooks/useResizeObserver.js.map +2 -2
- package/dist/cjs/hooks/useShouldRecalculate.js +9 -16
- package/dist/cjs/hooks/useShouldRecalculate.js.map +2 -2
- package/dist/cjs/hooks/useWindowScrollerList.js +20 -25
- package/dist/cjs/hooks/useWindowScrollerList.js.map +2 -2
- package/dist/cjs/index.js +17 -27
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/objectUtilities.js +30 -0
- package/dist/cjs/objectUtilities.js.map +7 -0
- package/dist/cjs/onClickHandlerForNonInteractiveElements.js +11 -18
- package/dist/cjs/onClickHandlerForNonInteractiveElements.js.map +2 -2
- package/dist/cjs/operators.js +9 -16
- package/dist/cjs/operators.js.map +2 -2
- package/dist/cjs/platform.js +9 -16
- package/dist/cjs/platform.js.map +1 -1
- package/dist/cjs/props-helpers/defaultProps/index.js +22 -0
- package/dist/cjs/props-helpers/defaultProps/index.js.map +7 -0
- package/dist/cjs/props-helpers/defaultProps/useMemoMergePropsWithDefault.js +55 -0
- package/dist/cjs/props-helpers/defaultProps/useMemoMergePropsWithDefault.js.map +7 -0
- package/dist/cjs/props-helpers/getProps/index.js +30 -0
- package/dist/cjs/props-helpers/getProps/index.js.map +7 -0
- package/dist/cjs/props-helpers/globalProps/constants.js +390 -0
- package/dist/cjs/props-helpers/globalProps/constants.js.map +7 -0
- package/dist/cjs/props-helpers/globalProps/getGlobalAttributes.js +45 -0
- package/dist/cjs/props-helpers/globalProps/getGlobalAttributes.js.map +7 -0
- package/dist/cjs/props-helpers/globalProps/globalAttributesPropTypes.js +391 -0
- package/dist/cjs/props-helpers/globalProps/globalAttributesPropTypes.js.map +7 -0
- package/dist/cjs/props-helpers/globalProps/index.js +24 -0
- package/dist/cjs/props-helpers/globalProps/index.js.map +7 -0
- package/dist/cjs/props-helpers/globalProps/useGetGlobalAttributes.js +33 -0
- package/dist/cjs/props-helpers/globalProps/useGetGlobalAttributes.js.map +7 -0
- package/dist/cjs/props-helpers/index.js +28 -0
- package/dist/cjs/props-helpers/index.js.map +7 -0
- package/dist/cjs/props-helpers/propTypes/PropTypes.js +144 -0
- package/dist/cjs/props-helpers/propTypes/PropTypes.js.map +7 -0
- package/dist/cjs/props-helpers/propTypes/customPropTypes.js +31 -0
- package/dist/cjs/props-helpers/propTypes/customPropTypes.js.map +7 -0
- package/dist/cjs/props-helpers/propTypes/describe.js +74 -0
- package/dist/cjs/props-helpers/propTypes/describe.js.map +7 -0
- package/dist/cjs/props-helpers/propTypes/describeConversions.js +89 -0
- package/dist/cjs/props-helpers/propTypes/describeConversions.js.map +7 -0
- package/dist/cjs/props-helpers/propTypes/describeGuards.js +42 -0
- package/dist/cjs/props-helpers/propTypes/describeGuards.js.map +7 -0
- package/dist/cjs/props-helpers/propTypes/index.js +30 -0
- package/dist/cjs/props-helpers/propTypes/index.js.map +7 -0
- package/dist/cjs/props-helpers/propTypes/toTypescript.js +147 -0
- package/dist/cjs/props-helpers/propTypes/toTypescript.js.map +7 -0
- package/dist/cjs/props-helpers/propTypes/types.js +20 -0
- package/dist/cjs/props-helpers/propTypes/types.js.map +7 -0
- package/dist/cjs/props-helpers/tests/globalProps/TestComponent.js +47 -0
- package/dist/cjs/props-helpers/tests/globalProps/TestComponent.js.map +7 -0
- package/dist/cjs/props-helpers/tests/validation/test.schema.js +62 -0
- package/dist/cjs/props-helpers/tests/validation/test.schema.js.map +7 -0
- package/dist/cjs/props-helpers/tests/xstyledProps/TestComponent.js +53 -0
- package/dist/cjs/props-helpers/tests/xstyledProps/TestComponent.js.map +7 -0
- package/dist/cjs/props-helpers/useDeprecateComponent/index.js +33 -0
- package/dist/cjs/props-helpers/useDeprecateComponent/index.js.map +7 -0
- package/dist/cjs/props-helpers/validation/errorTemplates.js +41 -0
- package/dist/cjs/props-helpers/validation/errorTemplates.js.map +7 -0
- package/dist/cjs/props-helpers/validation/index.js +23 -0
- package/dist/cjs/props-helpers/validation/index.js.map +7 -0
- package/dist/cjs/props-helpers/validation/typescriptGuards.js +76 -0
- package/dist/cjs/props-helpers/validation/typescriptGuards.js.map +7 -0
- package/dist/cjs/props-helpers/validation/typescriptParsers.js +69 -0
- package/dist/cjs/props-helpers/validation/typescriptParsers.js.map +7 -0
- package/dist/cjs/props-helpers/validation/typescriptValidator.js +170 -0
- package/dist/cjs/props-helpers/validation/typescriptValidator.js.map +7 -0
- package/dist/cjs/props-helpers/xstyledProps/constants.js +81 -0
- package/dist/cjs/props-helpers/xstyledProps/constants.js.map +7 -0
- package/dist/cjs/props-helpers/xstyledProps/index.js +23 -0
- package/dist/cjs/props-helpers/xstyledProps/index.js.map +7 -0
- package/dist/cjs/props-helpers/xstyledProps/useGetXstyledProps.js +41 -0
- package/dist/cjs/props-helpers/xstyledProps/useGetXstyledProps.js.map +7 -0
- package/dist/cjs/props-helpers/xstyledProps/xstyledPropTypes.js +85 -0
- package/dist/cjs/props-helpers/xstyledProps/xstyledPropTypes.js.map +7 -0
- package/dist/cjs/reactTypesUtility.js +12 -40
- package/dist/cjs/reactTypesUtility.js.map +2 -2
- package/dist/cjs/system.js +14 -26
- package/dist/cjs/system.js.map +2 -2
- package/dist/cjs/timeUtils.js +9 -16
- package/dist/cjs/timeUtils.js.map +2 -2
- package/dist/cjs/utils.js +15 -19
- package/dist/cjs/utils.js.map +2 -2
- package/dist/cjs/validations.js +13 -22
- package/dist/cjs/validations.js.map +2 -2
- package/dist/esm/capitalize.js.map +1 -1
- package/dist/esm/compose.js.map +2 -2
- package/dist/esm/deprecated/deprecatedMsg.js +6 -0
- package/dist/esm/deprecated/deprecatedMsg.js.map +7 -0
- package/dist/esm/deprecated/index.js +8 -0
- package/dist/esm/deprecated/index.js.map +7 -0
- package/dist/esm/deprecated/reactTypesUtility.js +31 -0
- package/dist/esm/deprecated/reactTypesUtility.js.map +7 -0
- package/dist/esm/{scrollingTimer.js → deprecated/scrollingTimer.js} +5 -3
- package/dist/esm/deprecated/scrollingTimer.js.map +7 -0
- package/dist/esm/{hooks → deprecated}/useParentElement.js +0 -0
- package/dist/esm/deprecated/useParentElement.js.map +7 -0
- package/dist/esm/{hooks → deprecated}/useSetRef.js +2 -0
- package/dist/esm/deprecated/useSetRef.js.map +7 -0
- package/dist/esm/deprecated/useUncontrolled.js +11 -0
- package/dist/esm/deprecated/useUncontrolled.js.map +7 -0
- package/dist/esm/{hooks → deprecated}/useWindowSize.js +6 -2
- package/dist/esm/deprecated/useWindowSize.js.map +7 -0
- package/dist/esm/getComponentFromProps.js +1 -1
- package/dist/esm/getComponentFromProps.js.map +2 -2
- package/dist/esm/hooks/index.js +5 -10
- package/dist/esm/hooks/index.js.map +2 -2
- package/dist/esm/hooks/useCallbackAfterRender.js +2 -2
- package/dist/esm/hooks/useCallbackAfterRender.js.map +2 -2
- package/dist/esm/hooks/useCancellableDelayedCallback.js.map +2 -2
- package/dist/esm/hooks/useDerivedStateFromProps.js.map +2 -2
- package/dist/esm/hooks/useExecutionTimer.js +4 -2
- package/dist/esm/hooks/useExecutionTimer.js.map +2 -2
- package/dist/esm/hooks/useExpandState.js.map +2 -2
- package/dist/esm/hooks/useFocusTrap.js +67 -13
- package/dist/esm/hooks/useFocusTrap.js.map +2 -2
- package/dist/esm/hooks/useHotkeys.js +1 -1
- package/dist/esm/hooks/useHotkeys.js.map +2 -2
- package/dist/esm/hooks/useHoverHandlersDelay.js +6 -4
- package/dist/esm/hooks/useHoverHandlersDelay.js.map +2 -2
- package/dist/esm/hooks/useIsMobile.js +28 -0
- package/dist/esm/hooks/useIsMobile.js.map +7 -0
- package/dist/esm/hooks/useIsShowingEllipsis.js.map +1 -1
- package/dist/esm/hooks/useOnElementResize.js.map +1 -1
- package/dist/esm/hooks/usePrevious.js.map +2 -2
- package/dist/esm/hooks/useResizeObserver.js +4 -4
- package/dist/esm/hooks/useResizeObserver.js.map +2 -2
- package/dist/esm/hooks/useShouldRecalculate.js.map +2 -2
- package/dist/esm/hooks/useWindowScrollerList.js +12 -10
- package/dist/esm/hooks/useWindowScrollerList.js.map +2 -2
- package/dist/esm/index.js +11 -24
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/objectUtilities.js +8 -0
- package/dist/esm/objectUtilities.js.map +7 -0
- package/dist/esm/onClickHandlerForNonInteractiveElements.js +2 -2
- package/dist/esm/onClickHandlerForNonInteractiveElements.js.map +2 -2
- package/dist/esm/operators.js.map +2 -2
- package/dist/esm/props-helpers/defaultProps/index.js +3 -0
- package/dist/esm/props-helpers/defaultProps/index.js.map +7 -0
- package/dist/esm/props-helpers/defaultProps/useMemoMergePropsWithDefault.js +35 -0
- package/dist/esm/props-helpers/defaultProps/useMemoMergePropsWithDefault.js.map +7 -0
- package/dist/esm/props-helpers/getProps/index.js +8 -0
- package/dist/esm/props-helpers/getProps/index.js.map +7 -0
- package/dist/esm/props-helpers/globalProps/constants.js +368 -0
- package/dist/esm/props-helpers/globalProps/constants.js.map +7 -0
- package/dist/esm/props-helpers/globalProps/getGlobalAttributes.js +23 -0
- package/dist/esm/props-helpers/globalProps/getGlobalAttributes.js.map +7 -0
- package/dist/esm/props-helpers/globalProps/globalAttributesPropTypes.js +369 -0
- package/dist/esm/props-helpers/globalProps/globalAttributesPropTypes.js.map +7 -0
- package/dist/esm/props-helpers/globalProps/index.js +5 -0
- package/dist/esm/props-helpers/globalProps/index.js.map +7 -0
- package/dist/esm/props-helpers/globalProps/useGetGlobalAttributes.js +11 -0
- package/dist/esm/props-helpers/globalProps/useGetGlobalAttributes.js.map +7 -0
- package/dist/esm/props-helpers/index.js +9 -0
- package/dist/esm/props-helpers/index.js.map +7 -0
- package/dist/esm/props-helpers/propTypes/PropTypes.js +124 -0
- package/dist/esm/props-helpers/propTypes/PropTypes.js.map +7 -0
- package/dist/esm/props-helpers/propTypes/customPropTypes.js +9 -0
- package/dist/esm/props-helpers/propTypes/customPropTypes.js.map +7 -0
- package/dist/esm/props-helpers/propTypes/describe.js +52 -0
- package/dist/esm/props-helpers/propTypes/describe.js.map +7 -0
- package/dist/esm/props-helpers/propTypes/describeConversions.js +76 -0
- package/dist/esm/props-helpers/propTypes/describeConversions.js.map +7 -0
- package/dist/esm/props-helpers/propTypes/describeGuards.js +20 -0
- package/dist/esm/props-helpers/propTypes/describeGuards.js.map +7 -0
- package/dist/esm/props-helpers/propTypes/index.js +8 -0
- package/dist/esm/props-helpers/propTypes/index.js.map +7 -0
- package/dist/esm/props-helpers/propTypes/toTypescript.js +127 -0
- package/dist/esm/props-helpers/propTypes/toTypescript.js.map +7 -0
- package/dist/esm/props-helpers/propTypes/types.js +2 -0
- package/dist/esm/props-helpers/propTypes/types.js.map +7 -0
- package/dist/esm/props-helpers/tests/globalProps/TestComponent.js +27 -0
- package/dist/esm/props-helpers/tests/globalProps/TestComponent.js.map +7 -0
- package/dist/esm/props-helpers/tests/validation/test.schema.js +40 -0
- package/dist/esm/props-helpers/tests/validation/test.schema.js.map +7 -0
- package/dist/esm/props-helpers/tests/xstyledProps/TestComponent.js +33 -0
- package/dist/esm/props-helpers/tests/xstyledProps/TestComponent.js.map +7 -0
- package/dist/esm/props-helpers/useDeprecateComponent/index.js +11 -0
- package/dist/esm/props-helpers/useDeprecateComponent/index.js.map +7 -0
- package/dist/esm/props-helpers/validation/errorTemplates.js +19 -0
- package/dist/esm/props-helpers/validation/errorTemplates.js.map +7 -0
- package/dist/esm/props-helpers/validation/index.js +4 -0
- package/dist/esm/props-helpers/validation/index.js.map +7 -0
- package/dist/esm/props-helpers/validation/typescriptGuards.js +54 -0
- package/dist/esm/props-helpers/validation/typescriptGuards.js.map +7 -0
- package/dist/esm/props-helpers/validation/typescriptParsers.js +47 -0
- package/dist/esm/props-helpers/validation/typescriptParsers.js.map +7 -0
- package/dist/esm/props-helpers/validation/typescriptValidator.js +159 -0
- package/dist/esm/props-helpers/validation/typescriptValidator.js.map +7 -0
- package/dist/esm/props-helpers/xstyledProps/constants.js +59 -0
- package/dist/esm/props-helpers/xstyledProps/constants.js.map +7 -0
- package/dist/esm/props-helpers/xstyledProps/index.js +4 -0
- package/dist/esm/props-helpers/xstyledProps/index.js.map +7 -0
- package/dist/esm/props-helpers/xstyledProps/useGetXstyledProps.js +19 -0
- package/dist/esm/props-helpers/xstyledProps/useGetXstyledProps.js.map +7 -0
- package/dist/esm/props-helpers/xstyledProps/xstyledPropTypes.js +63 -0
- package/dist/esm/props-helpers/xstyledProps/xstyledPropTypes.js.map +7 -0
- package/dist/esm/reactTypesUtility.js +3 -24
- package/dist/esm/reactTypesUtility.js.map +2 -2
- package/dist/esm/system.js +5 -10
- package/dist/esm/system.js.map +2 -2
- package/dist/esm/timeUtils.js.map +2 -2
- package/dist/esm/utils.js +6 -3
- package/dist/esm/utils.js.map +2 -2
- package/dist/esm/validations.js +4 -6
- package/dist/esm/validations.js.map +2 -2
- package/package.json +10 -9
- package/dist/cjs/hooks/useParentElement.js +0 -43
- package/dist/cjs/hooks/useParentElement.js.map +0 -7
- package/dist/cjs/hooks/useSetRef.js +0 -42
- package/dist/cjs/hooks/useSetRef.js.map +0 -7
- package/dist/cjs/hooks/useWindowSize.js.map +0 -7
- package/dist/cjs/scrollingTimer.js +0 -46
- package/dist/cjs/scrollingTimer.js.map +0 -7
- package/dist/esm/hooks/useParentElement.js.map +0 -7
- package/dist/esm/hooks/useSetRef.js.map +0 -7
- package/dist/esm/hooks/useWindowSize.js.map +0 -7
- package/dist/esm/scrollingTimer.js.map +0 -7
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
8
|
+
var __spreadValues = (a, b) => {
|
|
9
|
+
for (var prop in b || (b = {}))
|
|
10
|
+
if (__hasOwnProp.call(b, prop))
|
|
11
|
+
__defNormalProp(a, prop, b[prop]);
|
|
12
|
+
if (__getOwnPropSymbols)
|
|
13
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
14
|
+
if (__propIsEnum.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
}
|
|
17
|
+
return a;
|
|
18
|
+
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
|
+
import * as React from "react";
|
|
21
|
+
import React2 from "react";
|
|
22
|
+
import { useGetXstyledProps } from "../../xstyledProps";
|
|
23
|
+
const TestComponent = (props) => {
|
|
24
|
+
const xstyledProps = useGetXstyledProps(props);
|
|
25
|
+
props.signal(xstyledProps);
|
|
26
|
+
return /* @__PURE__ */ React2.createElement("div", __spreadProps(__spreadValues({}, xstyledProps), {
|
|
27
|
+
"data-testid": "xstyled-div"
|
|
28
|
+
}), "Some random div");
|
|
29
|
+
};
|
|
30
|
+
export {
|
|
31
|
+
TestComponent
|
|
32
|
+
};
|
|
33
|
+
//# sourceMappingURL=TestComponent.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../../scripts/build/transpile/react-shim.js", "../../../../../src/props-helpers/tests/xstyledProps/TestComponent.js"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable react/prop-types */\nimport React from 'react';\nimport { useGetXstyledProps } from '../../xstyledProps';\n\nexport const TestComponent = (props) => {\n const xstyledProps = useGetXstyledProps(props);\n\n props.signal(xstyledProps);\n\n return (\n <div {...xstyledProps} data-testid=\"xstyled-div\">\n Some random div\n </div>\n );\n};\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;AAAA;ACCA;AACA;AAEO,MAAM,gBAAgB,CAAC,UAAU;AACtC,QAAM,eAAe,mBAAmB,KAAK;AAE7C,QAAM,OAAO,YAAY;AAEzB,SACE,qCAAC,wCAAQ,eAAR;AAAA,IAAsB,eAAY;AAAA,MAAc,iBAEjD;AAEJ;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
const useDeprecateComponent = ({ componentName, version }) => {
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
console.error(`Warning: ${componentName}:: this component will be deprecated in version: ${version}.`);
|
|
6
|
+
}, [componentName, version]);
|
|
7
|
+
};
|
|
8
|
+
export {
|
|
9
|
+
useDeprecateComponent
|
|
10
|
+
};
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/props-helpers/useDeprecateComponent/index.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable no-console */\nimport { useEffect } from 'react';\n\ninterface Props {\n componentName: string;\n version: string;\n}\n\nexport const useDeprecateComponent = ({ componentName, version }: Props) => {\n useEffect(() => {\n console.error(`Warning: ${componentName}:: this component will be deprecated in version: ${version}.`);\n }, [componentName, version]);\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACCA;AAOO,MAAM,wBAAwB,CAAC,EAAE,eAAe,cAAqB;AAC1E,YAAU,MAAM;AACd,YAAQ,MAAM,YAAY,iEAAiE,UAAU;AAAA,EACvG,GAAG,CAAC,eAAe,OAAO,CAAC;AAC7B;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const throwTypeError = (componentName, validPropKey, invalidProp, validFormat) => {
|
|
3
|
+
throw new Error(`${componentName}:: You are trying to pass a not valid "${validPropKey}" property,
|
|
4
|
+
please provide a valid type.
|
|
5
|
+
|
|
6
|
+
Received: ${invalidProp} (${typeof invalidProp})
|
|
7
|
+
Expected: (${validFormat.replace("\n", " or ")})
|
|
8
|
+
`);
|
|
9
|
+
};
|
|
10
|
+
const throwRequiredError = (componentName, validPropKey) => {
|
|
11
|
+
throw new Error(`${componentName}:: Please provide a/an "${validPropKey}" property to use this component.
|
|
12
|
+
This property is required.
|
|
13
|
+
`);
|
|
14
|
+
};
|
|
15
|
+
export {
|
|
16
|
+
throwRequiredError,
|
|
17
|
+
throwTypeError
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=errorTemplates.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/props-helpers/validation/errorTemplates.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable max-params */\nexport const throwTypeError = (\n componentName: string,\n validPropKey: string,\n invalidProp: unknown,\n validFormat: string,\n): void => {\n throw new Error(\n `${componentName}:: You are trying to pass a not valid \"${validPropKey}\" property, \n please provide a valid type.\n\n Received: ${invalidProp} (${typeof invalidProp})\n Expected: (${validFormat.replace('\\n', ' or ')})\n `,\n );\n};\n\nexport const throwRequiredError = (componentName: string, validPropKey: string): void => {\n throw new Error(\n `${componentName}:: Please provide a/an \"${validPropKey}\" property to use this component. \n This property is required.\n `,\n );\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACCO,MAAM,iBAAiB,CAC5B,eACA,cACA,aACA,gBACS;AACT,QAAM,IAAI,MACR,GAAG,uDAAuD;AAAA;AAAA;AAAA,cAGhD,gBAAgB,OAAO;AAAA,eACtB,YAAY,QAAQ,MAAM,MAAM;AAAA,GAE7C;AACF;AAEO,MAAM,qBAAqB,CAAC,eAAuB,iBAA+B;AACvF,QAAM,IAAI,MACR,GAAG,wCAAwC;AAAA;AAAA,GAG7C;AACF;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/props-helpers/validation/index.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export * from './errorTemplates';\nexport * from './typescriptValidator';\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const isPrimitiveType = (format) => ["string", "number", "boolean"].includes(format);
|
|
3
|
+
const isUndefined = (format) => format === '"undefined"';
|
|
4
|
+
const isNull = (format) => format === '"null"';
|
|
5
|
+
const isUnion = (format) => {
|
|
6
|
+
let depth = 0;
|
|
7
|
+
let satisfies = false;
|
|
8
|
+
format.split("").forEach((char) => {
|
|
9
|
+
if (["{", "("].includes(char))
|
|
10
|
+
depth += 1;
|
|
11
|
+
else if (["}", ")"].includes(char))
|
|
12
|
+
depth -= 1;
|
|
13
|
+
else if (char === "|" && depth === 0)
|
|
14
|
+
satisfies = true;
|
|
15
|
+
});
|
|
16
|
+
return satisfies;
|
|
17
|
+
};
|
|
18
|
+
const isString = (format) => !isUnion(format) && format[0] === '"' && format.slice(-1) === '"';
|
|
19
|
+
const isArray = (format) => !isUnion(format) && format.slice(-2) === "[]";
|
|
20
|
+
const isObject = (format) => format === "object" || !isUnion(format) && format[0] === "{" && format.slice(-1) === "}";
|
|
21
|
+
const isFunction = (format) => {
|
|
22
|
+
if (isUnion(format))
|
|
23
|
+
return false;
|
|
24
|
+
if (!format.startsWith("((") && format.slice(-1) !== ")")
|
|
25
|
+
return false;
|
|
26
|
+
let depth = 0;
|
|
27
|
+
let arrowOccursAtDepth1 = false;
|
|
28
|
+
for (let i = 0; i < format.length; i += 1) {
|
|
29
|
+
const char = format[i];
|
|
30
|
+
if (["{", "("].includes(char))
|
|
31
|
+
depth += 1;
|
|
32
|
+
else if (["}", ")"].includes(char))
|
|
33
|
+
depth -= 1;
|
|
34
|
+
else if (i < format.length - 1 && format.slice(i, i + 2) === "=>") {
|
|
35
|
+
arrowOccursAtDepth1 = arrowOccursAtDepth1 || depth === 1;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return arrowOccursAtDepth1;
|
|
39
|
+
};
|
|
40
|
+
const isJSXorNode = (format) => !isUnion(format) && ["React.ReactNode", "JSX.Element"].includes(format);
|
|
41
|
+
const isSomethingWithParenthesis = (format) => !isUnion(format) && format[0] === "(" && format.slice(-1) === ")";
|
|
42
|
+
export {
|
|
43
|
+
isArray,
|
|
44
|
+
isFunction,
|
|
45
|
+
isJSXorNode,
|
|
46
|
+
isNull,
|
|
47
|
+
isObject,
|
|
48
|
+
isPrimitiveType,
|
|
49
|
+
isSomethingWithParenthesis,
|
|
50
|
+
isString,
|
|
51
|
+
isUndefined,
|
|
52
|
+
isUnion
|
|
53
|
+
};
|
|
54
|
+
//# sourceMappingURL=typescriptGuards.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/props-helpers/validation/typescriptGuards.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "type GuardFn = (format: string) => boolean;\n\nexport const isPrimitiveType: GuardFn = (format) => ['string', 'number', 'boolean'].includes(format);\nexport const isUndefined: GuardFn = (format) => format === '\"undefined\"';\nexport const isNull: GuardFn = (format) => format === '\"null\"';\nexport const isUnion: GuardFn = (format) => {\n let depth = 0;\n let satisfies = false;\n format.split('').forEach((char) => {\n if (['{', '('].includes(char)) depth += 1;\n else if (['}', ')'].includes(char)) depth -= 1;\n else if (char === '|' && depth === 0) satisfies = true;\n });\n return satisfies;\n};\n\nexport const isString: GuardFn = (format) => !isUnion(format) && format[0] === '\"' && format.slice(-1) === '\"';\n\nexport const isArray: GuardFn = (format) => !isUnion(format) && format.slice(-2) === '[]';\n\nexport const isObject: GuardFn = (format) =>\n format === 'object' || (!isUnion(format) && format[0] === '{' && format.slice(-1) === '}');\n\nexport const isFunction: GuardFn = (format) => {\n // It's isn't an union\n if (isUnion(format)) return false;\n // Has to start with (( and end with )\n if (!format.startsWith('((') && format.slice(-1) !== ')') return false;\n\n // The arrow MUST occur at depth 1 (when couting parenthesis)\n // Otherwise the only possibility is that we have \"something with parenthesis\" (look down below)\n let depth = 0;\n let arrowOccursAtDepth1 = false;\n for (let i = 0; i < format.length; i += 1) {\n const char = format[i];\n if (['{', '('].includes(char)) depth += 1;\n else if (['}', ')'].includes(char)) depth -= 1;\n else if (i < format.length - 1 && format.slice(i, i + 2) === '=>') {\n arrowOccursAtDepth1 = arrowOccursAtDepth1 || depth === 1;\n }\n }\n return arrowOccursAtDepth1;\n};\n\nexport const isJSXorNode: GuardFn = (format) => !isUnion(format) && ['React.ReactNode', 'JSX.Element'].includes(format);\n\nexport const isSomethingWithParenthesis: GuardFn = (format) =>\n !isUnion(format) && format[0] === '(' && format.slice(-1) === ')';\n"],
|
|
5
|
+
"mappings": "AAAA;ACEO,MAAM,kBAA2B,CAAC,WAAW,CAAC,UAAU,UAAU,SAAS,EAAE,SAAS,MAAM;AAC5F,MAAM,cAAuB,CAAC,WAAW,WAAW;AACpD,MAAM,SAAkB,CAAC,WAAW,WAAW;AAC/C,MAAM,UAAmB,CAAC,WAAW;AAC1C,MAAI,QAAQ;AACZ,MAAI,YAAY;AAChB,SAAO,MAAM,EAAE,EAAE,QAAQ,CAAC,SAAS;AACjC,QAAI,CAAC,KAAK,GAAG,EAAE,SAAS,IAAI;AAAG,eAAS;AAAA,aAC/B,CAAC,KAAK,GAAG,EAAE,SAAS,IAAI;AAAG,eAAS;AAAA,aACpC,SAAS,OAAO,UAAU;AAAG,kBAAY;AAAA,EACpD,CAAC;AACD,SAAO;AACT;AAEO,MAAM,WAAoB,CAAC,WAAW,CAAC,QAAQ,MAAM,KAAK,OAAO,OAAO,OAAO,OAAO,MAAM,EAAE,MAAM;AAEpG,MAAM,UAAmB,CAAC,WAAW,CAAC,QAAQ,MAAM,KAAK,OAAO,MAAM,EAAE,MAAM;AAE9E,MAAM,WAAoB,CAAC,WAChC,WAAW,YAAa,CAAC,QAAQ,MAAM,KAAK,OAAO,OAAO,OAAO,OAAO,MAAM,EAAE,MAAM;AAEjF,MAAM,aAAsB,CAAC,WAAW;AAE7C,MAAI,QAAQ,MAAM;AAAG,WAAO;AAE5B,MAAI,CAAC,OAAO,WAAW,IAAI,KAAK,OAAO,MAAM,EAAE,MAAM;AAAK,WAAO;AAIjE,MAAI,QAAQ;AACZ,MAAI,sBAAsB;AAC1B,WAAS,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK,GAAG;AACzC,UAAM,OAAO,OAAO;AACpB,QAAI,CAAC,KAAK,GAAG,EAAE,SAAS,IAAI;AAAG,eAAS;AAAA,aAC/B,CAAC,KAAK,GAAG,EAAE,SAAS,IAAI;AAAG,eAAS;AAAA,aACpC,IAAI,OAAO,SAAS,KAAK,OAAO,MAAM,GAAG,IAAI,CAAC,MAAM,MAAM;AACjE,4BAAsB,uBAAuB,UAAU;AAAA,IACzD;AAAA,EACF;AACA,SAAO;AACT;AAEO,MAAM,cAAuB,CAAC,WAAW,CAAC,QAAQ,MAAM,KAAK,CAAC,mBAAmB,aAAa,EAAE,SAAS,MAAM;AAE/G,MAAM,6BAAsC,CAAC,WAClD,CAAC,QAAQ,MAAM,KAAK,OAAO,OAAO,OAAO,OAAO,MAAM,EAAE,MAAM;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const typescriptObjectParser = (format) => {
|
|
3
|
+
const keyValuePairs = [];
|
|
4
|
+
let lastKey = "";
|
|
5
|
+
let lastValue = "";
|
|
6
|
+
let shouldAppendToKey = true;
|
|
7
|
+
const pushPair = () => {
|
|
8
|
+
if (lastKey)
|
|
9
|
+
keyValuePairs.push([lastKey, lastValue]);
|
|
10
|
+
lastKey = "";
|
|
11
|
+
lastValue = "";
|
|
12
|
+
shouldAppendToKey = true;
|
|
13
|
+
};
|
|
14
|
+
let depth = 0;
|
|
15
|
+
format.split("").forEach((char) => {
|
|
16
|
+
if (char === "{") {
|
|
17
|
+
depth += 1;
|
|
18
|
+
if (depth > 1)
|
|
19
|
+
lastValue += char;
|
|
20
|
+
} else if (char === "}") {
|
|
21
|
+
if (depth > 1)
|
|
22
|
+
lastValue += char;
|
|
23
|
+
depth -= 1;
|
|
24
|
+
if (depth === 1)
|
|
25
|
+
pushPair();
|
|
26
|
+
} else if (char === ":") {
|
|
27
|
+
shouldAppendToKey = false;
|
|
28
|
+
if (depth > 1)
|
|
29
|
+
lastValue += char;
|
|
30
|
+
} else if (char === ",") {
|
|
31
|
+
if (depth === 1)
|
|
32
|
+
pushPair();
|
|
33
|
+
else
|
|
34
|
+
lastValue += char;
|
|
35
|
+
} else if (char === " ") {
|
|
36
|
+
} else if (shouldAppendToKey)
|
|
37
|
+
lastKey += char;
|
|
38
|
+
else
|
|
39
|
+
lastValue += char;
|
|
40
|
+
});
|
|
41
|
+
pushPair();
|
|
42
|
+
return keyValuePairs;
|
|
43
|
+
};
|
|
44
|
+
export {
|
|
45
|
+
typescriptObjectParser
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=typescriptParsers.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/props-helpers/validation/typescriptParsers.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\nexport const typescriptObjectParser = (format: string): [string, string][] => {\n const keyValuePairs: [string, string][] = [];\n\n // State of the algorithm\n let lastKey = '';\n let lastValue = '';\n let shouldAppendToKey = true;\n\n const pushPair = () => {\n if (lastKey) keyValuePairs.push([lastKey, lastValue]);\n lastKey = '';\n lastValue = '';\n shouldAppendToKey = true;\n };\n\n // Complex -- but working -- logic\n let depth = 0;\n format.split('').forEach((char) => {\n if (char === '{') {\n depth += 1;\n if (depth > 1) lastValue += char;\n } else if (char === '}') {\n if (depth > 1) lastValue += char;\n depth -= 1;\n if (depth === 1) pushPair();\n } else if (char === ':') {\n shouldAppendToKey = false;\n if (depth > 1) lastValue += char;\n } else if (char === ',') {\n if (depth === 1) pushPair();\n else lastValue += char;\n } else if (char === ' ') {\n // Do nothing\n } else if (shouldAppendToKey) lastKey += char;\n else lastValue += char;\n });\n pushPair();\n\n return keyValuePairs;\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACCO,MAAM,yBAAyB,CAAC,WAAuC;AAC5E,QAAM,gBAAoC,CAAC;AAG3C,MAAI,UAAU;AACd,MAAI,YAAY;AAChB,MAAI,oBAAoB;AAExB,QAAM,WAAW,MAAM;AACrB,QAAI;AAAS,oBAAc,KAAK,CAAC,SAAS,SAAS,CAAC;AACpD,cAAU;AACV,gBAAY;AACZ,wBAAoB;AAAA,EACtB;AAGA,MAAI,QAAQ;AACZ,SAAO,MAAM,EAAE,EAAE,QAAQ,CAAC,SAAS;AACjC,QAAI,SAAS,KAAK;AAChB,eAAS;AACT,UAAI,QAAQ;AAAG,qBAAa;AAAA,IAC9B,WAAW,SAAS,KAAK;AACvB,UAAI,QAAQ;AAAG,qBAAa;AAC5B,eAAS;AACT,UAAI,UAAU;AAAG,iBAAS;AAAA,IAC5B,WAAW,SAAS,KAAK;AACvB,0BAAoB;AACpB,UAAI,QAAQ;AAAG,qBAAa;AAAA,IAC9B,WAAW,SAAS,KAAK;AACvB,UAAI,UAAU;AAAG,iBAAS;AAAA;AACrB,qBAAa;AAAA,IACpB,WAAW,SAAS,KAAK;AAAA,IAEzB,WAAW;AAAmB,iBAAW;AAAA;AACpC,mBAAa;AAAA,EACpB,CAAC;AACD,WAAS;AAET,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useMemo, useRef } from "react";
|
|
3
|
+
import { describe } from "../propTypes";
|
|
4
|
+
import { throwRequiredError, throwTypeError } from "./errorTemplates";
|
|
5
|
+
import {
|
|
6
|
+
isArray,
|
|
7
|
+
isFunction,
|
|
8
|
+
isJSXorNode,
|
|
9
|
+
isObject,
|
|
10
|
+
isPrimitiveType,
|
|
11
|
+
isSomethingWithParenthesis,
|
|
12
|
+
isString,
|
|
13
|
+
isUnion,
|
|
14
|
+
isUndefined,
|
|
15
|
+
isNull
|
|
16
|
+
} from "./typescriptGuards";
|
|
17
|
+
import { typescriptObjectParser } from "./typescriptParsers";
|
|
18
|
+
const validateUndefined = (schemaName, key, value, format) => {
|
|
19
|
+
if (value !== void 0 || value === "undefined") {
|
|
20
|
+
throwTypeError(schemaName, key, value, format);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
const validateNull = (schemaName, key, value, format) => {
|
|
24
|
+
if (value !== null || value === "null") {
|
|
25
|
+
throwTypeError(schemaName, key, value, format);
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const validatePrimitiveType = (schemaName, key, value, format) => {
|
|
29
|
+
if (typeof value !== format) {
|
|
30
|
+
throwTypeError(schemaName, key, value, format);
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
const validateString = (schemaName, key, value, format) => {
|
|
34
|
+
if (value !== format.slice(1, -1)) {
|
|
35
|
+
throwTypeError(schemaName, key, value, format);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const validateArray = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {
|
|
39
|
+
if (!Array.isArray(value)) {
|
|
40
|
+
throwTypeError(schemaName, key, value, format);
|
|
41
|
+
}
|
|
42
|
+
value.forEach((val, index) => {
|
|
43
|
+
validateValueWithFormat(schemaName, `${key}[${index}]`, val, format.slice(0, -2), validationsMemo, nextValidationsMemo);
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
function isObjectType(value) {
|
|
47
|
+
return !(typeof value !== "object" || Array.isArray(value));
|
|
48
|
+
}
|
|
49
|
+
const validateObject = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {
|
|
50
|
+
const valuesIsObject = isObjectType(value);
|
|
51
|
+
if (!valuesIsObject) {
|
|
52
|
+
throwTypeError(schemaName, key, value, format);
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
if (format === "object")
|
|
56
|
+
return;
|
|
57
|
+
const keyValuePairs = typescriptObjectParser(format);
|
|
58
|
+
keyValuePairs.forEach(([objectKey, objectValue]) => {
|
|
59
|
+
const trueKey = objectKey.slice(-1) === "?" ? objectKey.slice(0, -1) : objectKey;
|
|
60
|
+
if (trueKey === objectKey && !(trueKey in value)) {
|
|
61
|
+
throwRequiredError(schemaName, key);
|
|
62
|
+
}
|
|
63
|
+
if (trueKey in value) {
|
|
64
|
+
validateValueWithFormat(schemaName, `${key}[${trueKey}]`, value[trueKey], objectValue, validationsMemo, nextValidationsMemo);
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
};
|
|
68
|
+
const validateUnion = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {
|
|
69
|
+
const possibilities = format.split(/\s?\|\s?/);
|
|
70
|
+
const errors = [];
|
|
71
|
+
possibilities.forEach((possibility) => {
|
|
72
|
+
try {
|
|
73
|
+
validateValueWithFormat(schemaName, key, value, possibility, validationsMemo, nextValidationsMemo);
|
|
74
|
+
} catch (e) {
|
|
75
|
+
errors.push(e);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
if (errors.length === possibilities.length) {
|
|
79
|
+
throwTypeError(schemaName, key, value, format);
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const validateFunction = (schemaName, key, value, format) => {
|
|
83
|
+
if (typeof value !== "function") {
|
|
84
|
+
throwTypeError(schemaName, key, value, format);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
function isJSXElement(value) {
|
|
88
|
+
return value === null || typeof value === "object" && value !== null && "$$typeof" in value;
|
|
89
|
+
}
|
|
90
|
+
const validateJSXorNode = (schemaName, key, value, format) => {
|
|
91
|
+
const valueIsJSX = isJSXElement(value);
|
|
92
|
+
if (format === "JSX.Element" && !valueIsJSX) {
|
|
93
|
+
throwTypeError(schemaName, key, value, format);
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const validateValueWithFormat = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {
|
|
97
|
+
nextValidationsMemo[value] = format;
|
|
98
|
+
if (value in validationsMemo) {
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (isUndefined(format)) {
|
|
102
|
+
validateUndefined(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
|
|
103
|
+
} else if (isNull(format)) {
|
|
104
|
+
validateNull(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
|
|
105
|
+
} else if (isPrimitiveType(format)) {
|
|
106
|
+
validatePrimitiveType(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
|
|
107
|
+
} else if (isUnion(format)) {
|
|
108
|
+
validateUnion(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
|
|
109
|
+
} else if (isString(format)) {
|
|
110
|
+
validateString(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
|
|
111
|
+
} else if (isArray(format)) {
|
|
112
|
+
validateArray(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
|
|
113
|
+
} else if (isObject(format)) {
|
|
114
|
+
validateObject(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
|
|
115
|
+
} else if (isFunction(format)) {
|
|
116
|
+
validateFunction(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
|
|
117
|
+
} else if (isJSXorNode(format)) {
|
|
118
|
+
validateJSXorNode(schemaName, key, value, format, validationsMemo, nextValidationsMemo);
|
|
119
|
+
} else if (isSomethingWithParenthesis(format)) {
|
|
120
|
+
validateValueWithFormat(schemaName, key, value, format.slice(1, -1), validationsMemo, nextValidationsMemo);
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
const validateTypescriptPropTypesImplementation = (props, schema, validationsMemo = {}, nextValidationsMemo = {}) => {
|
|
124
|
+
const { properties, name: schemaName } = schema;
|
|
125
|
+
properties.forEach((property) => {
|
|
126
|
+
const { name, format, required, isRequiredIf } = property;
|
|
127
|
+
const requiredConditionally = isRequiredIf && isRequiredIf(props);
|
|
128
|
+
if (required && !(name in props)) {
|
|
129
|
+
throwRequiredError(schema.name, name);
|
|
130
|
+
}
|
|
131
|
+
if (requiredConditionally && !(name in props)) {
|
|
132
|
+
throwRequiredError(schema.name, name);
|
|
133
|
+
}
|
|
134
|
+
const shouldValidateProperty = props[name] !== void 0 || required || requiredConditionally;
|
|
135
|
+
if (name in props && format && shouldValidateProperty) {
|
|
136
|
+
validateValueWithFormat(schemaName, name, props[name], format, validationsMemo, nextValidationsMemo);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
const useValidateTypescriptPropTypes = (props, propTypes) => {
|
|
141
|
+
const validationsMemo = useRef({});
|
|
142
|
+
const typescriptSchema = useMemo(() => {
|
|
143
|
+
const Component = () => {
|
|
144
|
+
};
|
|
145
|
+
const DescribedComponent = describe(Component);
|
|
146
|
+
DescribedComponent.propTypes = propTypes;
|
|
147
|
+
return DescribedComponent.toTypescript();
|
|
148
|
+
}, [propTypes]);
|
|
149
|
+
useMemo(() => {
|
|
150
|
+
const nextValidationsMemo = {};
|
|
151
|
+
validateTypescriptPropTypesImplementation(props, typescriptSchema, validationsMemo.current, nextValidationsMemo);
|
|
152
|
+
validationsMemo.current = nextValidationsMemo;
|
|
153
|
+
}, [props]);
|
|
154
|
+
};
|
|
155
|
+
export {
|
|
156
|
+
useValidateTypescriptPropTypes,
|
|
157
|
+
validateTypescriptPropTypesImplementation
|
|
158
|
+
};
|
|
159
|
+
//# sourceMappingURL=typescriptValidator.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/props-helpers/validation/typescriptValidator.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "/* eslint-disable complexity */\n/* eslint-disable max-lines */\n/* eslint-disable max-params */\nimport { PropsWithChildren, useMemo, useRef, WeakValidationMap } from 'react';\nimport { TypescriptDocumentation } from '../propTypes/types';\nimport { describe } from '../propTypes';\nimport { throwRequiredError, throwTypeError } from './errorTemplates';\nimport {\n isArray,\n isFunction,\n isJSXorNode,\n isObject,\n isPrimitiveType,\n isSomethingWithParenthesis,\n isString,\n isUnion,\n isUndefined,\n isNull,\n} from './typescriptGuards';\nimport { typescriptObjectParser } from './typescriptParsers';\n\ntype ValidatorFn = (\n schemaName: string,\n key: string,\n value: unknown,\n format: string,\n validationsMemo: Record<symbol, string>,\n nextValidationsMemo: Record<symbol, string>,\n) => void;\n\n// =============================================================================\n// Atom Validators\n// =============================================================================\n\n// This functions will validate something from the data\n// and optionally recursively apply `validateValueWithFormat`\n// in smaller parts\n\nconst validateUndefined: ValidatorFn = (schemaName, key, value, format) => {\n if (value !== undefined || value === 'undefined') {\n throwTypeError(schemaName, key, value, format);\n }\n};\nconst validateNull: ValidatorFn = (schemaName, key, value, format) => {\n if (value !== null || value === 'null') {\n throwTypeError(schemaName, key, value, format);\n }\n};\nconst validatePrimitiveType: ValidatorFn = (schemaName, key, value, format) => {\n if (typeof value !== format) {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\nconst validateString: ValidatorFn = (schemaName, key, value, format) => {\n if (value !== format.slice(1, -1)) {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\nconst validateArray: ValidatorFn = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {\n // Check that we have an array\n if (!Array.isArray(value)) {\n throwTypeError(schemaName, key, value, format);\n }\n\n // Check that each element inside satisfies the format\n (value as unknown[]).forEach((val, index) => {\n // this is a recursive func, we need to invoke it before it's defined.\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n validateValueWithFormat(\n schemaName,\n `${key}[${index}]`,\n val,\n format.slice(0, -2),\n validationsMemo,\n nextValidationsMemo,\n );\n });\n};\nfunction isObjectType(value: unknown | Record<string, unknown>): value is Record<string, unknown> {\n return !(typeof value !== 'object' || Array.isArray(value));\n}\nconst validateObject: ValidatorFn = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {\n const valuesIsObject = isObjectType(value);\n // Check that we have an object\n if (!valuesIsObject) {\n throwTypeError(schemaName, key, value, format);\n return;\n }\n\n if (format === 'object') return;\n\n const keyValuePairs = typescriptObjectParser(format);\n // Now we have the key - value pairs\n // Each key could either be required or not\n // Just recursively check the object\n\n keyValuePairs.forEach(([objectKey, objectValue]) => {\n const trueKey = objectKey.slice(-1) === '?' ? objectKey.slice(0, -1) : objectKey;\n\n if (trueKey === objectKey && !(trueKey in value)) {\n throwRequiredError(schemaName, key);\n }\n\n if (trueKey in value) {\n // this is a recursive func, we need to invoke it before it's defined.\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n validateValueWithFormat(\n schemaName,\n `${key}[${trueKey}]`,\n value[trueKey],\n objectValue,\n validationsMemo,\n nextValidationsMemo,\n );\n }\n });\n};\n\nconst validateUnion: ValidatorFn = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {\n const possibilities = format.split(/\\s?\\|\\s?/);\n\n const errors = [];\n\n possibilities.forEach((possibility) => {\n try {\n // this is a recursive func, we need to invoke it before it's defined.\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n validateValueWithFormat(schemaName, key, value, possibility, validationsMemo, nextValidationsMemo);\n } catch (e) {\n errors.push(e);\n }\n });\n\n if (errors.length === possibilities.length) {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\nconst validateFunction: ValidatorFn = (schemaName, key, value, format) => {\n // Check that we have a function\n if (typeof value !== 'function') {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\nfunction isJSXElement(value: unknown | JSX.Element): value is JSX.Element {\n return value === null || (typeof value === 'object' && value !== null && '$$typeof' in value);\n}\nconst validateJSXorNode: ValidatorFn = (schemaName, key, value, format) => {\n const valueIsJSX = isJSXElement(value);\n if (format === 'JSX.Element' && !valueIsJSX) {\n throwTypeError(schemaName, key, value, format);\n }\n};\n\n// =============================================================================\n// Schema validator\n// =============================================================================\n\nconst validateValueWithFormat: ValidatorFn = (schemaName, key, value, format, validationsMemo, nextValidationsMemo) => {\n nextValidationsMemo[value as symbol] = format;\n\n if ((value as symbol) in validationsMemo) {\n // We already validated this value on this format\n return;\n }\n\n if (isUndefined(format)) {\n validateUndefined(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isNull(format)) {\n validateNull(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isPrimitiveType(format)) {\n validatePrimitiveType(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isUnion(format)) {\n validateUnion(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isString(format)) {\n validateString(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isArray(format)) {\n validateArray(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isObject(format)) {\n validateObject(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isFunction(format)) {\n validateFunction(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isJSXorNode(format)) {\n validateJSXorNode(schemaName, key, value, format, validationsMemo, nextValidationsMemo);\n } else if (isSomethingWithParenthesis(format)) {\n validateValueWithFormat(schemaName, key, value, format.slice(1, -1), validationsMemo, nextValidationsMemo);\n }\n};\n\nexport const validateTypescriptPropTypesImplementation = (\n props: PropsWithChildren<Record<string, unknown>>,\n schema: TypescriptDocumentation,\n validationsMemo: Record<string, string> = {},\n nextValidationsMemo: Record<string, string> = {},\n): void => {\n const { properties, name: schemaName } = schema;\n\n properties.forEach((property) => {\n const { name, format, required, isRequiredIf } = property;\n\n const requiredConditionally = isRequiredIf && isRequiredIf(props);\n\n if (required && !(name in props)) {\n throwRequiredError(schema.name, name);\n }\n\n if (requiredConditionally && !(name in props)) {\n throwRequiredError(schema.name, name);\n }\n\n const shouldValidateProperty = props[name] !== undefined || required || requiredConditionally;\n\n if (name in props && format && shouldValidateProperty) {\n validateValueWithFormat(schemaName, name, props[name], format, validationsMemo, nextValidationsMemo);\n }\n });\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const useValidateTypescriptPropTypes = <T = Record<string, any>>(\n props: PropsWithChildren<T>,\n propTypes: WeakValidationMap<unknown>,\n): void => {\n const validationsMemo = useRef<Record<string, string>>({});\n\n const typescriptSchema = useMemo(() => {\n const Component = () => {};\n\n const DescribedComponent = describe(Component);\n DescribedComponent.propTypes = propTypes;\n return DescribedComponent.toTypescript();\n }, [propTypes]);\n\n useMemo(() => {\n const nextValidationsMemo = {};\n\n validateTypescriptPropTypesImplementation(props, typescriptSchema, validationsMemo.current, nextValidationsMemo);\n validationsMemo.current = nextValidationsMemo;\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [props]);\n};\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
const marginKeys = [
|
|
3
|
+
"margin",
|
|
4
|
+
"marginTop",
|
|
5
|
+
"marginRight",
|
|
6
|
+
"marginBottom",
|
|
7
|
+
"marginLeft",
|
|
8
|
+
"m",
|
|
9
|
+
"mt",
|
|
10
|
+
"mr",
|
|
11
|
+
"mb",
|
|
12
|
+
"ml",
|
|
13
|
+
"mx",
|
|
14
|
+
"my"
|
|
15
|
+
];
|
|
16
|
+
const paddingKeys = [
|
|
17
|
+
"padding",
|
|
18
|
+
"p",
|
|
19
|
+
"paddingTop",
|
|
20
|
+
"pt",
|
|
21
|
+
"paddingRight",
|
|
22
|
+
"pr",
|
|
23
|
+
"paddingBottom",
|
|
24
|
+
"pb",
|
|
25
|
+
"paddingLeft",
|
|
26
|
+
"pl",
|
|
27
|
+
"px",
|
|
28
|
+
"py"
|
|
29
|
+
];
|
|
30
|
+
const spaceKeys = ["spaceY", "spaceX", "spaceXReverse", "spaceYReverse"];
|
|
31
|
+
const widthKeys = ["w", "maxWidth", "maxW", "minWidth", "minW"];
|
|
32
|
+
const heightKeys = ["h", "maxHeight", "maxH", "minHeight", "minH"];
|
|
33
|
+
const maskSizeKeys = ["maskSize"];
|
|
34
|
+
const spacingKeys = [...marginKeys, ...paddingKeys, ...spaceKeys];
|
|
35
|
+
const sizingKeys = [...widthKeys, ...heightKeys, ...maskSizeKeys];
|
|
36
|
+
const layoutKeys = [
|
|
37
|
+
"display",
|
|
38
|
+
"float",
|
|
39
|
+
"boxSizing",
|
|
40
|
+
"container",
|
|
41
|
+
"overflow",
|
|
42
|
+
"overflowX",
|
|
43
|
+
"overflowY",
|
|
44
|
+
"zIndex",
|
|
45
|
+
"position",
|
|
46
|
+
"top",
|
|
47
|
+
"right",
|
|
48
|
+
"bottom",
|
|
49
|
+
"left",
|
|
50
|
+
"visibility",
|
|
51
|
+
"overscrollBehavior",
|
|
52
|
+
"objectFit"
|
|
53
|
+
];
|
|
54
|
+
const xstyledKeys = Object.fromEntries([...spacingKeys, ...sizingKeys, ...layoutKeys].map((item) => [item, true]));
|
|
55
|
+
export {
|
|
56
|
+
layoutKeys,
|
|
57
|
+
xstyledKeys
|
|
58
|
+
};
|
|
59
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/props-helpers/xstyledProps/constants.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "const marginKeys = [\n 'margin',\n 'marginTop',\n 'marginRight',\n 'marginBottom',\n 'marginLeft',\n 'm',\n 'mt',\n 'mr',\n 'mb',\n 'ml',\n 'mx',\n 'my',\n];\n\nconst paddingKeys = [\n 'padding',\n 'p',\n 'paddingTop',\n 'pt',\n 'paddingRight',\n 'pr',\n 'paddingBottom',\n 'pb',\n 'paddingLeft',\n 'pl',\n 'px',\n 'py',\n];\n\nconst spaceKeys = ['spaceY', 'spaceX', 'spaceXReverse', 'spaceYReverse'];\n\nconst widthKeys = ['w', 'maxWidth', 'maxW', 'minWidth', 'minW'];\n\nconst heightKeys = ['h', 'maxHeight', 'maxH', 'minHeight', 'minH'];\n\nconst maskSizeKeys = ['maskSize'];\n\nconst spacingKeys = [...marginKeys, ...paddingKeys, ...spaceKeys];\nconst sizingKeys = [...widthKeys, ...heightKeys, ...maskSizeKeys];\nexport const layoutKeys = [\n 'display',\n 'float',\n 'boxSizing',\n 'container',\n 'overflow',\n 'overflowX',\n 'overflowY',\n 'zIndex',\n 'position',\n 'top',\n 'right',\n 'bottom',\n 'left',\n 'visibility',\n 'overscrollBehavior',\n 'objectFit',\n];\n\nexport const xstyledKeys = Object.fromEntries(\n [...spacingKeys, ...sizingKeys, ...layoutKeys].map((item) => [item, true]),\n) as Record<string, true>;\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA,MAAM,aAAa;AAAA,EACjB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,cAAc;AAAA,EAClB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,YAAY,CAAC,UAAU,UAAU,iBAAiB,eAAe;AAEvE,MAAM,YAAY,CAAC,KAAK,YAAY,QAAQ,YAAY,MAAM;AAE9D,MAAM,aAAa,CAAC,KAAK,aAAa,QAAQ,aAAa,MAAM;AAEjE,MAAM,eAAe,CAAC,UAAU;AAEhC,MAAM,cAAc,CAAC,GAAG,YAAY,GAAG,aAAa,GAAG,SAAS;AAChE,MAAM,aAAa,CAAC,GAAG,WAAW,GAAG,YAAY,GAAG,YAAY;AACzD,MAAM,aAAa;AAAA,EACxB;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEO,MAAM,cAAc,OAAO,YAChC,CAAC,GAAG,aAAa,GAAG,YAAY,GAAG,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,IAAI,CAAC,CAC3E;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/props-helpers/xstyledProps/index.ts"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "export * from './useGetXstyledProps';\nexport * from './xstyledPropTypes';\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AACA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { useMemo } from "react";
|
|
3
|
+
import { xstyledKeys } from "./constants";
|
|
4
|
+
const useGetXstyledProps = (props) => {
|
|
5
|
+
const componentXstyledProps = useMemo(() => {
|
|
6
|
+
const xstyledPropsObject = {};
|
|
7
|
+
Object.entries(props).forEach(([key, value]) => {
|
|
8
|
+
if (key in xstyledKeys) {
|
|
9
|
+
xstyledPropsObject[key] = value;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
return xstyledPropsObject;
|
|
13
|
+
}, [props]);
|
|
14
|
+
return componentXstyledProps;
|
|
15
|
+
};
|
|
16
|
+
export {
|
|
17
|
+
useGetXstyledProps
|
|
18
|
+
};
|
|
19
|
+
//# sourceMappingURL=useGetXstyledProps.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/props-helpers/xstyledProps/useGetXstyledProps.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { useMemo } from 'react';\nimport type { SizingProps, SpaceProps, LayoutProps } from '@xstyled/styled-components';\nimport { xstyledKeys } from './constants';\n\nexport type XstyledProps = SpaceProps & SizingProps & LayoutProps;\n\ntype PropsWithXstyled<T> = T & XstyledProps;\n\nexport const useGetXstyledProps = <T,>(props: PropsWithXstyled<T>): XstyledProps => {\n const componentXstyledProps = useMemo(() => {\n const xstyledPropsObject: Record<string, unknown> = {};\n Object.entries(props).forEach(([key, value]) => {\n if (key in xstyledKeys) {\n xstyledPropsObject[key] = value;\n }\n });\n return xstyledPropsObject;\n }, [props]);\n\n return componentXstyledProps as XstyledProps;\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AAEA;AAMO,MAAM,qBAAqB,CAAK,UAA6C;AAClF,QAAM,wBAAwB,QAAQ,MAAM;AAC1C,UAAM,qBAA8C,CAAC;AACrD,WAAO,QAAQ,KAAK,EAAE,QAAQ,CAAC,CAAC,KAAK,WAAW;AAC9C,UAAI,OAAO,aAAa;AACtB,2BAAmB,OAAO;AAAA,MAC5B;AAAA,IACF,CAAC;AACD,WAAO;AAAA,EACT,GAAG,CAAC,KAAK,CAAC;AAEV,SAAO;AACT;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { PropTypes } from "../propTypes";
|
|
3
|
+
const xstyledPropTypes = {
|
|
4
|
+
margin: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
5
|
+
m: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
6
|
+
marginTop: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
7
|
+
mt: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
8
|
+
marginRight: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
9
|
+
mr: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
10
|
+
marginBottom: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
11
|
+
mb: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
12
|
+
marginLeft: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
13
|
+
ml: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
14
|
+
mx: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
15
|
+
my: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
16
|
+
padding: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
17
|
+
p: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
18
|
+
paddingTop: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
19
|
+
pt: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
20
|
+
paddingRight: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
21
|
+
pr: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
22
|
+
paddingBottom: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
23
|
+
pb: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
24
|
+
paddingLeft: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
25
|
+
pl: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
26
|
+
px: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
27
|
+
py: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
28
|
+
spaceY: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
29
|
+
spaceX: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
30
|
+
spaceXReverse: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
31
|
+
spaceYReverse: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
32
|
+
w: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
33
|
+
maxWidth: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
34
|
+
maxW: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
35
|
+
minWidth: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
36
|
+
minW: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
37
|
+
h: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
38
|
+
maxHeight: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
39
|
+
maxH: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
40
|
+
minHeight: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
41
|
+
minH: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
42
|
+
maskSize: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
43
|
+
display: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
44
|
+
float: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
45
|
+
boxSizing: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
46
|
+
container: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
47
|
+
overflow: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
48
|
+
overflowX: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
49
|
+
overflowY: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
50
|
+
zIndex: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
51
|
+
position: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
52
|
+
top: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
53
|
+
right: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
54
|
+
bottom: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
55
|
+
left: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
56
|
+
visibility: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
57
|
+
overscrollBehavior: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled(),
|
|
58
|
+
objectFit: PropTypes.any.description("Applies to the root container. For more info read xstyled docs").xstyled()
|
|
59
|
+
};
|
|
60
|
+
export {
|
|
61
|
+
xstyledPropTypes
|
|
62
|
+
};
|
|
63
|
+
//# sourceMappingURL=xstyledPropTypes.js.map
|