hy-app 0.2.18 → 0.3.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.
@@ -57,10 +57,11 @@ export default {
57
57
  </script>
58
58
 
59
59
  <script setup lang="ts">
60
- import { computed, ref, toRefs, watch, nextTick } from 'vue'
60
+ import { computed, ref, toRefs, watch, nextTick, inject } from 'vue'
61
61
  import type { CSSProperties, PropType } from 'vue'
62
62
  import type { ITextareaEmits } from './typing'
63
63
  import { addUnit } from '../../utils'
64
+ import { FormItemContext } from '@/package/components/hy-form-item/typing'
64
65
 
65
66
  /**
66
67
  * 用于输入多行文本信息,聊天输入框等。
@@ -177,6 +178,7 @@ const props = defineProps({
177
178
  })
178
179
  const { modelValue, customStyle, border, disabled, formatter } = toRefs(props)
179
180
  const emit = defineEmits<ITextareaEmits>()
181
+ const formItem = inject<FormItemContext>('formItem')
180
182
 
181
183
  // 输入框的值
182
184
  const innerValue = ref<string>('')
@@ -249,16 +251,17 @@ const onFocus = (e: FocusEvent) => {
249
251
  isFocus.value = true
250
252
  emit('focus', e)
251
253
  }
252
- const onBlur = (e: FocusEvent) => {
254
+ const onBlur = (e: any) => {
253
255
  isFocus.value = false
254
256
  emit('blur', e)
257
+ formItem.handleBlur(e.detail.value)
255
258
  // 尝试调用u-form的验证方法
256
259
  // formValidate(this, "blur");
257
260
  }
258
- const onLinechange = (e: Event) => {
259
- emit('linechange', e)
261
+ const onLinechange = (e: any) => {
262
+ emit('lineChange', e)
260
263
  }
261
- const onInput = (e: Event) => {
264
+ const onInput = (e: any) => {
262
265
  let { value } = e?.detail
263
266
  // 格式化过滤方法
264
267
  const format = formatter.value || innerFormatter
@@ -280,8 +283,7 @@ const valueChange = () => {
280
283
  // 标识value值的变化是由内部引起的
281
284
  changeFromInner.value = true
282
285
  emit('change', value)
283
- // 尝试调用u-form的验证方法
284
- // formValidate(this, "change");
286
+ formItem.handleChange(value)
285
287
  })
286
288
  }
287
289
  const onConfirm = (e: Event) => {
@@ -36,7 +36,7 @@ export interface ITextareaEmits {
36
36
  /** 点击完成时, 触发 confirm 事件 */
37
37
  (e: 'confirm', event: any): void
38
38
  /** 输入框行数变化时调用 */
39
- (e: 'linechange'): void
39
+ (e: 'lineChange', event: any): void
40
40
  /** 当键盘输入时,触发 input 事件 */
41
41
  (e: 'update:modelValue', value: string): void
42
42
  /** 键盘高度发生变化的时候触发此事件 */
@@ -18,8 +18,10 @@ import HyDropdown from './hy-dropdown/hy-dropdown.vue'
18
18
  import HyDropdownItem from './hy-dropdown-item/hy-dropdown-item.vue'
19
19
  import YkEmpty from './hy-empty/hy-empty.vue'
20
20
  import YkFloatButton from './hy-float-button/hy-float-button.vue'
21
- import HyFoldingPanel from './hy-folding-panel/hy-folding-panel.vue'
22
- import HyForm from './hy-form/hy-form.vue'
21
+ import HyFoldingPanel from '@/package/components/hy-folding-panel/hy-folding-panel.vue'
22
+ import HyForm from '@/package/components/hy-form-group/hy-form.vue'
23
+ import HyFormSimple from '@/package/components/hy-form/hy-form-simple.vue'
24
+ import HyFormItem from './hy-form-item/hy-form-item.vue'
23
25
  import HyGrid from './hy-grid/hy-grid.vue'
24
26
  import HyIcon from './hy-icon/hy-icon.vue'
25
27
  import HyImage from './hy-image/hy-image.vue'
@@ -80,6 +82,8 @@ const install = (Vue: any) => {
80
82
  Vue.component('YkFloatButton', YkFloatButton)
81
83
  Vue.component('HyFoldingPanel', HyFoldingPanel)
82
84
  Vue.component('HyForm', HyForm)
85
+ Vue.component('HyFormSimple', HyFormSimple)
86
+ Vue.component('HyFormItem', HyFormItem)
83
87
  Vue.component('HyGrid', HyGrid)
84
88
  Vue.component('HyIcon', HyIcon)
85
89
  Vue.component('HyImage', HyImage)
@@ -139,6 +143,8 @@ export {
139
143
  YkFloatButton,
140
144
  HyFoldingPanel,
141
145
  HyForm,
146
+ HyFormSimple,
147
+ HyFormItem,
142
148
  HyGrid,
143
149
  HyIcon,
144
150
  HyImage,
package/global.d.ts CHANGED
@@ -22,9 +22,12 @@ declare module 'vue' {
22
22
  HyDropdown: (typeof import('./components/hy-dropdown/hy-dropdown.vue'))['default']
23
23
  HyDropdownItem: (typeof import('./components/hy-dropdown-item/hy-dropdown-item.vue'))['default']
24
24
  HyEmpty: (typeof import('./components/hy-empty/hy-empty.vue'))['default']
25
+ HyFlex: (typeof import('./components/hy-flex/hy-flex.vue'))['default']
25
26
  HyFloatButton: (typeof import('./components/hy-float-button/hy-float-button.vue'))['default']
26
27
  HyFloatingPanel: (typeof import('./components/hy-floating-panel/hy-floating-panel.vue'))['default']
27
- HyForm: (typeof import('./components/hy-form/hy-form.vue'))['default']
28
+ HyForm: (typeof import('@/package/components/hy-form-group/hy-form.vue'))['default']
29
+ HyFormItem: (typeof import('./components/hy-form-item/hy-form-item.vue'))['default']
30
+ HyFormGroup: (typeof import('./components/hy-form-group/hy-form-group.vue'))['default']
28
31
  HyGrid: (typeof import('./components/hy-grid/hy-grid.vue'))['default']
29
32
  HyIcon: (typeof import('./components/hy-icon/hy-icon.vue'))['default']
30
33
  HyImage: (typeof import('./components/hy-image/hy-image.vue'))['default']
@@ -11,6 +11,7 @@
11
11
  }
12
12
  }
13
13
 
14
+ /* 加上-- */
14
15
  @mixin m($modifier) {
15
16
  $selector: &;
16
17
  $currentSelector: '';
@@ -29,7 +30,7 @@
29
30
  }
30
31
  }
31
32
 
32
- /* 定义元素(e),对于伪类,会自动将 e 嵌套在 伪类 底下 */
33
+ /* 定义元素(e)__,对于伪类,会自动将 e 嵌套在 伪类 底下 */
33
34
  @mixin e($element...) {
34
35
  $selector: &;
35
36
  $selectors: "";
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hy-app",
3
- "version": "0.2.18",
4
- "description": "bug修复",
3
+ "version": "0.3.1",
4
+ "description": "feat: 弹性布局组件",
5
5
  "main": "./index.ts",
6
6
  "private": false,
7
7
  "scripts": {},
package/theme.scss CHANGED
@@ -40,14 +40,14 @@ $hy-text-color--hover: var(--hy-text-color--hover, #58595b)!default; // 点击
40
40
  /* 背景色 */
41
41
  $hy-background: var(--hy-background, #f8f8f8) !default; // 背景色
42
42
  $hy-background--2: var(--hy-background--2, #ffffff) !default; // 弹窗背景色
43
- $hy-background--3: var(--hy-background--3, #646566) !default; // 弹窗背景色
43
+ $hy-background--3: var(--hy-background--3, rgb(238, 238, 239)) !default; // 弹窗背景色
44
44
  $hy-background--container: var(--hy-background--container, #ffffff) !default; // 容器背景色
45
- $hy-background--disabled: var(--hy-background--disabled, #F5F5F5); // 禁用背景色
45
+ $hy-background--disabled: var(--hy-background--disabled, rgba(0, 0, 0, 0.04)); // 禁用背景色
46
46
  $hy-background--track: var(--hy-background--track, #F6F6F6) !default; // 轨道背景色
47
47
  $hy-background--empty: var(--hy-background--empty, #F3F3F3) !default; // 搜索背景色
48
- $hy-background--hover: var(--hy-background--hover, rgba(0,0,0,0.1)) !default; // 点击状态
48
+ $hy-background--hover: var(--hy-background--hover, rgba(0,0,0,0.05)) !default; // 点击状态
49
49
  $hy-light-background-mask: var(--hy-light-background-mask, rgba(0, 0, 0, 0.5)); //遮罩颜色
50
- $hy-background--active: var(--hy-background--active, #131313); // 选中背景色
50
+ $hy-background--active: var(--hy-background--active, #FFFFFF); // 选中背景色
51
51
  $hy-background--close: var(--hy-background--close, #f0f0f0); // 选中背景色
52
52
 
53
53
  /* 文字尺寸 */
@@ -88,4 +88,4 @@ $hy-border-margin-padding-sm: var(--hy-border-margin-padding-sm, 10rpx) !default
88
88
  $hy-border-margin-padding-base: var(--hy-border-margin-padding-base, 20rpx) !default;
89
89
  $hy-border-margin-padding-lg: var(--hy-border-margin-padding-lg, 30rpx) !default;
90
90
  /* 底部线条 */
91
- $hy-border-line: var(--hy-border-line, 1rpx solid rgba(0, 0, 0, 0.02)) !default;
91
+ $hy-border-line: var(--hy-border-line, 1rpx solid #e8e8e8) !default;
package/utils/inspect.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @description 判断字符串是否是数字
3
- * @param {string | number} text 值
4
- * @return {boolean}
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 {string | number} text 值
13
- * @return {boolean}
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 {boolean}
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 {boolean}
36
+ * @return {Boolean}
37
37
  */
38
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 {number | string} value yyyy-mm-dd hh:mm:ss 或 时间戳
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 phone {string} 手机号
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 idCard {string} 身份证号
100
- * @return {boolean}
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 {string} zh 校验值
109
- * @return {boolean}
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