@elliemae/ds-utilities 3.0.0-next.9 → 3.0.1
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 +29 -32
- package/dist/cjs/hooks/index.js.map +2 -2
- package/dist/cjs/hooks/useCallbackAfterRender.js +12 -18
- 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 +76 -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/useOnBlurOut.js +43 -0
- package/dist/cjs/hooks/useOnBlurOut.js.map +7 -0
- package/dist/cjs/hooks/useOnElementResize.js +9 -16
- package/dist/cjs/hooks/useOnElementResize.js.map +1 -1
- package/dist/cjs/hooks/useOnFirstFocusIn.js +61 -0
- package/dist/cjs/hooks/useOnFirstFocusIn.js.map +7 -0
- package/dist/cjs/hooks/useOnSpecificFocus.js +40 -0
- package/dist/cjs/hooks/useOnSpecificFocus.js.map +7 -0
- 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 +23 -27
- package/dist/cjs/index.js.map +2 -2
- package/dist/cjs/objectUtilities.js +46 -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 +94 -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 +20 -16
- package/dist/esm/hooks/index.js.map +2 -2
- package/dist/esm/hooks/useCallbackAfterRender.js +4 -3
- 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 +68 -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/useOnBlurOut.js +21 -0
- package/dist/esm/hooks/useOnBlurOut.js.map +7 -0
- package/dist/esm/hooks/useOnElementResize.js.map +1 -1
- package/dist/esm/hooks/useOnFirstFocusIn.js +39 -0
- package/dist/esm/hooks/useOnFirstFocusIn.js.map +7 -0
- package/dist/esm/hooks/useOnSpecificFocus.js +18 -0
- package/dist/esm/hooks/useOnSpecificFocus.js.map +7 -0
- 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 +23 -24
- package/dist/esm/index.js.map +2 -2
- package/dist/esm/objectUtilities.js +24 -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 +72 -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,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": "AAAA;ACGA;AAEA;AACA;AACA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAYA;AAmBA,MAAM,oBAAiC,CAAC,YAAY,KAAK,OAAO,WAAW;AACzE,MAAI,UAAU,UAAa,UAAU,aAAa;AAChD,mBAAe,YAAY,KAAK,OAAO,MAAM;AAAA,EAC/C;AACF;AACA,MAAM,eAA4B,CAAC,YAAY,KAAK,OAAO,WAAW;AACpE,MAAI,UAAU,QAAQ,UAAU,QAAQ;AACtC,mBAAe,YAAY,KAAK,OAAO,MAAM;AAAA,EAC/C;AACF;AACA,MAAM,wBAAqC,CAAC,YAAY,KAAK,OAAO,WAAW;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F,CAAC;AACH;AAGO,MAAM,iCAAiC,CAC5C,OACA,cACS;AACT,QAAM,kBAAkB,OAA+B,CAAC,CAAC;AAEzD,QAAM,mBAAmB,QAAQ,MAAM;AACrC,UAAM,YAAY,MAAM;AAAA,IAAC;AAEzB,UAAM,qBAAqB,SAAS,SAAS;AAC7C,uBAAmB,YAAY;AAC/B,WAAO,mBAAmB,aAAa;AAAA,EACzC,GAAG,CAAC,SAAS,CAAC;AAEd,UAAQ,MAAM;AACZ,UAAM,sBAAsB,CAAC;AAE7B,8CAA0C,OAAO,kBAAkB,gBAAgB,SAAS,mBAAmB;AAC/G,oBAAgB,UAAU;AAAA,EAE5B,GAAG,CAAC,KAAK,CAAC;AACZ;",
|
|
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 = ["width", "w", "maxWidth", "maxW", "minWidth", "minW"];
|
|
32
|
+
const heightKeys = ["height", "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 = ['width', 'w', 'maxWidth', 'maxW', 'minWidth', 'minW'];\n\nconst heightKeys = ['height', '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,SAAS,KAAK,YAAY,QAAQ,YAAY,MAAM;AAEvE,MAAM,aAAa,CAAC,UAAU,KAAK,aAAa,QAAQ,aAAa,MAAM;AAE3E,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,72 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { PropTypes } from "../propTypes";
|
|
3
|
+
const xstyledGenericPropType = PropTypes.oneOfType([
|
|
4
|
+
PropTypes.number,
|
|
5
|
+
PropTypes.string,
|
|
6
|
+
PropTypes.object,
|
|
7
|
+
PropTypes.bool
|
|
8
|
+
]);
|
|
9
|
+
const genericDescription = "Applies to the root container. For more info read xstyled docs";
|
|
10
|
+
const xstyledPropTypes = {
|
|
11
|
+
margin: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
12
|
+
m: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
13
|
+
marginTop: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
14
|
+
mt: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
15
|
+
marginRight: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
16
|
+
mr: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
17
|
+
marginBottom: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
18
|
+
mb: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
19
|
+
marginLeft: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
20
|
+
ml: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
21
|
+
mx: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
22
|
+
my: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
23
|
+
padding: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
24
|
+
p: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
25
|
+
paddingTop: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
26
|
+
pt: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
27
|
+
paddingRight: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
28
|
+
pr: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
29
|
+
paddingBottom: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
30
|
+
pb: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
31
|
+
paddingLeft: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
32
|
+
pl: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
33
|
+
px: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
34
|
+
py: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
35
|
+
spaceY: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
36
|
+
spaceX: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
37
|
+
spaceXReverse: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
38
|
+
spaceYReverse: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
39
|
+
w: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
40
|
+
width: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
41
|
+
maxWidth: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
42
|
+
maxW: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
43
|
+
minWidth: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
44
|
+
minW: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
45
|
+
h: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
46
|
+
height: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
47
|
+
maxHeight: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
48
|
+
maxH: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
49
|
+
minHeight: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
50
|
+
minH: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
51
|
+
maskSize: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
52
|
+
display: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
53
|
+
float: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
54
|
+
boxSizing: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
55
|
+
container: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
56
|
+
overflow: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
57
|
+
overflowX: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
58
|
+
overflowY: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
59
|
+
zIndex: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
60
|
+
position: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
61
|
+
top: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
62
|
+
right: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
63
|
+
bottom: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
64
|
+
left: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
65
|
+
visibility: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
66
|
+
overscrollBehavior: xstyledGenericPropType.description(genericDescription).xstyled(),
|
|
67
|
+
objectFit: xstyledGenericPropType.description(genericDescription).xstyled()
|
|
68
|
+
};
|
|
69
|
+
export {
|
|
70
|
+
xstyledPropTypes
|
|
71
|
+
};
|
|
72
|
+
//# sourceMappingURL=xstyledPropTypes.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../../../scripts/build/transpile/react-shim.js", "../../../../src/props-helpers/xstyledProps/xstyledPropTypes.tsx"],
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { PropTypes } from '../propTypes';\n\n// Based on https://github.com/gregberge/xstyled/blob/c0c92b459bb3a5de46d7854be3667861f816baa5/packages/prop-types/src/index.ts\nconst xstyledGenericPropType = PropTypes.oneOfType([\n PropTypes.number,\n PropTypes.string,\n PropTypes.object,\n PropTypes.bool,\n]);\n\nconst genericDescription = 'Applies to the root container. For more info read xstyled docs';\n\nexport const xstyledPropTypes = {\n margin: xstyledGenericPropType.description(genericDescription).xstyled(),\n m: xstyledGenericPropType.description(genericDescription).xstyled(),\n marginTop: xstyledGenericPropType.description(genericDescription).xstyled(),\n mt: xstyledGenericPropType.description(genericDescription).xstyled(),\n marginRight: xstyledGenericPropType.description(genericDescription).xstyled(),\n mr: xstyledGenericPropType.description(genericDescription).xstyled(),\n marginBottom: xstyledGenericPropType.description(genericDescription).xstyled(),\n mb: xstyledGenericPropType.description(genericDescription).xstyled(),\n marginLeft: xstyledGenericPropType.description(genericDescription).xstyled(),\n ml: xstyledGenericPropType.description(genericDescription).xstyled(),\n mx: xstyledGenericPropType.description(genericDescription).xstyled(),\n my: xstyledGenericPropType.description(genericDescription).xstyled(),\n padding: xstyledGenericPropType.description(genericDescription).xstyled(),\n p: xstyledGenericPropType.description(genericDescription).xstyled(),\n paddingTop: xstyledGenericPropType.description(genericDescription).xstyled(),\n pt: xstyledGenericPropType.description(genericDescription).xstyled(),\n paddingRight: xstyledGenericPropType.description(genericDescription).xstyled(),\n pr: xstyledGenericPropType.description(genericDescription).xstyled(),\n paddingBottom: xstyledGenericPropType.description(genericDescription).xstyled(),\n pb: xstyledGenericPropType.description(genericDescription).xstyled(),\n paddingLeft: xstyledGenericPropType.description(genericDescription).xstyled(),\n pl: xstyledGenericPropType.description(genericDescription).xstyled(),\n px: xstyledGenericPropType.description(genericDescription).xstyled(),\n py: xstyledGenericPropType.description(genericDescription).xstyled(),\n spaceY: xstyledGenericPropType.description(genericDescription).xstyled(),\n spaceX: xstyledGenericPropType.description(genericDescription).xstyled(),\n spaceXReverse: xstyledGenericPropType.description(genericDescription).xstyled(),\n spaceYReverse: xstyledGenericPropType.description(genericDescription).xstyled(),\n w: xstyledGenericPropType.description(genericDescription).xstyled(),\n width: xstyledGenericPropType.description(genericDescription).xstyled(),\n maxWidth: xstyledGenericPropType.description(genericDescription).xstyled(),\n maxW: xstyledGenericPropType.description(genericDescription).xstyled(),\n minWidth: xstyledGenericPropType.description(genericDescription).xstyled(),\n minW: xstyledGenericPropType.description(genericDescription).xstyled(),\n h: xstyledGenericPropType.description(genericDescription).xstyled(),\n height: xstyledGenericPropType.description(genericDescription).xstyled(),\n maxHeight: xstyledGenericPropType.description(genericDescription).xstyled(),\n maxH: xstyledGenericPropType.description(genericDescription).xstyled(),\n minHeight: xstyledGenericPropType.description(genericDescription).xstyled(),\n minH: xstyledGenericPropType.description(genericDescription).xstyled(),\n maskSize: xstyledGenericPropType.description(genericDescription).xstyled(),\n display: xstyledGenericPropType.description(genericDescription).xstyled(),\n float: xstyledGenericPropType.description(genericDescription).xstyled(),\n boxSizing: xstyledGenericPropType.description(genericDescription).xstyled(),\n container: xstyledGenericPropType.description(genericDescription).xstyled(),\n overflow: xstyledGenericPropType.description(genericDescription).xstyled(),\n overflowX: xstyledGenericPropType.description(genericDescription).xstyled(),\n overflowY: xstyledGenericPropType.description(genericDescription).xstyled(),\n zIndex: xstyledGenericPropType.description(genericDescription).xstyled(),\n position: xstyledGenericPropType.description(genericDescription).xstyled(),\n top: xstyledGenericPropType.description(genericDescription).xstyled(),\n right: xstyledGenericPropType.description(genericDescription).xstyled(),\n bottom: xstyledGenericPropType.description(genericDescription).xstyled(),\n left: xstyledGenericPropType.description(genericDescription).xstyled(),\n visibility: xstyledGenericPropType.description(genericDescription).xstyled(),\n overscrollBehavior: xstyledGenericPropType.description(genericDescription).xstyled(),\n objectFit: xstyledGenericPropType.description(genericDescription).xstyled(),\n};\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AAGA,MAAM,yBAAyB,UAAU,UAAU;AAAA,EACjD,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AAAA,EACV,UAAU;AACZ,CAAC;AAED,MAAM,qBAAqB;AAEpB,MAAM,mBAAmB;AAAA,EAC9B,QAAQ,uBAAuB,YAAY,kBAAkB,EAAE,QAAQ;AAAA,EACvE,GAAG,uBAAuB,YAAY,kBAAkB,EAAE,QAAQ;AAAA,EAClE,WAAW,uBAAuB,YAAY,kBAAkB,EAAE,QAAQ;AAAA,EAC1E,IAAI,uBAAuB,YAAY,kBAAkB,EAAE,QAAQ;AAAA,EACnE,aAAa,uBAAuB,YAAY,kBAAkB,EAAE,QAAQ;AAAA,EAC5E,IAAI,uBAAuB,YAAY,kBAAkB,EAAE,QAAQ;AAAA,EACnE,cAAc,uBAAuB,YAAY,kBAAkB,EAAE,QAAQ;AAAA,EAC7E,IAAI,uBAAuB,YAAY,kBAAkB,EAAE,QAAQ;AAAA,EACnE,YAAY,uBAAuB,YAAY,kBAAkB,EAAE,QAAQ;AAAA,EAC3E,IAAI,uBAAuB,YAAY,kBAAkB,EAAE,QAAQ;AAAA,EACnE,IAAI,uBAAuB,YAAY,kBAAkB,EAAE,QAAQ;AAAA,EACnE,IAAI,uBAAuB,YAAY,kBAAkB,EAAE,QAAQ;AAAA,EACnE,SAAS,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"names": []
|
|
7
|
+
}
|
|
@@ -1,29 +1,8 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import React2 from "react";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
function isFunctionComponent(component) {
|
|
7
|
-
return typeof component === "function" && String(component).includes("return React.createElement");
|
|
8
|
-
}
|
|
9
|
-
function isReactComponent(component) {
|
|
10
|
-
return !!(isClassComponent(component) || isFunctionComponent(component));
|
|
11
|
-
}
|
|
12
|
-
function isElement(element) {
|
|
13
|
-
return React2.isValidElement(element);
|
|
14
|
-
}
|
|
15
|
-
function isDOMTypeElement(element) {
|
|
16
|
-
return isElement(element) && typeof element.type === "string";
|
|
17
|
-
}
|
|
18
|
-
function isCompositeTypeElement(element) {
|
|
19
|
-
return isElement(element) && typeof element.type === "function";
|
|
20
|
-
}
|
|
3
|
+
const isElement = (element) => React2.isValidElement(element);
|
|
4
|
+
const isDOMTypeElement = (element) => isElement(element) && typeof element?.type === "string";
|
|
21
5
|
export {
|
|
22
|
-
|
|
23
|
-
isCompositeTypeElement,
|
|
24
|
-
isDOMTypeElement,
|
|
25
|
-
isElement,
|
|
26
|
-
isFunctionComponent,
|
|
27
|
-
isReactComponent
|
|
6
|
+
isDOMTypeElement
|
|
28
7
|
};
|
|
29
8
|
//# sourceMappingURL=reactTypesUtility.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/reactTypesUtility.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\n\
|
|
5
|
-
"mappings": "AAAA;ACAA;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import React from 'react';\n\nconst isElement = (element: Record<string, unknown> | null | undefined) => React.isValidElement(element);\n\nexport const isDOMTypeElement = (element: Record<string, unknown> | null | undefined) =>\n isElement(element) && typeof element?.type === 'string';\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AAEA,MAAM,YAAY,CAAC,YAAwD,OAAM,eAAe,OAAO;AAEhG,MAAM,mBAAmB,CAAC,YAC/B,UAAU,OAAO,KAAK,OAAO,SAAS,SAAS;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/system.js
CHANGED
|
@@ -7,19 +7,14 @@ const setRef = (ref, value) => {
|
|
|
7
7
|
ref.current = value;
|
|
8
8
|
}
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
const mergeRefs = (...refs) => {
|
|
11
|
+
const mergeRefsFunc = (node) => {
|
|
12
12
|
if (!node)
|
|
13
13
|
return;
|
|
14
|
-
refs.forEach((ref) =>
|
|
15
|
-
if (isFunction(ref)) {
|
|
16
|
-
ref(node);
|
|
17
|
-
} else if (ref) {
|
|
18
|
-
ref.current = node;
|
|
19
|
-
}
|
|
20
|
-
});
|
|
14
|
+
refs.forEach((ref) => setRef(ref, node));
|
|
21
15
|
};
|
|
22
|
-
|
|
16
|
+
return mergeRefsFunc;
|
|
17
|
+
};
|
|
23
18
|
function logger(...args) {
|
|
24
19
|
console.log(...args);
|
|
25
20
|
}
|
package/dist/esm/system.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/system.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { isFunction } from './utils';\n\nexport const setRef = (ref
|
|
5
|
-
"mappings": "AAAA;ACAA;
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { isFunction } from './utils';\n\ntype AnyRef<T extends HTMLElement> = React.MutableRefObject<T> | ((_ref: T) => void);\n\nexport const setRef = <T extends HTMLElement>(ref: AnyRef<T>, value: T) => {\n if (isFunction(ref)) {\n ref(value);\n } else if (ref) {\n ref.current = value;\n }\n};\n\nexport const mergeRefs = <T extends HTMLElement>(...refs: AnyRef<T>[]) => {\n const mergeRefsFunc = (node: T) => {\n if (!node) return;\n refs.forEach((ref) => setRef(ref, node));\n };\n return mergeRefsFunc;\n};\n\nexport function logger(...args: unknown[]) {\n // eslint-disable-next-line no-console\n console.log(...args);\n}\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AAIO,MAAM,SAAS,CAAwB,KAAgB,UAAa;AACzE,MAAI,WAAW,GAAG,GAAG;AACnB,QAAI,KAAK;AAAA,EACX,WAAW,KAAK;AACd,QAAI,UAAU;AAAA,EAChB;AACF;AAEO,MAAM,YAAY,IAA2B,SAAsB;AACxE,QAAM,gBAAgB,CAAC,SAAY;AACjC,QAAI,CAAC;AAAM;AACX,SAAK,QAAQ,CAAC,QAAQ,OAAO,KAAK,IAAI,CAAC;AAAA,EACzC;AACA,SAAO;AACT;AAEO,mBAAmB,MAAiB;AAEzC,UAAQ,IAAI,GAAG,IAAI;AACrB;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../scripts/build/transpile/react-shim.js", "../../src/timeUtils.tsx"],
|
|
4
|
-
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { padStart } from './utils';\n\nexport const getVisibleTimeByFormat = format => ({\n showHours
|
|
5
|
-
"mappings": "AAAA;ACAA;AAEO,MAAM,yBAAyB,
|
|
4
|
+
"sourcesContent": ["import * as React from 'react';\nexport { React };\n", "import { padStart } from './utils';\n\nexport const getVisibleTimeByFormat = (format: string) => ({\n showHours: format.indexOf('H') > -1 || format.indexOf('h') > -1 || format.indexOf('k') > -1,\n showMinutes: format.indexOf('m') > -1,\n showSeconds: format.indexOf('s') > -1,\n use12Hours: format.indexOf('A') > -1 || format.indexOf('h') > -1 || format.indexOf('a') > -1,\n});\n\nexport const addLeadingZeros = (count: number) => (number: number) => padStart(String(number), count, '0');\n"],
|
|
5
|
+
"mappings": "AAAA;ACAA;AAEO,MAAM,yBAAyB,CAAC,WAAoB;AAAA,EACzD,WAAW,OAAO,QAAQ,GAAG,IAAI,MAAM,OAAO,QAAQ,GAAG,IAAI,MAAM,OAAO,QAAQ,GAAG,IAAI;AAAA,EACzF,aAAa,OAAO,QAAQ,GAAG,IAAI;AAAA,EACnC,aAAa,OAAO,QAAQ,GAAG,IAAI;AAAA,EACnC,YAAY,OAAO,QAAQ,GAAG,IAAI,MAAM,OAAO,QAAQ,GAAG,IAAI,MAAM,OAAO,QAAQ,GAAG,IAAI;AAC5F;AAEO,MAAM,kBAAkB,CAAC,UAAkB,CAAC,WAAmB,SAAS,OAAO,MAAM,GAAG,OAAO,GAAG;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/utils.js
CHANGED
|
@@ -87,9 +87,12 @@ function runAll(...fns) {
|
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
function hashArray(arr, fieldName) {
|
|
90
|
-
return arr.reduce((result, item) =>
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
return arr.reduce((result, item) => {
|
|
91
|
+
const newKey = fieldName && typeof item === "object" ? item[fieldName] : item;
|
|
92
|
+
return __spreadProps(__spreadValues({}, result), {
|
|
93
|
+
[newKey]: true
|
|
94
|
+
});
|
|
95
|
+
}, {});
|
|
93
96
|
}
|
|
94
97
|
function safeCall(fun, ...args) {
|
|
95
98
|
if (isFunction(fun)) {
|