@genesislcap/foundation-notifications 14.401.1 → 14.401.2
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/dist/dts/container/index.d.ts +1 -0
- package/dist/dts/container/index.d.ts.map +1 -1
- package/dist/dts/container/notify-container-sorters.d.ts +13 -0
- package/dist/dts/container/notify-container-sorters.d.ts.map +1 -0
- package/dist/dts/container/notify-container.d.ts +65 -0
- package/dist/dts/container/notify-container.d.ts.map +1 -1
- package/dist/dts/container/notify-container.template.d.ts +1 -1
- package/dist/dts/container/notify-container.template.d.ts.map +1 -1
- package/dist/esm/container/index.js +1 -0
- package/dist/esm/container/notify-container-sorters.js +23 -0
- package/dist/esm/container/notify-container.js +126 -5
- package/dist/esm/container/notify-container.styles.js +3 -3
- package/dist/foundation-notifications.api.json +215 -6
- package/dist/foundation-notifications.d.ts +78 -0
- package/docs/api/foundation-notifications.md +11 -0
- package/docs/api/foundation-notifications.notifycontainer.md +36 -0
- package/docs/api/foundation-notifications.notifycontainer.notificationinterval.md +11 -0
- package/docs/api/foundation-notifications.notifycontainer.sortfn.md +11 -0
- package/docs/api/foundation-notifications.notifycontainerconfig.allowcloseall.md +2 -0
- package/docs/api/foundation-notifications.notifycontainerconfig.allowmanualcollapse.md +2 -0
- package/docs/api/foundation-notifications.notifycontainerconfig.designsystemprefix.md +2 -0
- package/docs/api/foundation-notifications.notifycontainerconfig.md +52 -0
- package/docs/api/foundation-notifications.notifycontainerconfig.notificationinterval.md +15 -0
- package/docs/api/foundation-notifications.notifycontainerconfig.position.md +2 -0
- package/docs/api/foundation-notifications.notifycontainerconfig.showcount.md +2 -0
- package/docs/api/foundation-notifications.notifycontainerconfig.sortfn.md +13 -0
- package/docs/api/foundation-notifications.notifycontainerconfig.stackthreshold.md +2 -0
- package/docs/api/foundation-notifications.sortnotificationbyseverity.md +73 -0
- package/docs/api-report.md.api.md +13 -6
- package/package.json +12 -12
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/container/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/container/index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,4BAA4B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A ready-made sort comparator for use with {@link NotifyContainerConfig.sortFn} that places the
|
|
3
|
+
* most severe notifications at the top of the stack. Severity is determined by the `notify`
|
|
4
|
+
* attribute on each toast element: `error` (highest) → `warning` → `success` → unstyled (lowest).
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```ts
|
|
8
|
+
* configureNotifications({ sortFn: sortNotificationBySeverity });
|
|
9
|
+
* ```
|
|
10
|
+
* @public
|
|
11
|
+
*/
|
|
12
|
+
export declare const sortNotificationBySeverity: (a: HTMLElement, b: HTMLElement) => number;
|
|
13
|
+
//# sourceMappingURL=notify-container-sorters.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notify-container-sorters.d.ts","sourceRoot":"","sources":["../../../src/container/notify-container-sorters.ts"],"names":[],"mappings":"AASA;;;;;;;;;;GAUG;AACH,eAAO,MAAM,0BAA0B,GAAI,GAAG,WAAW,EAAE,GAAG,WAAW,KAAG,MAI3E,CAAC"}
|
|
@@ -1,12 +1,58 @@
|
|
|
1
1
|
import { GenesisElement } from '@genesislcap/web-core';
|
|
2
2
|
import { ToastPosition } from '../types';
|
|
3
3
|
export interface NotifyContainerConfig {
|
|
4
|
+
/**
|
|
5
|
+
* The corner of the screen where notifications appear.
|
|
6
|
+
* Note: bottom-left and bottom-right are not currently supported.
|
|
7
|
+
* @defaultValue 'top-right'
|
|
8
|
+
*/
|
|
4
9
|
position: ToastPosition;
|
|
10
|
+
/**
|
|
11
|
+
* The number of visible notifications that triggers the stack to auto-collapse.
|
|
12
|
+
* @defaultValue 5
|
|
13
|
+
*/
|
|
5
14
|
stackThreshold: number;
|
|
15
|
+
/**
|
|
16
|
+
* Whether to show the Expand/Collapse button in the header.
|
|
17
|
+
* @defaultValue true
|
|
18
|
+
*/
|
|
6
19
|
allowManualCollapse: boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Whether to show the Close All button in the header.
|
|
22
|
+
* @defaultValue true
|
|
23
|
+
*/
|
|
7
24
|
allowCloseAll: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* The design system prefix used to resolve child component tag names (e.g. buttons, icons).
|
|
27
|
+
* @defaultValue 'rapid'
|
|
28
|
+
*/
|
|
8
29
|
designSystemPrefix: string;
|
|
30
|
+
/**
|
|
31
|
+
* Whether to show the notification count in the header.
|
|
32
|
+
* @defaultValue true
|
|
33
|
+
*/
|
|
9
34
|
showCount: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* When set, notifications added simultaneously are revealed one-by-one with this delay (in ms)
|
|
37
|
+
* between each. Auto-close timers on individual notifications only begin once they are shown.
|
|
38
|
+
* Setting this to 0 disables queuing.
|
|
39
|
+
*
|
|
40
|
+
* When {@link NotifyContainerConfig.sortFn} is also set, each incoming notification that would
|
|
41
|
+
* not appear at the front of the collapsed stack will briefly peek at the front for half the
|
|
42
|
+
* interval duration before animating to its sorted position, making it visible to the user
|
|
43
|
+
* before it settles.
|
|
44
|
+
*
|
|
45
|
+
* @defaultValue 0
|
|
46
|
+
*/
|
|
47
|
+
notificationInterval: number;
|
|
48
|
+
/**
|
|
49
|
+
* An optional comparator function to sort visible notifications. Follows the same signature as
|
|
50
|
+
* `Array.sort` — return a negative number to sort `a` before `b` (i.e. higher in the stack).
|
|
51
|
+
* Re-applied automatically whenever the set of visible notifications changes.
|
|
52
|
+
* See {@link sortNotificationBySeverity} for a ready-made example.
|
|
53
|
+
* @defaultValue undefined (insertion order)
|
|
54
|
+
*/
|
|
55
|
+
sortFn?: (a: HTMLElement, b: HTMLElement) => number;
|
|
10
56
|
}
|
|
11
57
|
export declare class NotifyContainer extends GenesisElement implements NotifyContainerConfig {
|
|
12
58
|
position: ToastPosition;
|
|
@@ -16,7 +62,16 @@ export declare class NotifyContainer extends GenesisElement implements NotifyCon
|
|
|
16
62
|
designSystemPrefix: string;
|
|
17
63
|
showCount: boolean;
|
|
18
64
|
stackCollapsed: boolean;
|
|
65
|
+
notificationInterval: number;
|
|
66
|
+
sortFn?: (a: HTMLElement, b: HTMLElement) => number;
|
|
19
67
|
private manuallyExpanded;
|
|
68
|
+
private pendingQueue;
|
|
69
|
+
private queueTimer;
|
|
70
|
+
private queuedNodes;
|
|
71
|
+
private mutationObserver;
|
|
72
|
+
private knownNodes;
|
|
73
|
+
private peekingNode;
|
|
74
|
+
private peekTimer;
|
|
20
75
|
private routeSubscriber;
|
|
21
76
|
/** @internal */
|
|
22
77
|
connectedCallback(): void;
|
|
@@ -31,6 +86,16 @@ export declare class NotifyContainer extends GenesisElement implements NotifyCon
|
|
|
31
86
|
handleToggleCollapse(): void;
|
|
32
87
|
/** @internal */
|
|
33
88
|
handleCloseAll(): void;
|
|
89
|
+
/** @internal */
|
|
90
|
+
notificationIntervalChanged(_oldValue: number, newValue: number): void;
|
|
91
|
+
private handleMutation;
|
|
92
|
+
private processQueue;
|
|
93
|
+
private flushQueue;
|
|
94
|
+
/** @internal */
|
|
95
|
+
sortFnChanged(): void;
|
|
96
|
+
private applySort;
|
|
97
|
+
private maybePeek;
|
|
98
|
+
private cancelPeek;
|
|
34
99
|
/**
|
|
35
100
|
* Manages the absolute positioning of notifications to enable smooth stack-to-list animations.
|
|
36
101
|
* Uses a batch read/write pattern to avoid layout thrashing.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notify-container.d.ts","sourceRoot":"","sources":["../../../src/container/notify-container.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,cAAc,EAA0B,MAAM,uBAAuB,CAAC;AAEpG,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAIzC,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,aAAa,CAAC;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,aAAa,EAAE,OAAO,CAAC;IACvB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"notify-container.d.ts","sourceRoot":"","sources":["../../../src/container/notify-container.ts"],"names":[],"mappings":"AACA,OAAO,EAAuB,cAAc,EAA0B,MAAM,uBAAuB,CAAC;AAEpG,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAIzC,MAAM,WAAW,qBAAqB;IACpC;;;;OAIG;IACH,QAAQ,EAAE,aAAa,CAAC;IACxB;;;OAGG;IACH,cAAc,EAAE,MAAM,CAAC;IACvB;;;OAGG;IACH,mBAAmB,EAAE,OAAO,CAAC;IAC7B;;;OAGG;IACH,aAAa,EAAE,OAAO,CAAC;IACvB;;;OAGG;IACH,kBAAkB,EAAE,MAAM,CAAC;IAC3B;;;OAGG;IACH,SAAS,EAAE,OAAO,CAAC;IACnB;;;;;;;;;;;OAWG;IACH,oBAAoB,EAAE,MAAM,CAAC;IAC7B;;;;;;OAMG;IACH,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,KAAK,MAAM,CAAC;CACrD;AAKD,qBAKa,eAAgB,SAAQ,cAAe,YAAW,qBAAqB;IAC5E,QAAQ,EAAE,aAAa,CAAe;IACJ,cAAc,EAAE,MAAM,CAAqB;IACpB,mBAAmB,EAAE,OAAO,CACpF;IACkD,aAAa,EAAE,OAAO,CAAQ;IAC1C,kBAAkB,EAAE,MAAM,CAAW;IAC9B,SAAS,EAAE,OAAO,CAAQ;IAErB,cAAc,EAAE,OAAO,CAAS;IAC3C,oBAAoB,EAAE,MAAM,CAAK;IACnE,MAAM,CAAC,EAAE,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,EAAE,WAAW,KAAK,MAAM,CAAC;IAEhE,OAAO,CAAC,gBAAgB,CAAkB;IAC1C,OAAO,CAAC,YAAY,CAAqB;IACzC,OAAO,CAAC,UAAU,CAA8C;IAChE,OAAO,CAAC,WAAW,CAA+B;IAClD,OAAO,CAAC,gBAAgB,CAAiC;IACzD,OAAO,CAAC,UAAU,CAAwB;IAC1C,OAAO,CAAC,WAAW,CAA4B;IAC/C,OAAO,CAAC,SAAS,CAA8C;IAE/D,OAAO,CAAC,eAAe,CAErB;IAEF,gBAAgB;IAChB,iBAAiB,IAAI,IAAI;IAazB,oBAAoB,IAAI,IAAI;IAO5B,OAAO,CAAC,UAAU;IAUN,YAAY,EAAE,IAAI,EAAE,CAAM;IACtC,gBAAgB;IAChB,mBAAmB;IA4BnB,gBAAgB;IAChB,oBAAoB;IAQpB,gBAAgB;IAChB,oBAAoB;IAQpB,gBAAgB;IAChB,cAAc;IASd,gBAAgB;IAChB,2BAA2B,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM;IAM/D,OAAO,CAAC,cAAc;IAoBtB,OAAO,CAAC,YAAY;IAgBpB,OAAO,CAAC,UAAU;IAUlB,gBAAgB;IAChB,aAAa;IAIb,OAAO,CAAC,SAAS;IAejB,OAAO,CAAC,SAAS;IAkBjB,OAAO,CAAC,UAAU;IAMlB;;;;OAIG;IACH,OAAO,CAAC,cAAc;CAkBvB"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { NotifyContainer } from './notify-container';
|
|
1
|
+
import type { NotifyContainer } from './notify-container';
|
|
2
2
|
export declare const template: import("@microsoft/fast-element").ViewTemplate<NotifyContainer, any>;
|
|
3
3
|
//# sourceMappingURL=notify-container.template.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"notify-container.template.d.ts","sourceRoot":"","sources":["../../../src/container/notify-container.template.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"notify-container.template.d.ts","sourceRoot":"","sources":["../../../src/container/notify-container.template.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAoC1D,eAAO,MAAM,QAAQ,sEAUpB,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
const NOTIFY_TYPE_PRIORITY = {
|
|
2
|
+
error: 0,
|
|
3
|
+
warning: 1,
|
|
4
|
+
success: 2,
|
|
5
|
+
'': 3,
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* A ready-made sort comparator for use with {@link NotifyContainerConfig.sortFn} that places the
|
|
9
|
+
* most severe notifications at the top of the stack. Severity is determined by the `notify`
|
|
10
|
+
* attribute on each toast element: `error` (highest) → `warning` → `success` → unstyled (lowest).
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```ts
|
|
14
|
+
* configureNotifications({ sortFn: sortNotificationBySeverity });
|
|
15
|
+
* ```
|
|
16
|
+
* @public
|
|
17
|
+
*/
|
|
18
|
+
export const sortNotificationBySeverity = (a, b) => {
|
|
19
|
+
var _a, _b;
|
|
20
|
+
const aPriority = NOTIFY_TYPE_PRIORITY[(_a = a.getAttribute('notify')) !== null && _a !== void 0 ? _a : ''];
|
|
21
|
+
const bPriority = NOTIFY_TYPE_PRIORITY[(_b = b.getAttribute('notify')) !== null && _b !== void 0 ? _b : ''];
|
|
22
|
+
return aPriority - bPriority;
|
|
23
|
+
};
|
|
@@ -5,6 +5,7 @@ import { logger } from '../logger';
|
|
|
5
5
|
import { styles } from './notify-container.styles';
|
|
6
6
|
import { template } from './notify-container.template';
|
|
7
7
|
const DEFAULT_THRESHOLD = 5;
|
|
8
|
+
const PEEK_DURATION_MS = 1500;
|
|
8
9
|
let NotifyContainer = class NotifyContainer extends GenesisElement {
|
|
9
10
|
constructor() {
|
|
10
11
|
super(...arguments);
|
|
@@ -15,7 +16,15 @@ let NotifyContainer = class NotifyContainer extends GenesisElement {
|
|
|
15
16
|
this.designSystemPrefix = 'rapid';
|
|
16
17
|
this.showCount = true;
|
|
17
18
|
this.stackCollapsed = false;
|
|
19
|
+
this.notificationInterval = 0;
|
|
18
20
|
this.manuallyExpanded = false;
|
|
21
|
+
this.pendingQueue = [];
|
|
22
|
+
this.queueTimer = null;
|
|
23
|
+
this.queuedNodes = new Set();
|
|
24
|
+
this.mutationObserver = null;
|
|
25
|
+
this.knownNodes = new Set();
|
|
26
|
+
this.peekingNode = null;
|
|
27
|
+
this.peekTimer = null;
|
|
19
28
|
this.routeSubscriber = {
|
|
20
29
|
handleChange: () => this.checkRoute(RouteUtil.shared.pathName),
|
|
21
30
|
};
|
|
@@ -29,13 +38,22 @@ let NotifyContainer = class NotifyContainer extends GenesisElement {
|
|
|
29
38
|
}
|
|
30
39
|
Observable.getNotifier(RouteUtil.shared).subscribe(this.routeSubscriber, 'pathName');
|
|
31
40
|
this.checkRoute(RouteUtil.shared.pathName);
|
|
41
|
+
this.mutationObserver = new MutationObserver((mutations) => this.handleMutation(mutations));
|
|
42
|
+
this.mutationObserver.observe(this, { childList: true });
|
|
32
43
|
}
|
|
33
44
|
disconnectedCallback() {
|
|
45
|
+
var _a;
|
|
34
46
|
super.disconnectedCallback();
|
|
35
47
|
Observable.getNotifier(RouteUtil.shared).unsubscribe(this.routeSubscriber, 'pathName');
|
|
48
|
+
(_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
49
|
+
this.mutationObserver = null;
|
|
36
50
|
}
|
|
37
51
|
checkRoute(path) {
|
|
38
52
|
if (path.includes('/login') || path.includes('/logout')) {
|
|
53
|
+
this.pendingQueue = [];
|
|
54
|
+
this.queuedNodes.clear();
|
|
55
|
+
clearTimeout(this.queueTimer);
|
|
56
|
+
this.queueTimer = null;
|
|
39
57
|
this.handleCloseAll();
|
|
40
58
|
}
|
|
41
59
|
}
|
|
@@ -49,44 +67,141 @@ let NotifyContainer = class NotifyContainer extends GenesisElement {
|
|
|
49
67
|
if (this.stackCollapsed && this.slottedNodes.length <= 1) {
|
|
50
68
|
this.stackCollapsed = false;
|
|
51
69
|
this.manuallyExpanded = false;
|
|
70
|
+
this.cancelPeek();
|
|
52
71
|
}
|
|
53
|
-
this.
|
|
72
|
+
if (this.stackCollapsed) {
|
|
73
|
+
const newNode = this.slottedNodes
|
|
74
|
+
.filter((n) => n instanceof HTMLElement && !this.knownNodes.has(n))
|
|
75
|
+
.shift();
|
|
76
|
+
if (newNode) {
|
|
77
|
+
this.maybePeek(newNode);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
this.knownNodes = new Set(this.slottedNodes);
|
|
81
|
+
this.applySort();
|
|
54
82
|
}
|
|
55
83
|
/** @internal */
|
|
56
84
|
handleContainerClick() {
|
|
57
85
|
if (this.stackCollapsed) {
|
|
58
86
|
this.stackCollapsed = false;
|
|
59
87
|
this.manuallyExpanded = true;
|
|
88
|
+
this.cancelPeek();
|
|
60
89
|
}
|
|
61
90
|
}
|
|
62
91
|
/** @internal */
|
|
63
92
|
handleToggleCollapse() {
|
|
64
93
|
this.stackCollapsed = !this.stackCollapsed;
|
|
65
94
|
this.manuallyExpanded = !this.stackCollapsed;
|
|
95
|
+
if (!this.stackCollapsed) {
|
|
96
|
+
this.cancelPeek();
|
|
97
|
+
}
|
|
66
98
|
}
|
|
67
99
|
/** @internal */
|
|
68
100
|
handleCloseAll() {
|
|
101
|
+
this.cancelPeek();
|
|
69
102
|
while (this.firstChild) {
|
|
70
103
|
this.removeChild(this.firstChild);
|
|
71
104
|
}
|
|
72
105
|
this.stackCollapsed = false;
|
|
73
106
|
this.manuallyExpanded = false;
|
|
74
107
|
}
|
|
108
|
+
/** @internal */
|
|
109
|
+
notificationIntervalChanged(_oldValue, newValue) {
|
|
110
|
+
if (!newValue && this.pendingQueue) {
|
|
111
|
+
this.flushQueue();
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
handleMutation(mutations) {
|
|
115
|
+
if (!this.notificationInterval)
|
|
116
|
+
return;
|
|
117
|
+
mutations.forEach((mutation) => {
|
|
118
|
+
mutation.addedNodes.forEach((node) => {
|
|
119
|
+
if (!(node instanceof HTMLElement))
|
|
120
|
+
return;
|
|
121
|
+
if (this.queuedNodes.has(node)) {
|
|
122
|
+
this.queuedNodes.delete(node);
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
this.removeChild(node);
|
|
126
|
+
this.pendingQueue.push(node);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
if (!this.queueTimer) {
|
|
131
|
+
this.processQueue();
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
processQueue() {
|
|
135
|
+
if (!this.pendingQueue.length) {
|
|
136
|
+
this.queueTimer = null;
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
const next = this.pendingQueue.shift();
|
|
140
|
+
this.queuedNodes.add(next);
|
|
141
|
+
this.prepend(next);
|
|
142
|
+
this.queueTimer = setTimeout(() => {
|
|
143
|
+
this.queueTimer = null;
|
|
144
|
+
this.processQueue();
|
|
145
|
+
}, this.notificationInterval);
|
|
146
|
+
}
|
|
147
|
+
flushQueue() {
|
|
148
|
+
clearTimeout(this.queueTimer);
|
|
149
|
+
this.queueTimer = null;
|
|
150
|
+
while (this.pendingQueue.length) {
|
|
151
|
+
const next = this.pendingQueue.shift();
|
|
152
|
+
this.queuedNodes.add(next);
|
|
153
|
+
this.prepend(next);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
/** @internal */
|
|
157
|
+
sortFnChanged() {
|
|
158
|
+
this.applySort();
|
|
159
|
+
}
|
|
160
|
+
applySort() {
|
|
161
|
+
const toasts = this.slottedNodes.filter((node) => node instanceof HTMLElement);
|
|
162
|
+
if (!toasts.length)
|
|
163
|
+
return;
|
|
164
|
+
const sorted = this.sortFn && toasts.length > 1 ? [...toasts].sort(this.sortFn) : toasts;
|
|
165
|
+
if (this.peekingNode && sorted.includes(this.peekingNode)) {
|
|
166
|
+
this.handlePosition([this.peekingNode, ...sorted.filter((n) => n !== this.peekingNode)]);
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
this.handlePosition(sorted);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
maybePeek(newNode) {
|
|
173
|
+
const toasts = this.slottedNodes.filter((node) => node instanceof HTMLElement);
|
|
174
|
+
const sorted = this.sortFn && toasts.length > 1 ? [...toasts].sort(this.sortFn) : toasts;
|
|
175
|
+
if (sorted.indexOf(newNode) === 0)
|
|
176
|
+
return;
|
|
177
|
+
this.cancelPeek();
|
|
178
|
+
this.peekingNode = newNode;
|
|
179
|
+
const duration = this.notificationInterval ? this.notificationInterval / 2 : PEEK_DURATION_MS;
|
|
180
|
+
this.peekTimer = setTimeout(() => {
|
|
181
|
+
this.peekingNode = null;
|
|
182
|
+
this.peekTimer = null;
|
|
183
|
+
this.applySort();
|
|
184
|
+
}, duration);
|
|
185
|
+
}
|
|
186
|
+
cancelPeek() {
|
|
187
|
+
clearTimeout(this.peekTimer);
|
|
188
|
+
this.peekTimer = null;
|
|
189
|
+
this.peekingNode = null;
|
|
190
|
+
}
|
|
75
191
|
/**
|
|
76
192
|
* Manages the absolute positioning of notifications to enable smooth stack-to-list animations.
|
|
77
193
|
* Uses a batch read/write pattern to avoid layout thrashing.
|
|
78
194
|
* @internal
|
|
79
195
|
*/
|
|
80
|
-
handlePosition() {
|
|
81
|
-
|
|
82
|
-
if (!toasts.length) {
|
|
196
|
+
handlePosition(toasts) {
|
|
197
|
+
if (!toasts.length)
|
|
83
198
|
return;
|
|
84
|
-
}
|
|
85
199
|
toasts.forEach((toast, index) => {
|
|
86
200
|
toast.style.position = 'absolute';
|
|
87
201
|
toast.style.transition = 'all 0.3s ease-in';
|
|
88
202
|
toast.style.right = '0px';
|
|
89
203
|
toast.style.zIndex = (toasts.length - index).toString();
|
|
204
|
+
toast.dataset.stackIndex = index.toString();
|
|
90
205
|
});
|
|
91
206
|
const heights = toasts.map((toast) => toast.offsetHeight);
|
|
92
207
|
toasts.reduce((yOffset, toast, index) => {
|
|
@@ -116,6 +231,12 @@ __decorate([
|
|
|
116
231
|
__decorate([
|
|
117
232
|
attr({ attribute: 'stack-collapsed', mode: 'boolean' })
|
|
118
233
|
], NotifyContainer.prototype, "stackCollapsed", void 0);
|
|
234
|
+
__decorate([
|
|
235
|
+
attr({ attribute: 'notification-interval' })
|
|
236
|
+
], NotifyContainer.prototype, "notificationInterval", void 0);
|
|
237
|
+
__decorate([
|
|
238
|
+
observable
|
|
239
|
+
], NotifyContainer.prototype, "sortFn", void 0);
|
|
119
240
|
__decorate([
|
|
120
241
|
observable
|
|
121
242
|
], NotifyContainer.prototype, "slottedNodes", void 0);
|
|
@@ -175,7 +175,7 @@ export const styles = css `
|
|
|
175
175
|
|
|
176
176
|
/* Show and offset the top 3 items in the stack */
|
|
177
177
|
|
|
178
|
-
:host([stack-collapsed]) ::slotted(
|
|
178
|
+
:host([stack-collapsed]) ::slotted([data-stack-index='0']) {
|
|
179
179
|
opacity: 100%;
|
|
180
180
|
pointer-events: auto;
|
|
181
181
|
transform: translateY(0) scale(1);
|
|
@@ -183,14 +183,14 @@ export const styles = css `
|
|
|
183
183
|
position: relative !important;
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
-
:host([stack-collapsed]) ::slotted(
|
|
186
|
+
:host([stack-collapsed]) ::slotted([data-stack-index='1']) {
|
|
187
187
|
opacity: 100%;
|
|
188
188
|
transform: translateY(var(--stack-offset-y, 8px)) scale(0.95);
|
|
189
189
|
z-index: 2;
|
|
190
190
|
position: relative !important;
|
|
191
191
|
}
|
|
192
192
|
|
|
193
|
-
:host([stack-collapsed]) ::slotted(
|
|
193
|
+
:host([stack-collapsed]) ::slotted([data-stack-index='2']) {
|
|
194
194
|
opacity: 100%;
|
|
195
195
|
transform: translateY(var(--stack-offset-y-2, 16px)) scale(0.9);
|
|
196
196
|
z-index: 1;
|
|
@@ -2781,6 +2781,36 @@
|
|
|
2781
2781
|
"isAbstract": false,
|
|
2782
2782
|
"name": "disconnectedCallback"
|
|
2783
2783
|
},
|
|
2784
|
+
{
|
|
2785
|
+
"kind": "Property",
|
|
2786
|
+
"canonicalReference": "@genesislcap/foundation-notifications!NotifyContainer#notificationInterval:member",
|
|
2787
|
+
"docComment": "",
|
|
2788
|
+
"excerptTokens": [
|
|
2789
|
+
{
|
|
2790
|
+
"kind": "Content",
|
|
2791
|
+
"text": "notificationInterval: "
|
|
2792
|
+
},
|
|
2793
|
+
{
|
|
2794
|
+
"kind": "Content",
|
|
2795
|
+
"text": "number"
|
|
2796
|
+
},
|
|
2797
|
+
{
|
|
2798
|
+
"kind": "Content",
|
|
2799
|
+
"text": ";"
|
|
2800
|
+
}
|
|
2801
|
+
],
|
|
2802
|
+
"isReadonly": false,
|
|
2803
|
+
"isOptional": false,
|
|
2804
|
+
"releaseTag": "Public",
|
|
2805
|
+
"name": "notificationInterval",
|
|
2806
|
+
"propertyTypeTokenRange": {
|
|
2807
|
+
"startIndex": 1,
|
|
2808
|
+
"endIndex": 2
|
|
2809
|
+
},
|
|
2810
|
+
"isStatic": false,
|
|
2811
|
+
"isProtected": false,
|
|
2812
|
+
"isAbstract": false
|
|
2813
|
+
},
|
|
2784
2814
|
{
|
|
2785
2815
|
"kind": "Property",
|
|
2786
2816
|
"canonicalReference": "@genesislcap/foundation-notifications!NotifyContainer#position:member",
|
|
@@ -2877,6 +2907,54 @@
|
|
|
2877
2907
|
"isProtected": false,
|
|
2878
2908
|
"isAbstract": false
|
|
2879
2909
|
},
|
|
2910
|
+
{
|
|
2911
|
+
"kind": "Property",
|
|
2912
|
+
"canonicalReference": "@genesislcap/foundation-notifications!NotifyContainer#sortFn:member",
|
|
2913
|
+
"docComment": "",
|
|
2914
|
+
"excerptTokens": [
|
|
2915
|
+
{
|
|
2916
|
+
"kind": "Content",
|
|
2917
|
+
"text": "sortFn?: "
|
|
2918
|
+
},
|
|
2919
|
+
{
|
|
2920
|
+
"kind": "Content",
|
|
2921
|
+
"text": "(a: "
|
|
2922
|
+
},
|
|
2923
|
+
{
|
|
2924
|
+
"kind": "Reference",
|
|
2925
|
+
"text": "HTMLElement",
|
|
2926
|
+
"canonicalReference": "!HTMLElement:interface"
|
|
2927
|
+
},
|
|
2928
|
+
{
|
|
2929
|
+
"kind": "Content",
|
|
2930
|
+
"text": ", b: "
|
|
2931
|
+
},
|
|
2932
|
+
{
|
|
2933
|
+
"kind": "Reference",
|
|
2934
|
+
"text": "HTMLElement",
|
|
2935
|
+
"canonicalReference": "!HTMLElement:interface"
|
|
2936
|
+
},
|
|
2937
|
+
{
|
|
2938
|
+
"kind": "Content",
|
|
2939
|
+
"text": ") => number"
|
|
2940
|
+
},
|
|
2941
|
+
{
|
|
2942
|
+
"kind": "Content",
|
|
2943
|
+
"text": ";"
|
|
2944
|
+
}
|
|
2945
|
+
],
|
|
2946
|
+
"isReadonly": false,
|
|
2947
|
+
"isOptional": true,
|
|
2948
|
+
"releaseTag": "Public",
|
|
2949
|
+
"name": "sortFn",
|
|
2950
|
+
"propertyTypeTokenRange": {
|
|
2951
|
+
"startIndex": 1,
|
|
2952
|
+
"endIndex": 6
|
|
2953
|
+
},
|
|
2954
|
+
"isStatic": false,
|
|
2955
|
+
"isProtected": false,
|
|
2956
|
+
"isAbstract": false
|
|
2957
|
+
},
|
|
2880
2958
|
{
|
|
2881
2959
|
"kind": "Property",
|
|
2882
2960
|
"canonicalReference": "@genesislcap/foundation-notifications!NotifyContainer#stackCollapsed:member",
|
|
@@ -2967,7 +3045,7 @@
|
|
|
2967
3045
|
{
|
|
2968
3046
|
"kind": "PropertySignature",
|
|
2969
3047
|
"canonicalReference": "@genesislcap/foundation-notifications!NotifyContainerConfig#allowCloseAll:member",
|
|
2970
|
-
"docComment": "",
|
|
3048
|
+
"docComment": "/**\n * Whether to show the Close All button in the header.\n *\n * @defaultValue\n *\n * true\n */\n",
|
|
2971
3049
|
"excerptTokens": [
|
|
2972
3050
|
{
|
|
2973
3051
|
"kind": "Content",
|
|
@@ -2994,7 +3072,7 @@
|
|
|
2994
3072
|
{
|
|
2995
3073
|
"kind": "PropertySignature",
|
|
2996
3074
|
"canonicalReference": "@genesislcap/foundation-notifications!NotifyContainerConfig#allowManualCollapse:member",
|
|
2997
|
-
"docComment": "",
|
|
3075
|
+
"docComment": "/**\n * Whether to show the Expand/Collapse button in the header.\n *\n * @defaultValue\n *\n * true\n */\n",
|
|
2998
3076
|
"excerptTokens": [
|
|
2999
3077
|
{
|
|
3000
3078
|
"kind": "Content",
|
|
@@ -3021,7 +3099,7 @@
|
|
|
3021
3099
|
{
|
|
3022
3100
|
"kind": "PropertySignature",
|
|
3023
3101
|
"canonicalReference": "@genesislcap/foundation-notifications!NotifyContainerConfig#designSystemPrefix:member",
|
|
3024
|
-
"docComment": "",
|
|
3102
|
+
"docComment": "/**\n * The design system prefix used to resolve child component tag names (e.g. buttons, icons).\n *\n * @defaultValue\n *\n * 'rapid'\n */\n",
|
|
3025
3103
|
"excerptTokens": [
|
|
3026
3104
|
{
|
|
3027
3105
|
"kind": "Content",
|
|
@@ -3045,10 +3123,37 @@
|
|
|
3045
3123
|
"endIndex": 2
|
|
3046
3124
|
}
|
|
3047
3125
|
},
|
|
3126
|
+
{
|
|
3127
|
+
"kind": "PropertySignature",
|
|
3128
|
+
"canonicalReference": "@genesislcap/foundation-notifications!NotifyContainerConfig#notificationInterval:member",
|
|
3129
|
+
"docComment": "/**\n * When set, notifications added simultaneously are revealed one-by-one with this delay (in ms) between each. Auto-close timers on individual notifications only begin once they are shown. Setting this to 0 disables queuing.\n *\n * When {@link NotifyContainerConfig.sortFn} is also set, each incoming notification that would not appear at the front of the collapsed stack will briefly peek at the front for half the interval duration before animating to its sorted position, making it visible to the user before it settles.\n *\n * @defaultValue\n *\n * 0\n */\n",
|
|
3130
|
+
"excerptTokens": [
|
|
3131
|
+
{
|
|
3132
|
+
"kind": "Content",
|
|
3133
|
+
"text": "notificationInterval: "
|
|
3134
|
+
},
|
|
3135
|
+
{
|
|
3136
|
+
"kind": "Content",
|
|
3137
|
+
"text": "number"
|
|
3138
|
+
},
|
|
3139
|
+
{
|
|
3140
|
+
"kind": "Content",
|
|
3141
|
+
"text": ";"
|
|
3142
|
+
}
|
|
3143
|
+
],
|
|
3144
|
+
"isReadonly": false,
|
|
3145
|
+
"isOptional": false,
|
|
3146
|
+
"releaseTag": "Public",
|
|
3147
|
+
"name": "notificationInterval",
|
|
3148
|
+
"propertyTypeTokenRange": {
|
|
3149
|
+
"startIndex": 1,
|
|
3150
|
+
"endIndex": 2
|
|
3151
|
+
}
|
|
3152
|
+
},
|
|
3048
3153
|
{
|
|
3049
3154
|
"kind": "PropertySignature",
|
|
3050
3155
|
"canonicalReference": "@genesislcap/foundation-notifications!NotifyContainerConfig#position:member",
|
|
3051
|
-
"docComment": "",
|
|
3156
|
+
"docComment": "/**\n * The corner of the screen where notifications appear. Note: bottom-left and bottom-right are not currently supported.\n *\n * @defaultValue\n *\n * 'top-right'\n */\n",
|
|
3052
3157
|
"excerptTokens": [
|
|
3053
3158
|
{
|
|
3054
3159
|
"kind": "Content",
|
|
@@ -3076,7 +3181,7 @@
|
|
|
3076
3181
|
{
|
|
3077
3182
|
"kind": "PropertySignature",
|
|
3078
3183
|
"canonicalReference": "@genesislcap/foundation-notifications!NotifyContainerConfig#showCount:member",
|
|
3079
|
-
"docComment": "",
|
|
3184
|
+
"docComment": "/**\n * Whether to show the notification count in the header.\n *\n * @defaultValue\n *\n * true\n */\n",
|
|
3080
3185
|
"excerptTokens": [
|
|
3081
3186
|
{
|
|
3082
3187
|
"kind": "Content",
|
|
@@ -3100,10 +3205,55 @@
|
|
|
3100
3205
|
"endIndex": 2
|
|
3101
3206
|
}
|
|
3102
3207
|
},
|
|
3208
|
+
{
|
|
3209
|
+
"kind": "PropertySignature",
|
|
3210
|
+
"canonicalReference": "@genesislcap/foundation-notifications!NotifyContainerConfig#sortFn:member",
|
|
3211
|
+
"docComment": "/**\n * An optional comparator function to sort visible notifications. Follows the same signature as `Array.sort` — return a negative number to sort `a` before `b` (i.e. higher in the stack). Re-applied automatically whenever the set of visible notifications changes. See {@link sortNotificationBySeverity} for a ready-made example.\n *\n * @defaultValue\n *\n * undefined (insertion order)\n */\n",
|
|
3212
|
+
"excerptTokens": [
|
|
3213
|
+
{
|
|
3214
|
+
"kind": "Content",
|
|
3215
|
+
"text": "sortFn?: "
|
|
3216
|
+
},
|
|
3217
|
+
{
|
|
3218
|
+
"kind": "Content",
|
|
3219
|
+
"text": "(a: "
|
|
3220
|
+
},
|
|
3221
|
+
{
|
|
3222
|
+
"kind": "Reference",
|
|
3223
|
+
"text": "HTMLElement",
|
|
3224
|
+
"canonicalReference": "!HTMLElement:interface"
|
|
3225
|
+
},
|
|
3226
|
+
{
|
|
3227
|
+
"kind": "Content",
|
|
3228
|
+
"text": ", b: "
|
|
3229
|
+
},
|
|
3230
|
+
{
|
|
3231
|
+
"kind": "Reference",
|
|
3232
|
+
"text": "HTMLElement",
|
|
3233
|
+
"canonicalReference": "!HTMLElement:interface"
|
|
3234
|
+
},
|
|
3235
|
+
{
|
|
3236
|
+
"kind": "Content",
|
|
3237
|
+
"text": ") => number"
|
|
3238
|
+
},
|
|
3239
|
+
{
|
|
3240
|
+
"kind": "Content",
|
|
3241
|
+
"text": ";"
|
|
3242
|
+
}
|
|
3243
|
+
],
|
|
3244
|
+
"isReadonly": false,
|
|
3245
|
+
"isOptional": true,
|
|
3246
|
+
"releaseTag": "Public",
|
|
3247
|
+
"name": "sortFn",
|
|
3248
|
+
"propertyTypeTokenRange": {
|
|
3249
|
+
"startIndex": 1,
|
|
3250
|
+
"endIndex": 6
|
|
3251
|
+
}
|
|
3252
|
+
},
|
|
3103
3253
|
{
|
|
3104
3254
|
"kind": "PropertySignature",
|
|
3105
3255
|
"canonicalReference": "@genesislcap/foundation-notifications!NotifyContainerConfig#stackThreshold:member",
|
|
3106
|
-
"docComment": "",
|
|
3256
|
+
"docComment": "/**\n * The number of visible notifications that triggers the stack to auto-collapse.\n *\n * @defaultValue\n *\n * 5\n */\n",
|
|
3107
3257
|
"excerptTokens": [
|
|
3108
3258
|
{
|
|
3109
3259
|
"kind": "Content",
|
|
@@ -4072,6 +4222,65 @@
|
|
|
4072
4222
|
"endIndex": 2
|
|
4073
4223
|
}
|
|
4074
4224
|
},
|
|
4225
|
+
{
|
|
4226
|
+
"kind": "Function",
|
|
4227
|
+
"canonicalReference": "@genesislcap/foundation-notifications!sortNotificationBySeverity:function(1)",
|
|
4228
|
+
"docComment": "/**\n * A ready-made sort comparator for use with {@link NotifyContainerConfig.sortFn} that places the most severe notifications at the top of the stack. Severity is determined by the `notify` attribute on each toast element: `error` (highest) → `warning` → `success` → unstyled (lowest).\n *\n * @example\n * ```ts\n * configureNotifications({ sortFn: sortNotificationBySeverity });\n * ```\n *\n * @public\n */\n",
|
|
4229
|
+
"excerptTokens": [
|
|
4230
|
+
{
|
|
4231
|
+
"kind": "Content",
|
|
4232
|
+
"text": "sortNotificationBySeverity: (a: "
|
|
4233
|
+
},
|
|
4234
|
+
{
|
|
4235
|
+
"kind": "Reference",
|
|
4236
|
+
"text": "HTMLElement",
|
|
4237
|
+
"canonicalReference": "!HTMLElement:interface"
|
|
4238
|
+
},
|
|
4239
|
+
{
|
|
4240
|
+
"kind": "Content",
|
|
4241
|
+
"text": ", b: "
|
|
4242
|
+
},
|
|
4243
|
+
{
|
|
4244
|
+
"kind": "Reference",
|
|
4245
|
+
"text": "HTMLElement",
|
|
4246
|
+
"canonicalReference": "!HTMLElement:interface"
|
|
4247
|
+
},
|
|
4248
|
+
{
|
|
4249
|
+
"kind": "Content",
|
|
4250
|
+
"text": ") => "
|
|
4251
|
+
},
|
|
4252
|
+
{
|
|
4253
|
+
"kind": "Content",
|
|
4254
|
+
"text": "number"
|
|
4255
|
+
}
|
|
4256
|
+
],
|
|
4257
|
+
"fileUrlPath": "src/container/notify-container-sorters.ts",
|
|
4258
|
+
"returnTypeTokenRange": {
|
|
4259
|
+
"startIndex": 5,
|
|
4260
|
+
"endIndex": 6
|
|
4261
|
+
},
|
|
4262
|
+
"releaseTag": "Public",
|
|
4263
|
+
"overloadIndex": 1,
|
|
4264
|
+
"parameters": [
|
|
4265
|
+
{
|
|
4266
|
+
"parameterName": "a",
|
|
4267
|
+
"parameterTypeTokenRange": {
|
|
4268
|
+
"startIndex": 1,
|
|
4269
|
+
"endIndex": 2
|
|
4270
|
+
},
|
|
4271
|
+
"isOptional": false
|
|
4272
|
+
},
|
|
4273
|
+
{
|
|
4274
|
+
"parameterName": "b",
|
|
4275
|
+
"parameterTypeTokenRange": {
|
|
4276
|
+
"startIndex": 3,
|
|
4277
|
+
"endIndex": 4
|
|
4278
|
+
},
|
|
4279
|
+
"isOptional": false
|
|
4280
|
+
}
|
|
4281
|
+
],
|
|
4282
|
+
"name": "sortNotificationBySeverity"
|
|
4283
|
+
},
|
|
4075
4284
|
{
|
|
4076
4285
|
"kind": "Interface",
|
|
4077
4286
|
"canonicalReference": "@genesislcap/foundation-notifications!Toast:interface",
|
|
@@ -391,7 +391,16 @@ export declare class NotifyContainer extends GenesisElement implements NotifyCon
|
|
|
391
391
|
designSystemPrefix: string;
|
|
392
392
|
showCount: boolean;
|
|
393
393
|
stackCollapsed: boolean;
|
|
394
|
+
notificationInterval: number;
|
|
395
|
+
sortFn?: (a: HTMLElement, b: HTMLElement) => number;
|
|
394
396
|
private manuallyExpanded;
|
|
397
|
+
private pendingQueue;
|
|
398
|
+
private queueTimer;
|
|
399
|
+
private queuedNodes;
|
|
400
|
+
private mutationObserver;
|
|
401
|
+
private knownNodes;
|
|
402
|
+
private peekingNode;
|
|
403
|
+
private peekTimer;
|
|
395
404
|
private routeSubscriber;
|
|
396
405
|
/** @internal */
|
|
397
406
|
connectedCallback(): void;
|
|
@@ -406,6 +415,16 @@ export declare class NotifyContainer extends GenesisElement implements NotifyCon
|
|
|
406
415
|
handleToggleCollapse(): void;
|
|
407
416
|
/** @internal */
|
|
408
417
|
handleCloseAll(): void;
|
|
418
|
+
/** @internal */
|
|
419
|
+
notificationIntervalChanged(_oldValue: number, newValue: number): void;
|
|
420
|
+
private handleMutation;
|
|
421
|
+
private processQueue;
|
|
422
|
+
private flushQueue;
|
|
423
|
+
/** @internal */
|
|
424
|
+
sortFnChanged(): void;
|
|
425
|
+
private applySort;
|
|
426
|
+
private maybePeek;
|
|
427
|
+
private cancelPeek;
|
|
409
428
|
/**
|
|
410
429
|
* Manages the absolute positioning of notifications to enable smooth stack-to-list animations.
|
|
411
430
|
* Uses a batch read/write pattern to avoid layout thrashing.
|
|
@@ -415,12 +434,58 @@ export declare class NotifyContainer extends GenesisElement implements NotifyCon
|
|
|
415
434
|
}
|
|
416
435
|
|
|
417
436
|
export declare interface NotifyContainerConfig {
|
|
437
|
+
/**
|
|
438
|
+
* The corner of the screen where notifications appear.
|
|
439
|
+
* Note: bottom-left and bottom-right are not currently supported.
|
|
440
|
+
* @defaultValue 'top-right'
|
|
441
|
+
*/
|
|
418
442
|
position: ToastPosition;
|
|
443
|
+
/**
|
|
444
|
+
* The number of visible notifications that triggers the stack to auto-collapse.
|
|
445
|
+
* @defaultValue 5
|
|
446
|
+
*/
|
|
419
447
|
stackThreshold: number;
|
|
448
|
+
/**
|
|
449
|
+
* Whether to show the Expand/Collapse button in the header.
|
|
450
|
+
* @defaultValue true
|
|
451
|
+
*/
|
|
420
452
|
allowManualCollapse: boolean;
|
|
453
|
+
/**
|
|
454
|
+
* Whether to show the Close All button in the header.
|
|
455
|
+
* @defaultValue true
|
|
456
|
+
*/
|
|
421
457
|
allowCloseAll: boolean;
|
|
458
|
+
/**
|
|
459
|
+
* The design system prefix used to resolve child component tag names (e.g. buttons, icons).
|
|
460
|
+
* @defaultValue 'rapid'
|
|
461
|
+
*/
|
|
422
462
|
designSystemPrefix: string;
|
|
463
|
+
/**
|
|
464
|
+
* Whether to show the notification count in the header.
|
|
465
|
+
* @defaultValue true
|
|
466
|
+
*/
|
|
423
467
|
showCount: boolean;
|
|
468
|
+
/**
|
|
469
|
+
* When set, notifications added simultaneously are revealed one-by-one with this delay (in ms)
|
|
470
|
+
* between each. Auto-close timers on individual notifications only begin once they are shown.
|
|
471
|
+
* Setting this to 0 disables queuing.
|
|
472
|
+
*
|
|
473
|
+
* When {@link NotifyContainerConfig.sortFn} is also set, each incoming notification that would
|
|
474
|
+
* not appear at the front of the collapsed stack will briefly peek at the front for half the
|
|
475
|
+
* interval duration before animating to its sorted position, making it visible to the user
|
|
476
|
+
* before it settles.
|
|
477
|
+
*
|
|
478
|
+
* @defaultValue 0
|
|
479
|
+
*/
|
|
480
|
+
notificationInterval: number;
|
|
481
|
+
/**
|
|
482
|
+
* An optional comparator function to sort visible notifications. Follows the same signature as
|
|
483
|
+
* `Array.sort` — return a negative number to sort `a` before `b` (i.e. higher in the stack).
|
|
484
|
+
* Re-applied automatically whenever the set of visible notifications changes.
|
|
485
|
+
* See {@link sortNotificationBySeverity} for a ready-made example.
|
|
486
|
+
* @defaultValue undefined (insertion order)
|
|
487
|
+
*/
|
|
488
|
+
sortFn?: (a: HTMLElement, b: HTMLElement) => number;
|
|
424
489
|
}
|
|
425
490
|
|
|
426
491
|
/**
|
|
@@ -568,6 +633,19 @@ export declare interface SnackbarStructure {
|
|
|
568
633
|
*/
|
|
569
634
|
export declare type SnackbarType = 'error' | 'success';
|
|
570
635
|
|
|
636
|
+
/**
|
|
637
|
+
* A ready-made sort comparator for use with {@link NotifyContainerConfig.sortFn} that places the
|
|
638
|
+
* most severe notifications at the top of the stack. Severity is determined by the `notify`
|
|
639
|
+
* attribute on each toast element: `error` (highest) → `warning` → `success` → unstyled (lowest).
|
|
640
|
+
*
|
|
641
|
+
* @example
|
|
642
|
+
* ```ts
|
|
643
|
+
* configureNotifications({ sortFn: sortNotificationBySeverity });
|
|
644
|
+
* ```
|
|
645
|
+
* @public
|
|
646
|
+
*/
|
|
647
|
+
export declare const sortNotificationBySeverity: (a: HTMLElement, b: HTMLElement) => number;
|
|
648
|
+
|
|
571
649
|
/**
|
|
572
650
|
* Interface for Toast configuration
|
|
573
651
|
* @public
|
|
@@ -317,6 +317,17 @@ Shows the notification snackbar
|
|
|
317
317
|
Shows the notification toast
|
|
318
318
|
|
|
319
319
|
|
|
320
|
+
</td></tr>
|
|
321
|
+
<tr><td>
|
|
322
|
+
|
|
323
|
+
[sortNotificationBySeverity(a, b)](./foundation-notifications.sortnotificationbyseverity.md)
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
</td><td>
|
|
327
|
+
|
|
328
|
+
A ready-made sort comparator for use with [NotifyContainerConfig.sortFn](./foundation-notifications.notifycontainerconfig.sortfn.md) that places the most severe notifications at the top of the stack. Severity is determined by the `notify` attribute on each toast element: `error` (highest) → `warning` → `success` → unstyled (lowest).
|
|
329
|
+
|
|
330
|
+
|
|
320
331
|
</td></tr>
|
|
321
332
|
</tbody></table>
|
|
322
333
|
|
|
@@ -86,6 +86,23 @@ string
|
|
|
86
86
|
</td><td>
|
|
87
87
|
|
|
88
88
|
|
|
89
|
+
</td></tr>
|
|
90
|
+
<tr><td>
|
|
91
|
+
|
|
92
|
+
[notificationInterval](./foundation-notifications.notifycontainer.notificationinterval.md)
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
</td><td>
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
</td><td>
|
|
99
|
+
|
|
100
|
+
number
|
|
101
|
+
|
|
102
|
+
|
|
103
|
+
</td><td>
|
|
104
|
+
|
|
105
|
+
|
|
89
106
|
</td></tr>
|
|
90
107
|
<tr><td>
|
|
91
108
|
|
|
@@ -137,6 +154,25 @@ Node\[\]
|
|
|
137
154
|
</td><td>
|
|
138
155
|
|
|
139
156
|
|
|
157
|
+
</td></tr>
|
|
158
|
+
<tr><td>
|
|
159
|
+
|
|
160
|
+
[sortFn?](./foundation-notifications.notifycontainer.sortfn.md)
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
</td><td>
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
</td><td>
|
|
167
|
+
|
|
168
|
+
(a: HTMLElement, b: HTMLElement) => number
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
</td><td>
|
|
172
|
+
|
|
173
|
+
_(Optional)_
|
|
174
|
+
|
|
175
|
+
|
|
140
176
|
</td></tr>
|
|
141
177
|
<tr><td>
|
|
142
178
|
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@genesislcap/foundation-notifications](./foundation-notifications.md) > [NotifyContainer](./foundation-notifications.notifycontainer.md) > [notificationInterval](./foundation-notifications.notifycontainer.notificationinterval.md)
|
|
4
|
+
|
|
5
|
+
## NotifyContainer.notificationInterval property
|
|
6
|
+
|
|
7
|
+
**Signature:**
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
notificationInterval: number;
|
|
11
|
+
```
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@genesislcap/foundation-notifications](./foundation-notifications.md) > [NotifyContainer](./foundation-notifications.notifycontainer.md) > [sortFn](./foundation-notifications.notifycontainer.sortfn.md)
|
|
4
|
+
|
|
5
|
+
## NotifyContainer.sortFn property
|
|
6
|
+
|
|
7
|
+
**Signature:**
|
|
8
|
+
|
|
9
|
+
```typescript
|
|
10
|
+
sortFn?: (a: HTMLElement, b: HTMLElement) => number;
|
|
11
|
+
```
|
|
@@ -48,6 +48,8 @@ boolean
|
|
|
48
48
|
|
|
49
49
|
</td><td>
|
|
50
50
|
|
|
51
|
+
Whether to show the Close All button in the header.
|
|
52
|
+
|
|
51
53
|
|
|
52
54
|
</td></tr>
|
|
53
55
|
<tr><td>
|
|
@@ -65,6 +67,8 @@ boolean
|
|
|
65
67
|
|
|
66
68
|
</td><td>
|
|
67
69
|
|
|
70
|
+
Whether to show the Expand/Collapse button in the header.
|
|
71
|
+
|
|
68
72
|
|
|
69
73
|
</td></tr>
|
|
70
74
|
<tr><td>
|
|
@@ -82,6 +86,29 @@ string
|
|
|
82
86
|
|
|
83
87
|
</td><td>
|
|
84
88
|
|
|
89
|
+
The design system prefix used to resolve child component tag names (e.g. buttons, icons).
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
</td></tr>
|
|
93
|
+
<tr><td>
|
|
94
|
+
|
|
95
|
+
[notificationInterval](./foundation-notifications.notifycontainerconfig.notificationinterval.md)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
</td><td>
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
</td><td>
|
|
102
|
+
|
|
103
|
+
number
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
</td><td>
|
|
107
|
+
|
|
108
|
+
When set, notifications added simultaneously are revealed one-by-one with this delay (in ms) between each. Auto-close timers on individual notifications only begin once they are shown. Setting this to 0 disables queuing.
|
|
109
|
+
|
|
110
|
+
When [NotifyContainerConfig.sortFn](./foundation-notifications.notifycontainerconfig.sortfn.md) is also set, each incoming notification that would not appear at the front of the collapsed stack will briefly peek at the front for half the interval duration before animating to its sorted position, making it visible to the user before it settles.
|
|
111
|
+
|
|
85
112
|
|
|
86
113
|
</td></tr>
|
|
87
114
|
<tr><td>
|
|
@@ -99,6 +126,8 @@ string
|
|
|
99
126
|
|
|
100
127
|
</td><td>
|
|
101
128
|
|
|
129
|
+
The corner of the screen where notifications appear. Note: bottom-left and bottom-right are not currently supported.
|
|
130
|
+
|
|
102
131
|
|
|
103
132
|
</td></tr>
|
|
104
133
|
<tr><td>
|
|
@@ -116,6 +145,27 @@ boolean
|
|
|
116
145
|
|
|
117
146
|
</td><td>
|
|
118
147
|
|
|
148
|
+
Whether to show the notification count in the header.
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
</td></tr>
|
|
152
|
+
<tr><td>
|
|
153
|
+
|
|
154
|
+
[sortFn?](./foundation-notifications.notifycontainerconfig.sortfn.md)
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
</td><td>
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
</td><td>
|
|
161
|
+
|
|
162
|
+
(a: HTMLElement, b: HTMLElement) => number
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
</td><td>
|
|
166
|
+
|
|
167
|
+
_(Optional)_ An optional comparator function to sort visible notifications. Follows the same signature as `Array.sort` — return a negative number to sort `a` before `b` (i.e. higher in the stack). Re-applied automatically whenever the set of visible notifications changes. See [sortNotificationBySeverity()](./foundation-notifications.sortnotificationbyseverity.md) for a ready-made example.
|
|
168
|
+
|
|
119
169
|
|
|
120
170
|
</td></tr>
|
|
121
171
|
<tr><td>
|
|
@@ -133,6 +183,8 @@ number
|
|
|
133
183
|
|
|
134
184
|
</td><td>
|
|
135
185
|
|
|
186
|
+
The number of visible notifications that triggers the stack to auto-collapse.
|
|
187
|
+
|
|
136
188
|
|
|
137
189
|
</td></tr>
|
|
138
190
|
</tbody></table>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@genesislcap/foundation-notifications](./foundation-notifications.md) > [NotifyContainerConfig](./foundation-notifications.notifycontainerconfig.md) > [notificationInterval](./foundation-notifications.notifycontainerconfig.notificationinterval.md)
|
|
4
|
+
|
|
5
|
+
## NotifyContainerConfig.notificationInterval property
|
|
6
|
+
|
|
7
|
+
When set, notifications added simultaneously are revealed one-by-one with this delay (in ms) between each. Auto-close timers on individual notifications only begin once they are shown. Setting this to 0 disables queuing.
|
|
8
|
+
|
|
9
|
+
When [NotifyContainerConfig.sortFn](./foundation-notifications.notifycontainerconfig.sortfn.md) is also set, each incoming notification that would not appear at the front of the collapsed stack will briefly peek at the front for half the interval duration before animating to its sorted position, making it visible to the user before it settles.
|
|
10
|
+
|
|
11
|
+
**Signature:**
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
notificationInterval: number;
|
|
15
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@genesislcap/foundation-notifications](./foundation-notifications.md) > [NotifyContainerConfig](./foundation-notifications.notifycontainerconfig.md) > [sortFn](./foundation-notifications.notifycontainerconfig.sortfn.md)
|
|
4
|
+
|
|
5
|
+
## NotifyContainerConfig.sortFn property
|
|
6
|
+
|
|
7
|
+
An optional comparator function to sort visible notifications. Follows the same signature as `Array.sort` — return a negative number to sort `a` before `b` (i.e. higher in the stack). Re-applied automatically whenever the set of visible notifications changes. See [sortNotificationBySeverity()](./foundation-notifications.sortnotificationbyseverity.md) for a ready-made example.
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
sortFn?: (a: HTMLElement, b: HTMLElement) => number;
|
|
13
|
+
```
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
|
|
2
|
+
|
|
3
|
+
[Home](./index.md) > [@genesislcap/foundation-notifications](./foundation-notifications.md) > [sortNotificationBySeverity](./foundation-notifications.sortnotificationbyseverity.md)
|
|
4
|
+
|
|
5
|
+
## sortNotificationBySeverity() function
|
|
6
|
+
|
|
7
|
+
A ready-made sort comparator for use with [NotifyContainerConfig.sortFn](./foundation-notifications.notifycontainerconfig.sortfn.md) that places the most severe notifications at the top of the stack. Severity is determined by the `notify` attribute on each toast element: `error` (highest) → `warning` → `success` → unstyled (lowest).
|
|
8
|
+
|
|
9
|
+
**Signature:**
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
sortNotificationBySeverity: (a: HTMLElement, b: HTMLElement) => number
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Parameters
|
|
16
|
+
|
|
17
|
+
<table><thead><tr><th>
|
|
18
|
+
|
|
19
|
+
Parameter
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
</th><th>
|
|
23
|
+
|
|
24
|
+
Type
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
</th><th>
|
|
28
|
+
|
|
29
|
+
Description
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
</th></tr></thead>
|
|
33
|
+
<tbody><tr><td>
|
|
34
|
+
|
|
35
|
+
a
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
</td><td>
|
|
39
|
+
|
|
40
|
+
HTMLElement
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
</td><td>
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
</td></tr>
|
|
47
|
+
<tr><td>
|
|
48
|
+
|
|
49
|
+
b
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
</td><td>
|
|
53
|
+
|
|
54
|
+
HTMLElement
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
</td><td>
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
</td></tr>
|
|
61
|
+
</tbody></table>
|
|
62
|
+
|
|
63
|
+
**Returns:**
|
|
64
|
+
|
|
65
|
+
number
|
|
66
|
+
|
|
67
|
+
## Example
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
```ts
|
|
71
|
+
configureNotifications({ sortFn: sortNotificationBySeverity });
|
|
72
|
+
```
|
|
73
|
+
|
|
@@ -242,6 +242,10 @@ export class NotifyContainer extends GenesisElement implements NotifyContainerCo
|
|
|
242
242
|
// @internal (undocumented)
|
|
243
243
|
handleToggleCollapse(): void;
|
|
244
244
|
// (undocumented)
|
|
245
|
+
notificationInterval: number;
|
|
246
|
+
// @internal (undocumented)
|
|
247
|
+
notificationIntervalChanged(_oldValue: number, newValue: number): void;
|
|
248
|
+
// (undocumented)
|
|
245
249
|
position: ToastPosition;
|
|
246
250
|
// (undocumented)
|
|
247
251
|
showCount: boolean;
|
|
@@ -250,6 +254,10 @@ export class NotifyContainer extends GenesisElement implements NotifyContainerCo
|
|
|
250
254
|
// @internal (undocumented)
|
|
251
255
|
slottedNodesChanged(): void;
|
|
252
256
|
// (undocumented)
|
|
257
|
+
sortFn?: (a: HTMLElement, b: HTMLElement) => number;
|
|
258
|
+
// @internal (undocumented)
|
|
259
|
+
sortFnChanged(): void;
|
|
260
|
+
// (undocumented)
|
|
253
261
|
stackCollapsed: boolean;
|
|
254
262
|
// (undocumented)
|
|
255
263
|
stackThreshold: number;
|
|
@@ -257,17 +265,13 @@ export class NotifyContainer extends GenesisElement implements NotifyContainerCo
|
|
|
257
265
|
|
|
258
266
|
// @public (undocumented)
|
|
259
267
|
export interface NotifyContainerConfig {
|
|
260
|
-
// (undocumented)
|
|
261
268
|
allowCloseAll: boolean;
|
|
262
|
-
// (undocumented)
|
|
263
269
|
allowManualCollapse: boolean;
|
|
264
|
-
// (undocumented)
|
|
265
270
|
designSystemPrefix: string;
|
|
266
|
-
|
|
271
|
+
notificationInterval: number;
|
|
267
272
|
position: ToastPosition;
|
|
268
|
-
// (undocumented)
|
|
269
273
|
showCount: boolean;
|
|
270
|
-
|
|
274
|
+
sortFn?: (a: HTMLElement, b: HTMLElement) => number;
|
|
271
275
|
stackThreshold: number;
|
|
272
276
|
}
|
|
273
277
|
|
|
@@ -345,6 +349,9 @@ export interface SnackbarStructure {
|
|
|
345
349
|
// @public
|
|
346
350
|
export type SnackbarType = 'error' | 'success';
|
|
347
351
|
|
|
352
|
+
// @public
|
|
353
|
+
export const sortNotificationBySeverity: (a: HTMLElement, b: HTMLElement) => number;
|
|
354
|
+
|
|
348
355
|
// @public
|
|
349
356
|
export interface Toast {
|
|
350
357
|
// (undocumented)
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@genesislcap/foundation-notifications",
|
|
3
3
|
"description": "Genesis Foundation UI Notifications Utils",
|
|
4
|
-
"version": "14.401.
|
|
4
|
+
"version": "14.401.2",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"license": "SEE LICENSE IN license.txt",
|
|
7
7
|
"main": "dist/esm/index.js",
|
|
@@ -51,18 +51,18 @@
|
|
|
51
51
|
}
|
|
52
52
|
},
|
|
53
53
|
"devDependencies": {
|
|
54
|
-
"@genesislcap/foundation-testing": "14.401.
|
|
55
|
-
"@genesislcap/genx": "14.401.
|
|
56
|
-
"@genesislcap/rollup-builder": "14.401.
|
|
57
|
-
"@genesislcap/ts-builder": "14.401.
|
|
58
|
-
"@genesislcap/uvu-playwright-builder": "14.401.
|
|
59
|
-
"@genesislcap/vite-builder": "14.401.
|
|
60
|
-
"@genesislcap/webpack-builder": "14.401.
|
|
54
|
+
"@genesislcap/foundation-testing": "14.401.2",
|
|
55
|
+
"@genesislcap/genx": "14.401.2",
|
|
56
|
+
"@genesislcap/rollup-builder": "14.401.2",
|
|
57
|
+
"@genesislcap/ts-builder": "14.401.2",
|
|
58
|
+
"@genesislcap/uvu-playwright-builder": "14.401.2",
|
|
59
|
+
"@genesislcap/vite-builder": "14.401.2",
|
|
60
|
+
"@genesislcap/webpack-builder": "14.401.2"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@genesislcap/foundation-logger": "14.401.
|
|
64
|
-
"@genesislcap/foundation-utils": "14.401.
|
|
65
|
-
"@genesislcap/web-core": "14.401.
|
|
63
|
+
"@genesislcap/foundation-logger": "14.401.2",
|
|
64
|
+
"@genesislcap/foundation-utils": "14.401.2",
|
|
65
|
+
"@genesislcap/web-core": "14.401.2"
|
|
66
66
|
},
|
|
67
67
|
"repository": {
|
|
68
68
|
"type": "git",
|
|
@@ -72,5 +72,5 @@
|
|
|
72
72
|
"publishConfig": {
|
|
73
73
|
"access": "public"
|
|
74
74
|
},
|
|
75
|
-
"gitHead": "
|
|
75
|
+
"gitHead": "962c621bc4517795517825d5d8c932aad5f350fd"
|
|
76
76
|
}
|