hy-app 0.1.1 → 0.1.3

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 (264) hide show
  1. package/README.md +1 -1
  2. package/api/http.ts +8 -8
  3. package/components/dialog/index.ts +2 -2
  4. package/components/hy-address-picker/hy-address-picker.vue +14 -42
  5. package/components/hy-address-picker/index.scss +27 -0
  6. package/components/hy-address-picker/props.ts +2 -3
  7. package/components/hy-address-picker/typing.d.ts +1 -2
  8. package/components/hy-avatar/hy-avatar.vue +10 -54
  9. package/components/hy-avatar/index.scss +45 -0
  10. package/components/hy-avatar/props.ts +2 -2
  11. package/components/hy-avatar/typing.d.ts +2 -2
  12. package/components/hy-back-top/hy-back-top.vue +7 -22
  13. package/components/hy-back-top/index.scss +16 -0
  14. package/components/hy-back-top/props.ts +4 -4
  15. package/components/hy-back-top/typing.d.ts +2 -3
  16. package/components/hy-badge/hy-badge.vue +5 -75
  17. package/components/hy-badge/index.scss +72 -0
  18. package/components/hy-badge/props.ts +2 -2
  19. package/components/hy-badge/typing.d.ts +2 -2
  20. package/components/hy-button/hy-button.vue +22 -134
  21. package/components/hy-button/index.scss +116 -0
  22. package/components/hy-button/props.ts +4 -5
  23. package/components/hy-button/typing.d.ts +3 -3
  24. package/components/hy-calendar/header.vue +76 -0
  25. package/components/hy-calendar/hy-calendar.vue +366 -0
  26. package/components/hy-calendar/index.scss +171 -0
  27. package/components/hy-calendar/month.vue +524 -0
  28. package/components/hy-calendar/props.ts +37 -0
  29. package/components/hy-calendar/typing.d.ts +126 -0
  30. package/components/hy-card/hy-card.vue +21 -84
  31. package/components/hy-card/index.scss +57 -0
  32. package/components/hy-card/props.ts +2 -2
  33. package/components/hy-card/typing.d.ts +1 -1
  34. package/components/hy-cell/hy-cell.vue +30 -131
  35. package/components/hy-cell/index.scss +137 -0
  36. package/components/hy-cell/props.ts +2 -2
  37. package/components/hy-cell/typing.d.ts +4 -3
  38. package/components/hy-check-button/hy-check-button.vue +14 -7
  39. package/components/hy-check-button/index.scss +5 -0
  40. package/components/hy-check-button/props.ts +3 -3
  41. package/components/hy-checkbox/hy-checkbox.vue +24 -107
  42. package/components/hy-checkbox/index.scss +94 -0
  43. package/components/hy-checkbox/props.ts +4 -5
  44. package/components/hy-checkbox/typing.d.ts +3 -7
  45. package/components/hy-count-down/hy-count-down.vue +150 -0
  46. package/components/hy-count-down/index.scss +6 -0
  47. package/components/hy-count-down/index.ts +52 -0
  48. package/components/hy-count-down/props.ts +10 -0
  49. package/components/hy-count-down/typing.d.ts +20 -0
  50. package/components/hy-count-to/hy-count-to.vue +213 -0
  51. package/components/hy-count-to/index.scss +6 -0
  52. package/components/hy-count-to/props.ts +17 -0
  53. package/components/hy-count-to/typing.d.ts +48 -0
  54. package/components/hy-datetime-picker/hy-datetime-picker.vue +38 -64
  55. package/components/hy-datetime-picker/index.scss +28 -0
  56. package/components/hy-datetime-picker/props.ts +2 -2
  57. package/components/hy-datetime-picker/typing.d.ts +1 -1
  58. package/components/hy-divider/hy-divider.vue +24 -49
  59. package/components/hy-divider/index.scss +25 -0
  60. package/components/hy-divider/props.ts +2 -2
  61. package/components/hy-divider/typing.d.ts +1 -1
  62. package/components/hy-dropdown/hy-dropdown.vue +43 -0
  63. package/components/hy-dropdown/index.scss +17 -0
  64. package/components/hy-dropdown/props.ts +17 -0
  65. package/components/hy-dropdown/typing.d.ts +48 -0
  66. package/components/hy-dropdown-item/hy-dropdown-item.vue +194 -0
  67. package/components/hy-dropdown-item/index.scss +96 -0
  68. package/components/hy-dropdown-item/props.ts +10 -0
  69. package/components/hy-dropdown-item/typing.d.ts +31 -0
  70. package/components/hy-empty/hy-empty.vue +8 -26
  71. package/components/hy-empty/index.scss +19 -0
  72. package/components/hy-empty/props.ts +2 -2
  73. package/components/hy-empty/typing.d.ts +1 -1
  74. package/components/hy-float-button/hy-float-button.vue +201 -0
  75. package/components/hy-float-button/index.scss +69 -0
  76. package/components/hy-float-button/props.ts +25 -0
  77. package/components/hy-float-button/typing.d.ts +93 -0
  78. package/components/hy-folding-panel/hy-folding-panel.vue +9 -12
  79. package/components/hy-folding-panel/index.scss +6 -0
  80. package/components/hy-folding-panel/props.ts +2 -2
  81. package/components/hy-folding-panel/typing.d.ts +2 -2
  82. package/components/hy-form/hy-form.vue +22 -39
  83. package/components/hy-form/index.scss +30 -0
  84. package/components/hy-form/props.ts +4 -2
  85. package/components/hy-form/typing.d.ts +10 -2
  86. package/components/hy-grid/hy-grid.vue +4 -45
  87. package/components/hy-grid/index.scss +40 -0
  88. package/components/hy-grid/props.ts +5 -5
  89. package/components/hy-grid/typing.d.ts +2 -2
  90. package/components/hy-icon/hy-icon.vue +7 -97
  91. package/components/hy-icon/index.scss +84 -0
  92. package/components/hy-icon/props.ts +5 -5
  93. package/components/hy-image/hy-image.vue +212 -0
  94. package/components/hy-image/index.scss +26 -0
  95. package/components/hy-image/props.ts +24 -0
  96. package/components/hy-image/typing.d.ts +76 -0
  97. package/components/hy-input/hy-input.vue +11 -82
  98. package/components/hy-input/index.scss +65 -0
  99. package/components/hy-input/props.ts +2 -2
  100. package/components/hy-input/typing.d.ts +2 -2
  101. package/components/hy-line/hy-line.vue +4 -8
  102. package/components/hy-line/index.scss +5 -0
  103. package/components/hy-line/props.ts +3 -3
  104. package/components/hy-line/typing.d.ts +2 -2
  105. package/components/hy-line-progress/hy-line-progress.vue +15 -44
  106. package/components/hy-line-progress/index.scss +38 -0
  107. package/components/hy-line-progress/props.ts +2 -2
  108. package/components/hy-line-progress/typing.d.ts +1 -1
  109. package/components/hy-list/hy-list.vue +11 -41
  110. package/components/hy-list/index.scss +32 -0
  111. package/components/hy-list/props.ts +2 -2
  112. package/components/hy-loading/hy-loading.vue +95 -0
  113. package/components/hy-loading/index.scss +103 -0
  114. package/components/hy-loading/props.ts +17 -0
  115. package/components/hy-loading/typing.d.ts +52 -0
  116. package/components/hy-login/TheUserLogin.vue +16 -16
  117. package/components/hy-login/hy-login.vue +9 -9
  118. package/components/hy-login/props.ts +4 -4
  119. package/components/hy-modal/hy-modal.vue +11 -89
  120. package/components/hy-modal/index.scss +77 -0
  121. package/components/hy-modal/props.ts +2 -2
  122. package/components/hy-modal/typing.d.ts +1 -1
  123. package/components/hy-navbar/hy-navbar.vue +20 -92
  124. package/components/hy-navbar/index.scss +67 -0
  125. package/components/hy-navbar/props.ts +2 -2
  126. package/components/hy-navbar/typing.d.ts +1 -1
  127. package/components/hy-notice-bar/hy-column-notice.vue +11 -39
  128. package/components/hy-notice-bar/hy-notice-bar.vue +10 -12
  129. package/components/hy-notice-bar/hy-row-notice.vue +5 -56
  130. package/components/hy-notice-bar/index.scss +93 -0
  131. package/components/hy-notice-bar/props.ts +4 -2
  132. package/components/hy-notice-bar/typing.d.ts +13 -3
  133. package/components/hy-number-step/hy-number-step.vue +55 -105
  134. package/components/hy-number-step/index.scss +71 -0
  135. package/components/hy-number-step/props.ts +2 -2
  136. package/components/hy-number-step/typing.d.ts +1 -1
  137. package/components/hy-overlay/hy-overlay.vue +5 -17
  138. package/components/hy-overlay/index.scss +9 -0
  139. package/components/hy-overlay/props.ts +2 -2
  140. package/components/hy-overlay/typing.d.ts +1 -1
  141. package/components/hy-picker/hy-picker.vue +21 -87
  142. package/components/hy-picker/index.scss +68 -0
  143. package/components/hy-picker/props.ts +3 -2
  144. package/components/hy-picker/typing.d.ts +5 -1
  145. package/components/hy-popup/hy-popup.vue +7 -80
  146. package/components/hy-popup/index.scss +60 -0
  147. package/components/hy-popup/props.ts +2 -2
  148. package/components/hy-popup/typing.d.ts +1 -1
  149. package/components/hy-price/hy-price.vue +5 -15
  150. package/components/hy-price/index.scss +11 -0
  151. package/components/hy-price/props.ts +2 -2
  152. package/components/hy-price/typing.d.ts +1 -1
  153. package/components/hy-qrcode/hy-qrcode.vue +15 -37
  154. package/components/hy-qrcode/index.scss +23 -0
  155. package/components/hy-qrcode/props.ts +2 -2
  156. package/components/hy-qrcode/typing.d.ts +2 -2
  157. package/components/hy-radio/hy-radio.vue +27 -113
  158. package/components/hy-radio/index.scss +93 -0
  159. package/components/hy-radio/props.ts +4 -4
  160. package/components/hy-radio/typing.d.ts +2 -2
  161. package/components/hy-rate/hy-rate.vue +33 -53
  162. package/components/hy-rate/index.scss +33 -0
  163. package/components/hy-rate/props.ts +4 -3
  164. package/components/hy-rate/typing.d.ts +1 -1
  165. package/components/hy-read-more/hy-read-more.vue +7 -30
  166. package/components/hy-read-more/index.scss +25 -0
  167. package/components/hy-read-more/props.ts +3 -3
  168. package/components/hy-read-more/typing.d.ts +1 -1
  169. package/components/hy-safe-bottom/hy-safe-bottom.vue +5 -9
  170. package/components/hy-safe-bottom/index.scss +5 -0
  171. package/components/hy-scroll-list/hy-scroll-list.vue +13 -43
  172. package/components/hy-scroll-list/index.scss +34 -0
  173. package/components/hy-scroll-list/props.ts +2 -2
  174. package/components/hy-scroll-list/typing.d.ts +1 -1
  175. package/components/hy-search/hy-search.vue +12 -94
  176. package/components/hy-search/index.scss +83 -0
  177. package/components/hy-search/props.ts +2 -2
  178. package/components/hy-search/typing.d.ts +1 -2
  179. package/components/hy-slider/hy-slider.vue +42 -119
  180. package/components/hy-slider/index.scss +77 -0
  181. package/components/hy-slider/props.ts +2 -2
  182. package/components/hy-status-bar/hy-status-bar.vue +41 -0
  183. package/components/hy-status-bar/index.scss +6 -0
  184. package/components/hy-status-bar/props.ts +8 -0
  185. package/components/hy-status-bar/typing.d.ts +12 -0
  186. package/components/hy-steps/hy-steps.vue +36 -163
  187. package/components/hy-steps/index.scss +131 -0
  188. package/components/hy-steps/props.ts +2 -2
  189. package/components/hy-steps/typing.d.ts +2 -2
  190. package/components/hy-subsection/hy-subsection.vue +62 -125
  191. package/components/hy-subsection/index.scss +82 -0
  192. package/components/hy-subsection/props.ts +7 -3
  193. package/components/hy-subsection/typing.d.ts +20 -8
  194. package/components/hy-swipe-action/hy-swipe-action.vue +294 -0
  195. package/components/hy-swipe-action/index.scss +9 -0
  196. package/components/hy-swipe-action/index.wxs +235 -0
  197. package/components/hy-swipe-action/props.ts +16 -0
  198. package/components/hy-swipe-action/typing.d.ts +55 -0
  199. package/components/hy-swipe-action/wxs.js +15 -0
  200. package/components/hy-swiper/hy-swiper-indicator.vue +5 -35
  201. package/components/hy-swiper/hy-swiper.vue +45 -65
  202. package/components/hy-swiper/index.scss +82 -0
  203. package/components/hy-swiper/props.ts +3 -3
  204. package/components/hy-swiper/typing.d.ts +7 -4
  205. package/components/hy-switch/hy-switch.vue +65 -68
  206. package/components/hy-switch/index.scss +46 -0
  207. package/components/hy-switch/props.ts +6 -3
  208. package/components/hy-switch/typing.d.ts +14 -1
  209. package/components/hy-tabs/hy-tabs.vue +22 -81
  210. package/components/hy-tabs/index.scss +63 -0
  211. package/components/hy-tabs/props.ts +5 -5
  212. package/components/hy-tabs/typing.d.ts +1 -1
  213. package/components/hy-tag/hy-tag.vue +15 -230
  214. package/components/hy-tag/index.scss +204 -0
  215. package/components/hy-tag/props.ts +2 -2
  216. package/components/hy-tag/typing.d.ts +2 -2
  217. package/components/hy-text/hy-text.vue +238 -0
  218. package/components/hy-text/index.scss +70 -0
  219. package/components/hy-text/index.ts +0 -0
  220. package/components/hy-text/props.ts +30 -0
  221. package/components/hy-text/typing.d.ts +98 -0
  222. package/components/hy-textarea/hy-textarea.vue +13 -51
  223. package/components/hy-textarea/index.scss +40 -0
  224. package/components/hy-textarea/props.ts +2 -2
  225. package/components/hy-textarea/typing.d.ts +1 -1
  226. package/components/hy-tooltip/hy-tooltip.vue +42 -95
  227. package/components/hy-tooltip/index.scss +64 -0
  228. package/components/hy-tooltip/props.ts +2 -2
  229. package/components/hy-tooltip/typing.d.ts +1 -1
  230. package/components/hy-transition/hy-transition.vue +17 -8
  231. package/components/hy-transition/props.ts +2 -2
  232. package/components/hy-transition/typing.d.ts +2 -14
  233. package/components/hy-upload/hy-upload.vue +37 -182
  234. package/components/hy-upload/index.scss +147 -0
  235. package/components/hy-upload/props.ts +2 -2
  236. package/components/hy-upload/typing.d.ts +11 -11
  237. package/components/hy-warn/hy-warn.vue +15 -123
  238. package/components/hy-warn/index.scss +109 -0
  239. package/components/hy-warn/props.ts +3 -3
  240. package/components/hy-warn/typing.d.ts +4 -3
  241. package/components/hy-waterfall/index.scss +82 -0
  242. package/components/index.ts +25 -1
  243. package/components/message/index.ts +54 -54
  244. package/config/color.ts +2 -1
  245. package/global/index.ts +6 -6
  246. package/global/register-properties.ts +2 -2
  247. package/index.scss +2 -0
  248. package/libs/css/common.scss +16 -0
  249. package/package.json +4 -4
  250. package/{libs/css → public/font}/iconfont.css +5 -5
  251. package/{libs/css → public/font}/iconfont.ttf +0 -0
  252. package/public/font/iconfont.woff +0 -0
  253. package/public/font/iconfont.woff2 +0 -0
  254. package/theme.scss +9 -7
  255. package/typing/index.ts +0 -1
  256. package/typing/modules/common.d.ts +66 -1
  257. package/typing/modules/form.ts +3 -3
  258. package/utils/calendar.js +1021 -0
  259. package/utils/colorGradient.ts +112 -0
  260. package/utils/index.ts +2 -0
  261. package/utils/inside.ts +80 -34
  262. package/utils/inspect.ts +66 -0
  263. package/utils/utils.ts +27 -19
  264. package/typing/modules/img.ts +0 -15
@@ -0,0 +1,213 @@
1
+ <template>
2
+ <text
3
+ class="hy-count-num"
4
+ :style="{
5
+ fontSize: addUnit(fontSize),
6
+ fontWeight: bold ? 'bold' : 'normal',
7
+ color: color,
8
+ }"
9
+ >{{ displayValue }}</text
10
+ >
11
+ </template>
12
+
13
+ <script setup lang="ts">
14
+ import type IProps from "./typing";
15
+ import defaultProps from "./props";
16
+ import { computed, onMounted, onUnmounted, ref, toRefs, watch } from "vue";
17
+ import { addUnit, isNumber } from "../../utils";
18
+
19
+ const props = withDefaults(defineProps<IProps>(), defaultProps);
20
+ const {
21
+ startVal,
22
+ duration,
23
+ endVal,
24
+ autoplay,
25
+ separator,
26
+ useEasing,
27
+ decimals,
28
+ decimal,
29
+ } = toRefs(props);
30
+ const emit = defineEmits(["end"]);
31
+
32
+ const formatNumber = (num: number): string => {
33
+ let numStr = "";
34
+ // 将num转为Number类型,因为其值可能为字符串数值,调用toFixed会报错
35
+ num = Number(num);
36
+ numStr = num.toFixed(Number(decimals.value));
37
+ numStr += "";
38
+ const x = numStr.split(".");
39
+ let x1 = x[0];
40
+ const x2 = x.length > 1 ? decimal.value + x[1] : "";
41
+ const rgx = /(\d+)(\d{3})/;
42
+ if (separator.value && !isNumber(separator.value)) {
43
+ while (rgx.test(x1)) {
44
+ x1 = x1.replace(rgx, "$1" + separator.value + "$2");
45
+ }
46
+ }
47
+ return x1 + x2;
48
+ };
49
+
50
+ const localStartVal = ref(startVal.value);
51
+ let displayValue = ref(formatNumber(startVal.value));
52
+ const printVal = ref<number | null>(null);
53
+ const paused = ref(false); // 是否暂停
54
+ const localDuration = ref(Number(duration.value));
55
+ const startTime = ref<number | null>(null); // 开始的时间
56
+ const timestamp = ref<number | null>(null); // 时间戳
57
+ const remaining = ref<number | null>(null); // 停留的时间
58
+ const rAF = ref<number>(); // 停留的时间
59
+ const lastTime = ref(0); // 上一次的时间
60
+
61
+ const countDown = computed(() => {
62
+ return startVal.value > endVal.value;
63
+ });
64
+
65
+ watch(
66
+ () => startVal.value,
67
+ () => autoplay.value && start(),
68
+ );
69
+
70
+ watch(
71
+ () => endVal.value,
72
+ () => autoplay.value && start(),
73
+ );
74
+
75
+ onMounted(() => {
76
+ autoplay.value && start();
77
+ });
78
+
79
+ const easingFn = (t: number, b: number, c: number, d: number) => {
80
+ return (c * (-Math.pow(2, (-10 * t) / d) + 1) * 1024) / 1023 + b;
81
+ };
82
+
83
+ const requestAnimationFrame = (callback: Function): number => {
84
+ const currTime = new Date().getTime();
85
+ // 为了使setTimteout的尽可能的接近每秒60帧的效果
86
+ const timeToCall = Math.max(0, 16 - (currTime - lastTime.value));
87
+ const id = setTimeout(() => {
88
+ callback(currTime + timeToCall);
89
+ }, timeToCall) as unknown as number;
90
+ lastTime.value = currTime + timeToCall;
91
+ return id;
92
+ };
93
+
94
+ const cancelAnimationFrame = (id?: number) => {
95
+ clearTimeout(id);
96
+ };
97
+
98
+ /**
99
+ * @description 开始滚动数字
100
+ * */
101
+ const start = () => {
102
+ localStartVal.value = startVal.value;
103
+ startTime.value = null;
104
+ localDuration.value = duration.value;
105
+ paused.value = false;
106
+ rAF.value = requestAnimationFrame(count);
107
+ };
108
+
109
+ /**
110
+ * @description 暂定状态,重新再开始滚动;或者滚动状态下,暂停
111
+ * */
112
+ const reStart = () => {
113
+ if (paused.value) {
114
+ resume();
115
+ paused.value = false;
116
+ } else {
117
+ stop();
118
+ paused.value = true;
119
+ }
120
+ };
121
+
122
+ /**
123
+ * @description 暂停
124
+ * */
125
+ const stop = () => {
126
+ cancelAnimationFrame(rAF.value);
127
+ };
128
+
129
+ /**
130
+ * @description 重新开始(暂停的情况下)
131
+ * */
132
+ const resume = () => {
133
+ if (!remaining.value) return;
134
+ startTime.value = 0;
135
+ localDuration.value = remaining.value;
136
+ if (printVal.value) {
137
+ localStartVal.value = printVal.value;
138
+ }
139
+ requestAnimationFrame(count);
140
+ };
141
+
142
+ /**
143
+ * @description 重置
144
+ * */
145
+ const reset = () => {
146
+ startTime.value = null;
147
+ cancelAnimationFrame(rAF.value);
148
+ displayValue.value = formatNumber(startVal.value);
149
+ };
150
+ const count = (time_stamp: number) => {
151
+ if (!startTime.value) startTime.value = time_stamp;
152
+ timestamp.value = time_stamp;
153
+ const progress = time_stamp - startTime.value;
154
+ remaining.value = localDuration.value - progress;
155
+ if (useEasing.value) {
156
+ if (countDown.value) {
157
+ printVal.value =
158
+ localStartVal.value -
159
+ easingFn(
160
+ progress,
161
+ 0,
162
+ localStartVal.value - endVal.value,
163
+ localDuration.value,
164
+ );
165
+ } else {
166
+ printVal.value = easingFn(
167
+ progress,
168
+ localStartVal.value,
169
+ endVal.value - localStartVal.value,
170
+ localDuration.value,
171
+ );
172
+ }
173
+ } else {
174
+ if (countDown.value) {
175
+ printVal.value =
176
+ localStartVal.value -
177
+ (localStartVal.value - endVal.value) * (progress / localDuration.value);
178
+ } else {
179
+ printVal.value =
180
+ localStartVal.value +
181
+ (endVal.value - localStartVal.value) * (progress / localDuration.value);
182
+ }
183
+ }
184
+ if (countDown.value) {
185
+ printVal.value =
186
+ printVal.value < endVal.value ? endVal.value : printVal.value;
187
+ } else {
188
+ printVal.value =
189
+ printVal.value > endVal.value ? endVal.value : printVal.value;
190
+ }
191
+ displayValue.value = formatNumber(printVal.value);
192
+ if (progress < localDuration.value) {
193
+ rAF.value = requestAnimationFrame(count);
194
+ } else {
195
+ emit("end");
196
+ }
197
+ };
198
+
199
+ const destroyed = () => {
200
+ cancelAnimationFrame(rAF.value);
201
+ };
202
+
203
+ defineExpose({
204
+ start,
205
+ stop,
206
+ reStart,
207
+ resume,
208
+ });
209
+ </script>
210
+
211
+ <style scoped lang="scss">
212
+ @import "./index.scss";
213
+ </style>
@@ -0,0 +1,6 @@
1
+ .hy-count-num {
2
+ /* #ifndef APP-NVUE */
3
+ display: inline-flex;
4
+ /* #endif */
5
+ text-align: center;
6
+ }
@@ -0,0 +1,17 @@
1
+ import type IProps from "./typing";
2
+
3
+ const defaultProps: IProps = {
4
+ startVal: 0,
5
+ endVal: 0,
6
+ duration: 2000,
7
+ autoplay: true,
8
+ decimals: 0,
9
+ useEasing: true,
10
+ decimal: ".",
11
+ color: "#606266",
12
+ fontSize: 22,
13
+ bold: false,
14
+ separator: "",
15
+ };
16
+
17
+ export default defaultProps;
@@ -0,0 +1,48 @@
1
+ import type { CSSProperties } from "vue";
2
+
3
+ export default interface IProps {
4
+ /**
5
+ * @description 开始的数值,默认从0增长到某一个数(默认 0 )
6
+ * */
7
+ startVal?: number;
8
+ /**
9
+ * @description 要滚动的目标数值,必须 (默认 0 )
10
+ * */
11
+ endVal?: number;
12
+ /**
13
+ * @description 滚动到目标数值的动画持续时间,单位为毫秒(ms) (默认
14
+ * */
15
+ duration?: number;
16
+ /**
17
+ * @description 设置数值后是否自动开始滚动 (默认 true )
18
+ * */
19
+ autoplay?: boolean;
20
+ /**
21
+ * @description 要显示的小数位数,见官网说明(默认 0 )
22
+ * */
23
+ decimals?: number;
24
+ /**
25
+ * @description 滚动结束时,是否缓动结尾,见官网说明(默认 true )
26
+ * */
27
+ useEasing?: boolean;
28
+ /**
29
+ * @description 十进制分割 ( 默认 "." )
30
+ * */
31
+ decimal?: string;
32
+ /**
33
+ * @description 字体颜色( 默认 '#606266' )
34
+ * */
35
+ color?: string;
36
+ /**
37
+ * @description 字体大小,单位px( 默认 22 )
38
+ * */
39
+ fontSize?: number | string;
40
+ /**
41
+ * @description 字体是否加粗(默认 false )
42
+ * */
43
+ bold?: boolean;
44
+ /**
45
+ * @description 千位分隔符,见官网说明
46
+ * */
47
+ separator?: string;
48
+ }
@@ -8,7 +8,7 @@
8
8
  <slot name="trigger" :value="inputValue">
9
9
  <HyInput
10
10
  :placeholder="placeholder"
11
- :readonly="!!showByClickInput"
11
+ :readonly="true"
12
12
  v-model="inputValue"
13
13
  :disabled="disabled"
14
14
  :disabledColor="disabledColor"
@@ -55,7 +55,7 @@
55
55
  <script setup lang="ts">
56
56
  import { computed, onMounted, ref, toRefs, watch } from "vue";
57
57
  import defaultProps from "./props";
58
- import IProps from "./typing";
58
+ import type IProps from "./typing";
59
59
  import dayjs from "dayjs/esm";
60
60
  import { error, padZero } from "../../utils";
61
61
  import { DateModeEnum } from "../../typing";
@@ -79,14 +79,14 @@ const {
79
79
  minHour,
80
80
  maxHour,
81
81
  minMinute,
82
- maxMinute
82
+ maxMinute,
83
83
  } = toRefs(props);
84
84
  const emit = defineEmits([
85
85
  "close",
86
86
  "cancel",
87
87
  "confirm",
88
88
  "change",
89
- "update:modelValue"
89
+ "update:modelValue",
90
90
  ]);
91
91
 
92
92
  // 原来的日期选择器不方便,这里增加一个hasInput选项支持类似element的自带输入框的功能。
@@ -100,7 +100,7 @@ const validModes = new Set([
100
100
  DateModeEnum.TIME,
101
101
  DateModeEnum.MONTH_DAY,
102
102
  DateModeEnum.HOUR_MINUTE,
103
- DateModeEnum.MINUTE_SECOND
103
+ DateModeEnum.MINUTE_SECOND,
104
104
  ]);
105
105
 
106
106
  /**
@@ -110,7 +110,7 @@ const updateColumns = () => {
110
110
  const formatterFn = formatter.value || innerFormatter;
111
111
  // 获取各列的值,并且map后,对各列的具体值进行补0操作
112
112
  columns.value = getOriginColumns().map((column) =>
113
- column.values.map((value) => formatterFn(column.type, value))
113
+ column.values.map((value) => formatterFn(column.type, value)),
114
114
  );
115
115
  };
116
116
 
@@ -122,7 +122,7 @@ const updateColumnValue = (value: string | number) => {
122
122
  updateColumns();
123
123
  // 延迟执行,等待u-picker组件列数据更新完后再设置选中值索引
124
124
  setTimeout(() => {
125
- updateIndexs(value);
125
+ updateIndexes(value);
126
126
  }, 100);
127
127
  };
128
128
 
@@ -142,12 +142,12 @@ watch(
142
142
  if (newValue) {
143
143
  updateColumnValue(innerValue.value);
144
144
  }
145
- }
145
+ },
146
146
  );
147
147
 
148
148
  watch(
149
149
  () => modelValue.value,
150
- () => init()
150
+ () => init(),
151
151
  );
152
152
 
153
153
  const propsChange = computed(() => {
@@ -159,13 +159,13 @@ const propsChange = computed(() => {
159
159
  maxHour.value,
160
160
  minMinute.value,
161
161
  maxMinute.value,
162
- filter.value
162
+ filter.value,
163
163
  ];
164
164
  });
165
165
 
166
166
  watch(
167
167
  () => propsChange.value,
168
- () => init()
168
+ () => init(),
169
169
  );
170
170
 
171
171
  onMounted(() => {
@@ -254,7 +254,7 @@ const confirm = () => {
254
254
  }
255
255
  emit("confirm", {
256
256
  value: innerValue.value,
257
- mode: mode.value
257
+ mode: mode.value,
258
258
  });
259
259
  };
260
260
 
@@ -287,12 +287,12 @@ const change = (e: any) => {
287
287
  if (validModes.has(mode.value) && mode.value !== DateModeEnum.MONTH_DAY) {
288
288
  // 根据value各列索引,从各列数组中,取出当前时间的选中值
289
289
  selectValue = `${intercept(values[0][indexs[0]])}:${intercept(
290
- values[1][indexs[1]]
290
+ values[1][indexs[1]],
291
291
  )}`;
292
292
  } else if (mode.value === DateModeEnum.MONTH_DAY) {
293
293
  // 根据value各列索引,从各列数组中,取出当前时间的选中值
294
294
  selectValue = `${intercept(values[0][indexs[0]])}-${intercept(
295
- values[1][indexs[1]]
295
+ values[1][indexs[1]],
296
296
  )}`;
297
297
  } else {
298
298
  // 将选择的值转为数值,比如'03'转为数值的3,'2019'转为数值的2019
@@ -325,15 +325,15 @@ const change = (e: any) => {
325
325
  // 微信小程序不能传递this实例,会因为循环引用而报错
326
326
  // picker: this.$refs.picker,
327
327
  // #endif
328
- mode: mode.value
328
+ mode: mode.value,
329
329
  });
330
330
  };
331
331
 
332
332
  /**
333
333
  * @description 更新索引
334
334
  * */
335
- const updateIndexs = (value: number | string) => {
336
- let values = [];
335
+ const updateIndexes = (value: number | string) => {
336
+ let values: string[] = [];
337
337
  let timeArr: string[] = [];
338
338
  const formatterFn = formatter.value || innerFormatter;
339
339
 
@@ -343,7 +343,7 @@ const updateIndexs = (value: number | string) => {
343
343
  // 使用formatter格式化方法进行管道处理
344
344
  values = [
345
345
  formatterFn("hour", timeArr[0]),
346
- formatterFn("minute", timeArr[1])
346
+ formatterFn("minute", timeArr[1]),
347
347
  ];
348
348
  break;
349
349
  case DateModeEnum.MONTH_DAY:
@@ -351,7 +351,7 @@ const updateIndexs = (value: number | string) => {
351
351
  // 使用formatter格式化方法进行管道处理
352
352
  values = [
353
353
  formatterFn("month", timeArr[0]),
354
- formatterFn("day", timeArr[1])
354
+ formatterFn("day", timeArr[1]),
355
355
  ];
356
356
  break;
357
357
  case DateModeEnum.HOUR_MINUTE:
@@ -359,7 +359,7 @@ const updateIndexs = (value: number | string) => {
359
359
  // 使用formatter格式化方法进行管道处理
360
360
  values = [
361
361
  formatterFn("hour", timeArr[0]),
362
- formatterFn("minute", timeArr[1])
362
+ formatterFn("minute", timeArr[1]),
363
363
  ];
364
364
  break;
365
365
  case DateModeEnum.MINUTE_SECOND:
@@ -367,14 +367,14 @@ const updateIndexs = (value: number | string) => {
367
367
  // 使用formatter格式化方法进行管道处理
368
368
  values = [
369
369
  formatterFn("minute", timeArr[0]),
370
- formatterFn("second", timeArr[1])
370
+ formatterFn("second", timeArr[1]),
371
371
  ];
372
372
  break;
373
373
  default:
374
374
  values = [
375
375
  formatterFn("year", `${dayjs(value).year()}`),
376
376
  // 月份补0
377
- formatterFn("month", padZero(dayjs(value).month() + 1))
377
+ formatterFn("month", padZero(dayjs(value).month() + 1)),
378
378
  ];
379
379
  if (mode.value === DateModeEnum.DATE) {
380
380
  // date模式,需要添加天列
@@ -386,7 +386,7 @@ const updateIndexs = (value: number | string) => {
386
386
  formatterFn("day", padZero(dayjs(value).date())),
387
387
  formatterFn("hour", padZero(dayjs(value).hour())),
388
388
  formatterFn("minute", padZero(dayjs(value).minute())),
389
- formatterFn("second", padZero(dayjs(value).second()))
389
+ formatterFn("second", padZero(dayjs(value).second())),
390
390
  );
391
391
  }
392
392
  break;
@@ -396,7 +396,7 @@ const updateIndexs = (value: number | string) => {
396
396
  // 通过取大值,可以保证不会出现找不到索引的"-1"情况
397
397
  return Math.max(
398
398
  0,
399
- column.findIndex((item: string) => item === values[index])
399
+ column.findIndex((item: string) => item === values[index]),
400
400
  );
401
401
  });
402
402
  };
@@ -456,47 +456,47 @@ const getRanges = () => {
456
456
  return [
457
457
  {
458
458
  type: "hour",
459
- range: [props.minHour, props.maxHour]
459
+ range: [props.minHour, props.maxHour],
460
460
  },
461
461
  {
462
462
  type: "minute",
463
- range: [props.minMinute, props.maxMinute]
464
- }
463
+ range: [props.minMinute, props.maxMinute],
464
+ },
465
465
  ];
466
466
  }
467
467
  const { maxYear, maxDate, maxMonth, maxHour, maxMinute } = getBoundary(
468
468
  "max",
469
- innerValue.value
469
+ innerValue.value,
470
470
  );
471
471
  const { minYear, minDate, minMonth, minHour, minMinute } = getBoundary(
472
472
  "min",
473
- innerValue.value
473
+ innerValue.value,
474
474
  );
475
475
  const result = [
476
476
  {
477
477
  type: "year",
478
- range: [minYear, maxYear]
478
+ range: [minYear, maxYear],
479
479
  },
480
480
  {
481
481
  type: "month",
482
- range: [minMonth, maxMonth]
482
+ range: [minMonth, maxMonth],
483
483
  },
484
484
  {
485
485
  type: "day",
486
- range: [minDate, maxDate]
486
+ range: [minDate, maxDate],
487
487
  },
488
488
  {
489
489
  type: "hour",
490
- range: [minHour, maxHour]
490
+ range: [minHour, maxHour],
491
491
  },
492
492
  {
493
493
  type: "minute",
494
- range: [minMinute, maxMinute]
494
+ range: [minMinute, maxMinute],
495
495
  },
496
496
  {
497
497
  type: "second",
498
- range: [minMinute, maxMinute]
499
- }
498
+ range: [minMinute, maxMinute],
499
+ },
500
500
  ];
501
501
  let arr = result;
502
502
  // 截取对应的列数
@@ -543,7 +543,7 @@ const getBoundary = (type: string, innerVal: string | number) => {
543
543
  [`${type}Month`]: month,
544
544
  [`${type}Date`]: date,
545
545
  [`${type}Hour`]: hour,
546
- [`${type}Minute`]: minute
546
+ [`${type}Minute`]: minute,
547
547
  };
548
548
  };
549
549
  const onShowByClickInput = () => {
@@ -554,31 +554,5 @@ const onShowByClickInput = () => {
554
554
  </script>
555
555
 
556
556
  <style lang="scss" scoped>
557
- @import "../../libs/css/mixin.scss";
558
- .hy-datetime-picker {
559
- flex: 1;
560
- &__has-input {
561
- position: relative;
562
- display: flex;
563
- flex-direction: column;
564
- justify-content: center;
565
- /* #ifndef APP-NVUE */
566
- width: 100%;
567
- /* #endif */
568
- .input-cover {
569
- opacity: 0;
570
- position: absolute;
571
- top: 0;
572
- bottom: 0;
573
- left: 0;
574
- right: 0;
575
- display: flex;
576
- flex-direction: column;
577
- justify-content: center;
578
- border-radius: 4px;
579
- border: 1px solid #eee;
580
- padding: 0 10px;
581
- }
582
- }
583
- }
557
+ @import "./index.scss";
584
558
  </style>
@@ -0,0 +1,28 @@
1
+ @use "../../libs/css/mixin.scss" as *;
2
+
3
+ .hy-datetime-picker {
4
+ flex: 1;
5
+ &__has-input {
6
+ position: relative;
7
+ display: flex;
8
+ flex-direction: column;
9
+ justify-content: center;
10
+ /* #ifndef APP-NVUE */
11
+ width: 100%;
12
+ /* #endif */
13
+ .input-cover {
14
+ opacity: 0;
15
+ position: absolute;
16
+ top: 0;
17
+ bottom: 0;
18
+ left: 0;
19
+ right: 0;
20
+ display: flex;
21
+ flex-direction: column;
22
+ justify-content: center;
23
+ border-radius: 4px;
24
+ border: 1px solid #eee;
25
+ padding: 0 10px;
26
+ }
27
+ }
28
+ }
@@ -1,4 +1,4 @@
1
- import IProps from "./typing";
1
+ import type IProps from "./typing";
2
2
  import { DateModeEnum } from "../../typing";
3
3
 
4
4
  const defaultProps: IProps = {
@@ -30,7 +30,7 @@ const defaultProps: IProps = {
30
30
  format: "",
31
31
  placeholder: "请选择日期",
32
32
  disabledColor: "#F5F5F5",
33
- toolbarRightSlot: false
33
+ toolbarRightSlot: false,
34
34
  };
35
35
 
36
36
  export default defaultProps;
@@ -1,5 +1,5 @@
1
1
  import { DateModeEnum } from "../../typing";
2
- import { CSSProperties } from "vue";
2
+ import type { CSSProperties } from "vue";
3
3
 
4
4
  export default interface IProps {
5
5
  /**