hy-app 0.2.5 → 0.2.6

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 (37) hide show
  1. package/common/index.ts +2 -1
  2. package/common/shakeService.ts +62 -0
  3. package/components/hy-action-sheet/hy-action-sheet.vue +184 -0
  4. package/components/hy-action-sheet/index.scss +123 -0
  5. package/components/hy-action-sheet/props.ts +18 -0
  6. package/components/hy-action-sheet/typing.d.ts +96 -0
  7. package/components/hy-button/hy-button.vue +1 -1
  8. package/components/hy-button/typing.d.ts +35 -31
  9. package/components/hy-cell/typing.d.ts +27 -24
  10. package/components/hy-empty/hy-empty.vue +30 -37
  11. package/components/hy-empty/icon.ts +78 -0
  12. package/components/hy-empty/index.scss +2 -1
  13. package/components/hy-empty/props.ts +10 -9
  14. package/components/hy-empty/typing.d.ts +39 -14
  15. package/components/hy-float-button/hy-float-button.vue +98 -10
  16. package/components/hy-float-button/props.ts +16 -14
  17. package/components/hy-float-button/typing.d.ts +34 -23
  18. package/components/hy-icon/hy-icon.vue +40 -42
  19. package/components/hy-icon/props.ts +17 -16
  20. package/components/hy-icon/typing.d.ts +24 -20
  21. package/components/hy-modal/hy-modal.vue +42 -54
  22. package/components/hy-modal/index.scss +56 -32
  23. package/components/hy-modal/props.ts +15 -14
  24. package/components/hy-modal/typing.d.ts +23 -17
  25. package/components/hy-popup/index.scss +2 -2
  26. package/components/hy-popup/props.ts +7 -7
  27. package/components/hy-popup/typing.d.ts +17 -17
  28. package/components/hy-signature/props.ts +14 -14
  29. package/components/hy-tooltip/index.scss +2 -2
  30. package/libs/css/_config.scss +5 -0
  31. package/libs/css/_function.scss +89 -0
  32. package/libs/css/mixin.scss +58 -21
  33. package/libs/css/vars.css +3 -1
  34. package/package.json +2 -2
  35. package/theme.scss +2 -1
  36. package/utils/inspect.ts +48 -40
  37. package/utils/utils.ts +170 -187
package/theme.scss CHANGED
@@ -34,7 +34,7 @@ $hy-text-color--grey: var(--hy-text-color--grey, #999) !default; // 辅助灰色
34
34
  $hy-text-color--placeholder: var(--hy-text-color--placeholder, #808080) !default; // 输入框提示颜色
35
35
  $hy-text-color--disabled: var(--hy-text-color--disabled, #c0c0c0) !default; // 禁用文字颜色
36
36
  $hy-border-color: var(--hy-border-color, #c0c0c0) !default; // 边框颜色
37
- $hy-text-color-hover: var(--hy-text-color-hover, #58595b)!default; // 点击状态文字颜色
37
+ $hy-text-color--hover: var(--hy-text-color--hover, #58595b)!default; // 点击状态文字颜色
38
38
 
39
39
 
40
40
  /* 背景色 */
@@ -48,6 +48,7 @@ $hy-background--empty: var(--hy-background--empty, #F3F3F3) !default; // 搜索
48
48
  $hy-background--hover: var(--hy-background--hover, rgba(0,0,0,0.1)) !default; // 点击状态
49
49
  $hy-light-background-mask: var(--hy-light-background-mask, rgba(0, 0, 0, 0.5)); //遮罩颜色
50
50
  $hy-background--active: var(--hy-background--active, #131313); // 选中背景色
51
+ $hy-background--close: var(--hy-background--close, #f0f0f0); // 选中背景色
51
52
 
52
53
  /* 文字尺寸 */
53
54
  $hy-font-size-sm: 24rpx; // 提示文字大小
package/utils/inspect.ts CHANGED
@@ -4,8 +4,8 @@
4
4
  * @return {boolean}
5
5
  * */
6
6
  export const isNumericString = (text: string | number): boolean => {
7
- return typeof text === "string" && !isNaN(Number(text));
8
- };
7
+ return typeof text === 'string' && !isNaN(Number(text))
8
+ }
9
9
 
10
10
  /**
11
11
  * @description 判断是否是数字
@@ -13,8 +13,8 @@ export const isNumericString = (text: string | number): boolean => {
13
13
  * @return {boolean}
14
14
  * */
15
15
  export const isNumber = (text: string | number): boolean => {
16
- return typeof text === "number" || isNumericString(text);
17
- };
16
+ return typeof text === 'number' || isNumericString(text)
17
+ }
18
18
 
19
19
  /**
20
20
  * @description 判断是否数组
@@ -22,11 +22,11 @@ export const isNumber = (text: string | number): boolean => {
22
22
  * @return {boolean}
23
23
  */
24
24
  export const isArray = (arr: any): boolean => {
25
- if (typeof Array.isArray === "function") {
26
- return Array.isArray(arr);
25
+ if (typeof Array.isArray === 'function') {
26
+ return Array.isArray(arr)
27
27
  }
28
- return Object.prototype.toString.call(arr) === "[object Array]";
29
- };
28
+ return Object.prototype.toString.call(arr) === '[object Array]'
29
+ }
30
30
 
31
31
  /**
32
32
  * @description 判断是否对象
@@ -34,17 +34,16 @@ export const isArray = (arr: any): boolean => {
34
34
  * @return {boolean}
35
35
  */
36
36
  export const isObject = (obj: any): boolean => {
37
- return Object.prototype.toString.call(obj) === "[object Object]";
38
- };
37
+ return Object.prototype.toString.call(obj) === '[object Object]'
38
+ }
39
39
 
40
40
  /**
41
41
  * 是否视频格式
42
42
  * @param {String} value
43
43
  */
44
44
  export function isVideo(value: string): boolean {
45
- const VIDEO_REGEXP =
46
- /\.(mp4|mpg|mpeg|dat|asf|avi|rm|rmvb|mov|wmv|flv|mkv|m3u8)/i;
47
- return VIDEO_REGEXP.test(value);
45
+ const VIDEO_REGEXP = /\.(mp4|mpg|mpeg|dat|asf|avi|rm|rmvb|mov|wmv|flv|mkv|m3u8)/i
46
+ return VIDEO_REGEXP.test(value)
48
47
  }
49
48
 
50
49
  /**
@@ -52,46 +51,46 @@ export function isVideo(value: string): boolean {
52
51
  * @param {number | string} value yyyy-mm-dd hh:mm:ss 或 时间戳
53
52
  */
54
53
  export const isDate = (value: string | number) => {
55
- if (!value) return false;
54
+ if (!value) return false
56
55
  // number类型,判断是否是时间戳
57
- if (typeof value === "number") {
56
+ if (typeof value === 'number') {
58
57
  // len === 10 秒级时间戳 len === 13 毫秒级时间戳
59
58
  if (value.toString().length !== 10 && value.toString().length !== 13) {
60
- return false;
59
+ return false
61
60
  }
62
- return !isNaN(new Date(value).getTime());
61
+ return !isNaN(new Date(value).getTime())
63
62
  }
64
- if (typeof value === "string") {
63
+ if (typeof value === 'string') {
65
64
  // 是否为string类型时间戳
66
- const numV = Number(value);
65
+ const numV = Number(value)
67
66
  if (!isNaN(numV)) {
68
67
  if (numV.toString().length === 10 || numV.toString().length === 13) {
69
- return !isNaN(new Date(numV).getTime());
68
+ return !isNaN(new Date(numV).getTime())
70
69
  }
71
70
  }
72
71
  // 非时间戳,且长度在yyyy-mm-dd 至 yyyy-mm-dd hh:mm:ss 之间
73
72
  if (value.length < 10 || value.length > 19) {
74
- return false;
73
+ return false
75
74
  }
76
- const dateRegex = /^\d{4}[-\/]\d{2}[-\/]\d{2}( \d{1,2}:\d{2}(:\d{2})?)?$/;
75
+ const dateRegex = /^\d{4}[-\/]\d{2}[-\/]\d{2}( \d{1,2}:\d{2}(:\d{2})?)?$/
77
76
  if (!dateRegex.test(value)) {
78
- return false;
77
+ return false
79
78
  }
80
79
  // 检查是否为有效日期
81
- const dateValue = new Date(value);
82
- return !isNaN(dateValue.getTime());
80
+ const dateValue = new Date(value)
81
+ return !isNaN(dateValue.getTime())
83
82
  }
84
83
  // 非number和string类型,不做校验
85
- return false;
86
- };
84
+ return false
85
+ }
87
86
 
88
87
  /**
89
88
  * @description 验证是否是手机号格式
90
89
  * @param phone {string} 手机号
91
90
  */
92
91
  export const isPhone = (phone: string): boolean => {
93
- return /^1[23456789]\d{9}$/.test(phone);
94
- };
92
+ return /^1[23456789]\d{9}$/.test(phone)
93
+ }
95
94
 
96
95
  /**
97
96
  * @description 验证身份证号码
@@ -99,10 +98,8 @@ export const isPhone = (phone: string): boolean => {
99
98
  * @return {boolean}
100
99
  */
101
100
  export const isIdCard = (idCard: string): boolean => {
102
- 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(
103
- idCard,
104
- );
105
- };
101
+ 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)
102
+ }
106
103
 
107
104
  /**
108
105
  * @description 验证是否是中文
@@ -110,26 +107,37 @@ export const isIdCard = (idCard: string): boolean => {
110
107
  * @return {boolean}
111
108
  */
112
109
  export const isChinese = (zh: string): boolean => {
113
- const reg = /^[\u4e00-\u9fa5]+$/gi;
114
- return reg.test(zh);
115
- };
110
+ const reg = /^[\u4e00-\u9fa5]+$/gi
111
+ return reg.test(zh)
112
+ }
116
113
 
117
114
  /**
118
- * 是否为base64图片
115
+ * @description 是否为base64图片
119
116
  * @param {string} url
120
117
  * @return
121
118
  */
122
119
  export function isBase64Image(url: string) {
123
120
  // 使用正则表达式检查URL是否以"data:image"开头,这是Base64图片的常见前缀
124
- return /^data:image\/(png|jpg|jpeg|gif|bmp);base64,/.test(url);
121
+ return /^data:image\/(png|jpg|jpeg|gif|bmp);base64,/.test(url)
125
122
  }
126
123
 
127
124
  /**
128
- * 是否图片
125
+ * @description 是否图片
129
126
  * @param {string} url
130
127
  * @return
131
128
  */
132
129
  export function isImage(url: string) {
133
130
  // 使用正则表达式检查URL是否以"data:image"开头,这是Base64图片的常见前缀
134
- return /(\.jpg|\.jpeg|\.png|\.gif|\.bmp|\.webp)$/i.test(url);
131
+ return /(\.jpg|\.jpeg|\.png|\.gif|\.bmp|\.webp)$/i.test(url)
135
132
  }
133
+
134
+ /**
135
+ * @description 判断环境是否是H5
136
+ */
137
+ export const isH5 = (() => {
138
+ let isH5 = false
139
+ // #ifdef H5
140
+ isH5 = true
141
+ // #endif
142
+ return isH5
143
+ })()