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,283 +1,200 @@
1
1
  <template>
2
- <view>
3
- <HyPopup
4
- :show="showPopup"
5
- :duration="duration"
6
- mode="bottom"
7
- :close-on-click-overlay="closeOnClickOverlay"
8
- :safe-area-inset-bottom="safeAreaInsetBottom"
9
- @open="onOpen"
10
- @close="onClose"
11
- :z-index="zIndex"
12
- :round="round"
13
- >
14
- <view
15
- :class="`hy-action-sheet ${customClass}`"
16
- :style="`${
17
- (actions && actions.length) || (panels && panels.length)
18
- ? 'margin: 0 10px calc(var(--window-bottom) + 10px) 10px; border-radius: 16px;'
19
- : 'margin-bottom: var(--window-bottom);'
20
- } ${customStyle}`"
21
- >
22
- <!-- 标题 -->
23
- <view
24
- v-if="title"
25
- :class="`hy-action-sheet__header ${customHeaderClass}`"
2
+ <view>
3
+ <hy-popup
4
+ :show="showPopup"
5
+ :duration="duration"
6
+ mode="bottom"
7
+ :close-on-click-overlay="closeOnClickOverlay"
8
+ :safe-area-inset-bottom="safeAreaInsetBottom"
9
+ @open="onOpen"
10
+ @close="onClose"
11
+ :z-index="zIndex"
12
+ :round="round"
26
13
  >
27
- {{ title }}
28
- <HyIcon
29
- customClass="hy-action-sheet__close"
30
- class="hy-action-sheet__close"
31
- name="close"
32
- @click="onClose"
33
- />
34
- </view>
35
- <!-- 标题 -->
36
-
37
- <!-- 选项卡 -->
38
- <view class="hy-action-sheet__actions" v-if="actions && actions.length">
39
- <view
40
- v-for="(action, rowIndex) in actions"
41
- :key="rowIndex"
42
- :class="`hy-action-sheet__action ${
43
- action?.disabled ? 'hy-action-sheet__action--disabled' : ''
44
- } ${action?.loading ? 'hy-action-sheet__action--loading' : ''}`"
45
- :style="`color: ${action?.color}`"
46
- @click="onSelect(rowIndex, 'action')"
47
- >
48
- <HyLoading :show="!!action?.loading" mode="circle" />
49
- <view v-if="!action?.loading" class="hy-action-sheet__name">{{
50
- action?.name
51
- }}</view>
52
14
  <view
53
- v-if="!action?.loading && action?.sub"
54
- class="hy-action-sheet__subname"
15
+ :class="`hy-action-sheet ${customClass}`"
16
+ :style="`${
17
+ (actions && actions.length) || (panels && panels.length)
18
+ ? 'margin: 0 10px calc(var(--window-bottom) + 10px) 10px; border-radius: 16px;'
19
+ : 'margin-bottom: var(--window-bottom);'
20
+ } ${customStyle}`"
55
21
  >
56
- {{ action?.sub }}
57
- </view>
58
- </view>
59
- </view>
60
- <!-- 选项卡 -->
22
+ <!-- 标题 -->
23
+ <view v-if="title" :class="`hy-action-sheet__header ${customHeaderClass}`">
24
+ {{ title }}
25
+ <hy-icon
26
+ customClass="hy-action-sheet__close"
27
+ class="hy-action-sheet__close"
28
+ name="close"
29
+ @click="onClose"
30
+ />
31
+ </view>
32
+ <!-- 标题 -->
61
33
 
62
- <!-- 自定义面板 -->
63
- <view v-if="formatPanels && formatPanels.length">
64
- <view
65
- v-for="(panel, rowIndex) in formatPanels"
66
- :key="rowIndex"
67
- class="hy-action-sheet__panels"
68
- >
69
- <view class="hy-action-sheet__panels-content">
70
- <view
71
- v-for="(col, colIndex) in panel"
72
- :key="colIndex"
73
- class="hy-action-sheet__panel"
74
- @click="onSelect(rowIndex, 'panels', colIndex)"
75
- >
76
- <image
77
- class="hy-action-sheet__panel-img"
78
- :src="(col as any).iconUrl"
79
- />
80
- <view class="hy-action-sheet__panel-title">{{
81
- (col as any).name
82
- }}</view>
83
- </view>
84
- </view>
85
- </view>
86
- </view>
87
- <!-- 自定义面板 -->
34
+ <!-- 选项卡 -->
35
+ <view class="hy-action-sheet__actions" v-if="actions && actions.length">
36
+ <view
37
+ v-for="(action, rowIndex) in actions"
38
+ :key="rowIndex"
39
+ :class="`hy-action-sheet__action ${
40
+ action?.disabled ? 'hy-action-sheet__action--disabled' : ''
41
+ } ${action?.loading ? 'hy-action-sheet__action--loading' : ''}`"
42
+ :style="`color: ${action?.color}`"
43
+ @click="onSelect(rowIndex, 'action')"
44
+ >
45
+ <hy-loading :show="!!action?.loading" mode="circle" />
46
+ <view v-if="!action?.loading" class="hy-action-sheet__name">{{
47
+ action?.name
48
+ }}</view>
49
+ <view
50
+ v-if="!action?.loading && action?.sub"
51
+ class="hy-action-sheet__subname"
52
+ >
53
+ {{ action?.sub }}
54
+ </view>
55
+ </view>
56
+ </view>
57
+ <!-- 选项卡 -->
88
58
 
89
- <!-- 面板插槽 -->
90
- <slot />
91
- <!-- 自定义面板 -->
59
+ <!-- 自定义面板 -->
60
+ <view v-if="formatPanels && formatPanels.length">
61
+ <view
62
+ v-for="(panel, rowIndex) in formatPanels"
63
+ :key="rowIndex"
64
+ class="hy-action-sheet__panels"
65
+ >
66
+ <view class="hy-action-sheet__panels-content">
67
+ <view
68
+ v-for="(col, colIndex) in panel"
69
+ :key="colIndex"
70
+ class="hy-action-sheet__panel"
71
+ @click="onSelect(rowIndex, 'panels', colIndex)"
72
+ >
73
+ <image
74
+ class="hy-action-sheet__panel-img"
75
+ :src="(col as any).iconUrl"
76
+ />
77
+ <view class="hy-action-sheet__panel-title">{{
78
+ (col as any).name
79
+ }}</view>
80
+ </view>
81
+ </view>
82
+ </view>
83
+ </view>
84
+ <!-- 自定义面板 -->
92
85
 
93
- <!-- 取消按钮 -->
94
- <HyButton
95
- v-if="cancelText"
96
- :text="cancelText"
97
- shape="circle"
98
- custom-class="hy-action-sheet__cancel"
99
- @click="handleCancel"
100
- ></HyButton>
101
- <!-- 取消按钮 -->
102
- </view>
103
- </HyPopup>
104
- </view>
86
+ <!-- 面板插槽 -->
87
+ <slot />
88
+ <!-- 自定义面板 -->
89
+
90
+ <!-- 取消按钮 -->
91
+ <hy-button
92
+ v-if="cancelText"
93
+ :text="cancelText"
94
+ shape="circle"
95
+ custom-class="hy-action-sheet__cancel"
96
+ @click="handleCancel"
97
+ ></hy-button>
98
+ <!-- 取消按钮 -->
99
+ </view>
100
+ </hy-popup>
101
+ </view>
105
102
  </template>
106
103
 
107
104
  <script lang="ts">
108
105
  export default {
109
- name: "hy-action-sheet",
110
- options: {
111
- addGlobalClass: true,
112
- virtualHost: true,
113
- styleIsolation: "shared",
114
- },
115
- };
106
+ name: 'hy-action-sheet',
107
+ options: {
108
+ addGlobalClass: true,
109
+ virtualHost: true,
110
+ styleIsolation: 'shared'
111
+ }
112
+ }
116
113
  </script>
117
114
 
118
115
  <script lang="ts" setup>
119
- import { watch, ref } from "vue";
120
- import type { PropType, CSSProperties } from "vue";
121
- import { isArray } from "../../libs";
122
- import type {
123
- IActionSheetPanel,
124
- IActionSheetEmits,
125
- IActionSheetAction,
126
- } from "./typing";
116
+ import { watch, ref } from 'vue'
117
+ import { isArray } from '../../libs'
118
+ import type { IActionSheetPanel, IActionSheetEmits } from './typing'
119
+ import actionSheetProps from './props'
127
120
  // 组件
128
- import HyIcon from "../hy-icon/hy-icon.vue";
129
- import HyPopup from "../hy-popup/hy-popup.vue";
130
- import HyLoading from "../hy-loading/hy-loading.vue";
131
- import HyButton from "../hy-button/hy-button.vue";
121
+ import HyIcon from '../hy-icon/hy-icon.vue'
122
+ import HyPopup from '../hy-popup/hy-popup.vue'
123
+ import HyLoading from '../hy-loading/hy-loading.vue'
124
+ import HyButton from '../hy-button/hy-button.vue'
132
125
 
133
126
  /**
134
127
  * 本组件用于从底部弹出一个操作菜单,供用户选择并返回结果。本组件功能类似于uni的uni.showActionSheetAPI,配置更加灵活,所有平台都表现一致。
135
128
  * @displayName hy-action-sheet
136
129
  */
137
- defineOptions({});
130
+ defineOptions({})
138
131
 
139
- // const props = withDefaults(defineProps<HyActionSheetProps>(), defaultProps)
140
- const props = defineProps({
141
- /** 操作菜单是否展示 */
142
- modelValue: {
143
- type: Boolean,
144
- default: false,
145
- required: true,
146
- },
147
- /** 菜单选项列表 */
148
- actions: {
149
- type: Array as PropType<IActionSheetAction[]>,
150
- default() {
151
- return [];
152
- },
153
- },
154
- /** 自定义面板项,可以为字符串数组,也可以为对象数组,如果为二维数组,则为多行展示 */
155
- panels: {
156
- type: Array as PropType<Array<IActionSheetPanel | IActionSheetPanel[]>>,
157
- default() {
158
- return [];
159
- },
160
- },
161
- /** 操作菜单是否展示 */
162
- round: {
163
- type: [String, Number],
164
- default: 20,
165
- },
166
- /** 标题 */
167
- title: String,
168
- /**
169
- * 标题文字位置
170
- * @values left,center,right
171
- * */
172
- titleAlign: {
173
- type: String,
174
- default: "center",
175
- },
176
- /** 取消按钮的提示文字,不为空时显示按钮 */
177
- cancelText: String,
178
- /** 点击某个菜单项时是否关闭弹窗 */
179
- closeOnClickAction: {
180
- type: Boolean,
181
- default: true,
182
- },
183
- /** 点击遮罩是否允许关闭 */
184
- closeOnClickOverlay: {
185
- type: Boolean,
186
- default: true,
187
- },
188
- /** 弹框动画持续时间 */
189
- duration: {
190
- type: Number,
191
- default: 200,
192
- },
193
- /** 菜单层级 */
194
- zIndex: {
195
- type: Number,
196
- default: 100,
197
- },
198
- /** 处理底部安全区 */
199
- safeAreaInsetBottom: {
200
- type: Boolean,
201
- default: true,
202
- },
203
- /** 自定义外部样式 */
204
- customStyle: Object as PropType<CSSProperties>,
205
- /** 自定义外部类名 */
206
- customClass: String,
207
- /** 自定义标题类名 */
208
- customHeaderClass: String,
209
- });
210
- const emit = defineEmits<IActionSheetEmits>();
132
+ const props = defineProps(actionSheetProps)
133
+ const emit = defineEmits<IActionSheetEmits>()
211
134
 
212
- const formatPanels = ref<Array<IActionSheetPanel> | Array<IActionSheetPanel[]>>(
213
- [],
214
- );
215
- const showPopup = ref<boolean>(false);
135
+ const formatPanels = ref<Array<IActionSheetPanel> | Array<IActionSheetPanel[]>>([])
136
+ const showPopup = ref<boolean>(false)
216
137
 
217
- watch(() => props.panels, computedValue, { deep: true, immediate: true });
138
+ watch(() => props.panels, computedValue, { deep: true, immediate: true })
218
139
 
219
140
  watch(
220
- () => props.modelValue,
221
- (newValue) => {
222
- showPopup.value = newValue;
223
- },
224
- { deep: true, immediate: true },
225
- );
141
+ () => props.modelValue,
142
+ (newValue) => {
143
+ showPopup.value = newValue
144
+ },
145
+ { deep: true, immediate: true }
146
+ )
226
147
 
227
148
  function isPanelArray() {
228
- return props.panels.length && !isArray(props.panels[0]);
149
+ return props.panels.length && !isArray(props.panels[0])
229
150
  }
230
151
  function computedValue() {
231
- formatPanels.value = isPanelArray()
232
- ? [props.panels as IActionSheetPanel[]]
233
- : (props.panels as IActionSheetPanel[][]);
152
+ formatPanels.value = isPanelArray()
153
+ ? [props.panels as IActionSheetPanel[]]
154
+ : (props.panels as IActionSheetPanel[][])
234
155
  }
235
156
 
236
- function onSelect(
237
- rowIndex: number,
238
- type: "action" | "panels",
239
- colIndex?: number,
240
- ) {
241
- if (type === "action") {
242
- if (props.actions[rowIndex].disabled || props.actions[rowIndex].loading) {
243
- return;
157
+ function onSelect(rowIndex: number, type: 'action' | 'panels', colIndex?: number) {
158
+ if (type === 'action') {
159
+ if (props.actions[rowIndex].disabled || props.actions[rowIndex].loading) {
160
+ return
161
+ }
162
+ emit('select', {
163
+ item: props.actions[rowIndex],
164
+ index: rowIndex
165
+ })
166
+ } else if (isPanelArray()) {
167
+ emit('select', {
168
+ item: props.panels[Number(colIndex)],
169
+ index: colIndex
170
+ })
171
+ } else {
172
+ emit('select', {
173
+ item: (props.panels as IActionSheetPanel[][])[rowIndex][Number(colIndex)],
174
+ rowIndex,
175
+ colIndex
176
+ })
177
+ }
178
+ if (props.closeOnClickAction) {
179
+ onClose()
244
180
  }
245
- emit("select", {
246
- item: props.actions[rowIndex],
247
- index: rowIndex,
248
- });
249
- } else if (isPanelArray()) {
250
- emit("select", {
251
- item: props.panels[Number(colIndex)],
252
- index: colIndex,
253
- });
254
- } else {
255
- emit("select", {
256
- item: (props.panels as IActionSheetPanel[][])[rowIndex][Number(colIndex)],
257
- rowIndex,
258
- colIndex,
259
- });
260
- }
261
- if (props.closeOnClickAction) {
262
- onClose();
263
- }
264
181
  }
265
182
  function handleCancel() {
266
- emit("cancel");
267
- onClose();
183
+ emit('cancel')
184
+ onClose()
268
185
  }
269
186
  function onClose() {
270
- emit("update:modelValue", false);
271
- emit("close");
187
+ emit('update:modelValue', false)
188
+ emit('close')
272
189
  }
273
190
  function onOpen() {
274
- emit("open");
191
+ emit('open')
275
192
  }
276
193
  </script>
277
194
 
278
195
  <style lang="scss" scoped>
279
- @import "./index.scss";
196
+ @import './index.scss';
280
197
  .hy-action-sheet__header {
281
- text-align: v-bind(titleAlign);
198
+ text-align: v-bind(titleAlign);
282
199
  }
283
200
  </style>
@@ -1,18 +1,71 @@
1
- import type { HyActionSheetProps } from './typing'
1
+ import type { IActionSheetAction, IActionSheetPanel } from './typing'
2
+ import type { CSSProperties, PropType } from 'vue'
2
3
 
3
- const defaultProps: HyActionSheetProps = {
4
- modelValue: false,
5
- actions: [],
6
- panels: [],
7
- round: '20px',
8
- title: '',
9
- titleAlign: 'center',
10
- cancelText: '',
11
- closeOnClickAction: true,
12
- closeOnClickOverlay: true,
13
- duration: 200,
14
- zIndex: 100,
15
- safeAreaInsetBottom: true,
4
+ const actionSheetProps = {
5
+ /** 操作菜单是否展示 */
6
+ modelValue: {
7
+ type: Boolean,
8
+ default: false,
9
+ required: true
10
+ },
11
+ /** 菜单选项列表 */
12
+ actions: {
13
+ type: Array as PropType<IActionSheetAction[]>,
14
+ default: () => []
15
+ },
16
+ /** 自定义面板项,可以为字符串数组,也可以为对象数组,如果为二维数组,则为多行展示 */
17
+ panels: {
18
+ type: Array as PropType<Array<IActionSheetPanel | IActionSheetPanel[]>>,
19
+ default: () => []
20
+ },
21
+ /** 操作菜单是否展示 */
22
+ round: {
23
+ type: [String, Number],
24
+ default: 20
25
+ },
26
+ /** 标题 */
27
+ title: String,
28
+ /**
29
+ * 标题文字位置
30
+ * @values left,center,right
31
+ * */
32
+ titleAlign: {
33
+ type: String,
34
+ default: 'center'
35
+ },
36
+ /** 取消按钮的提示文字,不为空时显示按钮 */
37
+ cancelText: String,
38
+ /** 点击某个菜单项时是否关闭弹窗 */
39
+ closeOnClickAction: {
40
+ type: Boolean,
41
+ default: true
42
+ },
43
+ /** 点击遮罩是否允许关闭 */
44
+ closeOnClickOverlay: {
45
+ type: Boolean,
46
+ default: true
47
+ },
48
+ /** 弹框动画持续时间 */
49
+ duration: {
50
+ type: Number,
51
+ default: 200
52
+ },
53
+ /** 菜单层级 */
54
+ zIndex: {
55
+ type: Number,
56
+ default: 100
57
+ },
58
+ /** 处理底部安全区 */
59
+ safeAreaInsetBottom: {
60
+ type: Boolean,
61
+ default: true
62
+ },
63
+ /** 自定义外部样式 */
64
+ customStyle: Object as PropType<CSSProperties>,
65
+ /** 自定义外部类名 */
66
+ customClass: String,
67
+ /** 自定义标题类名 */
68
+ customHeaderClass: String
16
69
  }
17
70
 
18
- export default defaultProps
71
+ export default actionSheetProps