@microsoft/teamsfx-react 3.0.1-alpha.ru6q1vrv0.0 → 3.0.1-beta.2023071206.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.
Files changed (41) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +73 -2
  3. package/build/cjs/BaseDashboard.d.ts +60 -53
  4. package/build/cjs/BaseDashboard.d.ts.map +1 -1
  5. package/build/cjs/BaseDashboard.js +91 -102
  6. package/build/cjs/BaseWidget.d.ts +94 -62
  7. package/build/cjs/BaseWidget.d.ts.map +1 -1
  8. package/build/cjs/BaseWidget.js +158 -149
  9. package/build/cjs/index.d.ts +7 -7
  10. package/build/cjs/index.d.ts.map +1 -1
  11. package/build/cjs/index.js +20 -20
  12. package/build/cjs/useData.d.ts +33 -33
  13. package/build/cjs/useData.js +47 -47
  14. package/build/cjs/useGraph.d.ts +32 -32
  15. package/build/cjs/useGraph.js +151 -151
  16. package/build/cjs/useTeams.d.ts +30 -30
  17. package/build/cjs/useTeams.js +82 -82
  18. package/build/cjs/useTeamsFx.d.ts +41 -41
  19. package/build/cjs/useTeamsFx.js +34 -34
  20. package/build/cjs/useTeamsUserCredential.d.ts +41 -41
  21. package/build/cjs/useTeamsUserCredential.js +34 -34
  22. package/build/esm/BaseDashboard.d.ts +60 -53
  23. package/build/esm/BaseDashboard.d.ts.map +1 -1
  24. package/build/esm/BaseDashboard.js +88 -99
  25. package/build/esm/BaseWidget.d.ts +94 -62
  26. package/build/esm/BaseWidget.d.ts.map +1 -1
  27. package/build/esm/BaseWidget.js +155 -146
  28. package/build/esm/index.d.ts +7 -7
  29. package/build/esm/index.d.ts.map +1 -1
  30. package/build/esm/index.js +9 -9
  31. package/build/esm/useData.d.ts +33 -33
  32. package/build/esm/useData.js +43 -43
  33. package/build/esm/useGraph.d.ts +32 -32
  34. package/build/esm/useGraph.js +146 -146
  35. package/build/esm/useTeams.d.ts +30 -30
  36. package/build/esm/useTeams.js +78 -78
  37. package/build/esm/useTeamsFx.d.ts +41 -41
  38. package/build/esm/useTeamsFx.js +30 -30
  39. package/build/esm/useTeamsUserCredential.d.ts +41 -41
  40. package/build/esm/useTeamsUserCredential.js +30 -30
  41. package/package.json +12 -10
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
@@ -34,10 +34,19 @@ npm install @microsoft/teamsfx-react
34
34
 
35
35
  Please also install the peer dependencies if you are using npm 6.
36
36
  ```bash
37
- npm install @microsoft/teamsfx@^2.0.0 @microsoft/teams-js@^2.0.0 react@^16.8.6 react-dom@^16.8.6 @fluentui/react-northstar@^0.62.0 msteams-react-base-component@^3.1.1
37
+ npm install @microsoft/teamsfx@^2.0.0 @microsoft/teams-js@^2.0.0 react@^18.2.0 react-dom@^18.2.0 @fluentui/react-components@^9.16.0 @microsoft/microsoft-graph-client@^3.0.1
38
38
  ```
39
39
 
40
- Note that for `@microsoft/teamsfx-react@^2.0.0`, it depends on `@microsoft/teamsfx@^2.0.0` and `@microsoft/teams-js@^2.0.0`. If you wish to use lower versions, please install the peer dependencies as follows:
40
+ #### Note
41
+
42
+ For `@microsoft/teamsfx-react@^3.0.0`, it migrated to use `@fluentui/react-components` and did not support `@fluentui/react-northstar` any longer. If you still wish to use `@fluentui/react-northstar`, please use `@microsoft/teamsfx-react@<3.0.0`. To install the peer dependencies, you could use the following line:
43
+
44
+ ```bash
45
+ npm install @microsoft/teamsfx@^2.0.0 @microsoft/teams-js@^2.0.0 react@^16.8.6 react-dom@^16.8.6 @fluentui/react-northstar@^0.62.0 @microsoft/microsoft-graph-client@^3.0.1
46
+ ```
47
+
48
+ For `@microsoft/teamsfx-react@^2.0.0` and `@microsoft/teamsfx-react@^3.0.0`, they depend on `@microsoft/teamsfx@^2.0.0` and `@microsoft/teams-js@^2.0.0`. If you wish to use lower versions, please install the peer dependencies as follows:
49
+
41
50
  ```bash
42
51
  npm install @microsoft/teamsfx@^0.6.0 react@^16.8.6 @fluentui/react-northstar@^0.60.1 msteams-react-base-component@^3.1.1
43
52
  ```
@@ -111,6 +120,66 @@ return (
111
120
  );
112
121
  ```
113
122
 
123
+ ### Building a Dashboard Tab
124
+
125
+ #### 1. Create a new widget
126
+
127
+ Here is an example of creating a new widget:
128
+
129
+ ```tsx
130
+ import { Button, Text } from "@fluentui/react-components";
131
+ import { BaseWidget } from "@microsoft/teamsfx-react";
132
+ import { SampleModel } from "../models/sampleModel";
133
+ import { getSampleData } from "../services/sampleService";
134
+
135
+ interface SampleWidgetState {
136
+ data?: SampleModel;
137
+ }
138
+
139
+ export class SampleWidget extends BaseWidget<any, SampleWidgetState> {
140
+ override async getData(): Promise<SampleWidgetState> {
141
+ return { data: getSampleData() };
142
+ }
143
+
144
+ override header(): JSX.Element | undefined {
145
+ return <Text>Sample Widget</Text>;
146
+ }
147
+
148
+ override body(): JSX.Element | undefined {
149
+ return <div>{this.state.data?.content}</div>;
150
+ }
151
+
152
+ override footer(): JSX.Element | undefined {
153
+ return <Button>View Details</Button>;
154
+ }
155
+ }
156
+ ```
157
+
158
+ #### 2. Create a new dashboard
159
+
160
+ Here is an example of creating a new dashboard:
161
+
162
+ ```tsx
163
+ import { BaseDashboard } from "@microsoft/teamsfx-react";
164
+ import ListWidget from "../widgets/ListWidget";
165
+ import ChartWidget from "../widgets/ChartWidget";
166
+
167
+ export default class YourDashboard extends BaseDashboard<any, any> {
168
+ override styling(): string {
169
+ return "styling-class-name";
170
+ }
171
+
172
+ override layout(): JSX.Element | undefined {
173
+ return (
174
+ <>
175
+ <ListWidget />
176
+ <ChartWidget />
177
+ </>
178
+ );
179
+ }
180
+ }
181
+ ```
182
+
114
183
  ## React Hook list
115
184
 
116
185
  ### useData
@@ -141,6 +210,8 @@ const { loading, theme, themeString, teamsUserCredential } = useTeamsUserCredent
141
210
  This hook function leverage `useData` to call Graph API. It will execute the fetchGraphDataAsync function that the developer passes in first.
142
211
  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
212
 
213
+ ## Dashboard Related Classes
214
+
144
215
  ### BaseDashboard
145
216
  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
217
 
@@ -1,54 +1,61 @@
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 {};
1
+ import { Component } from "react";
2
+ /**
3
+ * The state interface for the BaseDashboard component.
4
+ */
5
+ interface BaseDashboardState {
6
+ /**
7
+ * A boolean property that indicates whether the dashboard layout should be optimized for mobile devices.
8
+ */
9
+ isMobile?: boolean;
10
+ /**
11
+ * A boolean property that indicates whether the login page should be displayed.
12
+ */
13
+ showLogin?: boolean;
14
+ /**
15
+ * The resize observer for the dashboard.
16
+ * @internal
17
+ */
18
+ observer?: ResizeObserver;
19
+ }
20
+ /**
21
+ * The base component that provides basic functionality to create a dashboard.
22
+ * @typeParam P The type of props.
23
+ * @typeParam S The type of state.
24
+ */
25
+ export declare class BaseDashboard<P, S> extends Component<P, S & BaseDashboardState> {
26
+ /**
27
+ * @internal
28
+ */
29
+ private ref;
30
+ /**
31
+ * Constructor of BaseDashboard.
32
+ * @param {Readonly<P>} props The properties for the dashboard.
33
+ */
34
+ constructor(props: Readonly<P>);
35
+ /**
36
+ * Called after the component is mounted. You can do initialization that requires DOM nodes here. You can also make network requests here if you need to load data from a remote endpoint.
37
+ */
38
+ componentDidMount(): Promise<void>;
39
+ /**
40
+ * Called before the component is unmounted and destroyed. You can do necessary cleanup here, such as invalidating timers, canceling network requests, or removing any DOM elements.
41
+ */
42
+ componentWillUnmount(): void;
43
+ /**
44
+ * Defines the default layout for the dashboard.
45
+ */
46
+ render(): JSX.Element;
47
+ /**
48
+ * Override this method to define the layout of the widget in the dashboard.
49
+ * @returns The layout of the widget in the dashboard.
50
+ * @public
51
+ */
52
+ protected layout(): JSX.Element | undefined;
53
+ /**
54
+ * Override this method to customize the dashboard style.
55
+ * @returns The className for customizing the dashboard style.
56
+ * @public
57
+ */
58
+ protected styling(): string;
59
+ }
60
+ export {};
54
61
  //# sourceMappingURL=BaseDashboard.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"BaseDashboard.d.ts","sourceRoot":"","sources":["../../src/BaseDashboard.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAoBzC;;GAEG;AACH,UAAU,kBAAkB;IAC1B;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;OAEG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;OAGG;IACH,QAAQ,CAAC,EAAE,cAAc,CAAC;CAC3B;AAED;;;;GAIG;AACH,qBAAa,aAAa,CAAC,CAAC,EAAE,CAAC,CAAE,SAAQ,SAAS,CAAC,CAAC,EAAE,CAAC,GAAG,kBAAkB,CAAC;IAC3E;;OAEG;IACH,OAAO,CAAC,GAAG,CAAkC;IAE7C;;;OAGG;gBACgB,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;IAUrC;;OAEG;IACU,iBAAiB;IAa9B;;OAEG;IACI,oBAAoB,IAAI,IAAI;IAOnC;;OAEG;IACI,MAAM;IAWb;;;;OAIG;IACH,SAAS,CAAC,MAAM,IAAI,GAAG,CAAC,OAAO,GAAG,SAAS;IAI3C;;;;OAIG;IACH,SAAS,CAAC,OAAO,IAAI,MAAM;CAG5B"}
@@ -1,102 +1,91 @@
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;
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
+ /**
8
+ * Returns the CSS class name for the dashboard.
9
+ * @returns The CSS class name for the dashboard.
10
+ * @internal
11
+ */
12
+ function dashboardStyle(isMobile) {
13
+ 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" } : {})));
14
+ }
15
+ /**
16
+ * The base component that provides basic functionality to create a dashboard.
17
+ * @typeParam P The type of props.
18
+ * @typeParam S The type of state.
19
+ */
20
+ var BaseDashboard = /** @class */ (function (_super) {
21
+ tslib_1.__extends(BaseDashboard, _super);
22
+ /**
23
+ * Constructor of BaseDashboard.
24
+ * @param {Readonly<P>} props The properties for the dashboard.
25
+ */
26
+ function BaseDashboard(props) {
27
+ var _this = _super.call(this, props) || this;
28
+ _this.state = {
29
+ isMobile: undefined,
30
+ showLogin: undefined,
31
+ observer: undefined,
32
+ };
33
+ _this.ref = react_1.default.createRef();
34
+ return _this;
35
+ }
36
+ /**
37
+ * Called after the component is mounted. You can do initialization that requires DOM nodes here. You can also make network requests here if you need to load data from a remote endpoint.
38
+ */
39
+ BaseDashboard.prototype.componentDidMount = function () {
40
+ return tslib_1.__awaiter(this, void 0, void 0, function () {
41
+ var observer;
42
+ var _this = this;
43
+ return tslib_1.__generator(this, function (_a) {
44
+ observer = new ResizeObserver(function (entries) {
45
+ for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
46
+ var entry = entries_1[_i];
47
+ if (entry.target === _this.ref.current) {
48
+ var width = entry.contentRect.width;
49
+ _this.setState({ isMobile: width < 600 });
50
+ }
51
+ }
52
+ });
53
+ observer.observe(this.ref.current);
54
+ return [2 /*return*/];
55
+ });
56
+ });
57
+ };
58
+ /**
59
+ * Called before the component is unmounted and destroyed. You can do necessary cleanup here, such as invalidating timers, canceling network requests, or removing any DOM elements.
60
+ */
61
+ BaseDashboard.prototype.componentWillUnmount = function () {
62
+ // Unobserve the dashboard div for resize events
63
+ if (this.state.observer && this.ref.current) {
64
+ this.state.observer.unobserve(this.ref.current);
65
+ }
66
+ };
67
+ /**
68
+ * Defines the default layout for the dashboard.
69
+ */
70
+ BaseDashboard.prototype.render = function () {
71
+ return (react_1.default.createElement("div", { ref: this.ref, className: (0, react_2.mergeStyles)(dashboardStyle(this.state.isMobile), this.styling()) }, this.layout()));
72
+ };
73
+ /**
74
+ * Override this method to define the layout of the widget in the dashboard.
75
+ * @returns The layout of the widget in the dashboard.
76
+ * @public
77
+ */
78
+ BaseDashboard.prototype.layout = function () {
79
+ return undefined;
80
+ };
81
+ /**
82
+ * Override this method to customize the dashboard style.
83
+ * @returns The className for customizing the dashboard style.
84
+ * @public
85
+ */
86
+ BaseDashboard.prototype.styling = function () {
87
+ return null;
88
+ };
89
+ return BaseDashboard;
90
+ }(react_1.Component));
91
+ exports.BaseDashboard = BaseDashboard;
@@ -1,63 +1,95 @@
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 {};
1
+ import { Component } from "react";
2
+ /**
3
+ * Interface for defining the class names of widget elements
4
+ */
5
+ export interface IWidgetClassNames {
6
+ /**
7
+ * The class name for the root part of the widget.
8
+ */
9
+ root?: string;
10
+ /**
11
+ * The class name for the header part of the widget.
12
+ */
13
+ header?: string;
14
+ /**
15
+ * The class name for the body part of the widget.
16
+ */
17
+ body?: string;
18
+ /**
19
+ * The class name for the footer part of the widget.
20
+ */
21
+ footer?: string;
22
+ }
23
+ /**
24
+ * Interface for defining the state of the BaseWidget class
25
+ */
26
+ interface BaseWidgetState {
27
+ loading?: boolean;
28
+ }
29
+ /**
30
+ * The base component that provides basic functionality to create a widget.
31
+ * @param P the type of props.
32
+ * @param S the type of state.
33
+ */
34
+ export declare class BaseWidget<P, S> extends Component<P, S & BaseWidgetState> {
35
+ /**
36
+ * Constructor of BaseWidget.
37
+ * @param {Readonly<P>} props - The props of the component.
38
+ */
39
+ constructor(props: Readonly<P>);
40
+ /**
41
+ * Called after the component is mounted. You can do initialization that requires DOM nodes here. You can also make network requests here if you need to load data from a remote endpoint.
42
+ */
43
+ componentDidMount(): Promise<void>;
44
+ /**
45
+ * Defines the default layout for the widget.
46
+ */
47
+ render(): JSX.Element;
48
+ /**
49
+ * Get data required by the widget
50
+ * @returns Data for the widget
51
+ * @public
52
+ */
53
+ protected getData(): Promise<S>;
54
+ /**
55
+ * The purpose of this method is to provide a way for you to add custom header content to the widget.
56
+ * By overriding this method, you can add additional functionality or styling to the widget's header.
57
+ * If the method is not overridden, the widget will return undefined as the default value for the header, indicating that no custom header content has been defined.
58
+ * @returns An optional JSX.Element representing the header of the widget.
59
+ * @public
60
+ */
61
+ protected header(): JSX.Element | undefined;
62
+ /**
63
+ * The purpose of this method is to provide a way for you to add custom body content to the widget.
64
+ * By overriding this method, you can add additional functionality or styling to the widget's body.
65
+ * If the method is not overridden, the widget will return undefined as the default value for the body, indicating that no custom body content has been defined.
66
+ * @returns An optional JSX.Element representing the body of the widget.
67
+ * @public
68
+ */
69
+ protected body(): JSX.Element | undefined;
70
+ /**
71
+ * The purpose of this method is to provide a way for you to add custom footer content to the widget.
72
+ * By overriding this method, you can add additional functionality or styling to the widget's footer.
73
+ * If the method is not overridden, the widget will return undefined as the default value for the footer, indicating that no custom footer content has been defined.
74
+ * @returns An optional JSX.Element representing the footer of the widget.
75
+ * @public
76
+ */
77
+ protected footer(): JSX.Element | undefined;
78
+ /**
79
+ * This method is typically called when the widget is in the process of fetching data.
80
+ * The `undefined` return value is used to indicate that no loading indicator is required.
81
+ * If a loading indicator is required, the method can return a `JSX.Element` containing the necessary components to render the loading indicator.
82
+ * @returns A JSX element or `undefined` if no loading indicator is required.
83
+ * @public
84
+ */
85
+ protected loading(): JSX.Element | undefined;
86
+ /**
87
+ * Override this method to returns an object that defines the class names for the different parts of the widget.
88
+ * The returned object conforms to the {@link IWidgetClassNames} interface which defines the possible keys and values for the class names.
89
+ * @returns An object that defines the class names for the different parts of the widget.
90
+ * @public
91
+ */
92
+ protected styling(): IWidgetClassNames;
93
+ }
94
+ export {};
63
95
  //# sourceMappingURL=BaseWidget.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"BaseWidget.d.ts","sourceRoot":"","sources":["../../src/BaseWidget.tsx"],"names":[],"mappings":"AAAA,OAAc,EAAE,SAAS,EAAE,aAAa,EAAE,MAA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