@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
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { TeamsFx } from "@microsoft/teamsfx";
|
|
2
|
-
import { Theme } from "@fluentui/react-components";
|
|
3
|
-
export type TeamsFxContext = {
|
|
4
|
-
/**
|
|
5
|
-
* Instance of TeamsFx.
|
|
6
|
-
*/
|
|
7
|
-
teamsfx?: TeamsFx;
|
|
8
|
-
/**
|
|
9
|
-
* Status of data loading.
|
|
10
|
-
*/
|
|
11
|
-
loading: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Error information.
|
|
14
|
-
*/
|
|
15
|
-
error: unknown;
|
|
16
|
-
/**
|
|
17
|
-
* Indicates that current environment is in Teams
|
|
18
|
-
*/
|
|
19
|
-
inTeams?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Teams theme.
|
|
22
|
-
*/
|
|
23
|
-
theme: Theme;
|
|
24
|
-
/**
|
|
25
|
-
* Teams theme string.
|
|
26
|
-
*/
|
|
27
|
-
themeString: string;
|
|
28
|
-
/**
|
|
29
|
-
* Teams context object.
|
|
30
|
-
*/
|
|
31
|
-
context?: any;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Initialize TeamsFx SDK with customized configuration.
|
|
35
|
-
*
|
|
36
|
-
* @param teamsfxConfig - custom configuration to override default ones.
|
|
37
|
-
* @returns TeamsFxContext object
|
|
38
|
-
*
|
|
39
|
-
* @beta
|
|
40
|
-
*/
|
|
41
|
-
export declare function useTeamsFx(teamsfxConfig?: Record<string, string>): TeamsFxContext;
|
|
1
|
+
import { TeamsFx } from "@microsoft/teamsfx";
|
|
2
|
+
import { Theme } from "@fluentui/react-components";
|
|
3
|
+
export type TeamsFxContext = {
|
|
4
|
+
/**
|
|
5
|
+
* Instance of TeamsFx.
|
|
6
|
+
*/
|
|
7
|
+
teamsfx?: TeamsFx;
|
|
8
|
+
/**
|
|
9
|
+
* Status of data loading.
|
|
10
|
+
*/
|
|
11
|
+
loading: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Error information.
|
|
14
|
+
*/
|
|
15
|
+
error: unknown;
|
|
16
|
+
/**
|
|
17
|
+
* Indicates that current environment is in Teams
|
|
18
|
+
*/
|
|
19
|
+
inTeams?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Teams theme.
|
|
22
|
+
*/
|
|
23
|
+
theme: Theme;
|
|
24
|
+
/**
|
|
25
|
+
* Teams theme string.
|
|
26
|
+
*/
|
|
27
|
+
themeString: string;
|
|
28
|
+
/**
|
|
29
|
+
* Teams context object.
|
|
30
|
+
*/
|
|
31
|
+
context?: any;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Initialize TeamsFx SDK with customized configuration.
|
|
35
|
+
*
|
|
36
|
+
* @param teamsfxConfig - custom configuration to override default ones.
|
|
37
|
+
* @returns TeamsFxContext object
|
|
38
|
+
*
|
|
39
|
+
* @beta
|
|
40
|
+
*/
|
|
41
|
+
export declare function useTeamsFx(teamsfxConfig?: Record<string, string>): TeamsFxContext;
|
|
42
42
|
//# sourceMappingURL=useTeamsFx.d.ts.map
|
package/build/cjs/useTeamsFx.js
CHANGED
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) Microsoft Corporation.
|
|
3
|
-
// Licensed under the MIT license.
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.useTeamsFx = void 0;
|
|
6
|
-
var tslib_1 = require("tslib");
|
|
7
|
-
var teamsfx_1 = require("@microsoft/teamsfx");
|
|
8
|
-
var useTeams_1 = require("./useTeams");
|
|
9
|
-
var useData_1 = require("./useData");
|
|
10
|
-
/**
|
|
11
|
-
* Initialize TeamsFx SDK with customized configuration.
|
|
12
|
-
*
|
|
13
|
-
* @param teamsfxConfig - custom configuration to override default ones.
|
|
14
|
-
* @returns TeamsFxContext object
|
|
15
|
-
*
|
|
16
|
-
* @beta
|
|
17
|
-
*/
|
|
18
|
-
function useTeamsFx(teamsfxConfig) {
|
|
19
|
-
var _this = this;
|
|
20
|
-
var result = (0, useTeams_1.useTeams)({})[0];
|
|
21
|
-
var _a = (0, useData_1.useData)(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
22
|
-
return tslib_1.__generator(this, function (_a) {
|
|
23
|
-
if (process.env.NODE_ENV === "development") {
|
|
24
|
-
(0, teamsfx_1.setLogLevel)(teamsfx_1.LogLevel.Verbose);
|
|
25
|
-
(0, teamsfx_1.setLogFunction)(function (level, message) {
|
|
26
|
-
console.log(message);
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
return [2 /*return*/, new teamsfx_1.TeamsFx(teamsfx_1.IdentityType.User, teamsfxConfig)];
|
|
30
|
-
});
|
|
31
|
-
}); }), data = _a.data, error = _a.error, loading = _a.loading;
|
|
32
|
-
return tslib_1.__assign({ teamsfx: data, error: error, loading: loading }, result);
|
|
33
|
-
}
|
|
34
|
-
exports.useTeamsFx = useTeamsFx;
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT license.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.useTeamsFx = void 0;
|
|
6
|
+
var tslib_1 = require("tslib");
|
|
7
|
+
var teamsfx_1 = require("@microsoft/teamsfx");
|
|
8
|
+
var useTeams_1 = require("./useTeams");
|
|
9
|
+
var useData_1 = require("./useData");
|
|
10
|
+
/**
|
|
11
|
+
* Initialize TeamsFx SDK with customized configuration.
|
|
12
|
+
*
|
|
13
|
+
* @param teamsfxConfig - custom configuration to override default ones.
|
|
14
|
+
* @returns TeamsFxContext object
|
|
15
|
+
*
|
|
16
|
+
* @beta
|
|
17
|
+
*/
|
|
18
|
+
function useTeamsFx(teamsfxConfig) {
|
|
19
|
+
var _this = this;
|
|
20
|
+
var result = (0, useTeams_1.useTeams)({})[0];
|
|
21
|
+
var _a = (0, useData_1.useData)(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
22
|
+
return tslib_1.__generator(this, function (_a) {
|
|
23
|
+
if (process.env.NODE_ENV === "development") {
|
|
24
|
+
(0, teamsfx_1.setLogLevel)(teamsfx_1.LogLevel.Verbose);
|
|
25
|
+
(0, teamsfx_1.setLogFunction)(function (level, message) {
|
|
26
|
+
console.log(message);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return [2 /*return*/, new teamsfx_1.TeamsFx(teamsfx_1.IdentityType.User, teamsfxConfig)];
|
|
30
|
+
});
|
|
31
|
+
}); }), data = _a.data, error = _a.error, loading = _a.loading;
|
|
32
|
+
return tslib_1.__assign({ teamsfx: data, error: error, loading: loading }, result);
|
|
33
|
+
}
|
|
34
|
+
exports.useTeamsFx = useTeamsFx;
|
|
@@ -1,42 +1,42 @@
|
|
|
1
|
-
import { TeamsUserCredentialAuthConfig, TeamsUserCredential } from "@microsoft/teamsfx";
|
|
2
|
-
import { Theme } from "@fluentui/react-components";
|
|
3
|
-
export type TeamsContextWithCredential = {
|
|
4
|
-
/**
|
|
5
|
-
* Instance of TeamsUserCredential.
|
|
6
|
-
*/
|
|
7
|
-
teamsUserCredential?: TeamsUserCredential;
|
|
8
|
-
/**
|
|
9
|
-
* Status of data loading.
|
|
10
|
-
*/
|
|
11
|
-
loading: boolean;
|
|
12
|
-
/**
|
|
13
|
-
* Error information.
|
|
14
|
-
*/
|
|
15
|
-
error: unknown;
|
|
16
|
-
/**
|
|
17
|
-
* Indicates that current environment is in Teams
|
|
18
|
-
*/
|
|
19
|
-
inTeams?: boolean;
|
|
20
|
-
/**
|
|
21
|
-
* Teams theme.
|
|
22
|
-
*/
|
|
23
|
-
theme: Theme;
|
|
24
|
-
/**
|
|
25
|
-
* Teams theme string.
|
|
26
|
-
*/
|
|
27
|
-
themeString: string;
|
|
28
|
-
/**
|
|
29
|
-
* Teams context object.
|
|
30
|
-
*/
|
|
31
|
-
context?: any;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Initialize TeamsFx SDK with customized configuration.
|
|
35
|
-
*
|
|
36
|
-
* @param authConfig - custom configuration to override default ones.
|
|
37
|
-
* @returns TeamsContextWithCredential object
|
|
38
|
-
*
|
|
39
|
-
* @beta
|
|
40
|
-
*/
|
|
41
|
-
export declare function useTeamsUserCredential(authConfig: TeamsUserCredentialAuthConfig): TeamsContextWithCredential;
|
|
1
|
+
import { TeamsUserCredentialAuthConfig, TeamsUserCredential } from "@microsoft/teamsfx";
|
|
2
|
+
import { Theme } from "@fluentui/react-components";
|
|
3
|
+
export type TeamsContextWithCredential = {
|
|
4
|
+
/**
|
|
5
|
+
* Instance of TeamsUserCredential.
|
|
6
|
+
*/
|
|
7
|
+
teamsUserCredential?: TeamsUserCredential;
|
|
8
|
+
/**
|
|
9
|
+
* Status of data loading.
|
|
10
|
+
*/
|
|
11
|
+
loading: boolean;
|
|
12
|
+
/**
|
|
13
|
+
* Error information.
|
|
14
|
+
*/
|
|
15
|
+
error: unknown;
|
|
16
|
+
/**
|
|
17
|
+
* Indicates that current environment is in Teams
|
|
18
|
+
*/
|
|
19
|
+
inTeams?: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Teams theme.
|
|
22
|
+
*/
|
|
23
|
+
theme: Theme;
|
|
24
|
+
/**
|
|
25
|
+
* Teams theme string.
|
|
26
|
+
*/
|
|
27
|
+
themeString: string;
|
|
28
|
+
/**
|
|
29
|
+
* Teams context object.
|
|
30
|
+
*/
|
|
31
|
+
context?: any;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* Initialize TeamsFx SDK with customized configuration.
|
|
35
|
+
*
|
|
36
|
+
* @param authConfig - custom configuration to override default ones.
|
|
37
|
+
* @returns TeamsContextWithCredential object
|
|
38
|
+
*
|
|
39
|
+
* @beta
|
|
40
|
+
*/
|
|
41
|
+
export declare function useTeamsUserCredential(authConfig: TeamsUserCredentialAuthConfig): TeamsContextWithCredential;
|
|
42
42
|
//# sourceMappingURL=useTeamsUserCredential.d.ts.map
|
|
@@ -1,34 +1,34 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Copyright (c) Microsoft Corporation.
|
|
3
|
-
// Licensed under the MIT license.
|
|
4
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.useTeamsUserCredential = void 0;
|
|
6
|
-
var tslib_1 = require("tslib");
|
|
7
|
-
var teamsfx_1 = require("@microsoft/teamsfx");
|
|
8
|
-
var useTeams_1 = require("./useTeams");
|
|
9
|
-
var useData_1 = require("./useData");
|
|
10
|
-
/**
|
|
11
|
-
* Initialize TeamsFx SDK with customized configuration.
|
|
12
|
-
*
|
|
13
|
-
* @param authConfig - custom configuration to override default ones.
|
|
14
|
-
* @returns TeamsContextWithCredential object
|
|
15
|
-
*
|
|
16
|
-
* @beta
|
|
17
|
-
*/
|
|
18
|
-
function useTeamsUserCredential(authConfig) {
|
|
19
|
-
var _this = this;
|
|
20
|
-
var result = (0, useTeams_1.useTeams)({})[0];
|
|
21
|
-
var _a = (0, useData_1.useData)(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
22
|
-
return tslib_1.__generator(this, function (_a) {
|
|
23
|
-
if (process.env.NODE_ENV === "development") {
|
|
24
|
-
(0, teamsfx_1.setLogLevel)(teamsfx_1.LogLevel.Verbose);
|
|
25
|
-
(0, teamsfx_1.setLogFunction)(function (level, message) {
|
|
26
|
-
console.log(message);
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
return [2 /*return*/, new teamsfx_1.TeamsUserCredential(authConfig)];
|
|
30
|
-
});
|
|
31
|
-
}); }), data = _a.data, error = _a.error, loading = _a.loading;
|
|
32
|
-
return tslib_1.__assign({ teamsUserCredential: data, error: error, loading: loading }, result);
|
|
33
|
-
}
|
|
34
|
-
exports.useTeamsUserCredential = useTeamsUserCredential;
|
|
1
|
+
"use strict";
|
|
2
|
+
// Copyright (c) Microsoft Corporation.
|
|
3
|
+
// Licensed under the MIT license.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.useTeamsUserCredential = void 0;
|
|
6
|
+
var tslib_1 = require("tslib");
|
|
7
|
+
var teamsfx_1 = require("@microsoft/teamsfx");
|
|
8
|
+
var useTeams_1 = require("./useTeams");
|
|
9
|
+
var useData_1 = require("./useData");
|
|
10
|
+
/**
|
|
11
|
+
* Initialize TeamsFx SDK with customized configuration.
|
|
12
|
+
*
|
|
13
|
+
* @param authConfig - custom configuration to override default ones.
|
|
14
|
+
* @returns TeamsContextWithCredential object
|
|
15
|
+
*
|
|
16
|
+
* @beta
|
|
17
|
+
*/
|
|
18
|
+
function useTeamsUserCredential(authConfig) {
|
|
19
|
+
var _this = this;
|
|
20
|
+
var result = (0, useTeams_1.useTeams)({})[0];
|
|
21
|
+
var _a = (0, useData_1.useData)(function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
|
|
22
|
+
return tslib_1.__generator(this, function (_a) {
|
|
23
|
+
if (process.env.NODE_ENV === "development") {
|
|
24
|
+
(0, teamsfx_1.setLogLevel)(teamsfx_1.LogLevel.Verbose);
|
|
25
|
+
(0, teamsfx_1.setLogFunction)(function (level, message) {
|
|
26
|
+
console.log(message);
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
return [2 /*return*/, new teamsfx_1.TeamsUserCredential(authConfig)];
|
|
30
|
+
});
|
|
31
|
+
}); }), data = _a.data, error = _a.error, loading = _a.loading;
|
|
32
|
+
return tslib_1.__assign({ teamsUserCredential: data, error: error, loading: loading }, result);
|
|
33
|
+
}
|
|
34
|
+
exports.useTeamsUserCredential = useTeamsUserCredential;
|
|
@@ -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,99 @@
|
|
|
1
|
+
import { __assign, __awaiter, __extends, __generator } from "tslib";
|
|
2
|
+
import React, { Component } from "react";
|
|
3
|
+
import { mergeStyles } from "@fluentui/react";
|
|
4
|
+
function dashboardStyle(isMobile) {
|
|
5
|
+
return mergeStyles(__assign({ display: "grid", gap: "20px", padding: "20px", gridTemplateRows: "1fr", gridTemplateColumns: "4fr 6fr" }, (isMobile === true ? { gridTemplateColumns: "1fr", gridTemplateRows: "1fr" } : {})));
|
|
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
|
+
var BaseDashboard = /** @class */ (function (_super) {
|
|
14
|
+
__extends(BaseDashboard, _super);
|
|
15
|
+
/**
|
|
16
|
+
* Constructor for the dashboard class.
|
|
17
|
+
* @param props The properties for the dashboard.
|
|
18
|
+
*/
|
|
19
|
+
function BaseDashboard(props) {
|
|
20
|
+
var _this = _super.call(this, props) || this;
|
|
21
|
+
_this.state = {
|
|
22
|
+
isMobile: undefined,
|
|
23
|
+
showLogin: undefined,
|
|
24
|
+
observer: undefined,
|
|
25
|
+
};
|
|
26
|
+
_this.ref = React.createRef();
|
|
27
|
+
return _this;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* This method is invoked immediately after a component is mounted.
|
|
31
|
+
* For more information about react lifecycle, please refer to https://reactjs.org/docs/react-component.html#componentdidmount
|
|
32
|
+
*/
|
|
33
|
+
BaseDashboard.prototype.componentDidMount = function () {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
35
|
+
var observer;
|
|
36
|
+
var _this = this;
|
|
37
|
+
return __generator(this, function (_a) {
|
|
38
|
+
observer = new ResizeObserver(function (entries) {
|
|
39
|
+
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
|
40
|
+
var entry = entries_1[_i];
|
|
41
|
+
if (entry.target === _this.ref.current) {
|
|
42
|
+
var width = entry.contentRect.width;
|
|
43
|
+
_this.setState({ isMobile: width < 600 });
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
observer.observe(this.ref.current);
|
|
48
|
+
return [2 /*return*/];
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* This method is invoked immediately when a component will be unmounted. It's a good place to clean up the resources.
|
|
54
|
+
*/
|
|
55
|
+
BaseDashboard.prototype.componentWillUnmount = function () {
|
|
56
|
+
// Unobserve the dashboard div for resize events
|
|
57
|
+
if (this.state.observer && this.ref.current) {
|
|
58
|
+
this.state.observer.unobserve(this.ref.current);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
/**
|
|
62
|
+
* Define thie dashboard default layout.
|
|
63
|
+
*/
|
|
64
|
+
BaseDashboard.prototype.render = function () {
|
|
65
|
+
var root = dashboardStyle(this.state.isMobile);
|
|
66
|
+
return (React.createElement("div", { ref: this.ref, className: mergeStyles(root, this.genClassName()), style: this.genStyle() }, this.layout()));
|
|
67
|
+
};
|
|
68
|
+
/**
|
|
69
|
+
* Override this method to define the layout of the widget in the dashboard.
|
|
70
|
+
*/
|
|
71
|
+
BaseDashboard.prototype.layout = function () {
|
|
72
|
+
return undefined;
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Override this method to customize the dashboard style.
|
|
76
|
+
* @returns The style for the dashboard
|
|
77
|
+
*/
|
|
78
|
+
BaseDashboard.prototype.styling = function () {
|
|
79
|
+
return {};
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Construct CSSProperties object for styling the dashboard.
|
|
83
|
+
* @returns CSSProperties object
|
|
84
|
+
*/
|
|
85
|
+
BaseDashboard.prototype.genStyle = function () {
|
|
86
|
+
return typeof this.styling() === "string"
|
|
87
|
+
? {}
|
|
88
|
+
: this.styling();
|
|
89
|
+
};
|
|
90
|
+
/**
|
|
91
|
+
* Construct className string for styling the dashboard.
|
|
92
|
+
* @returns className for styling the dashboard
|
|
93
|
+
*/
|
|
94
|
+
BaseDashboard.prototype.genClassName = function () {
|
|
95
|
+
return typeof this.styling() === "string" ? this.styling() : "";
|
|
96
|
+
};
|
|
97
|
+
return BaseDashboard;
|
|
98
|
+
}(Component));
|
|
99
|
+
export { 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,146 @@
|
|
|
1
|
+
import { __assign, __awaiter, __extends, __generator } from "tslib";
|
|
2
|
+
import React, { Component } from "react";
|
|
3
|
+
import { mergeStyles, mergeStyleSets } from "@fluentui/react";
|
|
4
|
+
import { tokens } from "@fluentui/react-components";
|
|
5
|
+
var widgetStyle = mergeStyleSets({
|
|
6
|
+
root: {
|
|
7
|
+
display: "grid",
|
|
8
|
+
padding: "1.25rem 2rem 1.25rem 2rem",
|
|
9
|
+
backgroundColor: tokens.colorNeutralBackground1,
|
|
10
|
+
border: "1px solid var(--colorTransparentStroke)",
|
|
11
|
+
boxShadow: tokens.shadow4,
|
|
12
|
+
borderRadius: tokens.borderRadiusMedium,
|
|
13
|
+
gap: tokens.spacingHorizontalL,
|
|
14
|
+
gridTemplateRows: "max-content 1fr max-content",
|
|
15
|
+
},
|
|
16
|
+
header: {
|
|
17
|
+
display: "grid",
|
|
18
|
+
height: "max-content",
|
|
19
|
+
"& div": {
|
|
20
|
+
display: "grid",
|
|
21
|
+
gap: tokens.spacingHorizontalS,
|
|
22
|
+
alignItems: "center",
|
|
23
|
+
gridTemplateColumns: "min-content 1fr min-content",
|
|
24
|
+
},
|
|
25
|
+
"& svg": {
|
|
26
|
+
height: "1.5rem",
|
|
27
|
+
width: "1.5rem",
|
|
28
|
+
},
|
|
29
|
+
"& span": {
|
|
30
|
+
fontWeight: tokens.fontWeightSemibold,
|
|
31
|
+
lineHeight: tokens.lineHeightBase200,
|
|
32
|
+
fontSize: tokens.fontSizeBase200,
|
|
33
|
+
},
|
|
34
|
+
},
|
|
35
|
+
footer: {
|
|
36
|
+
"& button": {
|
|
37
|
+
width: "fit-content",
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
/**
|
|
42
|
+
* The base class for widget implementation. I
|
|
43
|
+
* It's also a react component, for more information about react component, please refer to https://reactjs.org/docs/react-component.html
|
|
44
|
+
* @param P the type of props.
|
|
45
|
+
* @param S the type of state.
|
|
46
|
+
*/
|
|
47
|
+
var BaseWidget = /** @class */ (function (_super) {
|
|
48
|
+
__extends(BaseWidget, _super);
|
|
49
|
+
function BaseWidget(props) {
|
|
50
|
+
var _this = _super.call(this, props) || this;
|
|
51
|
+
_this.state = { loading: undefined };
|
|
52
|
+
return _this;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* This method is invoked immediately after a component is mounted.
|
|
56
|
+
* For more information about react lifecycle, please refer to https://reactjs.org/docs/react-component.html#componentdidmount
|
|
57
|
+
*/
|
|
58
|
+
BaseWidget.prototype.componentDidMount = function () {
|
|
59
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
60
|
+
var _a, _b;
|
|
61
|
+
return __generator(this, function (_c) {
|
|
62
|
+
switch (_c.label) {
|
|
63
|
+
case 0:
|
|
64
|
+
_a = this.setState;
|
|
65
|
+
_b = [{}];
|
|
66
|
+
return [4 /*yield*/, this.getData()];
|
|
67
|
+
case 1:
|
|
68
|
+
_a.apply(this, [__assign.apply(void 0, [__assign.apply(void 0, _b.concat([(_c.sent())])), { loading: false }])]);
|
|
69
|
+
return [2 /*return*/];
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Define the basic layout of a widget
|
|
76
|
+
*/
|
|
77
|
+
BaseWidget.prototype.render = function () {
|
|
78
|
+
var root = widgetStyle.root, header = widgetStyle.header, footer = widgetStyle.footer;
|
|
79
|
+
return (React.createElement("div", { className: mergeStyles(root, this.genClassName()), style: this.genStyle() },
|
|
80
|
+
this.header() && React.createElement("div", { className: header }, this.header()),
|
|
81
|
+
this.state.loading !== false && this.loading() !== undefined ? (this.loading()) : (React.createElement(React.Fragment, null,
|
|
82
|
+
this.body() !== undefined && this.body(),
|
|
83
|
+
this.footer() !== undefined && React.createElement("div", { className: footer }, this.footer())))));
|
|
84
|
+
};
|
|
85
|
+
/**
|
|
86
|
+
* Get data required by the widget
|
|
87
|
+
* @returns data for the widget
|
|
88
|
+
*/
|
|
89
|
+
BaseWidget.prototype.getData = function () {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
91
|
+
return __generator(this, function (_a) {
|
|
92
|
+
return [2 /*return*/, undefined];
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
/**
|
|
97
|
+
* Override this method to customize the widget header.
|
|
98
|
+
* @returns JSX component for the widget body
|
|
99
|
+
*/
|
|
100
|
+
BaseWidget.prototype.header = function () {
|
|
101
|
+
return undefined;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Override this method to customize the widget body.
|
|
105
|
+
* @returns JSX component for the widget body
|
|
106
|
+
*/
|
|
107
|
+
BaseWidget.prototype.body = function () {
|
|
108
|
+
return undefined;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Override this method to customize the widget footer.
|
|
112
|
+
* @returns react node for the widget footer
|
|
113
|
+
*/
|
|
114
|
+
BaseWidget.prototype.footer = function () {
|
|
115
|
+
return undefined;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Override this method to customize what the widget will look like when it is loading.
|
|
119
|
+
*/
|
|
120
|
+
BaseWidget.prototype.loading = function () {
|
|
121
|
+
return undefined;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* Override this method to customize the widget style.
|
|
125
|
+
* @returns custom style for the widget
|
|
126
|
+
*/
|
|
127
|
+
BaseWidget.prototype.styling = function () {
|
|
128
|
+
return "";
|
|
129
|
+
};
|
|
130
|
+
/**
|
|
131
|
+
* Construct CSSProperties object for styling the widget.
|
|
132
|
+
* @returns CSSProperties object
|
|
133
|
+
*/
|
|
134
|
+
BaseWidget.prototype.genStyle = function () {
|
|
135
|
+
return typeof this.styling() === "string" ? undefined : this.styling();
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Construct className string for styling the widget.
|
|
139
|
+
* @returns className for styling the widget
|
|
140
|
+
*/
|
|
141
|
+
BaseWidget.prototype.genClassName = function () {
|
|
142
|
+
return typeof this.styling() === "string" ? this.styling() : "";
|
|
143
|
+
};
|
|
144
|
+
return BaseWidget;
|
|
145
|
+
}(Component));
|
|
146
|
+
export { BaseWidget };
|