@office-iss/react-native-win32 0.66.4 → 0.67.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/.eslintignore +2 -0
- package/.flowconfig +1 -1
- package/CHANGELOG.json +228 -46
- package/CHANGELOG.md +102 -25
- package/Libraries/ActionSheetIOS/ActionSheetIOS.js +14 -1
- package/Libraries/ActionSheetIOS/NativeActionSheetManager.js +2 -0
- package/Libraries/Animated/AnimatedEvent.js +23 -4
- package/Libraries/Animated/NativeAnimatedHelper.js +2 -2
- package/Libraries/Animated/components/AnimatedImage.js +3 -3
- package/Libraries/Animated/components/AnimatedScrollView.js +3 -3
- package/Libraries/Animated/components/AnimatedText.js +3 -3
- package/Libraries/Animated/components/AnimatedView.js +1 -3
- package/Libraries/Animated/createAnimatedComponent.js +3 -34
- package/Libraries/Components/Button/ButtonWin32.js +2 -2
- package/Libraries/Components/Button/ButtonWin32.js.map +1 -1
- package/Libraries/Components/Button.js +3 -0
- package/Libraries/Components/DatePicker/DatePickerIOS.ios.js +3 -6
- package/Libraries/Components/DrawerAndroid/DrawerLayoutAndroid.android.js +4 -7
- package/Libraries/Components/EnterString.win32.js +3 -3
- package/Libraries/Components/EnterString.win32.js.map +1 -1
- package/Libraries/Components/Keyboard/Keyboard.js +2 -2
- package/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +1 -0
- package/Libraries/Components/ScrollView/ScrollView.js +17 -16
- package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +268 -252
- package/Libraries/Components/Text/Tests/TextWin32Test.d.ts +0 -1
- package/Libraries/Components/Text/TextWin32.Props.d.ts +2 -2
- package/Libraries/Components/Text/TextWin32.Props.js.map +1 -1
- package/Libraries/Components/Text/TextWin32.js +1 -1
- package/Libraries/Components/Text/TextWin32.js.map +1 -1
- package/Libraries/Components/TextInput/Tests/TextInputTest.d.ts +0 -1
- package/Libraries/Components/TextInput/TextInput.win32.js +6 -6
- package/Libraries/Components/TextInput/TextInput.win32.js.map +1 -1
- package/Libraries/Components/Touchable/Tests/TouchableWin32Test.d.ts +0 -1
- package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js +1 -1
- package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js.map +1 -1
- package/Libraries/Components/Touchable/TouchableNativeFeedback.win32.js +2 -2
- package/Libraries/Components/Touchable/TouchableNativeFeedback.win32.js.map +1 -1
- package/Libraries/Components/Touchable/TouchableWin32.js +2 -2
- package/Libraries/Components/Touchable/TouchableWin32.js.map +1 -1
- package/Libraries/Components/View/Tests/ViewWin32Test.d.ts +0 -1
- package/Libraries/Components/View/View.js +1 -1
- package/Libraries/Components/View/View.win32.js +1 -1
- package/Libraries/Components/View/ViewAccessibility.js +1 -1
- package/Libraries/Components/View/ViewWin32.Props.d.ts +3 -6
- package/Libraries/Components/View/ViewWin32.Props.js.map +1 -1
- package/Libraries/Components/View/ViewWin32.js +5 -5
- package/Libraries/Components/View/ViewWin32.js.map +1 -1
- package/Libraries/Core/ExceptionsManager.js +45 -80
- package/Libraries/Core/ExtendedError.js +0 -1
- package/Libraries/Core/ReactNativeVersion.js +3 -3
- package/Libraries/Core/setUpBatchedBridge.js +1 -1
- package/Libraries/Core/setUpGlobals.js +2 -4
- package/Libraries/Core/setUpTimers.js +2 -2
- package/Libraries/Image/Image.ios.js +6 -0
- package/Libraries/Image/Image.win32.js +6 -0
- package/Libraries/Image/ImageBackground.js +10 -8
- package/Libraries/Image/ImageProps.js +28 -0
- package/Libraries/Image/Tests/ImageWin32Test.d.ts +0 -1
- package/Libraries/LogBox/Data/LogBoxData.js +18 -19
- package/Libraries/LogBox/UI/LogBoxImages/alert-triangle.png +0 -0
- package/Libraries/LogBox/UI/LogBoxImages/chevron-left.png +0 -0
- package/Libraries/LogBox/UI/LogBoxImages/chevron-right.png +0 -0
- package/Libraries/LogBox/UI/LogBoxImages/close.png +0 -0
- package/Libraries/LogBox/UI/LogBoxImages/loader.png +0 -0
- package/Libraries/NewAppScreen/components/logo.png +0 -0
- package/Libraries/PermissionsAndroid/NativePermissionsAndroid.js +2 -1
- package/Libraries/PermissionsAndroid/PermissionsAndroid.js +2 -0
- package/Libraries/PersonaCoin/PersonaCoin.js +3 -2
- package/Libraries/PersonaCoin/PersonaCoin.js.map +1 -1
- package/Libraries/Pressability/Pressability.js +13 -13
- package/Libraries/Pressability/Pressability.win32.js +13 -13
- package/Libraries/Pressability/PressabilityPerformanceEventEmitter.js +1 -1
- package/Libraries/ReactNative/AppRegistry.js +4 -2
- package/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +1569 -875
- package/Libraries/Renderer/implementations/ReactFabric-prod.fb.js +529 -319
- package/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js +570 -362
- package/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +1592 -891
- package/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js +521 -311
- package/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js +562 -354
- package/Libraries/Share/Share.js +1 -1
- package/Libraries/StyleSheet/normalizeColor.js +2 -2
- package/Libraries/Text/TextProps.js +1 -7
- package/Libraries/TurboModule/TurboModuleRegistry.js +1 -1
- package/Libraries/Utilities/HMRClient.js +1 -1
- package/flow/global.js +45 -0
- package/index.js +15 -10
- package/index.win32.js +15 -10
- package/jest/mockModal.js +31 -0
- package/jest/preprocessor.js +7 -75
- package/jest/setup.js +5 -3
- package/overrides.json +8 -14
- package/package.json +19 -17
- package/rntypes/BatchedBridge.d.ts +23 -0
- package/rntypes/Devtools.d.ts +20 -0
- package/rntypes/LaunchScreen.d.ts +9 -0
- package/rntypes/globals.d.ts +496 -0
- package/rntypes/index.d.ts +9966 -0
- package/rntypes/legacy-properties.d.ts +266 -0
- package/src/Libraries/Components/Text/TextWin32.Props.ts +2 -2
- package/src/Libraries/Components/View/ViewWin32.Props.ts +6 -12
- package/src/rntypes/BatchedBridge.d.ts +23 -0
- package/src/rntypes/Devtools.d.ts +20 -0
- package/src/rntypes/LaunchScreen.d.ts +9 -0
- package/src/rntypes/globals.d.ts +496 -0
- package/src/rntypes/index.d.ts +9966 -0
- package/src/rntypes/legacy-properties.d.ts +266 -0
- package/src/typings-index.ts +11 -4
- package/typings-index.d.ts +3 -1
- package/typings-index.js +7 -5
- package/typings-index.js.map +1 -1
- package/Libraries/Components/DatePickerAndroid/DatePickerAndroid.android.js +0 -87
- package/Libraries/Components/DatePickerAndroid/DatePickerAndroid.ios.js +0 -30
- package/Libraries/Components/DatePickerAndroid/DatePickerAndroid.win32.js +0 -30
- package/Libraries/Components/DatePickerAndroid/DatePickerAndroidTypes.js +0 -30
- package/Libraries/Components/StaticContainer.react.js +0 -51
- package/Libraries/Components/Touchable/ensurePositiveDelayProps.js +0 -25
- package/Libraries/Interaction/InteractionMixin.js +0 -54
- package/Libraries/ReactNative/queryLayoutByID.js +0 -58
|
@@ -4,25 +4,29 @@
|
|
|
4
4
|
* This source code is licensed under the MIT license found in the
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*
|
|
7
|
-
* @flow
|
|
7
|
+
* @flow
|
|
8
8
|
* @format
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
|
|
11
|
+
import AnimatedImplementation from '../../Animated/AnimatedImplementation';
|
|
12
|
+
import AnimatedAddition from '../../Animated/nodes/AnimatedAddition';
|
|
13
|
+
import AnimatedDiffClamp from '../../Animated/nodes/AnimatedDiffClamp';
|
|
14
|
+
import AnimatedNode from '../../Animated/nodes/AnimatedNode';
|
|
15
|
+
|
|
16
16
|
import * as React from 'react';
|
|
17
|
-
import
|
|
17
|
+
import StyleSheet from '../../StyleSheet/StyleSheet';
|
|
18
|
+
import View from '../View/View';
|
|
19
|
+
import Platform from '../../Utilities/Platform';
|
|
20
|
+
|
|
21
|
+
import type {LayoutEvent} from '../../Types/CoreEventTypes';
|
|
18
22
|
|
|
19
|
-
const AnimatedView =
|
|
23
|
+
const AnimatedView = AnimatedImplementation.createAnimatedComponent(View);
|
|
20
24
|
|
|
21
25
|
export type Props = $ReadOnly<{
|
|
22
|
-
children?: React.Element
|
|
26
|
+
children?: React.Element<any>,
|
|
23
27
|
nextHeaderLayoutY: ?number,
|
|
24
28
|
onLayout: (event: LayoutEvent) => void,
|
|
25
|
-
scrollAnimatedValue:
|
|
29
|
+
scrollAnimatedValue: AnimatedImplementation.Value,
|
|
26
30
|
// Will cause sticky headers to stick at the bottom of the ScrollView instead
|
|
27
31
|
// of the top.
|
|
28
32
|
inverted: ?boolean,
|
|
@@ -32,275 +36,287 @@ export type Props = $ReadOnly<{
|
|
|
32
36
|
hiddenOnScroll?: ?boolean,
|
|
33
37
|
}>;
|
|
34
38
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
inverted,
|
|
44
|
-
scrollViewHeight,
|
|
45
|
-
hiddenOnScroll,
|
|
46
|
-
scrollAnimatedValue,
|
|
47
|
-
nextHeaderLayoutY: _nextHeaderLayoutY,
|
|
48
|
-
} = props;
|
|
39
|
+
type State = {
|
|
40
|
+
measured: boolean,
|
|
41
|
+
layoutY: number,
|
|
42
|
+
layoutHeight: number,
|
|
43
|
+
nextHeaderLayoutY: ?number,
|
|
44
|
+
translateY: ?number,
|
|
45
|
+
...
|
|
46
|
+
};
|
|
49
47
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
48
|
+
class ScrollViewStickyHeader extends React.Component<Props, State> {
|
|
49
|
+
state: State = {
|
|
50
|
+
measured: false,
|
|
51
|
+
layoutY: 0,
|
|
52
|
+
layoutHeight: 0,
|
|
53
|
+
nextHeaderLayoutY: this.props.nextHeaderLayoutY,
|
|
54
|
+
translateY: null,
|
|
55
|
+
};
|
|
58
56
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
componentRef.current = ref;
|
|
64
|
-
if (ref) {
|
|
65
|
-
ref.setNextHeaderY = value => {
|
|
66
|
-
setNextHeaderLayoutY(value);
|
|
67
|
-
};
|
|
68
|
-
setIsFabric(
|
|
69
|
-
!!(
|
|
70
|
-
// An internal transform mangles variables with leading "_" as private.
|
|
71
|
-
// eslint-disable-next-line dot-notation
|
|
72
|
-
ref['_internalInstanceHandle']?.stateNode?.canonical
|
|
73
|
-
),
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
});
|
|
57
|
+
_translateY: ?AnimatedNode = null;
|
|
58
|
+
_shouldRecreateTranslateY: boolean = true;
|
|
59
|
+
_haveReceivedInitialZeroTranslateY: boolean = true;
|
|
60
|
+
_ref: any; // TODO T53738161: flow type this, and the whole file
|
|
78
61
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
.interpolate({
|
|
85
|
-
extrapolateLeft: 'clamp',
|
|
86
|
-
inputRange: [layoutY, layoutY + 1],
|
|
87
|
-
outputRange: ([0, 1]: Array<number>),
|
|
88
|
-
})
|
|
89
|
-
.interpolate({
|
|
90
|
-
inputRange: [0, 1],
|
|
91
|
-
outputRange: ([0, -1]: Array<number>),
|
|
92
|
-
}),
|
|
93
|
-
-layoutHeight,
|
|
94
|
-
0,
|
|
95
|
-
)
|
|
96
|
-
: null,
|
|
97
|
-
[scrollAnimatedValue, layoutHeight, layoutY, hiddenOnScroll],
|
|
98
|
-
);
|
|
62
|
+
// Fabric-only:
|
|
63
|
+
_timer: ?TimeoutID;
|
|
64
|
+
_animatedValueListenerId: string;
|
|
65
|
+
_animatedValueListener: (valueObject: $ReadOnly<{|value: number|}>) => void;
|
|
66
|
+
_debounceTimeout: number = Platform.OS === 'android' ? 15 : 64;
|
|
99
67
|
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const inputRange: Array<number> = [-1, 0];
|
|
105
|
-
const outputRange: Array<number> = [0, 0];
|
|
106
|
-
const initialTranslateY: Animated.Interpolation = scrollAnimatedValue.interpolate(
|
|
107
|
-
{
|
|
108
|
-
inputRange,
|
|
109
|
-
outputRange,
|
|
110
|
-
},
|
|
111
|
-
);
|
|
68
|
+
setNextHeaderY: (y: number) => void = (y: number): void => {
|
|
69
|
+
this._shouldRecreateTranslateY = true;
|
|
70
|
+
this.setState({nextHeaderLayoutY: y});
|
|
71
|
+
};
|
|
112
72
|
|
|
113
|
-
|
|
114
|
-
|
|
73
|
+
componentWillUnmount() {
|
|
74
|
+
if (this._translateY != null && this._animatedValueListenerId != null) {
|
|
75
|
+
this._translateY.removeListener(this._animatedValueListenerId);
|
|
76
|
+
}
|
|
77
|
+
if (this._timer) {
|
|
78
|
+
clearTimeout(this._timer);
|
|
115
79
|
}
|
|
116
|
-
|
|
117
|
-
});
|
|
80
|
+
}
|
|
118
81
|
|
|
119
|
-
|
|
120
|
-
|
|
82
|
+
UNSAFE_componentWillReceiveProps(nextProps: Props) {
|
|
83
|
+
if (
|
|
84
|
+
nextProps.scrollViewHeight !== this.props.scrollViewHeight ||
|
|
85
|
+
nextProps.scrollAnimatedValue !== this.props.scrollAnimatedValue ||
|
|
86
|
+
nextProps.inverted !== this.props.inverted
|
|
87
|
+
) {
|
|
88
|
+
this._shouldRecreateTranslateY = true;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
121
91
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
92
|
+
updateTranslateListener(
|
|
93
|
+
translateY: AnimatedImplementation.Interpolation,
|
|
94
|
+
isFabric: boolean,
|
|
95
|
+
offset: AnimatedDiffClamp | null,
|
|
96
|
+
) {
|
|
97
|
+
if (this._translateY != null && this._animatedValueListenerId != null) {
|
|
98
|
+
this._translateY.removeListener(this._animatedValueListenerId);
|
|
125
99
|
}
|
|
126
|
-
|
|
100
|
+
offset
|
|
101
|
+
? (this._translateY = new AnimatedAddition(translateY, offset))
|
|
102
|
+
: (this._translateY = translateY);
|
|
127
103
|
|
|
128
|
-
|
|
129
|
-
// updates, which is several times per frame during scrolling.
|
|
130
|
-
// To ensure that the Fabric ShadowTree has the most recent
|
|
131
|
-
// translate style of this node, we debounce the value and then
|
|
132
|
-
// pass it through to the underlying node during render.
|
|
133
|
-
// This is:
|
|
134
|
-
// 1. Only an issue in Fabric.
|
|
135
|
-
// 2. Worse in Android than iOS. In Android, but not iOS, you
|
|
136
|
-
// can touch and move your finger slightly and still trigger
|
|
137
|
-
// a "tap" event. In iOS, moving will cancel the tap in
|
|
138
|
-
// both Fabric and non-Fabric. On Android when you move
|
|
139
|
-
// your finger, the hit-detection moves from the Android
|
|
140
|
-
// platform to JS, so we need the ShadowTree to have knowledge
|
|
141
|
-
// of the current position.
|
|
142
|
-
const animatedValueListener = useCallback(
|
|
143
|
-
({value}) => {
|
|
144
|
-
const _debounceTimeout: number = Platform.OS === 'android' ? 15 : 64;
|
|
145
|
-
// When the AnimatedInterpolation is recreated, it always initializes
|
|
146
|
-
// to a value of zero and emits a value change of 0 to its listeners.
|
|
147
|
-
if (value === 0 && !_haveReceivedInitialZeroTranslateY.current) {
|
|
148
|
-
_haveReceivedInitialZeroTranslateY.current = true;
|
|
149
|
-
return;
|
|
150
|
-
}
|
|
151
|
-
if (_timer.current != null) {
|
|
152
|
-
clearTimeout(_timer.current);
|
|
153
|
-
}
|
|
154
|
-
_timer.current = setTimeout(() => {
|
|
155
|
-
if (value !== translateY) {
|
|
156
|
-
setTranslateY(value);
|
|
157
|
-
}
|
|
158
|
-
}, _debounceTimeout);
|
|
159
|
-
},
|
|
160
|
-
[translateY],
|
|
161
|
-
);
|
|
104
|
+
this._shouldRecreateTranslateY = false;
|
|
162
105
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
106
|
+
if (!isFabric) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
166
109
|
|
|
167
|
-
if (
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
inputRange.push(stickStartPoint + 1);
|
|
189
|
-
outputRange.push(1);
|
|
190
|
-
// If the next sticky header has not loaded yet (probably windowing) or is the last
|
|
191
|
-
// we can just keep it sticked forever.
|
|
192
|
-
const collisionPoint =
|
|
193
|
-
(nextHeaderLayoutY || 0) - layoutHeight - scrollViewHeight;
|
|
194
|
-
if (collisionPoint > stickStartPoint) {
|
|
195
|
-
inputRange.push(collisionPoint, collisionPoint + 1);
|
|
196
|
-
outputRange.push(
|
|
197
|
-
collisionPoint - stickStartPoint,
|
|
198
|
-
collisionPoint - stickStartPoint,
|
|
199
|
-
);
|
|
200
|
-
}
|
|
201
|
-
}
|
|
110
|
+
if (!this._animatedValueListener) {
|
|
111
|
+
// This is called whenever the (Interpolated) Animated Value
|
|
112
|
+
// updates, which is several times per frame during scrolling.
|
|
113
|
+
// To ensure that the Fabric ShadowTree has the most recent
|
|
114
|
+
// translate style of this node, we debounce the value and then
|
|
115
|
+
// pass it through to the underlying node during render.
|
|
116
|
+
// This is:
|
|
117
|
+
// 1. Only an issue in Fabric.
|
|
118
|
+
// 2. Worse in Android than iOS. In Android, but not iOS, you
|
|
119
|
+
// can touch and move your finger slightly and still trigger
|
|
120
|
+
// a "tap" event. In iOS, moving will cancel the tap in
|
|
121
|
+
// both Fabric and non-Fabric. On Android when you move
|
|
122
|
+
// your finger, the hit-detection moves from the Android
|
|
123
|
+
// platform to JS, so we need the ShadowTree to have knowledge
|
|
124
|
+
// of the current position.
|
|
125
|
+
this._animatedValueListener = ({value}) => {
|
|
126
|
+
// When the AnimatedInterpolation is recreated, it always initializes
|
|
127
|
+
// to a value of zero and emits a value change of 0 to its listeners.
|
|
128
|
+
if (value === 0 && !this._haveReceivedInitialZeroTranslateY) {
|
|
129
|
+
this._haveReceivedInitialZeroTranslateY = true;
|
|
130
|
+
return;
|
|
202
131
|
}
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
// - Negative scroll: no translation
|
|
206
|
-
// - From 0 to the y of the header: no translation. This will cause the header
|
|
207
|
-
// to scroll normally until it reaches the top of the scroll view.
|
|
208
|
-
// - From header y to when the next header y hits the bottom edge of the header: translate
|
|
209
|
-
// equally to scroll. This will cause the header to stay at the top of the scroll view.
|
|
210
|
-
// - Past the collision with the next header y: no more translation. This will cause the
|
|
211
|
-
// header to continue scrolling up and make room for the next sticky header.
|
|
212
|
-
// In the case that there is no next header just translate equally to
|
|
213
|
-
// scroll indefinitely.
|
|
214
|
-
inputRange.push(layoutY);
|
|
215
|
-
outputRange.push(0);
|
|
216
|
-
// If the next sticky header has not loaded yet (probably windowing) or is the last
|
|
217
|
-
// we can just keep it sticked forever.
|
|
218
|
-
const collisionPoint = (nextHeaderLayoutY || 0) - layoutHeight;
|
|
219
|
-
if (collisionPoint >= layoutY) {
|
|
220
|
-
inputRange.push(collisionPoint, collisionPoint + 1);
|
|
221
|
-
outputRange.push(collisionPoint - layoutY, collisionPoint - layoutY);
|
|
222
|
-
} else {
|
|
223
|
-
inputRange.push(layoutY + 1);
|
|
224
|
-
outputRange.push(1);
|
|
132
|
+
if (this._timer) {
|
|
133
|
+
clearTimeout(this._timer);
|
|
225
134
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
if (offset != null) {
|
|
235
|
-
newAnimatedTranslateY = Animated.add(newAnimatedTranslateY, offset);
|
|
135
|
+
this._timer = setTimeout(() => {
|
|
136
|
+
if (value !== this.state.translateY) {
|
|
137
|
+
this.setState({
|
|
138
|
+
translateY: value,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}, this._debounceTimeout);
|
|
142
|
+
};
|
|
236
143
|
}
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
let animatedListenerId;
|
|
240
|
-
if (isFabric) {
|
|
241
|
-
animatedListenerId = newAnimatedTranslateY.addListener(
|
|
242
|
-
animatedValueListener,
|
|
243
|
-
);
|
|
144
|
+
if (this.state.translateY !== 0 && this.state.translateY != null) {
|
|
145
|
+
this._haveReceivedInitialZeroTranslateY = false;
|
|
244
146
|
}
|
|
147
|
+
this._animatedValueListenerId = translateY.addListener(
|
|
148
|
+
this._animatedValueListener,
|
|
149
|
+
);
|
|
150
|
+
}
|
|
245
151
|
|
|
246
|
-
|
|
152
|
+
_onLayout = event => {
|
|
153
|
+
const layoutY = event.nativeEvent.layout.y;
|
|
154
|
+
const layoutHeight = event.nativeEvent.layout.height;
|
|
155
|
+
const measured = true;
|
|
247
156
|
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
}
|
|
256
|
-
};
|
|
257
|
-
}, [nextHeaderLayoutY, measured, layoutHeight, layoutY, scrollViewHeight, scrollAnimatedValue, inverted, offset, animatedValueListener, isFabric]);
|
|
157
|
+
if (
|
|
158
|
+
layoutY !== this.state.layoutY ||
|
|
159
|
+
layoutHeight !== this.state.layoutHeight ||
|
|
160
|
+
measured !== this.state.measured
|
|
161
|
+
) {
|
|
162
|
+
this._shouldRecreateTranslateY = true;
|
|
163
|
+
}
|
|
258
164
|
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
165
|
+
this.setState({
|
|
166
|
+
measured,
|
|
167
|
+
layoutY,
|
|
168
|
+
layoutHeight,
|
|
169
|
+
});
|
|
263
170
|
|
|
264
|
-
props.onLayout(event);
|
|
265
|
-
const child = React.Children.only(props.children);
|
|
171
|
+
this.props.onLayout(event);
|
|
172
|
+
const child = React.Children.only(this.props.children);
|
|
266
173
|
if (child.props.onLayout) {
|
|
267
174
|
child.props.onLayout(event);
|
|
268
175
|
}
|
|
269
176
|
};
|
|
270
177
|
|
|
271
|
-
|
|
178
|
+
_setComponentRef = ref => {
|
|
179
|
+
this._ref = ref;
|
|
180
|
+
};
|
|
181
|
+
|
|
182
|
+
render(): React.Node {
|
|
183
|
+
// Fabric Detection
|
|
184
|
+
const isFabric = !!(
|
|
185
|
+
// An internal transform mangles variables with leading "_" as private.
|
|
186
|
+
// eslint-disable-next-line dot-notation
|
|
187
|
+
(this._ref && this._ref['_internalInstanceHandle']?.stateNode?.canonical)
|
|
188
|
+
);
|
|
189
|
+
// Initially and in the case of updated props or layout, we
|
|
190
|
+
// recreate this interpolated value. Otherwise, we do not recreate
|
|
191
|
+
// when there are state changes.
|
|
192
|
+
if (this._shouldRecreateTranslateY) {
|
|
193
|
+
const {inverted, scrollViewHeight} = this.props;
|
|
194
|
+
const {measured, layoutHeight, layoutY, nextHeaderLayoutY} = this.state;
|
|
195
|
+
const inputRange: Array<number> = [-1, 0];
|
|
196
|
+
const outputRange: Array<number> = [0, 0];
|
|
272
197
|
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
198
|
+
if (measured) {
|
|
199
|
+
if (inverted) {
|
|
200
|
+
// The interpolation looks like:
|
|
201
|
+
// - Negative scroll: no translation
|
|
202
|
+
// - `stickStartPoint` is the point at which the header will start sticking.
|
|
203
|
+
// It is calculated using the ScrollView viewport height so it is a the bottom.
|
|
204
|
+
// - Headers that are in the initial viewport will never stick, `stickStartPoint`
|
|
205
|
+
// will be negative.
|
|
206
|
+
// - From 0 to `stickStartPoint` no translation. This will cause the header
|
|
207
|
+
// to scroll normally until it reaches the top of the scroll view.
|
|
208
|
+
// - From `stickStartPoint` to when the next header y hits the bottom edge of the header: translate
|
|
209
|
+
// equally to scroll. This will cause the header to stay at the top of the scroll view.
|
|
210
|
+
// - Past the collision with the next header y: no more translation. This will cause the
|
|
211
|
+
// header to continue scrolling up and make room for the next sticky header.
|
|
212
|
+
// In the case that there is no next header just translate equally to
|
|
213
|
+
// scroll indefinitely.
|
|
214
|
+
if (scrollViewHeight != null) {
|
|
215
|
+
const stickStartPoint = layoutY + layoutHeight - scrollViewHeight;
|
|
216
|
+
if (stickStartPoint > 0) {
|
|
217
|
+
inputRange.push(stickStartPoint);
|
|
218
|
+
outputRange.push(0);
|
|
219
|
+
inputRange.push(stickStartPoint + 1);
|
|
220
|
+
outputRange.push(1);
|
|
221
|
+
// If the next sticky header has not loaded yet (probably windowing) or is the last
|
|
222
|
+
// we can just keep it sticked forever.
|
|
223
|
+
const collisionPoint =
|
|
224
|
+
(nextHeaderLayoutY || 0) - layoutHeight - scrollViewHeight;
|
|
225
|
+
if (collisionPoint > stickStartPoint) {
|
|
226
|
+
inputRange.push(collisionPoint, collisionPoint + 1);
|
|
227
|
+
outputRange.push(
|
|
228
|
+
collisionPoint - stickStartPoint,
|
|
229
|
+
collisionPoint - stickStartPoint,
|
|
230
|
+
);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
} else {
|
|
235
|
+
// The interpolation looks like:
|
|
236
|
+
// - Negative scroll: no translation
|
|
237
|
+
// - From 0 to the y of the header: no translation. This will cause the header
|
|
238
|
+
// to scroll normally until it reaches the top of the scroll view.
|
|
239
|
+
// - From header y to when the next header y hits the bottom edge of the header: translate
|
|
240
|
+
// equally to scroll. This will cause the header to stay at the top of the scroll view.
|
|
241
|
+
// - Past the collision with the next header y: no more translation. This will cause the
|
|
242
|
+
// header to continue scrolling up and make room for the next sticky header.
|
|
243
|
+
// In the case that there is no next header just translate equally to
|
|
244
|
+
// scroll indefinitely.
|
|
245
|
+
inputRange.push(layoutY);
|
|
246
|
+
outputRange.push(0);
|
|
247
|
+
// If the next sticky header has not loaded yet (probably windowing) or is the last
|
|
248
|
+
// we can just keep it sticked forever.
|
|
249
|
+
const collisionPoint = (nextHeaderLayoutY || 0) - layoutHeight;
|
|
250
|
+
if (collisionPoint >= layoutY) {
|
|
251
|
+
inputRange.push(collisionPoint, collisionPoint + 1);
|
|
252
|
+
outputRange.push(
|
|
253
|
+
collisionPoint - layoutY,
|
|
254
|
+
collisionPoint - layoutY,
|
|
255
|
+
);
|
|
256
|
+
} else {
|
|
257
|
+
inputRange.push(layoutY + 1);
|
|
258
|
+
outputRange.push(1);
|
|
259
|
+
}
|
|
278
260
|
}
|
|
279
|
-
|
|
261
|
+
}
|
|
280
262
|
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
263
|
+
this.updateTranslateListener(
|
|
264
|
+
this.props.scrollAnimatedValue.interpolate({
|
|
265
|
+
inputRange,
|
|
266
|
+
outputRange,
|
|
267
|
+
}),
|
|
268
|
+
isFabric,
|
|
269
|
+
this.props.hiddenOnScroll
|
|
270
|
+
? new AnimatedDiffClamp(
|
|
271
|
+
this.props.scrollAnimatedValue
|
|
272
|
+
.interpolate({
|
|
273
|
+
extrapolateLeft: 'clamp',
|
|
274
|
+
inputRange: [layoutY, layoutY + 1],
|
|
275
|
+
outputRange: ([0, 1]: Array<number>),
|
|
276
|
+
})
|
|
277
|
+
.interpolate({
|
|
278
|
+
inputRange: [0, 1],
|
|
279
|
+
outputRange: ([0, -1]: Array<number>),
|
|
280
|
+
}),
|
|
281
|
+
-this.state.layoutHeight,
|
|
282
|
+
0,
|
|
283
|
+
)
|
|
284
|
+
: null,
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const child = React.Children.only(this.props.children);
|
|
289
|
+
|
|
290
|
+
// TODO T68319535: remove this if NativeAnimated is rewritten for Fabric
|
|
291
|
+
const passthroughAnimatedPropExplicitValues =
|
|
292
|
+
isFabric && this.state.translateY != null
|
|
293
|
+
? {
|
|
294
|
+
style: {transform: [{translateY: this.state.translateY}]},
|
|
295
|
+
}
|
|
296
|
+
: null;
|
|
297
|
+
|
|
298
|
+
return (
|
|
299
|
+
<AnimatedView
|
|
300
|
+
collapsable={false}
|
|
301
|
+
nativeID={this.props.nativeID}
|
|
302
|
+
onLayout={this._onLayout}
|
|
303
|
+
ref={this._setComponentRef}
|
|
304
|
+
style={[
|
|
305
|
+
child.props.style,
|
|
306
|
+
styles.header,
|
|
307
|
+
{transform: [{translateY: this._translateY}]},
|
|
308
|
+
]}
|
|
309
|
+
passthroughAnimatedPropExplicitValues={
|
|
310
|
+
passthroughAnimatedPropExplicitValues
|
|
311
|
+
}>
|
|
312
|
+
{React.cloneElement(child, {
|
|
313
|
+
style: styles.fill, // We transfer the child style to the wrapper.
|
|
314
|
+
onLayout: undefined, // we call this manually through our this._onLayout
|
|
315
|
+
})}
|
|
316
|
+
</AnimatedView>
|
|
317
|
+
);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
304
320
|
|
|
305
321
|
const styles = StyleSheet.create({
|
|
306
322
|
header: {
|
|
@@ -312,4 +328,4 @@ const styles = StyleSheet.create({
|
|
|
312
328
|
},
|
|
313
329
|
});
|
|
314
330
|
|
|
315
|
-
|
|
331
|
+
module.exports = ScrollViewStickyHeader;
|
|
@@ -8,7 +8,7 @@ export declare type SharedTextPropsAndroidandWin32 = {
|
|
|
8
8
|
/**
|
|
9
9
|
* Role-based text style names.
|
|
10
10
|
*/
|
|
11
|
-
export declare type
|
|
11
|
+
export declare type TextWin32TextStyle = 'None' | 'SmallStandard' | 'SmallSecondary' | 'MediumStandard' | 'MediumSecondary' | 'MediumApp' | 'MediumBold' | 'MediumBoldApp' | 'LargeStandard' | 'LargePlusStandard' | 'ExtraLargeStandard' | 'HugeStandard';
|
|
12
12
|
export interface ITextWin32Props extends Omit<RN.TextProps, TextWin32OmitTypes>, BasePropsWin32 {
|
|
13
13
|
onKeyDown?: (args: IKeyboardEvent) => void;
|
|
14
14
|
onKeyDownCapture?: (args: IKeyboardEvent) => void;
|
|
@@ -62,7 +62,7 @@ export interface ITextWin32Props extends Omit<RN.TextProps, TextWin32OmitTypes>,
|
|
|
62
62
|
*
|
|
63
63
|
* @deprecated Use `style` instead.
|
|
64
64
|
*/
|
|
65
|
-
textStyle?:
|
|
65
|
+
textStyle?: TextWin32TextStyle;
|
|
66
66
|
/** Tooltip displayed on mouse hover of this element */
|
|
67
67
|
tooltip?: string;
|
|
68
68
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextWin32.Props.js","sourceRoot":"","sources":["../../../src/Libraries/Components/Text/TextWin32.Props.ts"],"names":[],"mappings":"","sourcesContent":["import RN = require('react-native');\nimport { SharedAccessibilityPropsIOSandWin32, OmittedAccessibilityPropsWin32, BasePropsWin32, IKeyboardEvent, IHandledKeyboardEvent } from '../View/ViewWin32.Props';\n\n// removes from interface T the members of interface K\ntype Omit<T, K> = Pick<T, Exclude<keyof T, keyof K>>;\n\nexport type TextWin32OmitTypes = Omit<RN.TextPropsAndroid, SharedTextPropsAndroidandWin32> &\n RN.TextPropsIOS &\n RN.AccessibilityPropsAndroid &\n Omit<RN.AccessibilityPropsIOS, SharedAccessibilityPropsIOSandWin32> &\n OmittedAccessibilityPropsWin32;\n\nexport type SharedTextPropsAndroidandWin32 = {\n selectable?: boolean;\n};\n\n/**\n * Role-based text style names.\n */\nexport type
|
|
1
|
+
{"version":3,"file":"TextWin32.Props.js","sourceRoot":"","sources":["../../../src/Libraries/Components/Text/TextWin32.Props.ts"],"names":[],"mappings":"","sourcesContent":["import RN = require('react-native');\nimport { SharedAccessibilityPropsIOSandWin32, OmittedAccessibilityPropsWin32, BasePropsWin32, IKeyboardEvent, IHandledKeyboardEvent } from '../View/ViewWin32.Props';\n\n// removes from interface T the members of interface K\ntype Omit<T, K> = Pick<T, Exclude<keyof T, keyof K>>;\n\nexport type TextWin32OmitTypes = Omit<RN.TextPropsAndroid, SharedTextPropsAndroidandWin32> &\n RN.TextPropsIOS &\n RN.AccessibilityPropsAndroid &\n Omit<RN.AccessibilityPropsIOS, SharedAccessibilityPropsIOSandWin32> &\n OmittedAccessibilityPropsWin32;\n\nexport type SharedTextPropsAndroidandWin32 = {\n selectable?: boolean;\n};\n\n/**\n * Role-based text style names.\n */\nexport type TextWin32TextStyle =\n | 'None'\n | 'SmallStandard'\n | 'SmallSecondary'\n | 'MediumStandard'\n | 'MediumSecondary'\n | 'MediumApp'\n | 'MediumBold'\n | 'MediumBoldApp'\n | 'LargeStandard'\n | 'LargePlusStandard'\n | 'ExtraLargeStandard'\n | 'HugeStandard';\n\nexport interface ITextWin32Props extends Omit<RN.TextProps, TextWin32OmitTypes>, BasePropsWin32 {\n onKeyDown?: (args: IKeyboardEvent) => void;\n onKeyDownCapture?: (args: IKeyboardEvent) => void;\n onKeyUp?: (args: IKeyboardEvent) => void;\n onKeyUpCapture?: (args: IKeyboardEvent) => void;\n\n keyDownEvents?: IHandledKeyboardEvent[];\n keyUpEvents?: IHandledKeyboardEvent[];\n\n /** Enables a focusable label with copyability but without character selectability (property:selectable) */\n focusable?: boolean;\n\n /**\n * The onBlur event occurs when an element loses focus. The opposite of onBlur is onFocus. Note that in React\n * Native, unlike in the web, the onBlur event bubbles (similar to onFocusOut in the web).\n *\n * `ev.target === ev.currentTarget` when the focus is being lost from this component.\n * `ev.target !== ev.currentTarget` when the focus is being lost from a descendant.\n */\n onBlur?: (ev: RN.NativeSyntheticEvent<{}>) => void;\n /**\n * The onBlur event occurs when an element loses focus. The opposite of onBlur is onFocus. Note that in React\n * Native, unlike in the web, the onBlur event bubbles (similar to onFocusOut in the web).\n *\n * `ev.target === ev.currentTarget` when the focus is being lost from this component.\n * `ev.target !== ev.currentTarget` when the focus is being lost from a descendant.\n */\n onBlurCapture?: (ev: RN.NativeSyntheticEvent<{}>) => void;\n /**\n * The onFocus event occurs when an element gets focus. The opposite of onFocus is onBlur. Note that in React\n * Native, unlike in the web, the onFocus event bubbles (similar to onFocusIn in the web).\n *\n * `ev.target === ev.currentTarget` when the focus is being lost from this component.\n * `ev.target !== ev.currentTarget` when the focus is being lost from a descendant.\n */\n onFocus?: (ev: RN.NativeSyntheticEvent<{}>) => void;\n /**\n * The onFocus event occurs when an element gets focus. The opposite of onFocus is onBlur. Note that in React\n * Native, unlike in the web, the onFocus event bubbles (similar to onFocusIn in the web).\n *\n * `ev.target === ev.currentTarget` when the focus is being lost from this component.\n * `ev.target !== ev.currentTarget` when the focus is being lost from a descendant.\n */\n onFocusCapture?: (ev: RN.NativeSyntheticEvent<{}>) => void;\n \n /**\n * Role-based styling of the text control. The styles applied include\n * font face, size, weight and color. These styles take precedence over\n * the `style` property.\n *\n * @remarks\n * The default value is `MediumStandard`.\n *\n * When set to `None`, role-based styling is disabled.\n *\n * @deprecated Use `style` instead.\n */\n textStyle?: TextWin32TextStyle;\n\n /** Tooltip displayed on mouse hover of this element */\n tooltip?: string;\n}\n"]}
|
|
@@ -11,7 +11,7 @@ class TextWin32 extends react_1.default.Component {
|
|
|
11
11
|
super(props);
|
|
12
12
|
}
|
|
13
13
|
render() {
|
|
14
|
-
return react_1.default.createElement(RN.Text,
|
|
14
|
+
return react_1.default.createElement(RN.Text, { ...this.props });
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
exports.TextWin32 = TextWin32;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextWin32.js","sourceRoot":"","sources":["../../../src/Libraries/Components/Text/TextWin32.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAAyB;AACzB,mCAAoC;AAWpC,MAAa,SAAU,SAAQ,eAAK,CAAC,SAA8B;IACjE,YAAY,KAAsB;QAChC,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;IAEM,MAAM;QACX,OAAO,8BAAC,EAAE,CAAC,IAAI,
|
|
1
|
+
{"version":3,"file":"TextWin32.js","sourceRoot":"","sources":["../../../src/Libraries/Components/Text/TextWin32.tsx"],"names":[],"mappings":";;;;;;AAAA,kDAAyB;AACzB,mCAAoC;AAWpC,MAAa,SAAU,SAAQ,eAAK,CAAC,SAA8B;IACjE,YAAY,KAAsB;QAChC,KAAK,CAAC,KAAK,CAAC,CAAC;IACf,CAAC;IAEM,MAAM;QACX,OAAO,8BAAC,EAAE,CAAC,IAAI,OAAM,IAAI,CAAC,KAAwB,GAAI,CAAC;IACzD,CAAC;CACF;AARD,8BAQC","sourcesContent":["import React from 'react'\nimport RN = require('react-native');\nimport { ITextWin32Props } from './TextWin32.Props';\nimport { UseFrom } from '../View/ViewWin32.Props';\n\n/**\n * React-native <Text> control with additional Win32-specific functionality.\n */\n\ntype InnerViewProps = UseFrom<ITextWin32Props, RN.TextProps, 'accessibilityRole'> &\n UseFrom<ITextWin32Props, RN.TextProps, 'accessibilityState'> &\n UseFrom<ITextWin32Props, RN.TextProps, 'accessibilityActions'>;\nexport class TextWin32 extends React.Component<ITextWin32Props, {}> {\n constructor(props: ITextWin32Props) {\n super(props);\n }\n\n public render() {\n return <RN.Text {...(this.props as InnerViewProps)} />;\n }\n}\n"]}
|