@office-iss/react-native-win32 0.0.0-canary.288 → 0.0.0-canary.289

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.
Files changed (59) hide show
  1. package/.flowconfig +3 -2
  2. package/CHANGELOG.json +22 -1
  3. package/CHANGELOG.md +16 -7
  4. package/Libraries/Alert/Alert.d.ts +4 -1
  5. package/Libraries/Alert/Alert.js +3 -0
  6. package/Libraries/Animated/Easing.js +13 -15
  7. package/Libraries/Animated/createAnimatedComponent.js +24 -12
  8. package/Libraries/Animated/nodes/AnimatedNode.js +2 -1
  9. package/Libraries/Animated/nodes/AnimatedProps.js +18 -1
  10. package/Libraries/Animated/nodes/AnimatedValue.js +6 -2
  11. package/Libraries/Blob/URL.js +23 -10
  12. package/Libraries/Components/TextInput/Tests/TextInputTest.d.ts +2 -1
  13. package/Libraries/Components/TextInput/Tests/TextInputTest.js.map +1 -1
  14. package/Libraries/Components/TextInput/TextInput.d.ts +6 -0
  15. package/Libraries/Components/TextInput/TextInput.flow.js +36 -3
  16. package/Libraries/Components/TextInput/TextInput.js +101 -110
  17. package/Libraries/Components/TextInput/TextInput.win32.js +102 -111
  18. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.d.ts +2 -1
  19. package/Libraries/Components/Touchable/Tests/TouchableWin32Test.js.map +1 -1
  20. package/Libraries/Core/ReactNativeVersion.js +2 -2
  21. package/Libraries/Image/Tests/ImageWin32Test.d.ts +2 -1
  22. package/Libraries/Image/Tests/ImageWin32Test.js.map +1 -1
  23. package/Libraries/Interaction/TaskQueue.js +1 -0
  24. package/Libraries/Modal/Modal.js +30 -4
  25. package/Libraries/ReactNative/AppRegistry.flow.js +49 -0
  26. package/Libraries/ReactNative/AppRegistry.js +2 -322
  27. package/Libraries/ReactNative/AppRegistry.js.flow +23 -0
  28. package/Libraries/ReactNative/AppRegistryImpl.js +316 -0
  29. package/Libraries/ReactNative/ReactFabricPublicInstance/ReactFabricPublicInstance.js +1 -4
  30. package/Libraries/StyleSheet/PlatformColorValueTypesIOS.js +6 -0
  31. package/Libraries/StyleSheet/StyleSheet.js +5 -197
  32. package/Libraries/StyleSheet/StyleSheet.js.flow +166 -0
  33. package/Libraries/StyleSheet/{StyleSheet.win32.js → StyleSheetExports.js} +2 -151
  34. package/Libraries/StyleSheet/StyleSheetExports.js.flow +110 -0
  35. package/Libraries/StyleSheet/StyleSheetTypes.js +42 -18
  36. package/Libraries/Types/CodegenTypesNamespace.d.ts +45 -0
  37. package/Libraries/{Modal/ModalInjection.js → Types/CodegenTypesNamespace.js} +4 -5
  38. package/Libraries/Utilities/codegenNativeCommands.d.ts +18 -0
  39. package/Libraries/Utilities/codegenNativeComponent.d.ts +26 -0
  40. package/Libraries/vendor/emitter/EventEmitter.js +6 -2
  41. package/flow/global.js +1 -0
  42. package/flow/jest.js +4 -2
  43. package/index.js +47 -43
  44. package/index.win32.js +60 -55
  45. package/overrides.json +8 -16
  46. package/package.json +14 -14
  47. package/src/private/animated/NativeAnimatedHelper.js +18 -7
  48. package/src/private/animated/NativeAnimatedHelper.win32.js +18 -7
  49. package/src/private/animated/createAnimatedPropsHook.js +34 -15
  50. package/src/private/featureflags/ReactNativeFeatureFlags.js +14 -31
  51. package/src/private/featureflags/ReactNativeFeatureFlagsBase.js +9 -1
  52. package/src/private/featureflags/specs/NativeReactNativeFeatureFlags.js +2 -3
  53. package/src/private/webapis/dom/nodes/ReadOnlyNode.js +5 -18
  54. package/src/private/webapis/dom/nodes/internals/NodeInternals.js +6 -0
  55. package/src/types/third_party/event-target-shim.d.ts +392 -0
  56. package/src-win/Libraries/Components/TextInput/Tests/TextInputTest.tsx +7 -7
  57. package/src-win/Libraries/Components/Touchable/Tests/TouchableWin32Test.tsx +3 -3
  58. package/src-win/Libraries/Image/Tests/ImageWin32Test.tsx +1 -1
  59. package/types/index.d.ts +4 -0
@@ -0,0 +1,392 @@
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
+ * @format
8
+ */
9
+
10
+ export as namespace EventTargetShim;
11
+
12
+ /**
13
+ * `Event` interface.
14
+ * @see https://dom.spec.whatwg.org/#event
15
+ */
16
+ export interface Event {
17
+ /**
18
+ * The type of this event.
19
+ */
20
+ readonly type: string;
21
+
22
+ /**
23
+ * The target of this event.
24
+ */
25
+ readonly target: EventTarget<{}, {}, 'standard'> | null;
26
+
27
+ /**
28
+ * The current target of this event.
29
+ */
30
+ readonly currentTarget: EventTarget<{}, {}, 'standard'> | null;
31
+
32
+ /**
33
+ * The target of this event.
34
+ * @deprecated
35
+ */
36
+ readonly srcElement: any | null;
37
+
38
+ /**
39
+ * The composed path of this event.
40
+ */
41
+ composedPath(): EventTarget<{}, {}, 'standard'>[];
42
+
43
+ /**
44
+ * Constant of NONE.
45
+ */
46
+ readonly NONE: number;
47
+
48
+ /**
49
+ * Constant of CAPTURING_PHASE.
50
+ */
51
+ readonly CAPTURING_PHASE: number;
52
+
53
+ /**
54
+ * Constant of BUBBLING_PHASE.
55
+ */
56
+ readonly BUBBLING_PHASE: number;
57
+
58
+ /**
59
+ * Constant of AT_TARGET.
60
+ */
61
+ readonly AT_TARGET: number;
62
+
63
+ /**
64
+ * Indicates which phase of the event flow is currently being evaluated.
65
+ */
66
+ readonly eventPhase: number;
67
+
68
+ /**
69
+ * Stop event bubbling.
70
+ */
71
+ stopPropagation(): void;
72
+
73
+ /**
74
+ * Stop event bubbling.
75
+ */
76
+ stopImmediatePropagation(): void;
77
+
78
+ /**
79
+ * Initialize event.
80
+ * @deprecated
81
+ */
82
+ initEvent(type: string, bubbles?: boolean, cancelable?: boolean): void;
83
+
84
+ /**
85
+ * The flag indicating bubbling.
86
+ */
87
+ readonly bubbles: boolean;
88
+
89
+ /**
90
+ * Stop event bubbling.
91
+ * @deprecated
92
+ */
93
+ cancelBubble: boolean;
94
+
95
+ /**
96
+ * Set or get cancellation flag.
97
+ * @deprecated
98
+ */
99
+ returnValue: boolean;
100
+
101
+ /**
102
+ * The flag indicating whether the event can be canceled.
103
+ */
104
+ readonly cancelable: boolean;
105
+
106
+ /**
107
+ * Cancel this event.
108
+ */
109
+ preventDefault(): void;
110
+
111
+ /**
112
+ * The flag to indicating whether the event was canceled.
113
+ */
114
+ readonly defaultPrevented: boolean;
115
+
116
+ /**
117
+ * The flag to indicating if event is composed.
118
+ */
119
+ readonly composed: boolean;
120
+
121
+ /**
122
+ * Indicates whether the event was dispatched by the user agent.
123
+ */
124
+ readonly isTrusted: boolean;
125
+
126
+ /**
127
+ * The unix time of this event.
128
+ */
129
+ readonly timeStamp: number;
130
+ }
131
+
132
+ /**
133
+ * The constructor of `EventTarget` interface.
134
+ */
135
+ export type EventTargetConstructor<
136
+ TEvents extends EventTarget.EventDefinition = {},
137
+ TEventAttributes extends EventTarget.EventDefinition = {},
138
+ TMode extends EventTarget.Mode = 'loose',
139
+ > = {
140
+ prototype: EventTarget<TEvents, TEventAttributes, TMode>;
141
+ new (): EventTarget<TEvents, TEventAttributes, TMode>;
142
+ };
143
+
144
+ /**
145
+ * `EventTarget` interface.
146
+ * @see https://dom.spec.whatwg.org/#interface-eventtarget
147
+ */
148
+ export type EventTarget<
149
+ TEvents extends EventTarget.EventDefinition = {},
150
+ TEventAttributes extends EventTarget.EventDefinition = {},
151
+ TMode extends EventTarget.Mode = 'loose',
152
+ > = EventTarget.EventAttributes<TEventAttributes> & {
153
+ /**
154
+ * Add a given listener to this event target.
155
+ * @param eventName The event name to add.
156
+ * @param listener The listener to add.
157
+ * @param options The options for this listener.
158
+ */
159
+ addEventListener<TEventType extends EventTarget.EventType<TEvents, TMode>>(
160
+ type: TEventType,
161
+ listener: EventTarget.Listener<
162
+ EventTarget.PickEvent<TEvents, TEventType>
163
+ > | null,
164
+ options?: boolean | EventTarget.AddOptions,
165
+ ): void;
166
+
167
+ /**
168
+ * Remove a given listener from this event target.
169
+ * @param eventName The event name to remove.
170
+ * @param listener The listener to remove.
171
+ * @param options The options for this listener.
172
+ */
173
+ removeEventListener<TEventType extends EventTarget.EventType<TEvents, TMode>>(
174
+ type: TEventType,
175
+ listener: EventTarget.Listener<
176
+ EventTarget.PickEvent<TEvents, TEventType>
177
+ > | null,
178
+ options?: boolean | EventTarget.RemoveOptions,
179
+ ): void;
180
+
181
+ /**
182
+ * Dispatch a given event.
183
+ * @param event The event to dispatch.
184
+ * @returns `false` if canceled.
185
+ */
186
+ dispatchEvent<TEventType extends EventTarget.EventType<TEvents, TMode>>(
187
+ event: EventTarget.EventData<TEvents, TEventType, TMode>,
188
+ ): boolean;
189
+ };
190
+
191
+ export const EventTarget: EventTargetConstructor & {
192
+ /**
193
+ * Create an `EventTarget` instance with detailed event definition.
194
+ *
195
+ * The detailed event definition requires to use `defineEventAttribute()`
196
+ * function later.
197
+ *
198
+ * Unfortunately, the second type parameter `TEventAttributes` was needed
199
+ * because we cannot compute string literal types.
200
+ *
201
+ * @example
202
+ * const signal = new EventTarget<{ abort: Event }, { onabort: Event }>()
203
+ * defineEventAttribute(signal, "abort")
204
+ */
205
+ new <
206
+ TEvents extends EventTarget.EventDefinition,
207
+ TEventAttributes extends EventTarget.EventDefinition,
208
+ TMode extends EventTarget.Mode = 'loose',
209
+ >(): EventTarget<TEvents, TEventAttributes, TMode>;
210
+
211
+ /**
212
+ * Define an `EventTarget` constructor with attribute events and detailed event definition.
213
+ *
214
+ * Unfortunately, the second type parameter `TEventAttributes` was needed
215
+ * because we cannot compute string literal types.
216
+ *
217
+ * @example
218
+ * class AbortSignal extends EventTarget<{ abort: Event }, { onabort: Event }>("abort") {
219
+ * abort(): void {}
220
+ * }
221
+ *
222
+ * @param events Optional event attributes (e.g. passing in `"click"` adds `onclick` to prototype).
223
+ */
224
+ <
225
+ TEvents extends EventTarget.EventDefinition = {},
226
+ TEventAttributes extends EventTarget.EventDefinition = {},
227
+ TMode extends EventTarget.Mode = 'loose',
228
+ >(
229
+ events: string[],
230
+ ): EventTargetConstructor<TEvents, TEventAttributes, TMode>;
231
+
232
+ /**
233
+ * Define an `EventTarget` constructor with attribute events and detailed event definition.
234
+ *
235
+ * Unfortunately, the second type parameter `TEventAttributes` was needed
236
+ * because we cannot compute string literal types.
237
+ *
238
+ * @example
239
+ * class AbortSignal extends EventTarget<{ abort: Event }, { onabort: Event }>("abort") {
240
+ * abort(): void {}
241
+ * }
242
+ *
243
+ * @param events Optional event attributes (e.g. passing in `"click"` adds `onclick` to prototype).
244
+ */
245
+ <
246
+ TEvents extends EventTarget.EventDefinition = {},
247
+ TEventAttributes extends EventTarget.EventDefinition = {},
248
+ TMode extends EventTarget.Mode = 'loose',
249
+ >(
250
+ event0: string,
251
+ ...events: string[]
252
+ ): EventTargetConstructor<TEvents, TEventAttributes, TMode>;
253
+ };
254
+
255
+ export namespace EventTarget {
256
+ /**
257
+ * Options of `removeEventListener()` method.
258
+ */
259
+ export interface RemoveOptions {
260
+ /**
261
+ * The flag to indicate that the listener is for the capturing phase.
262
+ */
263
+ capture?: boolean | undefined;
264
+ }
265
+
266
+ /**
267
+ * Options of `addEventListener()` method.
268
+ */
269
+ export interface AddOptions extends RemoveOptions {
270
+ /**
271
+ * The flag to indicate that the listener doesn't support
272
+ * `event.preventDefault()` operation.
273
+ */
274
+ passive?: boolean | undefined;
275
+ /**
276
+ * The flag to indicate that the listener will be removed on the first
277
+ * event.
278
+ */
279
+ once?: boolean | undefined;
280
+ }
281
+
282
+ /**
283
+ * The type of regular listeners.
284
+ */
285
+ export interface FunctionListener<TEvent> {
286
+ (event: TEvent): void;
287
+ }
288
+
289
+ /**
290
+ * The type of object listeners.
291
+ */
292
+ export interface ObjectListener<TEvent> {
293
+ handleEvent(event: TEvent): void;
294
+ }
295
+
296
+ /**
297
+ * The type of listeners.
298
+ */
299
+ export type Listener<TEvent> =
300
+ | FunctionListener<TEvent>
301
+ | ObjectListener<TEvent>;
302
+
303
+ /**
304
+ * Event definition.
305
+ */
306
+ export type EventDefinition = {
307
+ readonly [key: string]: Event;
308
+ };
309
+
310
+ /**
311
+ * Mapped type for event attributes.
312
+ */
313
+ export type EventAttributes<TEventAttributes extends EventDefinition> = {
314
+ [P in keyof TEventAttributes]: FunctionListener<TEventAttributes[P]> | null;
315
+ };
316
+
317
+ /**
318
+ * The type of event data for `dispatchEvent()` method.
319
+ */
320
+ export type EventData<
321
+ TEvents extends EventDefinition,
322
+ TEventType extends keyof TEvents | string,
323
+ TMode extends Mode,
324
+ > = TEventType extends keyof TEvents
325
+ ? // Require properties which are not generated automatically.
326
+ Pick<
327
+ TEvents[TEventType],
328
+ Exclude<keyof TEvents[TEventType], OmittableEventKeys>
329
+ > &
330
+ // Properties which are generated automatically are optional.
331
+ Partial<Pick<Event, OmittableEventKeys>>
332
+ : TMode extends 'standard'
333
+ ? Event
334
+ : Event | NonStandardEvent;
335
+
336
+ /**
337
+ * The string literal types of the properties which are generated
338
+ * automatically in `dispatchEvent()` method.
339
+ */
340
+ export type OmittableEventKeys = Exclude<keyof Event, 'type'>;
341
+
342
+ /**
343
+ * The type of event data.
344
+ */
345
+ export type NonStandardEvent = {
346
+ [key: string]: any;
347
+ type: string;
348
+ };
349
+
350
+ /**
351
+ * The type of listeners.
352
+ */
353
+ export type PickEvent<
354
+ TEvents extends EventDefinition,
355
+ TEventType extends keyof TEvents | string,
356
+ > = TEventType extends keyof TEvents ? TEvents[TEventType] : Event;
357
+
358
+ /**
359
+ * Event type candidates.
360
+ */
361
+ export type EventType<
362
+ TEvents extends EventDefinition,
363
+ TMode extends Mode,
364
+ > = TMode extends 'strict' ? keyof TEvents : keyof TEvents | string;
365
+
366
+ /**
367
+ * - `"strict"` ..... Methods don't accept unknown events.
368
+ * `dispatchEvent()` accepts partial objects.
369
+ * - `"loose"` ...... Methods accept unknown events.
370
+ * `dispatchEvent()` accepts partial objects.
371
+ * - `"standard"` ... Methods accept unknown events.
372
+ * `dispatchEvent()` doesn't accept partial objects.
373
+ */
374
+ export type Mode = 'strict' | 'standard' | 'loose';
375
+ }
376
+
377
+ /**
378
+ * Specialized `type` property.
379
+ */
380
+ export type Type<T extends string> = {type: T};
381
+
382
+ /**
383
+ * Define an event attribute (e.g. `eventTarget.onclick`).
384
+ * @param prototype The event target prototype to define an event attribute.
385
+ * @param eventName The event name to define.
386
+ */
387
+ export function defineEventAttribute(
388
+ prototype: EventTarget,
389
+ eventName: string,
390
+ ): void;
391
+
392
+ export default EventTarget;
@@ -114,49 +114,49 @@ export const examples = [
114
114
  {
115
115
  title: 'Autofocus Example',
116
116
  description: 'autoFocus in action',
117
- render(): JSX.Element {
117
+ render() {
118
118
  return (<AutoFocusingTextInputTest />);
119
119
  },
120
120
  },
121
121
  {
122
122
  title: 'Placeholders Example',
123
123
  description: 'placeholder in action',
124
- render(): JSX.Element {
124
+ render() {
125
125
  return (<PlaceholderTextInputTest />);
126
126
  },
127
127
  },
128
128
  {
129
129
  title: 'Controlled Example',
130
130
  description: 'Controlling inputs in action',
131
- render(): JSX.Element {
131
+ render() {
132
132
  return (<ControllingTextInputTest />);
133
133
  },
134
134
  },
135
135
  {
136
136
  title: 'Focus and Blur Example',
137
137
  description: 'onFocus/onBlur in action',
138
- render(): JSX.Element {
138
+ render() {
139
139
  return (<BlurringAndFocusingTextInputTest />);
140
140
  },
141
141
  },
142
142
  {
143
143
  title: 'ContentSizeChange Example',
144
144
  description: 'onContentSizeChange in action',
145
- render(): JSX.Element {
145
+ render() {
146
146
  return (<LayoutListeningTextInputTest />);
147
147
  },
148
148
  },
149
149
  {
150
150
  title: 'Control via onKeyPress Example',
151
151
  description: 'onKeyPress in action',
152
- render(): JSX.Element {
152
+ render() {
153
153
  return (<KeyPressListeningTextInputTest />);
154
154
  },
155
155
  },
156
156
  {
157
157
  title: 'Super Styling Example',
158
158
  description: 'Styling in action',
159
- render(): JSX.Element {
159
+ render() {
160
160
  return (<StyleTextInputTest />);
161
161
  },
162
162
  },
@@ -481,21 +481,21 @@ export const examples = [
481
481
  {
482
482
  title: 'TouchableWithoutFeedback Example',
483
483
  description: 'A simple example implementation of without feedback behavior',
484
- render(): JSX.Element {
484
+ render() {
485
485
  return <TouchableWithoutFeedbackExample />;
486
486
  },
487
487
  },
488
488
  {
489
489
  title: 'TouchableHighlight Example',
490
490
  description: 'A simple example implementation of highlight behavior',
491
- render(): JSX.Element {
491
+ render() {
492
492
  return <TouchableHighlightExample />;
493
493
  },
494
494
  },
495
495
  {
496
496
  title: 'Imperative Focus on TouchableWin32 Example',
497
497
  description: 'A simple example implementation of imperative focus behavior',
498
- render(): JSX.Element {
498
+ render() {
499
499
  return <TouchableFocusExample />;
500
500
  },
501
501
  }
@@ -10,7 +10,7 @@ export const examples = [
10
10
  {
11
11
  title: 'Win32 Image control test',
12
12
  description: 'Test Image',
13
- render(): JSX.Element {
13
+ render() {
14
14
  return (
15
15
  <Image
16
16
  style={ { width: 100, height: 100 } }
package/types/index.d.ts CHANGED
@@ -139,6 +139,7 @@ export * from '../Libraries/StyleSheet/processColor';
139
139
  export * from '../Libraries/Text/Text';
140
140
  export * from '../Libraries/TurboModule/RCTExport';
141
141
  export * as TurboModuleRegistry from '../Libraries/TurboModule/TurboModuleRegistry';
142
+ export * as CodegenTypes from '../Libraries/Types/CodegenTypesNamespace';
142
143
  export * from '../Libraries/Types/CoreEventTypes';
143
144
  export * from '../Libraries/Utilities/Appearance';
144
145
  export * from '../Libraries/Utilities/BackHandler';
@@ -159,5 +160,8 @@ export * from './public/Insets';
159
160
  export * from './public/ReactNativeRenderer';
160
161
  export * from './public/ReactNativeTypes';
161
162
 
163
+ export {default as codegenNativeCommands} from '../Libraries/Utilities/codegenNativeCommands';
164
+ export {default as codegenNativeComponent} from '../Libraries/Utilities/codegenNativeComponent';
165
+
162
166
  // Export platform specific types
163
167
  export * from '../Libraries/platform-types';