@semcore/core 17.0.0-prerelease.20-prerelease.20 → 17.0.0-prerelease.22
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,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _Symbol = function _Symbol2(key) {
|
|
4
|
-
return typeof Symbol !== "undefined" ? Symbol(key) : key;
|
|
5
|
-
};
|
|
6
|
-
var KEYS = {
|
|
1
|
+
const _Symbol = (key) => typeof Symbol !== "undefined" ? Symbol(key) : key;
|
|
2
|
+
const KEYS = {
|
|
7
3
|
__id__: _Symbol("__id__"),
|
|
8
4
|
__store__: _Symbol("__store__"),
|
|
9
5
|
__prev__: _Symbol("__prev__"),
|
|
@@ -18,44 +14,48 @@ var KEYS = {
|
|
|
18
14
|
*/
|
|
19
15
|
__classProp__: "className"
|
|
20
16
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
let index = 0;
|
|
18
|
+
const use = (obj) => {
|
|
19
|
+
const result = {};
|
|
24
20
|
result[KEYS.__use__] = obj;
|
|
25
21
|
return result;
|
|
26
22
|
};
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
for (
|
|
34
|
-
|
|
35
|
-
if (!
|
|
36
|
-
if (!
|
|
37
|
-
|
|
38
|
-
|
|
23
|
+
const create = (args) => {
|
|
24
|
+
const len = args.length;
|
|
25
|
+
let newStyle = {};
|
|
26
|
+
let id = "";
|
|
27
|
+
let vars = null;
|
|
28
|
+
let uses = null;
|
|
29
|
+
for (let i = 0; i < len; i++) {
|
|
30
|
+
const style2 = args[i];
|
|
31
|
+
if (!style2) continue;
|
|
32
|
+
if (!style2[KEYS.__id__]) {
|
|
33
|
+
style2[KEYS.__id__] = ++index;
|
|
34
|
+
style2[KEYS.__store__] = {
|
|
35
|
+
["_" + style2[KEYS.__id__]]: style2
|
|
36
|
+
};
|
|
39
37
|
}
|
|
40
|
-
id += "_" +
|
|
41
|
-
if (
|
|
42
|
-
vars = Object.assign(vars || {},
|
|
38
|
+
id += "_" + style2[KEYS.__id__];
|
|
39
|
+
if (style2[KEYS.__style__]) {
|
|
40
|
+
vars = Object.assign(vars || {}, style2[KEYS.__style__]);
|
|
43
41
|
}
|
|
44
|
-
if (
|
|
45
|
-
uses = Object.assign(uses || {},
|
|
42
|
+
if (style2[KEYS.__use__]) {
|
|
43
|
+
uses = Object.assign(uses || {}, style2[KEYS.__use__]);
|
|
46
44
|
}
|
|
47
|
-
if (
|
|
48
|
-
newStyle =
|
|
45
|
+
if (style2[KEYS.__store__][id]) {
|
|
46
|
+
newStyle = style2[KEYS.__store__][id];
|
|
49
47
|
continue;
|
|
50
48
|
}
|
|
51
49
|
newStyle = Object.create(newStyle);
|
|
52
|
-
for (
|
|
50
|
+
for (const key in style2) {
|
|
53
51
|
if (key in KEYS) continue;
|
|
54
|
-
newStyle[key] = appendClassName(
|
|
52
|
+
newStyle[key] = appendClassName(style2[key], newStyle[key]);
|
|
55
53
|
}
|
|
56
|
-
|
|
54
|
+
style2[KEYS.__store__][id] = newStyle;
|
|
57
55
|
newStyle[KEYS.__id__] = index;
|
|
58
|
-
newStyle[KEYS.__store__] =
|
|
56
|
+
newStyle[KEYS.__store__] = {
|
|
57
|
+
["_" + style2[KEYS.__id__]]: newStyle
|
|
58
|
+
};
|
|
59
59
|
}
|
|
60
60
|
if (vars || use) {
|
|
61
61
|
newStyle = Object.create(newStyle);
|
|
@@ -64,130 +64,117 @@ var create = function create2(args) {
|
|
|
64
64
|
}
|
|
65
65
|
return newStyle;
|
|
66
66
|
};
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
serverStyles2 += '<style type="text/css" id="'.concat(id, '">').concat(serverMap[id], "</style>");
|
|
76
|
-
}
|
|
77
|
-
return serverStyles2;
|
|
67
|
+
const isSSR = !(typeof window !== "undefined" && window.document && window.document.createElement);
|
|
68
|
+
const serverMap = {};
|
|
69
|
+
const getStyles = () => ({
|
|
70
|
+
map: serverMap,
|
|
71
|
+
get css() {
|
|
72
|
+
let serverStyles2 = "";
|
|
73
|
+
for (const id in serverMap) {
|
|
74
|
+
serverStyles2 += `<style type="text/css" id="${id}">${serverMap[id]}</style>`;
|
|
78
75
|
}
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
|
|
76
|
+
return serverStyles2;
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
const clearStyles = () => {
|
|
82
80
|
serverStyles = "";
|
|
83
81
|
};
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
}
|
|
88
|
-
var css = function css2(code, hash) {
|
|
89
|
-
var id = "reshadow-".concat(hash);
|
|
82
|
+
const RESHADOW_ID = "__reshadow__";
|
|
83
|
+
const appendChildToDocumentHead = (element) => document.head.appendChild(element);
|
|
84
|
+
const css = (code, hash) => {
|
|
85
|
+
const id = `reshadow-${hash}`;
|
|
90
86
|
if (isSSR) {
|
|
91
87
|
serverMap[id] = code;
|
|
92
88
|
return;
|
|
93
89
|
}
|
|
94
|
-
|
|
90
|
+
let container = document.getElementById(RESHADOW_ID);
|
|
95
91
|
if (!container) {
|
|
96
92
|
container = document.createElement("object");
|
|
97
93
|
container.id = RESHADOW_ID;
|
|
98
94
|
if (document.head) {
|
|
99
95
|
appendChildToDocumentHead(container);
|
|
100
96
|
} else {
|
|
101
|
-
document.addEventListener("DOMContentLoaded",
|
|
97
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
102
98
|
appendChildToDocumentHead(container);
|
|
103
99
|
});
|
|
104
100
|
}
|
|
105
101
|
}
|
|
106
|
-
|
|
107
|
-
if (!
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
container.appendChild(
|
|
102
|
+
let css2 = document.getElementById(id);
|
|
103
|
+
if (!css2) {
|
|
104
|
+
css2 = document.createElement("style");
|
|
105
|
+
css2.id = id;
|
|
106
|
+
css2.type = "text/css";
|
|
107
|
+
container.appendChild(css2);
|
|
112
108
|
}
|
|
113
|
-
|
|
109
|
+
css2.innerHTML = code;
|
|
114
110
|
};
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
111
|
+
let styles = {};
|
|
112
|
+
let style;
|
|
113
|
+
const stack = [];
|
|
114
|
+
const styled = (elem) => {
|
|
115
|
+
const curr = stack.pop() || [];
|
|
120
116
|
styles = curr[0] || styles;
|
|
121
117
|
style = curr[1] || style;
|
|
122
|
-
|
|
123
|
-
|
|
118
|
+
styled[KEYS.__styles__] = styles;
|
|
119
|
+
styled[KEYS.__style__] = style;
|
|
124
120
|
return elem;
|
|
125
121
|
};
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
122
|
+
styled[KEYS.__styles__] = styles;
|
|
123
|
+
const set = (args, newStyle) => {
|
|
124
|
+
const newStyles = create(args);
|
|
129
125
|
stack.push([styles, style]);
|
|
130
126
|
styles = newStyles;
|
|
131
127
|
style = newStyle;
|
|
132
128
|
if (styles[KEYS.__style__]) {
|
|
133
129
|
style = style ? Object.assign({}, style, styles[KEYS.__style__]) : styles[KEYS.__style__];
|
|
134
130
|
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
};
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
var parseAttribute = function parseAttribute2(name) {
|
|
146
|
-
return name.replace(MOD_PREFIX, "").split(MOD_SEPARATOR);
|
|
147
|
-
};
|
|
148
|
-
var appendClassName = function appendClassName2(className) {
|
|
149
|
-
var cn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : "";
|
|
131
|
+
styled[KEYS.__styles__] = styles;
|
|
132
|
+
styled[KEYS.__style__] = style;
|
|
133
|
+
};
|
|
134
|
+
const USE_PREFIX = "use--";
|
|
135
|
+
const ELEMENT_PREFIX = "__";
|
|
136
|
+
const MOD_PREFIX = "_";
|
|
137
|
+
const MOD_SEPARATOR = "_";
|
|
138
|
+
const parseElement = (name) => name.replace(ELEMENT_PREFIX, "");
|
|
139
|
+
const parseAttribute = (name) => name.replace(MOD_PREFIX, "").split(MOD_SEPARATOR);
|
|
140
|
+
const appendClassName = (className, cn = "") => {
|
|
150
141
|
if (className) {
|
|
151
142
|
cn += (cn ? " " : "") + className;
|
|
152
143
|
}
|
|
153
144
|
return cn;
|
|
154
145
|
};
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
return appendClassName(styles2[ELEMENT_PREFIX + key], cn);
|
|
158
|
-
};
|
|
159
|
-
var appendModifier = function appendModifier2(styles2, key, value) {
|
|
160
|
-
var cn = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : "";
|
|
146
|
+
const appendElement = (styles2, key, cn = "") => appendClassName(styles2[ELEMENT_PREFIX + key], cn);
|
|
147
|
+
const appendModifier = (styles2, key, value, cn = "") => {
|
|
161
148
|
if (value === void 0 || value === null || value === false || value === "") return cn;
|
|
162
149
|
cn = appendClassName(styles2[MOD_PREFIX + key], cn);
|
|
163
|
-
if (typeof value === "boolean" ||
|
|
150
|
+
if (typeof value === "boolean" || typeof value === "object" || typeof value === "function") return cn;
|
|
164
151
|
cn = appendClassName(styles2[MOD_SEPARATOR + key + MOD_SEPARATOR + value], cn);
|
|
165
152
|
return cn;
|
|
166
153
|
};
|
|
167
154
|
function map(element) {
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
for (
|
|
176
|
-
|
|
155
|
+
const currStyles = styled[KEYS.__styles__];
|
|
156
|
+
const nextProps = {};
|
|
157
|
+
let cn = appendElement(currStyles, element);
|
|
158
|
+
let vars = null;
|
|
159
|
+
const uses = currStyles[KEYS.__use__] || {};
|
|
160
|
+
const len = arguments.length;
|
|
161
|
+
let useProps;
|
|
162
|
+
for (let i = len - 1; i > 0; i--) {
|
|
163
|
+
const currProps = arguments[i];
|
|
177
164
|
if (!currProps) continue;
|
|
178
165
|
useProps = useProps || currProps[KEYS.__use__];
|
|
179
166
|
if (!vars && KEYS.__style__ in currProps) {
|
|
180
|
-
vars =
|
|
167
|
+
vars = styled[KEYS.__style__];
|
|
181
168
|
}
|
|
182
|
-
for (
|
|
169
|
+
for (const key in currProps) {
|
|
183
170
|
if (key === KEYS.__use__ || key === KEYS.__style__ || key in nextProps) {
|
|
184
171
|
continue;
|
|
185
172
|
}
|
|
186
|
-
|
|
173
|
+
const value = currProps[key];
|
|
187
174
|
cn = appendModifier(currStyles, key, value, cn);
|
|
188
|
-
|
|
175
|
+
const valueType = typeof value;
|
|
189
176
|
if (valueType === "string" || valueType === "boolean" || valueType === "number") {
|
|
190
|
-
|
|
177
|
+
const useKey = key + "_" + value;
|
|
191
178
|
if (key + "_true" in uses || useKey in uses) {
|
|
192
179
|
cn = appendModifier(currStyles, USE_PREFIX + key, value, cn);
|
|
193
180
|
if (uses[useKey]) {
|
|
@@ -199,9 +186,9 @@ function map(element) {
|
|
|
199
186
|
}
|
|
200
187
|
}
|
|
201
188
|
if (useProps) {
|
|
202
|
-
for (
|
|
203
|
-
|
|
204
|
-
cn = appendModifier(currStyles, USE_PREFIX +
|
|
189
|
+
for (const key in useProps) {
|
|
190
|
+
const value = useProps[key];
|
|
191
|
+
cn = appendModifier(currStyles, USE_PREFIX + key, value, cn);
|
|
205
192
|
}
|
|
206
193
|
}
|
|
207
194
|
cn = appendClassName(nextProps[KEYS.__classProp__], cn);
|
|
@@ -229,6 +216,6 @@ export {
|
|
|
229
216
|
parseAttribute,
|
|
230
217
|
parseElement,
|
|
231
218
|
set,
|
|
232
|
-
|
|
219
|
+
styled,
|
|
233
220
|
use
|
|
234
221
|
};
|
|
@@ -1,28 +1,25 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _cn from "classnames";
|
|
1
|
+
import cn from "classnames";
|
|
3
2
|
import { getStyles as getStyles$1 } from "./reshadow-core.mjs";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
serverStyles += "<style type='text/css' id='".concat(id, "'>").concat(serverMap[id], "</style>");
|
|
14
|
-
}
|
|
15
|
-
return serverStyles;
|
|
3
|
+
const RESHADOW_ID = "__reshadow__";
|
|
4
|
+
const isSSR = !(typeof window !== "undefined" && window.document && window.document.createElement);
|
|
5
|
+
const serverMap = getStyles$1().map;
|
|
6
|
+
const getStyles = () => ({
|
|
7
|
+
map: serverMap,
|
|
8
|
+
get css() {
|
|
9
|
+
let serverStyles = "";
|
|
10
|
+
for (const id in serverMap) {
|
|
11
|
+
serverStyles += `<style type='text/css' id='${id}'>${serverMap[id]}</style>`;
|
|
16
12
|
}
|
|
17
|
-
|
|
18
|
-
}
|
|
13
|
+
return serverStyles;
|
|
14
|
+
}
|
|
15
|
+
});
|
|
19
16
|
function insert(code, hash) {
|
|
20
|
-
|
|
17
|
+
const id = "reshadow-".concat(hash);
|
|
21
18
|
if (isSSR) {
|
|
22
19
|
serverMap[id] = code;
|
|
23
20
|
return;
|
|
24
21
|
}
|
|
25
|
-
|
|
22
|
+
let container = document.getElementById(RESHADOW_ID);
|
|
26
23
|
if (!container) {
|
|
27
24
|
container = document.createElement("object");
|
|
28
25
|
container.id = RESHADOW_ID;
|
|
@@ -34,7 +31,7 @@ function insert(code, hash) {
|
|
|
34
31
|
});
|
|
35
32
|
}
|
|
36
33
|
}
|
|
37
|
-
|
|
34
|
+
let css = document.getElementById(id);
|
|
38
35
|
if (!css) {
|
|
39
36
|
css = document.createElement("style");
|
|
40
37
|
css.id = id;
|
|
@@ -43,35 +40,30 @@ function insert(code, hash) {
|
|
|
43
40
|
}
|
|
44
41
|
css.innerHTML = code;
|
|
45
42
|
}
|
|
46
|
-
function merge() {
|
|
47
|
-
|
|
48
|
-
var s2 = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
49
|
-
return Object.entries(s2).reduce(function(acc, _ref) {
|
|
50
|
-
var _ref2 = _slicedToArray(_ref, 2), key = _ref2[0], value = _ref2[1];
|
|
43
|
+
function merge(s1 = {}, s2 = {}) {
|
|
44
|
+
return Object.entries(s2).reduce((acc, [key, value]) => {
|
|
51
45
|
if (key.startsWith("@") || key.startsWith("--")) {
|
|
52
46
|
acc[key] = value;
|
|
53
47
|
} else {
|
|
54
|
-
acc[key] =
|
|
48
|
+
acc[key] = cn(acc[key], value);
|
|
55
49
|
}
|
|
56
50
|
return acc;
|
|
57
51
|
}, Object.assign({}, s1));
|
|
58
52
|
}
|
|
59
53
|
function getClassAndVars(styles, name, props) {
|
|
60
54
|
function getPropValue(key, props2) {
|
|
61
|
-
|
|
62
|
-
return (_props = props2["use:".concat(key)]) !== null && _props !== void 0 ? _props : props2[key];
|
|
55
|
+
return props2[`use:${key}`] ?? props2[key];
|
|
63
56
|
}
|
|
64
|
-
return Object.entries(styles).reduce(
|
|
65
|
-
var _ref4 = _slicedToArray(_ref3, 2), key = _ref4[0], value = _ref4[1];
|
|
57
|
+
return Object.entries(styles).reduce((acc, [key, value]) => {
|
|
66
58
|
if (key.startsWith("--")) {
|
|
67
59
|
acc[1][value] = getPropValue(key.substring(2), props);
|
|
68
60
|
} else if (name === key) {
|
|
69
61
|
acc[0][value] = true;
|
|
70
62
|
} else {
|
|
71
|
-
|
|
72
|
-
|
|
63
|
+
const [mod, modValue] = key.split("=");
|
|
64
|
+
const propValue = getPropValue(mod, props);
|
|
73
65
|
if (modValue === void 0) {
|
|
74
|
-
acc[0][value] = Boolean(propValue
|
|
66
|
+
acc[0][value] = Boolean(propValue ?? false);
|
|
75
67
|
} else {
|
|
76
68
|
acc[0][value] = propValue == modValue;
|
|
77
69
|
}
|
|
@@ -79,14 +71,13 @@ function getClassAndVars(styles, name, props) {
|
|
|
79
71
|
return acc;
|
|
80
72
|
}, [{}, {}]);
|
|
81
73
|
}
|
|
82
|
-
|
|
74
|
+
const reshadowMap = /* @__PURE__ */ new WeakMap();
|
|
83
75
|
function reshadowToShadow(obj) {
|
|
84
76
|
if (reshadowMap.has(obj)) {
|
|
85
77
|
return reshadowMap.get(obj);
|
|
86
78
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
var n = name;
|
|
79
|
+
const shadowStyle = Object.entries(obj).reduce((style, [name, value]) => {
|
|
80
|
+
let n = name;
|
|
90
81
|
if (name.startsWith("__")) {
|
|
91
82
|
n = name.replace(/^__/, "");
|
|
92
83
|
} else if (name.startsWith("_")) {
|
|
@@ -98,13 +89,12 @@ function reshadowToShadow(obj) {
|
|
|
98
89
|
reshadowMap.set(obj, shadowStyle);
|
|
99
90
|
return shadowStyle;
|
|
100
91
|
}
|
|
101
|
-
function sstyled() {
|
|
102
|
-
var styles = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
92
|
+
function sstyled(styles = {}) {
|
|
103
93
|
return {
|
|
104
|
-
cn
|
|
105
|
-
|
|
94
|
+
cn(name, props) {
|
|
95
|
+
const [classes, style] = getClassAndVars(reshadowToShadow(styles), name, props);
|
|
106
96
|
if (Object.keys(classes).length) {
|
|
107
|
-
props.className =
|
|
97
|
+
props.className = cn(props.className, classes);
|
|
108
98
|
}
|
|
109
99
|
if (Object.keys(style).length) {
|
|
110
100
|
props.style = Object.assign(style, props.style);
|
|
@@ -1,27 +1,18 @@
|
|
|
1
|
-
import
|
|
2
|
-
import _cn from "classnames";
|
|
1
|
+
import cn from "classnames";
|
|
3
2
|
import { forkRef } from "./ref.mjs";
|
|
4
3
|
import "../styled/index.mjs";
|
|
5
4
|
import { sstyled } from "../styled/sstyled.mjs";
|
|
6
|
-
function callAllEventHandlers() {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
12
|
-
args[_key2] = arguments[_key2];
|
|
5
|
+
function callAllEventHandlers(...fns) {
|
|
6
|
+
return (...args) => !fns.some((fn) => {
|
|
7
|
+
let result;
|
|
8
|
+
if (fn) {
|
|
9
|
+
result = fn(...args);
|
|
13
10
|
}
|
|
14
|
-
return !
|
|
15
|
-
|
|
16
|
-
if (fn) {
|
|
17
|
-
result = fn.apply(void 0, args);
|
|
18
|
-
}
|
|
19
|
-
return typeof result === "boolean" && !result;
|
|
20
|
-
});
|
|
21
|
-
};
|
|
11
|
+
return typeof result === "boolean" && !result;
|
|
12
|
+
});
|
|
22
13
|
}
|
|
23
14
|
function assignHandlers(props, source) {
|
|
24
|
-
return Object.keys(source).reduce(
|
|
15
|
+
return Object.keys(source).reduce((proxySource, propName) => {
|
|
25
16
|
if (typeof source[propName] === "function" && propName.startsWith("on")) {
|
|
26
17
|
proxySource[propName] = callAllEventHandlers(props[propName], source[propName]);
|
|
27
18
|
}
|
|
@@ -29,7 +20,7 @@ function assignHandlers(props, source) {
|
|
|
29
20
|
}, {});
|
|
30
21
|
}
|
|
31
22
|
function assignHandlersInner(props, source) {
|
|
32
|
-
return Object.keys(source).reduce(
|
|
23
|
+
return Object.keys(source).reduce((proxySource, propName) => {
|
|
33
24
|
if (propName !== "ref" && propName.startsWith("on")) {
|
|
34
25
|
if (typeof source[propName] === "function" && typeof props[propName] === "function") {
|
|
35
26
|
proxySource[propName] = callAllEventHandlers(props[propName], source[propName]);
|
|
@@ -42,26 +33,28 @@ function assignHandlersInner(props, source) {
|
|
|
42
33
|
return proxySource;
|
|
43
34
|
}, {});
|
|
44
35
|
}
|
|
45
|
-
function assignProps() {
|
|
46
|
-
var props = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
47
|
-
var source = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
36
|
+
function assignProps(props = {}, source = {}) {
|
|
48
37
|
if (props === source) return props;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
38
|
+
const newProps = {
|
|
39
|
+
...source,
|
|
40
|
+
...props,
|
|
41
|
+
...assignHandlersInner(props, source)
|
|
42
|
+
};
|
|
43
|
+
for (const key in source) {
|
|
44
|
+
if (key.startsWith("use:")) {
|
|
45
|
+
const originalKey = key.slice("use:".length);
|
|
46
|
+
newProps[originalKey] = source[key];
|
|
54
47
|
}
|
|
55
48
|
}
|
|
56
|
-
for (
|
|
57
|
-
if (
|
|
58
|
-
|
|
59
|
-
newProps[
|
|
49
|
+
for (const key in props) {
|
|
50
|
+
if (key.startsWith("use:")) {
|
|
51
|
+
const originalKey = key.slice("use:".length);
|
|
52
|
+
newProps[originalKey] = props[key];
|
|
60
53
|
}
|
|
61
54
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (sourceDescriptorRef
|
|
55
|
+
const sourceDescriptorRef = Object.getOwnPropertyDescriptor(source, "ref");
|
|
56
|
+
const propsDescriptorRef = Object.getOwnPropertyDescriptor(props, "ref");
|
|
57
|
+
if ((sourceDescriptorRef == null ? void 0 : sourceDescriptorRef.configurable) && (propsDescriptorRef == null ? void 0 : propsDescriptorRef.configurable)) {
|
|
65
58
|
newProps.ref = forkRef(source.ref, props.ref);
|
|
66
59
|
}
|
|
67
60
|
if (props.forwardRef) {
|
|
@@ -69,10 +62,13 @@ function assignProps() {
|
|
|
69
62
|
newProps.forwardRef = newProps.ref;
|
|
70
63
|
}
|
|
71
64
|
if (source.style && props.style) {
|
|
72
|
-
newProps.style =
|
|
65
|
+
newProps.style = {
|
|
66
|
+
...source.style,
|
|
67
|
+
...props.style
|
|
68
|
+
};
|
|
73
69
|
}
|
|
74
70
|
if (source.className) {
|
|
75
|
-
newProps.className =
|
|
71
|
+
newProps.className = cn(props.className, source.className);
|
|
76
72
|
}
|
|
77
73
|
if (source.styles && props.styles) {
|
|
78
74
|
newProps.styles = sstyled.merge(source.styles, props.styles);
|
|
@@ -1,24 +1,22 @@
|
|
|
1
1
|
import { createIntlCache, createIntl } from "@formatjs/intl";
|
|
2
2
|
import React, { createContext } from "react";
|
|
3
3
|
import { useAsyncI18nMessages } from "./i18nEnhance.mjs";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}, [resolvedDictionary, lang]);
|
|
19
|
-
return React.useCallback(function(messageId, variables) {
|
|
4
|
+
const Context = /* @__PURE__ */ createContext(void 0);
|
|
5
|
+
const {
|
|
6
|
+
Provider: I18nProvider,
|
|
7
|
+
Consumer: I18nConsumer
|
|
8
|
+
} = Context;
|
|
9
|
+
const messagesCache = createIntlCache();
|
|
10
|
+
const useI18n = (dictionary, locale = "en", fallbackDictionary) => {
|
|
11
|
+
const lang = React.useContext(Context) ?? locale;
|
|
12
|
+
const resolvedDictionary = useAsyncI18nMessages(dictionary, lang, fallbackDictionary);
|
|
13
|
+
const intl = React.useMemo(() => createIntl({
|
|
14
|
+
locale: lang,
|
|
15
|
+
messages: resolvedDictionary
|
|
16
|
+
}, messagesCache), [resolvedDictionary, lang]);
|
|
17
|
+
return React.useCallback((messageId, variables) => {
|
|
20
18
|
return intl.formatMessage({
|
|
21
|
-
id: messageId
|
|
19
|
+
id: messageId ?? ""
|
|
22
20
|
}, variables);
|
|
23
21
|
}, [intl]);
|
|
24
22
|
};
|