hy-app 0.4.13 → 0.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.
Files changed (211) hide show
  1. package/components/hy-action-sheet/hy-action-sheet.vue +155 -238
  2. package/components/hy-action-sheet/props.ts +68 -15
  3. package/components/hy-action-sheet/typing.d.ts +115 -115
  4. package/components/hy-address-picker/hy-address-picker.vue +185 -289
  5. package/components/hy-address-picker/props.ts +97 -21
  6. package/components/hy-address-picker/typing.d.ts +90 -89
  7. package/components/hy-avatar/hy-avatar.vue +121 -204
  8. package/components/hy-avatar/props.ts +76 -18
  9. package/components/hy-avatar/typing.d.ts +63 -62
  10. package/components/hy-back-top/hy-back-top.vue +65 -120
  11. package/components/hy-back-top/props.ts +57 -16
  12. package/components/hy-back-top/typing.d.ts +43 -42
  13. package/components/hy-badge/hy-badge.vue +66 -138
  14. package/components/hy-badge/props.ts +73 -17
  15. package/components/hy-badge/typing.d.ts +59 -58
  16. package/components/hy-button/hy-button.vue +226 -375
  17. package/components/hy-button/props.ts +129 -158
  18. package/components/hy-calendar/header.vue +48 -64
  19. package/components/hy-calendar/hy-calendar.vue +274 -438
  20. package/components/hy-calendar/month.vue +508 -516
  21. package/components/hy-calendar/props.ts +157 -35
  22. package/components/hy-calendar/typing.d.ts +129 -128
  23. package/components/hy-card/hy-card.vue +118 -240
  24. package/components/hy-card/index.scss +1 -2
  25. package/components/hy-card/props.ts +122 -27
  26. package/components/hy-card/typing.d.ts +119 -118
  27. package/components/hy-cell/hy-cell.vue +176 -258
  28. package/components/hy-cell/props.ts +71 -17
  29. package/components/hy-cell/typing.d.ts +87 -86
  30. package/components/hy-check-button/hy-check-button.vue +69 -139
  31. package/components/hy-check-button/props.ts +72 -18
  32. package/components/hy-check-button/typing.d.ts +74 -73
  33. package/components/hy-checkbox/hy-checkbox.vue +170 -263
  34. package/components/hy-checkbox/props.ts +94 -24
  35. package/components/hy-checkbox/typing.d.ts +72 -72
  36. package/components/hy-checkbox-group/hy-checkbox-group.vue +25 -100
  37. package/components/hy-checkbox-group/props.ts +80 -0
  38. package/components/hy-checkbox-group/typing.d.ts +65 -65
  39. package/components/hy-checkbox-item/hy-checkbox-item.vue +140 -177
  40. package/components/hy-checkbox-item/props.ts +24 -0
  41. package/components/hy-checkbox-item/typing.d.ts +4 -3
  42. package/components/hy-code-input/hy-code-input.vue +179 -262
  43. package/components/hy-code-input/props.ts +84 -18
  44. package/components/hy-code-input/typing.d.ts +71 -71
  45. package/components/hy-config-provider/hy-config-provider.vue +28 -50
  46. package/components/hy-config-provider/props.ts +26 -11
  47. package/components/hy-config-provider/typing.d.ts +20 -20
  48. package/components/hy-count-down/hy-count-down.vue +103 -131
  49. package/components/hy-count-down/props.ts +30 -8
  50. package/components/hy-count-down/typing.d.ts +25 -25
  51. package/components/hy-count-to/hy-count-to.vue +148 -213
  52. package/components/hy-count-to/props.ts +60 -15
  53. package/components/hy-count-to/typing.d.ts +46 -46
  54. package/components/hy-coupon/README.md +133 -0
  55. package/components/hy-coupon/hy-coupon.vue +180 -0
  56. package/components/hy-coupon/index.scss +553 -0
  57. package/components/hy-coupon/props.ts +129 -0
  58. package/components/hy-coupon/typing.d.ts +146 -0
  59. package/components/hy-datetime-picker/hy-datetime-picker.vue +415 -580
  60. package/components/hy-datetime-picker/props.ts +142 -32
  61. package/components/hy-datetime-picker/typing.d.ts +132 -132
  62. package/components/hy-divider/hy-divider.vue +90 -169
  63. package/components/hy-divider/props.ts +78 -19
  64. package/components/hy-divider/typing.d.ts +60 -60
  65. package/components/hy-dropdown/hy-dropdown.vue +37 -71
  66. package/components/hy-dropdown/props.ts +38 -15
  67. package/components/hy-dropdown/typing.d.ts +44 -44
  68. package/components/hy-dropdown-item/hy-dropdown-item.vue +141 -173
  69. package/components/hy-dropdown-item/props.ts +19 -8
  70. package/components/hy-empty/hy-empty.vue +75 -129
  71. package/components/hy-empty/props.ts +57 -15
  72. package/components/hy-empty/typing.d.ts +84 -84
  73. package/components/hy-flex/hy-flex.vue +33 -88
  74. package/components/hy-flex/props.ts +58 -0
  75. package/components/hy-flex/typing.d.ts +14 -16
  76. package/components/hy-float-button/hy-float-button.vue +289 -406
  77. package/components/hy-float-button/props.ts +109 -25
  78. package/components/hy-folding-panel/hy-folding-panel.vue +86 -374
  79. package/components/hy-folding-panel/props.ts +40 -15
  80. package/components/hy-folding-panel/typing.d.ts +52 -63
  81. package/components/hy-folding-panel-item/hy-folding-panel-item.vue +186 -228
  82. package/components/hy-folding-panel-item/index.scss +87 -0
  83. package/components/hy-folding-panel-item/props.ts +81 -0
  84. package/components/hy-folding-panel-item/typing.d.ts +23 -0
  85. package/components/hy-form/hy-form.vue +172 -212
  86. package/components/hy-form/props.ts +37 -0
  87. package/components/hy-form/typing.d.ts +68 -61
  88. package/components/hy-form-group/typing.d.ts +74 -74
  89. package/components/hy-form-item/hy-form-item.vue +100 -129
  90. package/components/hy-form-item/props.ts +25 -0
  91. package/components/hy-form-item/typing.d.ts +40 -37
  92. package/components/hy-grid/hy-grid.vue +76 -132
  93. package/components/hy-grid/props.ts +58 -16
  94. package/components/hy-grid/typing.d.ts +66 -66
  95. package/components/hy-icon/hy-icon.vue +84 -161
  96. package/components/hy-icon/props.ts +76 -22
  97. package/components/hy-icon/typing.d.ts +83 -82
  98. package/components/hy-image/hy-image.vue +142 -272
  99. package/components/hy-image/props.ts +105 -23
  100. package/components/hy-image/typing.d.ts +84 -87
  101. package/components/hy-input/hy-input.vue +230 -421
  102. package/components/hy-input/props.ts +183 -35
  103. package/components/hy-input/typing.d.ts +169 -169
  104. package/components/hy-line/hy-line.vue +34 -72
  105. package/components/hy-line/props.ts +41 -10
  106. package/components/hy-line/typing.d.ts +29 -29
  107. package/components/hy-line-progress/hy-line-progress.vue +66 -101
  108. package/components/hy-line-progress/props.ts +31 -10
  109. package/components/hy-line-progress/typing.d.ts +29 -29
  110. package/components/hy-list/hy-list.vue +151 -220
  111. package/components/hy-list/props.ts +67 -16
  112. package/components/hy-list/typing.d.ts +52 -52
  113. package/components/hy-loading/hy-loading.vue +63 -119
  114. package/components/hy-loading/props.ts +63 -15
  115. package/components/hy-loading/typing.d.ts +49 -49
  116. package/components/hy-menu/hy-menu.vue +124 -166
  117. package/components/hy-menu/props.ts +42 -10
  118. package/components/hy-menu/typing.d.ts +60 -60
  119. package/components/hy-modal/hy-modal.vue +127 -218
  120. package/components/hy-modal/props.ts +89 -24
  121. package/components/hy-navbar/hy-navbar.vue +104 -177
  122. package/components/hy-navbar/props.ts +76 -22
  123. package/components/hy-navbar/typing.d.ts +81 -81
  124. package/components/hy-notice-bar/hy-notice-bar.vue +67 -144
  125. package/components/hy-notice-bar/props.ts +80 -19
  126. package/components/hy-notice-bar/typing.d.ts +62 -62
  127. package/components/hy-notify/hy-notify.vue +128 -177
  128. package/components/hy-notify/props.ts +49 -12
  129. package/components/hy-notify/typing.d.ts +45 -41
  130. package/components/hy-number-step/hy-number-step.vue +281 -394
  131. package/components/hy-number-step/props.ts +110 -27
  132. package/components/hy-number-step/typing.d.ts +120 -120
  133. package/components/hy-overlay/hy-overlay.vue +39 -66
  134. package/components/hy-overlay/props.ts +31 -8
  135. package/components/hy-pagination/hy-pagination.vue +100 -155
  136. package/components/hy-pagination/props.ts +53 -13
  137. package/components/hy-picker/hy-picker.vue +309 -430
  138. package/components/hy-picker/index.scss +8 -12
  139. package/components/hy-picker/props.ts +110 -26
  140. package/components/hy-popover/hy-popover.vue +190 -252
  141. package/components/hy-popover/props.ts +48 -10
  142. package/components/hy-popup/hy-popup.vue +162 -248
  143. package/components/hy-popup/props.ts +82 -18
  144. package/components/hy-price/hy-price.vue +45 -104
  145. package/components/hy-price/props.ts +52 -12
  146. package/components/hy-price/typing.d.ts +41 -36
  147. package/components/hy-qrcode/hy-qrcode.vue +115 -185
  148. package/components/hy-qrcode/props.ts +68 -18
  149. package/components/hy-qrcode/typing.d.ts +67 -66
  150. package/components/hy-radio/hy-radio.vue +161 -259
  151. package/components/hy-radio/props.ts +95 -25
  152. package/components/hy-radio/typing.d.ts +85 -84
  153. package/components/hy-rate/hy-rate.vue +185 -270
  154. package/components/hy-rate/props.ts +76 -18
  155. package/components/hy-rate/typing.d.ts +61 -60
  156. package/components/hy-read-more/hy-read-more.vue +93 -136
  157. package/components/hy-read-more/props.ts +43 -13
  158. package/components/hy-scroll-list/hy-scroll-list.vue +81 -102
  159. package/components/hy-scroll-list/props.ts +22 -11
  160. package/components/hy-search/hy-search.vue +155 -284
  161. package/components/hy-search/props.ts +130 -25
  162. package/components/hy-signature/hy-signature.vue +491 -635
  163. package/components/hy-signature/props.ts +115 -26
  164. package/components/hy-signature/typing.d.ts +138 -138
  165. package/components/hy-slider/hy-slider.vue +388 -477
  166. package/components/hy-slider/props.ts +75 -19
  167. package/components/hy-steps/hy-steps.vue +212 -279
  168. package/components/hy-steps/props.ts +47 -13
  169. package/components/hy-submit-bar/hy-submit-bar.vue +137 -222
  170. package/components/hy-submit-bar/props.ts +89 -20
  171. package/components/hy-submit-bar/typing.d.ts +86 -85
  172. package/components/hy-subsection/hy-subsection.vue +132 -185
  173. package/components/hy-subsection/props.ts +50 -17
  174. package/components/hy-subsection/typing.d.ts +52 -52
  175. package/components/hy-swipe-action/hy-swipe-action.vue +228 -283
  176. package/components/hy-swipe-action/props.ts +43 -18
  177. package/components/hy-swipe-action/typing.d.ts +46 -46
  178. package/components/hy-swiper/hy-swiper.vue +159 -286
  179. package/components/hy-swiper/props.ts +126 -28
  180. package/components/hy-swiper/typing.d.ts +115 -115
  181. package/components/hy-switch/hy-switch.vue +112 -176
  182. package/components/hy-switch/props.ts +60 -15
  183. package/components/hy-switch/typing.d.ts +63 -63
  184. package/components/hy-tabBar/hy-tabBar.vue +64 -60
  185. package/components/hy-tabs/hy-tabs.vue +277 -380
  186. package/components/hy-tabs/props.ts +75 -18
  187. package/components/hy-tag/hy-tag.vue +111 -204
  188. package/components/hy-tag/props.ts +81 -19
  189. package/components/hy-text/hy-text.vue +200 -322
  190. package/components/hy-text/props.ts +107 -28
  191. package/components/hy-textarea/hy-textarea.vue +147 -256
  192. package/components/hy-textarea/props.ts +112 -25
  193. package/components/hy-textarea/typing.d.ts +42 -42
  194. package/components/hy-toast/hy-toast.vue +135 -143
  195. package/components/hy-tooltip/hy-tooltip.vue +220 -306
  196. package/components/hy-tooltip/props.ts +79 -15
  197. package/components/hy-transition/hy-transition.vue +111 -138
  198. package/components/hy-transition/props.ts +30 -8
  199. package/components/hy-upload/hy-upload.vue +320 -469
  200. package/components/hy-upload/props.ts +130 -27
  201. package/components/hy-warn/hy-warn.vue +80 -129
  202. package/components/hy-warn/props.ts +47 -12
  203. package/components/hy-waterfall/hy-waterfall.vue +139 -163
  204. package/components/hy-waterfall/props.ts +19 -7
  205. package/components/hy-watermark/hy-watermark.vue +762 -870
  206. package/components/hy-watermark/props.ts +103 -22
  207. package/global.d.ts +2 -0
  208. package/libs/css/theme.scss +3 -3
  209. package/package.json +2 -2
  210. package/web-types.json +1 -1
  211. package/components/hy-folding-panel/index.scss +0 -9
@@ -1,17 +1,81 @@
1
- import type IProps from "./typing";
1
+ import type { CSSProperties, PropType } from 'vue'
2
+ import type { IPlacementVo } from '@/package/components/hy-popover/typing'
2
3
 
3
- const defaultProps: IProps = {
4
- text: "",
5
- copyText: "",
6
- size: 14,
7
- color: "",
8
- bgColor: "transparent",
9
- direction: "top",
10
- zIndex: 10071,
11
- showCopy: true,
12
- buttons: [],
13
- overlay: true,
14
- showToast: true,
15
- };
4
+ const tooltipProps = {
5
+ /** 需要显示的提示文字 */
6
+ text: {
7
+ type: String,
8
+ default: ''
9
+ },
10
+ /** 点击复制按钮时,复制的文本,为空则使用text值 */
11
+ copyText: {
12
+ type: String,
13
+ default: ''
14
+ },
15
+ /**
16
+ * 触发模式
17
+ * @values longpress,click
18
+ * */
19
+ triggerMode: {
20
+ type: String as PropType<'longpress' | 'click'>,
21
+ default: 'longpress'
22
+ },
23
+ /**
24
+ * 指定 popover 的放置位置
25
+ * @values top,top-start,top-end,bottom,bottom-start,bottom-end,left,left-start,left-end,right,right-start,right-end
26
+ * */
27
+ placement: {
28
+ type: String as PropType<IPlacementVo>,
29
+ default: 'bottom'
30
+ },
31
+ /** 文本大小 */
32
+ size: {
33
+ type: [String, Number],
34
+ default: 14
35
+ },
36
+ /** 字体颜色 */
37
+ color: String,
38
+ /** 字体粗细 */
39
+ bold: {
40
+ type: Boolean,
41
+ default: false
42
+ },
43
+ /** 弹出提示框时,文本的背景色 */
44
+ bgColor: {
45
+ type: String,
46
+ default: 'transparent'
47
+ },
48
+ /** 弹出提示的z-index,nvue无效 */
49
+ zIndex: {
50
+ type: Number,
51
+ default: 10071
52
+ },
53
+ /** 是否显示复制按钮 */
54
+ showCopy: {
55
+ type: Boolean,
56
+ default: true
57
+ },
58
+ /** 扩展的按钮组 */
59
+ buttons: {
60
+ type: Array,
61
+ default() {
62
+ return []
63
+ }
64
+ },
65
+ /** 是否显示透明遮罩以防止触摸穿透 */
66
+ overlay: {
67
+ type: Boolean,
68
+ default: true
69
+ },
70
+ /** 是否显示提示 */
71
+ showToast: {
72
+ type: Boolean,
73
+ default: true
74
+ },
75
+ /** 定义需要用到的外部样式 */
76
+ customStyle: Object as PropType<CSSProperties>,
77
+ /** 自定义外部类名 */
78
+ customClass: String
79
+ }
16
80
 
17
- export default defaultProps;
81
+ export default tooltipProps
@@ -1,184 +1,157 @@
1
1
  <template>
2
- <view
3
- v-if="hasInit"
4
- class="hy-transition"
5
- ref="u-transition"
6
- @tap.stop="clickHandler"
7
- :class="[classes, customClass]"
8
- :style="[mergeStyle]"
9
- >
10
- <slot />
11
- </view>
2
+ <view
3
+ v-if="hasInit"
4
+ class="hy-transition"
5
+ ref="u-transition"
6
+ @tap.stop="clickHandler"
7
+ :class="[classes, customClass]"
8
+ :style="[mergeStyle]"
9
+ >
10
+ <slot />
11
+ </view>
12
12
  </template>
13
13
 
14
14
  <script lang="ts">
15
15
  export default {
16
- name: "hy-transition",
17
- options: {
18
- addGlobalClass: true,
19
- virtualHost: true,
20
- styleIsolation: "shared",
21
- },
22
- };
16
+ name: 'hy-transition',
17
+ options: {
18
+ addGlobalClass: true,
19
+ virtualHost: true,
20
+ styleIsolation: 'shared'
21
+ }
22
+ }
23
23
  </script>
24
24
 
25
25
  <script setup lang="ts">
26
- import { computed, ref, watch, nextTick } from "vue";
27
- import type { CSSProperties, PropType } from "vue";
28
- import { sleep } from "../../libs";
29
- import type { ITransitionEmits } from "./typing";
26
+ import { computed, ref, watch, nextTick } from 'vue'
27
+ import type { CSSProperties } from 'vue'
28
+ import { sleep } from '../../libs'
29
+ import type { ITransitionEmits } from './typing'
30
+ import transitionProps from './props'
30
31
 
31
32
  /**
32
33
  * 该组件用于组件的动画过渡效果。
33
34
  * @displayName hy-transition
34
35
  */
35
- defineOptions({});
36
+ defineOptions({})
36
37
 
37
- // const props = withDefaults(defineProps<IProps>(), defaultProps)
38
- const props = defineProps({
39
- /** 是否展示组件 */
40
- show: {
41
- type: Boolean,
42
- default: false,
43
- },
44
- /** 使用的动画模式 */
45
- mode: {
46
- type: String,
47
- default: "fade",
48
- },
49
- /** 动画的执行时间,单位ms */
50
- duration: {
51
- type: Number,
52
- default: 300,
53
- },
54
- /** 使用的动画过渡函数 */
55
- timingFunction: {
56
- type: String,
57
- default: "ease-out",
58
- },
59
- /** 定义需要用到的外部样式 */
60
- customStyle: {
61
- type: Object as PropType<CSSProperties>,
62
- },
63
- /** 自定义外部类名 */
64
- customClass: String,
65
- });
66
- const emit = defineEmits<ITransitionEmits>();
38
+ const props = defineProps(transitionProps)
39
+ const emit = defineEmits<ITransitionEmits>()
67
40
 
68
- const hasInit = ref<boolean>(false); // 是否显示/隐藏组件
69
- const viewStyle = ref<CSSProperties>({}); // 组件内部的样式
70
- const status = ref<string>(""); // 记录组件动画的状态
71
- const transitionEnded = ref<boolean>(false); // 组件是否结束的标记
72
- const display = ref<boolean>(false); // 组件是否展示
73
- const classes = ref<string>(""); // 应用的类名
41
+ const hasInit = ref<boolean>(false) // 是否显示/隐藏组件
42
+ const viewStyle = ref<CSSProperties>({}) // 组件内部的样式
43
+ const status = ref<string>('') // 记录组件动画的状态
44
+ const transitionEnded = ref<boolean>(false) // 组件是否结束的标记
45
+ const display = ref<boolean>(false) // 组件是否展示
46
+ const classes = ref<string>('') // 应用的类名
74
47
 
75
48
  // #ifndef APP-NVUE
76
49
  // 定义类名,通过给元素动态切换类名,赋予元素一定的css动画样式
77
50
  const getClassNames = (name: string) => ({
78
- enter: `u-${name}-enter u-${name}-enter-active`,
79
- "enter-to": `u-${name}-enter-to u-${name}-enter-active`,
80
- leave: `u-${name}-leave u-${name}-leave-active`,
81
- "leave-to": `u-${name}-leave-to u-${name}-leave-active`,
82
- });
51
+ enter: `u-${name}-enter u-${name}-enter-active`,
52
+ 'enter-to': `u-${name}-enter-to u-${name}-enter-active`,
53
+ leave: `u-${name}-leave u-${name}-leave-active`,
54
+ 'leave-to': `u-${name}-leave-to u-${name}-leave-active`
55
+ })
83
56
  // #endif
84
57
 
85
58
  // #ifndef APP-NVUE
86
59
  // vue版本的组件进场处理
87
60
  const vueEnter = async () => {
88
- // 动画进入时的类名
89
- const classNames = getClassNames(props.mode);
90
- // 定义状态和发出动画进入前事件
91
- status.value = "enter";
92
- emit("beforeEnter");
93
- hasInit.value = true;
94
- display.value = true;
95
- classes.value = classNames.enter;
96
- await nextTick();
97
- {
98
- // https://github.com/umicro/uView2.0/issues/545
99
- await sleep(20);
100
- // 标识动画尚未结束
101
- emit("enter");
102
- transitionEnded.value = false;
103
- // 组件动画进入后触发的事件
104
- emit("afterEnter");
105
- // 赋予组件enter-to类名
106
- classes.value = classNames["enter-to"];
107
- }
108
- };
61
+ // 动画进入时的类名
62
+ const classNames = getClassNames(props.mode)
63
+ // 定义状态和发出动画进入前事件
64
+ status.value = 'enter'
65
+ emit('beforeEnter')
66
+ hasInit.value = true
67
+ display.value = true
68
+ classes.value = classNames.enter
69
+ await nextTick()
70
+ {
71
+ // https://github.com/umicro/uView2.0/issues/545
72
+ await sleep(20)
73
+ // 标识动画尚未结束
74
+ emit('enter')
75
+ transitionEnded.value = false
76
+ // 组件动画进入后触发的事件
77
+ emit('afterEnter')
78
+ // 赋予组件enter-to类名
79
+ classes.value = classNames['enter-to']
80
+ }
81
+ }
109
82
  // 动画离场处理
110
83
  const vueLeave = async () => {
111
- // 如果不是展示状态,无需执行逻辑
112
- if (!display.value) return;
113
- const classNames = getClassNames(props.mode);
114
- // 标记离开状态和发出事件
115
- status.value = "leave";
116
- emit("beforeLeave");
117
- // 获得类名
118
- classes.value = classNames.leave;
84
+ // 如果不是展示状态,无需执行逻辑
85
+ if (!display.value) return
86
+ const classNames = getClassNames(props.mode)
87
+ // 标记离开状态和发出事件
88
+ status.value = 'leave'
89
+ emit('beforeLeave')
90
+ // 获得类名
91
+ classes.value = classNames.leave
119
92
 
120
- await nextTick();
121
- {
122
- // 动画正在离场的状态
123
- transitionEnded.value = false;
124
- emit("leave");
125
- // 组件执行动画,到了执行的执行时间后,执行一些额外处理
126
- setTimeout(() => onTransitionEnd(), props.duration);
127
- classes.value = classNames["leave-to"];
128
- }
129
- };
93
+ await nextTick()
94
+ {
95
+ // 动画正在离场的状态
96
+ transitionEnded.value = false
97
+ emit('leave')
98
+ // 组件执行动画,到了执行的执行时间后,执行一些额外处理
99
+ setTimeout(() => onTransitionEnd(), props.duration)
100
+ classes.value = classNames['leave-to']
101
+ }
102
+ }
130
103
  // #endif
131
104
 
132
105
  watch(
133
- () => props.show,
134
- (newVal) => {
135
- // vue和nvue分别执行不同的方法
136
- // #ifdef APP-NVUE
137
- // newVal ? nvueEnter() : nvueLeave()
138
- // #endif
139
- // #ifndef APP-NVUE
140
- newVal ? vueEnter() : vueLeave();
141
- // #endif
142
- },
143
- { immediate: true },
144
- );
106
+ () => props.show,
107
+ (newVal) => {
108
+ // vue和nvue分别执行不同的方法
109
+ // #ifdef APP-NVUE
110
+ // newVal ? nvueEnter() : nvueLeave()
111
+ // #endif
112
+ // #ifndef APP-NVUE
113
+ newVal ? vueEnter() : vueLeave()
114
+ // #endif
115
+ },
116
+ { immediate: true }
117
+ )
145
118
 
146
119
  const mergeStyle = computed(() => {
147
- return {
148
- // #ifndef APP-NVUE
149
- transitionDuration: `${props.duration}ms`,
150
- // display: `${this.display ? '' : 'none'}`,
151
- transitionTimingFunction: props.timingFunction,
152
- // #endif
153
- // 避免自定义样式影响到动画属性,所以写在viewStyle前面
154
- ...props.customStyle,
155
- ...viewStyle,
156
- };
157
- });
120
+ return {
121
+ // #ifndef APP-NVUE
122
+ transitionDuration: `${props.duration}ms`,
123
+ // display: `${this.display ? '' : 'none'}`,
124
+ transitionTimingFunction: props.timingFunction,
125
+ // #endif
126
+ // 避免自定义样式影响到动画属性,所以写在viewStyle前面
127
+ ...props.customStyle,
128
+ ...viewStyle
129
+ }
130
+ })
158
131
 
159
132
  /**
160
133
  * @description 组件被点击发出事件
161
134
  * */
162
135
  const clickHandler = () => {
163
- emit("click");
164
- };
136
+ emit('click')
137
+ }
165
138
 
166
139
  const onTransitionEnd = () => {
167
- // 如果已经是结束的状态,无需再处理
168
- if (transitionEnded.value) return;
169
- transitionEnded.value = true;
170
- // 发出组件动画执行后的事件
171
- status.value === "leave" ? emit("afterLeave") : emit("afterEnter");
172
- if (!props.show && display.value) {
173
- display.value = false;
174
- hasInit.value = false;
175
- }
176
- };
140
+ // 如果已经是结束的状态,无需再处理
141
+ if (transitionEnded.value) return
142
+ transitionEnded.value = true
143
+ // 发出组件动画执行后的事件
144
+ status.value === 'leave' ? emit('afterLeave') : emit('afterEnter')
145
+ if (!props.show && display.value) {
146
+ display.value = false
147
+ hasInit.value = false
148
+ }
149
+ }
177
150
  </script>
178
151
 
179
152
  <style lang="scss" scoped>
180
153
  /* #ifndef APP-NVUE */
181
154
  // vue版本动画相关的样式抽离在外部文件
182
- @import "./index.scss";
155
+ @import './index.scss';
183
156
  /* #endif */
184
157
  </style>
@@ -1,10 +1,32 @@
1
- import type IProps from "./typing";
1
+ import type { CSSProperties, PropType } from 'vue'
2
2
 
3
- const defaultProps: IProps = {
4
- show: false,
5
- mode: "fade",
6
- duration: 300,
7
- timingFunction: "ease-out",
8
- };
3
+ const transitionProps = {
4
+ /** 是否展示组件 */
5
+ show: {
6
+ type: Boolean,
7
+ default: false
8
+ },
9
+ /** 使用的动画模式 */
10
+ mode: {
11
+ type: String,
12
+ default: 'fade'
13
+ },
14
+ /** 动画的执行时间,单位ms */
15
+ duration: {
16
+ type: Number,
17
+ default: 300
18
+ },
19
+ /** 使用的动画过渡函数 */
20
+ timingFunction: {
21
+ type: String,
22
+ default: 'ease-out'
23
+ },
24
+ /** 定义需要用到的外部样式 */
25
+ customStyle: {
26
+ type: Object as PropType<CSSProperties>
27
+ },
28
+ /** 自定义外部类名 */
29
+ customClass: String
30
+ }
9
31
 
10
- export default defaultProps;
32
+ export default transitionProps