memorial-ui-component-library 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/types/dialog.d.ts CHANGED
@@ -1,643 +1,643 @@
1
- import { MemorialUIComponent, MemorialUIPluginComponent } from './component';
2
- import { VueConstructor, PluginObject } from 'vue';
3
- import { SdDialogPluginOptions } from './options';
4
- import { RuleProperty } from './async-validator';
5
-
6
- declare module 'vue/types/vue' {
7
- interface Vue {
8
- /** Dialog controller*/
9
- $dialog: typeof SdDialogController;
10
- }
11
- }
12
-
13
- /**
14
- * Callbacks to execute when certain life-cycle hooks are reached.
15
- */
16
- export declare interface DialogHooks<ReturnType> {
17
- /**
18
- * Indicates that the dialog was successfully closed.
19
- * @param result The result returned by the dialog instance.
20
- */
21
- close?: (
22
- result: ReturnType,
23
- cancel: (message?: string | Error) => void
24
- ) => any | void;
25
- /**
26
- * Indicates that that dialog was closed by cancellation.
27
- * @param message The error or message that described the reason for cancellation.
28
- */
29
- cancel?: (message: string | Error) => void;
30
-
31
- /**
32
- * Indicates that the dialog was closed in error.
33
- * @param err The error or message that occurred.
34
- */
35
- error?: (err: string | Error) => void;
36
- }
37
-
38
- export declare class SdDialog<
39
- TReturn,
40
- TPayload,
41
- TContainerPayload
42
- > extends MemorialUIPluginComponent {
43
- /**
44
- * Vue templates for common use cases.
45
- */
46
- static templates: {
47
- alert: typeof SdAlertDialog;
48
- confirm: typeof SdConfirmDialog;
49
- prompt: typeof SdPromptDialog;
50
- };
51
-
52
- /**
53
- * Attaches the dialog components to the app root. NOTE: This function is not necessary in Nuxt apps.
54
- * @param app Root Vue app instance.
55
- */
56
- static attach(app?: VueConstructor): void;
57
-
58
- /**
59
- * Payload scoped to the dialog accessible within extended component template.
60
- */
61
- payload?: TPayload;
62
-
63
- /**
64
- * Payload scoped and accessible to the entire container controlling the dialog.
65
- */
66
- containerPayload?: TContainerPayload;
67
-
68
- /**
69
- * Container the dialog is mounted within.
70
- */
71
- container: SdDialogContainer<TContainerPayload>;
72
-
73
- /** Unique dialog id. */
74
- readonly id: string;
75
-
76
- /**
77
- * Destroys the dialog indicating that the instance life-cycle was completed.
78
- * @param data Optional data returned by the dialog instance.
79
- */
80
- close(data: TReturn): Promise<void>;
81
-
82
- /**
83
- * Destroys the dialog indicating that the instance life-cycle was cancelled.
84
- * @param message Optional message indicating why the dialog was cancelled.
85
- */
86
- cancel(message?: string | Error): Promise<void>;
87
-
88
- /**
89
- * Destroys the dialog indicating that an error has occurred.
90
- * @param message The error or message that occurred.
91
- */
92
- error(message: string | Error): Promise<void>;
93
- }
94
-
95
- export declare class SdDialogNode<
96
- TPrecedingResult,
97
- TOwnResult,
98
- TPayload,
99
- TContainerScopeData
100
- > extends SdDialog<TOwnResult, TPayload, TContainerScopeData> {
101
- /**
102
- * Result returned by the preceding dialog in the sequence or graph.
103
- */
104
- precedingResult?: TPrecedingResult;
105
- }
106
-
107
- export declare class SdAlertDialog<TContainerPayload> extends SdDialog<
108
- void,
109
- SdAlertDialogOptions,
110
- TContainerPayload
111
- > {
112
- /**
113
- * The alert's displayed title.
114
- */
115
- title: string;
116
- /**
117
- * The alert's message body.
118
- */
119
- message: string;
120
- }
121
-
122
- export declare class SdConfirmDialog<TContainerPayload> extends SdDialog<
123
- boolean,
124
- SdConfirmDialogOptions,
125
- TContainerPayload
126
- > {
127
- /**
128
- * The confirmation's displayed title.
129
- */
130
- title: string;
131
- /**
132
- * The confirmation's message body.
133
- */
134
- message: string;
135
- }
136
-
137
- export declare class SdPromptDialog<TContainerPayload> extends SdDialog<
138
- string,
139
- SdPromptDialogOptions,
140
- TContainerPayload
141
- > {
142
- /**
143
- * The prompts displayed title.
144
- */
145
- title: string;
146
- /**
147
- * The prompts message body.
148
- */
149
- message: string;
150
- }
151
-
152
- export declare class SdDialogContainer<
153
- TContainerPayload
154
- > extends MemorialUIComponent {
155
- /**
156
- * Payload scoped and accessible to the entire container controlling the dialog.
157
- */
158
- containerPayload?: TContainerPayload;
159
- }
160
-
161
- export interface SdDialogOptions<TResult, TPayload> {
162
- /**
163
- * Payload scoped to the dialog accessible within extended component template.
164
- */
165
- payload?: TPayload;
166
- /**
167
- * Callbacks to execute when certain life-cycle hooks are reached.
168
- */
169
- hooks?: DialogHooks<TResult>;
170
- }
171
-
172
- export interface SdDialogSequenceOptions<TPrecedingResult, TResult, TPayload> {
173
- /**
174
- * Payload scoped to the dialog node and accessible within extended component template.
175
- */
176
- payload?: TPayload;
177
- /**
178
- * Callbacks to execute when specified life-cycle hooks are reached.
179
- */
180
- hooks?: DialogHooks<TResult>;
181
- /**
182
- * Validation functions which control the flow of execution.
183
- */
184
- execution?: {
185
- /**
186
- * Executed before proceeding to the next dialog.
187
- * @param ownResult The result returned by the current dialog node.
188
- * @param precedingResult The result returned by the previous dialog node
189
- * @returns Boolean value indicating whether to proceed to the next dialog node.
190
- */
191
- beforeNext?: (
192
- ownResult: TResult,
193
- precedingResult: TPrecedingResult
194
- ) => boolean | Promise<boolean>;
195
- };
196
- }
197
-
198
- export interface SdAlertDialogOptions {
199
- /**
200
- * The title to display for the alert.
201
- */
202
- title: string;
203
- /**
204
- * The message body to display in the alert.
205
- */
206
- message: string;
207
- /**
208
- * Optional text to replace the contents of the close button.
209
- */
210
- closeButtonText?: string;
211
- }
212
-
213
- export interface SdConfirmDialogOptions {
214
- /**
215
- * The title to display for the confirmation.
216
- */
217
- title: string;
218
- /**
219
- * The message body to display in the confirmation.
220
- */
221
- message: string;
222
- /**
223
- * Whether to show a close button in the upper right corner of the dialog.
224
- */
225
- showClose?: boolean;
226
- /**
227
- * Optional text to replace the contents of the **Yes** button.
228
- */
229
- yesButtonText?: string;
230
- /**
231
- * Optional text to replace the contents of the **No** button.
232
- */
233
- noButtonText?: string;
234
- }
235
-
236
- export interface SdPromptDialogOptions {
237
- /**
238
- * The title to display for the prompt.
239
- */
240
- title: string;
241
- /**
242
- * The message body to display in the prompt.
243
- */
244
- message: string;
245
- /**
246
- * Whether an input value is required to successfully close the prompt.
247
- */
248
- inputRequired?: boolean;
249
- /**
250
- * Optional text to replace the default validation message in the event of an input validation error.
251
- */
252
- inputValidationMessage?: string;
253
- /**
254
- * Additional validation rules to apply to the input
255
- */
256
- rules?: RuleProperty[];
257
- /**
258
- * Whether to show a close button in the upper right corner of the dialog.
259
- */
260
- showClose?: boolean;
261
- /**
262
- * Optional text to replace the contents of the **Submit** button.
263
- */
264
- submitButtonText?: string;
265
- /**
266
- * Optional text to replace the contents of the **Cancel** button.
267
- */
268
- cancelButtonText?: string;
269
- }
270
-
271
- export declare class SdDialogInstance<TResult, TPayload> {
272
- /**
273
- * Displays the dialog.
274
- * @returns A promise which gets resolved when the dialog is closed. Contains the result of the dialog.
275
- */
276
- showAsync(): Promise<TResult>;
277
-
278
- /**
279
- * Manually cancels the instance execution.
280
- * @param message The message or error describing think reason for cancellation.
281
- */
282
- cancel(message: string | Error): void;
283
- }
284
-
285
- /**
286
- * Registers the entry node dialog node of the sequence.
287
- * @param ctor The Vue constructor of the template to display.
288
- * @param options Options used to configure the dialog.
289
- */
290
- interface DialogSequenceEntry<TSequencePayload> {
291
- <TResult, TPayload>(
292
- ctor: DialogNodeComponent<undefined, TResult, TPayload, TSequencePayload>,
293
- options?: SdDialogSequenceOptions<undefined, TResult, TPayload>
294
- ): {
295
- /**
296
- * Starts the dialog sequence by displaying the first registered node.
297
- * @returns The result of the last dialog in the sequence.
298
- */
299
- startAsync(): Promise<TResult>;
300
-
301
- /**
302
- * Manually cancels the sequence execution.
303
- * @param message The message or error describing think reason for cancellation.
304
- */
305
- cancel(message: string | Error): void;
306
-
307
- /**
308
- * Registers a node dialog node within the sequence.
309
- * @param ctor The Vue constructor of the template to display.
310
- * @param options Options used to configure the dialog.
311
- */
312
- register: DialogSequenceBuilder<TResult, TSequencePayload>;
313
- };
314
- }
315
-
316
- /**
317
- * Registers a node dialog node within the sequence.
318
- * @param ctor The Vue constructor of the template to display.
319
- * @param options Options used to configure the dialog.
320
- */
321
- interface DialogSequenceBuilder<TPreviousResult, TSequencePayload> {
322
- <TResult, TPayload>(
323
- ctor: DialogNodeComponent<
324
- TPreviousResult,
325
- TResult,
326
- TPayload,
327
- TSequencePayload
328
- >,
329
- options?: SdDialogSequenceOptions<TPreviousResult, TResult, TPayload>
330
- ): {
331
- /**
332
- * Starts the dialog sequence by displaying the first registered node.
333
- * @returns The result of the last dialog in the sequence.
334
- */
335
- startAsync(): Promise<TResult>;
336
-
337
- /**
338
- * Manually cancels the sequence execution.
339
- * @param message The message or error describing think reason for cancellation.
340
- */
341
- cancel(message: string | Error): void;
342
-
343
- /**
344
- * Registers a node dialog node within the sequence.
345
- * @param ctor The Vue constructor of the template to display.
346
- * @param options Options used to configure the dialog.
347
- */
348
- register: DialogSequenceBuilder<TResult, TSequencePayload>;
349
- };
350
- }
351
-
352
- export declare class SdDialogSequence<TSequencePayload> {
353
- /**
354
- * Registers the entry node dialog node of the sequence.
355
- * @param ctor The Vue constructor of the template to display.
356
- * @param options Options used to configure the dialog.
357
- */
358
- register: DialogSequenceEntry<TSequencePayload>;
359
- }
360
-
361
- /**
362
- * Graph node configuration.
363
- */
364
- export type GraphNode<
365
- TPrecedingResult = any,
366
- TResult = any,
367
- TPayload = any,
368
- TContainerPayload = any
369
- > = {
370
- /**
371
- * The Vue constructor of the template to display.
372
- */
373
- ctor: DialogNodeComponent<
374
- TPrecedingResult,
375
- TResult,
376
- TPayload,
377
- TContainerPayload
378
- >;
379
- } & SdDialogSequenceOptions<TPrecedingResult, TResult, TPayload>;
380
-
381
- export type TypeCaster = <TPR, TR, TP, TCP>(
382
- node: GraphNode<TPR, TR, TP, TCP>
383
- ) => GraphNode<TPR, TR, TP, TCP>;
384
-
385
- /**
386
- * Collection of nodes to include in the graph.
387
- */
388
- export interface GraphNodeList<TGraphPayload = any> {
389
- [id: string]: GraphNode<any, any, any, TGraphPayload>;
390
- }
391
-
392
- /**
393
- * Mapping between node identifiers and the resolution of its destination node.
394
- */
395
- export type NodePathMap<TPayload> = {
396
- [k in keyof GraphNodeList<TPayload>]: DestinationEdge<
397
- GraphNodeList<TPayload>
398
- >;
399
- };
400
-
401
- /**
402
- * Defines an edge identifier within the the graph.
403
- */
404
- export type DestinationEdge<TNodes> =
405
- | (keyof TNodes)
406
- | ((result: any, from: keyof TNodes) => (keyof TNodes) | null)
407
- | null;
408
-
409
- /**
410
- * Function to declare an edge between two two graph nodes.
411
- * @param source The starting edge node.
412
- * @param destination The identifier or function to resolve an identifier of the end edge node.
413
- */
414
- export type EdgeCtor<TNodes> = (
415
- source: keyof TNodes,
416
- destination: DestinationEdge<TNodes>
417
- ) => EdgeBuilder<TNodes>;
418
-
419
- /**
420
- * builder which defines the edges within a graph
421
- */
422
- export interface EdgeBuilder<TNodes> {
423
- /**
424
- * Function to declare an edge between two two graph nodes.
425
- * @param source The starting edge node.
426
- * @param destination The identifier or function to resolve an identifier of the end edge node.
427
- */
428
- edge: EdgeCtor<TNodes>;
429
- }
430
-
431
- export interface GraphBuilderEntry<TNodes extends GraphNodeList> {
432
- /**
433
- * Defines the entry (entry) node of the graph.
434
- * @param node The identifier of the entry node.
435
- * @param next Optionally defines the to destination node for the first graph edge.
436
- * @returns An edge builder which defines the remaining edged within the graph.
437
- */
438
- entry<K extends keyof TNodes>(
439
- node: K,
440
- next?: DestinationEdge<TNodes>
441
- ): EdgeBuilder<TNodes>;
442
- }
443
-
444
- /**
445
- * Factory which creates a the edge map of a graph.
446
- */
447
- export type GraphBuilderFactory<TNodes extends GraphNodeList> = (
448
- builder: GraphBuilderEntry<TNodes>
449
- ) => void;
450
-
451
- export declare class SdDialogGraph<TGraphPayload> {
452
- /**
453
- * Starts the dialog graph by displaying the entry node.
454
- * @returns The result of the last dialog in the graph.
455
- */
456
- startAsync(): Promise<any>;
457
-
458
- /**
459
- * Manually cancels the graph execution.
460
- * @param message The message or error describing think reason for cancellation.
461
- */
462
- cancel(message: string | Error): void;
463
- }
464
-
465
- export declare class SdDialogController {
466
- /**
467
- * Creates an instance of a single dialog.
468
- * @param ctor The Vue constructor of the template to display.
469
- * @param options Options used to configure the dialog.
470
- */
471
- static create<TReturn, TPayload, TContainerData>(
472
- ctor: DialogComponent<TReturn, TPayload, TContainerData>,
473
- options?: SdDialogOptions<TReturn, TPayload>
474
- ): SdDialogInstance<TReturn, TPayload>;
475
-
476
- /**
477
- * Creates a sequence of dialog to progress through.
478
- * @param payload Data accessible to all dialog nodes within the sequence.
479
- */
480
- static sequence<TSequencePayload>(
481
- payload?: TSequencePayload
482
- ): SdDialogSequence<TSequencePayload>;
483
-
484
- /**
485
- * Creates a bidirectional graph of dialog nodes to dynamically progress through.
486
- * @param nodes The list of nodes to make up the graph.
487
- * @param builder Factory used to configure the edges between nodes.
488
- * @param payload Data accessible to all dialog nodes within the graph.
489
- */
490
- static graph<TGraphPayload>(
491
- nodes: GraphNodeList<TGraphPayload>,
492
- builder: GraphBuilderFactory<GraphNodeList<TGraphPayload>>,
493
- payload?: TGraphPayload
494
- ): SdDialogGraph<TGraphPayload>;
495
-
496
- /**
497
- * Creates an instance of an alert dialog.
498
- * @param options Options used to configure the alert dialog.
499
- * @param hooks Callbacks to execute when specified life-cycle hooks are reached.
500
- */
501
- static alert(
502
- options: SdAlertDialogOptions,
503
- hooks?: DialogHooks<void>
504
- ): SdDialogInstance<void, SdAlertDialogOptions>;
505
-
506
- /**
507
- * Creates an instance of a confirmation dialog.
508
- * @param options Options used to configure the confirmation dialog.
509
- * @param hooks Callbacks to execute when specified life-cycle hooks are reached.
510
- */
511
- static confirm(
512
- options: SdConfirmDialogOptions,
513
- hooks?: DialogHooks<boolean>
514
- ): SdDialogInstance<boolean, SdConfirmDialogOptions>;
515
-
516
- /**
517
- * Creates an instance of a prompt dialog.
518
- * @param options Options used to configure the prompt dialog.
519
- * @param hooks Callbacks to execute when specified life-cycle hooks are reached.
520
- */
521
- static prompt(
522
- options: SdPromptDialogOptions,
523
- hooks?: DialogHooks<boolean>
524
- ): SdDialogInstance<any, SdPromptDialogOptions>;
525
- }
526
-
527
- export interface DialogComponentConstructor<
528
- ReturnType,
529
- Payload,
530
- ContainerScopeData
531
- > {
532
- new (): SdDialog<ReturnType, Payload, ContainerScopeData>;
533
- }
534
-
535
- export type GenericComponent<ReturnType, Payload, ContainerScopeData> =
536
- | DialogComponentConstructor<ReturnType, Payload, ContainerScopeData>
537
- | VueConstructor;
538
-
539
- export type ESModuleComponent<ReturnType, Payload, ContainerScopeData> =
540
- | GenericComponent<ReturnType, Payload, ContainerScopeData>
541
- | { default: GenericComponent<ReturnType, Payload, ContainerScopeData> };
542
-
543
- export type AsyncComponent<ReturnType, Payload, ContainerScopeData> = Promise<
544
- ESModuleComponent<ReturnType, Payload, ContainerScopeData>
545
- >;
546
-
547
- export type DialogComponent<ReturnType, Payload, ContainerScopeData> =
548
- | ESModuleComponent<ReturnType, Payload, ContainerScopeData>
549
- | AsyncComponent<ReturnType, Payload, ContainerScopeData>;
550
-
551
- // Node types
552
- export interface DialogNodeComponentConstructor<
553
- PrecedingResult,
554
- ReturnType,
555
- Payload,
556
- ContainerScopeData
557
- > {
558
- new (): SdDialogNode<
559
- PrecedingResult,
560
- ReturnType,
561
- Payload,
562
- ContainerScopeData
563
- >;
564
- }
565
-
566
- export type GenericDialogNodeComponent<
567
- PrecedingResult,
568
- ReturnType,
569
- Payload,
570
- ContainerScopeData
571
- > =
572
- | DialogNodeComponentConstructor<
573
- PrecedingResult,
574
- ReturnType,
575
- Payload,
576
- ContainerScopeData
577
- >
578
- | VueConstructor;
579
-
580
- export type ESModuleDialogNodeComponent<
581
- PrecedingResult,
582
- ReturnType,
583
- Payload,
584
- ContainerScopeData
585
- > =
586
- | GenericDialogNodeComponent<
587
- PrecedingResult,
588
- ReturnType,
589
- Payload,
590
- ContainerScopeData
591
- >
592
- | {
593
- default: GenericDialogNodeComponent<
594
- PrecedingResult,
595
- ReturnType,
596
- Payload,
597
- ContainerScopeData
598
- >;
599
- };
600
-
601
- export type AsyncDialogNodeComponent<
602
- PrecedingResult,
603
- ReturnType,
604
- Payload,
605
- ContainerScopeData
606
- > = Promise<
607
- ESModuleDialogNodeComponent<
608
- PrecedingResult,
609
- ReturnType,
610
- Payload,
611
- ContainerScopeData
612
- >
613
- >;
614
-
615
- export type DialogNodeComponent<
616
- PrecedingResult,
617
- ReturnType,
618
- Payload,
619
- ContainerScopeData
620
- > =
621
- | ESModuleDialogNodeComponent<
622
- PrecedingResult,
623
- ReturnType,
624
- Payload,
625
- ContainerScopeData
626
- >
627
- | AsyncDialogNodeComponent<
628
- PrecedingResult,
629
- ReturnType,
630
- Payload,
631
- ContainerScopeData
632
- >;
633
-
634
- declare const plugin: typeof SdDialog &
635
- PluginObject<SdDialogPluginOptions> & {
636
- /**
637
- * Attached the dialog components to the app root. NOTE: This function is not necessary in Nuxt apps.
638
- * @param app Root Vue app instance.
639
- */
640
- attach(app?: VueConstructor): void;
641
- };
642
-
643
- export default plugin;
1
+ import { MemorialUIComponent, MemorialUIPluginComponent } from './component';
2
+ import { VueConstructor, PluginObject } from 'vue';
3
+ import { SdDialogPluginOptions } from './options';
4
+ import { RuleProperty } from './async-validator';
5
+
6
+ declare module 'vue/types/vue' {
7
+ interface Vue {
8
+ /** Dialog controller*/
9
+ $dialog: typeof SdDialogController;
10
+ }
11
+ }
12
+
13
+ /**
14
+ * Callbacks to execute when certain life-cycle hooks are reached.
15
+ */
16
+ export declare interface DialogHooks<ReturnType> {
17
+ /**
18
+ * Indicates that the dialog was successfully closed.
19
+ * @param result The result returned by the dialog instance.
20
+ */
21
+ close?: (
22
+ result: ReturnType,
23
+ cancel: (message?: string | Error) => void
24
+ ) => any | void;
25
+ /**
26
+ * Indicates that that dialog was closed by cancellation.
27
+ * @param message The error or message that described the reason for cancellation.
28
+ */
29
+ cancel?: (message: string | Error) => void;
30
+
31
+ /**
32
+ * Indicates that the dialog was closed in error.
33
+ * @param err The error or message that occurred.
34
+ */
35
+ error?: (err: string | Error) => void;
36
+ }
37
+
38
+ export declare class SdDialog<
39
+ TReturn,
40
+ TPayload,
41
+ TContainerPayload
42
+ > extends MemorialUIPluginComponent {
43
+ /**
44
+ * Vue templates for common use cases.
45
+ */
46
+ static templates: {
47
+ alert: typeof SdAlertDialog;
48
+ confirm: typeof SdConfirmDialog;
49
+ prompt: typeof SdPromptDialog;
50
+ };
51
+
52
+ /**
53
+ * Attaches the dialog components to the app root. NOTE: This function is not necessary in Nuxt apps.
54
+ * @param app Root Vue app instance.
55
+ */
56
+ static attach(app?: VueConstructor): void;
57
+
58
+ /**
59
+ * Payload scoped to the dialog accessible within extended component template.
60
+ */
61
+ payload?: TPayload;
62
+
63
+ /**
64
+ * Payload scoped and accessible to the entire container controlling the dialog.
65
+ */
66
+ containerPayload?: TContainerPayload;
67
+
68
+ /**
69
+ * Container the dialog is mounted within.
70
+ */
71
+ container: SdDialogContainer<TContainerPayload>;
72
+
73
+ /** Unique dialog id. */
74
+ readonly id: string;
75
+
76
+ /**
77
+ * Destroys the dialog indicating that the instance life-cycle was completed.
78
+ * @param data Optional data returned by the dialog instance.
79
+ */
80
+ close(data: TReturn): Promise<void>;
81
+
82
+ /**
83
+ * Destroys the dialog indicating that the instance life-cycle was cancelled.
84
+ * @param message Optional message indicating why the dialog was cancelled.
85
+ */
86
+ cancel(message?: string | Error): Promise<void>;
87
+
88
+ /**
89
+ * Destroys the dialog indicating that an error has occurred.
90
+ * @param message The error or message that occurred.
91
+ */
92
+ error(message: string | Error): Promise<void>;
93
+ }
94
+
95
+ export declare class SdDialogNode<
96
+ TPrecedingResult,
97
+ TOwnResult,
98
+ TPayload,
99
+ TContainerScopeData
100
+ > extends SdDialog<TOwnResult, TPayload, TContainerScopeData> {
101
+ /**
102
+ * Result returned by the preceding dialog in the sequence or graph.
103
+ */
104
+ precedingResult?: TPrecedingResult;
105
+ }
106
+
107
+ export declare class SdAlertDialog<TContainerPayload> extends SdDialog<
108
+ void,
109
+ SdAlertDialogOptions,
110
+ TContainerPayload
111
+ > {
112
+ /**
113
+ * The alert's displayed title.
114
+ */
115
+ title: string;
116
+ /**
117
+ * The alert's message body.
118
+ */
119
+ message: string;
120
+ }
121
+
122
+ export declare class SdConfirmDialog<TContainerPayload> extends SdDialog<
123
+ boolean,
124
+ SdConfirmDialogOptions,
125
+ TContainerPayload
126
+ > {
127
+ /**
128
+ * The confirmation's displayed title.
129
+ */
130
+ title: string;
131
+ /**
132
+ * The confirmation's message body.
133
+ */
134
+ message: string;
135
+ }
136
+
137
+ export declare class SdPromptDialog<TContainerPayload> extends SdDialog<
138
+ string,
139
+ SdPromptDialogOptions,
140
+ TContainerPayload
141
+ > {
142
+ /**
143
+ * The prompts displayed title.
144
+ */
145
+ title: string;
146
+ /**
147
+ * The prompts message body.
148
+ */
149
+ message: string;
150
+ }
151
+
152
+ export declare class SdDialogContainer<
153
+ TContainerPayload
154
+ > extends MemorialUIComponent {
155
+ /**
156
+ * Payload scoped and accessible to the entire container controlling the dialog.
157
+ */
158
+ containerPayload?: TContainerPayload;
159
+ }
160
+
161
+ export interface SdDialogOptions<TResult, TPayload> {
162
+ /**
163
+ * Payload scoped to the dialog accessible within extended component template.
164
+ */
165
+ payload?: TPayload;
166
+ /**
167
+ * Callbacks to execute when certain life-cycle hooks are reached.
168
+ */
169
+ hooks?: DialogHooks<TResult>;
170
+ }
171
+
172
+ export interface SdDialogSequenceOptions<TPrecedingResult, TResult, TPayload> {
173
+ /**
174
+ * Payload scoped to the dialog node and accessible within extended component template.
175
+ */
176
+ payload?: TPayload;
177
+ /**
178
+ * Callbacks to execute when specified life-cycle hooks are reached.
179
+ */
180
+ hooks?: DialogHooks<TResult>;
181
+ /**
182
+ * Validation functions which control the flow of execution.
183
+ */
184
+ execution?: {
185
+ /**
186
+ * Executed before proceeding to the next dialog.
187
+ * @param ownResult The result returned by the current dialog node.
188
+ * @param precedingResult The result returned by the previous dialog node
189
+ * @returns Boolean value indicating whether to proceed to the next dialog node.
190
+ */
191
+ beforeNext?: (
192
+ ownResult: TResult,
193
+ precedingResult: TPrecedingResult
194
+ ) => boolean | Promise<boolean>;
195
+ };
196
+ }
197
+
198
+ export interface SdAlertDialogOptions {
199
+ /**
200
+ * The title to display for the alert.
201
+ */
202
+ title: string;
203
+ /**
204
+ * The message body to display in the alert.
205
+ */
206
+ message: string;
207
+ /**
208
+ * Optional text to replace the contents of the close button.
209
+ */
210
+ closeButtonText?: string;
211
+ }
212
+
213
+ export interface SdConfirmDialogOptions {
214
+ /**
215
+ * The title to display for the confirmation.
216
+ */
217
+ title: string;
218
+ /**
219
+ * The message body to display in the confirmation.
220
+ */
221
+ message: string;
222
+ /**
223
+ * Whether to show a close button in the upper right corner of the dialog.
224
+ */
225
+ showClose?: boolean;
226
+ /**
227
+ * Optional text to replace the contents of the **Yes** button.
228
+ */
229
+ yesButtonText?: string;
230
+ /**
231
+ * Optional text to replace the contents of the **No** button.
232
+ */
233
+ noButtonText?: string;
234
+ }
235
+
236
+ export interface SdPromptDialogOptions {
237
+ /**
238
+ * The title to display for the prompt.
239
+ */
240
+ title: string;
241
+ /**
242
+ * The message body to display in the prompt.
243
+ */
244
+ message: string;
245
+ /**
246
+ * Whether an input value is required to successfully close the prompt.
247
+ */
248
+ inputRequired?: boolean;
249
+ /**
250
+ * Optional text to replace the default validation message in the event of an input validation error.
251
+ */
252
+ inputValidationMessage?: string;
253
+ /**
254
+ * Additional validation rules to apply to the input
255
+ */
256
+ rules?: RuleProperty[];
257
+ /**
258
+ * Whether to show a close button in the upper right corner of the dialog.
259
+ */
260
+ showClose?: boolean;
261
+ /**
262
+ * Optional text to replace the contents of the **Submit** button.
263
+ */
264
+ submitButtonText?: string;
265
+ /**
266
+ * Optional text to replace the contents of the **Cancel** button.
267
+ */
268
+ cancelButtonText?: string;
269
+ }
270
+
271
+ export declare class SdDialogInstance<TResult, TPayload> {
272
+ /**
273
+ * Displays the dialog.
274
+ * @returns A promise which gets resolved when the dialog is closed. Contains the result of the dialog.
275
+ */
276
+ showAsync(): Promise<TResult>;
277
+
278
+ /**
279
+ * Manually cancels the instance execution.
280
+ * @param message The message or error describing think reason for cancellation.
281
+ */
282
+ cancel(message: string | Error): void;
283
+ }
284
+
285
+ /**
286
+ * Registers the entry node dialog node of the sequence.
287
+ * @param ctor The Vue constructor of the template to display.
288
+ * @param options Options used to configure the dialog.
289
+ */
290
+ interface DialogSequenceEntry<TSequencePayload> {
291
+ <TResult, TPayload>(
292
+ ctor: DialogNodeComponent<undefined, TResult, TPayload, TSequencePayload>,
293
+ options?: SdDialogSequenceOptions<undefined, TResult, TPayload>
294
+ ): {
295
+ /**
296
+ * Starts the dialog sequence by displaying the first registered node.
297
+ * @returns The result of the last dialog in the sequence.
298
+ */
299
+ startAsync(): Promise<TResult>;
300
+
301
+ /**
302
+ * Manually cancels the sequence execution.
303
+ * @param message The message or error describing think reason for cancellation.
304
+ */
305
+ cancel(message: string | Error): void;
306
+
307
+ /**
308
+ * Registers a node dialog node within the sequence.
309
+ * @param ctor The Vue constructor of the template to display.
310
+ * @param options Options used to configure the dialog.
311
+ */
312
+ register: DialogSequenceBuilder<TResult, TSequencePayload>;
313
+ };
314
+ }
315
+
316
+ /**
317
+ * Registers a node dialog node within the sequence.
318
+ * @param ctor The Vue constructor of the template to display.
319
+ * @param options Options used to configure the dialog.
320
+ */
321
+ interface DialogSequenceBuilder<TPreviousResult, TSequencePayload> {
322
+ <TResult, TPayload>(
323
+ ctor: DialogNodeComponent<
324
+ TPreviousResult,
325
+ TResult,
326
+ TPayload,
327
+ TSequencePayload
328
+ >,
329
+ options?: SdDialogSequenceOptions<TPreviousResult, TResult, TPayload>
330
+ ): {
331
+ /**
332
+ * Starts the dialog sequence by displaying the first registered node.
333
+ * @returns The result of the last dialog in the sequence.
334
+ */
335
+ startAsync(): Promise<TResult>;
336
+
337
+ /**
338
+ * Manually cancels the sequence execution.
339
+ * @param message The message or error describing think reason for cancellation.
340
+ */
341
+ cancel(message: string | Error): void;
342
+
343
+ /**
344
+ * Registers a node dialog node within the sequence.
345
+ * @param ctor The Vue constructor of the template to display.
346
+ * @param options Options used to configure the dialog.
347
+ */
348
+ register: DialogSequenceBuilder<TResult, TSequencePayload>;
349
+ };
350
+ }
351
+
352
+ export declare class SdDialogSequence<TSequencePayload> {
353
+ /**
354
+ * Registers the entry node dialog node of the sequence.
355
+ * @param ctor The Vue constructor of the template to display.
356
+ * @param options Options used to configure the dialog.
357
+ */
358
+ register: DialogSequenceEntry<TSequencePayload>;
359
+ }
360
+
361
+ /**
362
+ * Graph node configuration.
363
+ */
364
+ export type GraphNode<
365
+ TPrecedingResult = any,
366
+ TResult = any,
367
+ TPayload = any,
368
+ TContainerPayload = any
369
+ > = {
370
+ /**
371
+ * The Vue constructor of the template to display.
372
+ */
373
+ ctor: DialogNodeComponent<
374
+ TPrecedingResult,
375
+ TResult,
376
+ TPayload,
377
+ TContainerPayload
378
+ >;
379
+ } & SdDialogSequenceOptions<TPrecedingResult, TResult, TPayload>;
380
+
381
+ export type TypeCaster = <TPR, TR, TP, TCP>(
382
+ node: GraphNode<TPR, TR, TP, TCP>
383
+ ) => GraphNode<TPR, TR, TP, TCP>;
384
+
385
+ /**
386
+ * Collection of nodes to include in the graph.
387
+ */
388
+ export interface GraphNodeList<TGraphPayload = any> {
389
+ [id: string]: GraphNode<any, any, any, TGraphPayload>;
390
+ }
391
+
392
+ /**
393
+ * Mapping between node identifiers and the resolution of its destination node.
394
+ */
395
+ export type NodePathMap<TPayload> = {
396
+ [k in keyof GraphNodeList<TPayload>]: DestinationEdge<
397
+ GraphNodeList<TPayload>
398
+ >;
399
+ };
400
+
401
+ /**
402
+ * Defines an edge identifier within the the graph.
403
+ */
404
+ export type DestinationEdge<TNodes> =
405
+ | (keyof TNodes)
406
+ | ((result: any, from: keyof TNodes) => (keyof TNodes) | null)
407
+ | null;
408
+
409
+ /**
410
+ * Function to declare an edge between two two graph nodes.
411
+ * @param source The starting edge node.
412
+ * @param destination The identifier or function to resolve an identifier of the end edge node.
413
+ */
414
+ export type EdgeCtor<TNodes> = (
415
+ source: keyof TNodes,
416
+ destination: DestinationEdge<TNodes>
417
+ ) => EdgeBuilder<TNodes>;
418
+
419
+ /**
420
+ * builder which defines the edges within a graph
421
+ */
422
+ export interface EdgeBuilder<TNodes> {
423
+ /**
424
+ * Function to declare an edge between two two graph nodes.
425
+ * @param source The starting edge node.
426
+ * @param destination The identifier or function to resolve an identifier of the end edge node.
427
+ */
428
+ edge: EdgeCtor<TNodes>;
429
+ }
430
+
431
+ export interface GraphBuilderEntry<TNodes extends GraphNodeList> {
432
+ /**
433
+ * Defines the entry (entry) node of the graph.
434
+ * @param node The identifier of the entry node.
435
+ * @param next Optionally defines the to destination node for the first graph edge.
436
+ * @returns An edge builder which defines the remaining edged within the graph.
437
+ */
438
+ entry<K extends keyof TNodes>(
439
+ node: K,
440
+ next?: DestinationEdge<TNodes>
441
+ ): EdgeBuilder<TNodes>;
442
+ }
443
+
444
+ /**
445
+ * Factory which creates a the edge map of a graph.
446
+ */
447
+ export type GraphBuilderFactory<TNodes extends GraphNodeList> = (
448
+ builder: GraphBuilderEntry<TNodes>
449
+ ) => void;
450
+
451
+ export declare class SdDialogGraph<TGraphPayload> {
452
+ /**
453
+ * Starts the dialog graph by displaying the entry node.
454
+ * @returns The result of the last dialog in the graph.
455
+ */
456
+ startAsync(): Promise<any>;
457
+
458
+ /**
459
+ * Manually cancels the graph execution.
460
+ * @param message The message or error describing think reason for cancellation.
461
+ */
462
+ cancel(message: string | Error): void;
463
+ }
464
+
465
+ export declare class SdDialogController {
466
+ /**
467
+ * Creates an instance of a single dialog.
468
+ * @param ctor The Vue constructor of the template to display.
469
+ * @param options Options used to configure the dialog.
470
+ */
471
+ static create<TReturn, TPayload, TContainerData>(
472
+ ctor: DialogComponent<TReturn, TPayload, TContainerData>,
473
+ options?: SdDialogOptions<TReturn, TPayload>
474
+ ): SdDialogInstance<TReturn, TPayload>;
475
+
476
+ /**
477
+ * Creates a sequence of dialog to progress through.
478
+ * @param payload Data accessible to all dialog nodes within the sequence.
479
+ */
480
+ static sequence<TSequencePayload>(
481
+ payload?: TSequencePayload
482
+ ): SdDialogSequence<TSequencePayload>;
483
+
484
+ /**
485
+ * Creates a bidirectional graph of dialog nodes to dynamically progress through.
486
+ * @param nodes The list of nodes to make up the graph.
487
+ * @param builder Factory used to configure the edges between nodes.
488
+ * @param payload Data accessible to all dialog nodes within the graph.
489
+ */
490
+ static graph<TGraphPayload>(
491
+ nodes: GraphNodeList<TGraphPayload>,
492
+ builder: GraphBuilderFactory<GraphNodeList<TGraphPayload>>,
493
+ payload?: TGraphPayload
494
+ ): SdDialogGraph<TGraphPayload>;
495
+
496
+ /**
497
+ * Creates an instance of an alert dialog.
498
+ * @param options Options used to configure the alert dialog.
499
+ * @param hooks Callbacks to execute when specified life-cycle hooks are reached.
500
+ */
501
+ static alert(
502
+ options: SdAlertDialogOptions,
503
+ hooks?: DialogHooks<void>
504
+ ): SdDialogInstance<void, SdAlertDialogOptions>;
505
+
506
+ /**
507
+ * Creates an instance of a confirmation dialog.
508
+ * @param options Options used to configure the confirmation dialog.
509
+ * @param hooks Callbacks to execute when specified life-cycle hooks are reached.
510
+ */
511
+ static confirm(
512
+ options: SdConfirmDialogOptions,
513
+ hooks?: DialogHooks<boolean>
514
+ ): SdDialogInstance<boolean, SdConfirmDialogOptions>;
515
+
516
+ /**
517
+ * Creates an instance of a prompt dialog.
518
+ * @param options Options used to configure the prompt dialog.
519
+ * @param hooks Callbacks to execute when specified life-cycle hooks are reached.
520
+ */
521
+ static prompt(
522
+ options: SdPromptDialogOptions,
523
+ hooks?: DialogHooks<boolean>
524
+ ): SdDialogInstance<any, SdPromptDialogOptions>;
525
+ }
526
+
527
+ export interface DialogComponentConstructor<
528
+ ReturnType,
529
+ Payload,
530
+ ContainerScopeData
531
+ > {
532
+ new (): SdDialog<ReturnType, Payload, ContainerScopeData>;
533
+ }
534
+
535
+ export type GenericComponent<ReturnType, Payload, ContainerScopeData> =
536
+ | DialogComponentConstructor<ReturnType, Payload, ContainerScopeData>
537
+ | VueConstructor;
538
+
539
+ export type ESModuleComponent<ReturnType, Payload, ContainerScopeData> =
540
+ | GenericComponent<ReturnType, Payload, ContainerScopeData>
541
+ | { default: GenericComponent<ReturnType, Payload, ContainerScopeData> };
542
+
543
+ export type AsyncComponent<ReturnType, Payload, ContainerScopeData> = Promise<
544
+ ESModuleComponent<ReturnType, Payload, ContainerScopeData>
545
+ >;
546
+
547
+ export type DialogComponent<ReturnType, Payload, ContainerScopeData> =
548
+ | ESModuleComponent<ReturnType, Payload, ContainerScopeData>
549
+ | AsyncComponent<ReturnType, Payload, ContainerScopeData>;
550
+
551
+ // Node types
552
+ export interface DialogNodeComponentConstructor<
553
+ PrecedingResult,
554
+ ReturnType,
555
+ Payload,
556
+ ContainerScopeData
557
+ > {
558
+ new (): SdDialogNode<
559
+ PrecedingResult,
560
+ ReturnType,
561
+ Payload,
562
+ ContainerScopeData
563
+ >;
564
+ }
565
+
566
+ export type GenericDialogNodeComponent<
567
+ PrecedingResult,
568
+ ReturnType,
569
+ Payload,
570
+ ContainerScopeData
571
+ > =
572
+ | DialogNodeComponentConstructor<
573
+ PrecedingResult,
574
+ ReturnType,
575
+ Payload,
576
+ ContainerScopeData
577
+ >
578
+ | VueConstructor;
579
+
580
+ export type ESModuleDialogNodeComponent<
581
+ PrecedingResult,
582
+ ReturnType,
583
+ Payload,
584
+ ContainerScopeData
585
+ > =
586
+ | GenericDialogNodeComponent<
587
+ PrecedingResult,
588
+ ReturnType,
589
+ Payload,
590
+ ContainerScopeData
591
+ >
592
+ | {
593
+ default: GenericDialogNodeComponent<
594
+ PrecedingResult,
595
+ ReturnType,
596
+ Payload,
597
+ ContainerScopeData
598
+ >;
599
+ };
600
+
601
+ export type AsyncDialogNodeComponent<
602
+ PrecedingResult,
603
+ ReturnType,
604
+ Payload,
605
+ ContainerScopeData
606
+ > = Promise<
607
+ ESModuleDialogNodeComponent<
608
+ PrecedingResult,
609
+ ReturnType,
610
+ Payload,
611
+ ContainerScopeData
612
+ >
613
+ >;
614
+
615
+ export type DialogNodeComponent<
616
+ PrecedingResult,
617
+ ReturnType,
618
+ Payload,
619
+ ContainerScopeData
620
+ > =
621
+ | ESModuleDialogNodeComponent<
622
+ PrecedingResult,
623
+ ReturnType,
624
+ Payload,
625
+ ContainerScopeData
626
+ >
627
+ | AsyncDialogNodeComponent<
628
+ PrecedingResult,
629
+ ReturnType,
630
+ Payload,
631
+ ContainerScopeData
632
+ >;
633
+
634
+ declare const plugin: typeof SdDialog &
635
+ PluginObject<SdDialogPluginOptions> & {
636
+ /**
637
+ * Attached the dialog components to the app root. NOTE: This function is not necessary in Nuxt apps.
638
+ * @param app Root Vue app instance.
639
+ */
640
+ attach(app?: VueConstructor): void;
641
+ };
642
+
643
+ export default plugin;