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
@@ -57,18 +57,14 @@
57
57
  @include edeep(mask) {
58
58
  background-image: none;
59
59
  }
60
- }
61
60
 
62
- @include m(loading) {
63
- position: absolute;
64
- top: 0;
65
- right: 0;
66
- left: 0;
67
- bottom: 0;
68
- @include flex;
69
- justify-content: center;
70
- align-items: center;
71
- background-color: rgba(255, 255, 255, 0.87);
72
- z-index: 1000;
61
+ @include edeep(loading) {
62
+ position: absolute;
63
+ top: 0;
64
+ right: 0;
65
+ left: 0;
66
+ bottom: 0;
67
+ z-index: 1000;
68
+ }
73
69
  }
74
70
  }
@@ -1,28 +1,112 @@
1
- import type IProps from "./typing";
1
+ import type { PickerColumnVo } from './typing'
2
+ import type HyInputProps from './typing'
3
+ import type { PropType } from 'vue'
2
4
 
3
- const defaultProps: IProps = {
4
- modelValue: "",
5
- show: false,
6
- popupMode: "bottom",
7
- separator: "/",
8
- showToolbar: true,
9
- title: "",
10
- columns: [],
11
- loading: false,
12
- itemHeight: 44,
13
- cancelText: "取消",
14
- confirmText: "确定",
15
- cancelColor: "#909193",
16
- confirmColor: "",
17
- visibleItemCount: 5,
18
- keyName: "text",
19
- closeOnClickOverlay: false,
20
- defaultIndex: [],
21
- immediateChange: true,
22
- zIndex: 10076,
23
- hasInput: false,
24
- input: {},
25
- toolbarRightSlot: false,
26
- };
5
+ const pickerProps = {
6
+ /** 显示到输入框值 */
7
+ modelValue: {
8
+ type: [String, Array],
9
+ default: ''
10
+ },
11
+ /** 是否显示弹窗 */
12
+ show: {
13
+ type: Boolean,
14
+ default: false
15
+ },
16
+ /** 弹窗弹出模式 */
17
+ popupMode: {
18
+ type: String,
19
+ default: 'bottom'
20
+ },
21
+ /** 分割数组条件 */
22
+ separator: {
23
+ type: String,
24
+ default: '/'
25
+ },
26
+ /** 是否显示顶部的操作栏 */
27
+ showToolbar: {
28
+ type: Boolean,
29
+ default: true
30
+ },
31
+ /** 顶部标题 */
32
+ title: String,
33
+ /** 二维数组,设置每一列的数据 */
34
+ columns: {
35
+ type: Array as unknown as PropType<(string | PickerColumnVo)[][]>,
36
+ default: []
37
+ },
38
+ /** 是否显示加载中状态 */
39
+ loading: {
40
+ type: Boolean,
41
+ default: false
42
+ },
43
+ /** 各列中,单个选项的高度 */
44
+ itemHeight: {
45
+ type: Number,
46
+ default: 44
47
+ },
48
+ /** 取消按钮的文字 */
49
+ cancelText: {
50
+ type: String,
51
+ default: '取消'
52
+ },
53
+ /** 确认按钮的文字 */
54
+ confirmText: {
55
+ type: String,
56
+ default: '确定'
57
+ },
58
+ /** 取消按钮的颜色 */
59
+ cancelColor: {
60
+ type: String,
61
+ default: '#909193'
62
+ },
63
+ /** 确认按钮的颜色 */
64
+ confirmColor: String,
65
+ /** 每列中可见选项的数量 */
66
+ visibleItemCount: {
67
+ type: Number,
68
+ default: 5
69
+ },
70
+ /** 显示到选项对象中,需要展示的属性键名 */
71
+ keyName: {
72
+ type: String,
73
+ default: 'text'
74
+ },
75
+ /** 是否允许点击遮罩关闭选择器 */
76
+ closeOnClickOverlay: {
77
+ type: Boolean,
78
+ default: false
79
+ },
80
+ /** 各列的默认索引 */
81
+ defaultIndex: {
82
+ type: Array as PropType<number[]>,
83
+ default: []
84
+ },
85
+ /** 是否在手指松开时立即触发change事件 */
86
+ immediateChange: {
87
+ type: Boolean,
88
+ default: true
89
+ },
90
+ /** 最高层级 */
91
+ zIndex: {
92
+ type: Number,
93
+ default: 10076
94
+ },
95
+ /** 是否显示输入框 */
96
+ hasInput: {
97
+ type: Boolean,
98
+ default: false
99
+ },
100
+ /** 输入框集合属性 */
101
+ input: {
102
+ type: Object as PropType<HyInputProps>,
103
+ default: () => {}
104
+ },
105
+ /** 是否自定义选择器nav左边内容 */
106
+ toolbarRightSlot: {
107
+ type: Boolean,
108
+ default: false
109
+ }
110
+ }
27
111
 
28
- export default defaultProps;
112
+ export default pickerProps
@@ -1,258 +1,196 @@
1
1
  <template>
2
- <view
3
- :class="['hy-popover', customClass]"
4
- :style="customStyle"
5
- id="popover"
6
- @click.stop="popover.noop"
7
- >
8
- <!-- 使用插槽时无法获取正确宽高 -->
9
- <view class="hy-popover__pos hy-popover__hidden" id="pos">
10
- <view class="hy-popover__container">
11
- <view
12
- v-if="!slots.content && mode === 'normal'"
13
- class="hy-popover__inner"
14
- >
15
- {{ content }}
16
- </view>
17
- <view
18
- v-if="!slots.content && mode === 'menu' && isArray(content)"
19
- class="hy-popover__menu"
20
- >
21
- <view
22
- v-for="(item, index) in content"
23
- :key="index"
24
- class="hy-popover__menu-inner"
25
- @click="menuClick(index)"
26
- >
27
- <hy-icon
28
- v-if="item.iconClass"
29
- :name="item.iconClass"
30
- custom-class="hy-popover__icon"
31
- />
32
- <text>{{ item.content }}</text>
33
- </view>
34
- </view>
35
- </view>
36
- </view>
37
-
38
- <hy-transition
39
- custom-class="hy-popover__pos"
40
- :custom-style="popover.popStyle.value"
41
- :show="showPopover"
42
- :duration="200"
2
+ <view
3
+ :class="['hy-popover', customClass]"
4
+ :style="customStyle"
5
+ id="popover"
6
+ @click.stop="popover.noop"
43
7
  >
44
- <view class="hy-popover__container">
45
- <!-- 三角形 -->
46
- <view
47
- :class="`hy-popover__arrow ${popover.arrowClass.value}`"
48
- :style="popover.arrowStyle.value"
49
- ></view>
50
- <!-- 三角形 -->
51
-
52
- <!-- 普通模式 -->
53
- <view
54
- v-if="!slots.content && mode === 'normal'"
55
- class="hy-popover__inner"
56
- >
57
- {{ content }}
8
+ <!-- 使用插槽时无法获取正确宽高 -->
9
+ <view class="hy-popover__pos hy-popover__hidden" id="pos">
10
+ <view class="hy-popover__container">
11
+ <view v-if="!slots.content && mode === 'normal'" class="hy-popover__inner">
12
+ {{ content }}
13
+ </view>
14
+ <view
15
+ v-if="!slots.content && mode === 'menu' && isArray(content)"
16
+ class="hy-popover__menu"
17
+ >
18
+ <view
19
+ v-for="(item, index) in content"
20
+ :key="index"
21
+ class="hy-popover__menu-inner"
22
+ @click="menuClick(index)"
23
+ >
24
+ <hy-icon
25
+ v-if="item.iconClass"
26
+ :name="item.iconClass"
27
+ custom-class="hy-popover__icon"
28
+ />
29
+ <text>{{ item.content }}</text>
30
+ </view>
31
+ </view>
32
+ </view>
58
33
  </view>
59
- <!-- 普通模式 -->
60
34
 
61
- <!-- 列表模式 -->
62
- <view
63
- v-if="!slots.content && mode === 'menu' && isArray(content)"
64
- class="hy-popover__menu"
35
+ <hy-transition
36
+ custom-class="hy-popover__pos"
37
+ :custom-style="popover.popStyle.value"
38
+ :show="showPopover"
39
+ :duration="200"
65
40
  >
66
- <view
67
- v-for="(item, index) in content"
68
- :key="index"
69
- class="hy-popover__menu-inner"
70
- @click="menuClick(index)"
71
- :style="index === 0 ? 'border-top: none' : ''"
72
- >
73
- <hy-icon
74
- v-if="typeof item === 'object' && item.icon"
75
- :name="item.icon"
76
- custom-class="hy-popover__icon"
77
- />
78
- <view style="display: inline-block">
79
- {{
80
- typeof item === "object" && item.content ? item.content : item
81
- }}
41
+ <view class="hy-popover__container">
42
+ <!-- 三角形 -->
43
+ <view
44
+ :class="`hy-popover__arrow ${popover.arrowClass.value}`"
45
+ :style="popover.arrowStyle.value"
46
+ ></view>
47
+ <!-- 三角形 -->
48
+
49
+ <!-- 普通模式 -->
50
+ <view v-if="!slots.content && mode === 'normal'" class="hy-popover__inner">
51
+ {{ content }}
52
+ </view>
53
+ <!-- 普通模式 -->
54
+
55
+ <!-- 列表模式 -->
56
+ <view
57
+ v-if="!slots.content && mode === 'menu' && isArray(content)"
58
+ class="hy-popover__menu"
59
+ >
60
+ <view
61
+ v-for="(item, index) in content"
62
+ :key="index"
63
+ class="hy-popover__menu-inner"
64
+ @click="menuClick(index)"
65
+ :style="index === 0 ? 'border-top: none' : ''"
66
+ >
67
+ <hy-icon
68
+ v-if="typeof item === 'object' && item.icon"
69
+ :name="item.icon"
70
+ custom-class="hy-popover__icon"
71
+ />
72
+ <view style="display: inline-block">
73
+ {{ typeof item === 'object' && item.content ? item.content : item }}
74
+ </view>
75
+ </view>
76
+ </view>
77
+ <!-- 列表模式 -->
78
+
79
+ <!-- 用户自定义样式 -->
80
+ <slot name="content" v-else />
81
+ <!-- 用户自定义样式 -->
82
82
  </view>
83
- </view>
83
+ <hy-icon
84
+ v-if="showClose"
85
+ name="close"
86
+ custom-class="hy-popover__close-icon"
87
+ @click="toggle"
88
+ ></hy-icon>
89
+ </hy-transition>
90
+ <view @click="toggle" class="hy-popover__target" id="target">
91
+ <slot />
84
92
  </view>
85
- <!-- 列表模式 -->
86
-
87
- <!-- 用户自定义样式 -->
88
- <slot name="content" v-else />
89
- <!-- 用户自定义样式 -->
90
- </view>
91
- <hy-icon
92
- v-if="showClose"
93
- name="close"
94
- custom-class="hy-popover__close-icon"
95
- @click="toggle"
96
- ></hy-icon>
97
- </hy-transition>
98
- <view @click="toggle" class="hy-popover__target" id="target">
99
- <slot />
100
93
  </view>
101
- </view>
102
94
  </template>
103
95
 
104
96
  <script lang="ts">
105
97
  export default {
106
- name: "hy-popover",
107
- options: {
108
- virtualHost: true,
109
- addGlobalClass: true,
110
- styleIsolation: "shared",
111
- },
112
- };
98
+ name: 'hy-popover',
99
+ options: {
100
+ virtualHost: true,
101
+ addGlobalClass: true,
102
+ styleIsolation: 'shared'
103
+ }
104
+ }
113
105
  </script>
114
106
 
115
107
  <script lang="ts" setup>
116
108
  import {
117
- getCurrentInstance,
118
- onMounted,
119
- onBeforeMount,
120
- onBeforeUnmount,
121
- ref,
122
- useSlots,
123
- watch,
124
- inject,
125
- nextTick,
126
- } from "vue";
127
- import type { PropType, CSSProperties } from "vue";
128
- import type {
129
- IOffset,
130
- IPlacementVo,
131
- IPopoverEmits,
132
- PopoverExpose,
133
- } from "./typing";
109
+ getCurrentInstance,
110
+ onBeforeMount,
111
+ onBeforeUnmount,
112
+ ref,
113
+ useSlots,
114
+ watch,
115
+ inject,
116
+ nextTick
117
+ } from 'vue'
118
+ import type { IPopoverEmits, PopoverExpose } from './typing'
134
119
  import {
135
- type Queue,
136
- queueKey,
137
- usePopover,
138
- closeOther,
139
- pushToQueue,
140
- removeFromQueue,
141
- isArray,
142
- } from "../../libs";
120
+ type Queue,
121
+ queueKey,
122
+ usePopover,
123
+ closeOther,
124
+ pushToQueue,
125
+ removeFromQueue,
126
+ isArray
127
+ } from '../../libs'
128
+ import popoverProps from './props'
143
129
  // 组件
144
- import HyIcon from "../hy-icon/hy-icon.vue";
145
- import HyTransition from "../hy-transition/hy-transition.vue";
130
+ import HyIcon from '../hy-icon/hy-icon.vue'
131
+ import HyTransition from '../hy-transition/hy-transition.vue'
146
132
 
147
133
  /**
148
134
  * 常用于展示提示信息。
149
135
  * @displayName hy-popover
150
136
  */
151
- defineOptions({});
137
+ defineOptions({})
152
138
 
153
- // const props = withDefaults(defineProps<IProps>(), defaultProps)
154
- const props = defineProps({
155
- /** 控制 popover 的显示状态 */
156
- modelValue: {
157
- type: Boolean,
158
- default: false,
159
- },
160
- /** 显示的内容,也可以通过 slot#content 传入 */
161
- content: {
162
- type: [String, Array] as PropType<string | any[]>,
163
- },
164
- /**
165
- * 指定 popover 的放置位置
166
- * @values top,top-start,top-end,bottom,bottom-start,bottom-end,left,left-start,left-end,right,right-start,right-end
167
- * */
168
- placement: {
169
- type: String as PropType<IPlacementVo>,
170
- default: "bottom",
171
- },
172
- /** 控制 popover 的显示状态 */
173
- offset: {
174
- type: [Number, Array, Object] as PropType<IOffset>,
175
- default: 0,
176
- },
177
- /** 是否显示关闭按钮 */
178
- showClose: {
179
- type: Boolean,
180
- default: false,
181
- },
182
- /** 是否禁用 popover */
183
- disabled: {
184
- type: Boolean,
185
- default: false,
186
- },
187
- /**
188
- * 当前显示的模式,决定内容的展现形式
189
- * @values normal,menu
190
- * */
191
- mode: {
192
- type: String,
193
- default: "normal",
194
- },
195
- /** 定义需要用到的外部样式 */
196
- customStyle: Object as PropType<CSSProperties>,
197
- /** 自定义外部类名 */
198
- customClass: String,
199
- });
200
- const emit = defineEmits<IPopoverEmits>();
139
+ const props = defineProps(popoverProps)
140
+ const emit = defineEmits<IPopoverEmits>()
201
141
 
202
- const slots = useSlots();
203
- const queue = inject<Queue | null>(queueKey, null);
204
- const selector: string = "popover";
205
- const visibleArrow = ref<boolean>(true);
206
- const { proxy } = getCurrentInstance() as any;
207
- const popover = usePopover();
208
- const showPopover = ref<boolean>(false); // 控制popover显隐
142
+ const slots = useSlots()
143
+ const queue = inject<Queue | null>(queueKey, null)
144
+ const selector: string = 'popover'
145
+ const visibleArrow = ref<boolean>(true)
146
+ const { proxy } = getCurrentInstance() as any
147
+ const popover = usePopover()
148
+ const showPopover = ref<boolean>(false) // 控制popover显隐
209
149
 
210
150
  watch(
211
- () => props.content,
212
- (newVal) => {
213
- if (props.mode === "normal" && typeof newVal !== "string") {
214
- console.error("在“normal”模式下,值类型必须为字符串类型。");
215
- } else if (props.mode === "menu" && !isArray(newVal)) {
216
- console.error("在“menu”模式下,值类型必须是数组类型。");
151
+ () => props.content,
152
+ (newVal) => {
153
+ if (props.mode === 'normal' && typeof newVal !== 'string') {
154
+ console.error('在“normal”模式下,值类型必须为字符串类型。')
155
+ } else if (props.mode === 'menu' && !isArray(newVal)) {
156
+ console.error('在“menu”模式下,值类型必须是数组类型。')
157
+ }
217
158
  }
218
- },
219
- );
159
+ )
220
160
 
221
161
  watch(
222
- () => props.placement,
223
- (newVal) => {
224
- nextTick(() => {
225
- popover.init(newVal, visibleArrow.value, selector);
226
- });
227
- },
228
- { immediate: true },
229
- );
162
+ () => props.placement,
163
+ (newVal) => {
164
+ nextTick(() => {
165
+ popover.init(newVal, visibleArrow.value, selector)
166
+ })
167
+ },
168
+ { immediate: true }
169
+ )
230
170
 
231
171
  watch(
232
- () => props.modelValue,
233
- (newValue: boolean) => {
234
- showPopover.value = newValue;
235
- },
236
- );
172
+ () => props.modelValue,
173
+ (newValue: boolean) => {
174
+ showPopover.value = newValue
175
+ }
176
+ )
237
177
 
238
178
  watch(
239
- () => showPopover.value,
240
- (newValue) => {
241
- if (newValue) {
242
- popover.control(props.placement, props.offset);
243
- if (queue && queue.closeOther) {
244
- queue.closeOther(proxy);
245
- } else {
246
- closeOther(proxy);
247
- }
179
+ () => showPopover.value,
180
+ (newValue) => {
181
+ if (newValue) {
182
+ popover.control(props.placement, props.offset)
183
+ if (queue && queue.closeOther) {
184
+ queue.closeOther(proxy)
185
+ } else {
186
+ closeOther(proxy)
187
+ }
188
+ }
189
+ popover.showStyle.value = newValue ? 'display: inline-block;' : 'display: none;'
190
+ emit('change', { show: newValue })
191
+ emit(`${newValue ? 'open' : 'close'}`)
248
192
  }
249
- popover.showStyle.value = newValue
250
- ? "display: inline-block;"
251
- : "display: none;";
252
- emit("change", { show: newValue });
253
- emit(`${newValue ? "open" : "close"}`);
254
- },
255
- );
193
+ )
256
194
 
257
195
  // onMounted(() => {
258
196
  // setTimeout(() => {
@@ -261,53 +199,53 @@ watch(
261
199
  // });
262
200
 
263
201
  onBeforeMount(() => {
264
- if (queue && queue.pushToQueue) {
265
- queue.pushToQueue(proxy);
266
- } else {
267
- pushToQueue(proxy);
268
- }
269
- popover.showStyle.value = showPopover.value ? "opacity: 1;" : "opacity: 0;";
270
- });
202
+ if (queue && queue.pushToQueue) {
203
+ queue.pushToQueue(proxy)
204
+ } else {
205
+ pushToQueue(proxy)
206
+ }
207
+ popover.showStyle.value = showPopover.value ? 'opacity: 1;' : 'opacity: 0;'
208
+ })
271
209
 
272
210
  onBeforeUnmount(() => {
273
- if (queue && queue.removeFromQueue) {
274
- queue.removeFromQueue(proxy);
275
- } else {
276
- removeFromQueue(proxy);
277
- }
278
- });
211
+ if (queue && queue.removeFromQueue) {
212
+ queue.removeFromQueue(proxy)
213
+ } else {
214
+ removeFromQueue(proxy)
215
+ }
216
+ })
279
217
 
280
218
  const menuClick = (index: number) => {
281
- updateModelValue(false);
282
- emit("menuClick", {
283
- item: isArray(props.content) ? props.content[index] : props.content,
284
- index,
285
- });
286
- };
219
+ updateModelValue(false)
220
+ emit('menuClick', {
221
+ item: isArray(props.content) ? props.content[index] : props.content,
222
+ index
223
+ })
224
+ }
287
225
 
288
226
  const toggle = () => {
289
- if (props.disabled) return;
290
- updateModelValue(!showPopover.value);
291
- };
227
+ if (props.disabled) return
228
+ updateModelValue(!showPopover.value)
229
+ }
292
230
 
293
231
  const open = () => {
294
- updateModelValue(true);
295
- };
232
+ updateModelValue(true)
233
+ }
296
234
 
297
235
  const close = () => {
298
- updateModelValue(false);
299
- };
236
+ updateModelValue(false)
237
+ }
300
238
 
301
239
  function updateModelValue(value: boolean) {
302
- showPopover.value = value;
303
- emit("update:modelValue", value);
240
+ showPopover.value = value
241
+ emit('update:modelValue', value)
304
242
  }
305
243
 
306
244
  defineExpose<PopoverExpose>({
307
- open,
308
- close,
309
- });
245
+ open,
246
+ close
247
+ })
310
248
  </script>
311
249
  <style lang="scss" scoped>
312
- @import "./index.scss";
250
+ @import './index.scss';
313
251
  </style>