@openfin/web-notifications 2.9.1-alpha-3944

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.
@@ -0,0 +1,1548 @@
1
+ import OpenFin from '@openfin/core';
2
+
3
+ /**
4
+ * Actions are the mechanism through which notifications send messages back to the application that created them. The
5
+ * service defines a number of ways in which actions can be raised (a notification being interacted with by the user,
6
+ * being closed, expiring, etc.), and it is up to each application to decide if it wishes to be informed when each of
7
+ * these triggers occur.
8
+ *
9
+ * For an action to be raised when one of these triggers occurs, the application must specify an
10
+ * {@link NotificationActionResult|action result} for each trigger it is interested in. The application should then
11
+ * listen for when these actions are raised by listening for the {@link NotificationActionEvent|`notification-action`}
12
+ * event.
13
+ *
14
+ * This event is fired once each time an action is raised, and will contain the
15
+ * {@link NotificationActionResult|action result} the application specified for that trigger. The application may then
16
+ * use the {@link NotificationActionResult|action result} to determine which trigger occurred and respond appropriately.
17
+ *
18
+ * If an {@link NotificationActionResult|action result} is not specified for a particular trigger, or it is set to
19
+ * `null`, the application will not receive a corresponding {@link NotificationActionEvent|`notification-action`} when
20
+ * that trigger occurs.
21
+ *
22
+ * Unlike other event types, {@link NotificationActionEvent|`notification-action`} events will be buffered by the
23
+ * service until the application has added a listener for this event type, at which point it will receive all buffered
24
+ * {@link NotificationActionEvent|`notification-action`} events. The service will also attempt to restart the
25
+ * application if it is not running when the event is fired.
26
+ *
27
+ * For an overview of actions, consider the sample notification below:
28
+ * ```ts
29
+ * import {addEventListener, create} from 'openfin-notifications';
30
+ *
31
+ * // Create a notification with two buttons
32
+ * create({
33
+ * // Basic info
34
+ * title: 'Reminder',
35
+ * body: 'Event "Weekly Meeting" is starting soon...',
36
+ *
37
+ * // We'll use the 'customData' field to store metadata about the event
38
+ * customData: {eventId: '12345'},
39
+ *
40
+ * // We want the user clicking the notification to open the associated event, so register an 'onSelect' action
41
+ * onSelect: {task: 'view-calendar-event', target: 'popup'},
42
+ *
43
+ * buttons: [
44
+ * // A button that will schedule another reminder for 5 minutes from now. Since the application will be
45
+ * // responsible for snoozing the event, it will need to know about the user clicking this button. By setting
46
+ * // a NotificationActionResult for 'onClick', the service will raise a "notification-action" event when this
47
+ * // button is clicked, and will pass the value of 'onClick' as the 'result' field within the event
48
+ * {
49
+ * title: 'Snooze for 5 minutes',
50
+ * iconUrl: 'https://www.example.com/timer.png',
51
+ * onClick: {
52
+ * task: 'schedule-reminder',
53
+ * intervalMs: 5 * 60 * 1000
54
+ * }
55
+ * },
56
+ *
57
+ * // A button that closes the notification and doesn't prompt the user about this event again. Since the
58
+ * // application doesn't need to do anything when the user clicks this button, we leave 'onClick' undefined
59
+ * // rather than specifying a NotificationActionResult. This means that no action will be raised when the
60
+ * // button is clicked, and hence no "notification-action" event will be fired
61
+ * {
62
+ * title: 'Dismiss',
63
+ * iconUrl: 'https://www.example.com/cancel.png'
64
+ * }
65
+ * ]
66
+ * });
67
+ *
68
+ * // Create a listener that will be called for each action
69
+ * // Note: This handler will be used for ALL actions, from ALL notifications that are created by this application.
70
+ * addEventListener('notification-action', (event: NotificationActionEvent) => {
71
+ * const {result, notification} = event;
72
+ *
73
+ * if (result['task'] === 'view-calendar-event') {
74
+ * // Open a window with full details of the associated event
75
+ * openEventDetails(notification.customData.eventId, result['target']);
76
+ * } else if (result['task'] === 'schedule-reminder') {
77
+ * // Schedule a new notification
78
+ * scheduleReminder(notification.customData.eventId, Date.now() + result['intervalMs']);
79
+ * } // Etc...
80
+ * });
81
+ * ```
82
+ *
83
+ * The example above uses `customData` to store details about the notification subject (in this case, a calendar
84
+ * event), and `onClick` actions to inform the application about how it should respond when the user interacts with the
85
+ * notification. This is our intended usage and recommended best-practice, but the service doesn't require applications
86
+ * to follow this convention - application developers are free to decide how to manage notification state.
87
+ *
88
+ * Within the `notification-action` handler, the application must be able to understand which notification is being
89
+ * handled, and how to decide what it should do next. The example above uses an application-defined `action` field to
90
+ * determine the correct action, but the notification's `id`, `customData` and other fields are also useful
91
+ * selectors.
92
+ *
93
+ * @module Actions
94
+ */
95
+ /**
96
+ * Need a comment block here so that the comment block above is interpreted as a file comment, and not a comment on the
97
+ * import below.
98
+ *
99
+ * @hidden
100
+ */
101
+
102
+ /**
103
+ * Denotes a field as being an action. Defining this field (with a non-`undefined` value) will result in actions being
104
+ * raised and sent back to the source application when the corresponding event happens.
105
+ *
106
+ * For example, providing a value for the `onClick` field of {@link ButtonOptions} will result in a
107
+ * {@link NotificationActionEvent|`notification-action`} event being fired when that button is clicked.
108
+ *
109
+ * The `NotificationActionResult returned back to an application is static
110
+ * and must be defined at the point where the notification is created.
111
+ */
112
+ type ActionDeclaration<T extends never, E extends never> = NotificationActionResult;
113
+ /**
114
+ * Data type used to represent the action result returned back to applications when an action is raised. Applications
115
+ * capture these responses by adding a `notification-action` listener. The contents of this type are entirely
116
+ * application-defined, the only requirement is that the item is serializable by `JSON.stringify`.
117
+ *
118
+ * Since this type is entirely application-specific, the type is used in these definitions. However, there is an
119
+ * optional generic argument here, which can be used if an application were to define its own conventions for the shape
120
+ * of this field (which is recommended). To make use of this, define a `notification-action` handler that includes the
121
+ * application-defined type as a template argument. This type is then propagated up to {@link NotificationActionEvent}.
122
+ * The example below demonstrates this, using the same use-case as at the top of this page.
123
+ *
124
+ * ```ts
125
+ * interface MyAction = SnoozeAction | DetailsAction;
126
+ *
127
+ * interface SnoozeAction {
128
+ * task: 'schedule-reminder';
129
+ * intervalMs: number;
130
+ * }
131
+ *
132
+ * interface DetailsAction {
133
+ * task: 'view-calendar-event';
134
+ * target: 'self'|'popup';
135
+ * }
136
+ *
137
+ * addEventListener('notification-action', (event: NotificationActionEvent<MyAction>)) => {
138
+ * if (event.result.task === 'schedule-reminder') {
139
+ * // 'event.result' will now be strongly-typed as an instance of SnoozeAction
140
+ * scheduleReminder(notification.customData.eventId, Date.now() + result.intervalMs);
141
+ * }
142
+ * // Etc...
143
+ * };
144
+ * ```
145
+ */
146
+ type NotificationActionResult<T = CustomData> = T;
147
+ /**
148
+ * Noop action types see {@link ActionNoop|ActionNoop}.
149
+ */
150
+ declare enum ActionNoopType {
151
+ /**
152
+ * No event will be raised and no dismissal of the notification on action.
153
+ */
154
+ EVENT_DISMISS = "event_dismiss"
155
+ }
156
+ /**
157
+ * BODY_CLICK action types see {@link ActionBodyClick|ActionBodyClick}.
158
+ */
159
+ declare enum ActionBodyClickType {
160
+ /**
161
+ * Dissmisal/Clearing event will be raised
162
+ */
163
+ DISMISS_EVENT = "dismiss_event"
164
+ }
165
+ /**
166
+ * @depracated {__NOOP__} has been deprecated. Notifications now default to not triggering the dismiss action when the body is clicked
167
+ *
168
+ * Setting the `__NOOP__` field on an action with a {@link ActionNoopType|type} allows you to override default user interaction with a notification.
169
+ *
170
+ * @example
171
+ * ```
172
+ * const notification = {
173
+ * //...
174
+ * onSelect: {__NOOP__: ActionNoopType.EVENT_DISMISS}
175
+ * };
176
+ * ```
177
+ *
178
+ * When a user clicks the notification body, the notification will not be dismissed and no event will be raised to the client application.
179
+ *
180
+ * <li> Currently <code>ActionBodyClickType.DISMISS_EVENT</code> is only supported by <code>ActionTrigger.SELECT/onSelect</code></li>
181
+ */
182
+ interface ActionNoop {
183
+ __NOOP__?: ActionNoopType;
184
+ }
185
+ /**
186
+ * Set the `BODY_CLICK` field on an action with a {@link ActionBodyClickType|type} to allow the end-user to click the body of the notification to dismiss it. This was the default behavior in earlier releases. An event is also sent to the client application.
187
+ *
188
+ * Note the following restrictions:
189
+ *
190
+ * <ul>
191
+ * <li>This override is ignored if buttons are passed to notification options.</li>
192
+ * <li>The <code>ActionBodyClickType.DISMISS_EVENT</code> is supported only by <code>ActionTrigger.SELECT/onSelect</code></li>
193
+ *
194
+ * @example
195
+ * ```
196
+ * const notification = {
197
+ * //...
198
+ * onSelect: {BODY_CLICK: ActionBodyClickType.DISMISS_EVENT}
199
+ * };
200
+ * ```
201
+ *
202
+ */
203
+ interface ActionBodyClick {
204
+ BODY_CLICK?: ActionBodyClickType;
205
+ }
206
+
207
+ /**
208
+ * @module Notifications
209
+ */
210
+ /**
211
+ * @deprecated
212
+ * Lists possible semantic use-cases for notifications, which can alter how the notification is presented to the user.
213
+ */
214
+ declare enum IndicatorType {
215
+ FAILURE = "failure",
216
+ WARNING = "warning",
217
+ SUCCESS = "success"
218
+ }
219
+ /**
220
+ * Lists possible colors available for use as NotificationIndicator background color.
221
+ */
222
+ declare enum IndicatorColor {
223
+ RED = "red",
224
+ GREEN = "green",
225
+ YELLOW = "yellow",
226
+ BLUE = "blue",
227
+ PURPLE = "purple",
228
+ GRAY = "gray",
229
+ ORANGE = "orange",
230
+ MAGENTA = "magenta",
231
+ TEAL = "teal"
232
+ }
233
+ interface NotificationIndicator {
234
+ /**
235
+ * @deprecated
236
+ *
237
+ * Deprecated - use the priority field instead.
238
+ *
239
+ * Indicates the semantic intent behind the indicator - this determines the visual styling of the indicator when
240
+ * seen by the user.
241
+ *
242
+ * For example - an indicator could be used to:
243
+ * - `IndicatorType.FAILURE`: Indicate a failure has occurred from an action the user has taken.
244
+ * - `IndicatorType.WARNING`: Warn a user that they have a limited amount of time to buy.
245
+ * - `IndicatorType.SUCCESS`: Inform the user that an item has been successfully ordered.
246
+ */
247
+ type?: IndicatorType;
248
+ /**
249
+ * The indicator banner color. Defaults to red.
250
+ */
251
+ color?: IndicatorColor;
252
+ /**
253
+ * Customized text to be displayed in the indicator. When set, this will override the default indicator text.
254
+ * Text is limited to 32 characters including spaces.
255
+ */
256
+ text?: string;
257
+ }
258
+ interface NotificationIndicatorWithCustomColor extends Omit<NotificationIndicator, 'color'> {
259
+ /**
260
+ * Custom color string for indicator banner. This string must be defined in `theme` during Workspace Platform initialization.
261
+ */
262
+ color: string;
263
+ /**
264
+ * Fallback color if custom color could not be found in theme.
265
+ */
266
+ fallback: IndicatorColor;
267
+ }
268
+
269
+ declare const WidgetType: {
270
+ readonly Time: "Time";
271
+ readonly Date: "Date";
272
+ readonly RadioGroup: "RadioGroup";
273
+ readonly CheckboxGroup: "CheckboxGroup";
274
+ readonly Toggle: "Toggle";
275
+ readonly Checkbox: "Checkbox";
276
+ readonly Number: "Number";
277
+ readonly Text: "Text";
278
+ readonly Dropdown: "Dropdown";
279
+ };
280
+ interface BaseWidgetSpec<T extends keyof typeof WidgetType> {
281
+ /**
282
+ * The type of widget to be used. Widgets can only be used with matching specific data types.
283
+ * For example the `Text` widget can be used with the `string` field type.
284
+ */
285
+ type: T;
286
+ }
287
+ /**
288
+ * A simple text field input widget.
289
+ */
290
+ interface TextWidgetSpec extends BaseWidgetSpec<typeof WidgetType['Text']> {
291
+ placeholder?: string;
292
+ multiline?: boolean;
293
+ rows?: number;
294
+ }
295
+ /**
296
+ * String field input widget.
297
+ */
298
+ type StringWidget = TextWidgetSpec | DropdownWidgetSpec;
299
+ interface NumberWidgetSpec extends BaseWidgetSpec<typeof WidgetType['Number']> {
300
+ placeholder?: string;
301
+ min?: number;
302
+ max?: number;
303
+ currencyChar?: string;
304
+ decimalPlaces?: number;
305
+ step?: number;
306
+ }
307
+ interface CheckboxGroupWidgetSpec extends BaseWidgetSpec<typeof WidgetType['CheckboxGroup']> {
308
+ group: Array<{
309
+ value: string;
310
+ label: string;
311
+ }>;
312
+ }
313
+ type CheckboxGroupWidget = CheckboxGroupWidgetSpec;
314
+ interface RadioGroupWidgetSpec extends BaseWidgetSpec<typeof WidgetType['RadioGroup']> {
315
+ group: Array<{
316
+ value: string;
317
+ label: string;
318
+ }>;
319
+ }
320
+ type RadioGroupWidget = RadioGroupWidgetSpec;
321
+ interface DateWidgetSpec extends BaseWidgetSpec<typeof WidgetType['Date']> {
322
+ minDate?: Date | null;
323
+ maxDate?: Date | null;
324
+ }
325
+ type TimeWidgetSpec = BaseWidgetSpec<typeof WidgetType['Time']>;
326
+ type DateWidget = DateWidgetSpec;
327
+ type TimeWidget = TimeWidgetSpec;
328
+ interface DropdownWidgetSpec extends BaseWidgetSpec<typeof WidgetType['Dropdown']> {
329
+ placeholder?: string;
330
+ options: Array<{
331
+ value: string;
332
+ label: string;
333
+ }>;
334
+ }
335
+ /**
336
+ * Number field input widget.
337
+ */
338
+ type NumberWidget = NumberWidgetSpec;
339
+ type ToggleWidgetSpec = BaseWidgetSpec<typeof WidgetType['Toggle']>;
340
+ type CheckboxWidgetSpec = BaseWidgetSpec<typeof WidgetType['Checkbox']>;
341
+ type BooleanWidget = ToggleWidgetSpec | CheckboxWidgetSpec;
342
+
343
+ /**
344
+ * @hidden
345
+ */
346
+ /**
347
+ * Need a comment block here so that the comment block above is interpreted as a file comment, and not a comment on the
348
+ * import below.
349
+ *
350
+ * @hidden
351
+ */
352
+ /**
353
+ * For notifications that have originated from an application running on the same machine as the provider.
354
+ */
355
+ interface NotificationSourceDesktop {
356
+ type: 'desktop';
357
+ /**
358
+ * The identity of the window that raised this notification.
359
+ *
360
+ * This will always be a window of the current application - but
361
+ * could have been raised by an instance of this application
362
+ * running on a different machine.
363
+ */
364
+ identity: OpenFin.Identity;
365
+ /**
366
+ * The origin of the notification, which is the url of the window that raised the notification.
367
+ * This property is optional to support backward compatibility with sources that do not have the origin starting with version 2.7.1.
368
+ */
369
+ origin?: string;
370
+ }
371
+ /**
372
+ * Union of all possible notification sources.
373
+ */
374
+ type NotificationSource = NotificationSourceDesktop;
375
+
376
+ /**
377
+ * A rule that specifies the allowed origins that can access
378
+ * the stored notification data and update the notifications
379
+ */
380
+ interface NotificationSecurityRule {
381
+ /**
382
+ * Array of [match patterns](https://developer.chrome.com/docs/extensions/develop/concepts/match-patterns)
383
+ * specifying the allowed origins that can access to the notification(s) for the client.
384
+ * If an empty array is provided, then no origins are allowed to access the stored notifications for the client.
385
+ */
386
+ allowedOrigins: string[];
387
+ }
388
+
389
+ /**
390
+ * @hidden
391
+ */
392
+ /**
393
+ * File contains types used to communicate between client and provider.
394
+ *
395
+ * These types are a part of the client, but are not required by applications wishing to interact with the service.
396
+ * This file is excluded from the public-facing TypeScript documentation.
397
+ */
398
+
399
+ type NotificationInternal<T extends NotificationOptions = NotificationOptions> = DistributiveOmit<Notification<T>, 'date' | 'expires'> & {
400
+ date: number;
401
+ expires: number | null;
402
+ _fragments?: (ActionableTextTemplateFragment | ImageTemplateFragment | ContainerTemplateFragment)[];
403
+ };
404
+ /**
405
+ * Distribute Omit across all union types instead of Omitting the union.
406
+ * https://davidgomes.com/pick-omit-over-union-types-in-typescript/
407
+ */
408
+ type DistributiveOmit<T, K extends keyof T> = T extends unknown ? Omit<T, K> : never;
409
+ type MakePropertyRequired<T, Prop extends keyof T> = Omit<T, Prop> & Required<Pick<T, Prop>>;
410
+
411
+ /**
412
+ * When you make a form, you provide a list of [[FormFields]]. Each FormField contains the ingredients to make a single widget in the form.
413
+ * The actual definitions of the widgets are derived from [[BaseWidgetSpec]].
414
+ *
415
+ * A FormField contains the type of data, the key to store the user input into [[CustomDataWithForms]], and some additional configuration.
416
+ * @module FormFields
417
+ */
418
+ /**
419
+ * imports.
420
+ */
421
+
422
+ /**
423
+ * Data type of a fields. e.g. string, number
424
+ */
425
+ declare const FieldType: {
426
+ readonly string: "string";
427
+ readonly number: "number";
428
+ readonly boolean: "boolean";
429
+ readonly date: "date";
430
+ readonly checkboxGroup: "checkboxGroup";
431
+ readonly radioGroup: "radioGroup";
432
+ readonly time: "time";
433
+ };
434
+ /**
435
+ * An abstract validation entry.
436
+ */
437
+ interface ValidationEntry<T = any> {
438
+ /**
439
+ * Message displayed to the user when input is invalid.
440
+ */
441
+ invalidMessage?: string;
442
+ /**
443
+ * Validation argument to test against.
444
+ */
445
+ arg?: T;
446
+ }
447
+ /**
448
+ * The base type for form fields.
449
+ */
450
+ interface BaseField<T extends keyof typeof FieldType, D = unknown> {
451
+ /**
452
+ * Field data type.
453
+ */
454
+ type: T;
455
+ /**
456
+ * The property key that this field value will appear in the returned {@link NotificationFormSubmittedEvent.form|form} object.
457
+ */
458
+ key: string;
459
+ /**
460
+ * Default value for field, and where it will be written to
461
+ */
462
+ value?: D;
463
+ /**
464
+ * Validation rules used to validate user input.
465
+ */
466
+ validation?: Record<string, any>;
467
+ /**
468
+ * Input label.
469
+ */
470
+ label?: string;
471
+ /**
472
+ * Helper text.
473
+ */
474
+ helperText?: string;
475
+ }
476
+ /**
477
+ * String field within a form.
478
+ */
479
+ interface StringField<W extends StringWidget = StringWidget> extends BaseField<'string', string> {
480
+ validation?: Partial<{
481
+ /**
482
+ * Minimum number of characters.
483
+ */
484
+ min: ValidationEntry<number>;
485
+ /**
486
+ * Maximum number of characters.
487
+ */
488
+ max: ValidationEntry<number>;
489
+ /**
490
+ * Length of the input string.
491
+ */
492
+ length: ValidationEntry<number>;
493
+ /**
494
+ * The field is required to be filled in by the user.
495
+ */
496
+ required: ValidationEntry;
497
+ /**
498
+ * Provide a regex string that will be tested against the input value.
499
+ */
500
+ match: ValidationEntry<string>;
501
+ }>;
502
+ /**
503
+ * What input widget is used.
504
+ * @default StringWidgets {@link StringWidgets}
505
+ */
506
+ widget: W;
507
+ }
508
+ /**
509
+ * Number field within a form.
510
+ */
511
+ interface NumberField<W extends NumberWidget = NumberWidget> extends BaseField<'number', number> {
512
+ validation?: Partial<{
513
+ /**
514
+ * Minimum number of characters.
515
+ */
516
+ min: ValidationEntry<number>;
517
+ /**
518
+ * Maximum number of characters.
519
+ */
520
+ max: ValidationEntry<number>;
521
+ /**
522
+ * Number must be less than this.
523
+ */
524
+ lessThan: ValidationEntry<number>;
525
+ /**
526
+ * Number must be more than this.
527
+ */
528
+ moreThan: ValidationEntry<number>;
529
+ /**
530
+ * Number must be positive.
531
+ */
532
+ positive: ValidationEntry;
533
+ /**
534
+ * Number must be negative.
535
+ */
536
+ negative: ValidationEntry;
537
+ /**
538
+ * The field is required to be filled in by the user.
539
+ */
540
+ required: ValidationEntry;
541
+ }>;
542
+ widget: W;
543
+ }
544
+ interface BooleanField<W extends BooleanWidget = BooleanWidget> extends BaseField<'boolean', boolean> {
545
+ widget: W;
546
+ }
547
+ type DateFieldValue = {
548
+ date?: number;
549
+ month?: number;
550
+ year?: number;
551
+ };
552
+ interface DateField<W extends DateWidget = DateWidget> extends BaseField<'date', DateFieldValue> {
553
+ widget: W;
554
+ }
555
+ type TimeFieldValue = {
556
+ hour?: number;
557
+ minute?: number;
558
+ };
559
+ interface TimeField<W extends TimeWidget = TimeWidget> extends BaseField<'time', TimeFieldValue> {
560
+ widget: W;
561
+ }
562
+ interface RadioGroupField<W extends RadioGroupWidget = RadioGroupWidget> extends BaseField<'radioGroup', string> {
563
+ widget: W;
564
+ }
565
+ interface CheckboxGroupField<W extends CheckboxGroupWidget = CheckboxGroupWidget> extends BaseField<'checkboxGroup', Array<string>> {
566
+ widget: W;
567
+ }
568
+ /**
569
+ * A field in a form.
570
+ */
571
+ type FormField = StringField | NumberField | BooleanField | DateField | RadioGroupField | CheckboxGroupField | TimeField;
572
+ /**
573
+ * A field in a form.
574
+ *
575
+ * The difference with [[FormField]] is that the label property is required.
576
+ */
577
+ type FormFieldWithRequiredLabel = MakePropertyRequired<FormField, 'label'>;
578
+ /**
579
+ * An ordered array of fields representing a form.
580
+ * When the form is displayed to the user the fields will appear in the same order they are in the array.
581
+ */
582
+ type NotificationFormData = ReadonlyArray<FormField>;
583
+ /**
584
+ * An ordered array of fields representing a form.
585
+ * When the form is displayed to the user the fields will appear in the same order they are in the array.
586
+ *
587
+ * The difference with [[NotificationFormData]] is that the label property is required for each field.
588
+ */
589
+ type NotificationFormDataWithRequiredLabel = ReadonlyArray<FormFieldWithRequiredLabel>;
590
+
591
+ /**
592
+ * OpenFin Notification Templates API Version 1
593
+ *
594
+ * @module Templates
595
+ */
596
+ /**
597
+ * imports
598
+ */
599
+
600
+ type SectionAlignment = 'left' | 'center' | 'right';
601
+ type ListPairs = [string, string][];
602
+ type CustomTemplateData = Record<string, string | ListPairs>;
603
+ /**
604
+ * The options you pass to the [[create]] function to generate a notification.
605
+ */
606
+ type NotificationOptions = TemplateMarkdown | TemplateList | TemplateCustom;
607
+ /**
608
+ * The options to build your custom template composition layout.
609
+ */
610
+ type TemplateFragment = ContainerTemplateFragment | TextTemplateFragment | ListTemplateFragment | ImageTemplateFragment | ActionableTextTemplateFragment;
611
+ declare const TemplateNames: {
612
+ readonly markdown: "markdown";
613
+ readonly list: "list";
614
+ readonly custom: "custom";
615
+ };
616
+ declare const PresentationTemplateFragmentNames: {
617
+ readonly text: "text";
618
+ readonly image: "image";
619
+ readonly list: "list";
620
+ readonly actionableText: "actionableText";
621
+ };
622
+ declare const TemplateFragmentNames: {
623
+ readonly text: "text";
624
+ readonly image: "image";
625
+ readonly list: "list";
626
+ readonly actionableText: "actionableText";
627
+ readonly container: "container";
628
+ };
629
+ interface TemplateComposition {
630
+ /**
631
+ * Minimum Template API version required for the service to render this composition.
632
+ *
633
+ * For example, a composition that consists only of container, text, image, or list
634
+ * fragments must declare a minimum template API version of "1".
635
+ *
636
+ * See {@link BodyTemplateOptions} for more details.
637
+ */
638
+ minTemplateAPIVersion: string;
639
+ /**
640
+ * Root of the template composition tree. See {@link ContainerTemplateFragment} for nesting.
641
+ */
642
+ layout: TemplateFragment;
643
+ }
644
+ interface IndicatorTemplateOptions {
645
+ /**
646
+ * Alignment of the notification's indicator section.
647
+ *
648
+ * Can be `left`, `center` or `right`.
649
+ *
650
+ * The default value is `center`.
651
+ */
652
+ align?: SectionAlignment;
653
+ /**
654
+ * Color of the indicator bar.
655
+ *
656
+ * Note: {@link BaseNotificationOptions|Notification's indicator color} definition has precedence over Template definition.
657
+ * Template's indicator color value will be taken into account only if the notification itself doesn't have the indicator color
658
+ * specified.
659
+ */
660
+ color?: IndicatorColor;
661
+ }
662
+ interface ButtonTemplateOptions {
663
+ /**
664
+ * Alignment of the notification's button section.
665
+ *
666
+ * Can be `left`, `center` or `right`.
667
+ *
668
+ * The default value is `right`.
669
+ */
670
+ align?: SectionAlignment;
671
+ }
672
+ interface BodyTemplateOptions {
673
+ /**
674
+ * A list of template compositions.
675
+ *
676
+ * You can include multiple compositions with different minimum Template API version to create fallback compositions and support the
677
+ * earlier versions of Notification Center (Starting from the Template API version 1).
678
+ *
679
+ * The service will search for the composition with the version number matching the Template API version it is supporting.
680
+ * If this doesn't exist, the service will then select the composition with the nearest version number smaller than the Template API version
681
+ * it is supporting and render the notification card with that composition.
682
+ */
683
+ compositions: TemplateComposition[];
684
+ /**
685
+ * Composition fallback text.
686
+ *
687
+ * The service will render this text instead of the notification body section if there are no compatible compositions found in the template.
688
+ *
689
+ * (E.g. All of the compositions in the template declare a greater minimum Template API version than the version supported by the running
690
+ * service instance.)
691
+ *
692
+ */
693
+ fallbackText?: string;
694
+ }
695
+ interface BaseTemplateFragment<T extends keyof typeof TemplateFragmentNames> {
696
+ /**
697
+ * Type of the template fragment.
698
+ */
699
+ type: T;
700
+ /**
701
+ * CSS style properties of the fragment.
702
+ *
703
+ * All the available custom template fragments support all of the React's inline style properties (with camelCase keys)
704
+ *
705
+ * Note: "position: fixed" is disallowed in the fragments.
706
+ */
707
+ style?: Record<string, string | number>;
708
+ }
709
+ interface ContainerTemplateFragment extends BaseTemplateFragment<'container'>, ActionableFragment {
710
+ /**
711
+ * Sub-fragments of the container.
712
+ *
713
+ * You can use container template fragment to create nested composition structures.
714
+ */
715
+ children?: TemplateFragment[];
716
+ }
717
+ interface PresentationTemplateFragment<T extends keyof typeof PresentationTemplateFragmentNames> extends BaseTemplateFragment<T> {
718
+ /**
719
+ * Optional flag.
720
+ *
721
+ * If a presentation template fragment is flagged as optional, The service will not require
722
+ * the fragment's `dataKey` to exist in `templateData`. If a fragment is optional and its data
723
+ * is missing, the fragment will be omitted quietly by the server.
724
+ */
725
+ optional?: boolean;
726
+ /**
727
+ * Data key of the template fragment.
728
+ *
729
+ * The data associated with this fragment will be looked up in `templateData` map with this key.
730
+ *
731
+ * Example:
732
+ * ```ts
733
+ * const myTemplate = {
734
+ * body: {
735
+ * compositions: [{
736
+ * minTemplateAPIVersion: '1',
737
+ * layout: {
738
+ * type: CustomTemplateFragmentNames.text,
739
+ * dataKey: 'message',
740
+ * },
741
+ * }],
742
+ * },
743
+ * }
744
+ *
745
+ * const notificationOption: TemplateCustom = {
746
+ * //...
747
+ * templateOptions: myTemplate,
748
+ * templateData: {
749
+ * message: 'My Custom Notification Message',
750
+ * }
751
+ * };
752
+ * ```
753
+ *
754
+ */
755
+ dataKey: string;
756
+ }
757
+ interface ActionableFragment {
758
+ /**
759
+ * onClick object that is user defined.
760
+ *
761
+ * If provided, notification-action event will be raised when clicking on the fragment.
762
+ *
763
+ *
764
+ * Example:
765
+ * ```ts
766
+ * {
767
+ * "type": "actionableText",
768
+ * "dataKey": "titlexyz",
769
+ * "tooltipKey": "some_key",
770
+ * "onClick": { // contents are user-defined
771
+ * "task": "schedule-reminder",
772
+ * "eventId": 142341,
773
+ * "intervalMs": 5000
774
+ * }
775
+ * }
776
+ *
777
+ * import { addEventListener, clear } from 'openfin-notifications';
778
+ *
779
+ * addEventListener('notification-action', (event: NotificationActionEvent<MyAction>)) => {
780
+ * if (event.result.task === 'schedule-reminder') {
781
+ * scheduleReminder(event.result.eventId, Date.now() + event.result.intervalMs);
782
+ * }
783
+ * clear(event.notification.id);
784
+ * });
785
+ * ```
786
+ *
787
+ */
788
+ onClick?: ActionDeclaration<never, never> | null;
789
+ /**
790
+ * Tooltip key of the template fragment.
791
+ *
792
+ * The string tooltip associated with this fragment will be looked up in templateData map with this key.
793
+ *
794
+ *
795
+ * Example:
796
+ * ```ts
797
+ * const myTemplate = {
798
+ * body: {
799
+ * compositions: [{
800
+ * minTemplateAPIVersion: '1',
801
+ * layout: {
802
+ * type: "actionableText",
803
+ * dataKey: 'message',
804
+ * tooltipKey: 'tooltipxyz',
805
+ * },
806
+ * }],
807
+ * },
808
+ * }
809
+ *
810
+ * const notificationOption: TemplateCustom = {
811
+ * //...
812
+ * templateOptions: myTemplate,
813
+ * templateData: {
814
+ * message: 'view stock tracker',
815
+ * tooltipxyz: 'My Custom Tooltip',
816
+ * }
817
+ * };
818
+ * ```
819
+ *
820
+ */
821
+ tooltipKey?: string;
822
+ }
823
+ type TextTemplateFragment = PresentationTemplateFragment<'text'>;
824
+ type ImageTemplateFragment = PresentationTemplateFragment<'image'> & ActionableFragment;
825
+ type ListTemplateFragment = PresentationTemplateFragment<'list'>;
826
+ type ActionableTextTemplateFragment = PresentationTemplateFragment<'actionableText'> & ActionableFragment;
827
+ /**
828
+ * Configuration options for the custom notification template.
829
+ */
830
+ interface CustomTemplateOptions {
831
+ /**
832
+ * Configuration options for the custom notification template body.
833
+ */
834
+ body: BodyTemplateOptions;
835
+ /**
836
+ * Configuration options for the custom notification template's modifications on the notification's indicator section.
837
+ */
838
+ indicator?: IndicatorTemplateOptions;
839
+ /**
840
+ * Configuration options for the custom notification template's modifications on the notification's button section.
841
+ */
842
+ buttons?: ButtonTemplateOptions;
843
+ }
844
+ /**
845
+ * Default markdown template. Contains a markdown body and forms data.
846
+ */
847
+ interface TemplateMarkdown extends Omit<BaseNotificationOptions<'markdown'>, 'template'> {
848
+ template?: 'markdown';
849
+ /**
850
+ * Notification body text.
851
+ *
852
+ * This is the main notification content, displayed below the notification title. The notification will expand to fit the length of this text.
853
+ * Markdown may be used in the body text to control how it is styled when rendered.
854
+ * With the exception of links and code blocks, all basic syntax as documented [here](https://www.markdownguide.org/basic-syntax) is supported.
855
+ */
856
+ body: string;
857
+ /**
858
+ * A collection of form fields or a form definition (Form<FormField>)
859
+ * @example
860
+ * ```ts
861
+ * [
862
+ * {
863
+ * key: 'phone',
864
+ * type: 'string',
865
+ * label: 'Phone',
866
+ * helperText:
867
+ * 'Must be in the following formats 123-456-7890, 123 456 7890, (123) 456 7890 or 1234567890',
868
+ * widget: {
869
+ * type: 'Text'
870
+ * },
871
+ * validation: {
872
+ * required: {
873
+ * arg: true
874
+ * }
875
+ * }
876
+ * },
877
+ * {
878
+ * key: 'email',
879
+ * type: 'string',
880
+ * label: 'Email',
881
+ * helperText: 'We will use this email to send you the report after we crawl your website',
882
+ * widget: {
883
+ * type: 'Text'
884
+ * },
885
+ * validation: {
886
+ * required: {
887
+ * arg: true
888
+ * }
889
+ * }
890
+ * }
891
+ * ]
892
+ * ```
893
+ */
894
+ form?: NotificationFormData | Form<FormField> | null;
895
+ }
896
+ /**
897
+ * Simple template that can render a list of name-value pairs.
898
+ */
899
+ interface TemplateList extends BaseNotificationOptions<'list'> {
900
+ /**
901
+ * Notification list template data.
902
+ */
903
+ list: Record<string, string>;
904
+ }
905
+ /**
906
+ * Notification that renders custom templates.
907
+ */
908
+ interface TemplateCustom extends BaseNotificationOptions<'custom'> {
909
+ templateOptions: CustomTemplateOptions;
910
+ /**
911
+ * Data associated with the custom notification template's presentation fragments.
912
+ */
913
+ templateData: CustomTemplateData;
914
+ /**
915
+ * A collection of form fields or a form definition (Form<FormField>)
916
+ * @example
917
+ * ```ts
918
+ * [
919
+ * {
920
+ * key: 'phone',
921
+ * type: 'string',
922
+ * label: 'Phone',
923
+ * helperText:
924
+ * 'Must be in the following formats 123-456-7890, 123 456 7890, (123) 456 7890 or 1234567890',
925
+ * widget: {
926
+ * type: 'Text'
927
+ * },
928
+ * validation: {
929
+ * required: {
930
+ * arg: true
931
+ * }
932
+ * }
933
+ * },
934
+ * {
935
+ * key: 'email',
936
+ * type: 'string',
937
+ * label: 'Email',
938
+ * helperText: 'We will use this email to send you the report after we crawl your website',
939
+ * widget: {
940
+ * type: 'Text'
941
+ * },
942
+ * validation: {
943
+ * required: {
944
+ * arg: true
945
+ * }
946
+ * }
947
+ * }
948
+ * ]
949
+ * ```
950
+ */
951
+ form?: NotificationFormDataWithRequiredLabel | Form<FormFieldWithRequiredLabel> | null;
952
+ }
953
+ interface FormSettings {
954
+ /**
955
+ * Controls that display of (Required) or (Optional) labels next to form fields.
956
+ */
957
+ displayFieldRequirementStatus?: boolean;
958
+ }
959
+ interface Form<T extends FormField | FormFieldWithRequiredLabel> extends FormSettings {
960
+ /**
961
+ * A collection of form fields.
962
+ * @example
963
+ * ```ts
964
+ * [
965
+ * {
966
+ * key: 'phone',
967
+ * type: 'string',
968
+ * label: 'Phone',
969
+ * helperText:
970
+ * 'Must be in the following formats 123-456-7890, 123 456 7890, (123) 456 7890 or 1234567890',
971
+ * widget: {
972
+ * type: 'Text'
973
+ * },
974
+ * validation: {
975
+ * required: {
976
+ * arg: true
977
+ * }
978
+ * }
979
+ * },
980
+ * {
981
+ * key: 'email',
982
+ * type: 'string',
983
+ * label: 'Email',
984
+ * helperText: 'We will use this email to send you the report after we crawl your website',
985
+ * widget: {
986
+ * type: 'Text'
987
+ * },
988
+ * validation: {
989
+ * required: {
990
+ * arg: true
991
+ * }
992
+ * }
993
+ * }
994
+ * ]
995
+ * ```
996
+ */
997
+ fields: ReadonlyArray<T>;
998
+ }
999
+
1000
+ /**
1001
+ * Core notification features.
1002
+ *
1003
+ * @module BaseNotificationOptions
1004
+ */
1005
+ /**
1006
+ * imports
1007
+ */
1008
+
1009
+ /**
1010
+ * Configuration options for constructing a Notifications object, shared between all templates.
1011
+ */
1012
+ interface BaseNotificationOptions<T extends keyof typeof TemplateNames> {
1013
+ /**
1014
+ * A unique identifier for the notification.
1015
+ *
1016
+ * If not provided at time of creation, one will be generated for you and returned as part of the {@link create} method.
1017
+ */
1018
+ id?: string;
1019
+ /**
1020
+ * Template of the notification payload.
1021
+ */
1022
+ template: T;
1023
+ /**
1024
+ * Title of the notification.
1025
+ *
1026
+ * Displayed as the first line of the notification, in a heading style.
1027
+ */
1028
+ title: string;
1029
+ /**
1030
+ * If set to false, the user won't be able to set a reminder for this notification in the Notification Center.
1031
+ *
1032
+ * Default value is `true`.
1033
+ */
1034
+ allowReminder?: boolean;
1035
+ /**
1036
+ * Describes the context of this notification. Allows users to control different notification types that are raised
1037
+ * by an application.
1038
+ *
1039
+ * This string is not displayed on the notification itself, but should be user-readable. It will be displayed in
1040
+ * the Notification Center preferences section, and any string passed as a `category` should make sense when
1041
+ * displayed in that context.
1042
+ *
1043
+ * Event categories should list all the different types of notifications raised by your app. As a general guide, if
1044
+ * a user may want to have different preferences for some subset of notifications created by your app, then
1045
+ * applications should ensure that those notifications have a distinct category.
1046
+ *
1047
+ * @deprecated This property is deprecated and will be removed in a future release.
1048
+ */
1049
+ category?: string;
1050
+ /**
1051
+ * Add a semantic visual indicator to a notification, to signal to the user the nature of the event that they are
1052
+ * being notified about.
1053
+ *
1054
+ * This should not be treated as a priority.
1055
+ */
1056
+ indicator?: NotificationIndicator | NotificationIndicatorWithCustomColor | null;
1057
+ /**
1058
+ * URL of the icon to be displayed in the notification.
1059
+ */
1060
+ icon?: string;
1061
+ /**
1062
+ * Application-defined context data that can be attached to buttons on notifications.
1063
+ *
1064
+ * When using forms, form data submitted will be written to `customData` and returned to your app by
1065
+ * listening to the submit {@link NotificationActionEvent|`notification-action`} with the trigger {@link ActionTrigger.SUBMIT|submit}.
1066
+ */
1067
+ customData?: CustomData;
1068
+ /**
1069
+ * The timestamp shown on the notification. If omitted, the current date/time will be used.
1070
+ *
1071
+ * This is presentational only - a date in the future does not incur a scheduling action.
1072
+ */
1073
+ date?: Date;
1074
+ /**
1075
+ * The expiry date and time of the notification. If specified, the notification will be removed at this time, or as
1076
+ * soon as possible after. If not specified, the notification will never expire, and will persist until it
1077
+ * is closed.
1078
+ */
1079
+ expires?: Date | null;
1080
+ /**
1081
+ * When set to `sticky` this settings enables the notification toast to stay visible on the desktop
1082
+ * until the user interacts with it. When set to `transient` the toasts will follow the default behavior
1083
+ * of fading away after a short duration. When set to `none` the toasts will not appear and the notification
1084
+ * will only appear in the Notification Center.
1085
+ *
1086
+ * This property has a precedence over `sticky` propery.
1087
+ *
1088
+ */
1089
+ toast?: 'sticky' | 'transient' | 'none';
1090
+ /**
1091
+ * @deprecated
1092
+ *
1093
+ * This property is deprecated. Use `toast` instead.
1094
+ */
1095
+ sticky?: 'sticky' | 'transient';
1096
+ /**
1097
+ * A list of buttons to display below the notification text.
1098
+ *
1099
+ * Notifications support up to four buttons. Attempting to add more than four will result in the notification
1100
+ * being rejected by the service.
1101
+ */
1102
+ buttons?: ButtonOptions[];
1103
+ /**
1104
+ * Notification Stream
1105
+ *
1106
+ * If the notification belongs to a stream, the user will be able to group notifications by stream.
1107
+ */
1108
+ stream?: NotificationStream | null;
1109
+ /**
1110
+ * Id of the platform this notification belongs to.
1111
+ *
1112
+ * If the application belongs to a platform, the user interaction with the notification will be dispatched
1113
+ * back to the platform provider.
1114
+ */
1115
+ platform?: string | null;
1116
+ /**
1117
+ * An {@link NotificationActionResult|action result} to be passed back to the application inside the
1118
+ * {@link NotificationActionEvent|`notification-action`} event fired when the notification is clicked.
1119
+ *
1120
+ * This action will only be raised on clicks to the notification body. Interactions with buttons (both
1121
+ * application-defined buttons, and the default 'X' close button) or with actionable fragments will not trigger a
1122
+ * {@link ActionTrigger.SELECT|select} action.
1123
+ *
1124
+ * See {@link Actions} for more details on notification actions, and receiving action events from notifications.
1125
+ */
1126
+ onSelect?: (ActionDeclaration<never, never> & ActionNoop & ActionBodyClick) | null;
1127
+ /**
1128
+ * An {@link NotificationActionResult|action result} to be passed back to the application inside the
1129
+ * {@link NotificationActionEvent|`notification-action`} event fired when the notification the expires.
1130
+ *
1131
+ * If `expires` is specified for the notification, this action will be raised when the notification expires. If
1132
+ * `expires` is not specified for the notification, this action will never be raised. Note that if an `onClose`
1133
+ * action result is also specified, both actions will be raised if and when the notification expires.
1134
+ *
1135
+ * See {@link Actions} for more details on notification actions, and receiving action events from notifications.
1136
+ */
1137
+ onExpire?: ActionDeclaration<never, never> | null;
1138
+ /**
1139
+ * An {@link NotificationActionResult|action result} to be passed back to the application inside the
1140
+ * {@link NotificationActionEvent|`notification-action`} event fired when the notification is closed.
1141
+ *
1142
+ * This action is raised regardless of how the notification is closed, whether from user interaction, expiration,
1143
+ * or programmatic removal -- such as a call to `clear`.
1144
+ *
1145
+ * See {@link Actions} for more details on notification actions, and receiving action events from notifications.
1146
+ */
1147
+ onClose?: ActionDeclaration<never, never> | null;
1148
+ /**
1149
+ * A priority for this notification. It's from 1 - 4.
1150
+ */
1151
+ priority?: number;
1152
+ /**
1153
+ * Sound options for a notification.
1154
+ */
1155
+ soundOptions?: NotificationSoundOptions;
1156
+ }
1157
+
1158
+ /**
1159
+ * Notifications allow additional UI components to be specified by applications. The service controls the
1160
+ * positioning and styling of these components.
1161
+ *
1162
+ * @module Controls
1163
+ */
1164
+ /**
1165
+ * Need a comment block here so that the comment block above is interpreted as a file comment, and not a comment on the
1166
+ * import below.
1167
+ *
1168
+ * @hidden
1169
+ */
1170
+
1171
+ /**
1172
+ * Configuration options for constructing a button within a notification.
1173
+ */
1174
+ interface ButtonOptions {
1175
+ /**
1176
+ * The type of the control. Optional, added automatically if `NotificationOptions.buttons` includes the `onClick`
1177
+ * property and therefore generates a `notification-action` event.
1178
+ */
1179
+ type?: 'button';
1180
+ /**
1181
+ * User-facing button text.
1182
+ *
1183
+ * The button caption should be kept short, particularly if there are multiple buttons. Notifications are
1184
+ * fixed-width, and all buttons will be displayed on the same row.
1185
+ */
1186
+ title: string;
1187
+ /**
1188
+ * Indicates that this button will be visually displayed as a 'Call to Action' button. In this case a Call To Action
1189
+ * means the button is made more prominent. We recommend you use this for true calls to action. For example, if you
1190
+ * have a notification which contains a report, it might have an 'OK' button which takes you to the report, and a
1191
+ * 'Dismiss' button which simply closes the notification. We suggest you make only the 'OK' button a CTA here.'
1192
+ *
1193
+ * If set as `false` or `undefined`, the default simple text button will be used instead.
1194
+ */
1195
+ cta?: boolean;
1196
+ /**
1197
+ * Indicates that this button should submit a form.
1198
+ * If a form is invalid, based on your validation rules provided, the button will be disabled until the users input within the form is valid.
1199
+ */
1200
+ submit?: boolean;
1201
+ /**
1202
+ * @deprecated
1203
+ * Optional icon URL, if an icon should be placed on the button.
1204
+ *
1205
+ * Icons are placed to the left of the button text.
1206
+ */
1207
+ iconUrl?: string;
1208
+ /**
1209
+ * Defines the data to be passed back to the application when the button is clicked.
1210
+ *
1211
+ * The {@link NotificationActionResult} specified here will be returned to the application via a
1212
+ * `notification-action` event when the button is clicked.
1213
+ *
1214
+ * If omitted or `null`, applications will not receive a {@link NotificationActionEvent|`notification-action`}
1215
+ * event when the button is clicked. This may be appropriate if the button represents a "dismiss" or some other
1216
+ * side-effect-free interaction. Even if `onClick` is omitted or `null`, a `notification-closed` event will still be
1217
+ * raised after the button click.
1218
+ *
1219
+ */
1220
+ onClick?: ActionDeclaration<never, never> | null;
1221
+ /**
1222
+ * Button index used for events. This gets set when hydrating.
1223
+ *
1224
+ * @hidden
1225
+ */
1226
+ index?: number;
1227
+ formOptions?: {
1228
+ /**
1229
+ * Title to display on a button when form is submitting.
1230
+ */
1231
+ submittingTitle?: string | null;
1232
+ /**
1233
+ * Title to display on a button when form is in the error state.
1234
+ */
1235
+ errorTitle?: string | null;
1236
+ /**
1237
+ * Title to display on a button when form is in the success state.
1238
+ */
1239
+ successTitle?: string | null;
1240
+ } | null;
1241
+ }
1242
+
1243
+ /**
1244
+ * @module Notifications
1245
+ */
1246
+ /**
1247
+ * Sound options for a notification
1248
+ */
1249
+ interface NotificationSoundOptions {
1250
+ /**
1251
+ * Determines the sound that will be played when a notification is received.
1252
+ *
1253
+ * @default 'default' plays the default notification sound.
1254
+ */
1255
+ mode: 'default' | 'silent';
1256
+ }
1257
+
1258
+ /**
1259
+ * @module Notifications
1260
+ */
1261
+ /**
1262
+ * Details of the application that will handle any actions coming from a particular stream.
1263
+ */
1264
+ interface NotificationStream {
1265
+ /**
1266
+ * Unique id of the stream.
1267
+ */
1268
+ id: string;
1269
+ /**
1270
+ * Stream title.
1271
+ *
1272
+ * Providing a different displayName for an existing stream id will update the
1273
+ * displayName of the stream stored in Notification Center.
1274
+ *
1275
+ */
1276
+ displayName: string;
1277
+ /**
1278
+ * ID of the application source of this stream.
1279
+ */
1280
+ appId: string;
1281
+ }
1282
+
1283
+ interface NotificationIndicatorColorsSet {
1284
+ background: string;
1285
+ foreground: string;
1286
+ }
1287
+ declare module 'styled-components' {
1288
+ interface DefaultTheme {
1289
+ notificationIndicatorColors?: Record<string, NotificationIndicatorColorsSet>;
1290
+ }
1291
+ }
1292
+
1293
+ /**
1294
+ * @module NotificationCenter
1295
+ */
1296
+ /**
1297
+ * Need a comment block here so that the comment block above is interpreted as a file comment, and not a comment on the
1298
+ * import below.
1299
+ *
1300
+ * @hidden
1301
+ */
1302
+
1303
+ /**
1304
+ * Application-defined context data that can be attached to buttons on notifications.
1305
+ */
1306
+ type CustomData = Record<string, any>;
1307
+ /**
1308
+ * A fully-hydrated form of {@link NotificationOptions}.
1309
+ *
1310
+ * After {@link create|creating} a notification, the service will return an object of this type. This will be the given
1311
+ * options object, with any unspecified fields filled-in with default values.
1312
+ *
1313
+ * This object should be treated as immutable. Modifying its state will not have any effect on the notification or the
1314
+ * state of the service.
1315
+ */
1316
+ type Notification<T extends NotificationOptions = NotificationOptions> = Readonly<Required<DistributiveOmit<T, 'buttons'>> & {
1317
+ readonly buttons: ReadonlyArray<Required<ButtonOptions>>;
1318
+ }>;
1319
+
1320
+ /**
1321
+ * Persisted modifiers to a notification.
1322
+ * Store changes to a notification here so we do not alter the original notification for historical purposes.
1323
+ */
1324
+ interface NotificationModifiers {
1325
+ /**
1326
+ * When a sticky notification has been minimized track its sticky state change here.
1327
+ */
1328
+ notSticky?: boolean;
1329
+ /**
1330
+ * When Notifications are updated a revision number is generated to allow for easier update rendering
1331
+ */
1332
+ revision?: number;
1333
+ /**
1334
+ * The timestamp at which this notification is set to be recreated.
1335
+ */
1336
+ reminder?: number;
1337
+ /**
1338
+ * A flag that indicates that this is a tutorial notification created by the center.
1339
+ * No events dispatch attempts will be done for tutorial notifications.
1340
+ */
1341
+ tutorial?: boolean;
1342
+ }
1343
+
1344
+ /**
1345
+ * Shape of the data that will be used internally by the service.
1346
+ *
1347
+ * The id property is the encoded notification id (i.e. "{app uuid}/{notification ID}")
1348
+ *
1349
+ */
1350
+ type StoredNotification<T extends NotificationOptions = NotificationOptions> = Immutable<{
1351
+ id: string;
1352
+ source: NotificationSource;
1353
+ notification: NotificationInternal<T>;
1354
+ title: string;
1355
+ modifiers?: NotificationModifiers;
1356
+ /**
1357
+ * Stripped text contents of the body without HTML/Markdown. Use this for search
1358
+ */
1359
+ bodyText: string;
1360
+ }>;
1361
+
1362
+ type StoredApplication = Immutable<ProgrammaticApplication> | Immutable<ManifestApplication> | Immutable<WebApplication>;
1363
+ /**
1364
+ * Interface used when reading properties from an application manifest
1365
+ *
1366
+ * Not intended to be a complete list of all properties, only defines the properties that are used by the service.
1367
+ */
1368
+ interface Manifest {
1369
+ name?: string;
1370
+ uuid?: string;
1371
+ startup_app?: {
1372
+ uuid: string;
1373
+ name: string;
1374
+ applicationIcon?: string;
1375
+ icon: string;
1376
+ };
1377
+ shortcut?: {
1378
+ name?: string;
1379
+ icon: string;
1380
+ };
1381
+ platform?: {
1382
+ uuid: string;
1383
+ };
1384
+ notifications?: {
1385
+ security?: {
1386
+ notificationRule?: NotificationSecurityRule;
1387
+ };
1388
+ };
1389
+ }
1390
+ interface StoredApplicationBase {
1391
+ id: string;
1392
+ title: string;
1393
+ muted: boolean;
1394
+ persistToasts: boolean;
1395
+ iconUrl?: string;
1396
+ }
1397
+ interface ProgrammaticApplication extends StoredApplicationBase {
1398
+ type: 'programmatic';
1399
+ initialOptions: Manifest;
1400
+ parentUuid: string;
1401
+ }
1402
+ interface ManifestApplication extends StoredApplicationBase {
1403
+ type: 'manifest';
1404
+ manifestUrl: string;
1405
+ }
1406
+ interface WebApplication extends StoredApplicationBase {
1407
+ type: 'web';
1408
+ }
1409
+
1410
+ /**
1411
+ * Shape of the internal streams stored in the database.
1412
+ */
1413
+ interface StoredStream extends NotificationStream {
1414
+ appId: string;
1415
+ muted: boolean;
1416
+ }
1417
+
1418
+ declare global {
1419
+ interface Window {
1420
+ search: SearchWindow;
1421
+ }
1422
+ }
1423
+ interface SearchWindow {
1424
+ minLength: number;
1425
+ useQueryLength: boolean;
1426
+ queryLengthMinus: number;
1427
+ threshold: number;
1428
+ distance: number;
1429
+ useExtendedSearch: boolean;
1430
+ logging: boolean;
1431
+ }
1432
+
1433
+ type Reminder = {
1434
+ modifiers: {
1435
+ reminder: number;
1436
+ };
1437
+ } & StoredNotification;
1438
+ type NotificationCenterSnapshot = {
1439
+ applications: StoredApplication[];
1440
+ streams: StoredStream[];
1441
+ notifications: StoredNotification[];
1442
+ reminders: Reminder[];
1443
+ };
1444
+ type Immutable<T> = {
1445
+ readonly [K in keyof T]: T[K] extends Date ? T[K] : T[K] extends [infer U, infer V] ? Readonly<[Immutable<U>, Immutable<V>]> : T[K] extends (infer U)[] ? ReadonlyArray<U extends object ? Immutable<U> : U> : T[K] extends object ? Immutable<T[K]> : Readonly<T[K]>;
1446
+ };
1447
+
1448
+ type NotificationCenterTheme = {
1449
+ palette: CustomPaletteSet;
1450
+ };
1451
+ type NotificationCenterStartupOptions = {
1452
+ /**
1453
+ * A snapshot of a previous state of the Notification Center to be loaded at startup.
1454
+ * @optional
1455
+ */
1456
+ snapshot?: NotificationCenterSnapshot;
1457
+ /**
1458
+ * A Web Notification Center theme to be loaded at startup.
1459
+ * @optional
1460
+ */
1461
+ theme?: NotificationCenterTheme;
1462
+ /**
1463
+ * A custom sound file URL to play when a new notification is created.
1464
+ * - If not provided, Notification Center attempts to load the default 'notification.wav' from the HERE CDN.
1465
+ * - If cross-origin media files are blocked and no customSoundUrl is set, no sound will play—
1466
+ * even if the user has enabled notification sounds in the settings panel.
1467
+ *
1468
+ * Note: Some audio formats may not be supported by all browsers.
1469
+ * Make sure to check browser compatibility for your chosen audio format.
1470
+ * @optional
1471
+ */
1472
+ customSoundUrl?: string;
1473
+ };
1474
+ type NotificationCenterInitOptions = NotificationCenterStartupOptions & {
1475
+ /**
1476
+ * Unique identifier for the Notification Center instance.
1477
+ * Must be a non-empty string that matches the `serviceId` used in the Web Notification Center Client API connection options.
1478
+ */
1479
+ serviceId: string;
1480
+ /**
1481
+ * The `fin` entry point for HERE Core Web integration.
1482
+ * For setup instructions, see: https://www.npmjs.com/package/@openfin/core-web
1483
+ */
1484
+ finContext: OpenFin.Fin<'external connection'>;
1485
+ /**
1486
+ * A container HTML element where the Web Notification Center will be rendered.
1487
+ * The UI is optimized for containers with a width of 345px.
1488
+ */
1489
+ container: HTMLElement;
1490
+ };
1491
+ type CustomPaletteSet = DefaultPaletteSet & {
1492
+ functional1?: string;
1493
+ functional2?: string;
1494
+ functional3?: string;
1495
+ functional4?: string;
1496
+ functional5?: string;
1497
+ functional6?: string;
1498
+ functional7?: string;
1499
+ functional8?: string;
1500
+ functional9?: string;
1501
+ functional10?: string;
1502
+ statusSuccess?: string;
1503
+ statusWarning?: string;
1504
+ statusCritical?: string;
1505
+ statusActive?: string;
1506
+ inputBackground?: string;
1507
+ inputColor?: string;
1508
+ inputPlaceholder?: string;
1509
+ inputDisabled?: string;
1510
+ inputFocused?: string;
1511
+ inputBorder?: string;
1512
+ textDefault?: string;
1513
+ textHelp?: string;
1514
+ textInactive?: string;
1515
+ background1?: string;
1516
+ background2?: string;
1517
+ background3?: string;
1518
+ background4?: string;
1519
+ background5?: string;
1520
+ background6?: string;
1521
+ contentBackground1?: string;
1522
+ contentBackground2?: string;
1523
+ contentBackground3?: string;
1524
+ contentBackground4?: string;
1525
+ contentBackground5?: string;
1526
+ linkDefault?: string;
1527
+ linkHover?: string;
1528
+ };
1529
+ type DefaultPaletteSet = {
1530
+ brandPrimary: string;
1531
+ brandSecondary: string;
1532
+ backgroundPrimary: string;
1533
+ };
1534
+ type ListenerContext = any;
1535
+
1536
+ declare function initNotificationCenter(options: NotificationCenterInitOptions): Promise<void>;
1537
+ declare function getSnapshot(): NotificationCenterSnapshot;
1538
+ declare function applySnapshot(snapshot: NotificationCenterSnapshot): Promise<void>;
1539
+ declare function setTheme(theme: NotificationCenterTheme): Promise<void>;
1540
+ declare function addNotificationCountListener(listener: (count: number) => void, context?: ListenerContext): void;
1541
+ declare function removeNotificationCountListener(listener: (count: number) => void, context?: ListenerContext): void;
1542
+ declare function addVisibilityListener(listener: (visible: boolean) => void, context?: ListenerContext): void;
1543
+ declare function removeVisibilityListener(listener: (visible: boolean) => void, context?: ListenerContext): void;
1544
+ declare function show(): Promise<void>;
1545
+ declare function hide(): Promise<void>;
1546
+
1547
+ export { addNotificationCountListener, addVisibilityListener, applySnapshot, getSnapshot, hide, initNotificationCenter, removeNotificationCountListener, removeVisibilityListener, setTheme, show };
1548
+ export type { CustomPaletteSet, DefaultPaletteSet, ListenerContext, NotificationCenterInitOptions, NotificationCenterSnapshot, NotificationCenterStartupOptions, NotificationCenterTheme };