Skip to content

Commit 3e755ca

Browse files
authored
update mgt-react to use wc-react 0.4, react sample is now ts (#888)
1 parent 1d6fd02 commit 3e755ca

File tree

11 files changed

+92
-75
lines changed

11 files changed

+92
-75
lines changed

packages/mgt-react/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@
3333
"dependencies": {
3434
"@microsoft/mgt-components": "*",
3535
"@microsoft/mgt-element": "*",
36-
"@microsoft/microsoft-graph-types": "^1.27.0",
36+
"@microsoft/microsoft-graph-types": "^1.28.0",
3737
"@microsoft/microsoft-graph-types-beta": "github:microsoftgraph/msgraph-typescript-typings#beta",
38-
"wc-react": "^0.3.1"
38+
"wc-react": "^0.4.0"
3939
},
4040
"publishConfig": {
4141
"access": "public"

packages/mgt-react/scripts/generate.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,7 @@ for (const tag of wc.tags) {
4040
className: className
4141
});
4242

43-
const props = {
44-
className: 'string',
45-
id: 'string'
46-
};
43+
const props = {};
4744

4845
for (const prop of tag.properties) {
4946
if (prop.type) {

packages/mgt-react/src/Mgt.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ export class Mgt extends Wc {
3030
public render() {
3131
const tag = this.getTag();
3232
if (!tag) {
33-
throw '"type" must be set!';
33+
throw '"wcType" must be set!';
3434
}
3535

3636
this.processTemplates(this.props.children);
@@ -142,6 +142,6 @@ export class Mgt extends Wc {
142142
*/
143143
export const wrapMgt = <T = WcProps>(tag: string) => {
144144
const component: React.FC<T & React.HTMLAttributes<any>> = (props: T) =>
145-
React.createElement(Mgt, { type: tag, ...props });
145+
React.createElement(Mgt, { wcType: tag, ...props });
146146
return component;
147147
};

packages/mgt-react/src/generated/react.ts

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ import * as MicrosoftGraphBeta from '@microsoft/microsoft-graph-types-beta';
55
import {wrapMgt} from '../Mgt';
66

77
export type AgendaProps = {
8-
className?: string;
9-
id?: string;
108
date?: string;
119
groupId?: string;
1210
days?: number;
@@ -21,8 +19,6 @@ export type AgendaProps = {
2119
}
2220

2321
export type GetProps = {
24-
className?: string;
25-
id?: string;
2622
resource?: string;
2723
scopes?: string[];
2824
version?: string;
@@ -37,8 +33,6 @@ export type GetProps = {
3733
}
3834

3935
export type LoginProps = {
40-
className?: string;
41-
id?: string;
4236
userDetails?: IDynamicPerson;
4337
templateContext?: TemplateContext;
4438
mediaQuery?: ComponentMediaQuery;
@@ -50,8 +44,6 @@ export type LoginProps = {
5044
}
5145

5246
export type PeoplePickerProps = {
53-
className?: string;
54-
id?: string;
5547
groupId?: string;
5648
type?: PersonType;
5749
groupType?: GroupType;
@@ -68,8 +60,6 @@ export type PeoplePickerProps = {
6860
}
6961

7062
export type PeopleProps = {
71-
className?: string;
72-
id?: string;
7363
groupId?: string;
7464
userIds?: string[];
7565
people?: IDynamicPerson[];
@@ -82,8 +72,6 @@ export type PeopleProps = {
8272
}
8373

8474
export type PersonCardProps = {
85-
className?: string;
86-
id?: string;
8775
personDetails?: IDynamicPerson;
8876
personQuery?: string;
8977
userId?: string;
@@ -98,8 +86,6 @@ export type PersonCardProps = {
9886
}
9987

10088
export type PersonProps = {
101-
className?: string;
102-
id?: string;
10389
config?: MgtPersonConfig;
10490
personQuery?: string;
10591
userId?: string;
@@ -122,8 +108,6 @@ export type PersonProps = {
122108
}
123109

124110
export type TasksProps = {
125-
className?: string;
126-
id?: string;
127111
res?: TasksStringResource;
128112
isNewTaskVisible?: boolean;
129113
readOnly?: boolean;
@@ -145,17 +129,13 @@ export type TasksProps = {
145129
}
146130

147131
export type TeamsChannelPickerProps = {
148-
className?: string;
149-
id?: string;
150132
selectedItem?: SelectedChannel;
151133
templateContext?: TemplateContext;
152134
mediaQuery?: ComponentMediaQuery;
153135
selectionChanged?: (e: Event) => void;
154136
}
155137

156138
export type TodoProps = {
157-
className?: string;
158-
id?: string;
159139
taskFilter?: TodoFilter;
160140
readOnly?: boolean;
161141
hideHeader?: boolean;

samples/react-app/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
"version": "1.3.0",
44
"private": true,
55
"dependencies": {
6-
"@microsoft/mgt": "*",
6+
"@microsoft/mgt-element": "*",
77
"@microsoft/mgt-react": "*",
8+
"@microsoft/mgt-msal-provider": "*",
89
"@webcomponents/webcomponentsjs": "2.2.10",
910
"react": "^16.8.5",
1011
"react-app-polyfill": "1.0.1",

samples/react-app/src/App.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

samples/react-app/src/App.tsx

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import React, { Component } from 'react';
2+
import {
3+
Login,
4+
Agenda,
5+
Person,
6+
PeoplePicker,
7+
PersonViewType,
8+
PersonType,
9+
MgtTemplateProps
10+
} from '@microsoft/mgt-react';
11+
import * as MicrosoftGraph from '@microsoft/microsoft-graph-types';
12+
13+
class App extends Component {
14+
render() {
15+
const personDetails = {
16+
displayName: 'Nikola Metulev',
17+
18+
};
19+
20+
return (
21+
<div className="App">
22+
<Login loginCompleted={() => console.log('login completed')} />
23+
<Agenda groupByDay>
24+
<MyEvent template="event" />
25+
</Agenda>
26+
27+
<Person
28+
personDetails={personDetails}
29+
view={PersonViewType.twolines}
30+
className="my-class"
31+
onClick={() => console.log('person clicked')}
32+
line2clicked={() => console.log('line1 clicked')}
33+
/>
34+
35+
<PeoplePicker type={PersonType.any} />
36+
</div>
37+
);
38+
}
39+
}
40+
41+
const MyEvent = (props: MgtTemplateProps) => {
42+
const { event } = props.dataContext as { event: MicrosoftGraph.Event };
43+
return <div>{event.subject}</div>;
44+
};
45+
46+
export default App;

samples/react-app/src/index.js

Lines changed: 0 additions & 24 deletions
This file was deleted.

samples/react-app/src/index.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from 'react';
2+
import ReactDOM from 'react-dom';
3+
import App from './App';
4+
5+
import { Providers, MockProvider } from '@microsoft/mgt-element';
6+
7+
// uncomment to use MSAL provider with your own ClientID (also comment out mock provider below)
8+
// import { MsalProvider } from '@microsoft/mgt-msal-provider';
9+
// Providers.globalProvider = new MsalProvider({ clientId: 'a974dfa0-9f57-49b9-95db-90f04ce2111a' });
10+
11+
Providers.globalProvider = new MockProvider(true);
12+
13+
ReactDOM.render(<App />, document.getElementById('root'));
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/// <reference types="react-scripts" />

0 commit comments

Comments
 (0)