@office-iss/react-native-win32 0.66.4 → 0.66.5

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 CHANGED
@@ -26,6 +26,8 @@
26
26
  <PROJECT_ROOT>/Libraries/Pressability/Pressability.js
27
27
  <PROJECT_ROOT>/Libraries/Pressability/HoverState.js
28
28
  <PROJECT_ROOT>/Libraries/StyleSheet/StyleSheet.js
29
+ <PROJECT_ROOT>/Libraries/Text/Text.js
30
+ <PROJECT_ROOT>/Libraries/Text/TextNativeComponent.js
29
31
  <PROJECT_ROOT>/Libraries/Types/CoreEventTypes.js
30
32
  <PROJECT_ROOT>/Libraries/Utilities/DeviceInfo.js
31
33
  <PROJECT_ROOT>/Libraries/Utilities/Dimensions.js
package/CHANGELOG.json CHANGED
@@ -2,7 +2,22 @@
2
2
  "name": "@office-iss/react-native-win32",
3
3
  "entries": [
4
4
  {
5
- "date": "Mon, 24 Jan 2022 16:10:41 GMT",
5
+ "date": "Mon, 21 Feb 2022 16:09:24 GMT",
6
+ "tag": "@office-iss/react-native-win32_v0.66.5",
7
+ "version": "0.66.5",
8
+ "comments": {
9
+ "patch": [
10
+ {
11
+ "comment": "forward isPressble to native text component",
12
+ "author": "30809111+acoates-ms@users.noreply.github.com",
13
+ "commit": "12e82b184f7f78aa1fcfbe3dd700daef70257356",
14
+ "package": "@office-iss/react-native-win32"
15
+ }
16
+ ]
17
+ }
18
+ },
19
+ {
20
+ "date": "Mon, 24 Jan 2022 16:11:33 GMT",
6
21
  "tag": "@office-iss/react-native-win32_v0.66.4",
7
22
  "version": "0.66.4",
8
23
  "comments": {
package/CHANGELOG.md CHANGED
@@ -1,17 +1,25 @@
1
1
  # Change Log - @office-iss/react-native-win32
2
2
 
3
- This log was last generated on Mon, 24 Jan 2022 16:10:41 GMT and should not be manually modified.
3
+ This log was last generated on Mon, 21 Feb 2022 16:09:24 GMT and should not be manually modified.
4
4
 
5
5
  <!-- Start content -->
6
6
 
7
- ## 0.66.4
7
+ ## 0.66.5
8
8
 
9
- Mon, 24 Jan 2022 16:10:41 GMT
9
+ Mon, 21 Feb 2022 16:09:24 GMT
10
10
 
11
11
  ### Patches
12
12
 
13
- - Promote 0.66 to legacy (ngerlem@microsoft.com)
13
+ - forward isPressble to native text component (30809111+acoates-ms@users.noreply.github.com)
14
14
 
15
+ ## 0.66.4
16
+
17
+ Mon, 24 Jan 2022 16:11:33 GMT
18
+
19
+ ### Patches
20
+
21
+ - Promote 0.66 to legacy (ngerlem@microsoft.com)
22
+
15
23
  ## 0.66.3
16
24
 
17
25
  Mon, 17 Jan 2022 16:12:35 GMT
@@ -0,0 +1,214 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its 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 DeprecatedTextPropTypes from '../DeprecatedPropTypes/DeprecatedTextPropTypes';
12
+ import * as PressabilityDebug from '../Pressability/PressabilityDebug';
13
+ import usePressability from '../Pressability/usePressability';
14
+ import StyleSheet from '../StyleSheet/StyleSheet';
15
+ import processColor from '../StyleSheet/processColor';
16
+ import TextAncestor from './TextAncestor';
17
+ import {NativeText, NativeVirtualText} from './TextNativeComponent';
18
+ import {type TextProps} from './TextProps';
19
+ import * as React from 'react';
20
+ import {useContext, useMemo, useState} from 'react';
21
+ import invariant from 'invariant';
22
+
23
+ /**
24
+ * Text is the fundamental component for displaying text.
25
+ *
26
+ * @see https://reactnative.dev/docs/text.html
27
+ */
28
+ const Text: React.AbstractComponent<
29
+ TextProps,
30
+ React.ElementRef<typeof NativeText | typeof NativeVirtualText>,
31
+ > = React.forwardRef((props: TextProps, forwardedRef) => {
32
+ const {
33
+ accessible,
34
+ allowFontScaling,
35
+ ellipsizeMode,
36
+ onLongPress,
37
+ onPress,
38
+ onPressIn,
39
+ onPressOut,
40
+ onResponderGrant,
41
+ onResponderMove,
42
+ onResponderRelease,
43
+ onResponderTerminate,
44
+ onResponderTerminationRequest,
45
+ onStartShouldSetResponder,
46
+ pressRetentionOffset,
47
+ suppressHighlighting,
48
+ ...restProps
49
+ } = props;
50
+
51
+ const [isHighlighted, setHighlighted] = useState(false);
52
+
53
+ const isPressable =
54
+ (onPress != null ||
55
+ onLongPress != null ||
56
+ onStartShouldSetResponder != null) &&
57
+ restProps.disabled !== true;
58
+
59
+ const initialized = useLazyInitialization(isPressable);
60
+ const config = useMemo(
61
+ () =>
62
+ initialized
63
+ ? {
64
+ disabled: !isPressable,
65
+ pressRectOffset: pressRetentionOffset,
66
+ onLongPress,
67
+ onPress,
68
+ onPressIn(event) {
69
+ setHighlighted(!suppressHighlighting);
70
+ onPressIn?.(event);
71
+ },
72
+ onPressOut(event) {
73
+ setHighlighted(false);
74
+ onPressOut?.(event);
75
+ },
76
+ onResponderTerminationRequest_DEPRECATED: onResponderTerminationRequest,
77
+ onStartShouldSetResponder_DEPRECATED: onStartShouldSetResponder,
78
+ }
79
+ : null,
80
+ [
81
+ initialized,
82
+ isPressable,
83
+ pressRetentionOffset,
84
+ onLongPress,
85
+ onPress,
86
+ onPressIn,
87
+ onPressOut,
88
+ onResponderTerminationRequest,
89
+ onStartShouldSetResponder,
90
+ suppressHighlighting,
91
+ ],
92
+ );
93
+
94
+ const eventHandlers = usePressability(config);
95
+ const eventHandlersForText = useMemo(
96
+ () =>
97
+ eventHandlers == null
98
+ ? null
99
+ : {
100
+ onResponderGrant(event) {
101
+ eventHandlers.onResponderGrant(event);
102
+ if (onResponderGrant != null) {
103
+ onResponderGrant(event);
104
+ }
105
+ },
106
+ onResponderMove(event) {
107
+ eventHandlers.onResponderMove(event);
108
+ if (onResponderMove != null) {
109
+ onResponderMove(event);
110
+ }
111
+ },
112
+ onResponderRelease(event) {
113
+ eventHandlers.onResponderRelease(event);
114
+ if (onResponderRelease != null) {
115
+ onResponderRelease(event);
116
+ }
117
+ },
118
+ onResponderTerminate(event) {
119
+ eventHandlers.onResponderTerminate(event);
120
+ if (onResponderTerminate != null) {
121
+ onResponderTerminate(event);
122
+ }
123
+ },
124
+ onResponderTerminationRequest:
125
+ eventHandlers.onResponderTerminationRequest,
126
+ onStartShouldSetResponder: eventHandlers.onStartShouldSetResponder,
127
+ },
128
+ [
129
+ eventHandlers,
130
+ onResponderGrant,
131
+ onResponderMove,
132
+ onResponderRelease,
133
+ onResponderTerminate,
134
+ ],
135
+ );
136
+
137
+ // TODO: Move this processing to the view configuration.
138
+ const selectionColor =
139
+ restProps.selectionColor == null
140
+ ? null
141
+ : processColor(restProps.selectionColor);
142
+
143
+ let style = restProps.style;
144
+ if (__DEV__) {
145
+ if (PressabilityDebug.isEnabled() && onPress != null) {
146
+ style = StyleSheet.compose(restProps.style, {
147
+ color: 'magenta',
148
+ });
149
+ }
150
+ }
151
+
152
+ let numberOfLines = restProps.numberOfLines;
153
+ if (numberOfLines != null && !(numberOfLines >= 0)) {
154
+ console.error(
155
+ `'numberOfLines' in <Text> must be a non-negative number, received: ${numberOfLines}. The value will be set to 0.`,
156
+ );
157
+ numberOfLines = 0;
158
+ }
159
+
160
+ const hasTextAncestor = useContext(TextAncestor);
161
+
162
+ return hasTextAncestor ? (
163
+ <NativeVirtualText
164
+ {...restProps}
165
+ {...eventHandlersForText}
166
+ isHighlighted={isHighlighted}
167
+ isPressable={isPressable} // This was added upstream in https://github.com/facebook/react-native/commit/f3bf2e4f51897f1bb71e37002c288ebf3b23cf78
168
+ numberOfLines={numberOfLines}
169
+ selectionColor={selectionColor}
170
+ style={style}
171
+ ref={forwardedRef}
172
+ />
173
+ ) : (
174
+ <TextAncestor.Provider value={true}>
175
+ <NativeText
176
+ {...restProps}
177
+ {...eventHandlersForText}
178
+ accessible={accessible !== false}
179
+ allowFontScaling={allowFontScaling !== false}
180
+ ellipsizeMode={ellipsizeMode ?? 'tail'}
181
+ isHighlighted={isHighlighted}
182
+ isPressable={isPressable} // [Win32] - We use this to optimize text hit testing
183
+ numberOfLines={numberOfLines}
184
+ selectionColor={selectionColor}
185
+ style={style}
186
+ ref={forwardedRef}
187
+ />
188
+ </TextAncestor.Provider>
189
+ );
190
+ });
191
+
192
+ Text.displayName = 'Text';
193
+
194
+ // TODO: Delete this.
195
+ Text.propTypes = DeprecatedTextPropTypes;
196
+
197
+ /**
198
+ * Returns false until the first time `newValue` is true, after which this will
199
+ * always return true. This is necessary to lazily initialize `Pressability` so
200
+ * we do not eagerly create one for every pressable `Text` component.
201
+ */
202
+ function useLazyInitialization(newValue: boolean): boolean {
203
+ const [oldValue, setValue] = useState(newValue);
204
+ if (!oldValue && newValue) {
205
+ setValue(newValue);
206
+ }
207
+ return oldValue;
208
+ }
209
+
210
+ // $FlowFixMe[incompatible-cast] - No good way to type a React.AbstractComponent with statics.
211
+ module.exports = (Text: typeof Text &
212
+ $ReadOnly<{
213
+ propTypes: typeof DeprecatedTextPropTypes,
214
+ }>);
@@ -1,3 +1,13 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its 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
8
+ * @format
9
+ */
10
+
1
11
  import ReactNativeViewAttributes from '../Components/View/ReactNativeViewAttributes';
2
12
  import UIManager from '../ReactNative/UIManager';
3
13
  import {type HostComponent} from '../Renderer/shims/ReactNativeTypes';
@@ -9,6 +19,10 @@ type NativeTextProps = $ReadOnly<{
9
19
  ...TextProps,
10
20
  isHighlighted?: ?boolean,
11
21
  selectionColor?: ?ProcessedColorValue,
22
+ // This is only needed for platforms that optimize text hit testing, e.g.,
23
+ // react-native-windows. It can be used to only hit test virtual text spans
24
+ // that have pressable events attached to them.
25
+ isPressable?: ?boolean,
12
26
  }>;
13
27
 
14
28
  export const NativeText: HostComponent<NativeTextProps> = (createReactNativeComponentClass(
@@ -18,6 +32,7 @@ export const NativeText: HostComponent<NativeTextProps> = (createReactNativeComp
18
32
  validAttributes: {
19
33
  ...ReactNativeViewAttributes.UIView,
20
34
  isHighlighted: true,
35
+ isPressable: true,
21
36
  numberOfLines: true,
22
37
  ellipsizeMode: true,
23
38
  allowFontScaling: true,
@@ -53,14 +68,14 @@ export const NativeText: HostComponent<NativeTextProps> = (createReactNativeComp
53
68
  ): any);
54
69
 
55
70
  export const NativeVirtualText: HostComponent<NativeTextProps> =
56
- !global.RN$Bridgeless &&
57
- UIManager.getViewManagerConfig('RCTVirtualText') == null
71
+ !global.RN$Bridgeless && !UIManager.hasViewManagerConfig('RCTVirtualText')
58
72
  ? NativeText
59
73
  : (createReactNativeComponentClass('RCTVirtualText', () => ({
60
74
  // $FlowFixMe[incompatible-call]
61
75
  validAttributes: {
62
76
  ...ReactNativeViewAttributes.UIView,
63
77
  isHighlighted: true,
78
+ isPressable: true,
64
79
  maxFontSizeMultiplier: true,
65
80
  },
66
81
  uiViewClassName: 'RCTVirtualText',
package/overrides.json CHANGED
@@ -445,7 +445,14 @@
445
445
  "baseHash": "afe4fc1e9aa91d08a7a1098e3bbd3b17a73b4a65"
446
446
  },
447
447
  {
448
- "type": "derived",
448
+ "type": "patch",
449
+ "file": "src/Libraries/Text/Text.win32.js",
450
+ "baseFile": "Libraries/Text/Text.js",
451
+ "baseHash": "8b90eb090dcfed88a40a38bbb51cbbd1e0d9ca9e",
452
+ "issue": 7074
453
+ },
454
+ {
455
+ "type": "patch",
449
456
  "file": "src/Libraries/Text/TextNativeComponent.win32.js",
450
457
  "baseFile": "Libraries/Text/TextNativeComponent.js",
451
458
  "baseHash": "1a196691fb0e9b656c348b7d42427c1c6163c9bb",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@office-iss/react-native-win32",
3
- "version": "0.66.4",
3
+ "version": "0.66.5",
4
4
  "description": "Implementation of react native on top of Office's Win32 platform.",
5
5
  "license": "MIT",
6
6
  "main": "./index.win32.js",