vue-popup-plus-plugin-preset 1.4.0 → 1.5.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.
@@ -1,6 +1,8 @@
1
1
  import { Component } from 'vue';
2
+ import { ExtractComponentPropTypes } from 'vue-popup-plus';
3
+ import { Placement } from 'vue-popup-plus';
2
4
  import { PopupPlugin } from 'vue-popup-plus';
3
- import { version } from '../package.json';
5
+ import { Version } from 'vue-popup-plus';
4
6
 
5
7
  export declare const album: PopupPlugin<GlobalOption>;
6
8
 
@@ -154,7 +156,7 @@ declare type ConfirmOption = {
154
156
 
155
157
  export declare const dialog: PopupPlugin<GlobalOption>;
156
158
 
157
- declare type DialogOption = {
159
+ declare type DialogOption<TComponent extends Component = Component> = {
158
160
  /**
159
161
  * 对话框标题
160
162
  *
@@ -164,11 +166,11 @@ declare type DialogOption = {
164
166
  /**
165
167
  * 对话框内容组件
166
168
  */
167
- component: Component;
169
+ component: TComponent;
168
170
  /**
169
171
  * 对话框内容组件props
170
172
  */
171
- componentProps?: Record<string, any>;
173
+ componentProps?: ExtractComponentPropTypes<TComponent>;
172
174
  /**
173
175
  * 对话框渲染完成时调用的回调函数
174
176
  */
@@ -227,6 +229,13 @@ declare type DialogOption = {
227
229
  * - 支持 `string` 或 `number` 类型
228
230
  */
229
231
  minHeight?: string | number;
232
+ /**
233
+ * 对话框位置
234
+ *
235
+ * - 默认值为 `center`
236
+ * @since 1.5.0
237
+ */
238
+ placement?: Placement;
230
239
  /**
231
240
  * 是否显示对话框遮罩层
232
241
  *
@@ -262,10 +271,10 @@ declare type DialogOption = {
262
271
  declare type GlobalOption = {
263
272
  /**
264
273
  * 插件弹出层皮肤
265
- * - 默认为 `classic` 经典皮肤
274
+ * - 默认为 `modern` 现代皮肤
266
275
  * - 可选值包括:
276
+ * - `modern` 现代皮肤
267
277
  * - `classic` 经典皮肤
268
- * - `modern` 现代皮肤(实验性)
269
278
  */
270
279
  skin?: Skin;
271
280
  };
@@ -341,29 +350,58 @@ export declare interface IDialog {
341
350
  /**
342
351
  * 显示对话框
343
352
  *
344
- * - 对话框内部组件可通过调用 `this.$emit('close', payload)`
353
+ * - 对话框内部组件可通过调用 `dialog.close(payload)`
345
354
  * 关闭对话框,payload 为关闭时传递的参数
346
355
  * - 如需获取对话框关闭时传递的参数,可在调用 `dialog` 方法时使用 `await` 关键字等待
347
356
  * Promise resolve 后获取
348
357
  * - 对话框关闭时,无论是否传递了参数,Promise 都将 resolve,因此需要在调用时判断是否有返回参数
349
358
  */
350
- <T extends any = any>(options: DialogOption): Promise<T | void>;
359
+ <T extends any = any, TComponent extends Component = Component>(options: DialogOption<TComponent>): Promise<T | void>;
360
+ /**
361
+ * 关闭对话框
362
+ *
363
+ * - 将会关闭最后一个创建的对话框
364
+ * - 如果当前没有对话框正在显示,则不会有任何效果,调试模式下会抛出警告
365
+ * - 可传递任意类型的参数,该参数将会被传递给打开对话框时的 Promise resolve 函数
366
+ * @param payload 关闭时传递的参数
367
+ */
368
+ close<T extends any = any>(payload?: T): Promise<void>;
351
369
  }
352
370
 
353
371
  export declare interface ILoading {
354
372
  /**
355
373
  * 显示加载遮罩
356
374
  *
357
- * - 返回关闭加载遮罩的方法,调用后关闭加载遮罩
375
+ * - 全局只会显示一个加载遮罩,每次调用时会先进行判断是否有已存在的加载遮罩
376
+ * 如果有,则会先关闭已存在的加载遮罩,再显示新的加载遮罩
377
+ *
378
+ * - 使用示例:
379
+ *
380
+ * ```ts
381
+ * // 显示加载遮罩
382
+ * popup.loading()
383
+ * // 关闭加载遮罩
384
+ * popup.loading.close()
385
+ *
386
+ * // 如果需要等待关闭动画结束,可通过 await 调用
387
+ * await popup.loading.close()
388
+ * ```
389
+ */
390
+ (option?: LoadingOption): void;
391
+ /**
392
+ * 关闭加载遮罩
393
+ *
358
394
  * - 使用示例:
359
395
  *
360
396
  * ```ts
361
- * const stopLoading = popup.loading()
362
397
  * // 关闭加载遮罩
363
- * stopLoading()
398
+ * popup.loading.close()
399
+ *
400
+ * // 如果需要等待关闭动画结束,可通过 await 调用
401
+ * await popup.loading.close()
364
402
  * ```
365
403
  */
366
- (option?: LoadingOption): () => void;
404
+ close(): Promise<void>;
367
405
  }
368
406
 
369
407
  export declare interface IPrompt {
@@ -395,8 +433,10 @@ export declare interface IToast {
395
433
  * 显示消息
396
434
  *
397
435
  * - 第一个参数为消息内容
398
- * - 第二个参数为消息选项,可自定义消息显示时间,默认值为 2000 毫秒
399
- * - 如果需要等待消息消失后继续执行后续代码,需要通过 `await` 调用, 等待执行结束后继续执行后续代码
436
+ * - 第二个参数为消息选项,可自定义消息显示时间,默认值为 `2000` 毫秒
437
+ * ,如果设置为 `0` ,则消息不会自动关闭
438
+ * - 如果需要等待消息消失后继续执行后续代码,需要通过 `await` 调用,
439
+ * 等待执行结束后继续执行后续代码
400
440
  * - 使用示例:
401
441
  *
402
442
  * ```ts
@@ -408,6 +448,22 @@ export declare interface IToast {
408
448
  * ```
409
449
  */
410
450
  (content: string, options?: ToastOption): Promise<void>;
451
+ /**
452
+ * 显示成功消息
453
+ */
454
+ success(content: string, options?: ToastOptionWithoutTheme): Promise<void>;
455
+ /**
456
+ * 显示信息消息
457
+ */
458
+ info(content: string, options?: ToastOptionWithoutTheme): Promise<void>;
459
+ /**
460
+ * 显示警告消息
461
+ */
462
+ warning(content: string, options?: ToastOptionWithoutTheme): Promise<void>;
463
+ /**
464
+ * 显示错误消息
465
+ */
466
+ danger(content: string, options?: ToastOptionWithoutTheme): Promise<void>;
411
467
  }
412
468
 
413
469
  export declare const loading: PopupPlugin<GlobalOption>;
@@ -424,6 +480,7 @@ declare type LoadingOption = {
424
480
  * 加载遮罩标题文本
425
481
  *
426
482
  * - 默认值:''
483
+ * @since 1.3.3
427
484
  */
428
485
  title?: string;
429
486
  /**
@@ -432,15 +489,23 @@ declare type LoadingOption = {
432
489
  * - 默认值:60
433
490
  */
434
491
  iconSize?: number;
492
+ /**
493
+ * 是否显示遮罩层
494
+ *
495
+ * - 默认值:`true`
496
+ * @since 1.5.0
497
+ */
498
+ mask?: boolean;
435
499
  /**
436
500
  * 遮罩层是否模糊
437
501
  *
438
502
  * - 默认值:`true`
503
+ * @since 1.3.3
439
504
  */
440
505
  maskBlur?: boolean;
441
506
  };
442
507
 
443
- export declare const presetPlugin: PopupPlugin<GlobalOption>;
508
+ export declare const plugin: PopupPlugin<GlobalOption>;
444
509
 
445
510
  declare const prompt_2: PopupPlugin<GlobalOption>;
446
511
  export { prompt_2 as prompt }
@@ -521,7 +586,7 @@ declare type PromptType = 'input' | 'textarea';
521
586
 
522
587
  declare type Skin = 'classic' | 'modern';
523
588
 
524
- declare type Theme = 'default' | 'primary' | 'info' | 'success' | 'warning' | 'danger';
589
+ declare type Theme = 'primary' | 'info' | 'success' | 'warning' | 'danger';
525
590
 
526
591
  export declare const toast: PopupPlugin<GlobalOption>;
527
592
 
@@ -539,9 +604,34 @@ declare type ToastOption = {
539
604
  * - 默认值: 2000 毫秒
540
605
  */
541
606
  duration?: number;
607
+ /**
608
+ * 消息位置
609
+ *
610
+ * - 默认值为 `center`
611
+ * @since 1.5.0
612
+ */
613
+ placement?: Placement;
614
+ /**
615
+ * 是否显示关闭按钮
616
+ *
617
+ * - 默认值: `false`
618
+ * - 当持续时间为 `0` 时,关闭按钮将会强制显示
619
+ * @since 1.5.0
620
+ */
621
+ showClose?: boolean;
622
+ /**
623
+ * 是否开启鼠标悬停持续显示
624
+ *
625
+ * - 默认值: `true`
626
+ * - 当持续时间为 `0` 时,该参数无效
627
+ * @since 1.5.0
628
+ */
629
+ hoverWait?: boolean;
542
630
  };
543
631
 
544
- export { version }
632
+ declare type ToastOptionWithoutTheme = Omit<ToastOption, 'theme'>;
633
+
634
+ export declare const version: Version;
545
635
 
546
636
  export { }
547
637
 
@@ -555,41 +645,41 @@ declare module 'vue-popup-plus' {
555
645
 
556
646
  declare module 'vue-popup-plus' {
557
647
  interface PopupCustomProperties {
558
- dialog: IDialog;
648
+ alert: IAlert;
559
649
  }
560
650
  }
561
651
 
562
652
 
563
653
  declare module 'vue-popup-plus' {
564
654
  interface PopupCustomProperties {
565
- alert: IAlert;
655
+ confirm: IConfirm;
566
656
  }
567
657
  }
568
658
 
569
659
 
570
660
  declare module 'vue-popup-plus' {
571
661
  interface PopupCustomProperties {
572
- toast: IToast;
662
+ dialog: IDialog;
573
663
  }
574
664
  }
575
665
 
576
666
 
577
667
  declare module 'vue-popup-plus' {
578
668
  interface PopupCustomProperties {
579
- loading: ILoading;
669
+ prompt: IPrompt;
580
670
  }
581
671
  }
582
672
 
583
673
 
584
674
  declare module 'vue-popup-plus' {
585
675
  interface PopupCustomProperties {
586
- confirm: IConfirm;
676
+ loading: ILoading;
587
677
  }
588
678
  }
589
679
 
590
680
 
591
681
  declare module 'vue-popup-plus' {
592
682
  interface PopupCustomProperties {
593
- prompt: IPrompt;
683
+ toast: IToast;
594
684
  }
595
685
  }