@ichicraft/widgets-widget-base 1.8.17 → 1.9.1
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/README.md +12 -0
- package/lib/BaseWidget.d.ts +3 -1
- package/lib/types/index.d.ts +136 -116
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,6 +9,18 @@ All notable changes to this project will be documented here.
|
|
|
9
9
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
10
10
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
11
11
|
|
|
12
|
+
## 1.9.1 - 2023-10-20
|
|
13
|
+
|
|
14
|
+
- Added `WidgetInstanceContext` interface, to allow typing the `instance` property of the `WidgetContext` interface.
|
|
15
|
+
- Added `WidgetVariantContext` interface, to allow typing the `definition` property of the `WidgetContext` interface.
|
|
16
|
+
- Added `WidgetManifestContext` interface, to allow typing the `manifest` property of the `WidgetContext` interface.
|
|
17
|
+
|
|
18
|
+
## 1.9.0 - 2023-10-20
|
|
19
|
+
|
|
20
|
+
- Added optional `importData()` function to the `BaseWidget` class, used to import widget-specific data.
|
|
21
|
+
- Added optional `exportData()` function to the `BaseWidget` class, used to export widget-specific data.
|
|
22
|
+
- Added new exported `ExportData` type.
|
|
23
|
+
|
|
12
24
|
## 1.8.17 - 2023-10-09
|
|
13
25
|
|
|
14
26
|
- Added `iconName` property to the `definition` object of the `WidgetContext` interface, to support using an icon to represent a widget.
|
package/lib/BaseWidget.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { WidgetContext, ValidationResult } from './types';
|
|
1
|
+
import { WidgetContext, ValidationResult, ExportData } from './types';
|
|
2
2
|
export default abstract class BaseWidget {
|
|
3
3
|
protected readonly context: WidgetContext;
|
|
4
4
|
constructor(context: WidgetContext);
|
|
@@ -12,5 +12,7 @@ export default abstract class BaseWidget {
|
|
|
12
12
|
renderAdminConfigurationForm?(domElement: HTMLDivElement): void;
|
|
13
13
|
validateAdminConfigurationForm?(): ValidationResult;
|
|
14
14
|
getSerializedAdminConfiguration?(): string;
|
|
15
|
+
importData?(exportData: ExportData): Promise<void>;
|
|
16
|
+
exportData?(): Promise<ExportData>;
|
|
15
17
|
cleanupResources?(): void;
|
|
16
18
|
}
|
package/lib/types/index.d.ts
CHANGED
|
@@ -3,134 +3,22 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export interface WidgetContext {
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* Metadata and functions in the context of a widget instance. A widget instance
|
|
7
7
|
* is a single and specific widget that a user has on his/her board. It has its own
|
|
8
8
|
* unique ID and possibly configuration data if the widget is configurable by the user
|
|
9
9
|
*/
|
|
10
|
-
instance:
|
|
11
|
-
/**
|
|
12
|
-
* Unique id for a specific widget on a user's board
|
|
13
|
-
*/
|
|
14
|
-
id: string;
|
|
15
|
-
/**
|
|
16
|
-
* Optional configuration data that contains user settings of a specific widget instance
|
|
17
|
-
*/
|
|
18
|
-
data?: string;
|
|
19
|
-
/**
|
|
20
|
-
* The type of board this widget instance is added to.
|
|
21
|
-
*/
|
|
22
|
-
boardType?: BoardType;
|
|
23
|
-
/**
|
|
24
|
-
* Call this function from within a widget instance to publish a notification to the
|
|
25
|
-
* notitication box on top of the widget board. It should provide information for this specific
|
|
26
|
-
* widget instance. Notitifcation content is limited to one single line and a widget instance
|
|
27
|
-
* can only have one active notification at a time
|
|
28
|
-
*/
|
|
29
|
-
publishNotification?: (content: string, expirationDateTime: Date) => void;
|
|
30
|
-
/**
|
|
31
|
-
* Call this function to open the widget configuration panel for a user. This is an additional
|
|
32
|
-
* way to open the panel because a user can also open the configuration panel by using the contextual
|
|
33
|
-
* menu of the widget.
|
|
34
|
-
*/
|
|
35
|
-
openConfiguration?: () => void;
|
|
36
|
-
/**
|
|
37
|
-
* Call this function to open the widget delete confirmation dialog for a user. This offers widget developers
|
|
38
|
-
* the ability to trigger the "widget deletion process". This allows different methods to delete the widget.
|
|
39
|
-
*/
|
|
40
|
-
initiateWidgetDeletion?: () => void;
|
|
41
|
-
/**
|
|
42
|
-
* Functionality offered by the widget board to change the title of the widget.
|
|
43
|
-
*/
|
|
44
|
-
setWidgetTitle?: (title: string) => void;
|
|
45
|
-
/**
|
|
46
|
-
* Functionality offered by the widget board to append the title of the widget with additional text.
|
|
47
|
-
*/
|
|
48
|
-
setWidgetTitleSuffix?: (suffix: string) => void;
|
|
49
|
-
/**
|
|
50
|
-
* Functionality offered by the widget board to change the subtitle of the widget.
|
|
51
|
-
*/
|
|
52
|
-
setWidgetSubtitle?: (subtitle: string) => void;
|
|
53
|
-
/**
|
|
54
|
-
* Show or hide the header of the widget, allowing widgets to take control of full widget real estate.
|
|
55
|
-
*/
|
|
56
|
-
setWidgetHeaderVisibility?: (visible: boolean) => void;
|
|
57
|
-
/**
|
|
58
|
-
* Show or hide the settings button of the widget.
|
|
59
|
-
*/
|
|
60
|
-
setUserConfigButtonVisibility?: (visible: boolean) => void;
|
|
61
|
-
/**
|
|
62
|
-
* Optional callback to handle the click event of the widget title.
|
|
63
|
-
*/
|
|
64
|
-
onWidgetTitleClicked?: () => void;
|
|
65
|
-
/**
|
|
66
|
-
* Allows registration of multiple custom command bar items which can either result in an icon or
|
|
67
|
-
* an icon button, depending on the presence of the onClick property. To remove the items,
|
|
68
|
-
* use the [unregisterCommandBarItems] function.
|
|
69
|
-
*/
|
|
70
|
-
registerCustomCommandBarItems?: (props: CustomCommandBarItemProps[]) => void;
|
|
71
|
-
/**
|
|
72
|
-
* Allows registration of a custom command bar item which can either result in an icon or
|
|
73
|
-
* an icon button, depending on the presence of the onClick property. To remove the item,
|
|
74
|
-
* use the [unregisterCommandBarItem] function.
|
|
75
|
-
*/
|
|
76
|
-
registerCustomCommandBarItem?: (props: CustomCommandBarItemProps) => void;
|
|
77
|
-
/**
|
|
78
|
-
* Removes all registered custom command bar items.
|
|
79
|
-
*/
|
|
80
|
-
unregisterCustomCommandBarItems?: () => void;
|
|
81
|
-
/**
|
|
82
|
-
* Removes a single custom command bar item, corresponding to the provided id.
|
|
83
|
-
* If no id was specified, it removes all items.
|
|
84
|
-
*/
|
|
85
|
-
unregisterCustomCommandBarItem?: (id?: string) => void;
|
|
86
|
-
/**
|
|
87
|
-
* Raises an event to be handled by the Time-based Events feature of Ichicraft Boards.
|
|
88
|
-
* @param object The object this event concerns (e.g. app, report, newsArticle, ...). Use camelCase.
|
|
89
|
-
* @param action The action that was performed to/on the object (e.g. viewed, clicked, deleted, ...). Use camelCase.
|
|
90
|
-
* @param data Optionally provide extra metadata to be included with the raised event.
|
|
91
|
-
* widgetAlias property (from manifest) and variantTitle property will automatically be added by the widget board.
|
|
92
|
-
*/
|
|
93
|
-
raiseEvent?: (object: string, action: string, data?: {
|
|
94
|
-
[key: string]: string;
|
|
95
|
-
}) => void;
|
|
96
|
-
};
|
|
10
|
+
instance: WidgetInstanceContext;
|
|
97
11
|
/**
|
|
98
12
|
* Metadata and functions in the context of a widget's variant (fka definition). A widget variant is
|
|
99
13
|
* a widget that's been installed by an administrator from within the board administration.
|
|
100
14
|
*/
|
|
101
|
-
definition:
|
|
102
|
-
/**
|
|
103
|
-
* Unique id of an installed and configured widget in the widget board.
|
|
104
|
-
* If this is a 'single instance widget', which means that no more than one instance of this
|
|
105
|
-
* widget can be installed in the widget board, the id of the definition is the same as the id of the manifest.
|
|
106
|
-
*/
|
|
107
|
-
id: string;
|
|
108
|
-
/**
|
|
109
|
-
* Optional configuration data that contains board-wide settings of a specific widget instance
|
|
110
|
-
*/
|
|
111
|
-
data?: string;
|
|
112
|
-
/**
|
|
113
|
-
* A list of board types applicable for this widget variant.
|
|
114
|
-
*/
|
|
115
|
-
allowedBoardTypes?: BoardType[];
|
|
116
|
-
/**
|
|
117
|
-
* The icon defined for this widget variant.
|
|
118
|
-
*/
|
|
119
|
-
iconName?: string;
|
|
120
|
-
};
|
|
15
|
+
definition: WidgetVariantContext;
|
|
121
16
|
/**
|
|
122
17
|
* Metadata and functions in the context of a widget's manifest. A widget manifest contains
|
|
123
18
|
* all information of the originally installed widget. Multiple `variants` of the same widget `manifest`
|
|
124
19
|
* can exist in a widget board configuration.
|
|
125
20
|
*/
|
|
126
|
-
manifest:
|
|
127
|
-
/**
|
|
128
|
-
* Unique id of a widget 'type', also used in the widget manifest config file in the original script source manifest file.
|
|
129
|
-
* If this is a 'single instance widget', which means that no more than one instance of this
|
|
130
|
-
* widget can be installed in the widget board, the id of the definition is the same as the id of the manifest.
|
|
131
|
-
*/
|
|
132
|
-
id: string;
|
|
133
|
-
};
|
|
21
|
+
manifest: WidgetManifestContext;
|
|
134
22
|
/**
|
|
135
23
|
* Tells whether the widget board is running in a Teams context
|
|
136
24
|
*/
|
|
@@ -313,6 +201,135 @@ export interface WidgetContext {
|
|
|
313
201
|
context: any;
|
|
314
202
|
};
|
|
315
203
|
}
|
|
204
|
+
/**
|
|
205
|
+
* Widget instance context providing metadata and functionality offered by the widget board. A widget instance
|
|
206
|
+
* is a single and specific widget that a user has on his/her board. It has its own
|
|
207
|
+
* unique ID and possibly configuration data if the widget is configurable by the user
|
|
208
|
+
*/
|
|
209
|
+
export interface WidgetInstanceContext {
|
|
210
|
+
/**
|
|
211
|
+
* Unique id for a specific widget on a user's board
|
|
212
|
+
*/
|
|
213
|
+
id: string;
|
|
214
|
+
/**
|
|
215
|
+
* Optional configuration data that contains user settings of a specific widget instance
|
|
216
|
+
*/
|
|
217
|
+
data?: string;
|
|
218
|
+
/**
|
|
219
|
+
* The type of board this widget instance is added to.
|
|
220
|
+
*/
|
|
221
|
+
boardType?: BoardType;
|
|
222
|
+
/**
|
|
223
|
+
* Call this function from within a widget instance to publish a notification to the
|
|
224
|
+
* notitication box on top of the widget board. It should provide information for this specific
|
|
225
|
+
* widget instance. Notitifcation content is limited to one single line and a widget instance
|
|
226
|
+
* can only have one active notification at a time
|
|
227
|
+
*/
|
|
228
|
+
publishNotification?: (content: string, expirationDateTime: Date) => void;
|
|
229
|
+
/**
|
|
230
|
+
* Call this function to open the widget configuration panel for a user. This is an additional
|
|
231
|
+
* way to open the panel because a user can also open the configuration panel by using the contextual
|
|
232
|
+
* menu of the widget.
|
|
233
|
+
*/
|
|
234
|
+
openConfiguration?: () => void;
|
|
235
|
+
/**
|
|
236
|
+
* Call this function to open the widget delete confirmation dialog for a user. This offers widget developers
|
|
237
|
+
* the ability to trigger the "widget deletion process". This allows different methods to delete the widget.
|
|
238
|
+
*/
|
|
239
|
+
initiateWidgetDeletion?: () => void;
|
|
240
|
+
/**
|
|
241
|
+
* Functionality offered by the widget board to change the title of the widget.
|
|
242
|
+
*/
|
|
243
|
+
setWidgetTitle?: (title: string) => void;
|
|
244
|
+
/**
|
|
245
|
+
* Functionality offered by the widget board to append the title of the widget with additional text.
|
|
246
|
+
*/
|
|
247
|
+
setWidgetTitleSuffix?: (suffix: string) => void;
|
|
248
|
+
/**
|
|
249
|
+
* Functionality offered by the widget board to change the subtitle of the widget.
|
|
250
|
+
*/
|
|
251
|
+
setWidgetSubtitle?: (subtitle: string) => void;
|
|
252
|
+
/**
|
|
253
|
+
* Show or hide the header of the widget, allowing widgets to take control of full widget real estate.
|
|
254
|
+
*/
|
|
255
|
+
setWidgetHeaderVisibility?: (visible: boolean) => void;
|
|
256
|
+
/**
|
|
257
|
+
* Show or hide the settings button of the widget.
|
|
258
|
+
*/
|
|
259
|
+
setUserConfigButtonVisibility?: (visible: boolean) => void;
|
|
260
|
+
/**
|
|
261
|
+
* Optional callback to handle the click event of the widget title.
|
|
262
|
+
*/
|
|
263
|
+
onWidgetTitleClicked?: () => void;
|
|
264
|
+
/**
|
|
265
|
+
* Allows registration of multiple custom command bar items which can either result in an icon or
|
|
266
|
+
* an icon button, depending on the presence of the onClick property. To remove the items,
|
|
267
|
+
* use the [unregisterCommandBarItems] function.
|
|
268
|
+
*/
|
|
269
|
+
registerCustomCommandBarItems?: (props: CustomCommandBarItemProps[]) => void;
|
|
270
|
+
/**
|
|
271
|
+
* Allows registration of a custom command bar item which can either result in an icon or
|
|
272
|
+
* an icon button, depending on the presence of the onClick property. To remove the item,
|
|
273
|
+
* use the [unregisterCommandBarItem] function.
|
|
274
|
+
*/
|
|
275
|
+
registerCustomCommandBarItem?: (props: CustomCommandBarItemProps) => void;
|
|
276
|
+
/**
|
|
277
|
+
* Removes all registered custom command bar items.
|
|
278
|
+
*/
|
|
279
|
+
unregisterCustomCommandBarItems?: () => void;
|
|
280
|
+
/**
|
|
281
|
+
* Removes a single custom command bar item, corresponding to the provided id.
|
|
282
|
+
* If no id was specified, it removes all items.
|
|
283
|
+
*/
|
|
284
|
+
unregisterCustomCommandBarItem?: (id?: string) => void;
|
|
285
|
+
/**
|
|
286
|
+
* Raises an event to be handled by the Time-based Events feature of Ichicraft Boards.
|
|
287
|
+
* @param object The object this event concerns (e.g. app, report, newsArticle, ...). Use camelCase.
|
|
288
|
+
* @param action The action that was performed to/on the object (e.g. viewed, clicked, deleted, ...). Use camelCase.
|
|
289
|
+
* @param data Optionally provide extra metadata to be included with the raised event.
|
|
290
|
+
* widgetAlias property (from manifest) and variantTitle property will automatically be added by the widget board.
|
|
291
|
+
*/
|
|
292
|
+
raiseEvent?: (object: string, action: string, data?: {
|
|
293
|
+
[key: string]: string;
|
|
294
|
+
}) => void;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Widget variant context providing metadata and functionality offered by the widget board. A widget variant is
|
|
298
|
+
* a widget that's been installed by an administrator from within the board administration.
|
|
299
|
+
*/
|
|
300
|
+
export interface WidgetVariantContext {
|
|
301
|
+
/**
|
|
302
|
+
* Unique id of an installed and configured widget in the widget board.
|
|
303
|
+
* If this is a 'single instance widget', which means that no more than one instance of this
|
|
304
|
+
* widget can be installed in the widget board, the id of the definition is the same as the id of the manifest.
|
|
305
|
+
*/
|
|
306
|
+
id: string;
|
|
307
|
+
/**
|
|
308
|
+
* Optional configuration data that contains board-wide settings of a specific widget instance
|
|
309
|
+
*/
|
|
310
|
+
data?: string;
|
|
311
|
+
/**
|
|
312
|
+
* A list of board types applicable for this widget variant.
|
|
313
|
+
*/
|
|
314
|
+
allowedBoardTypes?: BoardType[];
|
|
315
|
+
/**
|
|
316
|
+
* The icon defined for this widget variant.
|
|
317
|
+
*/
|
|
318
|
+
iconName?: string;
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Widget manifest context providing metadata and functions offered by the widget board. A widget manifest contains
|
|
322
|
+
* all information of the originally installed widget. Multiple `variants` of the same widget `manifest`
|
|
323
|
+
* can exist in a widget board configuration.
|
|
324
|
+
*/
|
|
325
|
+
export interface WidgetManifestContext {
|
|
326
|
+
/**
|
|
327
|
+
* Unique id of a widget 'type', also used in the widget manifest config file in the original script source manifest file.
|
|
328
|
+
* If this is a 'single instance widget', which means that no more than one instance of this
|
|
329
|
+
* widget can be installed in the widget board, the id of the definition is the same as the id of the manifest.
|
|
330
|
+
*/
|
|
331
|
+
id: string;
|
|
332
|
+
}
|
|
316
333
|
export interface ValidationResult {
|
|
317
334
|
isValid: boolean;
|
|
318
335
|
errors: string[];
|
|
@@ -652,3 +669,6 @@ export interface FilePickerFileProps {
|
|
|
652
669
|
}
|
|
653
670
|
export declare type BoardType = 'shared' | 'personal';
|
|
654
671
|
export declare type UserRole = 'administrator' | 'board-owner';
|
|
672
|
+
export interface ExportData {
|
|
673
|
+
data: object[];
|
|
674
|
+
}
|
package/package.json
CHANGED