Skip to content

Commit d66e74f

Browse files
authored
Merge pull request #186 from microsoft/exportEventArgsTypes
Export event args types from Types.tsx as well so they can be mentioned in apps
2 parents 327b300 + bc7b2fb commit d66e74f

File tree

13 files changed

+978
-479
lines changed

13 files changed

+978
-479
lines changed

examplenuget/App.tsx

Lines changed: 3 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -101,57 +101,10 @@ const App = () => {
101101
}}
102102
/>
103103

104-
<Button
105-
onTapped={a => {setShowState(ContentDialogState.Popup);}}
106-
content="click to open a ContentDialog" />
104+
<WinUI.ColorPicker onColorChanged={(e) => {
105+
console.log(e.nativeEvent);
106+
}} />
107107

108-
<ContentDialog
109-
showState={showState}
110-
defaultButton={ContentDialogButton.Close}
111-
title="the title"
112-
content="this is the content"
113-
closeButtonText="close"
114-
primaryButtonText="primary"
115-
secondaryButtonText="secondary"
116-
onPrimaryButtonClick={e => {
117-
alert('primary');
118-
}}
119-
onSecondaryButtonClick={e => {
120-
alert('secondary');
121-
}}
122-
onClosed={e => {
123-
setShowState(ContentDialogState.Hidden)
124-
alert(JSON.stringify(e.nativeEvent.args));
125-
}}
126-
/>
127-
128-
129-
<TextBlock
130-
text="Hello"
131-
onTapped={e => {
132-
MenuFlyout.ShowAt(menu, {point: {x: parseInt(x), y: 42}});
133-
}}
134-
ref={t => {
135-
_tbRef.current = t;
136-
}}
137-
onContextRequested={e => {
138-
const tag = findNodeHandle(_tbRef.current);
139-
140-
const { point, returnValue } = e.nativeEvent.args.TryGetPosition(tag);
141-
MenuFlyout.ShowAt(menu, { point: point });
142-
}}
143-
>
144-
<MenuFlyout
145-
ref={m => {
146-
menu.current = m;
147-
}}
148-
>
149-
<MenuFlyoutItem text="menu option" />
150-
</MenuFlyout>
151-
</TextBlock>
152-
<WinUI.ColorPicker onColorChanged={e => {
153-
alert(JSON.stringify(e.nativeEvent.args.newColor));
154-
}} />
155108
</View>
156109
</ScrollView>
157110
</SafeAreaView>

package/CHANGELOG.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,21 @@
11
{
22
"name": "react-native-xaml",
33
"entries": [
4+
{
5+
"date": "Sun, 20 Feb 2022 03:58:46 GMT",
6+
"tag": "react-native-xaml_v0.0.62",
7+
"version": "0.0.62",
8+
"comments": {
9+
"patch": [
10+
{
11+
"author": "[email protected]",
12+
"package": "react-native-xaml",
13+
"comment": "Export event args types from Types.tsx as well so they can be mentioned in apps",
14+
"commit": "7f9c7f907cf4ca407f0f8a5d41f83722d736f5f4"
15+
}
16+
]
17+
}
18+
},
419
{
520
"date": "Mon, 14 Feb 2022 08:09:35 GMT",
621
"tag": "react-native-xaml_v0.0.61",

package/CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
11
# Change Log - react-native-xaml
22

3-
This log was last generated on Mon, 14 Feb 2022 08:09:35 GMT and should not be manually modified.
3+
This log was last generated on Sun, 20 Feb 2022 03:58:46 GMT and should not be manually modified.
44

55
<!-- Start content -->
66

7+
## 0.0.62
8+
9+
Sun, 20 Feb 2022 03:58:46 GMT
10+
11+
### Patches
12+
13+
- Export event args types from Types.tsx as well so they can be mentioned in apps ([email protected])
14+
715
## 0.0.61
816

917
Mon, 14 Feb 2022 08:09:35 GMT

package/Codegen/TSProps.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public virtual string TransformText()
6060

6161
#line default
6262
#line hidden
63-
this.Write("export namespace ");
63+
this.Write("export namespace Native");
6464

6565
#line 32 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSProps.tt"
6666
this.Write(this.ToStringHelper.ToStringWithCulture(ns));
@@ -74,7 +74,7 @@ public virtual string TransformText()
7474

7575
#line default
7676
#line hidden
77-
this.Write("export type ");
77+
this.Write("export type Native");
7878

7979
#line 34 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSProps.tt"
8080
this.Write(this.ToStringHelper.ToStringWithCulture(Util.ToJsName(t)));
@@ -335,7 +335,7 @@ public virtual string TransformText()
335335
this.Write("?: (event: NativeSyntheticEvent<");
336336

337337
#line 80 "C:\Users\asklar\source\repos\react-native-xaml\package\Codegen\TSProps.tt"
338-
this.Write(this.ToStringHelper.ToStringWithCulture(Util.GetEventArgsTSName(evt)));
338+
this.Write(this.ToStringHelper.ToStringWithCulture(Util.GetEventArgsTSName(evt, "Native")));
339339

340340
#line default
341341
#line hidden

package/Codegen/TSProps.tt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@ export type TypedEvent<TArgs> = {
2929
<# foreach (var t in Util.eventArgsTypes) {
3030
var ns = Util.GetTSNamespace(t);
3131
if (ns != "") { #>
32-
export namespace <#= ns #> {
32+
export namespace Native<#= ns #> {
3333
<# } #>
34-
export type <#= Util.ToJsName(t) #> = {
34+
export type Native<#= Util.ToJsName(t) #> = {
3535
<# foreach (var m in Util.GetEventArgsMethods(t.GetFullName())) { #>
3636
<#= m #>(<#= Util.GetEventArgsMethodArgs(t, m) #>): <#= Util.GetEventArgsMethodReturnType(t, m) #>
3737
<# }
@@ -77,7 +77,7 @@ foreach (var prop in SyntheticProps.Where(p => type == p.DeclaringType)) { #>
7777
<#= Util.ToJsName(attachedDP) #>?: <#= Util.GetTypeScriptType(attachedDP) #>; // attached property
7878
<# }
7979
foreach (var evt in type.GetEvents()) { #>
80-
on<#= evt.GetName() #>?: (event: NativeSyntheticEvent<<#= Util.GetEventArgsTSName(evt) #>>) => void;
80+
on<#= evt.GetName() #>?: (event: NativeSyntheticEvent<<#= Util.GetEventArgsTSName(evt, "Native") #>>) => void;
8181
<# }
8282
foreach (var evt in SyntheticEvents.Where(e => type == e.DeclaringType)) { #>
8383
on<#= evt.Name #>?: (event: NativeSyntheticEvent<<#= Util.GetTypeScriptType(evt) #>>) => void;

0 commit comments

Comments
 (0)