hy-app 0.2.16 → 0.3.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.
- package/components/hy-action-sheet/hy-action-sheet.vue +5 -5
- package/components/hy-action-sheet/index.scss +6 -1
- package/components/hy-address-picker/hy-address-picker.vue +5 -5
- package/components/hy-avatar/hy-avatar.vue +5 -5
- package/components/hy-back-top/hy-back-top.vue +5 -5
- package/components/hy-badge/hy-badge.vue +5 -5
- package/components/hy-button/hy-button.vue +5 -5
- package/components/hy-calendar/hy-calendar.vue +22 -18
- package/components/hy-calendar/typing.d.ts +1 -1
- package/components/hy-card/hy-card.vue +5 -5
- package/components/hy-cell/hy-cell.vue +10 -11
- package/components/hy-check-button/hy-check-button.vue +7 -6
- package/components/hy-checkbox/hy-checkbox.vue +14 -14
- package/components/hy-code-input/hy-code-input.vue +8 -15
- package/components/hy-code-input/index.scss +1 -1
- package/components/hy-config-provider/hy-config-provider.vue +8 -6
- package/components/hy-count-down/hy-count-down.vue +7 -6
- package/components/hy-count-to/hy-count-to.vue +6 -5
- package/components/hy-datetime-picker/hy-datetime-picker.vue +7 -7
- package/components/hy-divider/hy-divider.vue +10 -7
- package/components/hy-dropdown/hy-dropdown.vue +6 -5
- package/components/hy-dropdown-item/hy-dropdown-item.vue +7 -5
- package/components/hy-empty/hy-empty.vue +6 -5
- package/components/hy-float-button/hy-float-button.vue +6 -6
- package/components/hy-folding-panel/hy-folding-panel.vue +6 -5
- package/components/hy-form/README.md +301 -0
- package/components/hy-form/hy-form.vue +252 -533
- package/components/hy-form/index.ts +5 -0
- package/components/hy-form/typing.d.ts +57 -77
- package/components/hy-form-group/hy-form-group.vue +533 -0
- package/components/hy-form-group/typing.d.ts +77 -0
- package/components/hy-form-item/hy-form-item.vue +199 -0
- package/components/hy-form-item/index.scss +41 -0
- package/components/hy-form-item/typing.d.ts +43 -0
- package/components/hy-grid/hy-grid.vue +11 -13
- package/components/hy-grid/typing.d.ts +1 -1
- package/components/hy-icon/hy-icon.vue +15 -15
- package/components/hy-image/hy-image.vue +15 -9
- package/components/hy-input/hy-input.vue +17 -11
- package/components/hy-line/hy-line.vue +8 -6
- package/components/hy-line-progress/hy-line-progress.vue +9 -16
- package/components/hy-list/hy-list.vue +6 -5
- package/components/hy-loading/hy-loading.vue +9 -10
- package/components/hy-login/TheUserLogin.vue +82 -90
- package/components/hy-menu/hy-menu.vue +11 -8
- package/components/hy-modal/hy-modal.vue +6 -6
- package/components/hy-modal/index.scss +1 -1
- package/components/hy-navbar/hy-navbar.vue +6 -6
- package/components/hy-notice-bar/hy-notice-bar.vue +14 -9
- package/components/hy-notify/hy-notify.vue +6 -6
- package/components/hy-number-step/hy-number-step.vue +8 -6
- package/components/hy-overlay/hy-overlay.vue +8 -9
- package/components/hy-pagination/hy-pagination.vue +11 -8
- package/components/hy-picker/hy-picker.vue +9 -9
- package/components/hy-popover/hy-popover.vue +11 -7
- package/components/hy-popup/hy-popup.vue +9 -7
- package/components/hy-price/hy-price.vue +6 -5
- package/components/hy-qrcode/hy-qrcode.vue +6 -8
- package/components/hy-radio/hy-radio.vue +10 -12
- package/components/hy-rate/hy-rate.vue +7 -7
- package/components/hy-read-more/hy-read-more.vue +6 -5
- package/components/hy-scroll-list/hy-scroll-list.vue +6 -5
- package/components/hy-search/hy-search.vue +8 -6
- package/components/hy-signature/hy-signature.vue +6 -5
- package/components/hy-slider/hy-slider.vue +8 -7
- package/components/hy-steps/hy-steps.vue +10 -17
- package/components/hy-submit-bar/hy-submit-bar.vue +6 -6
- package/components/hy-subsection/hy-subsection.vue +16 -19
- package/components/hy-swipe-action/hy-swipe-action.vue +31 -25
- package/components/hy-swipe-action/typing.d.ts +1 -1
- package/components/hy-swiper/hy-swiper.vue +15 -15
- package/components/hy-swiper/typing.d.ts +13 -1
- package/components/hy-switch/hy-switch.vue +17 -10
- package/components/hy-tabBar/hy-tabBar.vue +35 -26
- package/components/hy-tabs/hy-tabs.vue +28 -21
- package/components/hy-tag/hy-tag.vue +13 -17
- package/components/hy-tag/typing.d.ts +1 -1
- package/components/hy-text/hy-text.vue +12 -14
- package/components/hy-textarea/hy-textarea.vue +16 -13
- package/components/hy-textarea/index.scss +7 -2
- package/components/hy-textarea/typing.d.ts +1 -1
- package/components/hy-toast/hy-toast.vue +72 -75
- package/components/hy-tooltip/hy-tooltip.vue +8 -14
- package/components/hy-transition/hy-transition.vue +8 -6
- package/components/hy-upload/hy-upload.vue +6 -5
- package/components/hy-warn/hy-warn.vue +6 -6
- package/components/hy-waterfall/hy-waterfall.vue +8 -7
- package/components/hy-watermark/hy-watermark.vue +20 -10
- package/components/index.ts +7 -1
- package/global.d.ts +3 -1
- package/libs/css/common.scss +5 -0
- package/libs/css/mixin.scss +2 -1
- package/libs/css/vars.css +1 -1
- package/package.json +2 -2
- package/theme.scss +1 -1
- package/utils/inspect.ts +34 -34
- package/utils/utils.ts +1 -19
- package/web-types.json +1 -1
- /package/components/{hy-form → hy-form-group}/index.scss +0 -0
- /package/components/{hy-form → hy-form-group}/props.ts +0 -0
package/utils/inspect.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @description 判断字符串是否是数字
|
|
3
|
-
* @param {
|
|
4
|
-
* @return {
|
|
3
|
+
* @param {String | Number} text 值
|
|
4
|
+
* @return {Boolean}
|
|
5
5
|
* */
|
|
6
6
|
export const isNumericString = (text: string | number): boolean => {
|
|
7
7
|
return typeof text === 'string' && !isNaN(Number(text))
|
|
@@ -9,8 +9,8 @@ export const isNumericString = (text: string | number): boolean => {
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* @description 判断是否是数字
|
|
12
|
-
* @param {
|
|
13
|
-
* @return {
|
|
12
|
+
* @param {String | Number} text 值
|
|
13
|
+
* @return {Boolean}
|
|
14
14
|
* */
|
|
15
15
|
export const isNumber = (text: string | number): boolean => {
|
|
16
16
|
return typeof text === 'number' || isNumericString(text)
|
|
@@ -18,8 +18,8 @@ export const isNumber = (text: string | number): boolean => {
|
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
20
|
* @description 判断是否数组
|
|
21
|
-
* @param arr 传入数组值
|
|
22
|
-
* @return {
|
|
21
|
+
* @param {any} arr 传入数组值
|
|
22
|
+
* @return {Boolean}
|
|
23
23
|
*/
|
|
24
24
|
export const isArray = (arr: any): arr is Array<any> => {
|
|
25
25
|
// 如果 Array.isArray 函数可用,直接使用该函数检查
|
|
@@ -33,12 +33,32 @@ export const isArray = (arr: any): arr is Array<any> => {
|
|
|
33
33
|
/**
|
|
34
34
|
* @description 判断是否对象
|
|
35
35
|
* @param obj 传入对象值
|
|
36
|
-
* @return {
|
|
36
|
+
* @return {Boolean}
|
|
37
37
|
*/
|
|
38
|
-
export const isObject = (obj: any):
|
|
38
|
+
export const isObject = (obj: any): obj is Object => {
|
|
39
39
|
return Object.prototype.toString.call(obj) === '[object Object]'
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
+
/**
|
|
43
|
+
* @description 是否为base64图片
|
|
44
|
+
* @param {String} url
|
|
45
|
+
* @return
|
|
46
|
+
*/
|
|
47
|
+
export function isBase64Image(url: string) {
|
|
48
|
+
// 使用正则表达式检查URL是否以"data:image"开头,这是Base64图片的常见前缀
|
|
49
|
+
return /^data:image\/(png|jpg|jpeg|gif|bmp);base64,/.test(url)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* @description 是否图片
|
|
54
|
+
* @param {String} url
|
|
55
|
+
* @return
|
|
56
|
+
*/
|
|
57
|
+
export function isImage(url: string) {
|
|
58
|
+
// 使用正则表达式检查URL是否以"data:image"开头,这是Base64图片的常见前缀
|
|
59
|
+
return /(\.jpg|\.jpeg|\.png|\.gif|\.bmp|\.webp)$/i.test(url)
|
|
60
|
+
}
|
|
61
|
+
|
|
42
62
|
/**
|
|
43
63
|
* 是否视频格式
|
|
44
64
|
* @param {String} value
|
|
@@ -50,7 +70,7 @@ export function isVideo(value: string): boolean {
|
|
|
50
70
|
|
|
51
71
|
/**
|
|
52
72
|
* 判断是否是日期格式
|
|
53
|
-
* @param {
|
|
73
|
+
* @param {Number | String} value yyyy-mm-dd hh:mm:ss 或 时间戳
|
|
54
74
|
*/
|
|
55
75
|
export const isDate = (value: string | number) => {
|
|
56
76
|
if (!value) return false
|
|
@@ -88,7 +108,7 @@ export const isDate = (value: string | number) => {
|
|
|
88
108
|
|
|
89
109
|
/**
|
|
90
110
|
* @description 验证是否是手机号格式
|
|
91
|
-
* @param
|
|
111
|
+
* @param {String} phone 手机号
|
|
92
112
|
*/
|
|
93
113
|
export const isPhone = (phone: string): boolean => {
|
|
94
114
|
return /^1[23456789]\d{9}$/.test(phone)
|
|
@@ -96,8 +116,8 @@ export const isPhone = (phone: string): boolean => {
|
|
|
96
116
|
|
|
97
117
|
/**
|
|
98
118
|
* @description 验证身份证号码
|
|
99
|
-
* @param
|
|
100
|
-
* @return {
|
|
119
|
+
* @param {String} idCard 身份证号
|
|
120
|
+
* @return {Boolean}
|
|
101
121
|
*/
|
|
102
122
|
export const isIdCard = (idCard: string): boolean => {
|
|
103
123
|
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(idCard)
|
|
@@ -105,34 +125,14 @@ export const isIdCard = (idCard: string): boolean => {
|
|
|
105
125
|
|
|
106
126
|
/**
|
|
107
127
|
* @description 验证是否是中文
|
|
108
|
-
* @param {
|
|
109
|
-
* @return {
|
|
128
|
+
* @param {String} zh 校验值
|
|
129
|
+
* @return {Boolean}
|
|
110
130
|
*/
|
|
111
131
|
export const isChinese = (zh: string): boolean => {
|
|
112
132
|
const reg = /^[\u4e00-\u9fa5]+$/gi
|
|
113
133
|
return reg.test(zh)
|
|
114
134
|
}
|
|
115
135
|
|
|
116
|
-
/**
|
|
117
|
-
* @description 是否为base64图片
|
|
118
|
-
* @param {string} url
|
|
119
|
-
* @return
|
|
120
|
-
*/
|
|
121
|
-
export function isBase64Image(url: string) {
|
|
122
|
-
// 使用正则表达式检查URL是否以"data:image"开头,这是Base64图片的常见前缀
|
|
123
|
-
return /^data:image\/(png|jpg|jpeg|gif|bmp);base64,/.test(url)
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* @description 是否图片
|
|
128
|
-
* @param {string} url
|
|
129
|
-
* @return
|
|
130
|
-
*/
|
|
131
|
-
export function isImage(url: string) {
|
|
132
|
-
// 使用正则表达式检查URL是否以"data:image"开头,这是Base64图片的常见前缀
|
|
133
|
-
return /(\.jpg|\.jpeg|\.png|\.gif|\.bmp|\.webp)$/i.test(url)
|
|
134
|
-
}
|
|
135
|
-
|
|
136
136
|
/**
|
|
137
137
|
* @description 判断环境是否是H5
|
|
138
138
|
*/
|
package/utils/utils.ts
CHANGED
|
@@ -364,7 +364,7 @@ export type RectResultType<T extends boolean> = T extends true ? UniApp.NodeInfo
|
|
|
364
364
|
* @param ins 在微信小程序里,因为utils文件里面获取不到instance值所以必须通过ins这个传过来
|
|
365
365
|
* @param useFields 是否使用 fields 方法获取节点信息
|
|
366
366
|
*/
|
|
367
|
-
const getRect = (
|
|
367
|
+
const getRect = <T extends boolean>(
|
|
368
368
|
selector: string,
|
|
369
369
|
all?: T,
|
|
370
370
|
ins?: any,
|
|
@@ -395,24 +395,6 @@ const getRect = (
|
|
|
395
395
|
} else {
|
|
396
396
|
query[method](selector).boundingClientRect(callback).exec()
|
|
397
397
|
}
|
|
398
|
-
// // #ifdef MP-WEIXIN
|
|
399
|
-
// instance = ins;
|
|
400
|
-
// // #endif
|
|
401
|
-
// // #ifndef APP-NVUE
|
|
402
|
-
// uni
|
|
403
|
-
// .createSelectorQuery()
|
|
404
|
-
// .in(instance)
|
|
405
|
-
// [all ? "selectAll" : "select"](selector)
|
|
406
|
-
// .boundingClientRect((rect) => {
|
|
407
|
-
// if (all && Array.isArray(rect) && rect.length) {
|
|
408
|
-
// resolve(rect as UniApp.NodeInfo[]);
|
|
409
|
-
// }
|
|
410
|
-
// if (!all && rect) {
|
|
411
|
-
// resolve(rect as UniApp.NodeInfo);
|
|
412
|
-
// }
|
|
413
|
-
// })
|
|
414
|
-
// .exec();
|
|
415
|
-
// // #endif
|
|
416
398
|
})
|
|
417
399
|
}
|
|
418
400
|
|