@semcore/core 17.0.0-prerelease.20-prerelease.20 → 17.0.0-prerelease.21
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/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.js +25 -41
- package/lib/core-types/Component.js.map +1 -1
- package/lib/core-types/Component.mjs +18 -38
- 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.js +143 -205
- package/lib/coreFactory.js.map +1 -1
- package/lib/coreFactory.mjs +118 -164
- package/lib/coreFactory.mjs.map +1 -1
- package/lib/decorators/propsObserver.js +36 -64
- package/lib/decorators/propsObserver.js.map +1 -1
- package/lib/decorators/propsObserver.mjs +33 -61
- package/lib/decorators/propsObserver.mjs.map +1 -1
- package/lib/decorators/reactive.js +17 -17
- package/lib/decorators/reactive.js.map +1 -1
- package/lib/decorators/reactive.mjs +15 -15
- package/lib/decorators/reactive.mjs.map +1 -1
- 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 -65
- package/lib/enhancement/uncontrolledProps.js.map +1 -1
- package/lib/enhancement/uncontrolledProps.mjs +43 -52
- package/lib/enhancement/uncontrolledProps.mjs.map +1 -1
- package/lib/esm/LastInteractionType.mjs +19 -33
- package/lib/esm/core-types/Component.mjs +18 -38
- package/lib/esm/core-types/symbols.mjs +9 -9
- package/lib/esm/coreFactory.mjs +118 -164
- 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 -52
- 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 +15 -17
- 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 -43
- package/lib/esm/utils/use/useEnhancedEffect.mjs +1 -1
- package/lib/index.js +17 -17
- 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.js +4 -4
- 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.js +10 -8
- package/lib/utils/enhances/WithCSS.js.map +1 -1
- package/lib/utils/enhances/WithCSS.mjs +7 -6
- package/lib/utils/enhances/WithCSS.mjs.map +1 -1
- package/lib/utils/enhances/WithI18n.js +19 -19
- package/lib/utils/enhances/WithI18n.js.map +1 -1
- package/lib/utils/enhances/WithI18n.mjs +15 -17
- 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.js +55 -63
- package/lib/utils/enhances/animatedSizeEnhance.js.map +1 -1
- package/lib/utils/enhances/animatedSizeEnhance.mjs +50 -58
- 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.js +51 -67
- 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.js +30 -57
- package/lib/utils/eventEmitter.js.map +1 -1
- package/lib/utils/eventEmitter.mjs +26 -55
- 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/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.js +29 -47
- package/lib/utils/ref.js.map +1 -1
- package/lib/utils/ref.mjs +27 -43
- 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.js +22 -27
- package/lib/utils/uniqueID.js.map +1 -1
- package/lib/utils/uniqueID.mjs +18 -25
- 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.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.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 +1 -1
|
@@ -1,21 +1,22 @@
|
|
|
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 _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
9
|
-
var _objectSpread3 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread2"));
|
|
10
|
-
var _objectDestructuringEmpty2 = _interopRequireDefault(require("@babel/runtime/helpers/objectDestructuringEmpty"));
|
|
11
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
7
|
+
exports.default = void 0;
|
|
12
8
|
var _react = _interopRequireDefault(require("react"));
|
|
13
9
|
function contextEnhance(context, setOnProp) {
|
|
14
|
-
return
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
10
|
+
return props => {
|
|
11
|
+
const {
|
|
12
|
+
...other
|
|
13
|
+
} = props;
|
|
14
|
+
const value = _react.default.useContext(context);
|
|
15
|
+
return {
|
|
16
|
+
...other,
|
|
17
|
+
[setOnProp]: value
|
|
18
|
+
};
|
|
18
19
|
};
|
|
19
20
|
}
|
|
20
|
-
var _default = exports
|
|
21
|
+
var _default = exports.default = contextEnhance;
|
|
21
22
|
//# sourceMappingURL=contextEnhance.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextEnhance.js","names":["_react","_interopRequireDefault","require","contextEnhance","context","setOnProp","props","other","
|
|
1
|
+
{"version":3,"file":"contextEnhance.js","names":["_react","_interopRequireDefault","require","contextEnhance","context","setOnProp","props","other","value","React","useContext","_default","exports","default"],"sources":["../../../src/utils/enhances/contextEnhance.tsx"],"sourcesContent":["import React from 'react';\n\nfunction contextEnhance(context: React.Context<any>, setOnProp: string) {\n return (props: any) => {\n const { ...other } = props;\n const value = React.useContext(context);\n return {\n ...other,\n [setOnProp]: value,\n };\n };\n}\n\nexport default contextEnhance;\n"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,SAASC,cAAcA,CAACC,OAA2B,EAAEC,SAAiB,EAAE;EACtE,OAAQC,KAAU,IAAK;IACrB,MAAM;MAAE,GAAGC;IAAM,CAAC,GAAGD,KAAK;IAC1B,MAAME,KAAK,GAAGC,cAAK,CAACC,UAAU,CAACN,OAAO,CAAC;IACvC,OAAO;MACL,GAAGG,KAAK;MACR,CAACF,SAAS,GAAGG;IACf,CAAC;EACH,CAAC;AACH;AAAC,IAAAG,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEcV,cAAc","ignoreList":[]}
|
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
3
|
-
import _objectDestructuringEmpty from "@babel/runtime/helpers/esm/objectDestructuringEmpty";
|
|
4
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
5
1
|
import React from 'react';
|
|
6
2
|
function contextEnhance(context, setOnProp) {
|
|
7
|
-
return
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
3
|
+
return props => {
|
|
4
|
+
const {
|
|
5
|
+
...other
|
|
6
|
+
} = props;
|
|
7
|
+
const value = React.useContext(context);
|
|
8
|
+
return {
|
|
9
|
+
...other,
|
|
10
|
+
[setOnProp]: value
|
|
11
|
+
};
|
|
11
12
|
};
|
|
12
13
|
}
|
|
13
14
|
export default contextEnhance;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contextEnhance.mjs","names":["React","contextEnhance","context","setOnProp","props","other","
|
|
1
|
+
{"version":3,"file":"contextEnhance.mjs","names":["React","contextEnhance","context","setOnProp","props","other","value","useContext"],"sources":["../../../src/utils/enhances/contextEnhance.tsx"],"sourcesContent":["import React from 'react';\n\nfunction contextEnhance(context: React.Context<any>, setOnProp: string) {\n return (props: any) => {\n const { ...other } = props;\n const value = React.useContext(context);\n return {\n ...other,\n [setOnProp]: value,\n };\n };\n}\n\nexport default contextEnhance;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAASC,cAAcA,CAACC,OAA2B,EAAEC,SAAiB,EAAE;EACtE,OAAQC,KAAU,IAAK;IACrB,MAAM;MAAE,GAAGC;IAAM,CAAC,GAAGD,KAAK;IAC1B,MAAME,KAAK,GAAGN,KAAK,CAACO,UAAU,CAACL,OAAO,CAAC;IACvC,OAAO;MACL,GAAGG,KAAK;MACR,CAACF,SAAS,GAAGG;IACf,CAAC;EACH,CAAC;AACH;AAEA,eAAeL,cAAc","ignoreList":[]}
|
|
@@ -1,99 +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 container = _react["default"].useMemo(function () {
|
|
10
|
+
const useAsyncI18nMessages = (primaryContainer, locale, fallbackContainer) => {
|
|
11
|
+
const container = _react.default.useMemo(() => {
|
|
19
12
|
if (!fallbackContainer) return primaryContainer;
|
|
20
13
|
if (!primaryContainer) return fallbackContainer;
|
|
21
14
|
if (primaryContainer === fallbackContainer) return primaryContainer;
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
if (typeof primaryContainer[
|
|
25
|
-
container[
|
|
26
|
-
|
|
27
|
-
return
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
case 1:
|
|
33
|
-
_yield$Promise$all = _context.v;
|
|
34
|
-
_yield$Promise$all2 = (0, _slicedToArray2["default"])(_yield$Promise$all, 2);
|
|
35
|
-
primary = _yield$Promise$all2[0];
|
|
36
|
-
fallback = _yield$Promise$all2[1];
|
|
37
|
-
return _context.a(2, (0, _objectSpread3["default"])((0, _objectSpread3["default"])({}, primary), fallback));
|
|
38
|
-
}
|
|
39
|
-
}, _callee);
|
|
40
|
-
}));
|
|
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
|
+
};
|
|
41
25
|
} else {
|
|
42
|
-
|
|
43
|
-
|
|
26
|
+
container[locale] = {
|
|
27
|
+
...(primaryContainer[locale] ?? {}),
|
|
28
|
+
...(fallbackContainer[locale] ?? {})
|
|
29
|
+
};
|
|
44
30
|
}
|
|
45
|
-
};
|
|
46
|
-
for (var _locale in primaryContainer) {
|
|
47
|
-
_loop(_locale);
|
|
48
31
|
}
|
|
49
32
|
return container;
|
|
50
33
|
}, [primaryContainer, fallbackContainer]);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
for (
|
|
54
|
-
if (
|
|
55
|
-
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];
|
|
56
39
|
}
|
|
57
40
|
}
|
|
58
41
|
return store;
|
|
59
42
|
}, [container]);
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
store = _React$useState2[0],
|
|
63
|
-
setStore = _React$useState2[1];
|
|
64
|
-
var lastLoadedLocaleRef = _react["default"].useRef(null);
|
|
43
|
+
const [store, setStore] = _react.default.useState(initStore);
|
|
44
|
+
const lastLoadedLocaleRef = _react.default.useRef(null);
|
|
65
45
|
if (store[locale]) lastLoadedLocaleRef.current = locale;
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
var loadingLocaleRef = _react["default"].useRef(null);
|
|
70
|
-
_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(() => {
|
|
71
49
|
loadingLocaleRef.current = locale;
|
|
72
|
-
|
|
50
|
+
const asyncMessages = container[locale];
|
|
73
51
|
if (typeof asyncMessages === 'function') {
|
|
74
|
-
asyncMessages().then(
|
|
52
|
+
asyncMessages().then(module => {
|
|
75
53
|
if (loadingLocaleRef.current !== locale) return;
|
|
76
|
-
|
|
77
|
-
if ('default' in module &&
|
|
78
|
-
setStore(
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
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 => {
|
|
82
61
|
// eslint-disable-next-line no-console
|
|
83
62
|
console.error(err);
|
|
84
63
|
});
|
|
85
64
|
}
|
|
86
65
|
}, [container, locale]);
|
|
87
|
-
return
|
|
66
|
+
return store[locale] ?? fallbackMessages;
|
|
88
67
|
};
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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
|
+
};
|
|
97
80
|
};
|
|
98
81
|
};
|
|
82
|
+
exports.default = _default;
|
|
99
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":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,SAAA,GAAAD,OAAA;AAkBO,MAAME,oBAAoB,GAAGA,CAClCC,gBAAmC,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AACzB,SAAS,EAAEF,MAAM,CAAC,CAAC;EAEvB,OAAOU,KAAK,CAACV,MAAM,CAAC,IAAIgB,gBAAgB;AAC1C,CAAC;AAACc,OAAA,CAAAhC,oBAAA,GAAAA,oBAAA;AAAA,IAAAiC,QAAA,GACc7B,SAA6B,IAAK;EAChD,OAAQ8B,KAAU,IAAkD;IAClE,MAAM;MAAEC,IAAI;MAAEjC;IAAO,CAAC,GAAGgC,KAAK;IAC9B,MAAME,WAAW,GAAG,IAAAC,iBAAO,EAACF,IAAI,EAAEjC,MAAM,EAAEE,SAAS,CAAC;IAEpD,OAAO;MAAE,GAAG8B,KAAK;MAAEE;IAAY,CAAC;EAClC,CAAC;AACH,CAAC;AAAAJ,OAAA,CAAAL,OAAA,GAAAM,QAAA","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":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,SAA0BC,OAAO,QAAQ,gBAAY;AAkBrD,OAAO,MAAMC,oBAAoB,GAAGA,CAClCC,gBAAmC,EACnCC,MAAc,EACdC,iBAAqC,KAClC;EACH,MAAMC,SAAS,GAAGN,KAAK,CAACO,OAAO,CAAC,MAAM;IACpC,IAAI,CAACF,iBAAiB,EAAE,OAAOF,gBAAgB;IAC/C,IAAI,CAACA,gBAAgB,EAAE,OAAOE,iBAAiB;IAC/C,IAAIF,gBAAgB,KAAKE,iBAAiB,EAAE,OAAOF,gBAAgB;IACnE,MAAMG,SAA4B,GAAG,CAAC,CAAC;IACvC,KAAK,MAAMF,MAAM,IAAID,gBAAgB,EAAE;MACrC,IACE,OAAOA,gBAAg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;EAClC,CAAC;AACH,CAAC","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":[]}
|