Skip to content

Commit 5feda01

Browse files
authored
Revert "Typescript/keyboard (#1449)"
This reverts commit 8a36fa7.
1 parent 8a36fa7 commit 5feda01

33 files changed

+308
-376
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,4 @@ class MyScreen extends Component {
118118
}
119119
}
120120
```
121+

demo/src/screens/nativeComponentScreens/SafeAreaSpacerViewScreen.tsx renamed to demo/src/screens/nativeComponentScreens/SafeAreaSpacerViewScreen.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
import React, {PureComponent} from 'react';
22
import {ScrollView, StyleSheet} from 'react-native';
3-
import {Text, View, SafeAreaSpacerView} from 'react-native-ui-lib';
3+
import {Text, View, SafeAreaSpacerView} from 'react-native-ui-lib'; //eslint-disable-line
44

55
export default class SafeAreaSpacerViewScreen extends PureComponent {
6+
67
static options() {
78
return {
89
topBar: {
910
drawBehind: true,
10-
visible: false
11-
}
11+
visible: false,
12+
},
1213
};
1314
}
1415

@@ -18,7 +19,7 @@ export default class SafeAreaSpacerViewScreen extends PureComponent {
1819
<ScrollView contentContainerStyle={styles.scrollView}>
1920
<View paddingH-25 center>
2021
<Text text50 center>
21-
{'When there are absolute-positioned view at the bottom and top,' +
22+
{'When there are absolute-positioned view at the bottom and top,' +
2223
'it is sometimes hard or impossible to change the layout and avoid it.'}
2324
<Text red50> SafeAreaSpacerView </Text>
2425
{'can be used as a BOTTOM or TOP spacer and will get the height of the safe area insets'}
@@ -42,16 +43,16 @@ const styles = StyleSheet.create({
4243
scrollView: {
4344
flex: 1,
4445
alignItems: 'center',
45-
justifyContent: 'center'
46+
justifyContent: 'center',
4647
},
4748
topView: {
4849
position: 'absolute',
4950
top: 0,
50-
left: 0
51+
left: 0,
5152
},
5253
bottomView: {
5354
position: 'absolute',
5455
bottom: 0,
55-
left: 0
56-
}
56+
left: 0,
57+
},
5758
});

generatedTypes/index.d.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,6 @@ export {default as Wizard, WizardProps, WizardStepProps, WizardStepStates, Wizar
8585
export {default as ListItem, ListItemProps} from './components/listItem';
8686
export {default as StateScreen, StateScreenProps} from './components/stateScreen';
8787
export {default as LoaderScreen, LoaderScreenProps} from './components/loaderScreen';
88-
export {
89-
Keyboard,
90-
SafeAreaSpacerView,
91-
WheelPicker,
92-
WheelPickerProps,
93-
HighlighterOverlayView,
94-
SafeAreaInsetsManager
95-
} from '../lib/components';
9688

9789
/* All components with manual typings */
9890
export {
@@ -113,6 +105,8 @@ export {
113105
UIComponent,
114106
forwardRef,
115107
AvatarHelper,
108+
WheelPicker,
109+
WheelPickerProps,
116110
Picker,
117111
PickerItemValue,
118112
PickerProps
@@ -122,5 +116,11 @@ export {
122116
export const AnimatedImage;
123117
export const AnimatedScanner;
124118
export const DateTimePicker;
119+
export const HighlighterOverlayView;
120+
export const Keyboard;
121+
export const KeyboardAwareListView;
122+
export const KeyboardAwareScrollView;
123+
export const SafeAreaInsetsManager;
124+
export const SafeAreaSpacerView;
125125
export const SelectableComponent;
126126
export const TextField;

jest-setup.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,3 @@ jest.mock('react-native-reanimated', () => require('react-native-reanimated/mock
1010
global.__reanimatedWorkletInit = jest.fn();
1111
jest.mock('react-native-gesture-handler', () => {});
1212
jest.mock('@react-native-picker/picker', () => ({Picker: {Item: {}}}));
13-
jest.mock('react-native', () => {
14-
const reactNative = jest.requireActual('react-native');
15-
reactNative.NativeModules.KeyboardTrackingViewTempManager = {};
16-
return reactNative;
17-
});
Lines changed: 47 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,11 @@
11
import React from 'react';
2-
import {requireNativeComponent, processColor, Platform, StyleSheet, Modal, ViewStyle} from 'react-native';
2+
import PropTypes from 'prop-types';
3+
import {requireNativeComponent, processColor, Platform, StyleSheet, Modal} from 'react-native';
34

4-
const NativeHighlighterView = requireNativeComponent('HighlighterView');
5+
const NativeHighlighterView = requireNativeComponent('HighlighterView', null);
56
const DefaultOverlayColor = 'rgba(0, 0, 0, 0.5)';
67

7-
type HighlightFrameType = {
8-
x: number;
9-
y: number;
10-
width: number;
11-
height: number;
12-
}
13-
14-
type HighlightViewTagParams = {
15-
padding: number | ViewStyle['padding'];
16-
offset: Pick<HighlightFrameType, 'x' | 'y'>;
17-
}
18-
19-
export type HighlighterOverlayViewProps = {
20-
visible: boolean;
21-
overlayColor?: string;
22-
borderRadius?: number;
23-
strokeColor?: string;
24-
strokeWidth?: number;
25-
onRequestClose?: () => void;
26-
highlightFrame?: HighlightFrameType;
27-
style?: ViewStyle;
28-
highlightViewTag?: number | null;
29-
children?: JSX.Element[] | JSX.Element;
30-
highlightViewTagParams?: HighlightViewTagParams;
31-
minimumRectSize?: Pick<HighlightFrameType, 'width' | 'height'>;
32-
innerPadding?: number;
33-
accessible?: boolean;
34-
testID?: string;
35-
};
36-
37-
38-
const HighlighterOverlayView = (props: HighlighterOverlayViewProps) => {
8+
const HighlighterOverlayView = (props) => {
399
const {
4010
overlayColor,
4111
borderRadius,
@@ -49,15 +19,13 @@ const HighlighterOverlayView = (props: HighlighterOverlayViewProps) => {
4919
highlightViewTag,
5020
highlightViewTagParams,
5121
minimumRectSize,
52-
innerPadding
22+
innerPadding,
5323
} = props;
5424

5525
let overlayColorToUse = overlayColor || DefaultOverlayColor;
5626
let strokeColorToUse = strokeColor;
5727
if (Platform.OS === 'android') {
58-
// @ts-ignore
5928
overlayColorToUse = processColor(overlayColorToUse);
60-
// @ts-ignore
6129
strokeColorToUse = processColor(strokeColorToUse);
6230
}
6331

@@ -66,10 +34,9 @@ const HighlighterOverlayView = (props: HighlighterOverlayViewProps) => {
6634
visible={!!(visible)}
6735
animationType={'fade'}
6836
transparent
69-
onRequestClose={() => onRequestClose?.()}
37+
onRequestClose={() => onRequestClose && onRequestClose()}
7038
>
7139
<NativeHighlighterView
72-
// @ts-ignore, this became private, not sure if I should remove it
7340
highlightFrame={highlightFrame}
7441
style={[style, {...StyleSheet.absoluteFillObject, backgroundColor: 'transparent'}]}
7542
overlayColor={overlayColorToUse}
@@ -86,5 +53,46 @@ const HighlighterOverlayView = (props: HighlighterOverlayViewProps) => {
8653
);
8754
};
8855

56+
HighlighterOverlayView.propTypes = {
57+
overlayColor: PropTypes.string,
58+
borderRadius: PropTypes.number,
59+
strokeColor: PropTypes.string,
60+
strokeWidth: PropTypes.number,
61+
visible: PropTypes.bool.isRequired,
62+
onRequestClose: PropTypes.func,
63+
highlightFrame: PropTypes.shape({
64+
x: PropTypes.number,
65+
y: PropTypes.number,
66+
width: PropTypes.number,
67+
height: PropTypes.number,
68+
}),
69+
style: PropTypes.oneOfType([PropTypes.object, PropTypes.number, PropTypes.array]),
70+
highlightViewTag: PropTypes.number,
71+
children: PropTypes.oneOfType([
72+
PropTypes.arrayOf(PropTypes.node),
73+
PropTypes.node,
74+
]),
75+
highlightViewTagParams: PropTypes.shape({
76+
padding: PropTypes.oneOfType([
77+
PropTypes.number,
78+
PropTypes.shape({
79+
top: PropTypes.number,
80+
left: PropTypes.number,
81+
bottom: PropTypes.number,
82+
right: PropTypes.number}),
83+
]),
84+
offset: PropTypes.shape({
85+
x: PropTypes.number,
86+
y: PropTypes.number,
87+
}),
88+
}),
89+
minimumRectSize: PropTypes.shape({
90+
width: PropTypes.number,
91+
height: PropTypes.number,
92+
}),
93+
innerPadding: PropTypes.number,
94+
};
95+
8996
HighlighterOverlayView.displayName = 'IGNORE';
97+
9098
export default HighlighterOverlayView;
Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
import React from 'react';
2+
import PropTypes from 'prop-types';
23
import {requireNativeComponent} from 'react-native';
3-
import TextInputKeyboardManager from '../TextInputKeyboardManager/TextInputKeyboardManager.android';
4-
import KeyboardRegistry from '../KeyboardRegistry';
5-
import CustomKeyboardViewBase, {CustomKeyboardViewBaseProps} from '../CustomKeyboardViewBase';
4+
import TextInputKeyboardManager from './TextInputKeyboardManager';
5+
import KeyboardRegistry from './KeyboardRegistry';
6+
import CustomKeyboardViewBase from './CustomKeyboardViewBase';
67

78
const CustomKeyboardViewNativeAndroid = requireNativeComponent('CustomKeyboardViewNativeTemp');
89

9-
export default class CustomKeyboardView extends CustomKeyboardViewBase<CustomKeyboardViewBaseProps> {
10+
export default class CustomKeyboardView extends CustomKeyboardViewBase {
1011
static displayName = 'IGNORE';
12+
static propTypes = {
13+
initialProps: PropTypes.object,
14+
component: PropTypes.string,
15+
onItemSelected: PropTypes.func
16+
};
1117

1218
async componentDidUpdate(prevProps) {
1319
const {component} = this.props;
Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
1-
import TextInputKeyboardManager from './../TextInputKeyboardManager/TextInputKeyboardManager.ios';
2-
import KeyboardRegistry from './../KeyboardRegistry';
3-
import CustomKeyboardViewBase, {CustomKeyboardViewBaseProps} from './../CustomKeyboardViewBase';
1+
import PropTypes from 'prop-types';
2+
import TextInputKeyboardManager from './TextInputKeyboardManager';
3+
import KeyboardRegistry from './KeyboardRegistry';
4+
import CustomKeyboardViewBase from './CustomKeyboardViewBase';
45

5-
export type CustomKeyboardViewProps = CustomKeyboardViewBaseProps & {
6-
/**
7-
* The reference to the actual text input (or the keyboard may not reset when instructed to, etc.)
8-
*/
9-
inputRef?: any;
10-
useSafeArea?: boolean;
11-
};
12-
13-
export default class CustomKeyboardView extends CustomKeyboardViewBase<CustomKeyboardViewProps> {
6+
export default class CustomKeyboardView extends CustomKeyboardViewBase {
147
static displayName = 'IGNORE';
8+
static propTypes = {
9+
/**
10+
* The reference to the actual text input (or the keyboard may not reset when instructed to, etc.)
11+
*/
12+
inputRef: PropTypes.object,
13+
initialProps: PropTypes.object,
14+
component: PropTypes.string,
15+
onItemSelected: PropTypes.func,
16+
useSafeArea: PropTypes.bool
17+
};
1518

1619
static defaultProps = {
17-
initialProps: {},
1820
useSafeArea: true
1921
};
2022

21-
registeredRequestShowKeyboard: boolean;
22-
keyboardExpandedToggle: [any];
23-
2423
constructor(props) {
2524
super(props);
2625

lib/components/Keyboard/KeyboardInput/CustomKeyboardView/index.tsx

Lines changed: 0 additions & 16 deletions
This file was deleted.

lib/components/Keyboard/KeyboardInput/CustomKeyboardViewBase.tsx renamed to lib/components/Keyboard/KeyboardInput/CustomKeyboardViewBase.js

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,26 @@
1-
import React, {Component} from 'react';
1+
import {Component} from 'react';
2+
import PropTypes from 'prop-types';
23
import KeyboardRegistry from './KeyboardRegistry';
3-
import {EventSubscription} from 'react-native';
44

5-
export type CustomKeyboardViewBaseProps = {
6-
inputRef?: any;
7-
initialProps?: any;
8-
component?: string;
9-
onItemSelected?: () => void;
10-
onRequestShowKeyboard?: (keyboardId: string) => void;
11-
children?: React.ReactChild | React.ReactChild[];
12-
}
5+
export default class CustomKeyboardViewBase extends Component {
6+
static propTypes = {
7+
initialProps: PropTypes.object,
8+
component: PropTypes.string,
9+
onItemSelected: PropTypes.func
10+
};
1311

14-
export default class CustomKeyboardViewBase<T extends CustomKeyboardViewBaseProps> extends Component<T> {
15-
1612
static defaultProps = {
1713
initialProps: {}
1814
};
1915

20-
registeredRequestShowKeyboard = false;
21-
keyboardExpandedToggle: any;
22-
keyboardEventListeners: [EventSubscription];
23-
2416
constructor(props) {
2517
super(props);
2618

2719
const {component, onItemSelected} = props;
2820
if (component) {
2921
this.addOnItemSelectListener(onItemSelected, component);
22+
23+
this.registeredRequestShowKeyboard = false;
3024
}
3125

3226
this.keyboardExpandedToggle = {};
@@ -41,7 +35,7 @@ export default class CustomKeyboardViewBase<T extends CustomKeyboardViewBaseProp
4135
KeyboardRegistry.removeListeners('onRequestShowKeyboard');
4236

4337
if (this.keyboardEventListeners) {
44-
this.keyboardEventListeners.forEach((eventListener: EventSubscription) => eventListener.remove());
38+
this.keyboardEventListeners.forEach(eventListener => eventListener.remove());
4539
}
4640

4741
if (component) {

0 commit comments

Comments
 (0)