@ichicraft/widgets-widget-base 1.21.0 → 1.23.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/README.md +19 -2
- package/lib/types/index.d.ts +158 -1
- package/lib/types/index.js +33 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
This package supports development of widgets built using the Widget Development Kit
|
|
2
|
-
|
|
3
1
|
_This package is part of the Widget Development Kit, which is a collection of NPM packages that empower developers to create widgets for Bloom Intranet._
|
|
4
2
|
|
|
5
3
|
# @ichicraft/widgets-widget-base
|
|
@@ -146,6 +144,25 @@ Entries from 1.21.0 onwards are generated from pull request descriptions when a
|
|
|
146
144
|
|
|
147
145
|
<!-- changelog:insert -->
|
|
148
146
|
|
|
147
|
+
## 1.23.0 - 2026-09-21
|
|
148
|
+
|
|
149
|
+
### Added
|
|
150
|
+
- Widgets can now see whether the Copilot integration is switched on for the intranet, and whether the current user is allowed to use it.
|
|
151
|
+
|
|
152
|
+
## 1.22.0 - 2026-09-15
|
|
153
|
+
|
|
154
|
+
### Added
|
|
155
|
+
- Widgets can change how the board draws their header and body: the header can show as an overlay on hover instead of a bar, the actions can be limited to the essential ones the user can perform, and the body can be transparent without a card.
|
|
156
|
+
- Widgets can show an icon before their title, with an optional color and tooltip. While a widget is being debugged, the debug icon takes its place.
|
|
157
|
+
- Widgets can show a badge after their title, with a count or a short text.
|
|
158
|
+
- The design settings now include the spacing between widgets on the board, so a widget can align its own columns with the board.
|
|
159
|
+
- Widgets can read and follow properties that change while they are loaded: their title and subtitle, the selected tab, deep link data, their size in the board grid, the render options the board applies, whether they are being dragged or resized, whether the user can change their settings, and the current design and theme.
|
|
160
|
+
- Widgets that follow design and theme changes themselves are no longer reloaded when the user switches themes, for example to dark mode.
|
|
161
|
+
- Widgets can tell whether they are loaded from a local debug session instead of their published build.
|
|
162
|
+
|
|
163
|
+
### Changed
|
|
164
|
+
- Showing or hiding the widget header is replaced by the new render options. The previous function keeps working and maps to the header render mode.
|
|
165
|
+
|
|
149
166
|
## 1.21.0 - 2026-08-27
|
|
150
167
|
|
|
151
168
|
### Changed
|
package/lib/types/index.d.ts
CHANGED
|
@@ -234,6 +234,11 @@ export interface WidgetContext {
|
|
|
234
234
|
bloomGroups?: {
|
|
235
235
|
fetchGroups(): Promise<any[]>;
|
|
236
236
|
};
|
|
237
|
+
/**
|
|
238
|
+
* The Copilot integration as configured in the admin center. Absent on widget boards that do
|
|
239
|
+
* not offer the integration, which widgets should treat as switched off.
|
|
240
|
+
*/
|
|
241
|
+
copilotIntegration?: CopilotIntegrationContext;
|
|
237
242
|
/**
|
|
238
243
|
* Generates a hash of all combined SP Groups of the current user. This can be used as
|
|
239
244
|
* cache invalidator to detect changes.
|
|
@@ -286,6 +291,21 @@ export interface WidgetContext {
|
|
|
286
291
|
context: any;
|
|
287
292
|
};
|
|
288
293
|
}
|
|
294
|
+
/**
|
|
295
|
+
* Whether the Copilot integration may be used, as configured in the admin center. A widget offering
|
|
296
|
+
* Copilot needs both answers: the first decides whether the integration exists at all, so whether
|
|
297
|
+
* an administrator is offered Copilot settings, the second whether this user may use it.
|
|
298
|
+
*/
|
|
299
|
+
export interface CopilotIntegrationContext {
|
|
300
|
+
/**
|
|
301
|
+
* Whether the Copilot integration is switched on for this Bloom Intranet.
|
|
302
|
+
*/
|
|
303
|
+
isEnabled: boolean;
|
|
304
|
+
/**
|
|
305
|
+
* Whether the current user is allowed to use the Copilot integration.
|
|
306
|
+
*/
|
|
307
|
+
isAllowedForCurrentUser: boolean;
|
|
308
|
+
}
|
|
289
309
|
/**
|
|
290
310
|
* Widget instance context providing metadata and functionality offered by the widget board. A widget instance
|
|
291
311
|
* is a single and specific widget that a user has on his/her board. It has its own
|
|
@@ -345,14 +365,28 @@ export interface WidgetInstanceContext {
|
|
|
345
365
|
* Functionality offered by the widget board to append the title of the widget with additional text.
|
|
346
366
|
*/
|
|
347
367
|
setWidgetTitleSuffix?: (suffix: string) => void;
|
|
368
|
+
/**
|
|
369
|
+
* Displays a badge after the title of the widget. A number is displayed as a count badge, a string as its text.
|
|
370
|
+
* Provide `undefined`, `0` or an empty string to remove the badge.
|
|
371
|
+
*/
|
|
372
|
+
setWidgetTitleBadge?: (badge: string | number | undefined) => void;
|
|
373
|
+
/**
|
|
374
|
+
* Displays an icon before the title of the widget. Provide `undefined` to remove the icon.
|
|
375
|
+
*/
|
|
376
|
+
setWidgetHeaderIcon?: (icon: WidgetHeaderIconProps | undefined) => void;
|
|
348
377
|
/**
|
|
349
378
|
* Functionality offered by the widget board to change the subtitle of the widget.
|
|
350
379
|
*/
|
|
351
380
|
setWidgetSubtitle?: (subtitle: string) => void;
|
|
352
381
|
/**
|
|
353
382
|
* Show or hide the header of the widget, allowing widgets to take control of full widget real estate.
|
|
383
|
+
* @deprecated Use `setWidgetRenderOptions` instead. `true` maps to `WidgetHeaderRenderMode.Default`, `false` to `WidgetHeaderRenderMode.Overlay`.
|
|
354
384
|
*/
|
|
355
385
|
setWidgetHeaderVisibility?: (visible: boolean) => void;
|
|
386
|
+
/**
|
|
387
|
+
* Changes how the widget board renders the chrome around this widget. Only the provided options are changed.
|
|
388
|
+
*/
|
|
389
|
+
setWidgetRenderOptions?: (options: Partial<WidgetRenderOptions>) => void;
|
|
356
390
|
/**
|
|
357
391
|
* Show or hide the settings button of the widget.
|
|
358
392
|
*/
|
|
@@ -410,6 +444,123 @@ export interface WidgetInstanceContext {
|
|
|
410
444
|
* Data stored here is specific to this instance only.
|
|
411
445
|
*/
|
|
412
446
|
cache: CacheManager;
|
|
447
|
+
/**
|
|
448
|
+
* Properties of this widget instance that can change while the widget is loaded, such as the size it occupies in the board grid.
|
|
449
|
+
* Subscribe to be notified of changes without the widget being reloaded.
|
|
450
|
+
*/
|
|
451
|
+
dynamic?: DynamicWidgetInstanceContext;
|
|
452
|
+
}
|
|
453
|
+
export declare enum WidgetHeaderRenderMode {
|
|
454
|
+
/** A header bar at the top of the widget, showing the title and actions. */
|
|
455
|
+
Default = "default",
|
|
456
|
+
/** No header bar. Actions are shown on top of the widget body when hovering the widget. */
|
|
457
|
+
Overlay = "overlay"
|
|
458
|
+
}
|
|
459
|
+
export declare enum WidgetHeaderActionsMode {
|
|
460
|
+
/** All actions available to the user. */
|
|
461
|
+
All = "all",
|
|
462
|
+
/** Only essential actions the user can currently perform; informational, secondary and disabled actions are hidden. */
|
|
463
|
+
Limited = "limited"
|
|
464
|
+
}
|
|
465
|
+
export declare enum WidgetBodyRenderMode {
|
|
466
|
+
/** The widget is rendered on a card, with a background and shadow. */
|
|
467
|
+
Default = "default",
|
|
468
|
+
/** No background or shadow. The header is always rendered as `WidgetHeaderRenderMode.Overlay`. */
|
|
469
|
+
Transparent = "transparent"
|
|
470
|
+
}
|
|
471
|
+
export interface WidgetHeaderIconProps {
|
|
472
|
+
/** Name of a Fluent UI icon. */
|
|
473
|
+
iconName?: string;
|
|
474
|
+
/** Url of an image, used when no `iconName` is provided. */
|
|
475
|
+
imageUrl?: string;
|
|
476
|
+
/** Color of the icon. Only applies to `iconName`. Defaults to the theme's primary color. */
|
|
477
|
+
color?: string;
|
|
478
|
+
/** Tooltip displayed when hovering the icon. */
|
|
479
|
+
tooltip?: string;
|
|
480
|
+
}
|
|
481
|
+
export interface WidgetRenderOptions {
|
|
482
|
+
/** How the header is rendered. Defaults to `WidgetHeaderRenderMode.Default`. */
|
|
483
|
+
headerMode: WidgetHeaderRenderMode;
|
|
484
|
+
/** Which actions the header offers. Defaults to `WidgetHeaderActionsMode.All`. */
|
|
485
|
+
actionsMode: WidgetHeaderActionsMode;
|
|
486
|
+
/** How the widget body is rendered. Defaults to `WidgetBodyRenderMode.Default`. */
|
|
487
|
+
bodyMode: WidgetBodyRenderMode;
|
|
488
|
+
}
|
|
489
|
+
export declare enum WidgetUserConfigAccess {
|
|
490
|
+
/** The widget has no user configuration (`isConfigurableByUser` is `false` in its manifest). */
|
|
491
|
+
None = "none",
|
|
492
|
+
/** The current user can change this widget's user configuration. */
|
|
493
|
+
Editable = "editable",
|
|
494
|
+
/** The current user normally can, but not right now, e.g. while another user edits the shared board or the SharePoint page is in edit mode. */
|
|
495
|
+
Blocked = "blocked",
|
|
496
|
+
/** The current user can't change this widget's user configuration, e.g. when viewing someone else's shared board. */
|
|
497
|
+
ReadOnly = "readOnly"
|
|
498
|
+
}
|
|
499
|
+
export interface WidgetGridItemSize {
|
|
500
|
+
/** Number of board grid columns the widget occupies. */
|
|
501
|
+
columns: number;
|
|
502
|
+
/** Number of board grid rows the widget occupies. */
|
|
503
|
+
rows: number;
|
|
504
|
+
}
|
|
505
|
+
/** Widget properties that can change while the widget is loaded. */
|
|
506
|
+
export interface DynamicWidgetInstanceContextValue {
|
|
507
|
+
/**
|
|
508
|
+
* The widget's current title: set through `setWidgetTitle`, renamed by the user, or the variant's title, in that order.
|
|
509
|
+
* Excludes the suffix set through `setWidgetTitleSuffix`.
|
|
510
|
+
*/
|
|
511
|
+
title?: string;
|
|
512
|
+
/** The widget's current subtitle: set through `setWidgetSubtitle` or the variant's subtitle, with its tokens replaced. */
|
|
513
|
+
subtitle?: string;
|
|
514
|
+
/** The tab shown as selected, whether the widget or the user selected it. */
|
|
515
|
+
selectedTabId?: string;
|
|
516
|
+
/** This instance's deep link data in the current url; the same value `getDeepLinkData()` returns. */
|
|
517
|
+
deepLinkData: string;
|
|
518
|
+
/** The size the widget occupies in the board grid. Only set when the widget is on a board, not in the buddy bar or a web part. */
|
|
519
|
+
size?: WidgetGridItemSize;
|
|
520
|
+
/**
|
|
521
|
+
* The render options the widget board currently applies: the options requested through `setWidgetRenderOptions`,
|
|
522
|
+
* after the board's overrides. For example, the header renders as an overlay when the widget
|
|
523
|
+
* is scaled down, and the body keeps its card while an error is shown.
|
|
524
|
+
*/
|
|
525
|
+
renderOptions: WidgetRenderOptions;
|
|
526
|
+
/** Whether the user is dragging the widget. */
|
|
527
|
+
isDragging: boolean;
|
|
528
|
+
/** Whether the user is resizing the widget. While `true`, `size` describes the size the widget will snap to. */
|
|
529
|
+
isResizing: boolean;
|
|
530
|
+
/** Pointer events on the widget body are blocked, e.g. while any widget on the board is dragged or resized. */
|
|
531
|
+
isPointerEventsDisabled: boolean;
|
|
532
|
+
/** Whether the current user can change this widget's user configuration right now. */
|
|
533
|
+
userConfigAccess: WidgetUserConfigAccess;
|
|
534
|
+
/**
|
|
535
|
+
* The design settings of the user's current theme; the live counterpart of `WidgetContext.design`.
|
|
536
|
+
* The widget is reloaded when this changes, unless it subscribed to `design` by name.
|
|
537
|
+
*/
|
|
538
|
+
design: WidgetDesignContext;
|
|
539
|
+
/**
|
|
540
|
+
* The currently used theme, e.g. after switching to dark mode; the live counterpart of `WidgetContext.theme`.
|
|
541
|
+
* The widget is reloaded when this changes, unless it subscribed to `theme` by name.
|
|
542
|
+
*/
|
|
543
|
+
theme: any;
|
|
544
|
+
}
|
|
545
|
+
export type DynamicWidgetInstanceContextKey = keyof DynamicWidgetInstanceContextValue;
|
|
546
|
+
export type DynamicWidgetInstanceContextListener = (value: DynamicWidgetInstanceContextValue) => void;
|
|
547
|
+
export interface DynamicWidgetInstanceContext {
|
|
548
|
+
/** The current value. Also available during `init` and `render`. */
|
|
549
|
+
readonly current: DynamicWidgetInstanceContextValue;
|
|
550
|
+
/**
|
|
551
|
+
* Calls the listener when one of `keys` changes, or on every change when `keys` is omitted.
|
|
552
|
+
* Subscribing to `design` or `theme` by name tells the widget board the widget applies those changes itself,
|
|
553
|
+
* so it isn't reloaded when they change. Subscribing the same listener again replaces its keys.
|
|
554
|
+
* @returns A function that removes this listener.
|
|
555
|
+
*/
|
|
556
|
+
subscribe: (listener: DynamicWidgetInstanceContextListener, keys?: DynamicWidgetInstanceContextKey[]) => () => void;
|
|
557
|
+
/** Removes a listener passed to `subscribe`. Requires the same function reference. */
|
|
558
|
+
unsubscribe: (listener: DynamicWidgetInstanceContextListener) => void;
|
|
559
|
+
/**
|
|
560
|
+
* Removes all listeners of this widget, including those added by hooks of mounted components.
|
|
561
|
+
* Intended for teardown, e.g. in `cleanupResources`.
|
|
562
|
+
*/
|
|
563
|
+
unsubscribeAll: () => void;
|
|
413
564
|
}
|
|
414
565
|
export interface WidgetBuddyContext {
|
|
415
566
|
/**
|
|
@@ -491,14 +642,20 @@ export interface WidgetManifestContext {
|
|
|
491
642
|
* Data stored here is shared across all variants and instances of this widget type.
|
|
492
643
|
*/
|
|
493
644
|
cache: CacheManager;
|
|
645
|
+
/**
|
|
646
|
+
* Whether the widget board loaded this widget from a local debug session instead of its published build.
|
|
647
|
+
*/
|
|
648
|
+
isDebugging?: boolean;
|
|
494
649
|
}
|
|
495
650
|
export interface WidgetDesignContext {
|
|
496
651
|
/** Available options in the ColorPicker.*/
|
|
497
652
|
colorOptions: ColorOption[];
|
|
498
653
|
/** Preferred border radius of UI elements.*/
|
|
499
654
|
borderRadius: number;
|
|
500
|
-
/** The height of a single row in the board grid.
|
|
655
|
+
/** The height of a single row in the board grid. To know how many rows a widget occupies, use `instance.dynamic.current.size` instead. */
|
|
501
656
|
rowHeight: number;
|
|
657
|
+
/** Spacing between widgets in the board grid, in pixels. Use this to align columns within a widget with the board's columns. */
|
|
658
|
+
gridSpacing?: number;
|
|
502
659
|
/** Design settings related to icon badges. */
|
|
503
660
|
badge: {
|
|
504
661
|
/** Background color of an icon badge. */
|
package/lib/types/index.js
CHANGED
|
@@ -1,6 +1,38 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CommandBarItemType = exports.CustomCommandBarItemSeverity = void 0;
|
|
3
|
+
exports.CommandBarItemType = exports.CustomCommandBarItemSeverity = exports.WidgetUserConfigAccess = exports.WidgetBodyRenderMode = exports.WidgetHeaderActionsMode = exports.WidgetHeaderRenderMode = void 0;
|
|
4
|
+
var WidgetHeaderRenderMode;
|
|
5
|
+
(function (WidgetHeaderRenderMode) {
|
|
6
|
+
/** A header bar at the top of the widget, showing the title and actions. */
|
|
7
|
+
WidgetHeaderRenderMode["Default"] = "default";
|
|
8
|
+
/** No header bar. Actions are shown on top of the widget body when hovering the widget. */
|
|
9
|
+
WidgetHeaderRenderMode["Overlay"] = "overlay";
|
|
10
|
+
})(WidgetHeaderRenderMode || (exports.WidgetHeaderRenderMode = WidgetHeaderRenderMode = {}));
|
|
11
|
+
var WidgetHeaderActionsMode;
|
|
12
|
+
(function (WidgetHeaderActionsMode) {
|
|
13
|
+
/** All actions available to the user. */
|
|
14
|
+
WidgetHeaderActionsMode["All"] = "all";
|
|
15
|
+
/** Only essential actions the user can currently perform; informational, secondary and disabled actions are hidden. */
|
|
16
|
+
WidgetHeaderActionsMode["Limited"] = "limited";
|
|
17
|
+
})(WidgetHeaderActionsMode || (exports.WidgetHeaderActionsMode = WidgetHeaderActionsMode = {}));
|
|
18
|
+
var WidgetBodyRenderMode;
|
|
19
|
+
(function (WidgetBodyRenderMode) {
|
|
20
|
+
/** The widget is rendered on a card, with a background and shadow. */
|
|
21
|
+
WidgetBodyRenderMode["Default"] = "default";
|
|
22
|
+
/** No background or shadow. The header is always rendered as `WidgetHeaderRenderMode.Overlay`. */
|
|
23
|
+
WidgetBodyRenderMode["Transparent"] = "transparent";
|
|
24
|
+
})(WidgetBodyRenderMode || (exports.WidgetBodyRenderMode = WidgetBodyRenderMode = {}));
|
|
25
|
+
var WidgetUserConfigAccess;
|
|
26
|
+
(function (WidgetUserConfigAccess) {
|
|
27
|
+
/** The widget has no user configuration (`isConfigurableByUser` is `false` in its manifest). */
|
|
28
|
+
WidgetUserConfigAccess["None"] = "none";
|
|
29
|
+
/** The current user can change this widget's user configuration. */
|
|
30
|
+
WidgetUserConfigAccess["Editable"] = "editable";
|
|
31
|
+
/** The current user normally can, but not right now, e.g. while another user edits the shared board or the SharePoint page is in edit mode. */
|
|
32
|
+
WidgetUserConfigAccess["Blocked"] = "blocked";
|
|
33
|
+
/** The current user can't change this widget's user configuration, e.g. when viewing someone else's shared board. */
|
|
34
|
+
WidgetUserConfigAccess["ReadOnly"] = "readOnly";
|
|
35
|
+
})(WidgetUserConfigAccess || (exports.WidgetUserConfigAccess = WidgetUserConfigAccess = {}));
|
|
4
36
|
/**
|
|
5
37
|
* Tells the severity of the command bar item, resulting in
|
|
6
38
|
* distinguishable presentation of the item
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ichicraft/widgets-widget-base",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "Part of the Widget Development Kit for building widgets for Bloom Intranet",
|
|
3
|
+
"version": "1.23.0",
|
|
4
|
+
"description": "Part of the Widget Development Kit for building widgets for Bloom Intranet. The base class and context types every widget implements.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
7
7
|
"scripts": {
|