sard-uniapp 1.20.1 → 1.21.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.
Files changed (81) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/README.md +3 -2
  3. package/components/config/index.d.ts +5 -0
  4. package/components/config/index.js +5 -0
  5. package/components/crop-image-agent/common.js +1 -1
  6. package/components/crop-image-agent/crop-image-agent.vue +1 -1
  7. package/components/dialog/README.md +19 -3
  8. package/components/dialog/common.d.ts +0 -1
  9. package/components/dialog/dialog.vue +1 -2
  10. package/components/dialog-agent/common.d.ts +5 -2
  11. package/components/dialog-agent/common.js +2 -2
  12. package/components/dialog-agent/dialog-agent.d.ts +7 -1
  13. package/components/dialog-agent/dialog-agent.vue +123 -9
  14. package/components/dialog-agent/index.d.ts +1 -1
  15. package/components/dialog-agent/index.js +1 -1
  16. package/components/fab/README.md +6 -0
  17. package/components/fab/fab.vue +1 -1
  18. package/components/list/README.md +19 -12
  19. package/components/list/common.d.ts +6 -1
  20. package/components/list/common.js +1 -0
  21. package/components/list/index.scss +8 -0
  22. package/components/list/list.vue +12 -2
  23. package/components/list-item/index.scss +6 -0
  24. package/components/list-item/list-item.vue +6 -3
  25. package/components/locale/lang/en-US.js +1 -1
  26. package/components/locale/lang/zh-CN.js +1 -1
  27. package/components/notify/README.md +38 -3
  28. package/components/notify/common.d.ts +5 -1
  29. package/components/notify/index.d.ts +1 -1
  30. package/components/notify/notify.d.ts +14 -7
  31. package/components/notify/notify.vue +25 -4
  32. package/components/notify-agent/common.d.ts +5 -2
  33. package/components/notify-agent/common.js +2 -2
  34. package/components/notify-agent/index.d.ts +1 -1
  35. package/components/notify-agent/index.js +1 -1
  36. package/components/notify-agent/notify-agent.d.ts +7 -1
  37. package/components/notify-agent/notify-agent.vue +90 -5
  38. package/components/popup/common.d.ts +11 -0
  39. package/components/toast/README.md +28 -6
  40. package/components/toast/common.d.ts +2 -1
  41. package/components/toast/toast.d.ts +5 -3
  42. package/components/toast/toast.vue +17 -3
  43. package/components/toast-agent/common.d.ts +5 -2
  44. package/components/toast-agent/common.js +2 -2
  45. package/components/toast-agent/index.d.ts +1 -1
  46. package/components/toast-agent/index.js +1 -1
  47. package/components/toast-agent/toast-agent.d.ts +7 -1
  48. package/components/toast-agent/toast-agent.vue +85 -5
  49. package/components/upload/README.md +31 -23
  50. package/components/upload/common.d.ts +4 -1
  51. package/components/upload/upload.vue +4 -4
  52. package/components/waterfall/README.md +162 -0
  53. package/components/waterfall/common.d.ts +32 -0
  54. package/components/waterfall/common.js +3 -0
  55. package/components/waterfall/index.d.ts +1 -0
  56. package/components/waterfall/index.js +1 -0
  57. package/components/waterfall/index.scss +7 -0
  58. package/components/waterfall/test/SimulatedImage.vue +53 -0
  59. package/components/waterfall/variables.scss +6 -0
  60. package/components/waterfall/waterfall.d.ts +23 -0
  61. package/components/waterfall/waterfall.vue +182 -0
  62. package/components/waterfall-item/common.d.ts +23 -0
  63. package/components/waterfall-item/common.js +1 -0
  64. package/components/waterfall-item/index.d.ts +1 -0
  65. package/components/waterfall-item/index.js +1 -0
  66. package/components/waterfall-item/index.scss +18 -0
  67. package/components/waterfall-item/waterfall-item.d.ts +10 -0
  68. package/components/waterfall-item/waterfall-item.vue +115 -0
  69. package/components/waterfall-load/common.d.ts +19 -0
  70. package/components/waterfall-load/common.js +1 -0
  71. package/components/waterfall-load/index.d.ts +1 -0
  72. package/components/waterfall-load/index.js +1 -0
  73. package/components/waterfall-load/index.scss +12 -0
  74. package/components/waterfall-load/waterfall-load.d.ts +14 -0
  75. package/components/waterfall-load/waterfall-load.vue +87 -0
  76. package/global.d.ts +3 -0
  77. package/index.d.ts +3 -0
  78. package/index.js +3 -0
  79. package/index.scss +1 -0
  80. package/package.json +1 -1
  81. package/utils/utils.d.ts +1 -1
@@ -71,13 +71,48 @@ import { notify } from 'sard-uniapp'
71
71
  | duration | 显隐动画时长,单位 ms | number | 300 |
72
72
  | status-bar <sup>1.12+</sup> | 是否包含状态栏,自定义导航栏时应设为 `true` | boolean | false |
73
73
 
74
+ ### NotifySlots <sup>1.20.2+</sup>
75
+
76
+ | 插槽 | 描述 | 属性 |
77
+ | ------- | -------------- | ---- |
78
+ | default | 自定义默认内容 | - |
79
+
80
+ ### NotifyEmits
81
+
82
+ | 事件 | 描述 | 类型 |
83
+ | ---------------------------------- | --------------------------- | ---------------------------------- |
84
+ | update:visible | 通知框显隐时触发 | (visible: boolean) => void |
85
+ | click <sup>1.20.2+</sup> | 点击通知框时触发 | (event: any) => void |
86
+ | visible-hook <sup>1.20.2+</sup> | 入场/退场动画状态改变时触发 | (name: TransitionHookName) => void |
87
+ | before-enter <sup>1.20.2+</sup> | 入场动画开始前触发 | () => void |
88
+ | enter <sup>1.20.2+</sup> | 入场动画开始时触发 | () => void |
89
+ | after-enter <sup>1.20.2+</sup> | 入场动画结束时触发 | () => void |
90
+ | enter-cancelled <sup>1.20.2+</sup> | 入场动画取消时触发 | () => void |
91
+ | before-leave <sup>1.20.2+</sup> | 退场动画开始前触发 | () => void |
92
+ | leave <sup>1.20.2+</sup> | 退场动画开始时触发 | () => void |
93
+ | after-leave <sup>1.20.2+</sup> | 退场动画结束时触发 | () => void |
94
+ | leave-cancelled <sup>1.20.2+</sup> | 退场动画取消时触发 | () => void |
95
+
74
96
  ### NotifyAgentProps / NotifyOptions
75
97
 
76
98
  继承 [`NotifyProps`](#NotifyProps) 并有以下额外属性。
77
99
 
78
- | 属性 | 描述 | 类型 | 默认值 |
79
- | ---- | ------------- | ------ | -------- |
80
- | id | 通知组件的 id | string | 'notify' |
100
+ | 属性 | 描述 | 类型 | 默认值 |
101
+ | ----------------------------------- | --------------------------- | ---------------------------------- | -------- |
102
+ | id | 通知组件的 id | string | 'notify' |
103
+ | onVisibleHook <sup>1.20.2+</sup> | 入场/退场动画状态改变时调用 | (name: TransitionHookName) => void |
104
+ | onBeforeEnter <sup>1.20.2+</sup> | 入场动画开始前调用 | () => void |
105
+ | onEnter <sup>1.20.2+</sup> | 入场动画开始时调用 | () => void |
106
+ | onAfterEnter <sup>1.20.2+</sup> | 入场动画结束时调用 | () => void |
107
+ | onEnterCancelled <sup>1.20.2+</sup> | 入场动画取消时调用 | () => void |
108
+ | onBeforeLeave <sup>1.20.2+</sup> | 退场动画开始前调用 | () => void |
109
+ | onLeave <sup>1.20.2+</sup> | 退场动画开始时调用 | () => void |
110
+ | onAfterLeave <sup>1.20.2+</sup> | 退场动画结束时调用 | () => void |
111
+ | onLeaveCancelled <sup>1.20.2+</sup> | 退场动画取消时调用 | () => void |
112
+
113
+ ### NotifyAgentEmits <sup>1.20.2+</sup>
114
+
115
+ 继承 [`NotifyEmits`](#NotifyEmits)。
81
116
 
82
117
  ### 命令式方法
83
118
 
@@ -1,4 +1,5 @@
1
1
  import { type StyleValue } from 'vue';
2
+ import { type TransitionHookEmits } from '../popup/common';
2
3
  export interface NotifyProps {
3
4
  rootStyle?: StyleValue;
4
5
  rootClass?: string;
@@ -18,7 +19,10 @@ export declare const defaultNotifyProps: {
18
19
  duration: number;
19
20
  timeout: number;
20
21
  };
21
- export interface NotifyEmits {
22
+ export interface NotifySlots {
23
+ default?(props: Record<string, never>): any;
24
+ }
25
+ export interface NotifyEmits extends TransitionHookEmits {
22
26
  (e: 'click', event: any): void;
23
27
  (e: 'update:visible', event: any): void;
24
28
  }
@@ -1 +1 @@
1
- export type { NotifyProps, NotifyEmits, NotifyExpose } from './common';
1
+ export type { NotifyProps, NotifySlots, NotifyEmits, NotifyExpose, } from './common';
@@ -1,17 +1,24 @@
1
- import { type NotifyProps } from './common';
2
- declare const _default: import("vue").DefineComponent<NotifyProps, {
1
+ import { type NotifyProps, type NotifySlots } from './common';
2
+ declare function __VLS_template(): Readonly<NotifySlots> & NotifySlots;
3
+ declare const __VLS_component: import("vue").DefineComponent<NotifyProps, {
3
4
  reHideLater: () => void;
4
5
  cancelHide: () => void;
5
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
6
- click: (event: any) => any;
7
- "update:visible": (event: any) => any;
6
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
7
+ [x: string]: any;
8
+ } & {
9
+ [x: string]: any;
8
10
  }, string, import("vue").PublicProps, Readonly<NotifyProps> & Readonly<{
9
- onClick?: ((event: any) => any) | undefined;
10
- "onUpdate:visible"?: ((event: any) => any) | undefined;
11
+ [x: `on${Capitalize<any>}`]: ((...args: any) => any) | undefined;
11
12
  }>, {
12
13
  timeout: number;
13
14
  type: "primary" | "success" | "warning" | "error";
14
15
  position: "top" | "bottom";
15
16
  duration: number;
16
17
  }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
18
+ declare const _default: __VLS_WithTemplateSlots<typeof __VLS_component, ReturnType<typeof __VLS_template>>;
17
19
  export default _default;
20
+ type __VLS_WithTemplateSlots<T, S> = T & {
21
+ new (): {
22
+ $slots: S;
23
+ };
24
+ };
@@ -4,10 +4,13 @@
4
4
  :overlay="false"
5
5
  :effect="effect"
6
6
  :duration="duration"
7
+ @visible-hook="onVisibleHook"
7
8
  >
8
- <view :class="notifyClass" :style="notifyStyle">
9
+ <view :class="notifyClass" :style="notifyStyle" @click="onClick">
9
10
  <sar-status-bar v-if="position === 'top' && statusBar" />
10
- <view :class="bem.e('content')">{{ message }}</view>
11
+ <view :class="bem.e('content')">
12
+ <slot>{{ message }}</slot>
13
+ </view>
11
14
  </view>
12
15
  </sar-popup>
13
16
  </template>
@@ -32,6 +35,17 @@ import SarStatusBar from "../status-bar/status-bar.vue";
32
35
  * @property {number} timeout 展示时长(ms),值为 0 时,通知不会消失,默认值:3000。
33
36
  * @property {number} duration 显隐动画时长,单位 ms,默认值:300。
34
37
  * @property {boolean} statusBar 是否包含状态栏,自定义导航栏时应设为 `true`,默认值:false。
38
+ * @event {(visible: boolean) => void} update 通知框显隐时触发
39
+ * @event {(event: any) => void} click 点击通知框时触发
40
+ * @event {(name: TransitionHookName) => void} visible-hook 入场/退场动画状态改变时触发
41
+ * @event {() => void} before-enter 入场动画开始前触发
42
+ * @event {() => void} enter 入场动画开始时触发
43
+ * @event {() => void} after-enter 入场动画结束时触发
44
+ * @event {() => void} enter-cancelled 入场动画取消时触发
45
+ * @event {() => void} before-leave 退场动画开始前触发
46
+ * @event {() => void} leave 退场动画开始时触发
47
+ * @event {() => void} after-leave 退场动画结束时触发
48
+ * @event {() => void} leave-cancelled 退场动画取消时触发
35
49
  */
36
50
  export default _defineComponent({
37
51
  components: {
@@ -58,7 +72,7 @@ export default _defineComponent({
58
72
  duration: { type: Number, required: false },
59
73
  statusBar: { type: Boolean, required: false }
60
74
  }, defaultNotifyProps),
61
- emits: ["click", "update:visible"],
75
+ emits: ["click", "update:visible", "before-enter", "enter", "after-enter", "enter-cancelled", "before-leave", "leave", "after-leave", "leave-cancelled", "visible-hook"],
62
76
  setup(__props, { expose: __expose, emit: __emit }) {
63
77
  const props = __props;
64
78
  const emit = __emit;
@@ -96,6 +110,13 @@ export default _defineComponent({
96
110
  }
97
111
  }
98
112
  );
113
+ const onVisibleHook = (name) => {
114
+ emit("visible-hook", name);
115
+ emit(name);
116
+ };
117
+ const onClick = (event) => {
118
+ emit("click", event);
119
+ };
99
120
  __expose({
100
121
  reHideLater,
101
122
  cancelHide
@@ -117,7 +138,7 @@ export default _defineComponent({
117
138
  props.rootStyle
118
139
  );
119
140
  });
120
- const __returned__ = { props, emit, bem, effect, innerVisible, hideLater, cancelHide, reHideLater, notifyClass, notifyStyle, SarPopup, SarStatusBar };
141
+ const __returned__ = { props, emit, bem, effect, innerVisible, hideLater, cancelHide, reHideLater, onVisibleHook, onClick, notifyClass, notifyStyle, SarPopup, SarStatusBar };
121
142
  return __returned__;
122
143
  }
123
144
  });
@@ -1,5 +1,6 @@
1
- import { type NotifyProps } from '../notify/common';
2
- export interface NotifyAgentProps extends NotifyProps {
1
+ import { type NotifyEmits, type NotifyProps } from '../notify/common';
2
+ import { type TransitionHookCallbacks } from '../popup/common';
3
+ export interface NotifyAgentProps extends NotifyProps, TransitionHookCallbacks {
3
4
  id?: string;
4
5
  }
5
6
  export declare const defaultNotifyAgentProps: () => {
@@ -9,6 +10,8 @@ export declare const defaultNotifyAgentProps: () => {
9
10
  duration: number;
10
11
  timeout: number;
11
12
  };
13
+ export interface NotifyAgentEmits extends NotifyEmits {
14
+ }
12
15
  export declare const imperativeName = "notify";
13
16
  export interface NotifyImperative {
14
17
  show(newProps: Record<string, any>): void;
@@ -1,6 +1,6 @@
1
- import { defaultNotifyProps } from '../notify/common';
1
+ import { defaultNotifyProps, } from '../notify/common';
2
2
  import { defaultConfig } from '../config';
3
- import { getAllImperatives, getAvailableImperative, getImperatives, } from '../../use/useImperative';
3
+ import { getAllImperatives, getAvailableImperative, getImperatives, } from '../../use';
4
4
  export const defaultNotifyAgentProps = () => ({
5
5
  ...defaultNotifyProps,
6
6
  ...defaultConfig.notifyAgent,
@@ -1 +1 @@
1
- export { type NotifyAgentProps, type NotifyOptions, notify } from './common';
1
+ export { type NotifyAgentProps, type NotifyOptions, type NotifyAgentEmits, notify, } from './common';
@@ -1 +1 @@
1
- export { notify } from './common';
1
+ export { notify, } from './common';
@@ -1,5 +1,11 @@
1
1
  import { type NotifyAgentProps } from './common';
2
- declare const _default: import("vue").DefineComponent<NotifyAgentProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<NotifyAgentProps> & Readonly<{}>, {
2
+ declare const _default: import("vue").DefineComponent<NotifyAgentProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
3
+ [x: string]: any;
4
+ } & {
5
+ [x: string]: any;
6
+ }, string, import("vue").PublicProps, Readonly<NotifyAgentProps> & Readonly<{
7
+ [x: `on${Capitalize<any>}`]: ((...args: any) => any) | undefined;
8
+ }>, {
3
9
  timeout: number;
4
10
  type: "primary" | "success" | "warning" | "error";
5
11
  id: string;
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <sar-notify
3
3
  ref="elRef"
4
- v-model:visible="innerProps.visible"
4
+ :visible="innerProps.visible"
5
5
  :root-style="innerProps.rootStyle"
6
6
  :root-class="innerProps.rootClass"
7
7
  :type="innerProps.type"
@@ -12,6 +12,17 @@
12
12
  :timeout="innerProps.timeout"
13
13
  :duration="innerProps.duration"
14
14
  :status-bar="innerProps.statusBar"
15
+ @click="onClick"
16
+ @update:visible="onUpdateVisible"
17
+ @visible-hook="onVisibleHook"
18
+ @before-enter="onBeforeEnter"
19
+ @enter="onEnter"
20
+ @after-enter="onAfterEnter"
21
+ @enter-cancelled="onEnterCancelled"
22
+ @before-leave="onBeforeLeave"
23
+ @leave="onLeave"
24
+ @after-leave="onAfterLeave"
25
+ @leave-cancelled="onLeaveCancelled"
15
26
  />
16
27
  </template>
17
28
 
@@ -23,7 +34,7 @@ import {
23
34
  imperativeName,
24
35
  defaultNotifyAgentProps
25
36
  } from "./common";
26
- import { useImperative } from "../../use/useImperative";
37
+ import { useImperative } from "../../use";
27
38
  /**
28
39
  * @property {'primary' | 'success' | 'warning' | 'error'} type 加载类型,默认值:'primary'。
29
40
  * @property {string} message 通知内容,默认值:-。
@@ -35,6 +46,26 @@ import { useImperative } from "../../use/useImperative";
35
46
  * @property {number} duration 显隐动画时长,单位 ms,默认值:300。
36
47
  * @property {boolean} statusBar 是否包含状态栏,自定义导航栏时应设为 `true`,默认值:false。
37
48
  * @property {string} id 通知组件的 id,默认值:'notify'。
49
+ * @property {(name: TransitionHookName) => void} onVisibleHook 入场/退场动画状态改变时调用,默认值:undefined。
50
+ * @property {() => void} onBeforeEnter 入场动画开始前调用,默认值:undefined。
51
+ * @property {() => void} onEnter 入场动画开始时调用,默认值:undefined。
52
+ * @property {() => void} onAfterEnter 入场动画结束时调用,默认值:undefined。
53
+ * @property {() => void} onEnterCancelled 入场动画取消时调用,默认值:undefined。
54
+ * @property {() => void} onBeforeLeave 退场动画开始前调用,默认值:undefined。
55
+ * @property {() => void} onLeave 退场动画开始时调用,默认值:undefined。
56
+ * @property {() => void} onAfterLeave 退场动画结束时调用,默认值:undefined。
57
+ * @property {() => void} onLeaveCancelled 退场动画取消时调用,默认值:undefined。
58
+ * @event {(visible: boolean) => void} update 通知框显隐时触发
59
+ * @event {(event: any) => void} click 点击通知框时触发
60
+ * @event {(name: TransitionHookName) => void} visible-hook 入场/退场动画状态改变时触发
61
+ * @event {() => void} before-enter 入场动画开始前触发
62
+ * @event {() => void} enter 入场动画开始时触发
63
+ * @event {() => void} after-enter 入场动画结束时触发
64
+ * @event {() => void} enter-cancelled 入场动画取消时触发
65
+ * @event {() => void} before-leave 退场动画开始前触发
66
+ * @event {() => void} leave 退场动画开始时触发
67
+ * @event {() => void} after-leave 退场动画结束时触发
68
+ * @event {() => void} leave-cancelled 退场动画取消时触发
38
69
  */
39
70
  export default _defineComponent({
40
71
  components: {
@@ -59,11 +90,22 @@ export default _defineComponent({
59
90
  position: { type: String, required: false },
60
91
  timeout: { type: Number, required: false },
61
92
  duration: { type: Number, required: false },
62
- statusBar: { type: Boolean, required: false }
93
+ statusBar: { type: Boolean, required: false },
94
+ onVisibleHook: { type: Function, required: false },
95
+ onBeforeEnter: { type: Function, required: false },
96
+ onEnter: { type: Function, required: false },
97
+ onAfterEnter: { type: Function, required: false },
98
+ onEnterCancelled: { type: Function, required: false },
99
+ onBeforeLeave: { type: Function, required: false },
100
+ onLeave: { type: Function, required: false },
101
+ onAfterLeave: { type: Function, required: false },
102
+ onLeaveCancelled: { type: Function, required: false }
63
103
  }, defaultNotifyAgentProps()),
64
- setup(__props, { expose: __expose }) {
104
+ emits: ["click", "update:visible", "before-enter", "enter", "after-enter", "enter-cancelled", "before-leave", "leave", "after-leave", "leave-cancelled", "visible-hook"],
105
+ setup(__props, { expose: __expose, emit: __emit }) {
65
106
  __expose();
66
107
  const props = __props;
108
+ const emit = __emit;
67
109
  const innerProps = ref({ ...props });
68
110
  const elRef = ref();
69
111
  const imperative = {
@@ -83,12 +125,55 @@ export default _defineComponent({
83
125
  elRef.value?.cancelHide();
84
126
  }
85
127
  };
128
+ const onClick = (event) => {
129
+ emit("click", event);
130
+ };
131
+ const onUpdateVisible = (visible) => {
132
+ innerProps.value.visible = visible;
133
+ emit("update:visible", visible);
134
+ };
135
+ const onVisibleHook = (name) => {
136
+ emit("visible-hook", name);
137
+ innerProps.value.onVisibleHook?.(name);
138
+ };
139
+ const onBeforeEnter = () => {
140
+ emit("before-enter");
141
+ innerProps.value.onBeforeEnter?.();
142
+ };
143
+ const onEnter = () => {
144
+ emit("enter");
145
+ innerProps.value.onEnter?.();
146
+ };
147
+ const onAfterEnter = () => {
148
+ emit("after-enter");
149
+ innerProps.value.onAfterEnter?.();
150
+ };
151
+ const onEnterCancelled = () => {
152
+ emit("enter-cancelled");
153
+ innerProps.value.onEnterCancelled?.();
154
+ };
155
+ const onBeforeLeave = () => {
156
+ emit("before-leave");
157
+ innerProps.value.onBeforeLeave?.();
158
+ };
159
+ const onLeave = () => {
160
+ emit("leave");
161
+ innerProps.value.onLeave?.();
162
+ };
163
+ const onAfterLeave = () => {
164
+ emit("after-leave");
165
+ innerProps.value.onAfterLeave?.();
166
+ };
167
+ const onLeaveCancelled = () => {
168
+ emit("leave-cancelled");
169
+ innerProps.value.onLeaveCancelled?.();
170
+ };
86
171
  useImperative(
87
172
  imperativeName,
88
173
  imperative,
89
174
  computed(() => innerProps.value.id)
90
175
  );
91
- const __returned__ = { props, innerProps, elRef, imperative, SarNotify };
176
+ const __returned__ = { props, emit, innerProps, elRef, imperative, onClick, onUpdateVisible, onVisibleHook, onBeforeEnter, onEnter, onAfterEnter, onEnterCancelled, onBeforeLeave, onLeave, onAfterLeave, onLeaveCancelled, SarNotify };
92
177
  return __returned__;
93
178
  }
94
179
  });
@@ -32,6 +32,17 @@ export interface TransitionHookEmits {
32
32
  (e: 'leave-cancelled'): void;
33
33
  (e: 'visible-hook', name: TransitionHookName): void;
34
34
  }
35
+ export interface TransitionHookCallbacks {
36
+ onVisibleHook?: (name: TransitionHookName) => void;
37
+ onBeforeEnter?: () => void;
38
+ onEnter?: () => void;
39
+ onAfterEnter?: () => void;
40
+ onEnterCancelled?: () => void;
41
+ onBeforeLeave?: () => void;
42
+ onLeave?: () => void;
43
+ onAfterLeave?: () => void;
44
+ onLeaveCancelled?: () => void;
45
+ }
35
46
  export interface PopupEmits extends TransitionHookEmits {
36
47
  (e: 'overlay-click', event: any): void;
37
48
  }
@@ -60,17 +60,39 @@ import { toast } from 'sard-uniapp'
60
60
 
61
61
  ### ToastEmits
62
62
 
63
- | 事件 | 描述 | 类型 |
64
- | -------------- | ---------------- | -------------------------- |
65
- | update:visible | 对话框显隐时触发 | (visible: boolean) => void |
63
+ | 事件 | 描述 | 类型 |
64
+ | ---------------------------------- | --------------------------- | ---------------------------------- |
65
+ | update:visible | 提示框显隐时触发 | (visible: boolean) => void |
66
+ | visible-hook <sup>1.20.2+</sup> | 入场/退场动画状态改变时触发 | (name: TransitionHookName) => void |
67
+ | before-enter <sup>1.20.2+</sup> | 入场动画开始前触发 | () => void |
68
+ | enter <sup>1.20.2+</sup> | 入场动画开始时触发 | () => void |
69
+ | after-enter <sup>1.20.2+</sup> | 入场动画结束时触发 | () => void |
70
+ | enter-cancelled <sup>1.20.2+</sup> | 入场动画取消时触发 | () => void |
71
+ | before-leave <sup>1.20.2+</sup> | 退场动画开始前触发 | () => void |
72
+ | leave <sup>1.20.2+</sup> | 退场动画开始时触发 | () => void |
73
+ | after-leave <sup>1.20.2+</sup> | 退场动画结束时触发 | () => void |
74
+ | leave-cancelled <sup>1.20.2+</sup> | 退场动画取消时触发 | () => void |
66
75
 
67
76
  ### ToastAgentProps / ToastOptions
68
77
 
69
78
  继承 [`ToastProps`](#ToastProps) 并有以下额外属性。
70
79
 
71
- | 属性 | 描述 | 类型 | 默认值 |
72
- | ---- | ------------- | ------ | ------- |
73
- | id | 提示组件的 id | string | 'toast' |
80
+ | 属性 | 描述 | 类型 | 默认值 |
81
+ | ----------------------------------- | --------------------------- | ---------------------------------- | ------- |
82
+ | id | 提示组件的 id | string | 'toast' |
83
+ | onVisibleHook <sup>1.20.2+</sup> | 入场/退场动画状态改变时调用 | (name: TransitionHookName) => void |
84
+ | onBeforeEnter <sup>1.20.2+</sup> | 入场动画开始前调用 | () => void |
85
+ | onEnter <sup>1.20.2+</sup> | 入场动画开始时调用 | () => void |
86
+ | onAfterEnter <sup>1.20.2+</sup> | 入场动画结束时调用 | () => void |
87
+ | onEnterCancelled <sup>1.20.2+</sup> | 入场动画取消时调用 | () => void |
88
+ | onBeforeLeave <sup>1.20.2+</sup> | 退场动画开始前调用 | () => void |
89
+ | onLeave <sup>1.20.2+</sup> | 退场动画开始时调用 | () => void |
90
+ | onAfterLeave <sup>1.20.2+</sup> | 退场动画结束时调用 | () => void |
91
+ | onLeaveCancelled <sup>1.20.2+</sup> | 退场动画取消时调用 | () => void |
92
+
93
+ ### ToastAgentEmits <sup>1.20.2+</sup>
94
+
95
+ 继承 [`ToastEmits`](#ToastEmits)。
74
96
 
75
97
  ### 命令式方法
76
98
 
@@ -1,4 +1,5 @@
1
1
  import { type StyleValue } from 'vue';
2
+ import { type TransitionHookEmits } from '../popup/common';
2
3
  export interface ToastProps {
3
4
  rootStyle?: StyleValue;
4
5
  rootClass?: string;
@@ -18,7 +19,7 @@ export declare const defaultToastProps: {
18
19
  timeout: number;
19
20
  duration: number;
20
21
  };
21
- export interface ToastEmits {
22
+ export interface ToastEmits extends TransitionHookEmits {
22
23
  (e: 'update:visible', visible: boolean): void;
23
24
  }
24
25
  export interface ToastExpose {
@@ -2,10 +2,12 @@ import { type ToastProps } from './common';
2
2
  declare const _default: import("vue").DefineComponent<ToastProps, {
3
3
  reHideLater: () => void;
4
4
  cancelHide: () => void;
5
- }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
6
- "update:visible": (visible: boolean) => any;
5
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
6
+ [x: string]: any;
7
+ } & {
8
+ [x: string]: any;
7
9
  }, string, import("vue").PublicProps, Readonly<ToastProps> & Readonly<{
8
- "onUpdate:visible"?: ((visible: boolean) => any) | undefined;
10
+ [x: `on${Capitalize<any>}`]: ((...args: any) => any) | undefined;
9
11
  }>, {
10
12
  timeout: number;
11
13
  type: "text" | "loading" | "success" | "fail";
@@ -6,6 +6,7 @@
6
6
  :transparent="transparent"
7
7
  :root-style="popupStyle"
8
8
  effect="fade"
9
+ @visible-hook="onVisibleHook"
9
10
  >
10
11
  <view :class="toastClass" :style="toastStyle">
11
12
  <view v-if="type !== 'text'" :class="iconClass">
@@ -44,7 +45,16 @@ export const mapIdToast = {};
44
45
  * @property {boolean} transparent 使背景透明,默认值:false。
45
46
  * @property {number} timeout 提示的延迟时间,单位 ms,默认值:1500。
46
47
  * @property {number} duration 显隐动画时长,单位 ms,默认值:300。
47
- * @event {(visible: boolean) => void} update 对话框显隐时触发
48
+ * @event {(visible: boolean) => void} update 提示框显隐时触发
49
+ * @event {(name: TransitionHookName) => void} visible-hook 入场/退场动画状态改变时触发
50
+ * @event {() => void} before-enter 入场动画开始前触发
51
+ * @event {() => void} enter 入场动画开始时触发
52
+ * @event {() => void} after-enter 入场动画结束时触发
53
+ * @event {() => void} enter-cancelled 入场动画取消时触发
54
+ * @event {() => void} before-leave 退场动画开始前触发
55
+ * @event {() => void} leave 退场动画开始时触发
56
+ * @event {() => void} after-leave 退场动画结束时触发
57
+ * @event {() => void} leave-cancelled 退场动画取消时触发
48
58
  */
49
59
  export default _defineComponent({
50
60
  components: {
@@ -66,7 +76,7 @@ export default _defineComponent({
66
76
  timeout: { type: Number, required: false },
67
77
  duration: { type: Number, required: false }
68
78
  }, defaultToastProps),
69
- emits: ["update:visible"],
79
+ emits: ["update:visible", "before-enter", "enter", "after-enter", "enter-cancelled", "before-leave", "leave", "after-leave", "leave-cancelled", "visible-hook"],
70
80
  setup(__props, { expose: __expose, emit: __emit }) {
71
81
  const props = __props;
72
82
  const emit = __emit;
@@ -98,6 +108,10 @@ export default _defineComponent({
98
108
  }
99
109
  }
100
110
  );
111
+ const onVisibleHook = (name) => {
112
+ emit("visible-hook", name);
113
+ emit(name);
114
+ };
101
115
  __expose({
102
116
  reHideLater,
103
117
  cancelHide
@@ -138,7 +152,7 @@ export default _defineComponent({
138
152
  bem.em("icon", "loading", props.type === "loading")
139
153
  );
140
154
  });
141
- const __returned__ = { mapIdToast, props, emit, bem, innerVisible, hideLater, cancelHide, reHideLater, toastClass, toastStyle, popupStyle, iconClass, SarPopup, SarLoading, SarIcon };
155
+ const __returned__ = { mapIdToast, props, emit, bem, innerVisible, hideLater, cancelHide, reHideLater, onVisibleHook, toastClass, toastStyle, popupStyle, iconClass, SarPopup, SarLoading, SarIcon };
142
156
  return __returned__;
143
157
  }
144
158
  });
@@ -1,5 +1,6 @@
1
- import { type ToastProps } from '../toast/common';
2
- export interface ToastAgentProps extends ToastProps {
1
+ import { type TransitionHookCallbacks } from '../popup/common';
2
+ import { type ToastEmits, type ToastProps } from '../toast/common';
3
+ export interface ToastAgentProps extends ToastProps, TransitionHookCallbacks {
3
4
  id?: string;
4
5
  }
5
6
  export declare const defaultToastAgentProps: () => {
@@ -10,6 +11,8 @@ export declare const defaultToastAgentProps: () => {
10
11
  timeout: number;
11
12
  duration: number;
12
13
  };
14
+ export interface ToastAgentEmits extends ToastEmits {
15
+ }
13
16
  export declare const imperativeName = "toast";
14
17
  export interface ToastImperative {
15
18
  show(newProps: Record<string, any>): void;
@@ -1,6 +1,6 @@
1
- import { getAllImperatives, getAvailableImperative, getImperatives, } from '../../use/useImperative';
1
+ import { getAllImperatives, getAvailableImperative, getImperatives, } from '../../use';
2
2
  import { defaultConfig } from '../config';
3
- import { defaultToastProps } from '../toast/common';
3
+ import { defaultToastProps, } from '../toast/common';
4
4
  export const defaultToastAgentProps = () => ({
5
5
  ...defaultToastProps,
6
6
  ...defaultConfig.toastAgent,
@@ -1 +1 @@
1
- export { type ToastAgentProps, type ToastOptions, toast } from './common';
1
+ export { type ToastAgentProps, type ToastOptions, type ToastAgentEmits, toast, } from './common';
@@ -1 +1 @@
1
- export { toast } from './common';
1
+ export { toast, } from './common';
@@ -1,5 +1,11 @@
1
1
  import { type ToastAgentProps } from './common';
2
- declare const _default: import("vue").DefineComponent<ToastAgentProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<ToastAgentProps> & Readonly<{}>, {
2
+ declare const _default: import("vue").DefineComponent<ToastAgentProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
3
+ [x: string]: any;
4
+ } & {
5
+ [x: string]: any;
6
+ }, string, import("vue").PublicProps, Readonly<ToastAgentProps> & Readonly<{
7
+ [x: `on${Capitalize<any>}`]: ((...args: any) => any) | undefined;
8
+ }>, {
3
9
  timeout: number;
4
10
  type: "text" | "loading" | "success" | "fail";
5
11
  id: string;