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.
Files changed (100) hide show
  1. package/components/hy-action-sheet/hy-action-sheet.vue +5 -5
  2. package/components/hy-action-sheet/index.scss +6 -1
  3. package/components/hy-address-picker/hy-address-picker.vue +5 -5
  4. package/components/hy-avatar/hy-avatar.vue +5 -5
  5. package/components/hy-back-top/hy-back-top.vue +5 -5
  6. package/components/hy-badge/hy-badge.vue +5 -5
  7. package/components/hy-button/hy-button.vue +5 -5
  8. package/components/hy-calendar/hy-calendar.vue +22 -18
  9. package/components/hy-calendar/typing.d.ts +1 -1
  10. package/components/hy-card/hy-card.vue +5 -5
  11. package/components/hy-cell/hy-cell.vue +10 -11
  12. package/components/hy-check-button/hy-check-button.vue +7 -6
  13. package/components/hy-checkbox/hy-checkbox.vue +14 -14
  14. package/components/hy-code-input/hy-code-input.vue +8 -15
  15. package/components/hy-code-input/index.scss +1 -1
  16. package/components/hy-config-provider/hy-config-provider.vue +8 -6
  17. package/components/hy-count-down/hy-count-down.vue +7 -6
  18. package/components/hy-count-to/hy-count-to.vue +6 -5
  19. package/components/hy-datetime-picker/hy-datetime-picker.vue +7 -7
  20. package/components/hy-divider/hy-divider.vue +10 -7
  21. package/components/hy-dropdown/hy-dropdown.vue +6 -5
  22. package/components/hy-dropdown-item/hy-dropdown-item.vue +7 -5
  23. package/components/hy-empty/hy-empty.vue +6 -5
  24. package/components/hy-float-button/hy-float-button.vue +6 -6
  25. package/components/hy-folding-panel/hy-folding-panel.vue +6 -5
  26. package/components/hy-form/README.md +301 -0
  27. package/components/hy-form/hy-form.vue +252 -533
  28. package/components/hy-form/index.ts +5 -0
  29. package/components/hy-form/typing.d.ts +57 -77
  30. package/components/hy-form-group/hy-form-group.vue +533 -0
  31. package/components/hy-form-group/typing.d.ts +77 -0
  32. package/components/hy-form-item/hy-form-item.vue +199 -0
  33. package/components/hy-form-item/index.scss +41 -0
  34. package/components/hy-form-item/typing.d.ts +43 -0
  35. package/components/hy-grid/hy-grid.vue +11 -13
  36. package/components/hy-grid/typing.d.ts +1 -1
  37. package/components/hy-icon/hy-icon.vue +15 -15
  38. package/components/hy-image/hy-image.vue +15 -9
  39. package/components/hy-input/hy-input.vue +17 -11
  40. package/components/hy-line/hy-line.vue +8 -6
  41. package/components/hy-line-progress/hy-line-progress.vue +9 -16
  42. package/components/hy-list/hy-list.vue +6 -5
  43. package/components/hy-loading/hy-loading.vue +9 -10
  44. package/components/hy-login/TheUserLogin.vue +82 -90
  45. package/components/hy-menu/hy-menu.vue +11 -8
  46. package/components/hy-modal/hy-modal.vue +6 -6
  47. package/components/hy-modal/index.scss +1 -1
  48. package/components/hy-navbar/hy-navbar.vue +6 -6
  49. package/components/hy-notice-bar/hy-notice-bar.vue +14 -9
  50. package/components/hy-notify/hy-notify.vue +6 -6
  51. package/components/hy-number-step/hy-number-step.vue +8 -6
  52. package/components/hy-overlay/hy-overlay.vue +8 -9
  53. package/components/hy-pagination/hy-pagination.vue +11 -8
  54. package/components/hy-picker/hy-picker.vue +9 -9
  55. package/components/hy-popover/hy-popover.vue +11 -7
  56. package/components/hy-popup/hy-popup.vue +9 -7
  57. package/components/hy-price/hy-price.vue +6 -5
  58. package/components/hy-qrcode/hy-qrcode.vue +6 -8
  59. package/components/hy-radio/hy-radio.vue +10 -12
  60. package/components/hy-rate/hy-rate.vue +7 -7
  61. package/components/hy-read-more/hy-read-more.vue +6 -5
  62. package/components/hy-scroll-list/hy-scroll-list.vue +6 -5
  63. package/components/hy-search/hy-search.vue +8 -6
  64. package/components/hy-signature/hy-signature.vue +6 -5
  65. package/components/hy-slider/hy-slider.vue +8 -7
  66. package/components/hy-steps/hy-steps.vue +10 -17
  67. package/components/hy-submit-bar/hy-submit-bar.vue +6 -6
  68. package/components/hy-subsection/hy-subsection.vue +16 -19
  69. package/components/hy-swipe-action/hy-swipe-action.vue +31 -25
  70. package/components/hy-swipe-action/typing.d.ts +1 -1
  71. package/components/hy-swiper/hy-swiper.vue +15 -15
  72. package/components/hy-swiper/typing.d.ts +13 -1
  73. package/components/hy-switch/hy-switch.vue +17 -10
  74. package/components/hy-tabBar/hy-tabBar.vue +35 -26
  75. package/components/hy-tabs/hy-tabs.vue +28 -21
  76. package/components/hy-tag/hy-tag.vue +13 -17
  77. package/components/hy-tag/typing.d.ts +1 -1
  78. package/components/hy-text/hy-text.vue +12 -14
  79. package/components/hy-textarea/hy-textarea.vue +16 -13
  80. package/components/hy-textarea/index.scss +7 -2
  81. package/components/hy-textarea/typing.d.ts +1 -1
  82. package/components/hy-toast/hy-toast.vue +72 -75
  83. package/components/hy-tooltip/hy-tooltip.vue +8 -14
  84. package/components/hy-transition/hy-transition.vue +8 -6
  85. package/components/hy-upload/hy-upload.vue +6 -5
  86. package/components/hy-warn/hy-warn.vue +6 -6
  87. package/components/hy-waterfall/hy-waterfall.vue +8 -7
  88. package/components/hy-watermark/hy-watermark.vue +20 -10
  89. package/components/index.ts +7 -1
  90. package/global.d.ts +3 -1
  91. package/libs/css/common.scss +5 -0
  92. package/libs/css/mixin.scss +2 -1
  93. package/libs/css/vars.css +1 -1
  94. package/package.json +2 -2
  95. package/theme.scss +1 -1
  96. package/utils/inspect.ts +34 -34
  97. package/utils/utils.ts +1 -19
  98. package/web-types.json +1 -1
  99. /package/components/{hy-form → hy-form-group}/index.scss +0 -0
  100. /package/components/{hy-form → hy-form-group}/props.ts +0 -0
@@ -0,0 +1,77 @@
1
+ import type { FormColumnsType } from "../../typing";
2
+ import type HyInputProps from "../hy-input/typing";
3
+ import type HyTextareaProps from "../hy-textarea/typing";
4
+ import type HySwitchProps from "../hy-switch/typing";
5
+ import type HyPickerProps from "../hy-picker/typing";
6
+ import type HyRadioProps from "../hy-radio/typing";
7
+ import type HyCheckButtonProps from "../hy-check-button/typing";
8
+
9
+ export default interface HyFormProps {
10
+ /**
11
+ * @description 表单域提示文字的位置
12
+ * left - 左侧
13
+ * top - 上方
14
+ * */
15
+ labelPosition?: "left" | "top";
16
+ /**
17
+ * @description label宽度
18
+ * 数字 - 固定值
19
+ * auto - 自适应
20
+ * */
21
+ labelWidth?: string | number;
22
+ /**
23
+ * @description 是否右对齐
24
+ * */
25
+ right?: boolean;
26
+ /**
27
+ * @description label字体的对齐方式
28
+ * left - 左对齐
29
+ * center - 中间对齐
30
+ * right - 右对齐
31
+ * */
32
+ labelAlign?: HyApp.RowCenterType;
33
+ /**
34
+ * @description 显示冒号符号
35
+ * */
36
+ symbol?: boolean;
37
+ /**
38
+ * @description 显示底部下划线
39
+ * */
40
+ borderBottom?: boolean;
41
+ /**
42
+ * @description 当行内容高度
43
+ * */
44
+ itemHeight?: number | string;
45
+ /**
46
+ * @description 输入框属性api集合
47
+ * */
48
+ input?: Partial<HyInputProps>;
49
+ /**
50
+ * @description 文本域属性api集合
51
+ * */
52
+ textarea?: Partial<HyTextareaProps>;
53
+ /**
54
+ * @description 选择器属性api集合
55
+ * */
56
+ picker?: Partial<HyPickerProps>;
57
+ /**
58
+ * @description 开关属性api集合
59
+ * */
60
+ switchItem?: Partial<HySwitchProps>;
61
+ /**
62
+ * @description 单选属性api集合
63
+ * */
64
+ radio?: Partial<HyRadioProps>;
65
+ /**
66
+ * @description 选择按钮属性api集合
67
+ * */
68
+ checkButton?: Partial<HyCheckButtonProps>;
69
+ /**
70
+ * @description 表单配置
71
+ * */
72
+ columns: FormColumnsType[];
73
+ /**
74
+ * @description 表单值
75
+ * */
76
+ formData: Record<string, any>;
77
+ }
@@ -0,0 +1,199 @@
1
+ <template>
2
+ <view class="hy-form-item" :class="[`hy-form-item--${labelPosition}`]">
3
+ <view v-if="label" class="hy-form-item__label" :style="labelStyle">
4
+ <text v-if="isRequired" class="hy-form-item__label--required">*</text>
5
+ {{ label }}
6
+ </view>
7
+ <view class="hy-form-item__content">
8
+ <slot></slot>
9
+ <view v-if="errorMessage" class="hy-form-item__error">
10
+ {{ errorMessage }}
11
+ </view>
12
+ </view>
13
+ </view>
14
+ </template>
15
+
16
+ <script lang="ts">
17
+ export default {
18
+ name: 'hy-form-item',
19
+ options: {
20
+ addGlobalClass: true,
21
+ virtualHost: true,
22
+ styleIsolation: 'shared',
23
+ },
24
+ }
25
+ </script>
26
+
27
+ <script setup lang="ts">
28
+ import { computed, inject, onMounted, onUnmounted, type PropType, provide, ref } from 'vue'
29
+ import type { FormContext } from './typing'
30
+
31
+ /**
32
+ * 表单组件子组件,需要搭配hy-form
33
+ * @displayName hy-form-item
34
+ */
35
+ defineOptions({})
36
+
37
+ const props = defineProps({
38
+ /**
39
+ * 标签文本
40
+ */
41
+ label: String,
42
+ /**
43
+ * 表单字段名
44
+ */
45
+ prop: String,
46
+ /**
47
+ * 是否必填
48
+ */
49
+ required: {
50
+ type: Boolean,
51
+ default: false,
52
+ },
53
+ /**
54
+ * 验证规则
55
+ */
56
+ rules: Object as PropType<any>,
57
+ })
58
+
59
+ const emit = defineEmits<{
60
+ change: [value: any]
61
+ blur: [value: any]
62
+ }>()
63
+
64
+ // 注入表单上下文
65
+ const formContext = inject<FormContext>('formContext')
66
+ const formItem = {
67
+ // 处理子组件事件
68
+ handleChange(value: any) {
69
+ if (props.prop && formContext) {
70
+ formContext.setFieldValue(props.prop, value)
71
+ validate('change')
72
+ }
73
+ emit('change', value)
74
+ },
75
+ handleBlur(value: any) {
76
+ if (props.prop && formContext) {
77
+ validate('blur')
78
+ }
79
+ emit('blur', value)
80
+ },
81
+ }
82
+ provide('formItem', formItem)
83
+
84
+ // 当前组件的引用
85
+ const formItemRef = ref()
86
+
87
+ // 错误信息
88
+ const errorMessage = computed(() => {
89
+ if (!formContext || !props.prop) return ''
90
+ return formContext.errors[props.prop] || ''
91
+ })
92
+
93
+ // 是否必填
94
+ const isRequired = computed(() => {
95
+ if (props.required) return true
96
+ if (!formContext || !props.prop) return false
97
+
98
+ const fieldRules = formContext.rules.value?.[props.prop]
99
+ if (!fieldRules) return false
100
+
101
+ const rules = Array.isArray(fieldRules) ? fieldRules : [fieldRules]
102
+ return rules.some((rule) => rule.required)
103
+ })
104
+
105
+ // 标签样式
106
+ const labelStyle = computed(() => {
107
+ if (!formContext) return {}
108
+
109
+ const style: Record<string, any> = {}
110
+
111
+ if (formContext.labelWidth.value !== 'auto') {
112
+ style.width =
113
+ typeof formContext.labelWidth.value === 'number'
114
+ ? `${formContext.labelWidth.value}px`
115
+ : formContext.labelWidth.value
116
+ }
117
+
118
+ if (formContext.labelAlign.value) {
119
+ style.textAlign = formContext.labelAlign.value
120
+ }
121
+
122
+ return style
123
+ })
124
+
125
+ // 标签位置
126
+ const labelPosition = computed(() => {
127
+ return formContext?.labelPosition?.value || 'left'
128
+ })
129
+
130
+ // 监听表单数据变化
131
+ // watch(
132
+ // () => formContext?.formData[props.prop],
133
+ // (newVal) => {
134
+ // if (props.prop && formContext) {
135
+ // formContext.setFieldValue(props.prop, newVal)
136
+ // validate('change')
137
+ // }
138
+ // },
139
+ // { immediate: true },
140
+ // )
141
+
142
+ // 验证字段
143
+ const validate = (trigger?: 'blur' | 'change') => {
144
+ if (!formContext || !props.prop) return true
145
+
146
+ const value = formContext.getFieldValue(props.prop)
147
+ return formContext.validateField(props.prop, value, trigger)
148
+ }
149
+
150
+ // 重置字段
151
+ const resetField = () => {
152
+ if (!formContext || !props.prop) return
153
+
154
+ formContext.setFieldValue(props.prop, undefined)
155
+ formContext.validateField(props.prop, undefined)
156
+ }
157
+
158
+ // 清除验证
159
+ const clearValidate = () => {
160
+ if (!formContext || !props.prop) return
161
+
162
+ delete formContext.errors[props.prop]
163
+ }
164
+
165
+ // 组件挂载时注册到表单
166
+ onMounted(() => {
167
+ if (formContext) {
168
+ formContext.addFormItem({
169
+ props: props,
170
+ validate,
171
+ resetField,
172
+ clearValidate,
173
+ })
174
+ }
175
+ })
176
+
177
+ // 组件卸载时从表单中移除
178
+ onUnmounted(() => {
179
+ if (formContext) {
180
+ formContext.removeFormItem({
181
+ props: props,
182
+ validate,
183
+ resetField,
184
+ clearValidate,
185
+ })
186
+ }
187
+ })
188
+
189
+ // 暴露方法给父组件
190
+ defineExpose({
191
+ validate,
192
+ resetField,
193
+ clearValidate,
194
+ })
195
+ </script>
196
+
197
+ <style lang="scss" scoped>
198
+ @import './index.scss';
199
+ </style>
@@ -0,0 +1,41 @@
1
+ @use "../../theme.scss" as *;
2
+ @use "../../libs/css/mixin.scss" as *;
3
+
4
+ @include b(form-item) {
5
+ display: flex;
6
+ margin-bottom: 16px;
7
+
8
+ @include m(left) {
9
+ flex-direction: row;
10
+ align-items: flex-start;
11
+ }
12
+
13
+ @include m(top) {
14
+ flex-direction: column;
15
+ }
16
+
17
+ @include e(label) {
18
+ position: relative;
19
+ padding-right: 8px;
20
+ font-size: 14px;
21
+ color: #333;
22
+ line-height: 1.5;
23
+
24
+ @include m(required) {
25
+ color: #ff4d4f;
26
+ margin-right: 2px;
27
+ }
28
+ }
29
+
30
+ @include e(content) {
31
+ flex: 1;
32
+ min-width: 0;
33
+ }
34
+
35
+ @include e(error) {
36
+ margin-top: 4px;
37
+ font-size: 12px;
38
+ color: #ff4d4f;
39
+ line-height: 1.5;
40
+ }
41
+ }
@@ -0,0 +1,43 @@
1
+ export interface FormContext {
2
+ formData: Record<string, any>
3
+ errors: Record<string, string>
4
+ rules: any
5
+ labelWidth: any
6
+ labelPosition: any
7
+ labelAlign: any
8
+ addFormItem: (item: any) => void
9
+ removeFormItem: (item: any) => void
10
+ validateField: (field: string, value: any, trigger?: 'blur' | 'change') => boolean
11
+ setFieldValue: (field: string, value: any) => void
12
+ getFieldValue: (field: string) => any
13
+ }
14
+
15
+ export interface FormItemContext {
16
+ /**
17
+ * 失去焦点触发表单校验
18
+ * */
19
+ handleBlur: (value: string | number) => void
20
+ /**
21
+ * 值改变触发表单校验
22
+ * */
23
+ handleChange: (value: string | number) => void
24
+ }
25
+
26
+ export default interface HyFormItemProps {
27
+ /**
28
+ * 标签文本
29
+ */
30
+ label?: string
31
+ /**
32
+ * 表单字段名
33
+ */
34
+ prop?: string
35
+ /**
36
+ * 是否必填
37
+ */
38
+ required?: boolean
39
+ /**
40
+ * 验证规则
41
+ */
42
+ rules?: any
43
+ }
@@ -33,11 +33,6 @@
33
33
  </template>
34
34
 
35
35
  <script lang="ts">
36
- /**
37
- * 宫格组件一般用于同时展示多个同类项目的场景,可以给宫格的项目设置徽标组件(badge),或者图标等,也可以扩展为左右滑动的轮播形式
38
- * @displayName hy-grid
39
- */
40
- defineOptions({})
41
36
  export default {
42
37
  name: 'hy-grid',
43
38
  options: {
@@ -53,25 +48,30 @@ import { computed, toRefs } from 'vue'
53
48
  import type { CSSProperties, PropType } from 'vue'
54
49
  import type { CustomKeysVo, GridItemVo, IGridEmits } from './typing'
55
50
  import { addUnit } from '../../utils'
56
-
51
+ import type HyIconProps from '../hy-icon/typing'
57
52
  // 组件
58
53
  import HyIcon from '../hy-icon/hy-icon.vue'
59
- import type HyIconProps from '@/package/components/hy-icon/typing'
54
+
55
+ /**
56
+ * 宫格组件一般用于同时展示多个同类项目的场景,可以给宫格的项目设置徽标组件(badge),或者图标等,也可以扩展为左右滑动的轮播形式
57
+ * @displayName hy-grid
58
+ */
59
+ defineOptions({})
60
60
 
61
61
  // const props = withDefaults(defineProps<IProps>(), defaultProps);
62
62
  const props = defineProps({
63
63
  /** 数据列表 */
64
64
  list: {
65
65
  type: Array as PropType<GridItemVo[]>,
66
- default: [],
66
+ default: () => [],
67
67
  },
68
68
  /** 自定义键值 */
69
69
  customKeys: {
70
70
  type: Object as PropType<CustomKeysVo>,
71
- default: {
71
+ default: () => ({
72
72
  name: 'name',
73
73
  icon: 'icon',
74
- },
74
+ }),
75
75
  },
76
76
  /** 宫格的列数 */
77
77
  col: {
@@ -109,9 +109,7 @@ const props = defineProps({
109
109
  /** 图标属性api配置集合 */
110
110
  iconConfig: Object as PropType<HyIconProps>,
111
111
  /** 定义需要用到的外部样式 */
112
- customStyle: {
113
- type: Object as PropType<CSSProperties>,
114
- },
112
+ customStyle: Object as PropType<CSSProperties>,
115
113
  /** 自定义外部类名 */
116
114
  customClass: String,
117
115
  })
@@ -75,5 +75,5 @@ export default interface HyGridProps {
75
75
 
76
76
  export interface IGridEmits {
77
77
  /** 点击小菜单触发 */
78
- (e: 'click', name: string | Record<string, any>)): void
78
+ (e: 'click', name: string | Record<string, any>): void
79
79
  }
@@ -10,7 +10,7 @@
10
10
  <text v-else class="hy-icon__icon" :class="uClasses" :style="[iconStyle, customStyle]"></text>
11
11
  <!-- 这里进行空字符串判断,如果仅仅是v-if="label",可能会出现传递0的时候,结果也无法显示 -->
12
12
  <text
13
- v-if="label !== ''"
13
+ v-if="label"
14
14
  class="hy-icon__label"
15
15
  :style="{
16
16
  color: labelColor,
@@ -25,11 +25,6 @@
25
25
  </template>
26
26
 
27
27
  <script lang="ts">
28
- /**
29
- * 基于字体的图标集,包含了大多数常见场景的图标,使用简单,开箱即用,无需自己再写每个图标的样式,直接简单配置即可。支持自定义图标。
30
- * @displayName hy-icon
31
- */
32
- defineOptions({})
33
28
  export default {
34
29
  name: 'hy-icon',
35
30
  options: {
@@ -41,10 +36,17 @@ export default {
41
36
  </script>
42
37
 
43
38
  <script setup lang="ts">
44
- import { computed, type CSSProperties, type PropType, toRefs } from 'vue'
39
+ import { computed, toRefs } from 'vue'
40
+ import type { PropType, CSSProperties } from 'vue'
45
41
  import { addUnit } from '../../utils'
46
42
  import type { IIconEmits } from './typing'
47
43
 
44
+ /**
45
+ * 基于字体的图标集,包含了大多数常见场景的图标,使用简单,开箱即用,无需自己再写每个图标的样式,直接简单配置即可。支持自定义图标。
46
+ * @displayName hy-icon
47
+ */
48
+ defineOptions({})
49
+
48
50
  // const props = withDefaults(defineProps<IProps>(), defaultProps)
49
51
  const props = defineProps({
50
52
  /** 图标名称 */
@@ -90,12 +92,12 @@ const props = defineProps({
90
92
  /** 图片的mode */
91
93
  imgMode: String,
92
94
  /** 显示图片小图标时的宽度 */
93
- width: String,
95
+ width: [String, Number],
94
96
  /** 显示图片小图标时的高度 */
95
- height: String,
97
+ height: [String, Number],
96
98
  /** 图标在垂直方向上的定位 用于解决某些情况下,让图标垂直居中的用途 */
97
99
  top: {
98
- type: Number,
100
+ type: [String, Number],
99
101
  default: 0,
100
102
  },
101
103
  /** 是否阻止事件传播 */
@@ -110,13 +112,11 @@ const props = defineProps({
110
112
  },
111
113
  /** 图标圆角 */
112
114
  round: {
113
- type: Number,
115
+ type: [String, Number],
114
116
  default: 0,
115
117
  },
116
118
  /** 定义需要用到的外部样式 */
117
- customStyle: {
118
- type: Object as PropType<CSSProperties>,
119
- },
119
+ customStyle: Object as PropType<CSSProperties>,
120
120
  /** 自定义外部类名 */
121
121
  customClass: String,
122
122
  })
@@ -174,7 +174,7 @@ const iconStyle = computed<CSSProperties>(() => {
174
174
  * @description 判断传入的name属性,是否图片路径,只要带有"/"均认为是图片形式
175
175
  * */
176
176
  const isImg = computed(() => {
177
- return name.value.indexOf('/') !== -1
177
+ return name.value?.indexOf('/') !== -1
178
178
  })
179
179
  const imgStyle = computed((): CSSProperties => {
180
180
  let style: CSSProperties = {}
@@ -50,11 +50,6 @@
50
50
  </template>
51
51
 
52
52
  <script lang="ts">
53
- /**
54
- * uni-app的image组件的加强版,在继承了原有功能外,还支持淡入动画、加载中、加载失败提示、圆角值和形状等。
55
- * @displayName hy-image
56
- */
57
- defineOptions({})
58
53
  export default {
59
54
  name: 'hy-image',
60
55
  options: {
@@ -70,12 +65,17 @@ import { computed, onMounted, ref, toRefs, watch } from 'vue'
70
65
  import type { PropType, CSSProperties } from 'vue'
71
66
  import type { IImageEmits } from './typing'
72
67
  import { addUnit, getPx } from '../../utils'
73
-
68
+ import { IconConfig } from '../../config'
74
69
  // 组件
75
70
  import HyIcon from '../hy-icon/hy-icon.vue'
76
71
  import HyTransition from '../hy-transition/hy-transition.vue'
77
72
  import HyLoading from '../hy-loading/hy-loading.vue'
78
- import { IconConfig } from '@/package'
73
+
74
+ /**
75
+ * uni-app的image组件的加强版,在继承了原有功能外,还支持淡入动画、加载中、加载失败提示、圆角值和形状等。
76
+ * @displayName hy-image
77
+ */
78
+ defineOptions({})
79
79
 
80
80
  // const props = withDefaults(defineProps<IProps>(), defaultProps)
81
81
  const props = defineProps({
@@ -87,9 +87,15 @@ const props = defineProps({
87
87
  default: 'aspectFill',
88
88
  },
89
89
  /** 宽度,单位任意,如果为数值,则为px单位 */
90
- width: String,
90
+ width: {
91
+ type: [String, Number],
92
+ default: '',
93
+ },
91
94
  /** 高度,单位任意,如果为数值,则为px单位 */
92
- height: String,
95
+ height: {
96
+ type: [String, Number],
97
+ default: '',
98
+ },
93
99
  /**
94
100
  * 图片形状
95
101
  * @values circle,square
@@ -92,11 +92,6 @@
92
92
  </template>
93
93
 
94
94
  <script lang="ts">
95
- /**
96
- * 为一个输入框,利用它可以快速实现表单验证,输入内容,下拉选择等功能。
97
- * @displayName hy-input
98
- */
99
- defineOptions({})
100
95
  export default {
101
96
  name: 'hy-input',
102
97
  options: {
@@ -108,13 +103,21 @@ export default {
108
103
  </script>
109
104
 
110
105
  <script setup lang="ts">
111
- import { computed, nextTick, ref, toRefs, watch, getCurrentInstance, PropType } from 'vue'
112
- import type { CSSProperties } from 'vue'
106
+ import { computed, nextTick, ref, toRefs, watch, getCurrentInstance, inject } from 'vue'
107
+ import type { CSSProperties, PropType } from 'vue'
113
108
  import HyIcon from '../hy-icon/hy-icon.vue'
114
109
  import { addUnit, formatObject } from '../../utils'
115
110
  import { IconConfig } from '../../config'
116
111
  import type { IInputEmits } from './typing'
117
- import HyIconProps from '@/package/components/hy-icon/typing'
112
+ import type HyIconProps from '../hy-icon/typing'
113
+ import { FormItemContext } from '@/package/components/hy-form-item/typing'
114
+ import { TextAlign } from 'csstype'
115
+
116
+ /**
117
+ * 为一个输入框,利用它可以快速实现表单验证,输入内容,下拉选择等功能。
118
+ * @displayName hy-input
119
+ */
120
+ defineOptions({})
118
121
 
119
122
  // const props = withDefaults(defineProps<IProps>(), defaultProps)
120
123
  const props = defineProps({
@@ -235,7 +238,7 @@ const props = defineProps({
235
238
  * @values left,center,right
236
239
  * */
237
240
  inputAlign: {
238
- type: String,
241
+ type: String as PropType<TextAlign>,
239
242
  default: 'left',
240
243
  },
241
244
  /** 输入框字体的大小 */
@@ -278,7 +281,7 @@ const props = defineProps({
278
281
  },
279
282
  /** 是否忽略组件内对文本合成系统事件的处理 */
280
283
  ignoreCompositionEvent: {
281
- type: String,
284
+ type: Boolean,
282
285
  default: false,
283
286
  },
284
287
  /** 内容式化函数 */
@@ -302,6 +305,7 @@ const {
302
305
  placeholderStyle,
303
306
  } = toRefs(props)
304
307
  const emit = defineEmits<IInputEmits>()
308
+ const formItem = inject<FormItemContext>('formItem')
305
309
 
306
310
  const instance = getCurrentInstance()
307
311
  // 清除操作
@@ -423,8 +427,9 @@ const onInput = (e: any) => {
423
427
  /**
424
428
  * @description 输入框失去焦点时触发
425
429
  * */
426
- const onBlur = (event: Event) => {
430
+ const onBlur = (event: any) => {
427
431
  emit('blur', event.detail.value)
432
+ formItem.handleBlur(event.detail.value)
428
433
  // H5端的blur会先于点击清除控件的点击click事件触发,导致focused
429
434
  // 瞬间为false,从而隐藏了清除控件而无法被点击到
430
435
  setTimeout(() => {
@@ -465,6 +470,7 @@ const valueChange = (value: string | number, isOut = false) => {
465
470
  // 标识value值的变化是由内部引起的
466
471
  changeFromInner.value = true
467
472
  emit('change', value)
473
+ formItem.handleChange(value)
468
474
 
469
475
  emit('update:modelValue', value)
470
476
  }
@@ -3,11 +3,6 @@
3
3
  </template>
4
4
 
5
5
  <script lang="ts">
6
- /**
7
- * 一般用于显示一根线条,用于分隔内容块,有横向和竖向两种模式,且能设置0.5px线条,使用也很简单。
8
- * @displayName hy-line
9
- */
10
- defineOptions({})
11
6
  export default {
12
7
  name: 'hy-line',
13
8
  options: {
@@ -19,9 +14,16 @@ export default {
19
14
  </script>
20
15
 
21
16
  <script setup lang="ts">
22
- import { computed, type CSSProperties, type PropType, toRefs } from 'vue'
17
+ import { computed, toRefs } from 'vue'
18
+ import type { CSSProperties, PropType } from 'vue'
23
19
  import { addUnit } from '../../utils'
24
20
 
21
+ /**
22
+ * 一般用于显示一根线条,用于分隔内容块,有横向和竖向两种模式,且能设置0.5px线条,使用也很简单。
23
+ * @displayName hy-line
24
+ */
25
+ defineOptions({})
26
+
25
27
  // const props = withDefaults(defineProps<IProps>(), defaultProps);
26
28
  const props = defineProps({
27
29
  /** 线条的颜色 */