hy-app 0.4.15 → 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 (206) 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/hy-coupon.vue +10 -5
  55. package/components/hy-coupon/index.scss +148 -64
  56. package/components/hy-coupon/props.ts +35 -50
  57. package/components/hy-coupon/typing.d.ts +10 -0
  58. package/components/hy-datetime-picker/hy-datetime-picker.vue +415 -580
  59. package/components/hy-datetime-picker/props.ts +142 -32
  60. package/components/hy-datetime-picker/typing.d.ts +132 -132
  61. package/components/hy-divider/hy-divider.vue +90 -169
  62. package/components/hy-divider/props.ts +78 -19
  63. package/components/hy-divider/typing.d.ts +60 -60
  64. package/components/hy-dropdown/hy-dropdown.vue +37 -71
  65. package/components/hy-dropdown/props.ts +38 -15
  66. package/components/hy-dropdown/typing.d.ts +44 -44
  67. package/components/hy-dropdown-item/hy-dropdown-item.vue +141 -173
  68. package/components/hy-dropdown-item/props.ts +19 -8
  69. package/components/hy-empty/hy-empty.vue +75 -129
  70. package/components/hy-empty/props.ts +57 -15
  71. package/components/hy-empty/typing.d.ts +84 -84
  72. package/components/hy-flex/hy-flex.vue +33 -88
  73. package/components/hy-flex/props.ts +58 -0
  74. package/components/hy-flex/typing.d.ts +14 -16
  75. package/components/hy-float-button/hy-float-button.vue +289 -406
  76. package/components/hy-float-button/props.ts +109 -25
  77. package/components/hy-folding-panel/hy-folding-panel.vue +74 -114
  78. package/components/hy-folding-panel/props.ts +42 -0
  79. package/components/hy-folding-panel/typing.d.ts +57 -57
  80. package/components/hy-folding-panel-item/hy-folding-panel-item.vue +139 -231
  81. package/components/hy-folding-panel-item/props.ts +81 -0
  82. package/components/hy-folding-panel-item/typing.d.ts +23 -23
  83. package/components/hy-form/hy-form.vue +172 -212
  84. package/components/hy-form/props.ts +37 -0
  85. package/components/hy-form/typing.d.ts +68 -61
  86. package/components/hy-form-group/typing.d.ts +74 -74
  87. package/components/hy-form-item/hy-form-item.vue +100 -129
  88. package/components/hy-form-item/props.ts +25 -0
  89. package/components/hy-form-item/typing.d.ts +40 -37
  90. package/components/hy-grid/hy-grid.vue +76 -132
  91. package/components/hy-grid/props.ts +58 -16
  92. package/components/hy-grid/typing.d.ts +66 -66
  93. package/components/hy-icon/hy-icon.vue +84 -161
  94. package/components/hy-icon/props.ts +76 -22
  95. package/components/hy-icon/typing.d.ts +83 -82
  96. package/components/hy-image/hy-image.vue +142 -272
  97. package/components/hy-image/props.ts +105 -23
  98. package/components/hy-image/typing.d.ts +84 -87
  99. package/components/hy-input/hy-input.vue +230 -421
  100. package/components/hy-input/props.ts +183 -35
  101. package/components/hy-input/typing.d.ts +169 -169
  102. package/components/hy-line/hy-line.vue +34 -72
  103. package/components/hy-line/props.ts +41 -10
  104. package/components/hy-line/typing.d.ts +29 -29
  105. package/components/hy-line-progress/hy-line-progress.vue +66 -101
  106. package/components/hy-line-progress/props.ts +31 -10
  107. package/components/hy-line-progress/typing.d.ts +29 -29
  108. package/components/hy-list/hy-list.vue +151 -220
  109. package/components/hy-list/props.ts +67 -16
  110. package/components/hy-list/typing.d.ts +52 -52
  111. package/components/hy-loading/hy-loading.vue +63 -119
  112. package/components/hy-loading/props.ts +63 -15
  113. package/components/hy-loading/typing.d.ts +49 -49
  114. package/components/hy-menu/hy-menu.vue +124 -166
  115. package/components/hy-menu/props.ts +42 -10
  116. package/components/hy-menu/typing.d.ts +60 -60
  117. package/components/hy-modal/hy-modal.vue +127 -218
  118. package/components/hy-modal/props.ts +89 -24
  119. package/components/hy-navbar/hy-navbar.vue +104 -177
  120. package/components/hy-navbar/props.ts +76 -22
  121. package/components/hy-navbar/typing.d.ts +81 -81
  122. package/components/hy-notice-bar/hy-notice-bar.vue +67 -144
  123. package/components/hy-notice-bar/props.ts +80 -19
  124. package/components/hy-notice-bar/typing.d.ts +62 -62
  125. package/components/hy-notify/hy-notify.vue +128 -177
  126. package/components/hy-notify/props.ts +49 -12
  127. package/components/hy-notify/typing.d.ts +45 -41
  128. package/components/hy-number-step/hy-number-step.vue +281 -394
  129. package/components/hy-number-step/props.ts +110 -27
  130. package/components/hy-number-step/typing.d.ts +120 -120
  131. package/components/hy-overlay/hy-overlay.vue +39 -66
  132. package/components/hy-overlay/props.ts +31 -8
  133. package/components/hy-pagination/hy-pagination.vue +100 -155
  134. package/components/hy-pagination/props.ts +53 -13
  135. package/components/hy-picker/hy-picker.vue +309 -430
  136. package/components/hy-picker/index.scss +8 -12
  137. package/components/hy-picker/props.ts +110 -26
  138. package/components/hy-popover/hy-popover.vue +190 -252
  139. package/components/hy-popover/props.ts +48 -10
  140. package/components/hy-popup/hy-popup.vue +162 -248
  141. package/components/hy-popup/props.ts +82 -18
  142. package/components/hy-price/hy-price.vue +45 -104
  143. package/components/hy-price/props.ts +52 -12
  144. package/components/hy-price/typing.d.ts +41 -36
  145. package/components/hy-qrcode/hy-qrcode.vue +115 -185
  146. package/components/hy-qrcode/props.ts +68 -18
  147. package/components/hy-qrcode/typing.d.ts +67 -66
  148. package/components/hy-radio/hy-radio.vue +161 -259
  149. package/components/hy-radio/props.ts +95 -25
  150. package/components/hy-radio/typing.d.ts +85 -84
  151. package/components/hy-rate/hy-rate.vue +185 -270
  152. package/components/hy-rate/props.ts +76 -18
  153. package/components/hy-rate/typing.d.ts +61 -60
  154. package/components/hy-read-more/hy-read-more.vue +93 -136
  155. package/components/hy-read-more/props.ts +43 -13
  156. package/components/hy-scroll-list/hy-scroll-list.vue +81 -102
  157. package/components/hy-scroll-list/props.ts +22 -11
  158. package/components/hy-search/hy-search.vue +155 -284
  159. package/components/hy-search/props.ts +130 -25
  160. package/components/hy-signature/hy-signature.vue +491 -635
  161. package/components/hy-signature/props.ts +115 -26
  162. package/components/hy-signature/typing.d.ts +138 -138
  163. package/components/hy-slider/hy-slider.vue +388 -477
  164. package/components/hy-slider/props.ts +75 -19
  165. package/components/hy-steps/hy-steps.vue +212 -279
  166. package/components/hy-steps/props.ts +47 -13
  167. package/components/hy-submit-bar/hy-submit-bar.vue +136 -221
  168. package/components/hy-submit-bar/props.ts +89 -20
  169. package/components/hy-submit-bar/typing.d.ts +87 -87
  170. package/components/hy-subsection/hy-subsection.vue +132 -185
  171. package/components/hy-subsection/props.ts +50 -17
  172. package/components/hy-subsection/typing.d.ts +52 -52
  173. package/components/hy-swipe-action/hy-swipe-action.vue +228 -283
  174. package/components/hy-swipe-action/props.ts +43 -18
  175. package/components/hy-swipe-action/typing.d.ts +46 -46
  176. package/components/hy-swiper/hy-swiper.vue +159 -286
  177. package/components/hy-swiper/props.ts +126 -28
  178. package/components/hy-swiper/typing.d.ts +115 -115
  179. package/components/hy-switch/hy-switch.vue +112 -176
  180. package/components/hy-switch/props.ts +60 -15
  181. package/components/hy-switch/typing.d.ts +63 -63
  182. package/components/hy-tabBar/hy-tabBar.vue +64 -60
  183. package/components/hy-tabs/hy-tabs.vue +277 -380
  184. package/components/hy-tabs/props.ts +75 -18
  185. package/components/hy-tag/hy-tag.vue +111 -204
  186. package/components/hy-tag/props.ts +81 -19
  187. package/components/hy-text/hy-text.vue +200 -322
  188. package/components/hy-text/props.ts +107 -28
  189. package/components/hy-textarea/hy-textarea.vue +147 -256
  190. package/components/hy-textarea/props.ts +112 -25
  191. package/components/hy-textarea/typing.d.ts +42 -42
  192. package/components/hy-toast/hy-toast.vue +135 -143
  193. package/components/hy-tooltip/hy-tooltip.vue +220 -306
  194. package/components/hy-tooltip/props.ts +79 -15
  195. package/components/hy-transition/hy-transition.vue +111 -138
  196. package/components/hy-transition/props.ts +30 -8
  197. package/components/hy-upload/hy-upload.vue +320 -469
  198. package/components/hy-upload/props.ts +130 -27
  199. package/components/hy-warn/hy-warn.vue +80 -129
  200. package/components/hy-warn/props.ts +47 -12
  201. package/components/hy-waterfall/hy-waterfall.vue +139 -163
  202. package/components/hy-waterfall/props.ts +19 -7
  203. package/components/hy-watermark/hy-watermark.vue +762 -870
  204. package/components/hy-watermark/props.ts +103 -22
  205. package/package.json +2 -2
  206. package/web-types.json +1 -1
@@ -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