Skip to content

Commit 303dd6f

Browse files
acoates-msdanielayala94jonthysellchiaramooneyTatianaKapos
authored
[0.74] Cherry-pick changes (#14072)
* [Fabric] Introducing autocapitalize prop in TextInput - Take 2 (#13343) * New implementation of autocapitalize! * Change files * Fixed bug for sentences scenario * Just keep characters mode for now * Revert "Just keep characters mode for now" This reverts commit 60ca1ce. * Re-apply changes minus packages.json.lock * The original js file was deleted, re-applying changes * Fixed snapshot and lint errors * Fix override mismatch, added comments * Remove stale test check * Minor changes * Update obsolete snapshot * Cleanup ReactNativeAppBuilder and ReactNativeWin32App (#13983) This PR simplifies and scopes down the API for `ReactNativeAppBuilder` and `ReactNativeWin32App`. - Bug fix (non-breaking change which fixes an issue) `ReactNativeAppBuilder`'s API surface made it too easy to call incorrectly and not realize it. Resolves #13946 There are a variety of changes to the API surface: * `ReactInstanceSettingsBuilder` deleted: not only are there are simply too many APIs that would need to be exposed to be useful, the very act of creating and replacing the app's `ReactNativeHost`'s `ReactInstanceSettings` with a new one is what caused the bug in #13946 in the first place * `ReactNativeAppBuilder` now only exposes APIs to specify the intial, non-ReactNative, WinAppSDK types, (i.e. `DispatcherQueueController`, `Compositor`, and `AppWindow`), objects the app developer may already have created for their existing app, and otherwise is only responsible for building a `ReactNativeWin32App` with those types properly pre-made * `ReactNativeWin32App::Start()` is now more responsible for the stitching together all of the relevant types to make a working Win32 fabric app * All WinRT APIs without an immediate use-case have been commented out until we are sure they are necessary and that it is safe to expose them * The template has been updated to follow the pattern of: * Use `ReactNativeAppBuilder` to get a `ReactNativeWin32` app with the base WinAppSDK types ready * Get and modify the types as necessary from the created app object (like the `ReactInstanceSettings` and the `AppWindow`) * Call `app.Start()` N/A Verified new apps and example apps in libraryes build and run properly. Should this change be included in the release notes: _yes_ Cleanup ReactNativeAppBuilder and ReactNativeWin32App * Update Guardrails on Provider Instantiation (#13961) * Update Provider Guardrails * Change files * Format * Update Snapshots * Add very basic box-shadow support (#14028) * Add very basic box-shadow support * Change files * Focus should notify island host when tab loop wraps to give host oportunity to take focus (#14026) * Focus should notify island host when tab loop wraps to give host oportunity to take focus * Change files * Default scroll to bring a component into view should have padding around the viewport (#14018) * Default scroll to bring a component into view should have padding around the viewport * Change files * Update focus visuals to use cornerRadius and inner/outer strokes (#14008) * Update focus visuals to use cornerRadius and inner/outer strokes. * Change files * Format * lint fix * Scale focus border for scaleFactor * [Fabric] Get Modal to host RN components in new hwnd (#13500) * save state * add example * build but blank page still :( * clean up comments * visuals show up in new hwnd! * clean up code * better naming and unfork Modal examples * testing save state * Make the RN island a Modal member var * Failed attempt at skipping root view in CEH, leaving it for learning purposes * you can click on UI! * clean up code * Change files * save state * remove hardcoded rootTag * add width/height to example * add test * revert simple.tsx * remove test * update snapshot * feedback part 1: make Modal a RootComponentView * feedback part2: simplify MountChildren * fix deleting modal * feedback round2 * remove comment * remove imports * feedback part 3 * fix overrides * add simple layout - still has issues with padding/flex * feedback part4 * lint * update overrides * Change files * feedback --------- Co-authored-by: Daniel Ayala <[email protected]> * Support accessibilityState 'checked' (#13962) * Implement accessibilityState checked * Change files * Add Testing * Format and Update Snapshots * Adjust Guardrails * Merge * Format * Format * Lint * Change files * Fix Merge Error * Fix issue with prop cloning with custom native props (#14061) * Fix issue with prop cloning with custom native props * format * prettier * Change files --------- Co-authored-by: React-Native-Windows Bot <[email protected]> * change files * Build fixes * fix * fix * snapshot --------- Co-authored-by: Daniel Ayala <[email protected]> Co-authored-by: Jon Thysell <[email protected]> Co-authored-by: Chiara Mooney <[email protected]> Co-authored-by: Tatiana Kapos <[email protected]> Co-authored-by: React-Native-Windows Bot <[email protected]>
1 parent c2cfc96 commit 303dd6f

File tree

70 files changed

+4245
-1825
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+4245
-1825
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "adds default Modal",
4+
"packageName": "@office-iss/react-native-win32",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Implement accessibilityState checked",
4+
"packageName": "@react-native-windows/codegen",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Fix issue with prop cloning with custom native props",
4+
"packageName": "@react-native-windows/codegen",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Update Provider Guardrails",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Implement accessibilityState checked",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "adds default modal that hosts fabric components",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Cleanup ReactNativeAppBuilder and ReactNativeWin32App",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Focus should notify island host when tab loop wraps to give host oportunity to take focus",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Fix issue with prop cloning with custom native props",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Default scroll to bring a component into view should have padding around the viewport",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Add very basic box-shadow support",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Introduced autocapitalize prop in TextInput",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Update focus visuals to use cornerRadius and inner/outer strokes.",
4+
"packageName": "react-native-windows",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

packages/@office-iss/react-native-win32-tester/src/js/utils/RNTesterList.win32.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ const Components: Array<RNTesterModuleInfo> = [
5959
key: 'ImageWin32Test',
6060
module: require('@office-iss/react-native-win32/Libraries/Image/Tests/ImageWin32Test'),
6161
},
62+
{
63+
key: 'ModalExample',
64+
category: 'UI',
65+
module: require('../examples/Modal/ModalExample'),
66+
},
6267
/*
6368
{
6469
key: 'JSResponderHandlerExample',
@@ -68,11 +73,6 @@ const Components: Array<RNTesterModuleInfo> = [
6873
key: 'KeyboardAvoidingViewExample',
6974
module: require('../examples/KeyboardAvoidingView/KeyboardAvoidingViewExample'),
7075
},
71-
{
72-
key: 'ModalExample',
73-
category: 'UI',
74-
module: require('../examples/Modal/ModalExample'),
75-
},
7676
{
7777
key: 'NewAppScreenExample',
7878
module: require('../examples/NewAppScreen/NewAppScreenExample'),

packages/@react-native-windows/codegen/src/generators/GenerateComponentWindows.ts

+19-3
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,14 @@ const headerTemplate = `/*
3838

3939
const propsTemplate = `REACT_STRUCT(::_PROPS_NAME_::)
4040
struct ::_PROPS_NAME_:: : winrt::implements<::_PROPS_NAME_::, winrt::Microsoft::ReactNative::IComponentProps> {
41-
::_PROPS_NAME_::(winrt::Microsoft::ReactNative::ViewProps props) : ViewProps(props) {}
41+
::_PROPS_NAME_::(winrt::Microsoft::ReactNative::ViewProps props, const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom)
42+
: ViewProps(props)
43+
{
44+
if (cloneFrom) {
45+
auto cloneFromProps = cloneFrom.as<::_PROPS_NAME_::>();
46+
::_PROP_INITIALIZERS_::
47+
}
48+
}
4249
4350
void SetProp(uint32_t hash, winrt::hstring propName, winrt::Microsoft::ReactNative::IJSValueReader value) noexcept {
4451
winrt::Microsoft::ReactNative::ReadProp(hash, propName, value, *this);
@@ -144,8 +151,10 @@ void Register::_COMPONENT_NAME_::NativeComponent(
144151
L"::_COMPONENT_NAME_::", [builderCallback](winrt::Microsoft::ReactNative::IReactViewComponentBuilder const &builder) noexcept {
145152
auto compBuilder = builder.as<winrt::Microsoft::ReactNative::Composition::IReactCompositionViewComponentBuilder>();
146153
147-
builder.SetCreateProps(
148-
[](winrt::Microsoft::ReactNative::ViewProps props) noexcept { return winrt::make<::_COMPONENT_NAME_::Props>(props); });
154+
builder.SetCreateProps([](winrt::Microsoft::ReactNative::ViewProps props,
155+
const winrt::Microsoft::ReactNative::IComponentProps& cloneFrom) noexcept {
156+
return winrt::make<::_COMPONENT_NAME_::Props>(props, cloneFrom);
157+
});
149158
150159
builder.SetUpdatePropsHandler([](const winrt::Microsoft::ReactNative::ComponentView &view,
151160
const winrt::Microsoft::ReactNative::IComponentProps &newProps,
@@ -294,6 +303,12 @@ export function createComponentGenerator({
294303
})
295304
.join('\n');
296305

306+
const propInitializers = componentShape.props
307+
.map(prop => {
308+
return ` ${prop.name} = cloneFromProps->${prop.name};`;
309+
})
310+
.join('\n');
311+
297312
const propObjectTypes = propObjectAliases.jobs
298313
.map(propObjectTypeName => {
299314
const propObjectType = propObjectAliases.types[propObjectTypeName]!;
@@ -508,6 +523,7 @@ ${
508523
.replace(/::_EVENT_EMITTER_NAME_::/g, eventEmitterName)
509524
.replace(/::_PROPS_NAME_::/g, propsName)
510525
.replace(/::_COMPONENT_NAME_::/g, componentName)
526+
.replace(/::_PROP_INITIALIZERS_::/g, propInitializers)
511527
.replace(/::_PROPS_FIELDS_::/g, propsFields)
512528
.replace(/::_NAMESPACE_::/g, namespace)
513529
.replace(/\n\n\n+/g, '\n\n');

packages/@react-native-windows/tester/overrides.json

+12
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@
2727
"type": "platform",
2828
"file": "src/js/examples/HTTP/HTTPExampleMultiPartFormData.js"
2929
},
30+
{
31+
"type": "patch",
32+
"file": "src/js/examples/Modal/ModalOnShow.windows.js",
33+
"baseFile": "packages/rn-tester/js/examples/Modal/ModalOnShow.js",
34+
"baseHash": "5098723f16d232ef3c5971a6f153522f42f87f61"
35+
},
36+
{
37+
"type": "patch",
38+
"file": "src/js/examples/Modal/ModalPresentation.windows.js",
39+
"baseFile": "packages/rn-tester/js/examples/Modal/ModalPresentation.js",
40+
"baseHash": "97e0408dad28bd62e6ec22a8454af764d69d8ed5"
41+
},
3042
{
3143
"type": "patch",
3244
"file": "src/js/examples/Pressable/PressableExample.windows.js",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,149 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow strict-local
8+
* @format
9+
*/
10+
11+
import type {RNTesterModuleExample} from '../../types/RNTesterTypes';
12+
13+
import * as React from 'react';
14+
import {Modal, Pressable, StyleSheet, Text, View} from 'react-native';
15+
16+
function ModalOnShowOnDismiss(): React.Node {
17+
const [modalShowComponent, setModalShowComponent] = React.useState(true);
18+
const [modalVisible, setModalVisible] = React.useState(false);
19+
const [onShowCount, setOnShowCount] = React.useState(0);
20+
const [onDismissCount, setOnDismissCount] = React.useState(0);
21+
22+
return (
23+
<View style={styles.container}>
24+
{modalShowComponent && (
25+
<Modal
26+
animationType="slide"
27+
transparent={true}
28+
visible={modalVisible}
29+
onShow={() => {
30+
setOnShowCount(onShowCount + 1);
31+
}}
32+
onDismiss={() => {
33+
setOnDismissCount(onDismissCount + 1);
34+
}}
35+
onRequestClose={() => {
36+
setModalVisible(false);
37+
}}>
38+
<View
39+
style={[
40+
styles.centeredView,
41+
styles.modalBackdrop,
42+
styles.widthHeight,
43+
]}>
44+
<View style={styles.modalView}>
45+
<Text testID="modal-on-show-count">
46+
onShow is called {onShowCount} times
47+
</Text>
48+
<Text testID="modal-on-dismiss-count">
49+
onDismiss is called {onDismissCount} times
50+
</Text>
51+
<Pressable
52+
style={[styles.button, styles.buttonClose]}
53+
onPress={() => setModalVisible(false)}>
54+
<Text testID="dismiss-modal" style={styles.textStyle}>
55+
Hide modal by setting visible to false
56+
</Text>
57+
</Pressable>
58+
<Pressable
59+
style={[styles.button, styles.buttonClose]}
60+
onPress={() => setModalShowComponent(false)}>
61+
<Text
62+
testID="dismiss-modal-by-removing-component"
63+
style={styles.textStyle}>
64+
Hide modal by removing component
65+
</Text>
66+
</Pressable>
67+
</View>
68+
</View>
69+
</Modal>
70+
)}
71+
<Text testID="on-show-count">onShow is called {onShowCount} times</Text>
72+
<Text testID="on-dismiss-count">
73+
onDismiss is called {onDismissCount} times
74+
</Text>
75+
<Pressable
76+
style={[styles.button, styles.buttonOpen]}
77+
onPress={() => {
78+
setModalShowComponent(true);
79+
setModalVisible(true);
80+
}}>
81+
<Text testID="open-modal" style={styles.textStyle}>
82+
Show Modal
83+
</Text>
84+
</Pressable>
85+
</View>
86+
);
87+
}
88+
89+
const styles = StyleSheet.create({
90+
container: {
91+
display: 'flex',
92+
alignItems: 'center',
93+
paddingVertical: 30,
94+
},
95+
centeredView: {
96+
// flex: 1, [Windows]
97+
justifyContent: 'center',
98+
alignItems: 'center',
99+
},
100+
modalBackdrop: {
101+
backgroundColor: 'rgba(0, 0, 0, 0.5)',
102+
},
103+
modalView: {
104+
margin: 20,
105+
backgroundColor: 'white',
106+
borderRadius: 20,
107+
padding: 35,
108+
alignItems: 'center',
109+
shadowColor: '#000',
110+
shadowOffset: {
111+
width: 0,
112+
height: 2,
113+
},
114+
shadowOpacity: 0.25,
115+
shadowRadius: 4,
116+
elevation: 5,
117+
},
118+
button: {
119+
borderRadius: 20,
120+
padding: 10,
121+
marginVertical: 20,
122+
elevation: 2,
123+
},
124+
buttonOpen: {
125+
backgroundColor: '#F194FF',
126+
},
127+
buttonClose: {
128+
backgroundColor: '#2196F3',
129+
},
130+
textStyle: {
131+
color: 'white',
132+
fontWeight: 'bold',
133+
textAlign: 'center',
134+
},
135+
// [Windows
136+
widthHeight: {
137+
width: 300,
138+
height: 400,
139+
},
140+
// Windows]
141+
});
142+
143+
export default ({
144+
title: "Modal's onShow/onDismiss",
145+
name: 'onShow',
146+
description:
147+
'onShow and onDismiss (iOS only) callbacks are called when a modal is shown/dismissed',
148+
render: (): React.Node => <ModalOnShowOnDismiss />,
149+
}: RNTesterModuleExample);

0 commit comments

Comments
 (0)