@microsoft/teamsfx-react 3.0.0-alpha.46da7cd00.0 → 3.0.1-alpha.ru6q1vrv0.0
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/LICENSE +21 -21
- package/README.md +6 -0
- package/build/cjs/BaseDashboard.d.ts +54 -0
- package/build/cjs/BaseDashboard.d.ts.map +1 -0
- package/build/cjs/BaseDashboard.js +102 -0
- package/build/cjs/BaseWidget.d.ts +63 -0
- package/build/cjs/BaseWidget.d.ts.map +1 -0
- package/build/cjs/BaseWidget.js +149 -0
- package/build/cjs/index.d.ts +7 -5
- package/build/cjs/index.d.ts.map +1 -1
- package/build/cjs/index.js +20 -16
- package/build/cjs/useData.d.ts +33 -33
- package/build/cjs/useData.js +47 -47
- package/build/cjs/useGraph.d.ts +32 -32
- package/build/cjs/useGraph.js +151 -151
- package/build/cjs/useTeams.d.ts +30 -30
- package/build/cjs/useTeams.js +82 -82
- package/build/cjs/useTeamsFx.d.ts +41 -41
- package/build/cjs/useTeamsFx.js +34 -34
- package/build/cjs/useTeamsUserCredential.d.ts +41 -41
- package/build/cjs/useTeamsUserCredential.js +34 -34
- package/build/esm/BaseDashboard.d.ts +54 -0
- package/build/esm/BaseDashboard.d.ts.map +1 -0
- package/build/esm/BaseDashboard.js +99 -0
- package/build/esm/BaseWidget.d.ts +63 -0
- package/build/esm/BaseWidget.d.ts.map +1 -0
- package/build/esm/BaseWidget.js +146 -0
- package/build/esm/index.d.ts +7 -5
- package/build/esm/index.d.ts.map +1 -1
- package/build/esm/index.js +9 -7
- package/build/esm/useData.d.ts +33 -33
- package/build/esm/useData.js +43 -43
- package/build/esm/useGraph.d.ts +32 -32
- package/build/esm/useGraph.js +146 -146
- package/build/esm/useTeams.d.ts +30 -30
- package/build/esm/useTeams.js +78 -78
- package/build/esm/useTeamsFx.d.ts +41 -41
- package/build/esm/useTeamsFx.js +30 -30
- package/build/esm/useTeamsUserCredential.d.ts +41 -41
- package/build/esm/useTeamsUserCredential.js +30 -30
- package/package.json +6 -5
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
The MIT License (MIT)
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020 Microsoft
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Microsoft
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -141,6 +141,12 @@ const { loading, theme, themeString, teamsUserCredential } = useTeamsUserCredent
|
|
|
141
141
|
This hook function leverage `useData` to call Graph API. It will execute the fetchGraphDataAsync function that the developer passes in first.
|
|
142
142
|
If user has not consented to the scopes of AAD resources, `useGraph()`, `useGraphWithCredential` will automatically call login function to pop up the consent dialog. So, developers can focus on the business logic of how to fetch Microsoft Graph data.
|
|
143
143
|
|
|
144
|
+
### BaseDashboard
|
|
145
|
+
The BaseDashboard is a React component that provides a basic dashboard layout implementation for developers to quickly build a dashboard tab for Microsoft Teams. You can inherit this class and override some methods to customize your own dashboard. For example, define the layout of the widget in your dashboard by overriding the `layout()` method, and customize the dashboard style by overriding the `styling()` method.
|
|
146
|
+
|
|
147
|
+
### BaseWidget
|
|
148
|
+
The BaseWidget is a React component that provides a basic widget layout implementation for developers to quickly build a widget. You can inherit this class and override some methods to customize your own widget. For example, define the header of the widget by overriding the `header()` method, and get data needed for the widget by overriding the `getData()` method, etc.
|
|
149
|
+
|
|
144
150
|
## Next steps
|
|
145
151
|
|
|
146
152
|
Please take a look at the [Samples](https://github.com/OfficeDev/TeamsFx-Samples) project for detailed examples on how to use this library.
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Component, CSSProperties } from "react";
|
|
2
|
+
interface BaseDashboardState {
|
|
3
|
+
isMobile?: boolean;
|
|
4
|
+
showLogin?: boolean;
|
|
5
|
+
observer?: ResizeObserver;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* The base class for dashboard implementation.
|
|
9
|
+
* It's also a react component, for more information about react component, please refer to https://reactjs.org/docs/react-component.html
|
|
10
|
+
* @param P The type of props.
|
|
11
|
+
* @param S The type of state.
|
|
12
|
+
*/
|
|
13
|
+
export declare class BaseDashboard<P, S> extends Component<P, S & BaseDashboardState> {
|
|
14
|
+
private ref;
|
|
15
|
+
/**
|
|
16
|
+
* Constructor for the dashboard class.
|
|
17
|
+
* @param props The properties for the dashboard.
|
|
18
|
+
*/
|
|
19
|
+
constructor(props: Readonly<P>);
|
|
20
|
+
/**
|
|
21
|
+
* This method is invoked immediately after a component is mounted.
|
|
22
|
+
* For more information about react lifecycle, please refer to https://reactjs.org/docs/react-component.html#componentdidmount
|
|
23
|
+
*/
|
|
24
|
+
componentDidMount(): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* This method is invoked immediately when a component will be unmounted. It's a good place to clean up the resources.
|
|
27
|
+
*/
|
|
28
|
+
componentWillUnmount(): void;
|
|
29
|
+
/**
|
|
30
|
+
* Define thie dashboard default layout.
|
|
31
|
+
*/
|
|
32
|
+
render(): JSX.Element;
|
|
33
|
+
/**
|
|
34
|
+
* Override this method to define the layout of the widget in the dashboard.
|
|
35
|
+
*/
|
|
36
|
+
protected layout(): JSX.Element | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Override this method to customize the dashboard style.
|
|
39
|
+
* @returns The style for the dashboard
|
|
40
|
+
*/
|
|
41
|
+
protected styling(): CSSProperties | string;
|
|
42
|
+
/**
|
|
43
|
+
* Construct CSSProperties object for styling the dashboard.
|
|
44
|
+
* @returns CSSProperties object
|
|
45
|
+
*/
|
|
46
|
+
private genStyle;
|
|
47
|
+
/**
|
|
48
|
+
* Construct className string for styling the dashboard.
|
|
49
|
+
* @returns className for styling the dashboard
|
|
50
|
+
*/
|
|
51
|
+
private genClassName;
|
|
52
|
+
}
|
|
53
|
+
export {};
|
|
54
|
+
//# sourceMappingURL=BaseDashboard.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseDashboard.d.ts","sourceRoot":"","sources":["../../src/BaseDashboard.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAexD,UAAU,kBAAkB;IAC1B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED;;;;;GAKG;AACH,qBAAa,aAAa,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,SAAS,CAAC,CAAC,EAAE,CAAC,GAAG,kBAAkB,CAAC;IAC3E,OAAO,CAAC,GAAG,CAAkC;IAE7C;;;OAGG;gBACS,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;IAU9B;;;OAGG;IACG,iBAAiB;IAavB;;OAEG;IACH,oBAAoB,IAAI,IAAI;IAO5B;;OAEG;IACH,MAAM;IAaN;;OAEG;IACH,SAAS,CAAC,MAAM,IAAI,GAAG,CAAC,OAAO,GAAG,SAAS;IAI3C;;;OAGG;IACH,SAAS,CAAC,OAAO,IAAI,aAAa,GAAG,MAAM;IAI3C;;;OAGG;IACH,OAAO,CAAC,QAAQ;IAMhB;;;OAGG;IACH,OAAO,CAAC,YAAY;CAGrB"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseDashboard = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var react_1 = tslib_1.__importStar(require("react"));
|
|
6
|
+
var react_2 = require("@fluentui/react");
|
|
7
|
+
function dashboardStyle(isMobile) {
|
|
8
|
+
return (0, react_2.mergeStyles)(tslib_1.__assign({ display: "grid", gap: "20px", padding: "20px", gridTemplateRows: "1fr", gridTemplateColumns: "4fr 6fr" }, (isMobile === true ? { gridTemplateColumns: "1fr", gridTemplateRows: "1fr" } : {})));
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* The base class for dashboard implementation.
|
|
12
|
+
* It's also a react component, for more information about react component, please refer to https://reactjs.org/docs/react-component.html
|
|
13
|
+
* @param P The type of props.
|
|
14
|
+
* @param S The type of state.
|
|
15
|
+
*/
|
|
16
|
+
var BaseDashboard = /** @class */ (function (_super) {
|
|
17
|
+
tslib_1.__extends(BaseDashboard, _super);
|
|
18
|
+
/**
|
|
19
|
+
* Constructor for the dashboard class.
|
|
20
|
+
* @param props The properties for the dashboard.
|
|
21
|
+
*/
|
|
22
|
+
function BaseDashboard(props) {
|
|
23
|
+
var _this = _super.call(this, props) || this;
|
|
24
|
+
_this.state = {
|
|
25
|
+
isMobile: undefined,
|
|
26
|
+
showLogin: undefined,
|
|
27
|
+
observer: undefined,
|
|
28
|
+
};
|
|
29
|
+
_this.ref = react_1.default.createRef();
|
|
30
|
+
return _this;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* This method is invoked immediately after a component is mounted.
|
|
34
|
+
* For more information about react lifecycle, please refer to https://reactjs.org/docs/react-component.html#componentdidmount
|
|
35
|
+
*/
|
|
36
|
+
BaseDashboard.prototype.componentDidMount = function () {
|
|
37
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
38
|
+
var observer;
|
|
39
|
+
var _this = this;
|
|
40
|
+
return tslib_1.__generator(this, function (_a) {
|
|
41
|
+
observer = new ResizeObserver(function (entries) {
|
|
42
|
+
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
|
43
|
+
var entry = entries_1[_i];
|
|
44
|
+
if (entry.target === _this.ref.current) {
|
|
45
|
+
var width = entry.contentRect.width;
|
|
46
|
+
_this.setState({ isMobile: width < 600 });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
observer.observe(this.ref.current);
|
|
51
|
+
return [2 /*return*/];
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* This method is invoked immediately when a component will be unmounted. It's a good place to clean up the resources.
|
|
57
|
+
*/
|
|
58
|
+
BaseDashboard.prototype.componentWillUnmount = function () {
|
|
59
|
+
// Unobserve the dashboard div for resize events
|
|
60
|
+
if (this.state.observer && this.ref.current) {
|
|
61
|
+
this.state.observer.unobserve(this.ref.current);
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* Define thie dashboard default layout.
|
|
66
|
+
*/
|
|
67
|
+
BaseDashboard.prototype.render = function () {
|
|
68
|
+
var root = dashboardStyle(this.state.isMobile);
|
|
69
|
+
return (react_1.default.createElement("div", { ref: this.ref, className: (0, react_2.mergeStyles)(root, this.genClassName()), style: this.genStyle() }, this.layout()));
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Override this method to define the layout of the widget in the dashboard.
|
|
73
|
+
*/
|
|
74
|
+
BaseDashboard.prototype.layout = function () {
|
|
75
|
+
return undefined;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Override this method to customize the dashboard style.
|
|
79
|
+
* @returns The style for the dashboard
|
|
80
|
+
*/
|
|
81
|
+
BaseDashboard.prototype.styling = function () {
|
|
82
|
+
return {};
|
|
83
|
+
};
|
|
84
|
+
/**
|
|
85
|
+
* Construct CSSProperties object for styling the dashboard.
|
|
86
|
+
* @returns CSSProperties object
|
|
87
|
+
*/
|
|
88
|
+
BaseDashboard.prototype.genStyle = function () {
|
|
89
|
+
return typeof this.styling() === "string"
|
|
90
|
+
? {}
|
|
91
|
+
: this.styling();
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* Construct className string for styling the dashboard.
|
|
95
|
+
* @returns className for styling the dashboard
|
|
96
|
+
*/
|
|
97
|
+
BaseDashboard.prototype.genClassName = function () {
|
|
98
|
+
return typeof this.styling() === "string" ? this.styling() : "";
|
|
99
|
+
};
|
|
100
|
+
return BaseDashboard;
|
|
101
|
+
}(react_1.Component));
|
|
102
|
+
exports.BaseDashboard = BaseDashboard;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Component, CSSProperties } from "react";
|
|
2
|
+
interface BaseWidgetState {
|
|
3
|
+
loading?: boolean;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* The base class for widget implementation. I
|
|
7
|
+
* It's also a react component, for more information about react component, please refer to https://reactjs.org/docs/react-component.html
|
|
8
|
+
* @param P the type of props.
|
|
9
|
+
* @param S the type of state.
|
|
10
|
+
*/
|
|
11
|
+
export declare class BaseWidget<P, S> extends Component<P, S & BaseWidgetState> {
|
|
12
|
+
constructor(props: Readonly<P>);
|
|
13
|
+
/**
|
|
14
|
+
* This method is invoked immediately after a component is mounted.
|
|
15
|
+
* For more information about react lifecycle, please refer to https://reactjs.org/docs/react-component.html#componentdidmount
|
|
16
|
+
*/
|
|
17
|
+
componentDidMount(): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* Define the basic layout of a widget
|
|
20
|
+
*/
|
|
21
|
+
render(): JSX.Element;
|
|
22
|
+
/**
|
|
23
|
+
* Get data required by the widget
|
|
24
|
+
* @returns data for the widget
|
|
25
|
+
*/
|
|
26
|
+
protected getData(): Promise<S>;
|
|
27
|
+
/**
|
|
28
|
+
* Override this method to customize the widget header.
|
|
29
|
+
* @returns JSX component for the widget body
|
|
30
|
+
*/
|
|
31
|
+
protected header(): JSX.Element | undefined;
|
|
32
|
+
/**
|
|
33
|
+
* Override this method to customize the widget body.
|
|
34
|
+
* @returns JSX component for the widget body
|
|
35
|
+
*/
|
|
36
|
+
protected body(): JSX.Element | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Override this method to customize the widget footer.
|
|
39
|
+
* @returns react node for the widget footer
|
|
40
|
+
*/
|
|
41
|
+
protected footer(): JSX.Element | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Override this method to customize what the widget will look like when it is loading.
|
|
44
|
+
*/
|
|
45
|
+
protected loading(): JSX.Element | undefined;
|
|
46
|
+
/**
|
|
47
|
+
* Override this method to customize the widget style.
|
|
48
|
+
* @returns custom style for the widget
|
|
49
|
+
*/
|
|
50
|
+
protected styling(): CSSProperties | string;
|
|
51
|
+
/**
|
|
52
|
+
* Construct CSSProperties object for styling the widget.
|
|
53
|
+
* @returns CSSProperties object
|
|
54
|
+
*/
|
|
55
|
+
private genStyle;
|
|
56
|
+
/**
|
|
57
|
+
* Construct className string for styling the widget.
|
|
58
|
+
* @returns className for styling the widget
|
|
59
|
+
*/
|
|
60
|
+
private genClassName;
|
|
61
|
+
}
|
|
62
|
+
export {};
|
|
63
|
+
//# sourceMappingURL=BaseWidget.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BaseWidget.d.ts","sourceRoot":"","sources":["../../src/BaseWidget.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AA0CxD,UAAU,eAAe;IACvB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED;;;;;GAKG;AACH,qBAAa,UAAU,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,SAAS,CAAC,CAAC,EAAE,CAAC,GAAG,eAAe,CAAC;gBACzD,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;IAK9B;;;OAGG;IACG,iBAAiB;IAIvB;;OAEG;IACH,MAAM;IAiBN;;;OAGG;cACa,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC;IAIrC;;;OAGG;IACH,SAAS,CAAC,MAAM,IAAI,GAAG,CAAC,OAAO,GAAG,SAAS;IAI3C;;;OAGG;IACH,SAAS,CAAC,IAAI,IAAI,GAAG,CAAC,OAAO,GAAG,SAAS;IAIzC;;;OAGG;IACH,SAAS,CAAC,MAAM,IAAI,GAAG,CAAC,OAAO,GAAG,SAAS;IAI3C;;OAEG;IACH,SAAS,CAAC,OAAO,IAAI,GAAG,CAAC,OAAO,GAAG,SAAS;IAI5C;;;OAGG;IACH,SAAS,CAAC,OAAO,IAAI,aAAa,GAAG,MAAM;IAI3C;;;OAGG;IACH,OAAO,CAAC,QAAQ;IAIhB;;;OAGG;IACH,OAAO,CAAC,YAAY;CAGrB"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.BaseWidget = void 0;
|
|
4
|
+
var tslib_1 = require("tslib");
|
|
5
|
+
var react_1 = tslib_1.__importStar(require("react"));
|
|
6
|
+
var react_2 = require("@fluentui/react");
|
|
7
|
+
var react_components_1 = require("@fluentui/react-components");
|
|
8
|
+
var widgetStyle = (0, react_2.mergeStyleSets)({
|
|
9
|
+
root: {
|
|
10
|
+
display: "grid",
|
|
11
|
+
padding: "1.25rem 2rem 1.25rem 2rem",
|
|
12
|
+
backgroundColor: react_components_1.tokens.colorNeutralBackground1,
|
|
13
|
+
border: "1px solid var(--colorTransparentStroke)",
|
|
14
|
+
boxShadow: react_components_1.tokens.shadow4,
|
|
15
|
+
borderRadius: react_components_1.tokens.borderRadiusMedium,
|
|
16
|
+
gap: react_components_1.tokens.spacingHorizontalL,
|
|
17
|
+
gridTemplateRows: "max-content 1fr max-content",
|
|
18
|
+
},
|
|
19
|
+
header: {
|
|
20
|
+
display: "grid",
|
|
21
|
+
height: "max-content",
|
|
22
|
+
"& div": {
|
|
23
|
+
display: "grid",
|
|
24
|
+
gap: react_components_1.tokens.spacingHorizontalS,
|
|
25
|
+
alignItems: "center",
|
|
26
|
+
gridTemplateColumns: "min-content 1fr min-content",
|
|
27
|
+
},
|
|
28
|
+
"& svg": {
|
|
29
|
+
height: "1.5rem",
|
|
30
|
+
width: "1.5rem",
|
|
31
|
+
},
|
|
32
|
+
"& span": {
|
|
33
|
+
fontWeight: react_components_1.tokens.fontWeightSemibold,
|
|
34
|
+
lineHeight: react_components_1.tokens.lineHeightBase200,
|
|
35
|
+
fontSize: react_components_1.tokens.fontSizeBase200,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
footer: {
|
|
39
|
+
"& button": {
|
|
40
|
+
width: "fit-content",
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
/**
|
|
45
|
+
* The base class for widget implementation. I
|
|
46
|
+
* It's also a react component, for more information about react component, please refer to https://reactjs.org/docs/react-component.html
|
|
47
|
+
* @param P the type of props.
|
|
48
|
+
* @param S the type of state.
|
|
49
|
+
*/
|
|
50
|
+
var BaseWidget = /** @class */ (function (_super) {
|
|
51
|
+
tslib_1.__extends(BaseWidget, _super);
|
|
52
|
+
function BaseWidget(props) {
|
|
53
|
+
var _this = _super.call(this, props) || this;
|
|
54
|
+
_this.state = { loading: undefined };
|
|
55
|
+
return _this;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* This method is invoked immediately after a component is mounted.
|
|
59
|
+
* For more information about react lifecycle, please refer to https://reactjs.org/docs/react-component.html#componentdidmount
|
|
60
|
+
*/
|
|
61
|
+
BaseWidget.prototype.componentDidMount = function () {
|
|
62
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
63
|
+
var _a, _b;
|
|
64
|
+
return tslib_1.__generator(this, function (_c) {
|
|
65
|
+
switch (_c.label) {
|
|
66
|
+
case 0:
|
|
67
|
+
_a = this.setState;
|
|
68
|
+
_b = [{}];
|
|
69
|
+
return [4 /*yield*/, this.getData()];
|
|
70
|
+
case 1:
|
|
71
|
+
_a.apply(this, [tslib_1.__assign.apply(void 0, [tslib_1.__assign.apply(void 0, _b.concat([(_c.sent())])), { loading: false }])]);
|
|
72
|
+
return [2 /*return*/];
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Define the basic layout of a widget
|
|
79
|
+
*/
|
|
80
|
+
BaseWidget.prototype.render = function () {
|
|
81
|
+
var root = widgetStyle.root, header = widgetStyle.header, footer = widgetStyle.footer;
|
|
82
|
+
return (react_1.default.createElement("div", { className: (0, react_2.mergeStyles)(root, this.genClassName()), style: this.genStyle() },
|
|
83
|
+
this.header() && react_1.default.createElement("div", { className: header }, this.header()),
|
|
84
|
+
this.state.loading !== false && this.loading() !== undefined ? (this.loading()) : (react_1.default.createElement(react_1.default.Fragment, null,
|
|
85
|
+
this.body() !== undefined && this.body(),
|
|
86
|
+
this.footer() !== undefined && react_1.default.createElement("div", { className: footer }, this.footer())))));
|
|
87
|
+
};
|
|
88
|
+
/**
|
|
89
|
+
* Get data required by the widget
|
|
90
|
+
* @returns data for the widget
|
|
91
|
+
*/
|
|
92
|
+
BaseWidget.prototype.getData = function () {
|
|
93
|
+
return tslib_1.__awaiter(this, void 0, void 0, function () {
|
|
94
|
+
return tslib_1.__generator(this, function (_a) {
|
|
95
|
+
return [2 /*return*/, undefined];
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Override this method to customize the widget header.
|
|
101
|
+
* @returns JSX component for the widget body
|
|
102
|
+
*/
|
|
103
|
+
BaseWidget.prototype.header = function () {
|
|
104
|
+
return undefined;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* Override this method to customize the widget body.
|
|
108
|
+
* @returns JSX component for the widget body
|
|
109
|
+
*/
|
|
110
|
+
BaseWidget.prototype.body = function () {
|
|
111
|
+
return undefined;
|
|
112
|
+
};
|
|
113
|
+
/**
|
|
114
|
+
* Override this method to customize the widget footer.
|
|
115
|
+
* @returns react node for the widget footer
|
|
116
|
+
*/
|
|
117
|
+
BaseWidget.prototype.footer = function () {
|
|
118
|
+
return undefined;
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Override this method to customize what the widget will look like when it is loading.
|
|
122
|
+
*/
|
|
123
|
+
BaseWidget.prototype.loading = function () {
|
|
124
|
+
return undefined;
|
|
125
|
+
};
|
|
126
|
+
/**
|
|
127
|
+
* Override this method to customize the widget style.
|
|
128
|
+
* @returns custom style for the widget
|
|
129
|
+
*/
|
|
130
|
+
BaseWidget.prototype.styling = function () {
|
|
131
|
+
return "";
|
|
132
|
+
};
|
|
133
|
+
/**
|
|
134
|
+
* Construct CSSProperties object for styling the widget.
|
|
135
|
+
* @returns CSSProperties object
|
|
136
|
+
*/
|
|
137
|
+
BaseWidget.prototype.genStyle = function () {
|
|
138
|
+
return typeof this.styling() === "string" ? undefined : this.styling();
|
|
139
|
+
};
|
|
140
|
+
/**
|
|
141
|
+
* Construct className string for styling the widget.
|
|
142
|
+
* @returns className for styling the widget
|
|
143
|
+
*/
|
|
144
|
+
BaseWidget.prototype.genClassName = function () {
|
|
145
|
+
return typeof this.styling() === "string" ? this.styling() : "";
|
|
146
|
+
};
|
|
147
|
+
return BaseWidget;
|
|
148
|
+
}(react_1.Component));
|
|
149
|
+
exports.BaseWidget = BaseWidget;
|
package/build/cjs/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
export { useTeams } from "./useTeams";
|
|
2
|
-
export { useData } from "./useData";
|
|
3
|
-
export { useTeamsFx, TeamsFxContext } from "./useTeamsFx";
|
|
4
|
-
export { useTeamsUserCredential, TeamsContextWithCredential } from "./useTeamsUserCredential";
|
|
5
|
-
export { useGraph, useGraphWithCredential } from "./useGraph";
|
|
1
|
+
export { useTeams } from "./useTeams";
|
|
2
|
+
export { useData } from "./useData";
|
|
3
|
+
export { useTeamsFx, TeamsFxContext } from "./useTeamsFx";
|
|
4
|
+
export { useTeamsUserCredential, TeamsContextWithCredential } from "./useTeamsUserCredential";
|
|
5
|
+
export { useGraph, useGraphWithCredential } from "./useGraph";
|
|
6
|
+
export { BaseDashboard } from "./BaseDashboard";
|
|
7
|
+
export { BaseWidget } from "./BaseWidget";
|
|
6
8
|
//# sourceMappingURL=index.d.ts.map
|
package/build/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAC9F,OAAO,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAC1D,OAAO,EAAE,sBAAsB,EAAE,0BAA0B,EAAE,MAAM,0BAA0B,CAAC;AAC9F,OAAO,EAAE,QAAQ,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC"}
|
package/build/cjs/index.js
CHANGED
|
@@ -1,16 +1,20 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) Microsoft Corporation.
|
|
3
|
-
// Licensed under the MIT license.
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.useGraphWithCredential = exports.useGraph = exports.useTeamsUserCredential = exports.useTeamsFx = exports.useData = exports.useTeams = void 0;
|
|
6
|
-
var useTeams_1 = require("./useTeams");
|
|
7
|
-
Object.defineProperty(exports, "useTeams", { enumerable: true, get: function () { return useTeams_1.useTeams; } });
|
|
8
|
-
var useData_1 = require("./useData");
|
|
9
|
-
Object.defineProperty(exports, "useData", { enumerable: true, get: function () { return useData_1.useData; } });
|
|
10
|
-
var useTeamsFx_1 = require("./useTeamsFx");
|
|
11
|
-
Object.defineProperty(exports, "useTeamsFx", { enumerable: true, get: function () { return useTeamsFx_1.useTeamsFx; } });
|
|
12
|
-
var useTeamsUserCredential_1 = require("./useTeamsUserCredential");
|
|
13
|
-
Object.defineProperty(exports, "useTeamsUserCredential", { enumerable: true, get: function () { return useTeamsUserCredential_1.useTeamsUserCredential; } });
|
|
14
|
-
var useGraph_1 = require("./useGraph");
|
|
15
|
-
Object.defineProperty(exports, "useGraph", { enumerable: true, get: function () { return useGraph_1.useGraph; } });
|
|
16
|
-
Object.defineProperty(exports, "useGraphWithCredential", { enumerable: true, get: function () { return useGraph_1.useGraphWithCredential; } });
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT license.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.BaseWidget = exports.BaseDashboard = exports.useGraphWithCredential = exports.useGraph = exports.useTeamsUserCredential = exports.useTeamsFx = exports.useData = exports.useTeams = void 0;
|
|
6
|
+
var useTeams_1 = require("./useTeams");
|
|
7
|
+
Object.defineProperty(exports, "useTeams", { enumerable: true, get: function () { return useTeams_1.useTeams; } });
|
|
8
|
+
var useData_1 = require("./useData");
|
|
9
|
+
Object.defineProperty(exports, "useData", { enumerable: true, get: function () { return useData_1.useData; } });
|
|
10
|
+
var useTeamsFx_1 = require("./useTeamsFx");
|
|
11
|
+
Object.defineProperty(exports, "useTeamsFx", { enumerable: true, get: function () { return useTeamsFx_1.useTeamsFx; } });
|
|
12
|
+
var useTeamsUserCredential_1 = require("./useTeamsUserCredential");
|
|
13
|
+
Object.defineProperty(exports, "useTeamsUserCredential", { enumerable: true, get: function () { return useTeamsUserCredential_1.useTeamsUserCredential; } });
|
|
14
|
+
var useGraph_1 = require("./useGraph");
|
|
15
|
+
Object.defineProperty(exports, "useGraph", { enumerable: true, get: function () { return useGraph_1.useGraph; } });
|
|
16
|
+
Object.defineProperty(exports, "useGraphWithCredential", { enumerable: true, get: function () { return useGraph_1.useGraphWithCredential; } });
|
|
17
|
+
var BaseDashboard_1 = require("./BaseDashboard");
|
|
18
|
+
Object.defineProperty(exports, "BaseDashboard", { enumerable: true, get: function () { return BaseDashboard_1.BaseDashboard; } });
|
|
19
|
+
var BaseWidget_1 = require("./BaseWidget");
|
|
20
|
+
Object.defineProperty(exports, "BaseWidget", { enumerable: true, get: function () { return BaseWidget_1.BaseWidget; } });
|
package/build/cjs/useData.d.ts
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
type State<T> = {
|
|
2
|
-
/**
|
|
3
|
-
* User data.
|
|
4
|
-
*/
|
|
5
|
-
data?: T;
|
|
6
|
-
/**
|
|
7
|
-
* Status of data loading.
|
|
8
|
-
*/
|
|
9
|
-
loading: boolean;
|
|
10
|
-
/**
|
|
11
|
-
* Error information.
|
|
12
|
-
*/
|
|
13
|
-
error?: unknown;
|
|
14
|
-
};
|
|
15
|
-
export type Data<T> = State<T> & {
|
|
16
|
-
/**
|
|
17
|
-
* reload function.
|
|
18
|
-
*/
|
|
19
|
-
reload: () => void;
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Helper function to fetch data with status and error.
|
|
23
|
-
*
|
|
24
|
-
* @param fetchDataAsync - async function of how to fetch data
|
|
25
|
-
* @param options - if autoLoad is true, reload data immediately
|
|
26
|
-
* @returns data, loading status, error and reload function
|
|
27
|
-
*
|
|
28
|
-
* @beta
|
|
29
|
-
*/
|
|
30
|
-
export declare function useData<T>(fetchDataAsync: () => Promise<T>, options?: {
|
|
31
|
-
autoLoad: boolean;
|
|
32
|
-
}): Data<T>;
|
|
33
|
-
export {};
|
|
1
|
+
type State<T> = {
|
|
2
|
+
/**
|
|
3
|
+
* User data.
|
|
4
|
+
*/
|
|
5
|
+
data?: T;
|
|
6
|
+
/**
|
|
7
|
+
* Status of data loading.
|
|
8
|
+
*/
|
|
9
|
+
loading: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Error information.
|
|
12
|
+
*/
|
|
13
|
+
error?: unknown;
|
|
14
|
+
};
|
|
15
|
+
export type Data<T> = State<T> & {
|
|
16
|
+
/**
|
|
17
|
+
* reload function.
|
|
18
|
+
*/
|
|
19
|
+
reload: () => void;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* Helper function to fetch data with status and error.
|
|
23
|
+
*
|
|
24
|
+
* @param fetchDataAsync - async function of how to fetch data
|
|
25
|
+
* @param options - if autoLoad is true, reload data immediately
|
|
26
|
+
* @returns data, loading status, error and reload function
|
|
27
|
+
*
|
|
28
|
+
* @beta
|
|
29
|
+
*/
|
|
30
|
+
export declare function useData<T>(fetchDataAsync: () => Promise<T>, options?: {
|
|
31
|
+
autoLoad: boolean;
|
|
32
|
+
}): Data<T>;
|
|
33
|
+
export {};
|
|
34
34
|
//# sourceMappingURL=useData.d.ts.map
|
package/build/cjs/useData.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) Microsoft Corporation.
|
|
3
|
-
// Licensed under the MIT license.
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.useData = void 0;
|
|
6
|
-
var react_1 = require("react");
|
|
7
|
-
var createReducer = function () {
|
|
8
|
-
return function (state, action) {
|
|
9
|
-
switch (action.type) {
|
|
10
|
-
case "loading":
|
|
11
|
-
return { data: state.data, loading: true };
|
|
12
|
-
case "result":
|
|
13
|
-
return { data: action.result, loading: false };
|
|
14
|
-
case "error":
|
|
15
|
-
return { loading: false, error: action.error };
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Helper function to fetch data with status and error.
|
|
21
|
-
*
|
|
22
|
-
* @param fetchDataAsync - async function of how to fetch data
|
|
23
|
-
* @param options - if autoLoad is true, reload data immediately
|
|
24
|
-
* @returns data, loading status, error and reload function
|
|
25
|
-
*
|
|
26
|
-
* @beta
|
|
27
|
-
*/
|
|
28
|
-
function useData(fetchDataAsync, options) {
|
|
29
|
-
var _a;
|
|
30
|
-
var auto = (_a = options === null || options === void 0 ? void 0 : options.autoLoad) !== null && _a !== void 0 ? _a : true;
|
|
31
|
-
var _b = (0, react_1.useReducer)(createReducer(), {
|
|
32
|
-
loading: auto,
|
|
33
|
-
}), _c = _b[0], data = _c.data, loading = _c.loading, error = _c.error, dispatch = _b[1];
|
|
34
|
-
function reload() {
|
|
35
|
-
if (!loading)
|
|
36
|
-
dispatch({ type: "loading" });
|
|
37
|
-
fetchDataAsync()
|
|
38
|
-
.then(function (data) { return dispatch({ type: "result", result: data }); })
|
|
39
|
-
.catch(function (error) { return dispatch({ type: "error", error: error }); });
|
|
40
|
-
}
|
|
41
|
-
(0, react_1.useEffect)(function () {
|
|
42
|
-
if (auto)
|
|
43
|
-
reload();
|
|
44
|
-
}, []);
|
|
45
|
-
return { data: data, loading: loading, error: error, reload: reload };
|
|
46
|
-
}
|
|
47
|
-
exports.useData = useData;
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT license.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.useData = void 0;
|
|
6
|
+
var react_1 = require("react");
|
|
7
|
+
var createReducer = function () {
|
|
8
|
+
return function (state, action) {
|
|
9
|
+
switch (action.type) {
|
|
10
|
+
case "loading":
|
|
11
|
+
return { data: state.data, loading: true };
|
|
12
|
+
case "result":
|
|
13
|
+
return { data: action.result, loading: false };
|
|
14
|
+
case "error":
|
|
15
|
+
return { loading: false, error: action.error };
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Helper function to fetch data with status and error.
|
|
21
|
+
*
|
|
22
|
+
* @param fetchDataAsync - async function of how to fetch data
|
|
23
|
+
* @param options - if autoLoad is true, reload data immediately
|
|
24
|
+
* @returns data, loading status, error and reload function
|
|
25
|
+
*
|
|
26
|
+
* @beta
|
|
27
|
+
*/
|
|
28
|
+
function useData(fetchDataAsync, options) {
|
|
29
|
+
var _a;
|
|
30
|
+
var auto = (_a = options === null || options === void 0 ? void 0 : options.autoLoad) !== null && _a !== void 0 ? _a : true;
|
|
31
|
+
var _b = (0, react_1.useReducer)(createReducer(), {
|
|
32
|
+
loading: auto,
|
|
33
|
+
}), _c = _b[0], data = _c.data, loading = _c.loading, error = _c.error, dispatch = _b[1];
|
|
34
|
+
function reload() {
|
|
35
|
+
if (!loading)
|
|
36
|
+
dispatch({ type: "loading" });
|
|
37
|
+
fetchDataAsync()
|
|
38
|
+
.then(function (data) { return dispatch({ type: "result", result: data }); })
|
|
39
|
+
.catch(function (error) { return dispatch({ type: "error", error: error }); });
|
|
40
|
+
}
|
|
41
|
+
(0, react_1.useEffect)(function () {
|
|
42
|
+
if (auto)
|
|
43
|
+
reload();
|
|
44
|
+
}, []);
|
|
45
|
+
return { data: data, loading: loading, error: error, reload: reload };
|
|
46
|
+
}
|
|
47
|
+
exports.useData = useData;
|