@semcore/core 17.0.0 → 17.0.1-prerelease.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +3 -111
- package/README.md +35 -5
- package/lib/LastInteractionType.js +36 -22
- package/lib/LastInteractionType.js.map +1 -1
- package/lib/LastInteractionType.mjs +33 -19
- package/lib/LastInteractionType.mjs.map +1 -1
- package/lib/core-types/Component.js +41 -25
- package/lib/core-types/Component.js.map +1 -1
- package/lib/core-types/Component.mjs +38 -18
- 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 +238 -158
- package/lib/coreFactory.js.map +1 -1
- package/lib/coreFactory.mjs +189 -133
- package/lib/coreFactory.mjs.map +1 -1
- package/lib/decorators/propsObserver.js +64 -36
- package/lib/decorators/propsObserver.js.map +1 -1
- package/lib/decorators/propsObserver.mjs +61 -33
- 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 +59 -51
- package/lib/enhancement/Children.js.map +1 -1
- package/lib/enhancement/Children.mjs +41 -47
- package/lib/enhancement/Children.mjs.map +1 -1
- package/lib/enhancement/Root.js +37 -36
- package/lib/enhancement/Root.js.map +1 -1
- package/lib/enhancement/Root.mjs +18 -28
- package/lib/enhancement/Root.mjs.map +1 -1
- package/lib/enhancement/dataName.js +8 -7
- 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 +9 -6
- package/lib/enhancement/enhance.js.map +1 -1
- package/lib/enhancement/enhance.mjs +7 -4
- 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 +9 -10
- package/lib/enhancement/i18n.mjs.map +1 -1
- package/lib/enhancement/inheritedName.js +8 -7
- 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 +56 -47
- package/lib/enhancement/staticChildren.js.map +1 -1
- package/lib/enhancement/staticChildren.mjs +48 -43
- package/lib/enhancement/staticChildren.mjs.map +1 -1
- package/lib/enhancement/style.js +27 -29
- package/lib/enhancement/style.js.map +1 -1
- package/lib/enhancement/style.mjs +20 -26
- package/lib/enhancement/style.mjs.map +1 -1
- package/lib/enhancement/uncontrolledProps.js +65 -46
- package/lib/enhancement/uncontrolledProps.js.map +1 -1
- package/lib/enhancement/uncontrolledProps.mjs +52 -43
- package/lib/enhancement/uncontrolledProps.mjs.map +1 -1
- package/lib/esm/LastInteractionType.mjs +33 -19
- package/lib/esm/core-types/Component.mjs +38 -18
- package/lib/esm/core-types/symbols.mjs +9 -9
- package/lib/esm/coreFactory.mjs +189 -133
- package/lib/esm/enhancement/Children.mjs +41 -47
- package/lib/esm/enhancement/Root.mjs +18 -28
- package/lib/esm/enhancement/dataName.mjs +5 -5
- package/lib/esm/enhancement/enhance.mjs +7 -4
- package/lib/esm/enhancement/functionDefaultProps.mjs +4 -4
- package/lib/esm/enhancement/i18n.mjs +9 -10
- package/lib/esm/enhancement/inheritedName.mjs +5 -5
- package/lib/esm/enhancement/staticChildren.mjs +48 -43
- package/lib/esm/enhancement/style.mjs +20 -26
- package/lib/esm/enhancement/uncontrolledProps.mjs +52 -43
- package/lib/esm/register.mjs +20 -12
- package/lib/esm/styled/reshadow-core.mjs +111 -98
- package/lib/esm/styled/sstyled.mjs +41 -31
- package/lib/esm/utils/assignProps.mjs +36 -32
- package/lib/esm/utils/enhances/WithI18n.mjs +17 -15
- package/lib/esm/utils/enhances/i18nEnhance.mjs +61 -47
- package/lib/esm/utils/logger.mjs +21 -13
- package/lib/esm/utils/pick.mjs +4 -4
- package/lib/esm/utils/ref.mjs +43 -27
- package/lib/esm/utils/use/useEnhancedEffect.mjs +1 -1
- package/lib/index.js +17 -17
- package/lib/register.js +24 -17
- package/lib/register.js.map +1 -1
- package/lib/register.mjs +20 -12
- package/lib/register.mjs.map +1 -1
- package/lib/styled/index.js +4 -4
- package/lib/styled/reshadow-core.js +104 -102
- package/lib/styled/reshadow-core.js.map +1 -1
- package/lib/styled/reshadow-core.mjs +111 -98
- package/lib/styled/reshadow-core.mjs.map +1 -1
- package/lib/styled/sstyled.js +53 -31
- package/lib/styled/sstyled.js.map +1 -1
- package/lib/styled/sstyled.mjs +41 -31
- package/lib/styled/sstyled.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/utils/CSSinJS.js +10 -8
- package/lib/utils/CSSinJS.js.map +1 -1
- package/lib/utils/CSSinJS.mjs +7 -6
- package/lib/utils/CSSinJS.mjs.map +1 -1
- package/lib/utils/ThemeProvider.js +51 -44
- package/lib/utils/ThemeProvider.js.map +1 -1
- package/lib/utils/ThemeProvider.mjs +47 -36
- package/lib/utils/ThemeProvider.mjs.map +1 -1
- package/lib/utils/addonText.js +7 -4
- package/lib/utils/addonText.js.map +1 -1
- package/lib/utils/addonText.mjs +5 -2
- package/lib/utils/addonText.mjs.map +1 -1
- package/lib/utils/addonTextChildren.js +21 -15
- package/lib/utils/addonTextChildren.js.map +1 -1
- package/lib/utils/addonTextChildren.mjs +13 -7
- package/lib/utils/addonTextChildren.mjs.map +1 -1
- package/lib/utils/ariaProps.js +5 -7
- package/lib/utils/ariaProps.js.map +1 -1
- package/lib/utils/ariaProps.mjs +5 -7
- package/lib/utils/ariaProps.mjs.map +1 -1
- package/lib/utils/assignProps.js +37 -33
- package/lib/utils/assignProps.js.map +1 -1
- package/lib/utils/assignProps.mjs +36 -32
- 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 +95 -72
- package/lib/utils/color.js.map +1 -1
- package/lib/utils/color.mjs +94 -71
- package/lib/utils/color.mjs.map +1 -1
- package/lib/utils/compose.js +12 -3
- package/lib/utils/compose.js.map +1 -1
- package/lib/utils/compose.mjs +11 -2
- 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 +4 -3
- package/lib/utils/cssToIntDefault.js.map +1 -1
- package/lib/utils/cssToIntDefault.mjs +3 -2
- package/lib/utils/cssToIntDefault.mjs.map +1 -1
- package/lib/utils/enhances/WithCSS.js +8 -10
- package/lib/utils/enhances/WithCSS.js.map +1 -1
- package/lib/utils/enhances/WithCSS.mjs +6 -7
- 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 +17 -15
- package/lib/utils/enhances/WithI18n.mjs.map +1 -1
- package/lib/utils/enhances/a11yEnhance.js +39 -34
- package/lib/utils/enhances/a11yEnhance.js.map +1 -1
- package/lib/utils/enhances/a11yEnhance.mjs +36 -32
- package/lib/utils/enhances/a11yEnhance.mjs.map +1 -1
- package/lib/utils/enhances/animatedSizeEnhance.js +63 -55
- package/lib/utils/enhances/animatedSizeEnhance.js.map +1 -1
- package/lib/utils/enhances/animatedSizeEnhance.mjs +58 -50
- package/lib/utils/enhances/animatedSizeEnhance.mjs.map +1 -1
- package/lib/utils/enhances/contextEnhance.js +11 -12
- package/lib/utils/enhances/contextEnhance.js.map +1 -1
- package/lib/utils/enhances/contextEnhance.mjs +8 -9
- package/lib/utils/enhances/contextEnhance.mjs.map +1 -1
- package/lib/utils/enhances/i18nEnhance.js +67 -51
- package/lib/utils/enhances/i18nEnhance.js.map +1 -1
- package/lib/utils/enhances/i18nEnhance.mjs +61 -47
- package/lib/utils/enhances/i18nEnhance.mjs.map +1 -1
- package/lib/utils/enhances/resolveColorEnhance.js +10 -12
- package/lib/utils/enhances/resolveColorEnhance.js.map +1 -1
- package/lib/utils/enhances/resolveColorEnhance.mjs +6 -8
- package/lib/utils/enhances/resolveColorEnhance.mjs.map +1 -1
- package/lib/utils/eventEmitter.js +57 -30
- package/lib/utils/eventEmitter.js.map +1 -1
- package/lib/utils/eventEmitter.mjs +55 -26
- package/lib/utils/eventEmitter.mjs.map +1 -1
- package/lib/utils/findComponent.js +42 -35
- package/lib/utils/findComponent.js.map +1 -1
- package/lib/utils/findComponent.mjs +33 -26
- package/lib/utils/findComponent.mjs.map +1 -1
- package/lib/utils/fire.js +13 -7
- package/lib/utils/fire.js.map +1 -1
- package/lib/utils/fire.mjs +11 -5
- package/lib/utils/fire.mjs.map +1 -1
- package/lib/utils/focus-lock/focusBorders.js +32 -28
- package/lib/utils/focus-lock/focusBorders.js.map +1 -1
- package/lib/utils/focus-lock/focusBorders.mjs +32 -26
- package/lib/utils/focus-lock/focusBorders.mjs.map +1 -1
- package/lib/utils/focus-lock/getFocusableIn.js +6 -4
- package/lib/utils/focus-lock/getFocusableIn.js.map +1 -1
- package/lib/utils/focus-lock/getFocusableIn.mjs +6 -3
- package/lib/utils/focus-lock/getFocusableIn.mjs.map +1 -1
- package/lib/utils/focus-lock/isFocusInside.js +6 -5
- package/lib/utils/focus-lock/isFocusInside.js.map +1 -1
- package/lib/utils/focus-lock/isFocusInside.mjs +6 -4
- package/lib/utils/focus-lock/isFocusInside.mjs.map +1 -1
- package/lib/utils/focus-lock/isFocusable.js +12 -9
- package/lib/utils/focus-lock/isFocusable.js.map +1 -1
- package/lib/utils/focus-lock/isFocusable.mjs +11 -8
- package/lib/utils/focus-lock/isFocusable.mjs.map +1 -1
- package/lib/utils/focus-lock/setFocus.js +27 -21
- package/lib/utils/focus-lock/setFocus.js.map +1 -1
- package/lib/utils/focus-lock/setFocus.mjs +25 -19
- package/lib/utils/focus-lock/setFocus.mjs.map +1 -1
- package/lib/utils/getAccessibleName.js +22 -10
- package/lib/utils/getAccessibleName.js.map +1 -1
- package/lib/utils/getAccessibleName.mjs +21 -10
- package/lib/utils/getAccessibleName.mjs.map +1 -1
- package/lib/utils/getDisplayName.js +1 -1
- package/lib/utils/getEventTarget.js +32 -13
- package/lib/utils/getEventTarget.js.map +1 -1
- package/lib/utils/getEventTarget.mjs +31 -12
- 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 +6 -4
- package/lib/utils/getValue.js.map +1 -1
- package/lib/utils/getValue.mjs +5 -3
- package/lib/utils/getValue.mjs.map +1 -1
- package/lib/utils/hasLabels.js +27 -16
- package/lib/utils/hasLabels.js.map +1 -1
- package/lib/utils/hasLabels.mjs +24 -14
- package/lib/utils/hasLabels.mjs.map +1 -1
- package/lib/utils/hasParent.js +2 -3
- package/lib/utils/hasParent.js.map +1 -1
- package/lib/utils/hasParent.mjs +3 -2
- package/lib/utils/hasParent.mjs.map +1 -1
- package/lib/utils/ifChildren.js +4 -6
- package/lib/utils/ifChildren.js.map +1 -1
- package/lib/utils/ifChildren.mjs +2 -4
- package/lib/utils/ifChildren.mjs.map +1 -1
- package/lib/utils/indentStyles.js +10 -5
- package/lib/utils/indentStyles.js.map +1 -1
- package/lib/utils/indentStyles.mjs +9 -5
- package/lib/utils/indentStyles.mjs.map +1 -1
- package/lib/utils/injectStyle.js +13 -11
- package/lib/utils/injectStyle.js.map +1 -1
- package/lib/utils/injectStyle.mjs +10 -9
- 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 +9 -7
- package/lib/utils/isInteractiveElement.js.map +1 -1
- package/lib/utils/isInteractiveElement.mjs +9 -7
- package/lib/utils/isInteractiveElement.mjs.map +1 -1
- package/lib/utils/isNode.js +5 -4
- package/lib/utils/isNode.js.map +1 -1
- package/lib/utils/isNode.mjs +2 -1
- package/lib/utils/isNode.mjs.map +1 -1
- package/lib/utils/isPromise.js +1 -1
- package/lib/utils/isRetina.js +2 -7
- package/lib/utils/isRetina.js.map +1 -1
- package/lib/utils/isRetina.mjs +1 -6
- package/lib/utils/isRetina.mjs.map +1 -1
- package/lib/utils/logger.js +25 -18
- package/lib/utils/logger.js.map +1 -1
- package/lib/utils/logger.mjs +21 -13
- package/lib/utils/logger.mjs.map +1 -1
- package/lib/utils/numericChecker.js +18 -11
- package/lib/utils/numericChecker.js.map +1 -1
- package/lib/utils/numericChecker.mjs +17 -10
- 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 +12 -10
- package/lib/utils/propsForElement.js.map +1 -1
- package/lib/utils/propsForElement.mjs +10 -8
- package/lib/utils/propsForElement.mjs.map +1 -1
- package/lib/utils/rafTrottle.js +14 -9
- package/lib/utils/rafTrottle.js.map +1 -1
- package/lib/utils/rafTrottle.mjs +12 -7
- package/lib/utils/rafTrottle.mjs.map +1 -1
- package/lib/utils/reactToText.js +8 -5
- package/lib/utils/reactToText.js.map +1 -1
- package/lib/utils/reactToText.mjs +6 -3
- package/lib/utils/reactToText.mjs.map +1 -1
- package/lib/utils/ref.js +47 -29
- package/lib/utils/ref.js.map +1 -1
- package/lib/utils/ref.mjs +43 -27
- 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 +18 -8
- package/lib/utils/uncontroll.js.map +1 -1
- package/lib/utils/uncontroll.mjs +17 -8
- package/lib/utils/uncontroll.mjs.map +1 -1
- package/lib/utils/uniqueID.js +27 -22
- package/lib/utils/uniqueID.js.map +1 -1
- package/lib/utils/uniqueID.mjs +25 -18
- package/lib/utils/uniqueID.mjs.map +1 -1
- package/lib/utils/use/useColorResolver.js +22 -21
- package/lib/utils/use/useColorResolver.js.map +1 -1
- package/lib/utils/use/useColorResolver.mjs +19 -17
- 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 +10 -5
- package/lib/utils/use/useEventCallback.js.map +1 -1
- package/lib/utils/use/useEventCallback.mjs +8 -3
- package/lib/utils/use/useEventCallback.mjs.map +1 -1
- package/lib/utils/use/useEventListener.js +15 -11
- package/lib/utils/use/useEventListener.js.map +1 -1
- package/lib/utils/use/useEventListener.mjs +11 -7
- package/lib/utils/use/useEventListener.mjs.map +1 -1
- package/lib/utils/use/useFocusLock.js +94 -80
- package/lib/utils/use/useFocusLock.js.map +1 -1
- package/lib/utils/use/useFocusLock.mjs +88 -71
- package/lib/utils/use/useFocusLock.mjs.map +1 -1
- package/lib/utils/use/usePreventScroll.js +26 -24
- package/lib/utils/use/usePreventScroll.js.map +1 -1
- package/lib/utils/use/usePreventScroll.mjs +21 -19
- package/lib/utils/use/usePreventScroll.mjs.map +1 -1
- package/lib/utils/use/useScrollBarWidth.js +14 -8
- package/lib/utils/use/useScrollBarWidth.js.map +1 -1
- package/lib/utils/use/useScrollBarWidth.mjs +13 -8
- package/lib/utils/use/useScrollBarWidth.mjs.map +1 -1
- package/lib/utils/useCssVariable.js +37 -32
- package/lib/utils/useCssVariable.js.map +1 -1
- package/lib/utils/useCssVariable.mjs +34 -27
- package/lib/utils/useCssVariable.mjs.map +1 -1
- package/lib/utils/zIndexStacking.js +24 -28
- package/lib/utils/zIndexStacking.js.map +1 -1
- package/lib/utils/zIndexStacking.mjs +22 -23
- package/lib/utils/zIndexStacking.mjs.map +1 -1
- package/package.json +12 -316
- package/vite.config.ts +0 -22
- package/tsconfig-utils.json +0 -4
|
@@ -1,33 +1,62 @@
|
|
|
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";
|
|
1
4
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
|
|
3
|
-
|
|
5
|
+
var EventEmitter = /*#__PURE__*/function () {
|
|
6
|
+
function EventEmitter() {
|
|
7
|
+
_classCallCheck(this, EventEmitter);
|
|
4
8
|
_defineProperty(this, "events", new Map());
|
|
5
9
|
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
this.
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
return _createClass(EventEmitter, [{
|
|
11
|
+
key: "on",
|
|
12
|
+
value: function on(eventName, fn) {
|
|
13
|
+
var _this$events$get,
|
|
14
|
+
_this = this;
|
|
15
|
+
var handlers = (_this$events$get = this.events.get(eventName)) !== null && _this$events$get !== void 0 ? _this$events$get : new Set();
|
|
16
|
+
handlers.add(fn);
|
|
17
|
+
this.events.set(eventName, handlers);
|
|
18
|
+
return function () {
|
|
19
|
+
_this.off(eventName, fn);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
}, {
|
|
23
|
+
key: "off",
|
|
24
|
+
value: function off(eventName, fn) {
|
|
25
|
+
var _this$events$get2;
|
|
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
|
+
}
|
|
22
48
|
}
|
|
23
49
|
}
|
|
24
|
-
}
|
|
25
50
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
51
|
+
/**
|
|
52
|
+
* @deprecated. Fallback to the `on` method for backward compatibility.
|
|
53
|
+
*/
|
|
54
|
+
}, {
|
|
55
|
+
key: "subscribe",
|
|
56
|
+
value: function subscribe(eventName, fn) {
|
|
57
|
+
return this.on(eventName, fn);
|
|
58
|
+
}
|
|
59
|
+
}]);
|
|
60
|
+
}();
|
|
61
|
+
export { EventEmitter as default };
|
|
33
62
|
//# sourceMappingURL=eventEmitter.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"eventEmitter.mjs","names":["EventEmitter","
|
|
1
|
+
{"version":3,"file":"eventEmitter.mjs","names":["EventEmitter","_classCallCheck","_defineProperty","Map","_createClass","key","value","on","eventName","fn","_this$events$get","_this","handlers","events","get","Set","add","set","off","_this$events$get2","emit","_len","arguments","length","args","Array","_key","_iterator","_createForOfIteratorHelper","_step","s","n","done","handler","call","apply","concat","err","e","f","subscribe","default"],"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":";;;;IAGqBA,YAAY;EAAA,SAAAA,aAAA;IAAAC,eAAA,OAAAD,YAAA;IAAAE,eAAA,iBACd,IAAIC,GAAG,CAAY,CAAC;EAAA;EAAA,OAAAC,YAAA,CAAAJ,YAAA;IAAAK,GAAA;IAAAC,KAAA,EAErC,SAAOC,EAAEA,CAACC,SAAY,EAAEC,EAAK,EAAW;MAAA,IAAAC,gBAAA;QAAAC,KAAA;MACtC,IAAMC,QAAQ,IAAAF,gBAAA,GAAG,IAAI,CAACG,MAAM,CAACC,GAAG,CAACN,SAAS,CAAC,cAAAE,gBAAA,cAAAA,gBAAA,GAAI,IAAIK,GAAG,CAAI,CAAC;MAE3DH,QAAQ,CAACI,GAAG,CAACP,EAAE,CAAC;MAEhB,IAAI,CAACI,MAAM,CAACI,GAAG,CAACT,SAAS,EAAEI,QAAQ,CAAC;MAEpC,OAAO,YAAM;QACXD,KAAI,CAACO,GAAG,CAACV,SAAS,EAAEC,EAAE,CAAC;MACzB,CAAC;IACH;EAAC;IAAAJ,GAAA;IAAAC,KAAA,EAED,SAAOY,GAAGA,CAACV,SAAY,EAAEC,EAAK,EAAQ;MAAA,IAAAU,iBAAA;MACpC,CAAAA,iBAAA,OAAI,CAACN,MAAM,CAACC,GAAG,CAACN,SAAS,CAAC,cAAAW,iBAAA,eAA1BA,iBAAA,UAAkC,CAACV,EAAE,CAAC;IACxC;EAAC;IAAAJ,GAAA;IAAAC,KAAA,EAED,SAAOc,IAAIA,CAACZ,SAAY,EAA0B;MAChD,IAAMI,QAAQ,GAAG,IAAI,CAACC,MAAM,CAACC,GAAG,CAACN,SAAS,CAAC;MAE3C,IAAII,QAAQ,EAAE;QAAA,SAAAS,IAAA,GAAAC,SAAA,CAAAC,MAAA,EAHaC,IAAI,OAAAC,KAAA,CAAAJ,IAAA,OAAAA,IAAA,WAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;UAAJF,IAAI,CAAAE,IAAA,QAAAJ,SAAA,CAAAI,IAAA;QAAA;QAAA,IAAAC,SAAA,GAAAC,0BAAA,CAIPhB,QAAQ;UAAAiB,KAAA;QAAA;UAA9B,KAAAF,SAAA,CAAAG,CAAA,MAAAD,KAAA,GAAAF,SAAA,CAAAI,CAAA,IAAAC,IAAA,GAAgC;YAAA,IAArBC,OAAO,GAAAJ,KAAA,CAAAvB,KAAA;YAChB2B,OAAO,CAACC,IAAI,CAAAC,KAAA,CAAZF,OAAO,GAAM,IAAI,EAAAG,MAAA,CAAKZ,IAAI,EAAC;UAC7B;QAAC,SAAAa,GAAA;UAAAV,SAAA,CAAAW,CAAA,CAAAD,GAAA;QAAA;UAAAV,SAAA,CAAAY,CAAA;QAAA;MACH;IACF;;IAEA;AACF;AACA;EAFE;IAAAlC,GAAA;IAAAC,KAAA,EAGA,SAAOkC,SAASA,CAAChC,SAAY,EAAEC,EAAK,EAAW;MAC7C,OAAO,IAAI,CAACF,EAAE,CAACC,SAAS,EAAEC,EAAE,CAAC;IAC/B;EAAC;AAAA;AAAA,SAlCkBT,YAAY,IAAAyC,OAAA","ignoreList":[]}
|
|
@@ -1,26 +1,29 @@
|
|
|
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
|
-
|
|
14
|
+
function findComponent(Children, names, recursively) {
|
|
15
|
+
var limit = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 100;
|
|
16
|
+
var children = Children[_symbols.CHILDREN_COMPONENT] ? (0, _getOriginChildren["default"])(Children) : Children;
|
|
17
|
+
return _react["default"].Children.toArray(children).find(function (child) {
|
|
18
|
+
if (/*#__PURE__*/_react["default"].isValidElement(child)) {
|
|
19
|
+
if (child.type === _react["default"].Fragment) {
|
|
19
20
|
return findComponent(child.props.children, names, recursively, limit);
|
|
20
21
|
}
|
|
21
22
|
// @ts-ignore
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
var inheritedNames = child.type[_symbols.INHERITED_NAME] || [child.type.displayName];
|
|
24
|
+
var result = !!inheritedNames.find(function (name) {
|
|
25
|
+
return names.includes(name);
|
|
26
|
+
});
|
|
24
27
|
if (!result && child.props.children && recursively && limit > 0) {
|
|
25
28
|
return findComponent(child.props.children, names, recursively, limit - 1);
|
|
26
29
|
}
|
|
@@ -29,7 +32,7 @@ function findComponent(Children, names, recursively, limit = 100) {
|
|
|
29
32
|
});
|
|
30
33
|
}
|
|
31
34
|
function isAdvanceMode(Children, name, recursively) {
|
|
32
|
-
|
|
35
|
+
var children = Children[_symbols.CHILDREN_COMPONENT] ? (0, _getOriginChildren["default"])(Children) : Children;
|
|
33
36
|
if (!children) return false;
|
|
34
37
|
if (typeof children === 'function') {
|
|
35
38
|
return true;
|
|
@@ -37,30 +40,32 @@ function isAdvanceMode(Children, name, recursively) {
|
|
|
37
40
|
return !!findComponent(children, name, recursively);
|
|
38
41
|
}
|
|
39
42
|
function findAllComponents(Children, names) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
_react
|
|
44
|
-
if (/*#__PURE__*/_react
|
|
45
|
-
if (child.type === _react
|
|
46
|
-
|
|
43
|
+
var result = [];
|
|
44
|
+
var _findAllAndAdd = function findAllAndAdd(Children) {
|
|
45
|
+
var children = Children[_symbols.CHILDREN_COMPONENT] ? (0, _getOriginChildren["default"])(Children) : Children;
|
|
46
|
+
_react["default"].Children.toArray(children).forEach(function (child) {
|
|
47
|
+
if (/*#__PURE__*/_react["default"].isValidElement(child)) {
|
|
48
|
+
if (child.type === _react["default"].Fragment) {
|
|
49
|
+
_findAllAndAdd(child.props.children);
|
|
47
50
|
} else if (typeof child.type === 'function' && _symbols.CHILDREN_COMPONENT in child.type && child.type[_symbols.CHILDREN_COMPONENT]) {
|
|
48
|
-
|
|
51
|
+
_findAllAndAdd(child.type);
|
|
49
52
|
} else {
|
|
50
53
|
// @ts-ignore
|
|
51
|
-
|
|
52
|
-
|
|
54
|
+
var inheritedNames = child.type[_symbols.INHERITED_NAME] || [child.type.displayName];
|
|
55
|
+
var component = !!inheritedNames.find(function (name) {
|
|
56
|
+
return names.includes(name);
|
|
57
|
+
});
|
|
53
58
|
if (component) {
|
|
54
59
|
result.push(child);
|
|
55
60
|
}
|
|
56
61
|
if (child.props.children) {
|
|
57
|
-
return
|
|
62
|
+
return _findAllAndAdd(child.props.children);
|
|
58
63
|
}
|
|
59
64
|
}
|
|
60
65
|
}
|
|
61
66
|
});
|
|
62
67
|
};
|
|
63
|
-
|
|
68
|
+
_findAllAndAdd(Children);
|
|
64
69
|
return result;
|
|
65
70
|
}
|
|
66
71
|
|
|
@@ -68,20 +73,22 @@ function findAllComponents(Children, names) {
|
|
|
68
73
|
* Extract some components from Children and return them and rest of components as tuple.
|
|
69
74
|
*/
|
|
70
75
|
function extractFrom(Children, names) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
_react
|
|
76
|
-
if (/*#__PURE__*/_react
|
|
77
|
-
if (child.type === _react
|
|
78
|
-
|
|
76
|
+
var extracted = [];
|
|
77
|
+
var rest = [];
|
|
78
|
+
var _extractor = function extractor(Children) {
|
|
79
|
+
var children = Children[_symbols.CHILDREN_COMPONENT] ? (0, _getOriginChildren["default"])(Children) : Children;
|
|
80
|
+
_react["default"].Children.toArray(children).forEach(function (child) {
|
|
81
|
+
if (/*#__PURE__*/_react["default"].isValidElement(child)) {
|
|
82
|
+
if (child.type === _react["default"].Fragment) {
|
|
83
|
+
_extractor(child.props.children);
|
|
79
84
|
} else if (typeof child.type === 'function' && _symbols.CHILDREN_COMPONENT in child.type && child.type[_symbols.CHILDREN_COMPONENT]) {
|
|
80
|
-
|
|
85
|
+
_extractor(child.type);
|
|
81
86
|
} else {
|
|
82
87
|
// @ts-ignore
|
|
83
|
-
|
|
84
|
-
|
|
88
|
+
var inheritedNames = child.type[_symbols.INHERITED_NAME] || [child.type.displayName];
|
|
89
|
+
var component = !!inheritedNames.find(function (name) {
|
|
90
|
+
return names.includes(name);
|
|
91
|
+
});
|
|
85
92
|
if (component) {
|
|
86
93
|
extracted.push(child);
|
|
87
94
|
} else {
|
|
@@ -91,8 +98,8 @@ function extractFrom(Children, names) {
|
|
|
91
98
|
}
|
|
92
99
|
});
|
|
93
100
|
};
|
|
94
|
-
|
|
101
|
+
_extractor(Children);
|
|
95
102
|
return [extracted, rest];
|
|
96
103
|
}
|
|
97
|
-
var _default = exports
|
|
104
|
+
var _default = exports["default"] = findComponent;
|
|
98
105
|
//# sourceMappingURL=findComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
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"
|
|
1
|
+
{"version":3,"file":"findComponent.js","names":["_react","_interopRequireDefault","require","_getOriginChildren","_symbols","findComponent","Children","names","recursively","limit","arguments","length","undefined","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"],"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,EAEQ;EAAA,IAD7BC,KAAK,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,GAAG;EAEX,IAAMG,QAAQ,GAAGP,QAAQ,CAACQ,2BAAkB,CAAC,GAAG,IAAAC,6BAAiB,EAACT,QA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AAI,CAAChB,KAAK,CAAC;UACvB,CAAC,MAAM;YACLmB,IAAI,CAACH,IAAI,CAAChB,KAAK,CAAC;UAClB;QACF;MACF;IACF,CAAC,CAAC;EACJ,CAAC;EAEDoB,UAAS,CAACjC,QAAQ,CAAC;EAEnB,OAAO,CAAC+B,SAAS,EAAEC,IAAI,CAAC;AAC1B;AAAC,IAAAE,QAAA,GAAAC,OAAA,cAEcpC,aAAa","ignoreList":[]}
|
|
@@ -1,16 +1,19 @@
|
|
|
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
|
-
|
|
4
|
+
function findComponent(Children, names, recursively) {
|
|
5
|
+
var limit = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 100;
|
|
6
|
+
var children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;
|
|
7
|
+
return React.Children.toArray(children).find(function (child) {
|
|
7
8
|
if (/*#__PURE__*/React.isValidElement(child)) {
|
|
8
9
|
if (child.type === React.Fragment) {
|
|
9
10
|
return findComponent(child.props.children, names, recursively, limit);
|
|
10
11
|
}
|
|
11
12
|
// @ts-ignore
|
|
12
|
-
|
|
13
|
-
|
|
13
|
+
var inheritedNames = child.type[INHERITED_NAME] || [child.type.displayName];
|
|
14
|
+
var result = !!inheritedNames.find(function (name) {
|
|
15
|
+
return names.includes(name);
|
|
16
|
+
});
|
|
14
17
|
if (!result && child.props.children && recursively && limit > 0) {
|
|
15
18
|
return findComponent(child.props.children, names, recursively, limit - 1);
|
|
16
19
|
}
|
|
@@ -19,7 +22,7 @@ function findComponent(Children, names, recursively, limit = 100) {
|
|
|
19
22
|
});
|
|
20
23
|
}
|
|
21
24
|
export function isAdvanceMode(Children, name, recursively) {
|
|
22
|
-
|
|
25
|
+
var children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;
|
|
23
26
|
if (!children) return false;
|
|
24
27
|
if (typeof children === 'function') {
|
|
25
28
|
return true;
|
|
@@ -27,30 +30,32 @@ export function isAdvanceMode(Children, name, recursively) {
|
|
|
27
30
|
return !!findComponent(children, name, recursively);
|
|
28
31
|
}
|
|
29
32
|
export function findAllComponents(Children, names) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
React.Children.toArray(children).forEach(child
|
|
33
|
+
var result = [];
|
|
34
|
+
var _findAllAndAdd = function findAllAndAdd(Children) {
|
|
35
|
+
var children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;
|
|
36
|
+
React.Children.toArray(children).forEach(function (child) {
|
|
34
37
|
if (/*#__PURE__*/React.isValidElement(child)) {
|
|
35
38
|
if (child.type === React.Fragment) {
|
|
36
|
-
|
|
39
|
+
_findAllAndAdd(child.props.children);
|
|
37
40
|
} else if (typeof child.type === 'function' && CHILDREN_COMPONENT in child.type && child.type[CHILDREN_COMPONENT]) {
|
|
38
|
-
|
|
41
|
+
_findAllAndAdd(child.type);
|
|
39
42
|
} else {
|
|
40
43
|
// @ts-ignore
|
|
41
|
-
|
|
42
|
-
|
|
44
|
+
var inheritedNames = child.type[INHERITED_NAME] || [child.type.displayName];
|
|
45
|
+
var component = !!inheritedNames.find(function (name) {
|
|
46
|
+
return names.includes(name);
|
|
47
|
+
});
|
|
43
48
|
if (component) {
|
|
44
49
|
result.push(child);
|
|
45
50
|
}
|
|
46
51
|
if (child.props.children) {
|
|
47
|
-
return
|
|
52
|
+
return _findAllAndAdd(child.props.children);
|
|
48
53
|
}
|
|
49
54
|
}
|
|
50
55
|
}
|
|
51
56
|
});
|
|
52
57
|
};
|
|
53
|
-
|
|
58
|
+
_findAllAndAdd(Children);
|
|
54
59
|
return result;
|
|
55
60
|
}
|
|
56
61
|
|
|
@@ -58,20 +63,22 @@ export function findAllComponents(Children, names) {
|
|
|
58
63
|
* Extract some components from Children and return them and rest of components as tuple.
|
|
59
64
|
*/
|
|
60
65
|
export function extractFrom(Children, names) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
React.Children.toArray(children).forEach(child
|
|
66
|
+
var extracted = [];
|
|
67
|
+
var rest = [];
|
|
68
|
+
var _extractor = function extractor(Children) {
|
|
69
|
+
var children = Children[CHILDREN_COMPONENT] ? getOriginChildren(Children) : Children;
|
|
70
|
+
React.Children.toArray(children).forEach(function (child) {
|
|
66
71
|
if (/*#__PURE__*/React.isValidElement(child)) {
|
|
67
72
|
if (child.type === React.Fragment) {
|
|
68
|
-
|
|
73
|
+
_extractor(child.props.children);
|
|
69
74
|
} else if (typeof child.type === 'function' && CHILDREN_COMPONENT in child.type && child.type[CHILDREN_COMPONENT]) {
|
|
70
|
-
|
|
75
|
+
_extractor(child.type);
|
|
71
76
|
} else {
|
|
72
77
|
// @ts-ignore
|
|
73
|
-
|
|
74
|
-
|
|
78
|
+
var inheritedNames = child.type[INHERITED_NAME] || [child.type.displayName];
|
|
79
|
+
var component = !!inheritedNames.find(function (name) {
|
|
80
|
+
return names.includes(name);
|
|
81
|
+
});
|
|
75
82
|
if (component) {
|
|
76
83
|
extracted.push(child);
|
|
77
84
|
} else {
|
|
@@ -81,7 +88,7 @@ export function extractFrom(Children, names) {
|
|
|
81
88
|
}
|
|
82
89
|
});
|
|
83
90
|
};
|
|
84
|
-
|
|
91
|
+
_extractor(Children);
|
|
85
92
|
return [extracted, rest];
|
|
86
93
|
}
|
|
87
94
|
export default findComponent;
|
|
@@ -1 +1 @@
|
|
|
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,
|
|
1
|
+
{"version":3,"file":"findComponent.mjs","names":["React","getOriginChildren","CHILDREN_COMPONENT","INHERITED_NAME","findComponent","Children","names","recursively","limit","arguments","length","undefined","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,EAEQ;EAAA,IAD7BC,KAAK,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,GAAG;EAEX,IAAMG,QAAQ,GAAGP,QAAQ,CAACH,kBAAkB,CAAC,GAAGD,iBAAiB,CAACI,QAAQ,CAAC,GAAGA,QAAQ;EACtF,OAAOL,KAAK,CAACK,QAAQ,CAACQ,OAAO,CAACD,QAAQ,CAAC,CAACE,IAAI,CAAC,UAACC,KAAK,EAAK;IACtD,iBAAIf,KAAK,CAACgB,cAAc,CAACD,KAAK,CAAC,EAAE;MAC/B,IAAIA,KAAK,CAACE,IAAI,KAAKjB,KAAK,CAACkB,QAAQ,EAAE;QACjC,OAAOd,aAAa,CAACW,KAAK,CAACI,KAAK,CAACP,QAAQ,EAAEN,KAAK,EAAEC,WAAW,EAAEC,KAAK,CAAC;MACvE;MACA;MACA,IAAMY,cAAc,GAAGL,KAAK,CAACE,IAAI,CAACd,cAAc,CAAC,IAAI,CAACY,KAAK,CAACE,IAAI,CAAC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O,CAACD,QAAQ,CAAC,CAACgB,OAAO,CAAC,UAACb,KAAK,EAAK;MAClD,iBAAIf,KAAK,CAACgB,cAAc,CAACD,KAAK,CAAC,EAAE;QAC/B,IAAIA,KAAK,CAACE,IAAI,KAAKjB,KAAK,CAACkB,QAAQ,EAAE;UACjCgB,UAAS,CAACnB,KAAK,CAACI,KAAK,CAACP,QAAQ,CAAC;QACjC,CAAC,MAAM,IACL,OAAOG,KAAK,CAACE,IAAI,KAAK,UAAU,IAChCf,kBAAkB,IAAIa,KAAK,CAACE,IAAI,IAChCF,KAAK,CAACE,IAAI,CAACf,kBAAkB,CAAC,EAC9B;UACAgC,UAAS,CAACnB,KAAK,CAACE,IAAI,CAAC;QACvB,CAAC,MAAM;UACL;UACA,IAAMG,cAAc,GAAGL,KAAK,CAACE,IAAI,CAACd,cAAc,CAAC,IAAI,CAACY,KAAK,CAACE,IAAI,CAACI,WAAW,CAAC;UAC7E,IAAMQ,SAAS,GAAG,CAAC,CAACT,cAAc,CAACN,IAAI,CAAC,UAACS,IAAY;YAAA,OAAKjB,KAAK,CAACkB,QAAQ,CAACD,IAAI,CAAC;UAAA,EAAC;UAE/E,IAAIM,SAAS,EAAE;YACbG,SAAS,CAACF,IAAI,CAACf,KAAK,CAAC;UACvB,CAAC,MAAM;YACLkB,IAAI,CAACH,IAAI,CAACf,KAAK,CAAC;UAClB;QACF;MACF;IACF,CAAC,CAAC;EACJ,CAAC;EAEDmB,UAAS,CAAC7B,QAAQ,CAAC;EAEnB,OAAO,CAAC2B,SAAS,EAAEC,IAAI,CAAC;AAC1B;AAEA,eAAe7B,aAAa","ignoreList":[]}
|
package/lib/utils/fire.js
CHANGED
|
@@ -1,17 +1,23 @@
|
|
|
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
|
-
|
|
10
|
+
function fire(context, eventName) {
|
|
11
|
+
var fn = (0, _getValue["default"])(context, "props.".concat(eventName));
|
|
12
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
13
|
+
args[_key - 2] = arguments[_key];
|
|
14
|
+
}
|
|
15
|
+
if (fn) return fn.call.apply(fn, [context].concat(args));
|
|
13
16
|
}
|
|
14
|
-
function fireFn(fn
|
|
15
|
-
|
|
17
|
+
function fireFn(fn) {
|
|
18
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
19
|
+
args[_key2 - 1] = arguments[_key2];
|
|
20
|
+
}
|
|
21
|
+
if (typeof fn === 'function') return fn.apply(void 0, args);
|
|
16
22
|
}
|
|
17
23
|
//# 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","args","
|
|
1
|
+
{"version":3,"file":"fire.js","names":["_getValue","_interopRequireDefault","require","fire","context","eventName","fn","getValue","concat","_len","arguments","length","args","Array","_key","call","apply","fireFn","_len2","_key2"],"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,EAAgB;EACtF,IAAMC,EAAE,GAAG,IAAAC,oBAAQ,EAACH,OAAO,WAAAI,MAAA,CAAWH,SAAS,CAAE,CAAC;EAAC,SAAAI,IAAA,GAAAC,SAAA,CAAAC,MAAA,EADwBC,IAAI,OAAAC,KAAA,CAAAJ,IAAA,OAAAA,IAAA,WAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;IAAJF,IAAI,CAAAE,IAAA,QAAAJ,SAAA,CAAAI,IAAA;EAAA;EAE/E,IAAIR,EAAE,EAAE,OAAOA,EAAE,CAACS,IAAI,CAAAC,KAAA,CAAPV,EAAE,GAAMF,OAAO,EAAAI,MAAA,CAAKI,IAAI,EAAC;AAC1C;AAEO,SAASK,MAAMA,CAACX,EAA0B,EAAkB;EAAA,SAAAY,KAAA,GAAAR,SAAA,CAAAC,MAAA,EAAbC,IAAI,OAAAC,KAAA,CAAAK,KAAA,OAAAA,KAAA,WAAAC,KAAA,MAAAA,KAAA,GAAAD,KAAA,EAAAC,KAAA;IAAJP,IAAI,CAAAO,KAAA,QAAAT,SAAA,CAAAS,KAAA;EAAA;EACxD,IAAI,OAAOb,EAAE,KAAK,UAAU,EAAE,OAAOA,EAAE,CAAAU,KAAA,SAAIJ,IAAI,CAAC;AAClD","ignoreList":[]}
|
package/lib/utils/fire.mjs
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
import getValue from "./getValue.mjs";
|
|
2
|
-
export default function fire(context, eventName
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
export default function fire(context, eventName) {
|
|
3
|
+
var fn = getValue(context, "props.".concat(eventName));
|
|
4
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
5
|
+
args[_key - 2] = arguments[_key];
|
|
6
|
+
}
|
|
7
|
+
if (fn) return fn.call.apply(fn, [context].concat(args));
|
|
5
8
|
}
|
|
6
|
-
export function fireFn(fn
|
|
7
|
-
|
|
9
|
+
export function fireFn(fn) {
|
|
10
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
11
|
+
args[_key2 - 1] = arguments[_key2];
|
|
12
|
+
}
|
|
13
|
+
if (typeof fn === 'function') return fn.apply(void 0, args);
|
|
8
14
|
}
|
|
9
15
|
//# sourceMappingURL=fire.mjs.map
|
package/lib/utils/fire.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fire.mjs","names":["getValue","fire","context","eventName","args","
|
|
1
|
+
{"version":3,"file":"fire.mjs","names":["getValue","fire","context","eventName","fn","concat","_len","arguments","length","args","Array","_key","call","apply","fireFn","_len2","_key2"],"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,OAAOA,QAAQ,MAAM,gBAAY;AAEjC,eAAe,SAASC,IAAIA,CAAeC,OAAU,EAAEC,SAAiB,EAAgB;EACtF,IAAMC,EAAE,GAAGJ,QAAQ,CAACE,OAAO,WAAAG,MAAA,CAAWF,SAAS,CAAE,CAAC;EAAC,SAAAG,IAAA,GAAAC,SAAA,CAAAC,MAAA,EADwBC,IAAI,OAAAC,KAAA,CAAAJ,IAAA,OAAAA,IAAA,WAAAK,IAAA,MAAAA,IAAA,GAAAL,IAAA,EAAAK,IAAA;IAAJF,IAAI,CAAAE,IAAA,QAAAJ,SAAA,CAAAI,IAAA;EAAA;EAE/E,IAAIP,EAAE,EAAE,OAAOA,EAAE,CAACQ,IAAI,CAAAC,KAAA,CAAPT,EAAE,GAAMF,OAAO,EAAAG,MAAA,CAAKI,IAAI,EAAC;AAC1C;AAEA,OAAO,SAASK,MAAMA,CAACV,EAA0B,EAAkB;EAAA,SAAAW,KAAA,GAAAR,SAAA,CAAAC,MAAA,EAAbC,IAAI,OAAAC,KAAA,CAAAK,KAAA,OAAAA,KAAA,WAAAC,KAAA,MAAAA,KAAA,GAAAD,KAAA,EAAAC,KAAA;IAAJP,IAAI,CAAAO,KAAA,QAAAT,SAAA,CAAAS,KAAA;EAAA;EACxD,IAAI,OAAOZ,EAAE,KAAK,UAAU,EAAE,OAAOA,EAAE,CAAAS,KAAA,SAAIJ,IAAI,CAAC;AAClD","ignoreList":[]}
|