Skip to content

Commit

Permalink
Rework EventPhase type to avoid using TS enum (#12908)
Browse files Browse the repository at this point in the history
* Rework EventPhase type to avoid using TS enum

* Change files
  • Loading branch information
acoates-ms authored Apr 9, 2024
1 parent 69b701f commit 80688a3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Rework EventPhase type to avoid using TS enum",
"packageName": "react-native-windows",
"email": "30809111+acoates-ms@users.noreply.github.com",
"dependentChangeType": "patch"
}
24 changes: 14 additions & 10 deletions vnext/src-win/Libraries/Components/View/ViewPropTypes.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,16 +167,16 @@ export interface ViewPropsAndroid {

// [Windows

export enum EventPhase {
None = 0,
Capturing,
AtTarget,
Bubbling,
export namespace EventPhase {
export const None = 0;
export const Capturing = 1;
export const AtTarget = 2;
export const Bubbling = 3;
}

export enum HandledEventPhase {
Capturing = EventPhase.Capturing,
Bubbling = EventPhase.Bubbling,
export namespace HandledEventPhase {
const Capturing = EventPhase.Capturing;
const Bubbling = EventPhase.Bubbling;
}

export interface INativeKeyboardEvent {
Expand All @@ -186,7 +186,11 @@ export interface INativeKeyboardEvent {
shiftKey: boolean;
key: string;
code: string;
eventPhase: EventPhase;
eventPhase:
| EventPhase.None
| EventPhase.Capturing
| EventPhase.AtTarget
| EventPhase.Bubbling;
}

export interface IHandledKeyboardEvent {
Expand All @@ -195,7 +199,7 @@ export interface IHandledKeyboardEvent {
metaKey?: boolean;
shiftKey?: boolean;
code: string;
handledEventPhase?: HandledEventPhase;
handledEventPhase?: EventPhase.Capturing | EventPhase.Bubbling;
}

export type IKeyboardEvent = NativeSyntheticEvent<INativeKeyboardEvent>;
Expand Down

0 comments on commit 80688a3

Please # to comment.