@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,68 +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 _createForOfIteratorHelper2 = _interopRequireDefault(require("@babel/runtime/helpers/createForOfIteratorHelper"));
|
|
9
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
7
|
+
exports.default = void 0;
|
|
11
8
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
(0,
|
|
15
|
-
(0, _defineProperty2["default"])(this, "events", new Map());
|
|
9
|
+
class EventEmitter {
|
|
10
|
+
constructor() {
|
|
11
|
+
(0, _defineProperty2.default)(this, "events", new Map());
|
|
16
12
|
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
(_this$events$get2 = this.events.get(eventName)) === null || _this$events$get2 === void 0 || _this$events$get2["delete"](fn);
|
|
34
|
-
}
|
|
35
|
-
}, {
|
|
36
|
-
key: "emit",
|
|
37
|
-
value: function emit(eventName) {
|
|
38
|
-
var handlers = this.events.get(eventName);
|
|
39
|
-
if (handlers) {
|
|
40
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
41
|
-
args[_key - 1] = arguments[_key];
|
|
42
|
-
}
|
|
43
|
-
var _iterator = (0, _createForOfIteratorHelper2["default"])(handlers),
|
|
44
|
-
_step;
|
|
45
|
-
try {
|
|
46
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
47
|
-
var handler = _step.value;
|
|
48
|
-
handler.call.apply(handler, [null].concat(args));
|
|
49
|
-
}
|
|
50
|
-
} catch (err) {
|
|
51
|
-
_iterator.e(err);
|
|
52
|
-
} finally {
|
|
53
|
-
_iterator.f();
|
|
54
|
-
}
|
|
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);
|
|
19
|
+
};
|
|
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);
|
|
55
29
|
}
|
|
56
30
|
}
|
|
31
|
+
}
|
|
57
32
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}]);
|
|
67
|
-
}();
|
|
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;
|
|
68
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":[]}
|
|
@@ -1,62 +1,33 @@
|
|
|
1
|
-
import _createForOfIteratorHelper from "@babel/runtime/helpers/esm/createForOfIteratorHelper";
|
|
2
|
-
import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
|
|
3
|
-
import _createClass from "@babel/runtime/helpers/esm/createClass";
|
|
4
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
_classCallCheck(this, EventEmitter);
|
|
2
|
+
export default class EventEmitter {
|
|
3
|
+
constructor() {
|
|
8
4
|
_defineProperty(this, "events", new Map());
|
|
9
5
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
(_this$events$get2 = this.events.get(eventName)) === null || _this$events$get2 === void 0 || _this$events$get2["delete"](fn);
|
|
27
|
-
}
|
|
28
|
-
}, {
|
|
29
|
-
key: "emit",
|
|
30
|
-
value: function emit(eventName) {
|
|
31
|
-
var handlers = this.events.get(eventName);
|
|
32
|
-
if (handlers) {
|
|
33
|
-
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
34
|
-
args[_key - 1] = arguments[_key];
|
|
35
|
-
}
|
|
36
|
-
var _iterator = _createForOfIteratorHelper(handlers),
|
|
37
|
-
_step;
|
|
38
|
-
try {
|
|
39
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
40
|
-
var handler = _step.value;
|
|
41
|
-
handler.call.apply(handler, [null].concat(args));
|
|
42
|
-
}
|
|
43
|
-
} catch (err) {
|
|
44
|
-
_iterator.e(err);
|
|
45
|
-
} finally {
|
|
46
|
-
_iterator.f();
|
|
47
|
-
}
|
|
6
|
+
on(eventName, fn) {
|
|
7
|
+
const handlers = this.events.get(eventName) ?? new Set();
|
|
8
|
+
handlers.add(fn);
|
|
9
|
+
this.events.set(eventName, handlers);
|
|
10
|
+
return () => {
|
|
11
|
+
this.off(eventName, fn);
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
off(eventName, fn) {
|
|
15
|
+
this.events.get(eventName)?.delete(fn);
|
|
16
|
+
}
|
|
17
|
+
emit(eventName, ...args) {
|
|
18
|
+
const handlers = this.events.get(eventName);
|
|
19
|
+
if (handlers) {
|
|
20
|
+
for (const handler of handlers) {
|
|
21
|
+
handler.call(null, ...args);
|
|
48
22
|
}
|
|
49
23
|
}
|
|
24
|
+
}
|
|
50
25
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
59
|
-
}]);
|
|
60
|
-
}();
|
|
61
|
-
export { EventEmitter as default };
|
|
26
|
+
/**
|
|
27
|
+
* @deprecated. Fallback to the `on` method for backward compatibility.
|
|
28
|
+
*/
|
|
29
|
+
subscribe(eventName, fn) {
|
|
30
|
+
return this.on(eventName, fn);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
62
33
|
//# sourceMappingURL=eventEmitter.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventEmitter.mjs","names":["EventEmitter","
|
|
1
|
+
{"version":3,"file":"eventEmitter.mjs","names":["EventEmitter","constructor","_defineProperty","Map","on","eventName","fn","handlers","events","get","Set","add","set","off","delete","emit","args","handler","call","subscribe"],"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":";AAGA,eAAe,MAAMA,YAAY,CAAuE;EAAAC,YAAA;IAAAC,eAAA,iBACrF,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","ignoreList":[]}
|
|
@@ -1,29 +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
|
exports.extractFrom = extractFrom;
|
|
9
9
|
exports.findAllComponents = findAllComponents;
|
|
10
10
|
exports.isAdvanceMode = isAdvanceMode;
|
|
11
11
|
var _react = _interopRequireDefault(require("react"));
|
|
12
12
|
var _getOriginChildren = _interopRequireDefault(require("./getOriginChildren"));
|
|
13
13
|
var _symbols = require("../core-types/symbols");
|
|
14
|
-
function findComponent(Children, names, recursively) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (child.type === _react["default"].Fragment) {
|
|
14
|
+
function findComponent(Children, names, recursively, limit = 100) {
|
|
15
|
+
const children = Children[_symbols.CHILDREN_COMPONENT] ? (0, _getOriginChildren.default)(Children) : Children;
|
|
16
|
+
return _react.default.Children.toArray(children).find(child => {
|
|
17
|
+
if (/*#__PURE__*/_react.default.isValidElement(child)) {
|
|
18
|
+
if (child.type === _react.default.Fragment) {
|
|
20
19
|
return findComponent(child.props.children, names, recursively, limit);
|
|
21
20
|
}
|
|
22
21
|
// @ts-ignore
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
return names.includes(name);
|
|
26
|
-
});
|
|
22
|
+
const inheritedNames = child.type[_symbols.INHERITED_NAME] || [child.type.displayName];
|
|
23
|
+
const result = !!inheritedNames.find(name => names.includes(name));
|
|
27
24
|
if (!result && child.props.children && recursively && limit > 0) {
|
|
28
25
|
return findComponent(child.props.children, names, recursively, limit - 1);
|
|
29
26
|
}
|
|
@@ -32,7 +29,7 @@ function findComponent(Children, names, recursively) {
|
|
|
32
29
|
});
|
|
33
30
|
}
|
|
34
31
|
function isAdvanceMode(Children, name, recursively) {
|
|
35
|
-
|
|
32
|
+
const children = Children[_symbols.CHILDREN_COMPONENT] ? (0, _getOriginChildren.default)(Children) : Children;
|
|
36
33
|
if (!children) return false;
|
|
37
34
|
if (typeof children === 'function') {
|
|
38
35
|
return true;
|
|
@@ -40,32 +37,30 @@ function isAdvanceMode(Children, name, recursively) {
|
|
|
40
37
|
return !!findComponent(children, name, recursively);
|
|
41
38
|
}
|
|
42
39
|
function findAllComponents(Children, names) {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
_react
|
|
47
|
-
if (/*#__PURE__*/_react
|
|
48
|
-
if (child.type === _react
|
|
49
|
-
|
|
40
|
+
const result = [];
|
|
41
|
+
const findAllAndAdd = Children => {
|
|
42
|
+
const children = Children[_symbols.CHILDREN_COMPONENT] ? (0, _getOriginChildren.default)(Children) : Children;
|
|
43
|
+
_react.default.Children.toArray(children).forEach(child => {
|
|
44
|
+
if (/*#__PURE__*/_react.default.isValidElement(child)) {
|
|
45
|
+
if (child.type === _react.default.Fragment) {
|
|
46
|
+
findAllAndAdd(child.props.children);
|
|
50
47
|
} else if (typeof child.type === 'function' && _symbols.CHILDREN_COMPONENT in child.type && child.type[_symbols.CHILDREN_COMPONENT]) {
|
|
51
|
-
|
|
48
|
+
findAllAndAdd(child.type);
|
|
52
49
|
} else {
|
|
53
50
|
// @ts-ignore
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
return names.includes(name);
|
|
57
|
-
});
|
|
51
|
+
const inheritedNames = child.type[_symbols.INHERITED_NAME] || [child.type.displayName];
|
|
52
|
+
const component = !!inheritedNames.find(name => names.includes(name));
|
|
58
53
|
if (component) {
|
|
59
54
|
result.push(child);
|
|
60
55
|
}
|
|
61
56
|
if (child.props.children) {
|
|
62
|
-
return
|
|
57
|
+
return findAllAndAdd(child.props.children);
|
|
63
58
|
}
|
|
64
59
|
}
|
|
65
60
|
}
|
|
66
61
|
});
|
|
67
62
|
};
|
|
68
|
-
|
|
63
|
+
findAllAndAdd(Children);
|
|
69
64
|
return result;
|
|
70
65
|
}
|
|
71
66
|
|
|
@@ -73,22 +68,20 @@ function findAllComponents(Children, names) {
|
|
|
73
68
|
* Extract some components from Children and return them and rest of components as tuple.
|
|
74
69
|
*/
|
|
75
70
|
function extractFrom(Children, names) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
_react
|
|
81
|
-
if (/*#__PURE__*/_react
|
|
82
|
-
if (child.type === _react
|
|
83
|
-
|
|
71
|
+
const extracted = [];
|
|
72
|
+
const rest = [];
|
|
73
|
+
const extractor = Children => {
|
|
74
|
+
const children = Children[_symbols.CHILDREN_COMPONENT] ? (0, _getOriginChildren.default)(Children) : Children;
|
|
75
|
+
_react.default.Children.toArray(children).forEach(child => {
|
|
76
|
+
if (/*#__PURE__*/_react.default.isValidElement(child)) {
|
|
77
|
+
if (child.type === _react.default.Fragment) {
|
|
78
|
+
extractor(child.props.children);
|
|
84
79
|
} else if (typeof child.type === 'function' && _symbols.CHILDREN_COMPONENT in child.type && child.type[_symbols.CHILDREN_COMPONENT]) {
|
|
85
|
-
|
|
80
|
+
extractor(child.type);
|
|
86
81
|
} else {
|
|
87
82
|
// @ts-ignore
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
return names.includes(name);
|
|
91
|
-
});
|
|
83
|
+
const inheritedNames = child.type[_symbols.INHERITED_NAME] || [child.type.displayName];
|
|
84
|
+
const component = !!inheritedNames.find(name => names.includes(name));
|
|
92
85
|
if (component) {
|
|
93
86
|
extracted.push(child);
|
|
94
87
|
} else {
|
|
@@ -98,8 +91,8 @@ function extractFrom(Children, names) {
|
|
|
98
91
|
}
|
|
99
92
|
});
|
|
100
93
|
};
|
|
101
|
-
|
|
94
|
+
extractor(Children);
|
|
102
95
|
return [extracted, rest];
|
|
103
96
|
}
|
|
104
|
-
var _default = exports
|
|
97
|
+
var _default = exports.default = findComponent;
|
|
105
98
|
//# sourceMappingURL=findComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findComponent.js","names":["_react","_interopRequireDefault","require","_getOriginChildren","_symbols","findComponent","Children","names","recursively","limit","
|
|
1
|
+
{"version":3,"file":"findComponent.js","names":["_react","_interopRequireDefault","require","_getOriginChildren","_symbols","findComponent","Children","names","recursively","limit","children","CHILDREN_COMPONENT","getOriginChildren","React","toArray","find","child","isValidElement","type","Fragment","props","inheritedNames","INHERITED_NAME","displayName","result","name","includes","isAdvanceMode","findAllComponents","findAllAndAdd","forEach","component","push","extractFrom","extracted","rest","extractor","_default","exports","default"],"sources":["../../src/utils/findComponent.ts"],"sourcesContent":["import React, { type ReactElement, type MutableRefObject } from 'react';\n\nimport getOriginChildren from './getOriginChildren';\nimport { CHILDREN_COMPONENT, INHERITED_NAME } from '../core-types/symbols';\n\nfunction findComponent<P = any>(\n Children: any,\n names: string[],\n recursively?: boolean,\n limit = 100,\n): ReactElement<P> | undefined {\n const children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;\n return React.Children.toArray(children).find((child) => {\n if (React.isValidElement(child)) {\n if (child.type === React.Fragment) {\n return findComponent(child.props.children, names, recursively, limit);\n }\n // @ts-ignore\n const inheritedNames = child.type[INHERITED_NAME] || [child.type.displayName];\n const result = !!inheritedNames.find((name: string) => names.includes(name));\n\n if (!result && child.props.children && recursively && limit > 0) {\n return findComponent(child.props.children, names, recursively, limit - 1);\n }\n\n return result;\n }\n }) as ReactElement<P> | undefined;\n}\n\nexport function isAdvanceMode(Children: any, name: string[], recursively?: boolean) {\n const children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;\n if (!children) return false;\n if (typeof children === 'function') {\n return true;\n }\n return !!findComponent(children, name, recursively);\n}\n\ntype IntergalacticComponent = ReactElement & {\n ref?: MutableRefObject<HTMLElement>;\n};\n\nexport function findAllComponents(Children: any, names: string[]): IntergalacticComponent[] {\n const result: IntergalacticComponent[] = [];\n\n const findAllAndAdd = (Children: any) => {\n const children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;\n React.Children.toArray(children).forEach((child) => {\n if (React.isValidElement(child)) {\n if (child.type === React.Fragment) {\n findAllAndAdd(child.props.children);\n } else if (\n typeof child.type === 'function' &&\n CHILDREN_COMPONENT in child.type &&\n child.type[CHILDREN_COMPONENT]\n ) {\n findAllAndAdd(child.type);\n } else {\n // @ts-ignore\n const inheritedNames = child.type[INHERITED_NAME] || [child.type.displayName];\n const component = !!inheritedNames.find((name: string) => names.includes(name));\n\n if (component) {\n result.push(child);\n }\n\n if (child.props.children) {\n return findAllAndAdd(child.props.children);\n }\n }\n }\n });\n };\n\n findAllAndAdd(Children);\n\n return result;\n}\n\n/**\n * Extract some components from Children and return them and rest of components as tuple.\n */\nexport function extractFrom(Children: any, names: string[]): IntergalacticComponent[][] {\n const extracted: IntergalacticComponent[] = [];\n const rest: IntergalacticComponent[] = [];\n\n const extractor = (Children: any) => {\n const children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;\n React.Children.toArray(children).forEach((child) => {\n if (React.isValidElement(child)) {\n if (child.type === React.Fragment) {\n extractor(child.props.children);\n } else if (\n typeof child.type === 'function' &&\n CHILDREN_COMPONENT in child.type &&\n child.type[CHILDREN_COMPONENT]\n ) {\n extractor(child.type);\n } else {\n // @ts-ignore\n const inheritedNames = child.type[INHERITED_NAME] || [child.type.displayName];\n const component = !!inheritedNames.find((name: string) => names.includes(name));\n\n if (component) {\n extracted.push(child);\n } else {\n rest.push(child);\n }\n }\n }\n });\n };\n\n extractor(Children);\n\n return [extracted, rest];\n}\n\nexport default findComponent;\n"],"mappings":";;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,kBAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEA,SAASG,aAAaA,CACpBC,QAAa,EACbC,KAAe,EACfC,WAAqB,EACrBC,KAAK,GAAG,GAAG,EACkB;EAC7B,MAAMC,QAAQ,GAAGJ,QAAQ,CAACK,2BAAkB,CAAC,GAAG,IAAAC,0BAAiB,EAACN,QAAQ,CAAC,GAAGA,QAAQ;EACtF,OAAOO,cAAK,CAACP,QAAQ,CAACQ,OAAO,CAACJ,QAAQ,CAAC,CAACK,IAAI,CAAEC,KAAK,IAAK;IACtD,iBAAIH,cAAK,CAACI,cAAc,CAACD,KAAK,CAAC,EAAE;MAC/B,IAAIA,KAAK,CAACE,IAAI,KAAKL,cAAK,CAACM,QAAQ,EAAE;QACjC,OAAOd,aAAa,CAACW,KAAK,CAACI,KAAK,CAACV,QAAQ,EAAEH,KAAK,EAAEC,WAAW,EAAEC,KAAK,CAAC;MACvE;MACA;MACA,MAAMY,cAAc,GAAGL,KAAK,CAACE,IAAI,CAACI,uBAAc,CAAC,IAAI,CAACN,KAAK,CAACE,IAAI,CAACK,WAAW,CAAC;MAC7E,MAAMC,MAAM,GAAG,CAAC,CAACH,cAAc,CAACN,IAAI,CAAEU,IAAY,IAAKlB,KAAK,CAACmB,QAAQ,CAACD,IAAI,CAAC,CAAC;MAE5E,IAAI,CAACD,MAAM,IAAIR,KAAK,CAACI,KAAK,CAACV,QAAQ,IAAIF,WAAW,IAAIC,KAAK,GAAG,CAAC,EAAE;QAC/D,OAAOJ,aAAa,CAACW,KAAK,CAACI,KAAK,CAACV,QAAQ,EAAEH,KAAK,EAAEC,WAAW,EAAEC,KAAK,GAAG,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CAAC;QACvB,CAAC,MAAM;UACL;UACA,MAAMG,cAAc,GAAGL,KAAK,CAACE,IAAI,CAACI,uBAAc,CAAC,IAAI,CAACN,KAAK,CAACE,IAAI,CAACK,WAAW,CAAC;UAC7E,MAAMQ,SAAS,GAAG,CAAC,CAACV,cAAc,CAACN,IAAI,CAAEU,IAAY,IAAKlB,KAAK,CAACmB,QAAQ,CAACD,IAAI,CAAC,CAAC;UAE/E,IAAIM,SAAS,EAAE;YACbG,SAAS,CAACF,IAAI,CAAChB,KAAK,CAAC;UACvB,CAAC,MAAM;YACLmB,IAAI,CAACH,IAAI,CAAChB,KAAK,CAAC;UAClB;QACF;MACF;IACF,CAAC,CAAC;EACJ,CAAC;EAEDoB,SAAS,CAAC9B,QAAQ,CAAC;EAEnB,OAAO,CAAC4B,SAAS,EAAEC,IAAI,CAAC;AAC1B;AAAC,IAAAE,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAEclC,aAAa","ignoreList":[]}
|
|
@@ -1,19 +1,16 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import getOriginChildren from "./getOriginChildren.mjs";
|
|
3
3
|
import { CHILDREN_COMPONENT, INHERITED_NAME } from "../core-types/symbols.mjs";
|
|
4
|
-
function findComponent(Children, names, recursively) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return React.Children.toArray(children).find(function (child) {
|
|
4
|
+
function findComponent(Children, names, recursively, limit = 100) {
|
|
5
|
+
const children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;
|
|
6
|
+
return React.Children.toArray(children).find(child => {
|
|
8
7
|
if (/*#__PURE__*/React.isValidElement(child)) {
|
|
9
8
|
if (child.type === React.Fragment) {
|
|
10
9
|
return findComponent(child.props.children, names, recursively, limit);
|
|
11
10
|
}
|
|
12
11
|
// @ts-ignore
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return names.includes(name);
|
|
16
|
-
});
|
|
12
|
+
const inheritedNames = child.type[INHERITED_NAME] || [child.type.displayName];
|
|
13
|
+
const result = !!inheritedNames.find(name => names.includes(name));
|
|
17
14
|
if (!result && child.props.children && recursively && limit > 0) {
|
|
18
15
|
return findComponent(child.props.children, names, recursively, limit - 1);
|
|
19
16
|
}
|
|
@@ -22,7 +19,7 @@ function findComponent(Children, names, recursively) {
|
|
|
22
19
|
});
|
|
23
20
|
}
|
|
24
21
|
export function isAdvanceMode(Children, name, recursively) {
|
|
25
|
-
|
|
22
|
+
const children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;
|
|
26
23
|
if (!children) return false;
|
|
27
24
|
if (typeof children === 'function') {
|
|
28
25
|
return true;
|
|
@@ -30,32 +27,30 @@ export function isAdvanceMode(Children, name, recursively) {
|
|
|
30
27
|
return !!findComponent(children, name, recursively);
|
|
31
28
|
}
|
|
32
29
|
export function findAllComponents(Children, names) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
React.Children.toArray(children).forEach(
|
|
30
|
+
const result = [];
|
|
31
|
+
const findAllAndAdd = Children => {
|
|
32
|
+
const children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;
|
|
33
|
+
React.Children.toArray(children).forEach(child => {
|
|
37
34
|
if (/*#__PURE__*/React.isValidElement(child)) {
|
|
38
35
|
if (child.type === React.Fragment) {
|
|
39
|
-
|
|
36
|
+
findAllAndAdd(child.props.children);
|
|
40
37
|
} else if (typeof child.type === 'function' && CHILDREN_COMPONENT in child.type && child.type[CHILDREN_COMPONENT]) {
|
|
41
|
-
|
|
38
|
+
findAllAndAdd(child.type);
|
|
42
39
|
} else {
|
|
43
40
|
// @ts-ignore
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
return names.includes(name);
|
|
47
|
-
});
|
|
41
|
+
const inheritedNames = child.type[INHERITED_NAME] || [child.type.displayName];
|
|
42
|
+
const component = !!inheritedNames.find(name => names.includes(name));
|
|
48
43
|
if (component) {
|
|
49
44
|
result.push(child);
|
|
50
45
|
}
|
|
51
46
|
if (child.props.children) {
|
|
52
|
-
return
|
|
47
|
+
return findAllAndAdd(child.props.children);
|
|
53
48
|
}
|
|
54
49
|
}
|
|
55
50
|
}
|
|
56
51
|
});
|
|
57
52
|
};
|
|
58
|
-
|
|
53
|
+
findAllAndAdd(Children);
|
|
59
54
|
return result;
|
|
60
55
|
}
|
|
61
56
|
|
|
@@ -63,22 +58,20 @@ export function findAllComponents(Children, names) {
|
|
|
63
58
|
* Extract some components from Children and return them and rest of components as tuple.
|
|
64
59
|
*/
|
|
65
60
|
export function extractFrom(Children, names) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
React.Children.toArray(children).forEach(
|
|
61
|
+
const extracted = [];
|
|
62
|
+
const rest = [];
|
|
63
|
+
const extractor = Children => {
|
|
64
|
+
const children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;
|
|
65
|
+
React.Children.toArray(children).forEach(child => {
|
|
71
66
|
if (/*#__PURE__*/React.isValidElement(child)) {
|
|
72
67
|
if (child.type === React.Fragment) {
|
|
73
|
-
|
|
68
|
+
extractor(child.props.children);
|
|
74
69
|
} else if (typeof child.type === 'function' && CHILDREN_COMPONENT in child.type && child.type[CHILDREN_COMPONENT]) {
|
|
75
|
-
|
|
70
|
+
extractor(child.type);
|
|
76
71
|
} else {
|
|
77
72
|
// @ts-ignore
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
return names.includes(name);
|
|
81
|
-
});
|
|
73
|
+
const inheritedNames = child.type[INHERITED_NAME] || [child.type.displayName];
|
|
74
|
+
const component = !!inheritedNames.find(name => names.includes(name));
|
|
82
75
|
if (component) {
|
|
83
76
|
extracted.push(child);
|
|
84
77
|
} else {
|
|
@@ -88,7 +81,7 @@ export function extractFrom(Children, names) {
|
|
|
88
81
|
}
|
|
89
82
|
});
|
|
90
83
|
};
|
|
91
|
-
|
|
84
|
+
extractor(Children);
|
|
92
85
|
return [extracted, rest];
|
|
93
86
|
}
|
|
94
87
|
export default findComponent;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"findComponent.mjs","names":["React","getOriginChildren","CHILDREN_COMPONENT","INHERITED_NAME","findComponent","Children","names","recursively","limit","
|
|
1
|
+
{"version":3,"file":"findComponent.mjs","names":["React","getOriginChildren","CHILDREN_COMPONENT","INHERITED_NAME","findComponent","Children","names","recursively","limit","children","toArray","find","child","isValidElement","type","Fragment","props","inheritedNames","displayName","result","name","includes","isAdvanceMode","findAllComponents","findAllAndAdd","forEach","component","push","extractFrom","extracted","rest","extractor"],"sources":["../../src/utils/findComponent.ts"],"sourcesContent":["import React, { type ReactElement, type MutableRefObject } from 'react';\n\nimport getOriginChildren from './getOriginChildren';\nimport { CHILDREN_COMPONENT, INHERITED_NAME } from '../core-types/symbols';\n\nfunction findComponent<P = any>(\n Children: any,\n names: string[],\n recursively?: boolean,\n limit = 100,\n): ReactElement<P> | undefined {\n const children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;\n return React.Children.toArray(children).find((child) => {\n if (React.isValidElement(child)) {\n if (child.type === React.Fragment) {\n return findComponent(child.props.children, names, recursively, limit);\n }\n // @ts-ignore\n const inheritedNames = child.type[INHERITED_NAME] || [child.type.displayName];\n const result = !!inheritedNames.find((name: string) => names.includes(name));\n\n if (!result && child.props.children && recursively && limit > 0) {\n return findComponent(child.props.children, names, recursively, limit - 1);\n }\n\n return result;\n }\n }) as ReactElement<P> | undefined;\n}\n\nexport function isAdvanceMode(Children: any, name: string[], recursively?: boolean) {\n const children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;\n if (!children) return false;\n if (typeof children === 'function') {\n return true;\n }\n return !!findComponent(children, name, recursively);\n}\n\ntype IntergalacticComponent = ReactElement & {\n ref?: MutableRefObject<HTMLElement>;\n};\n\nexport function findAllComponents(Children: any, names: string[]): IntergalacticComponent[] {\n const result: IntergalacticComponent[] = [];\n\n const findAllAndAdd = (Children: any) => {\n const children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;\n React.Children.toArray(children).forEach((child) => {\n if (React.isValidElement(child)) {\n if (child.type === React.Fragment) {\n findAllAndAdd(child.props.children);\n } else if (\n typeof child.type === 'function' &&\n CHILDREN_COMPONENT in child.type &&\n child.type[CHILDREN_COMPONENT]\n ) {\n findAllAndAdd(child.type);\n } else {\n // @ts-ignore\n const inheritedNames = child.type[INHERITED_NAME] || [child.type.displayName];\n const component = !!inheritedNames.find((name: string) => names.includes(name));\n\n if (component) {\n result.push(child);\n }\n\n if (child.props.children) {\n return findAllAndAdd(child.props.children);\n }\n }\n }\n });\n };\n\n findAllAndAdd(Children);\n\n return result;\n}\n\n/**\n * Extract some components from Children and return them and rest of components as tuple.\n */\nexport function extractFrom(Children: any, names: string[]): IntergalacticComponent[][] {\n const extracted: IntergalacticComponent[] = [];\n const rest: IntergalacticComponent[] = [];\n\n const extractor = (Children: any) => {\n const children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;\n React.Children.toArray(children).forEach((child) => {\n if (React.isValidElement(child)) {\n if (child.type === React.Fragment) {\n extractor(child.props.children);\n } else if (\n typeof child.type === 'function' &&\n CHILDREN_COMPONENT in child.type &&\n child.type[CHILDREN_COMPONENT]\n ) {\n extractor(child.type);\n } else {\n // @ts-ignore\n const inheritedNames = child.type[INHERITED_NAME] || [child.type.displayName];\n const component = !!inheritedNames.find((name: string) => names.includes(name));\n\n if (component) {\n extracted.push(child);\n } else {\n rest.push(child);\n }\n }\n }\n });\n };\n\n extractor(Children);\n\n return [extracted, rest];\n}\n\nexport default findComponent;\n"],"mappings":"AAAA,OAAOA,KAAK,MAAoD,OAAO;AAEvE,OAAOC,iBAAiB,MAAM,yBAAqB;AACnD,SAASC,kBAAkB,EAAEC,cAAc,QAAQ,2BAAuB;AAE1E,SAASC,aAAaA,CACpBC,QAAa,EACbC,KAAe,EACfC,WAAqB,EACrBC,KAAK,GAAG,GAAG,EACkB;EAC7B,MAAMC,QAAQ,GAAGJ,QAAQ,CAACH,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IACF,CAAC,CAAC;EACJ,CAAC;EAEDmB,SAAS,CAAC1B,QAAQ,CAAC;EAEnB,OAAO,CAACwB,SAAS,EAAEC,IAAI,CAAC;AAC1B;AAEA,eAAe1B,aAAa","ignoreList":[]}
|
package/lib/utils/fire.js
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
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 = fire;
|
|
8
8
|
exports.fireFn = fireFn;
|
|
9
9
|
var _getValue = _interopRequireDefault(require("./getValue"));
|
|
10
|
-
function fire(context, eventName) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
args[_key - 2] = arguments[_key];
|
|
14
|
-
}
|
|
15
|
-
if (fn) return fn.call.apply(fn, [context].concat(args));
|
|
10
|
+
function fire(context, eventName, ...args) {
|
|
11
|
+
const fn = (0, _getValue.default)(context, `props.${eventName}`);
|
|
12
|
+
if (fn) return fn.call(context, ...args);
|
|
16
13
|
}
|
|
17
|
-
function fireFn(fn) {
|
|
18
|
-
|
|
19
|
-
args[_key2 - 1] = arguments[_key2];
|
|
20
|
-
}
|
|
21
|
-
if (typeof fn === 'function') return fn.apply(void 0, args);
|
|
14
|
+
function fireFn(fn, ...args) {
|
|
15
|
+
if (typeof fn === 'function') return fn(...args);
|
|
22
16
|
}
|
|
23
17
|
//# sourceMappingURL=fire.js.map
|
package/lib/utils/fire.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fire.js","names":["_getValue","_interopRequireDefault","require","fire","context","eventName","
|
|
1
|
+
{"version":3,"file":"fire.js","names":["_getValue","_interopRequireDefault","require","fire","context","eventName","args","fn","getValue","call","fireFn"],"sources":["../../src/utils/fire.ts"],"sourcesContent":["import getValue from './getValue';\n\nexport default function fire<T extends {}>(context: T, eventName: string, ...args: any) {\n const fn = getValue(context, `props.${eventName}`);\n if (fn) return fn.call(context, ...args);\n}\n\nexport function fireFn(fn: (...args: any) => void, ...args: any[]) {\n if (typeof fn === 'function') return fn(...args);\n}\n"],"mappings":";;;;;;;;AAAA,IAAAA,SAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEe,SAASC,IAAIA,CAAeC,OAAU,EAAEC,SAAiB,EAAE,GAAGC,IAAS,EAAE;EACtF,MAAMC,EAAE,GAAG,IAAAC,iBAAQ,EAACJ,OAAO,EAAE,SAASC,SAAS,EAAE,CAAC;EAClD,IAAIE,EAAE,EAAE,OAAOA,EAAE,CAACE,IAAI,CAACL,OAAO,EAAE,GAAGE,IAAI,CAAC;AAC1C;AAEO,SAASI,MAAMA,CAACH,EAA0B,EAAE,GAAGD,IAAW,EAAE;EACjE,IAAI,OAAOC,EAAE,KAAK,UAAU,EAAE,OAAOA,EAAE,CAAC,GAAGD,IAAI,CAAC;AAClD","ignoreList":[]}
|