uilib-native 4.5.2 → 5.0.0-snapshot.7175

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.
Files changed (71) hide show
  1. package/android/build.gradle +5 -5
  2. package/android/src/main/java/com/wix/reactnativeuilib/UiLibPackageList.java +0 -2
  3. package/android/src/main/java/com/wix/reactnativeuilib/highlighterview/HighlighterViewManager.java +31 -23
  4. package/android/src/main/java/com/wix/reactnativeuilib/keyboardinput/utils/RuntimeUtils.java +1 -1
  5. package/components/HighlighterOverlayView/HighlighterViewNativeComponent.d.ts +61 -0
  6. package/components/HighlighterOverlayView/HighlighterViewNativeComponent.js +2 -0
  7. package/components/HighlighterOverlayView/index.js +49 -0
  8. package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/CustomKeyboardView.android.d.ts +5 -2
  9. package/components/Keyboard/KeyboardAccessoryView/CustomKeyboardView/CustomKeyboardView.android.js +51 -0
  10. package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/CustomKeyboardView.ios.d.ts +1 -1
  11. package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/CustomKeyboardView.ios.js +3 -3
  12. package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/CustomKeyboardView}/CustomKeyboardViewBase.d.ts +3 -0
  13. package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/CustomKeyboardView}/CustomKeyboardViewBase.js +1 -1
  14. package/components/Keyboard/{KeyboardInput/utils → KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager}/__tests__/EventEmitterManager.spec.js +1 -1
  15. package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/KeyboardRegistry}/__tests__/KeyboardRegistry.spec.js +1 -1
  16. package/components/Keyboard/{KeyboardInput/KeyboardRegistry.d.ts → KeyboardAccessoryView/KeyboardRegistry/index.d.ts} +1 -1
  17. package/components/Keyboard/{KeyboardInput/KeyboardRegistry.js → KeyboardAccessoryView/KeyboardRegistry/index.js} +1 -1
  18. package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/KeyboardRegistry}/keyboardRegistry.api.json +9 -9
  19. package/components/Keyboard/KeyboardAccessoryView/KeyboardUtils/index.d.ts +26 -0
  20. package/components/Keyboard/KeyboardAccessoryView/KeyboardUtils/index.js +91 -0
  21. package/components/Keyboard/{KeyboardInput/KeyboardAccessoryView.d.ts → KeyboardAccessoryView/index.d.ts} +11 -1
  22. package/components/Keyboard/{KeyboardInput/KeyboardAccessoryView.js → KeyboardAccessoryView/index.js} +31 -5
  23. package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/keyboardAccessoryView.api.json +5 -5
  24. package/components/Keyboard/{KeyboardTracking/KeyboardAwareInsetsView.d.ts → KeyboardAwareInsetsView/index.d.ts} +1 -1
  25. package/components/Keyboard/{KeyboardTracking/KeyboardAwareInsetsView.js → KeyboardAwareInsetsView/index.js} +1 -1
  26. package/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.ios.d.ts +1 -4
  27. package/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.ios.js +5 -8
  28. package/components/Keyboard/KeyboardTrackingView/KeyboardTrackingViewNativeComponent.d.ts +58 -0
  29. package/components/Keyboard/KeyboardTrackingView/KeyboardTrackingViewNativeComponent.js +2 -0
  30. package/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.d.ts +2 -2
  31. package/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/keyboardTrackingView.api.json +11 -20
  32. package/components/Keyboard/index.d.ts +6 -6
  33. package/components/Keyboard/index.js +6 -6
  34. package/components/SafeArea/SafeAreaInsetsManager.d.ts +8 -3
  35. package/components/SafeArea/SafeAreaInsetsManager.js +89 -23
  36. package/components/SafeArea/SafeAreaSpacerView.js +60 -9
  37. package/package.json +1 -1
  38. package/react-native.config.js +1 -3
  39. package/scripts/releaseNative.js +20 -6
  40. package/android/src/main/java/com/wix/reactnativeuilib/highlighterview/ReactHacks.java +0 -30
  41. package/android/src/main/java/com/wix/reactnativeuilib/highlighterview/ReflectionUtils.java +0 -34
  42. package/android/src/main/java/com/wix/reactnativeuilib/textinput/DefaultKeyListener.java +0 -33
  43. package/android/src/main/java/com/wix/reactnativeuilib/textinput/KeyListenerProxy.java +0 -53
  44. package/android/src/main/java/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerModule.java +0 -54
  45. package/android/src/main/java/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerPackage.java +0 -28
  46. package/android/src/main/java/com/wix/reactnativeuilib/textinput/ViewUtils.java +0 -36
  47. package/components/HighlighterOverlayView.js +0 -40
  48. package/components/Keyboard/KeyboardInput/CustomKeyboardView/CustomKeyboardView.android.js +0 -28
  49. package/components/Keyboard/KeyboardInput/utils/KeyboardUtils.d.ts +0 -11
  50. package/components/Keyboard/KeyboardInput/utils/KeyboardUtils.js +0 -17
  51. /package/components/{HighlighterOverlayView.d.ts → HighlighterOverlayView/index.d.ts} +0 -0
  52. /package/components/{HighlighterOverlayView.web.d.ts → HighlighterOverlayView/index.web.d.ts} +0 -0
  53. /package/components/{HighlighterOverlayView.web.js → HighlighterOverlayView/index.web.js} +0 -0
  54. /package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.d.ts +0 -0
  55. /package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.js +0 -0
  56. /package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.web.d.ts +0 -0
  57. /package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.web.js +0 -0
  58. /package/components/Keyboard/{KeyboardInput/utils/EventEmitterManager.d.ts → KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager/index.d.ts} +0 -0
  59. /package/components/Keyboard/{KeyboardInput/utils/EventEmitterManager.js → KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager/index.js} +0 -0
  60. /package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.android.d.ts +0 -0
  61. /package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.android.js +0 -0
  62. /package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.ios.d.ts +0 -0
  63. /package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.ios.js +0 -0
  64. /package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/index.d.ts +0 -0
  65. /package/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/index.js +0 -0
  66. /package/components/Keyboard/{KeyboardTracking → KeyboardAwareInsetsView}/keyboardAwareInsetsView.api.json +0 -0
  67. /package/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.android.d.ts +0 -0
  68. /package/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.android.js +0 -0
  69. /package/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.js +0 -0
  70. /package/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.web.d.ts +0 -0
  71. /package/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.web.js +0 -0
@@ -1,8 +1,8 @@
1
1
  import React, { Component } from 'react';
2
2
  import { StyleSheet, Platform, NativeModules, NativeEventEmitter, DeviceEventEmitter, processColor, BackHandler } from 'react-native';
3
- import KeyboardTrackingView from "../KeyboardTracking/KeyboardTrackingView";
3
+ import KeyboardTrackingView from "../KeyboardTrackingView";
4
4
  import CustomKeyboardView from "./CustomKeyboardView";
5
- import KeyboardUtils from "./utils/KeyboardUtils";
5
+ import KeyboardUtils, { KeyboardHeightListener } from "./KeyboardUtils";
6
6
  const IsIOS = Platform.OS === 'ios';
7
7
  const IsAndroid = Platform.OS === 'android';
8
8
  /**
@@ -20,9 +20,11 @@ class KeyboardAccessoryView extends Component {
20
20
  allowHitsOutsideBounds: false,
21
21
  scrollBehavior: KeyboardTrackingView.scrollBehaviors.FIXED_OFFSET
22
22
  };
23
+ static currentId = 0;
23
24
 
24
25
  // TODO: fix
25
26
 
27
+ id = ++KeyboardAccessoryView.currentId;
26
28
  constructor(props) {
27
29
  super(props);
28
30
  this.onContainerComponentHeightChanged = this.onContainerComponentHeightChanged.bind(this);
@@ -33,12 +35,16 @@ class KeyboardAccessoryView extends Component {
33
35
  this.registerForKeyboardResignedEvent();
34
36
  this.registerAndroidBackHandler();
35
37
  }
38
+ state = {
39
+ keyboardHeight: 0,
40
+ shouldFocus: true
41
+ };
36
42
  componentWillUnmount() {
37
43
  if (this.customInputControllerEventsSubscriber) {
38
44
  this.customInputControllerEventsSubscriber.remove();
39
45
  }
40
46
  if (IsAndroid) {
41
- BackHandler.removeEventListener('hardwareBackPress', this.onAndroidBackPressed);
47
+ this.subscription.remove();
42
48
  }
43
49
  }
44
50
  onContainerComponentHeightChanged(event) {
@@ -87,7 +93,7 @@ class KeyboardAccessoryView extends Component {
87
93
  }
88
94
  registerAndroidBackHandler() {
89
95
  if (IsAndroid) {
90
- BackHandler.addEventListener('hardwareBackPress', this.onAndroidBackPressed);
96
+ this.subscription = BackHandler.addEventListener('hardwareBackPress', this.onAndroidBackPressed);
91
97
  }
92
98
  }
93
99
  processInitialProps() {
@@ -106,7 +112,26 @@ class KeyboardAccessoryView extends Component {
106
112
  this.trackingViewRef.scrollToStart();
107
113
  }
108
114
  }
115
+ onKeyboardHeightChange = keyboardHeight => {
116
+ this.setState({
117
+ keyboardHeight
118
+ });
119
+ };
120
+ onDismiss = () => {
121
+ this.setState({
122
+ shouldFocus: false
123
+ });
124
+ };
125
+ onKeyboardDismiss = () => {
126
+ this.setState({
127
+ shouldFocus: true
128
+ });
129
+ };
109
130
  render() {
131
+ const {
132
+ keyboardHeight,
133
+ shouldFocus
134
+ } = this.state;
110
135
  const {
111
136
  renderContent,
112
137
  kbInputRef,
@@ -117,8 +142,9 @@ class KeyboardAccessoryView extends Component {
117
142
  ...others
118
143
  } = this.props;
119
144
  return <KeyboardTrackingView {...others} scrollBehavior={scrollBehavior} ref={r => this.trackingViewRef = r} style={styles.trackingToolbarContainer} onLayout={this.onContainerComponentHeightChanged}>
145
+ <KeyboardHeightListener id={`${this.id}`} onDismiss={this.onDismiss} onKeyboardHeightChange={this.onKeyboardHeightChange} />
120
146
  <>{renderContent?.()}</>
121
- <CustomKeyboardView inputRef={kbInputRef} component={kbComponent} initialProps={this.processInitialProps()} onItemSelected={onItemSelected} onRequestShowKeyboard={onRequestShowKeyboard} useSafeArea={others.useSafeArea} />
147
+ <CustomKeyboardView keyboardHeight={keyboardHeight} shouldFocus={shouldFocus} onKeyboardDismiss={this.onKeyboardDismiss} inputRef={kbInputRef} component={kbComponent} initialProps={this.processInitialProps()} onItemSelected={onItemSelected} onRequestShowKeyboard={onRequestShowKeyboard} useSafeArea={others.useSafeArea} />
122
148
  </KeyboardTrackingView>;
123
149
  }
124
150
  }
@@ -15,9 +15,9 @@
15
15
  {
16
16
  "name": "kbInputRef",
17
17
  "type": "any",
18
- "description": "The reference to the actual text input (or the keyboard may not reset when instructed to, etc.).",
19
- "required": true,
20
- "note": "iOS only"
18
+ "description": "The reference to the actual text input (or the keyboard may not reset when instructed to, etc.)",
19
+ "note": "iOS only",
20
+ "required": true
21
21
  },
22
22
  {
23
23
  "name": "kbComponent",
@@ -33,12 +33,12 @@
33
33
  {
34
34
  "name": "onItemSelected",
35
35
  "type": "() => void",
36
- "description": "Callback that will be called when an item on the keyboard has been pressed."
36
+ "description": "Callback that will be called when an item on the keyboard has been pressed"
37
37
  },
38
38
  {
39
39
  "name": "onRequestShowKeyboard",
40
40
  "type": "() => void",
41
- "description": "Callback that will be called if KeyboardRegistry.requestShowKeyboard is called."
41
+ "description": "Callback that will be called if KeyboardRegistry.requestShowKeyboard is called"
42
42
  },
43
43
  {
44
44
  "name": "onKeyboardResigned",
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { KeyboardTrackingViewProps } from './KeyboardTrackingView';
2
+ import { KeyboardTrackingViewProps } from '../KeyboardTrackingView';
3
3
  type Props = KeyboardTrackingViewProps & {
4
4
  offset?: number;
5
5
  };
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { StyleSheet, Dimensions } from 'react-native';
3
- import KeyboardTrackingView from "./KeyboardTrackingView";
3
+ import KeyboardTrackingView from "../KeyboardTrackingView";
4
4
  /**
5
5
  * @description: Used to add an inset when a keyboard is used and might hide part of the screen.
6
6
  *
@@ -1,10 +1,7 @@
1
- /**
2
- * Created by artald on 15/05/2016.
3
- */
4
1
  import React, { PureComponent } from 'react';
5
2
  import { KeyboardTrackingViewProps } from './index';
6
3
  /**
7
- * @description: A UI component that enables keyboard tracking" for this view and it's sub-views.
4
+ * @description: A UI component that enables "keyboard tracking" for this view and it's sub-views.
8
5
  * Would typically be used when you have a TextField or TextInput inside this view.
9
6
  *
10
7
  * @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/nativeComponentScreens/KeyboardTrackingViewScreen.js
@@ -1,14 +1,11 @@
1
- /**
2
- * Created by artald on 15/05/2016.
3
- */
4
-
5
1
  import React, { PureComponent } from 'react';
6
- import ReactNative, { requireNativeComponent, NativeModules } from 'react-native';
7
- const NativeKeyboardTrackingView = requireNativeComponent('KeyboardTrackingViewTemp');
2
+ import ReactNative, { NativeModules } from 'react-native';
3
+ // Import the Codegen specification for New Architecture
4
+ import KeyboardTrackingViewNativeComponent from "./KeyboardTrackingViewNativeComponent";
8
5
  const KeyboardTrackingViewTempManager = NativeModules.KeyboardTrackingViewTempManager;
9
6
 
10
7
  /**
11
- * @description: A UI component that enables keyboard tracking" for this view and it's sub-views.
8
+ * @description: A UI component that enables "keyboard tracking" for this view and it's sub-views.
12
9
  * Would typically be used when you have a TextField or TextInput inside this view.
13
10
  *
14
11
  * @example: https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/nativeComponentScreens/KeyboardTrackingViewScreen.js
@@ -21,7 +18,7 @@ class KeyboardTrackingView extends PureComponent {
21
18
  useSafeArea: false
22
19
  };
23
20
  render() {
24
- return <NativeKeyboardTrackingView {...this.props} ref={r => this.ref = r} />;
21
+ return <KeyboardTrackingViewNativeComponent {...this.props} ref={r => this.ref = r} />;
25
22
  }
26
23
  async getNativeProps() {
27
24
  if (this.ref && KeyboardTrackingViewTempManager && KeyboardTrackingViewTempManager.getNativeProps) {
@@ -0,0 +1,58 @@
1
+ /// <reference types="react-native/types/modules/codegen" />
2
+ import type { ViewProps } from 'react-native';
3
+ import type { Int32, WithDefault } from 'react-native/Libraries/Types/CodegenTypes';
4
+ export interface NativeProps extends ViewProps {
5
+ /**
6
+ * Enables tracking of the keyboard when it's dismissed interactively (false by default).
7
+ */
8
+ trackInteractive?: WithDefault<boolean, false>;
9
+ /**
10
+ * iOS only.
11
+ * Show the keyboard on a negative scroll
12
+ */
13
+ revealKeyboardInteractive?: WithDefault<boolean, false>;
14
+ /**
15
+ * iOS only.
16
+ * Set to false to turn off inset management and manage it yourself
17
+ */
18
+ manageScrollView?: WithDefault<boolean, true>;
19
+ /**
20
+ * iOS only.
21
+ * Set to true manageScrollView is set to true and still does not work
22
+ */
23
+ requiresSameParentToManageScrollView?: WithDefault<boolean, false>;
24
+ /**
25
+ * iOS only.
26
+ * Allow hitting sub-views that are placed beyond the view bounds
27
+ */
28
+ allowHitsOutsideBounds?: WithDefault<boolean, false>;
29
+ /**
30
+ * Should the scrollView scroll to the focused input
31
+ */
32
+ scrollToFocusedInput?: WithDefault<boolean, false>;
33
+ /**
34
+ * iOS only.
35
+ * The scrolling behavior (NONE | SCROLL_TO_BOTTOM_INVERTED_ONLY | FIXED_OFFSET)
36
+ */
37
+ scrollBehavior?: WithDefault<Int32, 0>;
38
+ /**
39
+ * iOS only.
40
+ * Add a SafeArea view beneath the KeyboardAccessoryView
41
+ */
42
+ addBottomView?: WithDefault<boolean, false>;
43
+ /**
44
+ * iOS only.
45
+ * The bottom view's color
46
+ */
47
+ bottomViewColor?: string;
48
+ /**
49
+ * Allow control safe area
50
+ */
51
+ useSafeArea?: WithDefault<boolean, false>;
52
+ /**
53
+ * Whether or not to include bottom tab bar inset
54
+ */
55
+ usesBottomTabs?: WithDefault<boolean, false>;
56
+ }
57
+ declare const _default: import("react-native/Libraries/Utilities/codegenNativeComponent").NativeComponentType<NativeProps>;
58
+ export default _default;
@@ -0,0 +1,2 @@
1
+ import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
2
+ export default codegenNativeComponent('KeyboardTrackingViewTemp');
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
- import { ViewStyle, ViewProps } from 'react-native';
2
+ import { StyleProp, ViewStyle, ViewProps } from 'react-native';
3
3
  declare const SCROLL_BEHAVIORS: {
4
4
  NONE: any;
5
5
  SCROLL_TO_BOTTOM_INVERTED_ONLY: any;
@@ -72,7 +72,7 @@ export type KeyboardTrackingViewProps = ViewProps & {
72
72
  */
73
73
  usesBottomTabs?: boolean;
74
74
  ref?: any;
75
- style?: ViewStyle;
75
+ style?: StyleProp<ViewStyle>;
76
76
  children?: React.ReactChild | React.ReactChild[];
77
77
  };
78
78
  declare const _default: React.ForwardRefExoticComponent<Omit<KeyboardTrackingViewProps, "ref"> & React.RefAttributes<unknown>> & {
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "KeyboardTrackingView",
3
3
  "category": "infra",
4
- "description": "A UI component that enables 'keyboard tracking' for this view and it's sub-views.\nWould typically be used when you have a TextField or TextInput inside this view.",
5
- "note": "This view is useful only for iOS.",
4
+ "description": "A UI component that enables 'keyboard tracking' for this view and it's sub-views.\nWould typically be used when you have a TextField or TextInput inside this view",
5
+ "note": "This view is useful only for iOS",
6
6
  "example": "https://github.com/wix/react-native-ui-lib/blob/master/demo/src/screens/nativeComponentScreens/KeyboardTrackingViewScreen.js",
7
7
  "images": [
8
8
  "https://github.com/wix/react-native-ui-lib/blob/master/demo/showcase/KeyboardTrackingView/KeyboardTrackingView.gif?raw=true"
@@ -21,63 +21,54 @@
21
21
  {
22
22
  "name": "scrollBehavior",
23
23
  "type": "number",
24
- "description": "The scrolling behavior (use KeyboardTrackingView.scrollBehaviors.NONE | SCROLL_TO_BOTTOM_INVERTED_ONLY | FIXED_OFFSET)",
25
- "note": "iOS only"
24
+ "description": "The scrolling behavior (use KeyboardTrackingView.scrollBehaviors.NONE | SCROLL_TO_BOTTOM_INVERTED_ONLY | FIXED_OFFSET)"
26
25
  },
27
26
  {
28
27
  "name": "revealKeyboardInteractive",
29
28
  "type": "boolean",
30
- "description": "Show the keyboard on a negative scroll.",
31
- "note": "iOS only",
29
+ "description": "Show the keyboard on a negative scroll",
32
30
  "default": "false"
33
31
  },
34
32
  {
35
33
  "name": "manageScrollView",
36
34
  "type": "boolean",
37
- "description": "Set to false to turn off inset management and manage it yourself.",
38
- "note": "iOS only",
35
+ "description": "Set to false to turn off inset management and manage it yourself",
39
36
  "default": "true"
40
37
  },
41
38
  {
42
39
  "name": "requiresSameParentToManageScrollView",
43
40
  "type": "boolean",
44
- "description": "Set to true manageScrollView is set to true and still does not work,\nit means that the ScrollView found is the wrong one and you'll have\nto have the KeyboardAccessoryView and the ScrollView as siblings\nand set this to true.",
45
- "note": "iOS only",
41
+ "description": "Set to true manageScrollView is set to true and still does not work,\nit means that the ScrollView found is the wrong one and you'll have\nto have the KeyboardAccessoryView and the ScrollView as siblings\nand set this to true",
46
42
  "default": "false"
47
43
  },
48
44
  {
49
45
  "name": "allowHitsOutsideBounds",
50
46
  "type": "boolean",
51
- "description": "Allow hitting sub-views that are placed beyond the view bounds.",
52
- "note": "iOS only",
47
+ "description": "Allow hitting sub-views that are placed beyond the view bounds",
53
48
  "default": "false"
54
49
  },
55
50
  {
56
51
  "name": "addBottomView",
57
52
  "type": "boolean",
58
- "description": "Add a view beneath the KeyboardAccessoryView.",
59
- "note": "iOS only",
53
+ "description": "Add a view beneath the KeyboardAccessoryView",
60
54
  "default": "false"
61
55
  },
62
56
  {
63
57
  "name": "bottomViewColor",
64
58
  "type": "string",
65
- "description": "The bottom view's color.",
66
- "note": "iOS only",
59
+ "description": "The bottom view's color",
67
60
  "default": "white"
68
61
  },
69
62
  {
70
63
  "name": "useSafeArea",
71
64
  "type": "boolean",
72
- "description": "Whether or not to handle SafeArea.",
73
- "note": "iOS only",
65
+ "description": "Whether or not to handle SafeArea",
74
66
  "default": "true"
75
67
  },
76
68
  {
77
69
  "name": "usesBottomTabs",
78
70
  "type": "boolean",
79
- "description": "Whether or not to include bottom tab bar inset.",
80
- "note": "iOS only",
71
+ "description": "Whether or not to include bottom tab bar inset",
81
72
  "default": "false"
82
73
  },
83
74
  {"name": "ref", "type": "any", "description": ""},
@@ -1,8 +1,8 @@
1
1
  /// <reference types="react" />
2
- import { KeyboardTrackingViewProps } from './KeyboardTracking/KeyboardTrackingView';
3
- import KeyboardRegistry from './KeyboardInput/KeyboardRegistry';
4
- import KeyboardAccessoryView, { KeyboardAccessoryViewProps } from './KeyboardInput/KeyboardAccessoryView';
5
- import KeyboardUtils from './KeyboardInput/utils/KeyboardUtils';
2
+ import { KeyboardTrackingViewProps } from './KeyboardTrackingView';
3
+ import KeyboardAccessoryView, { KeyboardAccessoryViewProps } from './KeyboardAccessoryView';
4
+ import KeyboardRegistry from './KeyboardAccessoryView/KeyboardRegistry';
5
+ import KeyboardUtils from './KeyboardAccessoryView/KeyboardUtils';
6
6
  export { KeyboardTrackingViewProps, KeyboardAccessoryViewProps };
7
7
  declare const _default: {
8
8
  KeyboardTrackingView: import("react").ForwardRefExoticComponent<Omit<KeyboardTrackingViewProps, "ref"> & import("react").RefAttributes<unknown>> & {
@@ -26,15 +26,15 @@ declare const _default: {
26
26
  useSafeArea?: boolean | undefined;
27
27
  usesBottomTabs?: boolean | undefined;
28
28
  ref?: any;
29
- style?: import("react-native/types").ViewStyle | undefined;
29
+ style?: import("react-native/types").StyleProp<import("react-native/types").ViewStyle>;
30
30
  children?: import("react").ReactChild | import("react").ReactChild[] | undefined;
31
31
  } & {
32
32
  offset?: number | undefined;
33
33
  }): import("react").JSX.Element;
34
34
  displayName: string;
35
35
  };
36
- KeyboardRegistry: typeof KeyboardRegistry;
37
36
  KeyboardAccessoryView: typeof KeyboardAccessoryView;
37
+ KeyboardRegistry: typeof KeyboardRegistry;
38
38
  KeyboardUtils: typeof KeyboardUtils;
39
39
  };
40
40
  export default _default;
@@ -1,13 +1,13 @@
1
- import KeyboardTrackingView, { KeyboardTrackingViewProps } from "./KeyboardTracking/KeyboardTrackingView";
2
- import KeyboardAwareInsetsView from "./KeyboardTracking/KeyboardAwareInsetsView";
3
- import KeyboardRegistry from "./KeyboardInput/KeyboardRegistry";
4
- import KeyboardAccessoryView, { KeyboardAccessoryViewProps } from "./KeyboardInput/KeyboardAccessoryView";
5
- import KeyboardUtils from "./KeyboardInput/utils/KeyboardUtils";
1
+ import KeyboardTrackingView, { KeyboardTrackingViewProps } from "./KeyboardTrackingView";
2
+ import KeyboardAwareInsetsView from "./KeyboardAwareInsetsView";
3
+ import KeyboardAccessoryView, { KeyboardAccessoryViewProps } from "./KeyboardAccessoryView";
4
+ import KeyboardRegistry from "./KeyboardAccessoryView/KeyboardRegistry";
5
+ import KeyboardUtils from "./KeyboardAccessoryView/KeyboardUtils";
6
6
  export { KeyboardTrackingViewProps, KeyboardAccessoryViewProps };
7
7
  export default {
8
8
  KeyboardTrackingView,
9
9
  KeyboardAwareInsetsView,
10
- KeyboardRegistry,
11
10
  KeyboardAccessoryView,
11
+ KeyboardRegistry,
12
12
  KeyboardUtils
13
13
  };
@@ -8,13 +8,18 @@ declare class SafeAreaInsetsManager {
8
8
  _defaultInsets: SafeAreaInsetsType;
9
9
  _safeAreaInsets: SafeAreaInsetsType;
10
10
  _safeAreaChangedDelegates: Array<any>;
11
+ _nativeModule: any;
11
12
  constructor();
12
- addSafeAreaChangedListener(): void;
13
+ setupNativeConnection(): void;
14
+ setupEventListener(): void;
15
+ getInitialInsets(): Promise<void>;
16
+ notifyDelegates(insets: SafeAreaInsetsType): void;
13
17
  _updateInsets(): Promise<void>;
14
18
  getSafeAreaInsets(): Promise<SafeAreaInsetsType>;
15
19
  addSafeAreaChangedDelegate(delegate: any): void;
16
20
  removeSafeAreaChangedDelegate(delegateToRemove: any): void;
17
21
  get defaultInsets(): SafeAreaInsetsType;
22
+ refreshSafeAreaInsets(): Promise<void>;
18
23
  }
19
- declare const _default: SafeAreaInsetsManager;
20
- export default _default;
24
+ declare const instance: SafeAreaInsetsManager;
25
+ export default instance;
@@ -1,48 +1,101 @@
1
+ import _isEqual from "lodash/isEqual";
1
2
  import _remove from "lodash/remove";
2
3
  import _forEach from "lodash/forEach";
3
4
  /* eslint no-underscore-dangle: 0 */
4
-
5
- import { NativeModules, NativeEventEmitter } from 'react-native';
5
+ import { NativeModules, DeviceEventEmitter, Platform } from 'react-native';
6
6
  let SafeAreaInsetsCache = null;
7
- const NativeSafeAreaManager = NativeModules.SafeAreaManager;
8
7
  class SafeAreaInsetsManager {
9
8
  _defaultInsets = {
10
- top: 0,
9
+ top: 47,
11
10
  left: 0,
12
- bottom: 0,
11
+ bottom: 34,
13
12
  right: 0
14
- };
13
+ }; // Common iPhone safe area values
15
14
  _safeAreaInsets = {
16
- top: 0,
15
+ top: 47,
17
16
  left: 0,
18
- bottom: 0,
17
+ bottom: 34,
19
18
  right: 0
20
19
  };
21
20
  _safeAreaChangedDelegates = [];
21
+ _nativeModule = null;
22
22
  constructor() {
23
- this.addSafeAreaChangedListener();
23
+ // Initialize with default values
24
+ this._safeAreaInsets = this._defaultInsets;
25
+
26
+ // Try to connect to native module
27
+ this.setupNativeConnection();
24
28
  }
25
- addSafeAreaChangedListener() {
26
- if (!NativeSafeAreaManager) {
29
+ setupNativeConnection() {
30
+ try {
31
+ // Access the native module directly without causing getConstants
32
+ this._nativeModule = NativeModules.SafeAreaManager;
33
+ if (this._nativeModule) {
34
+ // Set up event listener using DeviceEventEmitter instead of NativeEventEmitter
35
+ // This avoids getConstants issues
36
+ this.setupEventListener();
37
+
38
+ // Get initial safe area insets
39
+ this.getInitialInsets();
40
+ } else {
41
+ console.log('SafeAreaInsetsManager: Native SafeAreaManager not available, using defaults');
42
+ }
43
+ } catch (error) {
44
+ console.warn('SafeAreaInsetsManager: Failed to connect to native module:', error);
45
+ }
46
+ }
47
+ setupEventListener() {
48
+ if (Platform.OS !== 'ios') {
27
49
  return;
28
50
  }
29
- const NativeSafeAreaEvents = new NativeEventEmitter(NativeSafeAreaManager);
30
- NativeSafeAreaEvents.addListener('SafeAreaInsetsDidChangeEvent', safeAreaInsets => {
31
- SafeAreaInsetsCache = safeAreaInsets;
32
- this._safeAreaInsets = SafeAreaInsetsCache;
33
- _forEach(this._safeAreaChangedDelegates, delegate => {
34
- if (delegate.onSafeAreaInsetsDidChangeEvent) {
35
- delegate.onSafeAreaInsetsDidChangeEvent(this._safeAreaInsets);
36
- } else {
37
- console.warn('ERROR', 'SafeAreaInsetsManager', 'safe area changed delegate was added, but it does not implement the onSafeAreaInsetsDidChangeEvent method'); //eslint-disable-line
51
+ try {
52
+ // Use DeviceEventEmitter instead of NativeEventEmitter to avoid getConstants
53
+ DeviceEventEmitter.addListener('SafeAreaInsetsDidChangeEvent', data => {
54
+ if (data) {
55
+ SafeAreaInsetsCache = data;
56
+ this._safeAreaInsets = data;
57
+ this.notifyDelegates(data);
38
58
  }
39
59
  });
60
+ } catch (error) {
61
+ console.warn('SafeAreaInsetsManager: Failed to setup event listener:', error);
62
+ }
63
+ }
64
+ async getInitialInsets() {
65
+ if (!this._nativeModule) {
66
+ return;
67
+ }
68
+ try {
69
+ const insets = await this._nativeModule.getSafeAreaInsets();
70
+ if (insets) {
71
+ SafeAreaInsetsCache = insets;
72
+ this._safeAreaInsets = insets;
73
+ // Don't notify delegates yet as components might not be ready
74
+ }
75
+ } catch (error) {
76
+ console.warn('SafeAreaInsetsManager: Failed to get initial insets:', error);
77
+ }
78
+ }
79
+ notifyDelegates(insets) {
80
+ _forEach(this._safeAreaChangedDelegates, delegate => {
81
+ if (delegate.onSafeAreaInsetsDidChangeEvent) {
82
+ delegate.onSafeAreaInsetsDidChangeEvent(insets);
83
+ }
40
84
  });
41
85
  }
42
86
  async _updateInsets() {
43
- if (NativeSafeAreaManager && SafeAreaInsetsCache === null) {
44
- SafeAreaInsetsCache = await NativeSafeAreaManager.getSafeAreaInsets();
87
+ if (this._nativeModule && SafeAreaInsetsCache === null) {
88
+ try {
89
+ SafeAreaInsetsCache = await this._nativeModule.getSafeAreaInsets();
90
+ this._safeAreaInsets = SafeAreaInsetsCache;
91
+ } catch (error) {
92
+ console.warn('SafeAreaInsetsManager: Failed to get native insets:', error);
93
+ this._safeAreaInsets = this._defaultInsets;
94
+ }
95
+ } else if (SafeAreaInsetsCache !== null) {
45
96
  this._safeAreaInsets = SafeAreaInsetsCache;
97
+ } else {
98
+ this._safeAreaInsets = this._defaultInsets;
46
99
  }
47
100
  }
48
101
  async getSafeAreaInsets() {
@@ -60,5 +113,18 @@ class SafeAreaInsetsManager {
60
113
  get defaultInsets() {
61
114
  return this._defaultInsets;
62
115
  }
116
+
117
+ // Method to manually refresh safe area insets and notify delegates
118
+ async refreshSafeAreaInsets() {
119
+ const previousInsets = this._safeAreaInsets;
120
+ SafeAreaInsetsCache = null; // Force refresh
121
+ await this._updateInsets();
122
+
123
+ // Notify delegates if insets changed
124
+ if (!_isEqual(previousInsets, this._safeAreaInsets)) {
125
+ this.notifyDelegates(this._safeAreaInsets);
126
+ }
127
+ }
63
128
  }
64
- export default new SafeAreaInsetsManager();
129
+ const instance = new SafeAreaInsetsManager();
130
+ export default instance;
@@ -1,14 +1,65 @@
1
- import React from 'react';
2
- import { View, requireNativeComponent, Platform } from 'react-native';
3
- const NativeSafeAreaSpacerView = requireNativeComponent('SafeAreaSpacerView');
4
- const isIOS = Platform.OS === 'ios';
1
+ import React, { useState, useCallback, useEffect } from 'react';
2
+ import { View, Dimensions } from 'react-native';
3
+ import SafeAreaInsetsManager from "./SafeAreaInsetsManager";
5
4
  const SafeAreaSpacerView = ({
6
5
  style
7
6
  }) => {
8
- return (
9
- // @ts-ignore
10
- isIOS ? <NativeSafeAreaSpacerView style={style} /> : <View style={style} />
11
- );
7
+ const [safeAreaInsets, setSafeAreaInsets] = useState({
8
+ top: 0,
9
+ left: 0,
10
+ bottom: 0,
11
+ right: 0
12
+ });
13
+ const [spacerHeight, setSpacerHeight] = useState(0);
14
+ useEffect(() => {
15
+ const getSafeAreaInsets = async () => {
16
+ try {
17
+ const insets = await SafeAreaInsetsManager.getSafeAreaInsets();
18
+ if (insets) {
19
+ setSafeAreaInsets(insets);
20
+ }
21
+ } catch (error) {
22
+ console.warn('SafeAreaSpacerView: Failed to get initial safe area insets:', error);
23
+ }
24
+ };
25
+ getSafeAreaInsets();
26
+
27
+ // Add delegate to listen for safe area changes from native component
28
+ const delegate = {
29
+ onSafeAreaInsetsDidChangeEvent: insets => {
30
+ if (insets) {
31
+ setSafeAreaInsets(insets);
32
+ }
33
+ }
34
+ };
35
+ SafeAreaInsetsManager.addSafeAreaChangedDelegate(delegate);
36
+ return () => {
37
+ SafeAreaInsetsManager.removeSafeAreaChangedDelegate(delegate);
38
+ };
39
+ }, []);
40
+
41
+ // Position detection with useCallback
42
+ const handleLayout = useCallback(event => {
43
+ const {
44
+ y
45
+ } = event.nativeEvent.layout;
46
+ const screenHeight = Dimensions.get('window').height;
47
+ let height = 0;
48
+ // Check if positioned within safe area bounds
49
+ if (y < safeAreaInsets.top) {
50
+ height = safeAreaInsets.top;
51
+ } else if (y > screenHeight - safeAreaInsets.bottom) {
52
+ height = safeAreaInsets.bottom;
53
+ }
54
+ if (height !== spacerHeight) {
55
+ setSpacerHeight(height);
56
+ }
57
+ }, [safeAreaInsets, spacerHeight]);
58
+ const spacerStyle = {
59
+ height: spacerHeight,
60
+ ...style
61
+ };
62
+ return <View style={spacerStyle} onLayout={handleLayout} />;
12
63
  };
13
- SafeAreaSpacerView.displayName = 'IGNORE';
64
+ SafeAreaSpacerView.displayName = 'SafeAreaSpacerView';
14
65
  export default SafeAreaSpacerView;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "uilib-native",
3
- "version": "4.5.2",
3
+ "version": "5.0.0-snapshot.7175",
4
4
  "homepage": "https://github.com/wix/react-native-ui-lib",
5
5
  "description": "uilib native components (separated from js components)",
6
6
  "main": "components/index",
@@ -10,11 +10,9 @@ module.exports = {
10
10
  sourceDir: './android/',
11
11
  packageImportPath: `import com.wix.reactnativeuilib.dynamicfont.DynamicFontPackage;
12
12
  import com.wix.reactnativeuilib.highlighterview.HighlighterViewPackage;
13
- import com.wix.reactnativeuilib.keyboardinput.KeyboardInputPackage;
14
- import com.wix.reactnativeuilib.textinput.TextInputDelKeyHandlerPackage;`,
13
+ import com.wix.reactnativeuilib.keyboardinput.KeyboardInputPackage;`,
15
14
  packageInstance: `new DynamicFontPackage(),
16
15
  new HighlighterViewPackage(),
17
- new TextInputDelKeyHandlerPackage(),
18
16
  new KeyboardInputPackage(getApplication())`
19
17
  }
20
18
  }