react-native-ui-lib 7.46.3 → 8.0.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.
Files changed (214) hide show
  1. package/babel.config.js +12 -0
  2. package/incubator.d.ts +2 -2
  3. package/incubator.js +0 -2
  4. package/index.js +1 -0
  5. package/lib/android/build.gradle +5 -5
  6. package/lib/android/src/main/java/com/wix/reactnativeuilib/UiLibPackageList.java +0 -2
  7. package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/HighlighterViewManager.java +31 -23
  8. package/lib/android/src/main/java/com/wix/reactnativeuilib/keyboardinput/utils/RuntimeUtils.java +1 -1
  9. package/lib/components/{HighlighterOverlayView.d.ts → HighlighterOverlayView/index.d.ts} +1 -1
  10. package/lib/components/HighlighterOverlayView/index.js +49 -0
  11. package/lib/components/{HighlighterOverlayView.web.d.ts → HighlighterOverlayView/index.web.d.ts} +1 -1
  12. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/CustomKeyboardView.android.d.ts +5 -2
  13. package/lib/components/Keyboard/KeyboardAccessoryView/CustomKeyboardView/CustomKeyboardView.android.js +51 -0
  14. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/CustomKeyboardView.ios.d.ts +1 -1
  15. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/CustomKeyboardView.ios.js +3 -3
  16. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/CustomKeyboardView}/CustomKeyboardViewBase.d.ts +3 -0
  17. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/CustomKeyboardView}/CustomKeyboardViewBase.js +1 -1
  18. package/lib/components/Keyboard/{KeyboardInput/utils → KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager}/__tests__/EventEmitterManager.spec.js +1 -1
  19. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/KeyboardRegistry}/__tests__/KeyboardRegistry.spec.js +1 -1
  20. package/lib/components/Keyboard/{KeyboardInput/KeyboardRegistry.d.ts → KeyboardAccessoryView/KeyboardRegistry/index.d.ts} +1 -1
  21. package/lib/components/Keyboard/{KeyboardInput/KeyboardRegistry.js → KeyboardAccessoryView/KeyboardRegistry/index.js} +1 -1
  22. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView/KeyboardRegistry}/keyboardRegistry.api.json +9 -9
  23. package/lib/components/Keyboard/KeyboardAccessoryView/KeyboardUtils/index.d.ts +26 -0
  24. package/lib/components/Keyboard/KeyboardAccessoryView/KeyboardUtils/index.js +91 -0
  25. package/lib/components/Keyboard/{KeyboardInput/KeyboardAccessoryView.d.ts → KeyboardAccessoryView/index.d.ts} +11 -1
  26. package/lib/components/Keyboard/{KeyboardInput/KeyboardAccessoryView.js → KeyboardAccessoryView/index.js} +31 -5
  27. package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/keyboardAccessoryView.api.json +5 -5
  28. package/lib/components/Keyboard/{KeyboardTracking/KeyboardAwareInsetsView.d.ts → KeyboardAwareInsetsView/index.d.ts} +1 -1
  29. package/lib/components/Keyboard/{KeyboardTracking/KeyboardAwareInsetsView.js → KeyboardAwareInsetsView/index.js} +1 -1
  30. package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.ios.d.ts +1 -4
  31. package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.ios.js +5 -8
  32. package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.d.ts +2 -2
  33. package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/keyboardTrackingView.api.json +11 -20
  34. package/lib/components/Keyboard/index.d.ts +6 -6
  35. package/lib/components/Keyboard/index.js +6 -6
  36. package/lib/components/SafeArea/SafeAreaInsetsManager.d.ts +21 -7
  37. package/lib/components/SafeArea/SafeAreaInsetsManager.js +95 -31
  38. package/lib/components/SafeArea/SafeAreaSpacerView.d.ts +2 -2
  39. package/lib/components/SafeArea/SafeAreaSpacerView.js +63 -9
  40. package/lib/components/SafeArea/__tests__/SafeAreaInsetsManager.spec.js +274 -0
  41. package/lib/components/SafeArea/index.d.ts +10 -0
  42. package/lib/components/SafeArea/index.js +11 -0
  43. package/lib/components/index.d.ts +1 -1
  44. package/lib/components/index.js +1 -1
  45. package/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomInputControllerTemp.m +56 -8
  46. package/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomKeyboardViewControllerTemp.h +1 -7
  47. package/lib/ios/reactnativeuilib/keyboardinput/rctcustomInputcontroller/RCTCustomKeyboardViewControllerTemp.m +1 -1
  48. package/lib/ios/reactnativeuilib/keyboardtrackingview/KeyboardTrackingViewTempManager.m +134 -44
  49. package/lib/package.json +3 -3
  50. package/lib/react-native.config.js +1 -3
  51. package/metro.config.js +2 -2
  52. package/package.json +33 -32
  53. package/panView.d.ts +2 -0
  54. package/panView.js +1 -0
  55. package/scripts/release/prReleaseNotesCommon.js +15 -4
  56. package/src/commons/Constants.js +2 -5
  57. package/src/commons/modifiers.d.ts +1 -0
  58. package/src/commons/modifiers.js +5 -2
  59. package/src/components/KeyboardAwareScrollView/KeyboardAwareBase.js +5 -1
  60. package/src/components/actionSheet/index.d.ts +2 -12
  61. package/src/components/actionSheet/index.js +3 -42
  62. package/src/components/animatedImage/index.js +12 -2
  63. package/src/components/badge/index.d.ts +107 -47
  64. package/src/components/button/button.api.json +1 -1
  65. package/src/components/button/index.d.ts +53 -23
  66. package/src/components/button/types.d.ts +0 -1
  67. package/src/components/colorPicker/ColorPickerDialog.d.ts +1 -1
  68. package/src/components/colorPicker/ColorPickerDialog.js +1 -1
  69. package/src/components/dateTimePicker/index.d.ts +186 -5
  70. package/src/components/dateTimePicker/index.js +3 -4
  71. package/src/components/dialog/dialog.api.json +34 -35
  72. package/src/{incubator → components}/dialog/dialogHeader.api.json +2 -2
  73. package/src/components/dialog/index.d.ts +13 -105
  74. package/src/components/dialog/index.js +205 -212
  75. package/src/{incubator → components}/dialog/types.d.ts +7 -19
  76. package/src/{incubator → components}/dialog/types.js +1 -3
  77. package/src/{incubator → components}/dialog/useDialogContent.d.ts +1 -1
  78. package/src/components/drawer/Swipeable.js +1 -2
  79. package/src/components/drawer/index.js +31 -25
  80. package/src/components/fadedScrollView/index.js +7 -2
  81. package/src/components/featureHighlight/index.d.ts +1 -1
  82. package/src/components/hint/index.d.ts +0 -8
  83. package/src/components/hint/index.js +4 -6
  84. package/src/components/image/index.js +4 -0
  85. package/src/components/index.js +0 -19
  86. package/src/components/marquee/types.js +4 -1
  87. package/src/components/modal/index.d.ts +5 -0
  88. package/src/components/modal/index.js +14 -10
  89. package/src/components/modal/modal.api.json +5 -0
  90. package/src/{incubator → components}/panView/index.d.ts +3 -3
  91. package/src/{incubator → components}/panView/index.js +4 -4
  92. package/src/{incubator → components}/panView/usePanGesture.d.ts +1 -1
  93. package/src/components/picker/Picker.driver.new.d.ts +2 -2
  94. package/src/components/picker/Picker.driver.new.js +3 -3
  95. package/src/components/picker/PickerItem.js +6 -20
  96. package/src/components/picker/PickerPresenter.d.ts +0 -1
  97. package/src/components/picker/PickerPresenter.js +1 -23
  98. package/src/components/picker/api/picker.api.json +0 -1
  99. package/src/components/picker/api/pickerItem.api.json +0 -5
  100. package/src/components/picker/helpers/useFieldType.d.ts +53 -23
  101. package/src/components/picker/helpers/usePickerLabel.d.ts +1 -1
  102. package/src/components/picker/helpers/usePickerLabel.js +2 -3
  103. package/src/components/picker/helpers/usePickerMigrationWarnings.d.ts +1 -1
  104. package/src/components/picker/helpers/usePickerMigrationWarnings.js +0 -12
  105. package/src/components/picker/helpers/usePickerSearch.d.ts +1 -1
  106. package/src/components/picker/helpers/usePickerSearch.js +4 -8
  107. package/src/components/picker/helpers/usePickerSelection.d.ts +1 -1
  108. package/src/components/picker/helpers/usePickerSelection.js +2 -10
  109. package/src/components/picker/index.js +4 -22
  110. package/src/components/picker/types.d.ts +1 -24
  111. package/src/components/segmentedControl/index.js +3 -3
  112. package/src/components/slider/GradientSlider.d.ts +1 -1
  113. package/src/components/slider/index.js +1 -1
  114. package/src/components/sortableGridList/SortableItem.js +13 -4
  115. package/src/components/sortableList/SortableListItem.js +13 -4
  116. package/src/components/stackAggregator/index.js +16 -11
  117. package/src/components/tabController/TabPage.js +18 -14
  118. package/src/components/text/Text.driver.new.d.ts +2 -2
  119. package/src/components/text/Text.driver.new.js +2 -2
  120. package/src/components/text/index.js +2 -3
  121. package/src/components/textField/Input.js +0 -1
  122. package/src/components/textField/TextField.driver.new.d.ts +2 -2
  123. package/src/components/textField/TextField.driver.new.js +2 -2
  124. package/src/components/textField/presets/outline.d.ts +106 -46
  125. package/src/components/textField/presets/underline.d.ts +106 -46
  126. package/src/components/textField/types.js +1 -0
  127. package/src/components/textField/usePreset.d.ts +72 -44
  128. package/src/components/timeline/types.js +3 -0
  129. package/src/{incubator/hooks/useHiddenLocation.web.d.ts → hooks/useHiddenLocation/index.d.ts} +1 -1
  130. package/src/{incubator/hooks/useHiddenLocation.d.ts → hooks/useHiddenLocation/index.web.d.ts} +1 -1
  131. package/src/incubator/expandableOverlay/ExpandableOverlay.driver.js +1 -1
  132. package/src/incubator/expandableOverlay/index.d.ts +42 -3
  133. package/src/incubator/expandableOverlay/index.js +1 -4
  134. package/src/incubator/index.d.ts +0 -2
  135. package/src/incubator/index.js +0 -2
  136. package/src/incubator/slider/SliderPresenter.js +2 -1
  137. package/src/incubator/toast/index.js +1 -1
  138. package/src/index.d.ts +3 -10
  139. package/src/index.js +42 -162
  140. package/src/testkit/index.d.ts +1 -1
  141. package/src/testkit/index.js +1 -1
  142. package/src/testkit/new/Component.driver.d.ts +4 -1
  143. package/src/testkit/new/Component.driver.js +3 -3
  144. package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/ReactHacks.java +0 -30
  145. package/lib/android/src/main/java/com/wix/reactnativeuilib/highlighterview/ReflectionUtils.java +0 -34
  146. package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/DefaultKeyListener.java +0 -33
  147. package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/KeyListenerProxy.java +0 -53
  148. package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerModule.java +0 -54
  149. package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/TextInputDelKeyHandlerPackage.java +0 -28
  150. package/lib/android/src/main/java/com/wix/reactnativeuilib/textinput/ViewUtils.java +0 -36
  151. package/lib/components/HighlighterOverlayView.js +0 -40
  152. package/lib/components/Keyboard/KeyboardInput/CustomKeyboardView/CustomKeyboardView.android.js +0 -28
  153. package/lib/components/Keyboard/KeyboardInput/utils/KeyboardUtils.d.ts +0 -11
  154. package/lib/components/Keyboard/KeyboardInput/utils/KeyboardUtils.js +0 -17
  155. package/panningViews.d.ts +0 -2
  156. package/panningViews.js +0 -1
  157. package/react-native.config.js +0 -22
  158. package/sharedTransition.d.ts +0 -2
  159. package/sharedTransition.js +0 -1
  160. package/src/components/dialog/DialogDismissibleView.d.ts +0 -34
  161. package/src/components/dialog/DialogDismissibleView.js +0 -184
  162. package/src/components/dialog/OverlayFadingBackground.d.ts +0 -14
  163. package/src/components/dialog/OverlayFadingBackground.js +0 -45
  164. package/src/components/panningViews/asPanViewConsumer.d.ts +0 -3
  165. package/src/components/panningViews/asPanViewConsumer.js +0 -16
  166. package/src/components/panningViews/panDismissibleView.d.ts +0 -51
  167. package/src/components/panningViews/panDismissibleView.js +0 -350
  168. package/src/components/panningViews/panGestureView.d.ts +0 -23
  169. package/src/components/panningViews/panGestureView.js +0 -156
  170. package/src/components/panningViews/panListenerView.d.ts +0 -66
  171. package/src/components/panningViews/panListenerView.js +0 -155
  172. package/src/components/panningViews/panResponderView.d.ts +0 -19
  173. package/src/components/panningViews/panResponderView.js +0 -79
  174. package/src/components/panningViews/panningContext.d.ts +0 -3
  175. package/src/components/panningViews/panningContext.js +0 -4
  176. package/src/components/panningViews/panningProvider.d.ts +0 -73
  177. package/src/components/panningViews/panningProvider.js +0 -101
  178. package/src/components/sharedTransition/ShareTransitionContext.js +0 -3
  179. package/src/components/sharedTransition/SharedArea.js +0 -153
  180. package/src/components/sharedTransition/SourceElement.js +0 -44
  181. package/src/components/sharedTransition/TargetElement.js +0 -38
  182. package/src/components/sharedTransition/index.js +0 -9
  183. package/src/incubator/dialog/dialog.api.json +0 -54
  184. package/src/incubator/dialog/index.d.ts +0 -15
  185. package/src/incubator/dialog/index.js +0 -218
  186. /package/lib/components/{HighlighterOverlayView.web.js → HighlighterOverlayView/index.web.js} +0 -0
  187. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.d.ts +0 -0
  188. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.js +0 -0
  189. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.web.d.ts +0 -0
  190. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/CustomKeyboardView/index.web.js +0 -0
  191. /package/lib/components/Keyboard/{KeyboardInput/utils/EventEmitterManager.d.ts → KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager/index.d.ts} +0 -0
  192. /package/lib/components/Keyboard/{KeyboardInput/utils/EventEmitterManager.js → KeyboardAccessoryView/KeyboardRegistry/EventEmitterManager/index.js} +0 -0
  193. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.android.d.ts +0 -0
  194. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.android.js +0 -0
  195. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.ios.d.ts +0 -0
  196. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/TextInputKeyboardManager.ios.js +0 -0
  197. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/index.d.ts +0 -0
  198. /package/lib/components/Keyboard/{KeyboardInput → KeyboardAccessoryView}/TextInputKeyboardManager/index.js +0 -0
  199. /package/lib/components/Keyboard/{KeyboardTracking → KeyboardAwareInsetsView}/keyboardAwareInsetsView.api.json +0 -0
  200. /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.android.d.ts +0 -0
  201. /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/KeyboardTrackingView.android.js +0 -0
  202. /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.js +0 -0
  203. /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.web.d.ts +0 -0
  204. /package/lib/components/Keyboard/{KeyboardTracking/KeyboardTrackingView → KeyboardTrackingView}/index.web.js +0 -0
  205. /package/src/{incubator → components}/dialog/Dialog.driver.new.d.ts +0 -0
  206. /package/src/{incubator → components}/dialog/Dialog.driver.new.js +0 -0
  207. /package/src/{incubator → components}/dialog/DialogHeader.d.ts +0 -0
  208. /package/src/{incubator → components}/dialog/DialogHeader.js +0 -0
  209. /package/src/{incubator → components}/dialog/useDialogContent.js +0 -0
  210. /package/src/{incubator → components}/panView/panningUtil.d.ts +0 -0
  211. /package/src/{incubator → components}/panView/panningUtil.js +0 -0
  212. /package/src/{incubator → components}/panView/usePanGesture.js +0 -0
  213. /package/src/{incubator/hooks/useHiddenLocation.js → hooks/useHiddenLocation/index.js} +0 -0
  214. /package/src/{incubator/hooks/useHiddenLocation.web.js → hooks/useHiddenLocation/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 "../../../specs/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) {
@@ -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
  };
@@ -1,20 +1,34 @@
1
- type SafeAreaInsetsType = {
1
+ export type SafeAreaInsetsType = {
2
2
  top: number;
3
3
  left: number;
4
4
  bottom: number;
5
5
  right: number;
6
6
  } | null;
7
+ export type SafeAreaChangedDelegateType = {
8
+ onSafeAreaInsetsDidChangeEvent?: (insets: SafeAreaInsetsType) => void;
9
+ };
10
+ export declare const DEFAULT_INSETS: {
11
+ top: number;
12
+ left: number;
13
+ bottom: number;
14
+ right: number;
15
+ };
7
16
  declare class SafeAreaInsetsManager {
8
17
  _defaultInsets: SafeAreaInsetsType;
9
18
  _safeAreaInsets: SafeAreaInsetsType;
10
- _safeAreaChangedDelegates: Array<any>;
19
+ _safeAreaChangedDelegates: Array<SafeAreaChangedDelegateType>;
20
+ _nativeModule: any;
11
21
  constructor();
12
- addSafeAreaChangedListener(): void;
22
+ setupNativeConnection(): void;
23
+ setupEventListener(): void;
24
+ getInitialInsets(): Promise<void>;
25
+ notifyDelegates(insets: SafeAreaInsetsType): void;
13
26
  _updateInsets(): Promise<void>;
14
27
  getSafeAreaInsets(): Promise<SafeAreaInsetsType>;
15
- addSafeAreaChangedDelegate(delegate: any): void;
16
- removeSafeAreaChangedDelegate(delegateToRemove: any): void;
28
+ addSafeAreaChangedDelegate(delegate: SafeAreaChangedDelegateType): void;
29
+ removeSafeAreaChangedDelegate(delegateToRemove: SafeAreaChangedDelegateType): void;
17
30
  get defaultInsets(): SafeAreaInsetsType;
31
+ refreshSafeAreaInsets(): Promise<void>;
18
32
  }
19
- declare const _default: SafeAreaInsetsManager;
20
- export default _default;
33
+ declare const instance: SafeAreaInsetsManager;
34
+ export default instance;
@@ -1,48 +1,99 @@
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 } from 'react-native';
6
+ export const DEFAULT_INSETS = {
7
+ top: 47,
8
+ left: 0,
9
+ bottom: 34,
10
+ right: 0
11
+ };
6
12
  let SafeAreaInsetsCache = null;
7
- const NativeSafeAreaManager = NativeModules.SafeAreaManager;
8
13
  class SafeAreaInsetsManager {
9
- _defaultInsets = {
10
- top: 0,
11
- left: 0,
12
- bottom: 0,
13
- right: 0
14
- };
15
- _safeAreaInsets = {
16
- top: 0,
17
- left: 0,
18
- bottom: 0,
19
- right: 0
20
- };
14
+ _defaultInsets = DEFAULT_INSETS; // Common iPhone safe area values
15
+
21
16
  _safeAreaChangedDelegates = [];
17
+ _nativeModule = null;
22
18
  constructor() {
23
- this.addSafeAreaChangedListener();
19
+ // Initialize with default values
20
+ this._safeAreaInsets = this._defaultInsets;
21
+
22
+ // Try to connect to native module
23
+ this.setupNativeConnection();
24
24
  }
25
- addSafeAreaChangedListener() {
26
- if (!NativeSafeAreaManager) {
27
- return;
25
+ setupNativeConnection() {
26
+ try {
27
+ // Access the native module directly without causing getConstants
28
+ this._nativeModule = NativeModules.SafeAreaManager;
29
+ if (this._nativeModule) {
30
+ // Set up event listener using DeviceEventEmitter instead of NativeEventEmitter
31
+ // This avoids getConstants issues
32
+ this.setupEventListener();
33
+
34
+ // Get initial safe area insets
35
+ this.getInitialInsets();
36
+ } else {
37
+ console.log('SafeAreaInsetsManager: Native SafeAreaManager not available, using defaults');
38
+ }
39
+ } catch (error) {
40
+ console.warn('SafeAreaInsetsManager: Failed to connect to native module:', error);
28
41
  }
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
42
+ }
43
+ setupEventListener() {
44
+ try {
45
+ // Use DeviceEventEmitter instead of NativeEventEmitter to avoid getConstants
46
+ DeviceEventEmitter.addListener('SafeAreaInsetsDidChangeEvent', data => {
47
+ if (data) {
48
+ SafeAreaInsetsCache = data;
49
+ this._safeAreaInsets = data;
50
+ this.notifyDelegates(data);
38
51
  }
39
52
  });
53
+ } catch (error) {
54
+ console.warn('SafeAreaInsetsManager: Failed to setup event listener:', error);
55
+ }
56
+ }
57
+ async getInitialInsets() {
58
+ if (!this._nativeModule) {
59
+ return;
60
+ }
61
+ try {
62
+ const insets = await this._nativeModule.getSafeAreaInsets();
63
+ if (insets) {
64
+ SafeAreaInsetsCache = insets;
65
+ this._safeAreaInsets = insets;
66
+ // Don't notify delegates yet as components might not be ready
67
+ }
68
+ } catch (error) {
69
+ console.warn('SafeAreaInsetsManager: Failed to get initial insets:', error);
70
+ }
71
+ }
72
+ notifyDelegates(insets) {
73
+ _forEach(this._safeAreaChangedDelegates, delegate => {
74
+ if (delegate.onSafeAreaInsetsDidChangeEvent) {
75
+ delegate.onSafeAreaInsetsDidChangeEvent(insets);
76
+ }
40
77
  });
41
78
  }
42
79
  async _updateInsets() {
43
- if (NativeSafeAreaManager && SafeAreaInsetsCache === null) {
44
- SafeAreaInsetsCache = await NativeSafeAreaManager.getSafeAreaInsets();
80
+ if (this._nativeModule && SafeAreaInsetsCache === null) {
81
+ try {
82
+ const insets = await this._nativeModule.getSafeAreaInsets();
83
+ if (insets) {
84
+ SafeAreaInsetsCache = insets;
85
+ this._safeAreaInsets = SafeAreaInsetsCache;
86
+ } else {
87
+ this._safeAreaInsets = this._defaultInsets;
88
+ }
89
+ } catch (error) {
90
+ console.warn('SafeAreaInsetsManager: Failed to get native insets:', error);
91
+ this._safeAreaInsets = this._defaultInsets;
92
+ }
93
+ } else if (SafeAreaInsetsCache !== null) {
45
94
  this._safeAreaInsets = SafeAreaInsetsCache;
95
+ } else {
96
+ this._safeAreaInsets = this._defaultInsets;
46
97
  }
47
98
  }
48
99
  async getSafeAreaInsets() {
@@ -60,5 +111,18 @@ class SafeAreaInsetsManager {
60
111
  get defaultInsets() {
61
112
  return this._defaultInsets;
62
113
  }
114
+
115
+ // Method to manually refresh safe area insets and notify delegates
116
+ async refreshSafeAreaInsets() {
117
+ const previousInsets = this._safeAreaInsets;
118
+ SafeAreaInsetsCache = null; // Force refresh
119
+ await this._updateInsets();
120
+
121
+ // Notify delegates if insets changed
122
+ if (!_isEqual(previousInsets, this._safeAreaInsets)) {
123
+ this.notifyDelegates(this._safeAreaInsets);
124
+ }
125
+ }
63
126
  }
64
- export default new SafeAreaInsetsManager();
127
+ const instance = new SafeAreaInsetsManager();
128
+ export default instance;
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
- import { ViewStyle } from 'react-native';
2
+ import { ViewStyle, StyleProp } from 'react-native';
3
3
  export type SafeAreaSpacerViewProps = {
4
- style?: ViewStyle;
4
+ style?: StyleProp<ViewStyle>;
5
5
  };
6
6
  declare const SafeAreaSpacerView: {
7
7
  ({ style }: SafeAreaSpacerViewProps): React.JSX.Element;
@@ -1,14 +1,68 @@
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, useMemo } 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 [componentHeight, setComponentHeight] = useState(0);
14
+ const [spacerHeight, setSpacerHeight] = useState(0);
15
+ useEffect(() => {
16
+ const getSafeAreaInsets = async () => {
17
+ try {
18
+ const insets = await SafeAreaInsetsManager.getSafeAreaInsets();
19
+ if (insets) {
20
+ setSafeAreaInsets(insets);
21
+ }
22
+ } catch (error) {
23
+ console.warn('SafeAreaSpacerView: Failed to get initial safe area insets:', error);
24
+ }
25
+ };
26
+ getSafeAreaInsets();
27
+
28
+ // Add delegate to listen for safe area changes from native component
29
+ const delegate = {
30
+ onSafeAreaInsetsDidChangeEvent: insets => {
31
+ if (insets) {
32
+ setSafeAreaInsets(insets);
33
+ }
34
+ }
35
+ };
36
+ SafeAreaInsetsManager.addSafeAreaChangedDelegate(delegate);
37
+ return () => {
38
+ SafeAreaInsetsManager.removeSafeAreaChangedDelegate(delegate);
39
+ };
40
+ }, []);
41
+
42
+ // Position detection with useCallback
43
+ const handleLayout = useCallback(event => {
44
+ const {
45
+ y
46
+ } = event.nativeEvent.layout;
47
+ setComponentHeight(y);
48
+ }, []);
49
+ useEffect(() => {
50
+ const screenHeight = Dimensions.get('window').height;
51
+ let height = 0;
52
+ // Check if positioned within safe area bounds
53
+ if (componentHeight < safeAreaInsets.top) {
54
+ height = safeAreaInsets.top;
55
+ } else if (componentHeight > screenHeight - safeAreaInsets.bottom) {
56
+ height = safeAreaInsets.bottom;
57
+ }
58
+ if (height !== spacerHeight) {
59
+ setSpacerHeight(height);
60
+ }
61
+ }, [componentHeight, safeAreaInsets, spacerHeight]);
62
+ const spacerStyle = useMemo(() => [{
63
+ height: spacerHeight
64
+ }, style], [spacerHeight, style]);
65
+ return <View style={spacerStyle} onLayout={handleLayout} />;
12
66
  };
13
- SafeAreaSpacerView.displayName = 'IGNORE';
67
+ SafeAreaSpacerView.displayName = 'SafeAreaSpacerView';
14
68
  export default SafeAreaSpacerView;