react-native-windows 0.0.0-canary.481 → 0.0.0-canary.484
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/.flowconfig +1 -1
- package/Libraries/Alert/Alert.windows.js +2 -2
- package/Libraries/AppState/AppState.js +1 -1
- package/Libraries/Components/ScrollView/ScrollViewStickyHeader.js +3 -1
- package/Libraries/Components/TextInput/TextInput.windows.js +1 -1
- package/Libraries/Components/Touchable/TouchableHighlight.windows.js +5 -5
- package/Libraries/Components/Touchable/TouchableOpacity.windows.js +4 -4
- package/Libraries/Components/View/View.windows.js +1 -1
- package/Libraries/Components/View/ViewPropTypes.js +15 -0
- package/Libraries/Components/View/ViewPropTypes.windows.js +15 -0
- package/Libraries/Core/ReactNativeVersion.js +1 -1
- package/Libraries/Image/Image.windows.js +2 -2
- package/Libraries/Lists/FlatList.js +27 -6
- package/Libraries/Lists/VirtualizedList.js +47 -32
- package/Libraries/Lists/__tests__/{FillRateHelper-test.windows.js → FillRateHelper-test.js} +2 -2
- package/Libraries/Lists/__tests__/{FlatList-test.windows.js → FlatList-test.js} +2 -2
- package/Libraries/Lists/__tests__/{SectionList-test.windows.js → SectionList-test.js} +14 -14
- package/Libraries/Lists/__tests__/{VirtualizeUtils-test.windows.js → VirtualizeUtils-test.js} +3 -3
- package/Libraries/Lists/__tests__/{VirtualizedList-test.windows.js → VirtualizedList-test.js} +61 -31
- package/Libraries/Lists/__tests__/{VirtualizedSectionList-test.windows.js → VirtualizedSectionList-test.js} +13 -13
- package/Libraries/NativeComponent/PlatformBaseViewConfig.js +38 -0
- package/Libraries/Network/FormData.js +7 -1
- package/Libraries/Pressability/Pressability.windows.js +4 -4
- package/Libraries/ReactNative/PaperUIManager.windows.js +5 -5
- package/Libraries/Renderer/shims/ReactNativeTypes.js +2 -1
- package/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +2 -1
- package/Libraries/Text/Text.js +1 -0
- package/Libraries/Text/Text.windows.js +1 -0
- package/Libraries/Text/TextNativeComponent.js +2 -0
- package/Libraries/Types/CoreEventTypes.js +12 -0
- package/Libraries/Types/CoreEventTypes.windows.js +12 -0
- package/Microsoft.ReactNative.Cxx/XamlUtils.h +39 -5
- package/PropertySheets/Generated/PackageVersion.g.props +1 -1
- package/ReactCommon/TEMP_UntilReactCommonUpdate/jsi/jsi/test/testlib.cpp +1431 -0
- package/Scripts/copyRNLibraries.js +8 -8
- package/Scripts/just.js +1 -1
- package/Scripts/rnw-dependencies.ps1 +3 -3
- package/Scripts/run-desktop-integration-tests.js +6 -6
- package/package.json +13 -12
- package/react-native.config.js +1 -1
package/.flowconfig
CHANGED
|
@@ -70,7 +70,7 @@ class Alert {
|
|
|
70
70
|
buttonNeutral,
|
|
71
71
|
buttonNegative,
|
|
72
72
|
buttonPositive,
|
|
73
|
-
].findIndex(
|
|
73
|
+
].findIndex(b => b != null && b.style === 'default');
|
|
74
74
|
|
|
75
75
|
// XAML has an enum to specify the default button, which is:
|
|
76
76
|
// None = 0, Primary = 1, Secondary = 2, Close = 3
|
|
@@ -101,7 +101,7 @@ class Alert {
|
|
|
101
101
|
options && options.onDismiss && options.onDismiss();
|
|
102
102
|
}
|
|
103
103
|
};
|
|
104
|
-
const onError =
|
|
104
|
+
const onError = errorMessage => console.warn(errorMessage);
|
|
105
105
|
NativeDialogManagerWindows.showAlert(config, onError, onAction);
|
|
106
106
|
}
|
|
107
107
|
|
|
@@ -154,7 +154,7 @@ class AppState {
|
|
|
154
154
|
case 'focus':
|
|
155
155
|
// $FlowIssue[invalid-tuple-arity] Flow cannot refine handler based on the event type
|
|
156
156
|
// $FlowIssue[incompatible-call]
|
|
157
|
-
emitter.
|
|
157
|
+
emitter.removeListener('appStateFocusChange', listener);
|
|
158
158
|
return;
|
|
159
159
|
}
|
|
160
160
|
throw new Error('Trying to unsubscribe from unknown event: ' + type);
|
|
@@ -170,7 +170,9 @@ class ScrollViewStickyHeader extends React.Component<Props, State> {
|
|
|
170
170
|
|
|
171
171
|
this.props.onLayout(event);
|
|
172
172
|
const child = React.Children.only(this.props.children);
|
|
173
|
-
if (child.props.
|
|
173
|
+
if (child.props.onCellLayout) {
|
|
174
|
+
child.props.onCellLayout(event, child.props.cellKey, child.props.index);
|
|
175
|
+
} else if (child.props.onLayout) {
|
|
174
176
|
child.props.onLayout(event);
|
|
175
177
|
}
|
|
176
178
|
};
|
|
@@ -1113,7 +1113,7 @@ function InternalTextInput(props: Props): React.Node {
|
|
|
1113
1113
|
|
|
1114
1114
|
const _setNativeRef = setAndForwardRef({
|
|
1115
1115
|
getForwardedRef: () => props.forwardedRef,
|
|
1116
|
-
setLocalRef:
|
|
1116
|
+
setLocalRef: ref => {
|
|
1117
1117
|
inputRef.current = ref;
|
|
1118
1118
|
|
|
1119
1119
|
/*
|
|
@@ -178,7 +178,7 @@ class TouchableHighlight extends React.Component<Props, State> {
|
|
|
178
178
|
android_disableSound: this.props.touchSoundDisabled,
|
|
179
179
|
onMouseEnter: this.props.onMouseEnter, // [Windows]
|
|
180
180
|
onMouseLeave: this.props.onMouseLeave, // [Windows]
|
|
181
|
-
onBlur:
|
|
181
|
+
onBlur: event => {
|
|
182
182
|
if (Platform.isTV) {
|
|
183
183
|
this._hideUnderlay();
|
|
184
184
|
}
|
|
@@ -186,7 +186,7 @@ class TouchableHighlight extends React.Component<Props, State> {
|
|
|
186
186
|
this.props.onBlur(event);
|
|
187
187
|
}
|
|
188
188
|
},
|
|
189
|
-
onFocus:
|
|
189
|
+
onFocus: event => {
|
|
190
190
|
if (Platform.isTV) {
|
|
191
191
|
this._showUnderlay();
|
|
192
192
|
}
|
|
@@ -195,7 +195,7 @@ class TouchableHighlight extends React.Component<Props, State> {
|
|
|
195
195
|
}
|
|
196
196
|
},
|
|
197
197
|
onLongPress: this.props.onLongPress,
|
|
198
|
-
onPress:
|
|
198
|
+
onPress: event => {
|
|
199
199
|
if (this._hideTimeout != null) {
|
|
200
200
|
clearTimeout(this._hideTimeout);
|
|
201
201
|
}
|
|
@@ -209,7 +209,7 @@ class TouchableHighlight extends React.Component<Props, State> {
|
|
|
209
209
|
this.props.onPress(event);
|
|
210
210
|
}
|
|
211
211
|
},
|
|
212
|
-
onPressIn:
|
|
212
|
+
onPressIn: event => {
|
|
213
213
|
if (this._hideTimeout != null) {
|
|
214
214
|
clearTimeout(this._hideTimeout);
|
|
215
215
|
this._hideTimeout = null;
|
|
@@ -219,7 +219,7 @@ class TouchableHighlight extends React.Component<Props, State> {
|
|
|
219
219
|
this.props.onPressIn(event);
|
|
220
220
|
}
|
|
221
221
|
},
|
|
222
|
-
onPressOut:
|
|
222
|
+
onPressOut: event => {
|
|
223
223
|
if (this._hideTimeout == null) {
|
|
224
224
|
this._hideUnderlay();
|
|
225
225
|
}
|
|
@@ -146,7 +146,7 @@ class TouchableOpacity extends React.Component<Props, State> {
|
|
|
146
146
|
pressRectOffset: this.props.pressRetentionOffset,
|
|
147
147
|
onMouseEnter: this.props.onMouseEnter, // [Windows]
|
|
148
148
|
onMouseLeave: this.props.onMouseLeave, // [Windows]
|
|
149
|
-
onBlur:
|
|
149
|
+
onBlur: event => {
|
|
150
150
|
if (Platform.isTV) {
|
|
151
151
|
this._opacityInactive(250);
|
|
152
152
|
}
|
|
@@ -154,7 +154,7 @@ class TouchableOpacity extends React.Component<Props, State> {
|
|
|
154
154
|
this.props.onBlur(event);
|
|
155
155
|
}
|
|
156
156
|
},
|
|
157
|
-
onFocus:
|
|
157
|
+
onFocus: event => {
|
|
158
158
|
if (Platform.isTV) {
|
|
159
159
|
this._opacityActive(150);
|
|
160
160
|
}
|
|
@@ -164,7 +164,7 @@ class TouchableOpacity extends React.Component<Props, State> {
|
|
|
164
164
|
},
|
|
165
165
|
onLongPress: this.props.onLongPress,
|
|
166
166
|
onPress: this.props.onPress,
|
|
167
|
-
onPressIn:
|
|
167
|
+
onPressIn: event => {
|
|
168
168
|
this._opacityActive(
|
|
169
169
|
event.dispatchConfig.registrationName === 'onResponderGrant'
|
|
170
170
|
? 0
|
|
@@ -174,7 +174,7 @@ class TouchableOpacity extends React.Component<Props, State> {
|
|
|
174
174
|
this.props.onPressIn(event);
|
|
175
175
|
}
|
|
176
176
|
},
|
|
177
|
-
onPressOut:
|
|
177
|
+
onPressOut: event => {
|
|
178
178
|
this._opacityInactive(250);
|
|
179
179
|
if (this.props.onPressOut != null) {
|
|
180
180
|
this.props.onPressOut(event);
|
|
@@ -81,7 +81,7 @@ const View: React.AbstractComponent<
|
|
|
81
81
|
// https://github.com/facebook/react-native/commit/66601e755fcad10698e61d20878d52194ad0e90c
|
|
82
82
|
// But since Views are not currently supported in Text, we do not need the extra provider
|
|
83
83
|
<TextAncestor.Consumer>
|
|
84
|
-
{
|
|
84
|
+
{hasTextAncestor => {
|
|
85
85
|
invariant(
|
|
86
86
|
!hasTextAncestor,
|
|
87
87
|
'Nesting of <View> within <Text> is not currently supported.',
|
|
@@ -99,6 +99,20 @@ type TouchEventProps = $ReadOnly<{|
|
|
|
99
99
|
onTouchStartCapture?: ?(e: PressEvent) => void,
|
|
100
100
|
|}>;
|
|
101
101
|
|
|
102
|
+
type PointerEventCallbackProps = $ReadOnly<{|
|
|
103
|
+
onPointerCancel?: ?(e: PointerEvent) => void,
|
|
104
|
+
onPointerCancelCapture?: ?(e: PointerEvent) => void,
|
|
105
|
+
onPointerDown?: ?(e: PointerEvent) => void,
|
|
106
|
+
onPointerDownCapture?: ?(e: PointerEvent) => void,
|
|
107
|
+
onPointerEnter2?: ?(e: PointerEvent) => void,
|
|
108
|
+
onPointerLeave2?: ?(e: PointerEvent) => void,
|
|
109
|
+
onPointerEnter2Capture?: ?(e: PointerEvent) => void,
|
|
110
|
+
onPointerLeave2Capture?: ?(e: PointerEvent) => void,
|
|
111
|
+
onPointerMove2Capture?: ?(e: PointerEvent) => void,
|
|
112
|
+
onPointerUp?: ?(e: PointerEvent) => void,
|
|
113
|
+
onPointerUpCapture?: ?(e: PointerEvent) => void,
|
|
114
|
+
|}>;
|
|
115
|
+
|
|
102
116
|
/**
|
|
103
117
|
* For most touch interactions, you'll simply want to wrap your component in
|
|
104
118
|
* `TouchableHighlight` or `TouchableOpacity`. Check out `Touchable.js`,
|
|
@@ -382,6 +396,7 @@ export type ViewProps = $ReadOnly<{|
|
|
|
382
396
|
...GestureResponderEventProps,
|
|
383
397
|
...MouseEventProps,
|
|
384
398
|
...TouchEventProps,
|
|
399
|
+
...PointerEventCallbackProps,
|
|
385
400
|
...AndroidViewProps,
|
|
386
401
|
...IOSViewProps,
|
|
387
402
|
|
|
@@ -100,6 +100,20 @@ type TouchEventProps = $ReadOnly<{|
|
|
|
100
100
|
onTouchStartCapture?: ?(e: PressEvent) => void,
|
|
101
101
|
|}>;
|
|
102
102
|
|
|
103
|
+
type PointerEventCallbackProps = $ReadOnly<{|
|
|
104
|
+
onPointerCancel?: ?(e: PointerEvent) => void,
|
|
105
|
+
onPointerCancelCapture?: ?(e: PointerEvent) => void,
|
|
106
|
+
onPointerDown?: ?(e: PointerEvent) => void,
|
|
107
|
+
onPointerDownCapture?: ?(e: PointerEvent) => void,
|
|
108
|
+
onPointerEnter2?: ?(e: PointerEvent) => void,
|
|
109
|
+
onPointerLeave2?: ?(e: PointerEvent) => void,
|
|
110
|
+
onPointerEnter2Capture?: ?(e: PointerEvent) => void,
|
|
111
|
+
onPointerLeave2Capture?: ?(e: PointerEvent) => void,
|
|
112
|
+
onPointerMove2Capture?: ?(e: PointerEvent) => void,
|
|
113
|
+
onPointerUp?: ?(e: PointerEvent) => void,
|
|
114
|
+
onPointerUpCapture?: ?(e: PointerEvent) => void,
|
|
115
|
+
|}>;
|
|
116
|
+
|
|
103
117
|
/**
|
|
104
118
|
* For most touch interactions, you'll simply want to wrap your component in
|
|
105
119
|
* `TouchableHighlight` or `TouchableOpacity`. Check out `Touchable.js`,
|
|
@@ -430,6 +444,7 @@ export type ViewProps = $ReadOnly<{|
|
|
|
430
444
|
...GestureResponderEventProps,
|
|
431
445
|
...MouseEventProps,
|
|
432
446
|
...TouchEventProps,
|
|
447
|
+
...PointerEventCallbackProps,
|
|
433
448
|
...AndroidViewProps,
|
|
434
449
|
...IOSViewProps,
|
|
435
450
|
...WindowsViewProps, // [Windows]
|
|
@@ -145,7 +145,7 @@ let Image = (props: ImagePropsType, forwardedRef) => {
|
|
|
145
145
|
return (
|
|
146
146
|
// [Windows
|
|
147
147
|
<TextAncestor.Consumer>
|
|
148
|
-
{
|
|
148
|
+
{hasTextAncestor => {
|
|
149
149
|
invariant(
|
|
150
150
|
!hasTextAncestor,
|
|
151
151
|
'Nesting of <Image> within <Text> is not currently supported.',
|
|
@@ -154,7 +154,7 @@ let Image = (props: ImagePropsType, forwardedRef) => {
|
|
|
154
154
|
|
|
155
155
|
return (
|
|
156
156
|
<ImageAnalyticsTagContext.Consumer>
|
|
157
|
-
{
|
|
157
|
+
{analyticTag => {
|
|
158
158
|
return (
|
|
159
159
|
<ImageViewNativeComponent
|
|
160
160
|
{...props}
|
|
@@ -26,6 +26,7 @@ import type {
|
|
|
26
26
|
} from './ViewabilityHelper';
|
|
27
27
|
import type {RenderItemType, RenderItemProps} from './VirtualizedList';
|
|
28
28
|
import {keyExtractor as defaultKeyExtractor} from './VirtualizeUtils';
|
|
29
|
+
import memoizeOne from 'memoize-one';
|
|
29
30
|
|
|
30
31
|
type RequiredProps<ItemT> = {|
|
|
31
32
|
/**
|
|
@@ -141,6 +142,10 @@ type OptionalProps<ItemT> = {|
|
|
|
141
142
|
* See `ScrollView` for flow type and further documentation.
|
|
142
143
|
*/
|
|
143
144
|
fadingEdgeLength?: ?number,
|
|
145
|
+
/**
|
|
146
|
+
* Enable an optimization to memoize the item renderer to prevent unnecessary rerenders.
|
|
147
|
+
*/
|
|
148
|
+
strictMode?: boolean,
|
|
144
149
|
|};
|
|
145
150
|
|
|
146
151
|
/**
|
|
@@ -578,9 +583,14 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
|
|
|
578
583
|
};
|
|
579
584
|
}
|
|
580
585
|
|
|
581
|
-
_renderer = (
|
|
582
|
-
|
|
583
|
-
|
|
586
|
+
_renderer = (
|
|
587
|
+
ListItemComponent: ?(React.ComponentType<any> | React.Element<any>),
|
|
588
|
+
renderItem: ?RenderItemType<ItemT>,
|
|
589
|
+
columnWrapperStyle: ?ViewStyleProp,
|
|
590
|
+
numColumns: ?number,
|
|
591
|
+
extraData: ?any,
|
|
592
|
+
) => {
|
|
593
|
+
const cols = numColumnsOrDefault(numColumns);
|
|
584
594
|
|
|
585
595
|
let virtualizedListRenderKey = ListItemComponent
|
|
586
596
|
? 'ListItemComponent'
|
|
@@ -605,7 +615,7 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
|
|
|
605
615
|
* This comment suppresses an error found when Flow v0.111 was deployed.
|
|
606
616
|
* To see the error, delete this comment and run Flow. */
|
|
607
617
|
[virtualizedListRenderKey]: (info: RenderItemProps<ItemT>) => {
|
|
608
|
-
if (
|
|
618
|
+
if (cols > 1) {
|
|
609
619
|
const {item, index} = info;
|
|
610
620
|
invariant(
|
|
611
621
|
Array.isArray(item),
|
|
@@ -616,7 +626,7 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
|
|
|
616
626
|
{item.map((it, kk) => {
|
|
617
627
|
const element = renderer({
|
|
618
628
|
item: it,
|
|
619
|
-
index: index *
|
|
629
|
+
index: index * cols + kk,
|
|
620
630
|
separators: info.separators,
|
|
621
631
|
});
|
|
622
632
|
return element != null ? (
|
|
@@ -632,14 +642,19 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
|
|
|
632
642
|
};
|
|
633
643
|
};
|
|
634
644
|
|
|
645
|
+
_memoizedRenderer = memoizeOne(this._renderer);
|
|
646
|
+
|
|
635
647
|
render(): React.Node {
|
|
636
648
|
const {
|
|
637
649
|
numColumns,
|
|
638
650
|
columnWrapperStyle,
|
|
639
651
|
removeClippedSubviews: _removeClippedSubviews,
|
|
652
|
+
strictMode = false,
|
|
640
653
|
...restProps
|
|
641
654
|
} = this.props;
|
|
642
655
|
|
|
656
|
+
const renderer = strictMode ? this._memoizedRenderer : this._renderer;
|
|
657
|
+
|
|
643
658
|
return (
|
|
644
659
|
<VirtualizedList
|
|
645
660
|
{...restProps}
|
|
@@ -651,7 +666,13 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
|
|
|
651
666
|
removeClippedSubviews={removeClippedSubviewsOrDefault(
|
|
652
667
|
_removeClippedSubviews,
|
|
653
668
|
)}
|
|
654
|
-
{...
|
|
669
|
+
{...renderer(
|
|
670
|
+
this.props.ListItemComponent,
|
|
671
|
+
this.props.renderItem,
|
|
672
|
+
columnWrapperStyle,
|
|
673
|
+
numColumns,
|
|
674
|
+
this.props.extraData,
|
|
675
|
+
)}
|
|
655
676
|
/>
|
|
656
677
|
);
|
|
657
678
|
}
|
|
@@ -34,6 +34,7 @@ import type {
|
|
|
34
34
|
ViewToken,
|
|
35
35
|
ViewabilityConfigCallbackPair,
|
|
36
36
|
} from './ViewabilityHelper';
|
|
37
|
+
import type {LayoutEvent} from '../Types/CoreEventTypes';
|
|
37
38
|
import {
|
|
38
39
|
VirtualizedListCellContextProvider,
|
|
39
40
|
VirtualizedListContext,
|
|
@@ -796,12 +797,17 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|
|
796
797
|
const {
|
|
797
798
|
CellRendererComponent,
|
|
798
799
|
ItemSeparatorComponent,
|
|
800
|
+
ListHeaderComponent,
|
|
801
|
+
ListItemComponent,
|
|
799
802
|
data,
|
|
803
|
+
debug,
|
|
800
804
|
getItem,
|
|
801
805
|
getItemCount,
|
|
806
|
+
getItemLayout,
|
|
802
807
|
horizontal,
|
|
808
|
+
renderItem,
|
|
803
809
|
} = this.props;
|
|
804
|
-
const stickyOffset =
|
|
810
|
+
const stickyOffset = ListHeaderComponent ? 1 : 0;
|
|
805
811
|
const end = getItemCount(data) - 1;
|
|
806
812
|
let prevCellKey;
|
|
807
813
|
last = Math.min(end, last);
|
|
@@ -816,21 +822,24 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|
|
816
822
|
<CellRenderer
|
|
817
823
|
CellRendererComponent={CellRendererComponent}
|
|
818
824
|
ItemSeparatorComponent={ii < end ? ItemSeparatorComponent : undefined}
|
|
825
|
+
ListItemComponent={ListItemComponent}
|
|
819
826
|
cellKey={key}
|
|
827
|
+
debug={debug}
|
|
820
828
|
fillRateHelper={this._fillRateHelper}
|
|
829
|
+
getItemLayout={getItemLayout}
|
|
821
830
|
horizontal={horizontal}
|
|
822
831
|
index={ii}
|
|
823
832
|
inversionStyle={inversionStyle}
|
|
824
833
|
item={item}
|
|
825
834
|
key={key}
|
|
826
835
|
prevCellKey={prevCellKey}
|
|
836
|
+
onCellLayout={this._onCellLayout}
|
|
827
837
|
onUpdateSeparators={this._onUpdateSeparators}
|
|
828
|
-
onLayout={e => this._onCellLayout(e, key, ii)}
|
|
829
838
|
onUnmount={this._onCellUnmount}
|
|
830
|
-
parentProps={this.props}
|
|
831
839
|
ref={ref => {
|
|
832
840
|
this._cellRefs[key] = ref;
|
|
833
841
|
}}
|
|
842
|
+
renderItem={renderItem}
|
|
834
843
|
/>,
|
|
835
844
|
);
|
|
836
845
|
prevCellKey = key;
|
|
@@ -1268,7 +1277,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|
|
1268
1277
|
}
|
|
1269
1278
|
};
|
|
1270
1279
|
|
|
1271
|
-
_onCellLayout(e, cellKey, index) {
|
|
1280
|
+
_onCellLayout = (e: LayoutEvent, cellKey: string, index: number): void => {
|
|
1272
1281
|
const layout = e.nativeEvent.layout;
|
|
1273
1282
|
const next = {
|
|
1274
1283
|
offset: this._selectOffset(layout),
|
|
@@ -1301,7 +1310,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|
|
1301
1310
|
|
|
1302
1311
|
this._computeBlankness();
|
|
1303
1312
|
this._updateViewableItems(this.props.data);
|
|
1304
|
-
}
|
|
1313
|
+
};
|
|
1305
1314
|
|
|
1306
1315
|
_onCellUnmount = (cellKey: string) => {
|
|
1307
1316
|
const curr = this._frames[cellKey];
|
|
@@ -1380,7 +1389,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|
|
1380
1389
|
}
|
|
1381
1390
|
}
|
|
1382
1391
|
|
|
1383
|
-
_onLayout = (e:
|
|
1392
|
+
_onLayout = (e: LayoutEvent) => {
|
|
1384
1393
|
if (this._isNestedWithSameOrientation()) {
|
|
1385
1394
|
// Need to adjust our scroll metrics to be relative to our containing
|
|
1386
1395
|
// VirtualizedList before we can make claims about list item viewability
|
|
@@ -1395,7 +1404,7 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|
|
1395
1404
|
this._maybeCallOnEndReached();
|
|
1396
1405
|
};
|
|
1397
1406
|
|
|
1398
|
-
_onLayoutEmpty = e => {
|
|
1407
|
+
_onLayoutEmpty = (e: LayoutEvent) => {
|
|
1399
1408
|
this.props.onLayout && this.props.onLayout(e);
|
|
1400
1409
|
};
|
|
1401
1410
|
|
|
@@ -1403,12 +1412,12 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
|
|
1403
1412
|
return this._getCellKey() + '-footer';
|
|
1404
1413
|
}
|
|
1405
1414
|
|
|
1406
|
-
_onLayoutFooter = e => {
|
|
1415
|
+
_onLayoutFooter = (e: LayoutEvent) => {
|
|
1407
1416
|
this._triggerRemeasureForChildListsInCell(this._getFooterCellKey());
|
|
1408
1417
|
this._footerLength = this._selectLength(e.nativeEvent.layout);
|
|
1409
1418
|
};
|
|
1410
1419
|
|
|
1411
|
-
_onLayoutHeader = e => {
|
|
1420
|
+
_onLayoutHeader = (e: LayoutEvent) => {
|
|
1412
1421
|
this._headerLength = this._selectLength(e.nativeEvent.layout);
|
|
1413
1422
|
};
|
|
1414
1423
|
|
|
@@ -1886,32 +1895,29 @@ type CellRendererProps = {
|
|
|
1886
1895
|
ItemSeparatorComponent: ?React.ComponentType<
|
|
1887
1896
|
any | {highlighted: boolean, leadingItem: ?Item},
|
|
1888
1897
|
>,
|
|
1898
|
+
ListItemComponent?: ?(React.ComponentType<any> | React.Element<any>),
|
|
1889
1899
|
cellKey: string,
|
|
1900
|
+
debug?: ?boolean,
|
|
1890
1901
|
fillRateHelper: FillRateHelper,
|
|
1902
|
+
getItemLayout?: (
|
|
1903
|
+
data: any,
|
|
1904
|
+
index: number,
|
|
1905
|
+
) => {
|
|
1906
|
+
length: number,
|
|
1907
|
+
offset: number,
|
|
1908
|
+
index: number,
|
|
1909
|
+
...
|
|
1910
|
+
},
|
|
1891
1911
|
horizontal: ?boolean,
|
|
1892
1912
|
index: number,
|
|
1893
1913
|
inversionStyle: ViewStyleProp,
|
|
1894
1914
|
item: Item,
|
|
1895
1915
|
// This is extracted by ScrollViewStickyHeader
|
|
1896
|
-
|
|
1916
|
+
onCellLayout: (event: Object, cellKey: string, index: number) => void,
|
|
1897
1917
|
onUnmount: (cellKey: string) => void,
|
|
1898
1918
|
onUpdateSeparators: (cellKeys: Array<?string>, props: Object) => void,
|
|
1899
|
-
parentProps: {
|
|
1900
|
-
// e.g. height, y,
|
|
1901
|
-
getItemLayout?: (
|
|
1902
|
-
data: any,
|
|
1903
|
-
index: number,
|
|
1904
|
-
) => {
|
|
1905
|
-
length: number,
|
|
1906
|
-
offset: number,
|
|
1907
|
-
index: number,
|
|
1908
|
-
...
|
|
1909
|
-
},
|
|
1910
|
-
renderItem?: ?RenderItemType<Item>,
|
|
1911
|
-
ListItemComponent?: ?(React.ComponentType<any> | React.Element<any>),
|
|
1912
|
-
...
|
|
1913
|
-
},
|
|
1914
1919
|
prevCellKey: ?string,
|
|
1920
|
+
renderItem?: ?RenderItemType<Item>,
|
|
1915
1921
|
...
|
|
1916
1922
|
};
|
|
1917
1923
|
|
|
@@ -1980,6 +1986,15 @@ class CellRenderer extends React.Component<
|
|
|
1980
1986
|
this.props.onUnmount(this.props.cellKey);
|
|
1981
1987
|
}
|
|
1982
1988
|
|
|
1989
|
+
_onLayout = (nativeEvent: LayoutEvent): void => {
|
|
1990
|
+
this.props.onCellLayout &&
|
|
1991
|
+
this.props.onCellLayout(
|
|
1992
|
+
nativeEvent,
|
|
1993
|
+
this.props.cellKey,
|
|
1994
|
+
this.props.index,
|
|
1995
|
+
);
|
|
1996
|
+
};
|
|
1997
|
+
|
|
1983
1998
|
_renderElement(renderItem, ListItemComponent, item, index) {
|
|
1984
1999
|
if (renderItem && ListItemComponent) {
|
|
1985
2000
|
console.warn(
|
|
@@ -2020,14 +2035,16 @@ class CellRenderer extends React.Component<
|
|
|
2020
2035
|
const {
|
|
2021
2036
|
CellRendererComponent,
|
|
2022
2037
|
ItemSeparatorComponent,
|
|
2038
|
+
ListItemComponent,
|
|
2039
|
+
debug,
|
|
2023
2040
|
fillRateHelper,
|
|
2041
|
+
getItemLayout,
|
|
2024
2042
|
horizontal,
|
|
2025
2043
|
item,
|
|
2026
2044
|
index,
|
|
2027
2045
|
inversionStyle,
|
|
2028
|
-
|
|
2046
|
+
renderItem,
|
|
2029
2047
|
} = this.props;
|
|
2030
|
-
const {renderItem, getItemLayout, ListItemComponent} = parentProps;
|
|
2031
2048
|
const element = this._renderElement(
|
|
2032
2049
|
renderItem,
|
|
2033
2050
|
ListItemComponent,
|
|
@@ -2036,12 +2053,10 @@ class CellRenderer extends React.Component<
|
|
|
2036
2053
|
);
|
|
2037
2054
|
|
|
2038
2055
|
const onLayout =
|
|
2039
|
-
|
|
2040
|
-
|
|
2041
|
-
* error delete this comment and run Flow. */
|
|
2042
|
-
getItemLayout && !parentProps.debug && !fillRateHelper.enabled()
|
|
2056
|
+
(getItemLayout && !debug && !fillRateHelper.enabled()) ||
|
|
2057
|
+
!this.props.onCellLayout
|
|
2043
2058
|
? undefined
|
|
2044
|
-
: this.
|
|
2059
|
+
: this._onLayout;
|
|
2045
2060
|
// NOTE: that when this is a sticky header, `onLayout` will get automatically extracted and
|
|
2046
2061
|
// called explicitly by `ScrollViewStickyHeader`.
|
|
2047
2062
|
const itemSeparator = ItemSeparatorComponent && (
|
|
@@ -31,7 +31,7 @@ function computeResult({helper, props, state, scroll}): number {
|
|
|
31
31
|
return helper.computeBlankness(
|
|
32
32
|
{
|
|
33
33
|
data: dataGlobal,
|
|
34
|
-
getItemCount:
|
|
34
|
+
getItemCount: data2 => data2.length,
|
|
35
35
|
initialNumToRender: 10,
|
|
36
36
|
...(props || {}),
|
|
37
37
|
},
|
|
@@ -98,7 +98,7 @@ describe('computeBlankness', function () {
|
|
|
98
98
|
|
|
99
99
|
it('can handle multiple listeners and unsubscribe', function () {
|
|
100
100
|
const listeners = [jest.fn(), jest.fn(), jest.fn()];
|
|
101
|
-
const subscriptions = listeners.map(
|
|
101
|
+
const subscriptions = listeners.map(listener =>
|
|
102
102
|
FillRateHelper.addListener(listener),
|
|
103
103
|
);
|
|
104
104
|
subscriptions[1].remove();
|
|
@@ -102,13 +102,13 @@ describe('FlatList', () => {
|
|
|
102
102
|
ReactTestRenderer.create(
|
|
103
103
|
<FlatList
|
|
104
104
|
data={[{key: 'outer0'}, {key: 'outer1'}]}
|
|
105
|
-
renderItem={
|
|
105
|
+
renderItem={outerInfo => (
|
|
106
106
|
<FlatList
|
|
107
107
|
data={[
|
|
108
108
|
{key: outerInfo.item.key + ':inner0'},
|
|
109
109
|
{key: outerInfo.item.key + ':inner1'},
|
|
110
110
|
]}
|
|
111
|
-
renderItem={
|
|
111
|
+
renderItem={innerInfo => {
|
|
112
112
|
return <item title={innerInfo.item.key} />;
|
|
113
113
|
}}
|
|
114
114
|
ref={listRef}
|
|
@@ -39,21 +39,21 @@ describe('SectionList', () => {
|
|
|
39
39
|
const component = ReactTestRenderer.create(
|
|
40
40
|
<SectionList
|
|
41
41
|
initialNumToRender={Infinity}
|
|
42
|
-
ItemSeparatorComponent={
|
|
42
|
+
ItemSeparatorComponent={props => (
|
|
43
43
|
<defaultItemSeparator v={propStr(props)} />
|
|
44
44
|
)}
|
|
45
|
-
ListEmptyComponent={
|
|
46
|
-
ListFooterComponent={
|
|
47
|
-
ListHeaderComponent={
|
|
48
|
-
SectionSeparatorComponent={
|
|
45
|
+
ListEmptyComponent={props => <empty v={propStr(props)} />}
|
|
46
|
+
ListFooterComponent={props => <footer v={propStr(props)} />}
|
|
47
|
+
ListHeaderComponent={props => <header v={propStr(props)} />}
|
|
48
|
+
SectionSeparatorComponent={props => (
|
|
49
49
|
<sectionSeparator v={propStr(props)} />
|
|
50
50
|
)}
|
|
51
51
|
sections={[
|
|
52
52
|
{
|
|
53
|
-
renderItem:
|
|
53
|
+
renderItem: props => <itemForSection1 v={propStr(props)} />,
|
|
54
54
|
key: 's1',
|
|
55
55
|
keyExtractor: (item, index) => item.id,
|
|
56
|
-
ItemSeparatorComponent:
|
|
56
|
+
ItemSeparatorComponent: props => (
|
|
57
57
|
<itemSeparatorForSection1 v={propStr(props)} />
|
|
58
58
|
),
|
|
59
59
|
data: [{id: 'i1s1'}, {id: 'i2s1'}],
|
|
@@ -69,9 +69,9 @@ describe('SectionList', () => {
|
|
|
69
69
|
]}
|
|
70
70
|
refreshing={false}
|
|
71
71
|
onRefresh={jest.fn()}
|
|
72
|
-
renderItem={
|
|
73
|
-
renderSectionHeader={
|
|
74
|
-
renderSectionFooter={
|
|
72
|
+
renderItem={props => <defaultItem v={propStr(props)} />}
|
|
73
|
+
renderSectionHeader={props => <sectionHeader v={propStr(props)} />}
|
|
74
|
+
renderSectionFooter={props => <sectionFooter v={propStr(props)} />}
|
|
75
75
|
/>,
|
|
76
76
|
);
|
|
77
77
|
expect(component).toMatchSnapshot();
|
|
@@ -81,8 +81,8 @@ describe('SectionList', () => {
|
|
|
81
81
|
<SectionList
|
|
82
82
|
sections={[{key: 's1', data: []}]}
|
|
83
83
|
renderItem={({item}) => <item v={item.key} />}
|
|
84
|
-
renderSectionHeader={
|
|
85
|
-
renderSectionFooter={
|
|
84
|
+
renderSectionHeader={props => <sectionHeader v={propStr(props)} />}
|
|
85
|
+
renderSectionFooter={props => <sectionFooter v={propStr(props)} />}
|
|
86
86
|
/>,
|
|
87
87
|
);
|
|
88
88
|
expect(component).toMatchSnapshot();
|
|
@@ -92,7 +92,7 @@ describe('SectionList', () => {
|
|
|
92
92
|
<SectionList
|
|
93
93
|
sections={[{key: 's1', data: []}]}
|
|
94
94
|
renderItem={({item}) => <item v={item.key} />}
|
|
95
|
-
renderSectionFooter={
|
|
95
|
+
renderSectionFooter={props => <sectionFooter v={propStr(props)} />}
|
|
96
96
|
/>,
|
|
97
97
|
);
|
|
98
98
|
expect(component).toMatchSnapshot();
|
|
@@ -101,7 +101,7 @@ describe('SectionList', () => {
|
|
|
101
101
|
|
|
102
102
|
function propStr(props) {
|
|
103
103
|
return Object.keys(props)
|
|
104
|
-
.map(
|
|
104
|
+
.map(k => {
|
|
105
105
|
const propObj = props[k] || {};
|
|
106
106
|
return `${k}:${propObj.key || propObj.id || props[k]}`;
|
|
107
107
|
})
|
package/Libraries/Lists/__tests__/{VirtualizeUtils-test.windows.js → VirtualizeUtils-test.js}
RENAMED
|
@@ -62,7 +62,7 @@ describe('elementsThatOverlapOffsets', function () {
|
|
|
62
62
|
{offset: 950, length: 150},
|
|
63
63
|
];
|
|
64
64
|
expect(
|
|
65
|
-
elementsThatOverlapOffsets(offsets, frames.length,
|
|
65
|
+
elementsThatOverlapOffsets(offsets, frames.length, ii => frames[ii]),
|
|
66
66
|
).toEqual([1, 1, 3]);
|
|
67
67
|
});
|
|
68
68
|
it('handles out of bounds', function () {
|
|
@@ -73,7 +73,7 @@ describe('elementsThatOverlapOffsets', function () {
|
|
|
73
73
|
{offset: 250, length: 100},
|
|
74
74
|
];
|
|
75
75
|
expect(
|
|
76
|
-
elementsThatOverlapOffsets(offsets, frames.length,
|
|
76
|
+
elementsThatOverlapOffsets(offsets, frames.length, ii => frames[ii]),
|
|
77
77
|
).toEqual([1]);
|
|
78
78
|
});
|
|
79
79
|
it('errors on non-increasing offsets', function () {
|
|
@@ -84,7 +84,7 @@ describe('elementsThatOverlapOffsets', function () {
|
|
|
84
84
|
{offset: 250, length: 100},
|
|
85
85
|
];
|
|
86
86
|
expect(() => {
|
|
87
|
-
elementsThatOverlapOffsets(offsets, frames.length,
|
|
87
|
+
elementsThatOverlapOffsets(offsets, frames.length, ii => frames[ii]);
|
|
88
88
|
}).toThrowErrorMatchingSnapshot();
|
|
89
89
|
});
|
|
90
90
|
});
|