@zfqh/uview-x 0.0.0-stage → 0.0.1

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 (93) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/LICENSE +21 -0
  3. package/README.md +127 -3
  4. package/components/uv-badge/props.ts +83 -0
  5. package/components/uv-badge/uv-badge.vue +186 -0
  6. package/components/uv-button/props.ts +148 -0
  7. package/components/uv-button/uv-button.vue +565 -0
  8. package/components/uv-checkbox/props.ts +83 -0
  9. package/components/uv-checkbox/uv-checkbox.vue +403 -0
  10. package/components/uv-checkbox-group/props.ts +97 -0
  11. package/components/uv-checkbox-group/uv-checkbox-group.vue +163 -0
  12. package/components/uv-code/props.ts +48 -0
  13. package/components/uv-code/uv-code.vue +156 -0
  14. package/components/uv-dialog/props.ts +56 -0
  15. package/components/uv-dialog/uv-dialog.vue +492 -0
  16. package/components/uv-form/props.ts +59 -0
  17. package/components/uv-form/uv-form.vue +256 -0
  18. package/components/uv-form/valid.ts +1344 -0
  19. package/components/uv-form-item/props.ts +62 -0
  20. package/components/uv-form-item/uv-form-item.vue +335 -0
  21. package/components/uv-icon/icons.ts +161 -0
  22. package/components/uv-icon/props.ts +91 -0
  23. package/components/uv-icon/uv-icon.vue +204 -0
  24. package/components/uv-icon/uvicons.ttf +0 -0
  25. package/components/uv-input/props.ts +185 -0
  26. package/components/uv-input/uv-input.vue +431 -0
  27. package/components/uv-line/props.ts +42 -0
  28. package/components/uv-line/uv-line.vue +75 -0
  29. package/components/uv-line-progress/props.ts +43 -0
  30. package/components/uv-line-progress/uv-line-progress.vue +166 -0
  31. package/components/uv-loading-icon/props.ts +78 -0
  32. package/components/uv-loading-icon/uv-loading-icon.vue +226 -0
  33. package/components/uv-overlay/props.ts +38 -0
  34. package/components/uv-overlay/uv-overlay.vue +120 -0
  35. package/components/uv-popup/props.ts +101 -0
  36. package/components/uv-popup/uv-popup.vue +371 -0
  37. package/components/uv-safe-bottom/props.ts +18 -0
  38. package/components/uv-safe-bottom/uv-safe-bottom.vue +120 -0
  39. package/components/uv-status-bar/props.ts +22 -0
  40. package/components/uv-status-bar/uv-status-bar.vue +121 -0
  41. package/components/uv-tabs/props.ts +84 -0
  42. package/components/uv-tabs/uv-tabs.vue +432 -0
  43. package/components/uv-transition/props.ts +38 -0
  44. package/components/uv-transition/uv-transition.vue +170 -0
  45. package/hooks/index.ts +5 -0
  46. package/hooks/useDebounce.ts +35 -0
  47. package/hooks/useI18n.ts +95 -0
  48. package/hooks/useThrottle.ts +38 -0
  49. package/index.ts +23 -0
  50. package/libs/dayjs/index.ts +217 -0
  51. package/libs/index.ts +4 -0
  52. package/libs/luch-request/adapters/index.ts +133 -0
  53. package/libs/luch-request/core/InterceptorManager.ts +52 -0
  54. package/libs/luch-request/core/Request.ts +202 -0
  55. package/libs/luch-request/core/buildFullPath.ts +21 -0
  56. package/libs/luch-request/core/defaults.ts +34 -0
  57. package/libs/luch-request/core/dispatchRequest.ts +7 -0
  58. package/libs/luch-request/core/mergeConfig.ts +127 -0
  59. package/libs/luch-request/core/settle.ts +17 -0
  60. package/libs/luch-request/helpers/buildURL.ts +65 -0
  61. package/libs/luch-request/helpers/combineURLs.ts +15 -0
  62. package/libs/luch-request/helpers/isAbsoluteURL.ts +15 -0
  63. package/libs/luch-request/index.d.ts +197 -0
  64. package/libs/luch-request/index.ts +3 -0
  65. package/libs/luch-request/utils/clone.ts +265 -0
  66. package/libs/luch-request/utils.ts +136 -0
  67. package/locales/en.ts +78 -0
  68. package/locales/index.ts +169 -0
  69. package/locales/zh-Hans.ts +78 -0
  70. package/package.json +42 -4
  71. package/styles/color.scss +33 -0
  72. package/styles/common.scss +134 -0
  73. package/styles/components.scss +19 -0
  74. package/styles/index.scss +7 -0
  75. package/styles/theme.scss +44 -0
  76. package/styles/var.module.scss +32 -0
  77. package/styles/vue.scss +39 -0
  78. package/theme.scss +2 -0
  79. package/types/index.d.ts +66 -0
  80. package/utils/colorGradient.ts +139 -0
  81. package/utils/compat.ts +165 -0
  82. package/utils/compress.ts +34 -0
  83. package/utils/config.ts +95 -0
  84. package/utils/debounce.ts +7 -0
  85. package/utils/digit.ts +157 -0
  86. package/utils/function.ts +771 -0
  87. package/utils/http.ts +5 -0
  88. package/utils/index.ts +57 -0
  89. package/utils/locale.ts +296 -0
  90. package/utils/platform.ts +71 -0
  91. package/utils/route.ts +142 -0
  92. package/utils/test.ts +256 -0
  93. package/utils/throttle.ts +7 -0
package/utils/test.ts ADDED
@@ -0,0 +1,256 @@
1
+ /**
2
+ * 验证电子邮箱格式
3
+ */
4
+ export function email(value: string): boolean {
5
+ return /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/.test(value)
6
+ }
7
+
8
+ /**
9
+ * 验证手机格式
10
+ */
11
+ export function mobile(value: string): boolean {
12
+ return /^1([3589]\d|4[5-9]|6[1-2,4-7]|7[0-8])\d{8}$/.test(value)
13
+ }
14
+
15
+ /**
16
+ * 验证URL格式
17
+ */
18
+ export function url(value: string): boolean {
19
+ return /^((https|http|ftp|rtsp|mms):\/\/)(([0-9a-zA-Z_!~*'().&=+$%-]+: )?[0-9a-zA-Z_!~*'().&=+$%-]+@)?(([0-9]{1,3}.){3}[0-9]{1,3}|([0-9a-zA-Z_!~*'()-]+.)*([0-9a-zA-Z][0-9a-zA-Z-]{0,61})?[0-9a-zA-Z].[a-zA-Z]{2,6})(:[0-9]{1,4})?((\/?)|(\/[0-9a-zA-Z_!~*'().;?:@&=+$,%#-]+)+\/?)$/
20
+ .test(value)
21
+ }
22
+
23
+ /**
24
+ * 验证日期格式
25
+ */
26
+ export function date(value: string | number | Date): boolean {
27
+ if (!value) return false
28
+ // 判断是否数值或者字符串数值(意味着为时间戳),转为数值,否则new Date无法识别字符串时间戳
29
+ if (typeof value !== 'object' && number(value)) value = +value
30
+ return !/Invalid|NaN/.test(new Date(value).toString())
31
+ }
32
+
33
+ /**
34
+ * 验证ISO类型的日期格式
35
+ */
36
+ export function dateISO(value: string): boolean {
37
+ return /^\d{4}[\/\-](0?[1-9]|1[012])[\/\-](0?[1-9]|[12][0-9]|3[01])$/.test(value)
38
+ }
39
+
40
+ /**
41
+ * 验证十进制数字
42
+ */
43
+ export function number(value: string | number): boolean {
44
+ return /^[\+-]?(\d+\.?\d*|\.\d+|\d\.\d+e\+\d+)$/.test(String(value))
45
+ }
46
+
47
+ /**
48
+ * 验证字符串
49
+ */
50
+ export function string(value: unknown): value is string {
51
+ return typeof value === 'string'
52
+ }
53
+
54
+ /**
55
+ * 验证整数
56
+ */
57
+ export function digits(value: string): boolean {
58
+ return /^\d+$/.test(value)
59
+ }
60
+
61
+ /**
62
+ * 验证身份证号码
63
+ */
64
+ export function idCard(value: string): boolean {
65
+ return /^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test(
66
+ value
67
+ )
68
+ }
69
+
70
+ /**
71
+ * 是否车牌号
72
+ */
73
+ export function carNo(value: string): boolean {
74
+ // 新能源车牌
75
+ const xreg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}(([0-9]{5}[DF]$)|([DF][A-HJ-NP-Z0-9][0-9]{4}$))/
76
+ // 旧车牌
77
+ const creg = /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-HJ-NP-Z0-9]{4}[A-HJ-NP-Z0-9挂学警港澳]{1}$/
78
+ if (value.length === 7) {
79
+ return creg.test(value)
80
+ } if (value.length === 8) {
81
+ return xreg.test(value)
82
+ }
83
+ return false
84
+ }
85
+
86
+ /**
87
+ * 金额,只允许2位小数
88
+ */
89
+ export function amount(value: string): boolean {
90
+ // 金额,只允许保留两位小数
91
+ return /^[1-9]\d*(,\d{3})*(\.\d{1,2})?$|^0\.\d{1,2}$/.test(value)
92
+ }
93
+
94
+ /**
95
+ * 中文
96
+ */
97
+ export function chinese(value: string): boolean {
98
+ const reg = /^[\u4e00-\u9fa5]+$/gi
99
+ return reg.test(value)
100
+ }
101
+
102
+ /**
103
+ * 只能输入字母
104
+ */
105
+ export function letter(value: string): boolean {
106
+ return /^[a-zA-Z]*$/.test(value)
107
+ }
108
+
109
+ /**
110
+ * 只能是字母或者数字
111
+ */
112
+ export function enOrNum(value: string): boolean {
113
+ // 英文或者数字
114
+ const reg = /^[0-9a-zA-Z]*$/g
115
+ return reg.test(value)
116
+ }
117
+
118
+ /**
119
+ * 验证是否包含某个值
120
+ */
121
+ export function contains(value: string | any[], param: any): boolean {
122
+ return value.indexOf(param) >= 0
123
+ }
124
+
125
+ /**
126
+ * 验证一个值范围[min, max]
127
+ */
128
+ export function range(value: number, param: readonly [number, number]): boolean {
129
+ return value >= param[0] && value <= param[1]
130
+ }
131
+
132
+ /**
133
+ * 验证一个长度范围[min, max]
134
+ */
135
+ export function rangeLength(value: string | any[], param: readonly [number, number]): boolean {
136
+ return value.length >= param[0] && value.length <= param[1]
137
+ }
138
+
139
+ /**
140
+ * 是否固定电话
141
+ */
142
+ export function landline(value: string): boolean {
143
+ const reg = /^\d{3,4}-\d{7,8}(-\d{3,4})?$/
144
+ return reg.test(value)
145
+ }
146
+
147
+ /**
148
+ * 判断是否为空
149
+ */
150
+ export function empty(value: unknown): boolean {
151
+ switch (typeof value) {
152
+ case 'undefined':
153
+ return true
154
+ case 'string':
155
+ if (value.replace(/(^[ \t\n\r]*)|([ \t\n\r]*$)/g, '').length == 0) return true
156
+ break
157
+ case 'boolean':
158
+ if (!value) return true
159
+ break
160
+ case 'number':
161
+ if (value === 0 || isNaN(value)) return true
162
+ break
163
+ case 'object':
164
+ if (value === null || (value as any).length === 0) return true
165
+ for (const i in value) {
166
+ return false
167
+ }
168
+ return true
169
+ }
170
+ return false
171
+ }
172
+
173
+ /**
174
+ * 是否json字符串
175
+ */
176
+ export function jsonString(value: unknown): boolean {
177
+ if (typeof value === 'string') {
178
+ try {
179
+ const obj = JSON.parse(value)
180
+ if (typeof obj === 'object' && obj) {
181
+ return true
182
+ }
183
+ return false
184
+ } catch (e) {
185
+ return false
186
+ }
187
+ }
188
+ return false
189
+ }
190
+
191
+ /**
192
+ * 是否数组
193
+ */
194
+ export function array(value: unknown): value is any[] {
195
+ if (typeof Array.isArray === 'function') {
196
+ return Array.isArray(value)
197
+ }
198
+ return Object.prototype.toString.call(value) === '[object Array]'
199
+ }
200
+
201
+ /**
202
+ * 是否对象
203
+ */
204
+ export function object(value: unknown): value is Record<string, any> {
205
+ return Object.prototype.toString.call(value) === '[object Object]'
206
+ }
207
+
208
+ /**
209
+ * 是否短信验证码
210
+ */
211
+ export function code(value: string | number, len = 6): boolean {
212
+ return new RegExp(`^\\d{${len}}$`).test(String(value))
213
+ }
214
+
215
+ /**
216
+ * 是否函数方法
217
+ * @param {Object} value
218
+ */
219
+ export function func(value: unknown): value is (...args: any[]) => any {
220
+ return typeof value === 'function'
221
+ }
222
+
223
+ /**
224
+ * 是否promise对象
225
+ * @param {Object} value
226
+ */
227
+ export function promise(value: unknown): value is Promise<any> {
228
+ return object(value) && func(value.then) && func(value.catch)
229
+ }
230
+
231
+ /** 是否图片格式
232
+ * @param {Object} value
233
+ */
234
+ export function image(value: string): boolean {
235
+ const newValue = value.split('?')[0]
236
+ const IMAGE_REGEXP = /\.(jpeg|jpg|gif|png|svg|webp|jfif|bmp|dpg)/i
237
+ return IMAGE_REGEXP.test(newValue)
238
+ }
239
+
240
+ /**
241
+ * 是否视频格式
242
+ * @param {Object} value
243
+ */
244
+ export function video(value: string): boolean {
245
+ const VIDEO_REGEXP = /\.(mp4|mpg|mpeg|dat|asf|avi|rm|rmvb|mov|wmv|flv|mkv|m3u8)/i
246
+ return VIDEO_REGEXP.test(value)
247
+ }
248
+
249
+ /**
250
+ * 是否为正则对象
251
+ * @param {Object}
252
+ * @return {Boolean}
253
+ */
254
+ export function regExp(o: unknown): o is RegExp {
255
+ return o && Object.prototype.toString.call(o) === '[object RegExp]'
256
+ }
@@ -0,0 +1,7 @@
1
+ import { useThrottle } from '../hooks/useThrottle'
2
+ import type { ThrottleFunction } from '../hooks/useThrottle'
3
+
4
+ // 兼容旧用法:模块级共享实例,复用 useThrottle 实现
5
+ const throttle: ThrottleFunction = useThrottle()
6
+
7
+ export default throttle