@semcore/core 16.5.1 → 17.0.0-prerelease.14
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/CHANGELOG.md +12 -1
- package/README.md +4 -4
- package/lib/LastInteractionType.js +22 -36
- package/lib/LastInteractionType.js.map +1 -1
- package/lib/LastInteractionType.mjs +19 -33
- package/lib/LastInteractionType.mjs.map +1 -1
- package/lib/core-types/Component.d.ts +26 -79
- package/lib/core-types/Component.js +24 -72
- package/lib/core-types/Component.js.map +1 -1
- package/lib/core-types/Component.mjs +18 -34
- package/lib/core-types/Component.mjs.map +1 -1
- package/lib/core-types/symbols.js +9 -9
- package/lib/core-types/symbols.js.map +1 -1
- package/lib/core-types/symbols.mjs +9 -9
- package/lib/core-types/symbols.mjs.map +1 -1
- package/lib/coreFactory.d.ts +6 -23
- package/lib/coreFactory.js +150 -217
- package/lib/coreFactory.js.map +1 -1
- package/lib/coreFactory.mjs +139 -194
- package/lib/coreFactory.mjs.map +1 -1
- package/lib/decorators/propsObserver.d.ts +11 -0
- package/lib/decorators/reactive.d.ts +11 -0
- package/lib/enhancement/Children.js +51 -59
- package/lib/enhancement/Children.js.map +1 -1
- package/lib/enhancement/Children.mjs +47 -41
- package/lib/enhancement/Children.mjs.map +1 -1
- package/lib/enhancement/Root.js +36 -37
- package/lib/enhancement/Root.js.map +1 -1
- package/lib/enhancement/Root.mjs +28 -18
- package/lib/enhancement/Root.mjs.map +1 -1
- package/lib/enhancement/dataName.js +7 -8
- package/lib/enhancement/dataName.js.map +1 -1
- package/lib/enhancement/dataName.mjs +5 -5
- package/lib/enhancement/dataName.mjs.map +1 -1
- package/lib/enhancement/enhance.js +6 -9
- package/lib/enhancement/enhance.js.map +1 -1
- package/lib/enhancement/enhance.mjs +5 -7
- package/lib/enhancement/enhance.mjs.map +1 -1
- package/lib/enhancement/functionDefaultProps.js +6 -6
- package/lib/enhancement/functionDefaultProps.js.map +1 -1
- package/lib/enhancement/functionDefaultProps.mjs +4 -4
- package/lib/enhancement/functionDefaultProps.mjs.map +1 -1
- package/lib/enhancement/i18n.js +13 -13
- package/lib/enhancement/i18n.js.map +1 -1
- package/lib/enhancement/i18n.mjs +10 -9
- package/lib/enhancement/i18n.mjs.map +1 -1
- package/lib/enhancement/inheritedName.js +7 -8
- package/lib/enhancement/inheritedName.js.map +1 -1
- package/lib/enhancement/inheritedName.mjs +5 -5
- package/lib/enhancement/inheritedName.mjs.map +1 -1
- package/lib/enhancement/staticChildren.js +47 -56
- package/lib/enhancement/staticChildren.js.map +1 -1
- package/lib/enhancement/staticChildren.mjs +43 -48
- package/lib/enhancement/staticChildren.mjs.map +1 -1
- package/lib/enhancement/style.js +29 -27
- package/lib/enhancement/style.js.map +1 -1
- package/lib/enhancement/style.mjs +26 -20
- package/lib/enhancement/style.mjs.map +1 -1
- package/lib/enhancement/uncontrolledProps.js +46 -64
- package/lib/enhancement/uncontrolledProps.js.map +1 -1
- package/lib/enhancement/uncontrolledProps.mjs +43 -51
- package/lib/enhancement/uncontrolledProps.mjs.map +1 -1
- package/lib/esm/LastInteractionType.mjs +19 -33
- package/lib/esm/core-types/Component.mjs +18 -34
- package/lib/esm/core-types/symbols.mjs +9 -9
- package/lib/esm/coreFactory.mjs +139 -194
- package/lib/esm/enhancement/Children.mjs +47 -41
- package/lib/esm/enhancement/Root.mjs +28 -18
- package/lib/esm/enhancement/dataName.mjs +5 -5
- package/lib/esm/enhancement/enhance.mjs +5 -7
- package/lib/esm/enhancement/functionDefaultProps.mjs +4 -4
- package/lib/esm/enhancement/i18n.mjs +10 -9
- package/lib/esm/enhancement/inheritedName.mjs +5 -5
- package/lib/esm/enhancement/staticChildren.mjs +43 -48
- package/lib/esm/enhancement/style.mjs +26 -20
- package/lib/esm/enhancement/uncontrolledProps.mjs +43 -51
- package/lib/esm/register.mjs +12 -20
- package/lib/esm/styled/reshadow-core.mjs +98 -111
- package/lib/esm/styled/sstyled.mjs +31 -41
- package/lib/esm/utils/assignProps.mjs +32 -36
- package/lib/esm/utils/enhances/WithI18n.mjs +16 -63
- package/lib/esm/utils/enhances/i18nEnhance.mjs +47 -61
- package/lib/esm/utils/logger.mjs +13 -21
- package/lib/esm/utils/pick.mjs +4 -4
- package/lib/esm/utils/ref.mjs +27 -57
- package/lib/esm/utils/use/useEnhancedEffect.mjs +1 -1
- package/lib/index.d.ts +3 -3
- package/lib/index.js +17 -17
- package/lib/index.js.map +1 -1
- package/lib/index.mjs.map +1 -1
- package/lib/register.js +17 -24
- package/lib/register.js.map +1 -1
- package/lib/register.mjs +12 -20
- package/lib/register.mjs.map +1 -1
- package/lib/styled/index.d.ts +1 -5
- package/lib/styled/index.js +4 -4
- package/lib/styled/index.js.map +1 -1
- package/lib/styled/index.mjs.map +1 -1
- package/lib/styled/reshadow-core.js +102 -104
- package/lib/styled/reshadow-core.js.map +1 -1
- package/lib/styled/reshadow-core.mjs +98 -111
- package/lib/styled/reshadow-core.mjs.map +1 -1
- package/lib/styled/sstyled.js +31 -53
- package/lib/styled/sstyled.js.map +1 -1
- package/lib/styled/sstyled.mjs +31 -41
- package/lib/styled/sstyled.mjs.map +1 -1
- package/lib/theme/processor.js +150 -222
- package/lib/theme/processor.js.map +1 -1
- package/lib/theme/processor.mjs +148 -221
- package/lib/theme/processor.mjs.map +1 -1
- package/lib/theme/themes/dark.js +2 -2
- package/lib/theme/themes/dark.js.map +1 -1
- package/lib/theme/themes/default.js +2 -2
- package/lib/theme/themes/default.js.map +1 -1
- package/lib/theme/themes/highlights-dark.js +2 -2
- package/lib/theme/themes/highlights-dark.js.map +1 -1
- package/lib/theme/themes/highlights-light.js +2 -2
- package/lib/theme/themes/highlights-light.js.map +1 -1
- package/lib/theme/themes/light.js +2 -2
- package/lib/theme/themes/light.js.map +1 -1
- package/lib/theme/utils.js +140 -215
- package/lib/theme/utils.js.map +1 -1
- package/lib/theme/utils.mjs +135 -214
- package/lib/theme/utils.mjs.map +1 -1
- package/lib/utils/CSSinJS.js +8 -10
- package/lib/utils/CSSinJS.js.map +1 -1
- package/lib/utils/CSSinJS.mjs +6 -7
- package/lib/utils/CSSinJS.mjs.map +1 -1
- package/lib/utils/ThemeProvider.js +44 -51
- package/lib/utils/ThemeProvider.js.map +1 -1
- package/lib/utils/ThemeProvider.mjs +36 -47
- package/lib/utils/ThemeProvider.mjs.map +1 -1
- package/lib/utils/addonText.js +4 -7
- package/lib/utils/addonText.js.map +1 -1
- package/lib/utils/addonText.mjs +2 -5
- package/lib/utils/addonText.mjs.map +1 -1
- package/lib/utils/addonTextChildren.js +15 -21
- package/lib/utils/addonTextChildren.js.map +1 -1
- package/lib/utils/addonTextChildren.mjs +7 -13
- package/lib/utils/addonTextChildren.mjs.map +1 -1
- package/lib/utils/ariaProps.js +7 -5
- package/lib/utils/ariaProps.js.map +1 -1
- package/lib/utils/ariaProps.mjs +7 -5
- package/lib/utils/ariaProps.mjs.map +1 -1
- package/lib/utils/assignProps.js +33 -37
- package/lib/utils/assignProps.js.map +1 -1
- package/lib/utils/assignProps.mjs +32 -36
- package/lib/utils/assignProps.mjs.map +1 -1
- package/lib/utils/canUseDOM.js +1 -1
- package/lib/utils/capitalizeFirstLetter.js +1 -1
- package/lib/utils/color.js +72 -95
- package/lib/utils/color.js.map +1 -1
- package/lib/utils/color.mjs +71 -94
- package/lib/utils/color.mjs.map +1 -1
- package/lib/utils/compose.js +3 -12
- package/lib/utils/compose.js.map +1 -1
- package/lib/utils/compose.mjs +2 -11
- package/lib/utils/compose.mjs.map +1 -1
- package/lib/utils/createUUID.js +5 -5
- package/lib/utils/createUUID.js.map +1 -1
- package/lib/utils/createUUID.mjs +4 -4
- package/lib/utils/createUUID.mjs.map +1 -1
- package/lib/utils/cssToIntDefault.js +3 -4
- package/lib/utils/cssToIntDefault.js.map +1 -1
- package/lib/utils/cssToIntDefault.mjs +2 -3
- package/lib/utils/cssToIntDefault.mjs.map +1 -1
- package/lib/utils/enhances/WithCSS.d.ts +2 -30
- package/lib/utils/enhances/WithCSS.js +13 -64
- package/lib/utils/enhances/WithCSS.js.map +1 -1
- package/lib/utils/enhances/WithCSS.mjs +9 -59
- package/lib/utils/enhances/WithCSS.mjs.map +1 -1
- package/lib/utils/enhances/WithI18n.d.ts +1 -30
- package/lib/utils/enhances/WithI18n.js +20 -76
- package/lib/utils/enhances/WithI18n.js.map +1 -1
- package/lib/utils/enhances/WithI18n.mjs +16 -63
- package/lib/utils/enhances/WithI18n.mjs.map +1 -1
- package/lib/utils/enhances/a11yEnhance.js +34 -39
- package/lib/utils/enhances/a11yEnhance.js.map +1 -1
- package/lib/utils/enhances/a11yEnhance.mjs +32 -36
- package/lib/utils/enhances/a11yEnhance.mjs.map +1 -1
- package/lib/utils/enhances/animatedSizeEnhance.d.ts +0 -4
- package/lib/utils/enhances/animatedSizeEnhance.js +55 -65
- package/lib/utils/enhances/animatedSizeEnhance.js.map +1 -1
- package/lib/utils/enhances/animatedSizeEnhance.mjs +50 -61
- package/lib/utils/enhances/animatedSizeEnhance.mjs.map +1 -1
- package/lib/utils/enhances/contextEnhance.js +12 -11
- package/lib/utils/enhances/contextEnhance.js.map +1 -1
- package/lib/utils/enhances/contextEnhance.mjs +9 -8
- package/lib/utils/enhances/contextEnhance.mjs.map +1 -1
- package/lib/utils/enhances/i18nEnhance.d.ts +0 -4
- package/lib/utils/enhances/i18nEnhance.js +51 -69
- package/lib/utils/enhances/i18nEnhance.js.map +1 -1
- package/lib/utils/enhances/i18nEnhance.mjs +47 -61
- package/lib/utils/enhances/i18nEnhance.mjs.map +1 -1
- package/lib/utils/enhances/resolveColorEnhance.js +12 -10
- package/lib/utils/enhances/resolveColorEnhance.js.map +1 -1
- package/lib/utils/enhances/resolveColorEnhance.mjs +8 -6
- package/lib/utils/enhances/resolveColorEnhance.mjs.map +1 -1
- package/lib/utils/eventEmitter.d.ts +10 -6
- package/lib/utils/eventEmitter.js +33 -32
- package/lib/utils/eventEmitter.js.map +1 -1
- package/lib/utils/eventEmitter.mjs +30 -31
- package/lib/utils/eventEmitter.mjs.map +1 -1
- package/lib/utils/findComponent.js +35 -42
- package/lib/utils/findComponent.js.map +1 -1
- package/lib/utils/findComponent.mjs +26 -33
- package/lib/utils/findComponent.mjs.map +1 -1
- package/lib/utils/fire.js +7 -13
- package/lib/utils/fire.js.map +1 -1
- package/lib/utils/fire.mjs +5 -11
- package/lib/utils/fire.mjs.map +1 -1
- package/lib/utils/focus-lock/focusBorders.js +28 -32
- package/lib/utils/focus-lock/focusBorders.js.map +1 -1
- package/lib/utils/focus-lock/focusBorders.mjs +26 -32
- package/lib/utils/focus-lock/focusBorders.mjs.map +1 -1
- package/lib/utils/focus-lock/getFocusableIn.js +4 -6
- package/lib/utils/focus-lock/getFocusableIn.js.map +1 -1
- package/lib/utils/focus-lock/getFocusableIn.mjs +3 -6
- package/lib/utils/focus-lock/getFocusableIn.mjs.map +1 -1
- package/lib/utils/focus-lock/isFocusInside.js +5 -6
- package/lib/utils/focus-lock/isFocusInside.js.map +1 -1
- package/lib/utils/focus-lock/isFocusInside.mjs +4 -6
- package/lib/utils/focus-lock/isFocusInside.mjs.map +1 -1
- package/lib/utils/focus-lock/isFocusable.js +9 -12
- package/lib/utils/focus-lock/isFocusable.js.map +1 -1
- package/lib/utils/focus-lock/isFocusable.mjs +8 -11
- package/lib/utils/focus-lock/isFocusable.mjs.map +1 -1
- package/lib/utils/focus-lock/setFocus.js +21 -27
- package/lib/utils/focus-lock/setFocus.js.map +1 -1
- package/lib/utils/focus-lock/setFocus.mjs +19 -25
- package/lib/utils/focus-lock/setFocus.mjs.map +1 -1
- package/lib/utils/getAccessibleName.js +10 -22
- package/lib/utils/getAccessibleName.js.map +1 -1
- package/lib/utils/getAccessibleName.mjs +10 -21
- package/lib/utils/getAccessibleName.mjs.map +1 -1
- package/lib/utils/getDisplayName.js +1 -1
- package/lib/utils/getDisplayName.mjs +3 -5
- package/lib/utils/getEventTarget.js +13 -32
- package/lib/utils/getEventTarget.js.map +1 -1
- package/lib/utils/getEventTarget.mjs +12 -31
- package/lib/utils/getEventTarget.mjs.map +1 -1
- package/lib/utils/getOriginChildren.js +4 -4
- package/lib/utils/getOriginChildren.js.map +1 -1
- package/lib/utils/getRandomInt.js +1 -1
- package/lib/utils/getValue.js +4 -6
- package/lib/utils/getValue.js.map +1 -1
- package/lib/utils/getValue.mjs +3 -5
- package/lib/utils/getValue.mjs.map +1 -1
- package/lib/utils/hasLabels.js +16 -27
- package/lib/utils/hasLabels.js.map +1 -1
- package/lib/utils/hasLabels.mjs +14 -24
- package/lib/utils/hasLabels.mjs.map +1 -1
- package/lib/utils/hasParent.js +3 -2
- package/lib/utils/hasParent.js.map +1 -1
- package/lib/utils/hasParent.mjs +2 -3
- package/lib/utils/hasParent.mjs.map +1 -1
- package/lib/utils/ifChildren.js +6 -4
- package/lib/utils/ifChildren.js.map +1 -1
- package/lib/utils/ifChildren.mjs +4 -2
- package/lib/utils/ifChildren.mjs.map +1 -1
- package/lib/utils/injectStyle.js +11 -13
- package/lib/utils/injectStyle.js.map +1 -1
- package/lib/utils/injectStyle.mjs +9 -10
- package/lib/utils/injectStyle.mjs.map +1 -1
- package/lib/utils/inputProps.js +5 -5
- package/lib/utils/inputProps.js.map +1 -1
- package/lib/utils/inputProps.mjs +4 -4
- package/lib/utils/inputProps.mjs.map +1 -1
- package/lib/utils/isInteractiveElement.js +7 -9
- package/lib/utils/isInteractiveElement.js.map +1 -1
- package/lib/utils/isInteractiveElement.mjs +7 -9
- package/lib/utils/isInteractiveElement.mjs.map +1 -1
- package/lib/utils/isNode.js +4 -5
- package/lib/utils/isNode.js.map +1 -1
- package/lib/utils/isNode.mjs +1 -2
- package/lib/utils/isNode.mjs.map +1 -1
- package/lib/utils/isPromise.js +1 -1
- package/lib/utils/isRetina.js +7 -2
- package/lib/utils/isRetina.js.map +1 -1
- package/lib/utils/isRetina.mjs +6 -1
- package/lib/utils/isRetina.mjs.map +1 -1
- package/lib/utils/logger.js +18 -25
- package/lib/utils/logger.js.map +1 -1
- package/lib/utils/logger.mjs +13 -21
- package/lib/utils/logger.mjs.map +1 -1
- package/lib/utils/numericChecker.js +11 -18
- package/lib/utils/numericChecker.js.map +1 -1
- package/lib/utils/numericChecker.mjs +10 -17
- package/lib/utils/numericChecker.mjs.map +1 -1
- package/lib/utils/ownerDocument.js +2 -2
- package/lib/utils/ownerDocument.js.map +1 -1
- package/lib/utils/ownerDocument.mjs +1 -1
- package/lib/utils/ownerDocument.mjs.map +1 -1
- package/lib/utils/pick.js +5 -5
- package/lib/utils/pick.js.map +1 -1
- package/lib/utils/pick.mjs +4 -4
- package/lib/utils/pick.mjs.map +1 -1
- package/lib/utils/propsForElement.js +10 -12
- package/lib/utils/propsForElement.js.map +1 -1
- package/lib/utils/propsForElement.mjs +8 -10
- package/lib/utils/propsForElement.mjs.map +1 -1
- package/lib/utils/rafTrottle.js +9 -14
- package/lib/utils/rafTrottle.js.map +1 -1
- package/lib/utils/rafTrottle.mjs +7 -12
- package/lib/utils/rafTrottle.mjs.map +1 -1
- package/lib/utils/reactToText.js +5 -8
- package/lib/utils/reactToText.js.map +1 -1
- package/lib/utils/reactToText.mjs +3 -6
- package/lib/utils/reactToText.mjs.map +1 -1
- package/lib/utils/ref.d.ts +1 -3
- package/lib/utils/ref.js +29 -61
- package/lib/utils/ref.js.map +1 -1
- package/lib/utils/ref.mjs +27 -57
- package/lib/utils/ref.mjs.map +1 -1
- package/lib/utils/setRef.js +2 -2
- package/lib/utils/setRef.js.map +1 -1
- package/lib/utils/syncScroll.js +24 -24
- package/lib/utils/syncScroll.js.map +1 -1
- package/lib/utils/syncScroll.mjs +21 -21
- package/lib/utils/syncScroll.mjs.map +1 -1
- package/lib/utils/uncontroll.js +8 -18
- package/lib/utils/uncontroll.js.map +1 -1
- package/lib/utils/uncontroll.mjs +8 -17
- package/lib/utils/uncontroll.mjs.map +1 -1
- package/lib/utils/uniqueID.d.ts +0 -4
- package/lib/utils/uniqueID.js +23 -30
- package/lib/utils/uniqueID.js.map +1 -1
- package/lib/utils/uniqueID.mjs +19 -29
- package/lib/utils/uniqueID.mjs.map +1 -1
- package/lib/utils/use/useColorResolver.js +20 -21
- package/lib/utils/use/useColorResolver.js.map +1 -1
- package/lib/utils/use/useColorResolver.mjs +16 -18
- package/lib/utils/use/useColorResolver.mjs.map +1 -1
- package/lib/utils/use/useEnhancedEffect.d.ts +1 -1
- package/lib/utils/use/useEnhancedEffect.js +4 -4
- package/lib/utils/use/useEnhancedEffect.js.map +1 -1
- package/lib/utils/use/useEnhancedEffect.mjs +1 -1
- package/lib/utils/use/useEnhancedEffect.mjs.map +1 -1
- package/lib/utils/use/useEventCallback.js +5 -10
- package/lib/utils/use/useEventCallback.js.map +1 -1
- package/lib/utils/use/useEventCallback.mjs +3 -8
- package/lib/utils/use/useEventCallback.mjs.map +1 -1
- package/lib/utils/use/useEventListener.js +11 -15
- package/lib/utils/use/useEventListener.js.map +1 -1
- package/lib/utils/use/useEventListener.mjs +7 -11
- package/lib/utils/use/useEventListener.mjs.map +1 -1
- package/lib/utils/use/useFocusLock.js +80 -94
- package/lib/utils/use/useFocusLock.js.map +1 -1
- package/lib/utils/use/useFocusLock.mjs +71 -88
- package/lib/utils/use/useFocusLock.mjs.map +1 -1
- package/lib/utils/use/usePreventScroll.js +26 -28
- package/lib/utils/use/usePreventScroll.js.map +1 -1
- package/lib/utils/use/usePreventScroll.mjs +21 -23
- package/lib/utils/use/usePreventScroll.mjs.map +1 -1
- package/lib/utils/use/useScrollBarWidth.js +8 -14
- package/lib/utils/use/useScrollBarWidth.js.map +1 -1
- package/lib/utils/use/useScrollBarWidth.mjs +8 -13
- package/lib/utils/use/useScrollBarWidth.mjs.map +1 -1
- package/lib/utils/useCssVariable.js +32 -37
- package/lib/utils/useCssVariable.js.map +1 -1
- package/lib/utils/useCssVariable.mjs +27 -34
- package/lib/utils/useCssVariable.mjs.map +1 -1
- package/lib/utils/zIndexStacking.d.ts +3 -1
- package/lib/utils/zIndexStacking.js +28 -24
- package/lib/utils/zIndexStacking.js.map +1 -1
- package/lib/utils/zIndexStacking.mjs +23 -22
- package/lib/utils/zIndexStacking.mjs.map +1 -1
- package/package.json +129 -129
- package/lib/enhancement/bindHandler.d.ts +0 -5
- package/lib/enhancement/bindHandler.js +0 -53
- package/lib/enhancement/bindHandler.js.map +0 -1
- package/lib/enhancement/bindHandler.mjs +0 -48
- package/lib/enhancement/bindHandler.mjs.map +0 -1
- package/lib/enhancement/hoistProps.d.ts +0 -10
- package/lib/enhancement/hoistProps.js +0 -95
- package/lib/enhancement/hoistProps.js.map +0 -1
- package/lib/enhancement/hoistProps.mjs +0 -78
- package/lib/enhancement/hoistProps.mjs.map +0 -1
- package/lib/esm/enhancement/bindHandler.mjs +0 -48
- package/lib/esm/enhancement/hoistProps.mjs +0 -78
- package/lib/esm/utils/createHoc.mjs +0 -42
- package/lib/esm/utils/getDisplayName.mjs +0 -6
- package/lib/utils/ScreenReaderOnly.d.ts +0 -8
- package/lib/utils/ScreenReaderOnly.js +0 -30
- package/lib/utils/ScreenReaderOnly.js.map +0 -1
- package/lib/utils/ScreenReaderOnly.mjs +0 -24
- package/lib/utils/ScreenReaderOnly.mjs.map +0 -1
- package/lib/utils/createHoc.d.ts +0 -3
- package/lib/utils/createHoc.js +0 -52
- package/lib/utils/createHoc.js.map +0 -1
- package/lib/utils/createHoc.mjs +0 -42
- package/lib/utils/createHoc.mjs.map +0 -1
- package/lib/utils/enhances/WithAutoFocus.d.ts +0 -14
- package/lib/utils/enhances/WithAutoFocus.js +0 -72
- package/lib/utils/enhances/WithAutoFocus.js.map +0 -1
- package/lib/utils/enhances/WithAutoFocus.mjs +0 -66
- package/lib/utils/enhances/WithAutoFocus.mjs.map +0 -1
- package/lib/utils/enhances/WithKeyboardFocus.d.ts +0 -46
- package/lib/utils/enhances/WithKeyboardFocus.js +0 -94
- package/lib/utils/enhances/WithKeyboardFocus.js.map +0 -1
- package/lib/utils/enhances/WithKeyboardFocus.mjs +0 -88
- package/lib/utils/enhances/WithKeyboardFocus.mjs.map +0 -1
- package/lib/utils/enhances/WithRef.d.ts +0 -3
- package/lib/utils/enhances/WithRef.js +0 -25
- package/lib/utils/enhances/WithRef.js.map +0 -1
- package/lib/utils/enhances/WithRef.mjs +0 -18
- package/lib/utils/enhances/WithRef.mjs.map +0 -1
- package/lib/utils/enhances/autoFocusEnhance.d.ts +0 -10
- package/lib/utils/enhances/autoFocusEnhance.js +0 -45
- package/lib/utils/enhances/autoFocusEnhance.js.map +0 -1
- package/lib/utils/enhances/autoFocusEnhance.mjs +0 -38
- package/lib/utils/enhances/autoFocusEnhance.mjs.map +0 -1
- package/lib/utils/enhances/keyboardFocusEnhance.d.ts +0 -27
- package/lib/utils/enhances/keyboardFocusEnhance.js +0 -63
- package/lib/utils/enhances/keyboardFocusEnhance.js.map +0 -1
- package/lib/utils/enhances/keyboardFocusEnhance.mjs +0 -57
- package/lib/utils/enhances/keyboardFocusEnhance.mjs.map +0 -1
- package/lib/utils/if.d.ts +0 -11
- package/lib/utils/if.js +0 -15
- package/lib/utils/if.js.map +0 -1
- package/lib/utils/if.mjs +0 -9
- package/lib/utils/if.mjs.map +0 -1
- package/lib/utils/use/useCss.d.ts +0 -4
- package/lib/utils/use/useCss.js +0 -19
- package/lib/utils/use/useCss.js.map +0 -1
- package/lib/utils/use/useCss.mjs +0 -12
- package/lib/utils/use/useCss.mjs.map +0 -1
|
@@ -1,101 +1,83 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports.useAsyncI18nMessages = exports
|
|
8
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
|
|
10
|
-
var _regenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/regenerator"));
|
|
11
|
-
var _objectSpread3 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
12
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
13
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
7
|
+
exports.useAsyncI18nMessages = exports.default = void 0;
|
|
14
8
|
var _react = _interopRequireDefault(require("react"));
|
|
15
9
|
var _WithI18n = require("./WithI18n");
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var useAsyncI18nMessages = exports.useAsyncI18nMessages = function useAsyncI18nMessages(primaryContainer, locale, fallbackContainer) {
|
|
19
|
-
var _store$locale;
|
|
20
|
-
var container = _react["default"].useMemo(function () {
|
|
10
|
+
const useAsyncI18nMessages = (primaryContainer, locale, fallbackContainer) => {
|
|
11
|
+
const container = _react.default.useMemo(() => {
|
|
21
12
|
if (!fallbackContainer) return primaryContainer;
|
|
22
13
|
if (!primaryContainer) return fallbackContainer;
|
|
23
14
|
if (primaryContainer === fallbackContainer) return primaryContainer;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if (typeof primaryContainer[
|
|
27
|
-
container[
|
|
28
|
-
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
case 1:
|
|
35
|
-
_yield$Promise$all = _context.v;
|
|
36
|
-
_yield$Promise$all2 = (0, _slicedToArray2["default"])(_yield$Promise$all, 2);
|
|
37
|
-
primary = _yield$Promise$all2[0];
|
|
38
|
-
fallback = _yield$Promise$all2[1];
|
|
39
|
-
return _context.a(2, (0, _objectSpread3["default"])((0, _objectSpread3["default"])({}, primary), fallback));
|
|
40
|
-
}
|
|
41
|
-
}, _callee);
|
|
42
|
-
}));
|
|
15
|
+
const container = {};
|
|
16
|
+
for (const locale in primaryContainer) {
|
|
17
|
+
if (typeof primaryContainer[locale] === 'function' || typeof fallbackContainer[locale] === 'function') {
|
|
18
|
+
container[locale] = async () => {
|
|
19
|
+
const [primary, fallback] = await Promise.all([primaryContainer[locale], fallbackContainer[locale]]);
|
|
20
|
+
return {
|
|
21
|
+
...primary,
|
|
22
|
+
...fallback
|
|
23
|
+
};
|
|
24
|
+
};
|
|
43
25
|
} else {
|
|
44
|
-
|
|
45
|
-
|
|
26
|
+
container[locale] = {
|
|
27
|
+
...(primaryContainer[locale] ?? {}),
|
|
28
|
+
...(fallbackContainer[locale] ?? {})
|
|
29
|
+
};
|
|
46
30
|
}
|
|
47
|
-
};
|
|
48
|
-
for (var _locale in primaryContainer) {
|
|
49
|
-
_loop(_locale);
|
|
50
31
|
}
|
|
51
32
|
return container;
|
|
52
33
|
}, [primaryContainer, fallbackContainer]);
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
for (
|
|
56
|
-
if (
|
|
57
|
-
store[
|
|
34
|
+
const initStore = _react.default.useMemo(() => {
|
|
35
|
+
const store = {};
|
|
36
|
+
for (const locale in container) {
|
|
37
|
+
if (typeof container[locale] === 'object') {
|
|
38
|
+
store[locale] = container[locale];
|
|
58
39
|
}
|
|
59
40
|
}
|
|
60
41
|
return store;
|
|
61
42
|
}, [container]);
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
store = _React$useState2[0],
|
|
65
|
-
setStore = _React$useState2[1];
|
|
66
|
-
var lastLoadedLocaleRef = _react["default"].useRef(null);
|
|
43
|
+
const [store, setStore] = _react.default.useState(initStore);
|
|
44
|
+
const lastLoadedLocaleRef = _react.default.useRef(null);
|
|
67
45
|
if (store[locale]) lastLoadedLocaleRef.current = locale;
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
var loadingLocaleRef = _react["default"].useRef(null);
|
|
72
|
-
_react["default"].useEffect(function () {
|
|
46
|
+
const fallbackMessages = _react.default.useMemo(() => Object.values(store)[0], [store]);
|
|
47
|
+
const loadingLocaleRef = _react.default.useRef(null);
|
|
48
|
+
_react.default.useEffect(() => {
|
|
73
49
|
loadingLocaleRef.current = locale;
|
|
74
|
-
|
|
50
|
+
const asyncMessages = container[locale];
|
|
75
51
|
if (typeof asyncMessages === 'function') {
|
|
76
|
-
asyncMessages().then(
|
|
52
|
+
asyncMessages().then(module => {
|
|
77
53
|
if (loadingLocaleRef.current !== locale) return;
|
|
78
|
-
|
|
79
|
-
if ('default' in module &&
|
|
80
|
-
setStore(
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
54
|
+
let messages = module;
|
|
55
|
+
if ('default' in module && typeof module.default === 'object') messages = module.default;
|
|
56
|
+
setStore(store => ({
|
|
57
|
+
...store,
|
|
58
|
+
[locale]: messages
|
|
59
|
+
}));
|
|
60
|
+
}).catch(err => {
|
|
84
61
|
// eslint-disable-next-line no-console
|
|
85
62
|
console.error(err);
|
|
86
63
|
});
|
|
87
64
|
}
|
|
88
65
|
}, [container, locale]);
|
|
89
|
-
return
|
|
66
|
+
return store[locale] ?? fallbackMessages;
|
|
90
67
|
};
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
68
|
+
exports.useAsyncI18nMessages = useAsyncI18nMessages;
|
|
69
|
+
var _default = container => {
|
|
70
|
+
return props => {
|
|
71
|
+
const {
|
|
72
|
+
i18n,
|
|
73
|
+
locale
|
|
74
|
+
} = props;
|
|
75
|
+
const getI18nText = (0, _WithI18n.useI18n)(i18n, locale, container);
|
|
76
|
+
return {
|
|
77
|
+
...props,
|
|
78
|
+
getI18nText
|
|
79
|
+
};
|
|
99
80
|
};
|
|
100
81
|
};
|
|
82
|
+
exports.default = _default;
|
|
101
83
|
//# sourceMappingURL=i18nEnhance.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18nEnhance.js","names":["_react","_interopRequireDefault","require","_WithI18n","useAsyncI18nMessages","
|
|
1
|
+
{"version":3,"file":"i18nEnhance.js","names":["_react","_interopRequireDefault","require","_WithI18n","useAsyncI18nMessages","primaryContainer","locale","fallbackContainer","container","React","useMemo","primary","fallback","Promise","all","initStore","store","setStore","useState","lastLoadedLocaleRef","useRef","current","fallbackMessages","Object","values","loadingLocaleRef","useEffect","asyncMessages","then","module","messages","default","catch","err","console","error","exports","_default","props","i18n","getI18nText","useI18n"],"sources":["../../../src/utils/enhances/i18nEnhance.tsx"],"sourcesContent":["import React from 'react';\n\nimport { type LocaleKeys, useI18n } from './WithI18n';\n\nexport type WithI18nEnhanceProps = {\n /* Function for getting the required field from the translation dictionary */\n getI18nText?: (key?: string, variables?: {}) => any;\n /* Object with translations */\n i18n?: {\n [locale: string]: {\n [key: string]: string;\n };\n };\n /* Locale for translations */\n locale?: LocaleKeys;\n};\n\ntype Messages = { [messageId: string]: string };\ntype MessagesContainer = { [locale: string]: Messages | (() => Promise<Messages>) };\ntype MessagesStore = { [locale: string]: Messages };\nexport const useAsyncI18nMessages = (\n primaryContainer: MessagesContainer,\n locale: string,\n fallbackContainer?: MessagesContainer,\n) => {\n const container = React.useMemo(() => {\n if (!fallbackContainer) return primaryContainer;\n if (!primaryContainer) return fallbackContainer;\n if (primaryContainer === fallbackContainer) return primaryContainer;\n const container: MessagesContainer = {};\n for (const locale in primaryContainer) {\n if (\n typeof primaryContainer[locale] === 'function' ||\n typeof fallbackContainer[locale] === 'function'\n ) {\n container[locale] = async () => {\n const [primary, fallback] = await Promise.all([\n primaryContainer[locale],\n fallbackContainer[locale],\n ]);\n return { ...primary, ...fallback };\n };\n } else {\n container[locale] = {\n ...(primaryContainer[locale] ?? {}),\n ...(fallbackContainer[locale] ?? {}),\n };\n }\n }\n return container;\n }, [primaryContainer, fallbackContainer]);\n const initStore = React.useMemo(() => {\n const store: MessagesStore = {};\n for (const locale in container) {\n if (typeof container[locale] === 'object') {\n store[locale] = container[locale] as Messages;\n }\n }\n return store;\n }, [container]);\n const [store, setStore] = React.useState(initStore);\n const lastLoadedLocaleRef = React.useRef<string | null>(null);\n if (store[locale]) lastLoadedLocaleRef.current = locale;\n const fallbackMessages = React.useMemo(() => Object.values(store)[0], [store]);\n\n const loadingLocaleRef = React.useRef<string | null>(null);\n React.useEffect(() => {\n loadingLocaleRef.current = locale;\n const asyncMessages = container[locale];\n if (typeof asyncMessages === 'function') {\n asyncMessages()\n .then((module) => {\n if (loadingLocaleRef.current !== locale) return;\n let messages = module;\n if ('default' in module && typeof module.default === 'object') messages = module.default;\n setStore((store) => ({\n ...store,\n [locale]: messages,\n }));\n })\n\n .catch((err) => {\n // eslint-disable-next-line no-console\n console.error(err);\n });\n }\n }, [container, locale]);\n\n return store[locale] ?? fallbackMessages;\n};\nexport default (container?: MessagesContainer) => {\n return (props: any): { getI18nText: ReturnType<typeof useI18n> } => {\n const { i18n, locale } = props;\n const getI18nText = useI18n(i18n, locale, container);\n\n return { ...props, getI18nText };\n };\n};\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -1,89 +1,75 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import _typeof from "@babel/runtime/helpers/esm/typeof";
|
|
3
|
-
import _regenerator from "@babel/runtime/helpers/esm/regenerator";
|
|
4
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
5
|
-
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
6
|
-
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
|
|
7
1
|
import React from "react";
|
|
8
2
|
import { useI18n } from "./WithI18n.mjs";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
var container = React.useMemo(function() {
|
|
3
|
+
const useAsyncI18nMessages = (primaryContainer, locale, fallbackContainer) => {
|
|
4
|
+
const container = React.useMemo(() => {
|
|
12
5
|
if (!fallbackContainer) return primaryContainer;
|
|
13
6
|
if (!primaryContainer) return fallbackContainer;
|
|
14
7
|
if (primaryContainer === fallbackContainer) return primaryContainer;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (typeof primaryContainer[
|
|
18
|
-
container2[
|
|
19
|
-
|
|
20
|
-
return
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
case 1:
|
|
26
|
-
_yield$Promise$all = _context.v;
|
|
27
|
-
_yield$Promise$all2 = _slicedToArray(_yield$Promise$all, 2);
|
|
28
|
-
primary = _yield$Promise$all2[0];
|
|
29
|
-
fallback = _yield$Promise$all2[1];
|
|
30
|
-
return _context.a(2, _objectSpread(_objectSpread({}, primary), fallback));
|
|
31
|
-
}
|
|
32
|
-
}, _callee);
|
|
33
|
-
}));
|
|
8
|
+
const container2 = {};
|
|
9
|
+
for (const locale2 in primaryContainer) {
|
|
10
|
+
if (typeof primaryContainer[locale2] === "function" || typeof fallbackContainer[locale2] === "function") {
|
|
11
|
+
container2[locale2] = async () => {
|
|
12
|
+
const [primary, fallback] = await Promise.all([primaryContainer[locale2], fallbackContainer[locale2]]);
|
|
13
|
+
return {
|
|
14
|
+
...primary,
|
|
15
|
+
...fallback
|
|
16
|
+
};
|
|
17
|
+
};
|
|
34
18
|
} else {
|
|
35
|
-
|
|
36
|
-
|
|
19
|
+
container2[locale2] = {
|
|
20
|
+
...primaryContainer[locale2] ?? {},
|
|
21
|
+
...fallbackContainer[locale2] ?? {}
|
|
22
|
+
};
|
|
37
23
|
}
|
|
38
|
-
};
|
|
39
|
-
for (var _locale in primaryContainer) {
|
|
40
|
-
_loop(_locale);
|
|
41
24
|
}
|
|
42
25
|
return container2;
|
|
43
26
|
}, [primaryContainer, fallbackContainer]);
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
for (
|
|
47
|
-
if (
|
|
48
|
-
store2[
|
|
27
|
+
const initStore = React.useMemo(() => {
|
|
28
|
+
const store2 = {};
|
|
29
|
+
for (const locale2 in container) {
|
|
30
|
+
if (typeof container[locale2] === "object") {
|
|
31
|
+
store2[locale2] = container[locale2];
|
|
49
32
|
}
|
|
50
33
|
}
|
|
51
34
|
return store2;
|
|
52
35
|
}, [container]);
|
|
53
|
-
|
|
54
|
-
|
|
36
|
+
const [store, setStore] = React.useState(initStore);
|
|
37
|
+
const lastLoadedLocaleRef = React.useRef(null);
|
|
55
38
|
if (store[locale]) lastLoadedLocaleRef.current = locale;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
var loadingLocaleRef = React.useRef(null);
|
|
60
|
-
React.useEffect(function() {
|
|
39
|
+
const fallbackMessages = React.useMemo(() => Object.values(store)[0], [store]);
|
|
40
|
+
const loadingLocaleRef = React.useRef(null);
|
|
41
|
+
React.useEffect(() => {
|
|
61
42
|
loadingLocaleRef.current = locale;
|
|
62
|
-
|
|
43
|
+
const asyncMessages = container[locale];
|
|
63
44
|
if (typeof asyncMessages === "function") {
|
|
64
|
-
asyncMessages().then(
|
|
45
|
+
asyncMessages().then((module) => {
|
|
65
46
|
if (loadingLocaleRef.current !== locale) return;
|
|
66
|
-
|
|
67
|
-
if ("default" in module &&
|
|
68
|
-
setStore(
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
47
|
+
let messages = module;
|
|
48
|
+
if ("default" in module && typeof module.default === "object") messages = module.default;
|
|
49
|
+
setStore((store2) => ({
|
|
50
|
+
...store2,
|
|
51
|
+
[locale]: messages
|
|
52
|
+
}));
|
|
53
|
+
}).catch((err) => {
|
|
72
54
|
console.error(err);
|
|
73
55
|
});
|
|
74
56
|
}
|
|
75
57
|
}, [container, locale]);
|
|
76
|
-
return
|
|
58
|
+
return store[locale] ?? fallbackMessages;
|
|
77
59
|
};
|
|
78
|
-
const i18nEnhance = (
|
|
79
|
-
return
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
60
|
+
const i18nEnhance = (container) => {
|
|
61
|
+
return (props) => {
|
|
62
|
+
const {
|
|
63
|
+
i18n,
|
|
64
|
+
locale
|
|
65
|
+
} = props;
|
|
66
|
+
const getI18nText = useI18n(i18n, locale, container);
|
|
67
|
+
return {
|
|
68
|
+
...props,
|
|
83
69
|
getI18nText
|
|
84
|
-
}
|
|
70
|
+
};
|
|
85
71
|
};
|
|
86
|
-
}
|
|
72
|
+
};
|
|
87
73
|
export {
|
|
88
74
|
i18nEnhance as default,
|
|
89
75
|
useAsyncI18nMessages
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"i18nEnhance.mjs","names":["React","useI18n","useAsyncI18nMessages","primaryContainer","locale","fallbackContainer","
|
|
1
|
+
{"version":3,"file":"i18nEnhance.mjs","names":["React","useI18n","useAsyncI18nMessages","primaryContainer","locale","fallbackContainer","container","useMemo","primary","fallback","Promise","all","initStore","store","setStore","useState","lastLoadedLocaleRef","useRef","current","fallbackMessages","Object","values","loadingLocaleRef","useEffect","asyncMessages","then","module","messages","default","catch","err","console","error","props","i18n","getI18nText"],"sources":["../../../src/utils/enhances/i18nEnhance.tsx"],"sourcesContent":["import React from 'react';\n\nimport { type LocaleKeys, useI18n } from './WithI18n';\n\nexport type WithI18nEnhanceProps = {\n /* Function for getting the required field from the translation dictionary */\n getI18nText?: (key?: string, variables?: {}) => any;\n /* Object with translations */\n i18n?: {\n [locale: string]: {\n [key: string]: string;\n };\n };\n /* Locale for translations */\n locale?: LocaleKeys;\n};\n\ntype Messages = { [messageId: string]: string };\ntype MessagesContainer = { [locale: string]: Messages | (() => Promise<Messages>) };\ntype MessagesStore = { [locale: string]: Messages };\nexport const useAsyncI18nMessages = (\n primaryContainer: MessagesContainer,\n locale: string,\n fallbackContainer?: MessagesContainer,\n) => {\n const container = React.useMemo(() => {\n if (!fallbackContainer) return primaryContainer;\n if (!primaryContainer) return fallbackContainer;\n if (primaryContainer === fallbackContainer) return primaryContainer;\n const container: MessagesContainer = {};\n for (const locale in primaryContainer) {\n if (\n typeof primaryContainer[locale] === 'function' ||\n typeof fallbackContainer[locale] === 'function'\n ) {\n container[locale] = async () => {\n const [primary, fallback] = await Promise.all([\n primaryContainer[locale],\n fallbackContainer[locale],\n ]);\n return { ...primary, ...fallback };\n };\n } else {\n container[locale] = {\n ...(primaryContainer[locale] ?? {}),\n ...(fallbackContainer[locale] ?? {}),\n };\n }\n }\n return container;\n }, [primaryContainer, fallbackContainer]);\n const initStore = React.useMemo(() => {\n const store: MessagesStore = {};\n for (const locale in container) {\n if (typeof container[locale] === 'object') {\n store[locale] = container[locale] as Messages;\n }\n }\n return store;\n }, [container]);\n const [store, setStore] = React.useState(initStore);\n const lastLoadedLocaleRef = React.useRef<string | null>(null);\n if (store[locale]) lastLoadedLocaleRef.current = locale;\n const fallbackMessages = React.useMemo(() => Object.values(store)[0], [store]);\n\n const loadingLocaleRef = React.useRef<string | null>(null);\n React.useEffect(() => {\n loadingLocaleRef.current = locale;\n const asyncMessages = container[locale];\n if (typeof asyncMessages === 'function') {\n asyncMessages()\n .then((module) => {\n if (loadingLocaleRef.current !== locale) return;\n let messages = module;\n if ('default' in module && typeof module.default === 'object') messages = module.default;\n setStore((store) => ({\n ...store,\n [locale]: messages,\n }));\n })\n\n .catch((err) => {\n // eslint-disable-next-line no-console\n console.error(err);\n });\n }\n }, [container, locale]);\n\n return store[locale] ?? fallbackMessages;\n};\nexport default (container?: MessagesContainer) => {\n return (props: any): { getI18nText: ReturnType<typeof useI18n> } => {\n const { i18n, locale } = props;\n const getI18nText = useI18n(i18n, locale, container);\n\n return { ...props, getI18nText };\n };\n};\n"],"mappings":"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","ignoreList":[]}
|
|
@@ -1,24 +1,26 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports
|
|
7
|
+
exports.default = void 0;
|
|
8
8
|
var _react = _interopRequireDefault(require("react"));
|
|
9
9
|
var _assignProps = _interopRequireDefault(require("../assignProps"));
|
|
10
10
|
var _ref = require("../ref");
|
|
11
11
|
var _useColorResolver = require("../use/useColorResolver");
|
|
12
|
-
|
|
13
|
-
return
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
const resolveColorEnhance = () => {
|
|
13
|
+
return props => {
|
|
14
|
+
const {
|
|
15
|
+
ref
|
|
16
|
+
} = props;
|
|
17
|
+
const internalRef = _react.default.useRef();
|
|
18
|
+
const resolveColor = (0, _useColorResolver.useColorResolver)();
|
|
19
|
+
return (0, _assignProps.default)(props, {
|
|
18
20
|
ref: (0, _ref.useForkRef)(ref, internalRef),
|
|
19
|
-
resolveColor
|
|
21
|
+
resolveColor
|
|
20
22
|
});
|
|
21
23
|
};
|
|
22
24
|
};
|
|
23
|
-
var _default = exports
|
|
25
|
+
var _default = exports.default = resolveColorEnhance;
|
|
24
26
|
//# sourceMappingURL=resolveColorEnhance.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveColorEnhance.js","names":["_react","_interopRequireDefault","require","_assignProps","_ref","_useColorResolver","resolveColorEnhance","props","ref","internalRef","React","useRef","resolveColor","useColorResolver","assignProps","useForkRef","_default","exports"],"sources":["../../../src/utils/enhances/resolveColorEnhance.tsx"],"sourcesContent":["import React from 'react';\n\nimport assignProps from '../assignProps';\nimport { useForkRef } from '../ref';\nimport { useColorResolver } from '../use/useColorResolver';\n\nconst resolveColorEnhance = () => {\n return (props: any) => {\n const { ref } = props;\n const internalRef = React.useRef<HTMLElement>();\n const resolveColor = useColorResolver();\n\n return assignProps(props, {\n ref: useForkRef(ref, internalRef),\n resolveColor,\n });\n };\n};\n\nexport default resolveColorEnhance;\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,IAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AAEA,
|
|
1
|
+
{"version":3,"file":"resolveColorEnhance.js","names":["_react","_interopRequireDefault","require","_assignProps","_ref","_useColorResolver","resolveColorEnhance","props","ref","internalRef","React","useRef","resolveColor","useColorResolver","assignProps","useForkRef","_default","exports","default"],"sources":["../../../src/utils/enhances/resolveColorEnhance.tsx"],"sourcesContent":["import React from 'react';\n\nimport assignProps from '../assignProps';\nimport { useForkRef } from '../ref';\nimport { useColorResolver } from '../use/useColorResolver';\n\nconst resolveColorEnhance = () => {\n return (props: any) => {\n const { ref } = props;\n const internalRef = React.useRef<HTMLElement>();\n const resolveColor = useColorResolver();\n\n return assignProps(props, {\n ref: useForkRef(ref, internalRef),\n resolveColor,\n });\n };\n};\n\nexport default resolveColorEnhance;\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,IAAA,GAAAF,OAAA;AACA,IAAAG,iBAAA,GAAAH,OAAA;AAEA,MAAMI,mBAAmB,GAAGA,CAAA,KAAM;EAChC,OAAQC,KAAU,IAAK;IACrB,MAAM;MAAEC;IAAI,CAAC,GAAGD,KAAK;IACrB,MAAME,WAAW,GAAGC,cAAK,CAACC,MAAM,CAAc,CAAC;IAC/C,MAAMC,YAAY,GAAG,IAAAC,kCAAgB,EAAC,CAAC;IAEvC,OAAO,IAAAC,oBAAW,EAACP,KAAK,EAAE;MACxBC,GAAG,EAAE,IAAAO,eAAU,EAACP,GAAG,EAAEC,WAAW,CAAC;MACjCG;IACF,CAAC,CAAC;EACJ,CAAC;AACH,CAAC;AAAC,IAAAI,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEaZ,mBAAmB","ignoreList":[]}
|
|
@@ -2,14 +2,16 @@ import React from 'react';
|
|
|
2
2
|
import assignProps from "../assignProps.mjs";
|
|
3
3
|
import { useForkRef } from "../ref.mjs";
|
|
4
4
|
import { useColorResolver } from "../use/useColorResolver.mjs";
|
|
5
|
-
|
|
6
|
-
return
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
const resolveColorEnhance = () => {
|
|
6
|
+
return props => {
|
|
7
|
+
const {
|
|
8
|
+
ref
|
|
9
|
+
} = props;
|
|
10
|
+
const internalRef = React.useRef();
|
|
11
|
+
const resolveColor = useColorResolver();
|
|
10
12
|
return assignProps(props, {
|
|
11
13
|
ref: useForkRef(ref, internalRef),
|
|
12
|
-
resolveColor
|
|
14
|
+
resolveColor
|
|
13
15
|
});
|
|
14
16
|
};
|
|
15
17
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveColorEnhance.mjs","names":["React","assignProps","useForkRef","useColorResolver","resolveColorEnhance","props","ref","internalRef","useRef","resolveColor"],"sources":["../../../src/utils/enhances/resolveColorEnhance.tsx"],"sourcesContent":["import React from 'react';\n\nimport assignProps from '../assignProps';\nimport { useForkRef } from '../ref';\nimport { useColorResolver } from '../use/useColorResolver';\n\nconst resolveColorEnhance = () => {\n return (props: any) => {\n const { ref } = props;\n const internalRef = React.useRef<HTMLElement>();\n const resolveColor = useColorResolver();\n\n return assignProps(props, {\n ref: useForkRef(ref, internalRef),\n resolveColor,\n });\n };\n};\n\nexport default resolveColorEnhance;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,OAAOC,WAAW,MAAM,oBAAgB;AACxC,SAASC,UAAU,QAAQ,YAAQ;AACnC,SAASC,gBAAgB,QAAQ,6BAAyB;AAE1D,
|
|
1
|
+
{"version":3,"file":"resolveColorEnhance.mjs","names":["React","assignProps","useForkRef","useColorResolver","resolveColorEnhance","props","ref","internalRef","useRef","resolveColor"],"sources":["../../../src/utils/enhances/resolveColorEnhance.tsx"],"sourcesContent":["import React from 'react';\n\nimport assignProps from '../assignProps';\nimport { useForkRef } from '../ref';\nimport { useColorResolver } from '../use/useColorResolver';\n\nconst resolveColorEnhance = () => {\n return (props: any) => {\n const { ref } = props;\n const internalRef = React.useRef<HTMLElement>();\n const resolveColor = useColorResolver();\n\n return assignProps(props, {\n ref: useForkRef(ref, internalRef),\n resolveColor,\n });\n };\n};\n\nexport default resolveColorEnhance;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,OAAOC,WAAW,MAAM,oBAAgB;AACxC,SAASC,UAAU,QAAQ,YAAQ;AACnC,SAASC,gBAAgB,QAAQ,6BAAyB;AAE1D,MAAMC,mBAAmB,GAAGA,CAAA,KAAM;EAChC,OAAQC,KAAU,IAAK;IACrB,MAAM;MAAEC;IAAI,CAAC,GAAGD,KAAK;IACrB,MAAME,WAAW,GAAGP,KAAK,CAACQ,MAAM,CAAc,CAAC;IAC/C,MAAMC,YAAY,GAAGN,gBAAgB,CAAC,CAAC;IAEvC,OAAOF,WAAW,CAACI,KAAK,EAAE;MACxBC,GAAG,EAAEJ,UAAU,CAACI,GAAG,EAAEC,WAAW,CAAC;MACjCE;IACF,CAAC,CAAC;EACJ,CAAC;AACH,CAAC;AAED,eAAeL,mBAAmB","ignoreList":[]}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
type
|
|
2
|
-
type
|
|
3
|
-
export default class EventEmitter<
|
|
1
|
+
type Events = Record<string, (...args: any[]) => void>;
|
|
2
|
+
type Cleanup = () => void;
|
|
3
|
+
export default class EventEmitter<E extends Events, K extends keyof E = keyof E, H extends E[K] = E[K]> {
|
|
4
4
|
private events;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
on(eventName: K, fn: H): Cleanup;
|
|
6
|
+
off(eventName: K, fn: H): void;
|
|
7
|
+
emit(eventName: K, ...args: Parameters<H>): void;
|
|
8
|
+
/**
|
|
9
|
+
* @deprecated. Fallback to the `on` method for backward compatibility.
|
|
10
|
+
*/
|
|
11
|
+
subscribe(eventName: K, fn: H): Cleanup;
|
|
8
12
|
}
|
|
9
13
|
export {};
|
|
@@ -1,40 +1,41 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports
|
|
8
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
9
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
7
|
+
exports.default = void 0;
|
|
10
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var event = _this.events[eventName];
|
|
22
|
-
if (event) {
|
|
23
|
-
event.forEach(function (fn) {
|
|
24
|
-
fn.call.apply(fn, [null].concat(args));
|
|
25
|
-
});
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
this.subscribe = function (eventName, fn) {
|
|
29
|
-
if (!_this.events[eventName]) {
|
|
30
|
-
_this.events[eventName] = [];
|
|
31
|
-
}
|
|
32
|
-
_this.events[eventName].push(fn);
|
|
33
|
-
return function () {
|
|
34
|
-
_this.events[eventName] = _this.events[eventName].filter(function (eventFn) {
|
|
35
|
-
return fn !== eventFn;
|
|
36
|
-
});
|
|
9
|
+
class EventEmitter {
|
|
10
|
+
constructor() {
|
|
11
|
+
(0, _defineProperty2.default)(this, "events", new Map());
|
|
12
|
+
}
|
|
13
|
+
on(eventName, fn) {
|
|
14
|
+
const handlers = this.events.get(eventName) ?? new Set();
|
|
15
|
+
handlers.add(fn);
|
|
16
|
+
this.events.set(eventName, handlers);
|
|
17
|
+
return () => {
|
|
18
|
+
this.off(eventName, fn);
|
|
37
19
|
};
|
|
38
|
-
}
|
|
39
|
-
|
|
20
|
+
}
|
|
21
|
+
off(eventName, fn) {
|
|
22
|
+
this.events.get(eventName)?.delete(fn);
|
|
23
|
+
}
|
|
24
|
+
emit(eventName, ...args) {
|
|
25
|
+
const handlers = this.events.get(eventName);
|
|
26
|
+
if (handlers) {
|
|
27
|
+
for (const handler of handlers) {
|
|
28
|
+
handler.call(null, ...args);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* @deprecated. Fallback to the `on` method for backward compatibility.
|
|
35
|
+
*/
|
|
36
|
+
subscribe(eventName, fn) {
|
|
37
|
+
return this.on(eventName, fn);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
exports.default = EventEmitter;
|
|
40
41
|
//# sourceMappingURL=eventEmitter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventEmitter.js","names":["EventEmitter","
|
|
1
|
+
{"version":3,"file":"eventEmitter.js","names":["EventEmitter","constructor","_defineProperty2","default","Map","on","eventName","fn","handlers","events","get","Set","add","set","off","delete","emit","args","handler","call","subscribe","exports"],"sources":["../../src/utils/eventEmitter.ts"],"sourcesContent":["type Events = Record<string, (...args: any[]) => void>;\ntype Cleanup = () => void;\n\nexport default class EventEmitter<E extends Events, K extends keyof E = keyof E, H extends E[K] = E[K]> {\n private events = new Map<K, Set<H>>();\n\n public on(eventName: K, fn: H): Cleanup {\n const handlers = this.events.get(eventName) ?? new Set<H>();\n\n handlers.add(fn);\n\n this.events.set(eventName, handlers);\n\n return () => {\n this.off(eventName, fn);\n };\n }\n\n public off(eventName: K, fn: H): void {\n this.events.get(eventName)?.delete(fn);\n }\n\n public emit(eventName: K, ...args: Parameters<H>) {\n const handlers = this.events.get(eventName);\n\n if (handlers) {\n for (const handler of handlers) {\n handler.call(null, ...args);\n }\n }\n }\n\n /**\n * @deprecated. Fallback to the `on` method for backward compatibility.\n */\n public subscribe(eventName: K, fn: H): Cleanup {\n return this.on(eventName, fn);\n }\n}\n"],"mappings":";;;;;;;;AAGe,MAAMA,YAAY,CAAuE;EAAAC,YAAA;IAAA,IAAAC,gBAAA,CAAAC,OAAA,kBACrF,IAAIC,GAAG,CAAY,CAAC;EAAA;EAE9BC,EAAEA,CAACC,SAAY,EAAEC,EAAK,EAAW;IACtC,MAAMC,QAAQ,GAAG,IAAI,CAACC,MAAM,CAACC,GAAG,CAACJ,SAAS,CAAC,IAAI,IAAIK,GAAG,CAAI,CAAC;IAE3DH,QAAQ,CAACI,GAAG,CAACL,EAAE,CAAC;IAEhB,IAAI,CAACE,MAAM,CAACI,GAAG,CAACP,SAAS,EAAEE,QAAQ,CAAC;IAEpC,OAAO,MAAM;MACX,IAAI,CAACM,GAAG,CAACR,SAAS,EAAEC,EAAE,CAAC;IACzB,CAAC;EACH;EAEOO,GAAGA,CAACR,SAAY,EAAEC,EAAK,EAAQ;IACpC,IAAI,CAACE,MAAM,CAACC,GAAG,CAACJ,SAAS,CAAC,EAAES,MAAM,CAACR,EAAE,CAAC;EACxC;EAEOS,IAAIA,CAACV,SAAY,EAAE,GAAGW,IAAmB,EAAE;IAChD,MAAMT,QAAQ,GAAG,IAAI,CAACC,MAAM,CAACC,GAAG,CAACJ,SAAS,CAAC;IAE3C,IAAIE,QAAQ,EAAE;MACZ,KAAK,MAAMU,OAAO,IAAIV,QAAQ,EAAE;QAC9BU,OAAO,CAACC,IAAI,CAAC,IAAI,EAAE,GAAGF,IAAI,CAAC;MAC7B;IACF;EACF;;EAEA;AACF;AACA;EACSG,SAASA,CAACd,SAAY,EAAEC,EAAK,EAAW;IAC7C,OAAO,IAAI,CAACF,EAAE,CAACC,SAAS,EAAEC,EAAE,CAAC;EAC/B;AACF;AAACc,OAAA,CAAAlB,OAAA,GAAAH,YAAA","ignoreList":[]}
|