hy-app 0.4.3 → 0.4.5

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 (147) hide show
  1. package/components/hy-action-sheet/hy-action-sheet.vue +1 -1
  2. package/components/hy-address-picker/hy-address-picker.vue +1 -1
  3. package/components/hy-avatar/hy-avatar.vue +1 -1
  4. package/components/hy-back-top/hy-back-top.vue +1 -2
  5. package/components/hy-badge/hy-badge.vue +1 -1
  6. package/components/hy-button/hy-button.vue +1 -2
  7. package/components/hy-calendar/hy-calendar.vue +3 -11
  8. package/components/hy-calendar/month.vue +1 -1
  9. package/components/hy-card/hy-card.vue +1 -1
  10. package/components/hy-cell/hy-cell.vue +1 -2
  11. package/components/hy-cell/props.ts +1 -1
  12. package/components/hy-check-button/hy-check-button.vue +2 -2
  13. package/components/hy-checkbox/hy-checkbox.vue +2 -3
  14. package/components/hy-checkbox-group/hy-checkbox-group.vue +1 -1
  15. package/components/hy-checkbox-item/hy-checkbox-item.vue +1 -2
  16. package/components/hy-code-input/hy-code-input.vue +1 -1
  17. package/components/hy-config-provider/hy-config-provider.vue +2 -3
  18. package/components/hy-config-provider/props.ts +1 -1
  19. package/components/hy-count-down/index.ts +1 -1
  20. package/components/hy-count-to/hy-count-to.vue +1 -1
  21. package/components/hy-datetime-picker/hy-datetime-picker.vue +2 -3
  22. package/components/hy-datetime-picker/props.ts +1 -1
  23. package/components/hy-divider/hy-divider.vue +1 -2
  24. package/components/hy-divider/props.ts +1 -1
  25. package/components/hy-dropdown/hy-dropdown.vue +2 -3
  26. package/components/hy-dropdown/props.ts +1 -1
  27. package/components/hy-dropdown-item/hy-dropdown-item.vue +1 -2
  28. package/components/hy-empty/hy-empty.vue +1 -1
  29. package/components/hy-flex/hy-flex.vue +1 -1
  30. package/components/hy-float-button/hy-float-button.vue +1 -2
  31. package/components/hy-float-button/props.ts +14 -14
  32. package/components/hy-folding-panel/hy-folding-panel.vue +2 -3
  33. package/components/hy-folding-panel/props.ts +1 -1
  34. package/components/hy-form/hy-form.vue +1 -1
  35. package/components/hy-form-group/hy-form-group.vue +183 -111
  36. package/components/hy-form-group/typing.d.ts +1 -1
  37. package/components/hy-form-item/hy-form-item.vue +1 -1
  38. package/components/hy-grid/hy-grid.vue +1 -1
  39. package/components/hy-icon/hy-icon.vue +1 -1
  40. package/components/hy-icon/index.scss +1 -1
  41. package/components/hy-image/hy-image.vue +1 -2
  42. package/components/hy-image/props.ts +10 -10
  43. package/components/hy-input/hy-input.vue +1 -2
  44. package/components/hy-line/hy-line.vue +1 -1
  45. package/components/hy-line-progress/hy-line-progress.vue +1 -2
  46. package/components/hy-list/hy-list.vue +1 -1
  47. package/components/hy-loading/hy-loading.vue +1 -1
  48. package/components/hy-menu/hy-menu.vue +1 -1
  49. package/components/hy-modal/hy-modal.vue +2 -2
  50. package/components/hy-modal/props.ts +13 -13
  51. package/components/hy-navbar/hy-navbar.vue +1 -2
  52. package/components/hy-navbar/props.ts +1 -1
  53. package/components/hy-notice-bar/hy-column-notice.vue +1 -2
  54. package/components/hy-notice-bar/hy-notice-bar.vue +1 -1
  55. package/components/hy-notice-bar/hy-row-notice.vue +1 -2
  56. package/components/hy-notice-bar/props.ts +1 -1
  57. package/components/hy-notify/hy-notify.vue +1 -2
  58. package/components/hy-number-step/hy-number-step.vue +1 -2
  59. package/components/hy-overlay/hy-overlay.vue +1 -1
  60. package/components/hy-pagination/hy-pagination.vue +1 -1
  61. package/components/hy-picker/hy-picker.vue +1 -2
  62. package/components/hy-popover/hy-popover.vue +9 -3
  63. package/components/hy-popup/hy-popup.vue +2 -3
  64. package/components/hy-price/hy-price.vue +3 -2
  65. package/components/hy-qrcode/hy-qrcode.vue +1 -1
  66. package/components/hy-radio/hy-radio.vue +1 -2
  67. package/components/hy-rate/hy-rate.vue +6 -4
  68. package/components/hy-rate/props.ts +6 -6
  69. package/components/hy-read-more/hy-read-more.vue +1 -2
  70. package/components/hy-scroll-list/hy-scroll-list.vue +1 -1
  71. package/components/hy-scroll-list/props.ts +0 -1
  72. package/components/hy-search/hy-search.vue +3 -3
  73. package/components/hy-signature/hy-signature.vue +1 -1
  74. package/components/hy-slider/hy-slider.vue +3 -13
  75. package/components/hy-slider/props.ts +1 -1
  76. package/components/hy-status-bar/hy-status-bar.vue +1 -1
  77. package/components/hy-status-bar/props.ts +1 -1
  78. package/components/hy-steps/hy-steps.vue +1 -2
  79. package/components/hy-subsection/hy-subsection.vue +1 -1
  80. package/components/hy-subsection/props.ts +0 -1
  81. package/components/hy-subsection/typing.d.ts +0 -1
  82. package/components/hy-swipe-action/hy-swipe-action.vue +1 -2
  83. package/components/hy-swiper/hy-swiper-indicator.vue +1 -1
  84. package/components/hy-swiper/hy-swiper.vue +2 -3
  85. package/components/hy-swiper/typing.d.ts +35 -36
  86. package/components/hy-switch/hy-switch.vue +2 -2
  87. package/components/hy-switch/typing.d.ts +0 -1
  88. package/components/hy-tabs/hy-tabs.vue +2 -3
  89. package/components/hy-tag/hy-tag.vue +1 -2
  90. package/components/hy-text/hy-text.vue +2 -2
  91. package/components/hy-text/typing.d.ts +26 -26
  92. package/components/hy-textarea/hy-textarea.vue +2 -2
  93. package/components/hy-toast/hy-toast.vue +33 -19
  94. package/components/hy-toast/index.scss +3 -2
  95. package/components/hy-toast/typing.d.ts +1 -1
  96. package/components/hy-tooltip/hy-tooltip.vue +8 -2
  97. package/components/hy-transition/hy-transition.vue +1 -1
  98. package/components/hy-upload/hy-upload.vue +7 -2
  99. package/components/hy-upload/props.ts +1 -1
  100. package/components/hy-warn/hy-warn.vue +1 -2
  101. package/components/hy-warn/typing.d.ts +12 -13
  102. package/components/hy-waterfall/hy-waterfall.vue +1 -1
  103. package/components/hy-watermark/hy-watermark.vue +1 -1
  104. package/components/index.ts +117 -118
  105. package/index.ts +1 -7
  106. package/{api → libs/api}/http.ts +2 -2
  107. package/libs/common/index.ts +2 -0
  108. package/libs/common/queue.ts +28 -0
  109. package/{composables → libs/composables}/index.ts +1 -0
  110. package/{composables → libs/composables}/usePopover.ts +7 -2
  111. package/{common/shakeService.ts → libs/composables/useShakeService.ts} +4 -2
  112. package/{composables → libs/composables}/useShare.ts +3 -0
  113. package/libs/composables/useToast.ts +45 -0
  114. package/{composables → libs/composables}/useTouch.ts +3 -0
  115. package/{global → libs/global}/register-properties.ts +1 -1
  116. package/libs/index.ts +7 -0
  117. package/{typing → libs/typing}/index.ts +0 -1
  118. package/{typing → libs/typing}/modules/form.ts +7 -7
  119. package/{utils → libs/utils}/utils.ts +1 -0
  120. package/package.json +2 -2
  121. package/common/index.ts +0 -3
  122. package/common/queue.ts +0 -34
  123. package/components/hy-form/README.md +0 -301
  124. package/components/hy-text/index.ts +0 -0
  125. package/components/yk-dialog/yk-dialog.vue +0 -129
  126. package/composables/useToast.ts +0 -51
  127. package/typing/modules/dialog.ts +0 -17
  128. /package/{api → libs/api}/index.ts +0 -0
  129. /package/{common → libs/common}/versionControl.ts +0 -0
  130. /package/{composables → libs/composables}/useQueue.ts +0 -0
  131. /package/{config → libs/config}/color.ts +0 -0
  132. /package/{config → libs/config}/icon.ts +0 -0
  133. /package/{config → libs/config}/index.ts +0 -0
  134. /package/{static/font → libs/css}/iconfont.css +0 -0
  135. /package/{global → libs/global}/index.ts +0 -0
  136. /package/{typing → libs/typing}/modules/common.d.ts +0 -0
  137. /package/{typing → libs/typing}/modules/enum.ts +0 -0
  138. /package/{typing → libs/typing}/modules/http.ts +0 -0
  139. /package/{typing → libs/typing}/modules/icon.d.ts +0 -0
  140. /package/{typing → libs/typing}/modules/rect.ts +0 -0
  141. /package/{utils → libs/utils}/address.json +0 -0
  142. /package/{utils → libs/utils}/base64.ts +0 -0
  143. /package/{utils → libs/utils}/calendar.js +0 -0
  144. /package/{utils → libs/utils}/colorGradient.ts +0 -0
  145. /package/{utils → libs/utils}/index.ts +0 -0
  146. /package/{utils → libs/utils}/inside.ts +0 -0
  147. /package/{utils → libs/utils}/inspect.ts +0 -0
@@ -6,7 +6,10 @@
6
6
  :key="item.field"
7
7
  >
8
8
  <view v-if="item.label" class="hy-form--item__label" :style="labelStyle">
9
- <text v-if="isRequired(item.rules)" style="color: red; font-size: 20px; line-height: 10px">
9
+ <text
10
+ v-if="isRequired(item.rules)"
11
+ style="color: red; font-size: 20px; line-height: 10px"
12
+ >
10
13
  *
11
14
  </text>
12
15
  {{ item.label }}
@@ -20,23 +23,35 @@
20
23
  v-model="formData[item.field]"
21
24
  :type="item.type"
22
25
  :disabled="item?.input?.disabled || input?.disabled"
23
- :disabledColor="item?.input?.disabledColor || input?.disabledColor"
26
+ :disabledColor="
27
+ item?.input?.disabledColor || input?.disabledColor
28
+ "
24
29
  :maxlength="item?.input?.maxlength || input?.maxlength"
25
30
  :password="item?.input?.password"
26
31
  :clearable="item?.input?.clearable || input?.clearable"
27
32
  :readonly="item?.input?.readonly || input?.readonly"
28
33
  :placeholder="item?.input?.placeholder"
29
- :placeholderClass="item?.input?.placeholderClass || input?.placeholderClass"
30
- :placeholderStyle="item?.input?.placeholderStyle || input?.placeholderStyle"
31
- :showWordLimit="item?.input?.showWordLimit || input?.showWordLimit"
34
+ :placeholderClass="
35
+ item?.input?.placeholderClass || input?.placeholderClass
36
+ "
37
+ :placeholderStyle="
38
+ item?.input?.placeholderStyle || input?.placeholderStyle
39
+ "
40
+ :showWordLimit="
41
+ item?.input?.showWordLimit || input?.showWordLimit
42
+ "
32
43
  :confirmType="item?.input?.confirmType || input?.confirmType"
33
44
  :confirmHold="item?.input?.confirmHold || input?.confirmHold"
34
45
  :holdKeyboard="item?.input?.holdKeyboard || input?.holdKeyboard"
35
46
  :focus="item?.input?.focus || input?.focus"
36
47
  :autoBlur="item?.input?.autoBlur || input?.autoBlur"
37
- :selectionStart="item?.input?.selectionStart || input?.selectionStart"
48
+ :selectionStart="
49
+ item?.input?.selectionStart || input?.selectionStart
50
+ "
38
51
  :selectionEnd="item?.input?.selectionEnd || input?.selectionEnd"
39
- :adjustPosition="item?.input?.adjustPosition || input?.adjustPosition"
52
+ :adjustPosition="
53
+ item?.input?.adjustPosition || input?.adjustPosition
54
+ "
40
55
  :inputAlign="item?.input?.inputAlign || input?.inputAlign"
41
56
  :fontSize="item?.input?.fontSize || input?.fontSize"
42
57
  :color="item?.input?.color || input?.color"
@@ -79,13 +94,25 @@
79
94
  :disabled="item?.textarea?.disabled || textarea?.disabled"
80
95
  :maxlength="item?.textarea?.maxlength || textarea?.maxlength"
81
96
  :placeholder="item?.textarea?.placeholder"
82
- :placeholderClass="item?.textarea?.placeholderClass || textarea?.placeholderClass"
83
- :placeholderStyle="item?.textarea?.placeholderStyle || textarea?.placeholderStyle"
84
- :holdKeyboard="item?.textarea?.holdKeyboard || textarea?.holdKeyboard"
97
+ :placeholderClass="
98
+ item?.textarea?.placeholderClass || textarea?.placeholderClass
99
+ "
100
+ :placeholderStyle="
101
+ item?.textarea?.placeholderStyle || textarea?.placeholderStyle
102
+ "
103
+ :holdKeyboard="
104
+ item?.textarea?.holdKeyboard || textarea?.holdKeyboard
105
+ "
85
106
  :focus="item?.textarea?.focus || textarea?.focus"
86
- :selectionStart="item?.textarea?.selectionStart || textarea?.selectionStart"
87
- :selectionEnd="item?.textarea?.selectionEnd || textarea?.selectionEnd"
88
- :adjustPosition="item?.textarea?.adjustPosition || textarea?.adjustPosition"
107
+ :selectionStart="
108
+ item?.textarea?.selectionStart || textarea?.selectionStart
109
+ "
110
+ :selectionEnd="
111
+ item?.textarea?.selectionEnd || textarea?.selectionEnd
112
+ "
113
+ :adjustPosition="
114
+ item?.textarea?.adjustPosition || textarea?.adjustPosition
115
+ "
89
116
  :formatter="item?.textarea?.formatter || textarea?.formatter"
90
117
  :border="item?.textarea?.border || textarea?.border"
91
118
  :customStyle="errorStyle(!!errors[item.field])"
@@ -106,9 +133,13 @@
106
133
  :size="item?.checkButton?.size || checkButton?.size"
107
134
  :col="item?.checkButton?.col || checkButton?.col"
108
135
  :gap="item?.checkButton?.gap || checkButton?.gap"
109
- :fieldNames="item?.checkButton?.fieldNames || checkButton?.fieldNames"
136
+ :fieldNames="
137
+ item?.checkButton?.fieldNames || checkButton?.fieldNames
138
+ "
110
139
  :disabled="item?.checkButton?.size || checkButton?.disabled"
111
- :selectType="item?.checkButton?.selectType || checkButton?.selectType"
140
+ :selectType="
141
+ item?.checkButton?.selectType || checkButton?.selectType
142
+ "
112
143
  ></hy-check-button>
113
144
  </template>
114
145
  <!-- 复选框/单选框 -->
@@ -123,7 +154,9 @@
123
154
  :disabled="item?.radio?.disabled || radio?.disabled"
124
155
  :size="item?.radio?.size || radio?.size"
125
156
  :activeColor="item?.radio?.activeColor || radio?.activeColor"
126
- :inactiveColor="item?.radio?.inactiveColor || radio?.inactiveColor"
157
+ :inactiveColor="
158
+ item?.radio?.inactiveColor || radio?.inactiveColor
159
+ "
127
160
  :iconSize="item?.radio?.iconSize || radio?.iconSize"
128
161
  :iconColor="item?.radio?.iconColor || radio?.iconColor"
129
162
  :labelDisabled="item?.radio?.disabled || radio?.labelDisabled"
@@ -139,12 +172,24 @@
139
172
  :loading="item?.switchItem?.loading || switchItem?.loading"
140
173
  :disabled="item?.switchItem?.disabled || switchItem?.disabled"
141
174
  :size="item?.switchItem?.size || switchItem?.size"
142
- :activeColor="item?.switchItem?.activeColor || switchItem?.activeColor"
143
- :inactiveColor="item?.switchItem?.inactiveColor || switchItem?.inactiveColor"
144
- :activeValue="item?.switchItem?.activeValue || switchItem?.activeValue"
145
- :inactiveValue="item?.switchItem?.inactiveValue || switchItem?.inactiveValue"
146
- :activeIcon="item?.switchItem?.activeIcon || switchItem?.activeIcon"
147
- :inactiveIcon="item?.switchItem?.inactiveIcon || switchItem?.inactiveIcon"
175
+ :activeColor="
176
+ item?.switchItem?.activeColor || switchItem?.activeColor
177
+ "
178
+ :inactiveColor="
179
+ item?.switchItem?.inactiveColor || switchItem?.inactiveColor
180
+ "
181
+ :activeValue="
182
+ item?.switchItem?.activeValue || switchItem?.activeValue
183
+ "
184
+ :inactiveValue="
185
+ item?.switchItem?.inactiveValue || switchItem?.inactiveValue
186
+ "
187
+ :activeIcon="
188
+ item?.switchItem?.activeIcon || switchItem?.activeIcon
189
+ "
190
+ :inactiveIcon="
191
+ item?.switchItem?.inactiveIcon || switchItem?.inactiveIcon
192
+ "
148
193
  :space="item?.switchItem?.space || switchItem?.space"
149
194
  ></HySwitch>
150
195
  </template>
@@ -162,7 +207,9 @@
162
207
  :confirmText="item?.picker?.confirmText || picker?.confirmText"
163
208
  :cancelColor="item?.picker?.cancelColor || picker?.cancelColor"
164
209
  :confirmColor="item?.picker?.confirmColor || picker?.confirmColor"
165
- :visibleItemCount="item?.picker?.visibleItemCount || picker?.visibleItemCount"
210
+ :visibleItemCount="
211
+ item?.picker?.visibleItemCount || picker?.visibleItemCount
212
+ "
166
213
  :closeOnClickOverlay="
167
214
  item?.picker?.closeOnClickOverlay || picker?.closeOnClickOverlay
168
215
  "
@@ -170,7 +217,8 @@
170
217
  :showToolbar="item?.picker?.showToolbar || picker?.showToolbar"
171
218
  :customStyle="errorStyle(!!errors[item.field])"
172
219
  :input="{
173
- disabled: item?.picker?.input?.disabled || picker?.input?.disabled,
220
+ disabled:
221
+ item?.picker?.input?.disabled || picker?.input?.disabled,
174
222
  placeholder: item.picker?.input?.placeholder,
175
223
  shape: item?.picker?.input?.shape || picker?.input?.shape,
176
224
  border: item?.picker?.input?.border || picker?.input?.border,
@@ -192,7 +240,9 @@
192
240
  :confirmText="item?.picker?.confirmText || picker?.confirmText"
193
241
  :cancelColor="item?.picker?.cancelColor || picker?.cancelColor"
194
242
  :confirmColor="item?.picker?.confirmColor || picker?.confirmColor"
195
- :visibleItemCount="item?.picker?.visibleItemCount || picker?.visibleItemCount"
243
+ :visibleItemCount="
244
+ item?.picker?.visibleItemCount || picker?.visibleItemCount
245
+ "
196
246
  :closeOnClickOverlay="
197
247
  item?.picker?.closeOnClickOverlay || picker?.closeOnClickOverlay
198
248
  "
@@ -200,7 +250,8 @@
200
250
  :showToolbar="item?.picker?.showToolbar || picker?.showToolbar"
201
251
  :customStyle="errorStyle(!!errors[item.field])"
202
252
  :input="{
203
- disabled: item?.picker?.input?.disabled || picker?.input?.disabled,
253
+ disabled:
254
+ item?.picker?.input?.disabled || picker?.input?.disabled,
204
255
  placeholder: item.picker?.input?.placeholder,
205
256
  shape: item?.picker?.input?.shape || picker?.input?.shape,
206
257
  border: item?.picker?.input?.border || picker?.input?.border,
@@ -221,7 +272,9 @@
221
272
  :confirmText="item?.picker?.confirmText || picker?.confirmText"
222
273
  :cancelColor="item?.picker?.cancelColor || picker?.cancelColor"
223
274
  :confirmColor="item?.picker?.confirmColor || picker?.confirmColor"
224
- :visibleItemCount="item?.picker?.visibleItemCount || picker?.visibleItemCount"
275
+ :visibleItemCount="
276
+ item?.picker?.visibleItemCount || picker?.visibleItemCount
277
+ "
225
278
  :closeOnClickOverlay="
226
279
  item?.picker?.closeOnClickOverlay || picker?.closeOnClickOverlay
227
280
  "
@@ -229,7 +282,8 @@
229
282
  :showToolbar="item?.picker?.showToolbar || picker?.showToolbar"
230
283
  :customStyle="errorStyle(!!errors[item.field])"
231
284
  :input="{
232
- disabled: item?.picker?.input?.disabled || picker?.input?.disabled,
285
+ disabled:
286
+ item?.picker?.input?.disabled || picker?.input?.disabled,
233
287
  placeholder: item.picker?.input?.placeholder,
234
288
  shape: item?.picker?.input?.shape || picker?.input?.shape,
235
289
  border: item?.picker?.input?.border || picker?.input?.border,
@@ -252,7 +306,9 @@
252
306
 
253
307
  <!-- 提示信息 -->
254
308
  <HyTransition :show="!!errors[item.field]" mode="slide-left">
255
- <view class="hy-form--item__container-warning">{{ errors[item.field] }}</view>
309
+ <view class="hy-form--item__container-warning">{{
310
+ errors[item.field]
311
+ }}</view>
256
312
  </HyTransition>
257
313
  <!-- 提示信息 -->
258
314
  </view>
@@ -262,69 +318,77 @@
262
318
 
263
319
  <script lang="ts">
264
320
  export default {
265
- name: 'hy-form',
321
+ name: "hy-form",
266
322
  options: {
267
323
  addGlobalClass: true,
268
324
  virtualHost: true,
269
- styleIsolation: 'shared',
325
+ styleIsolation: "shared",
270
326
  },
271
- }
327
+ };
272
328
  </script>
273
329
 
274
330
  <script setup lang="ts">
275
- import { computed, reactive, toRefs } from 'vue'
276
- import type { CSSProperties } from 'vue'
277
- import type IProps from './typing'
278
- import defaultProps from './props'
279
- import { addUnit, error } from '../../utils'
280
- import type { FormColumnsType, RulesVo } from '../../typing'
281
- import { FormTypeEnum } from '../../typing'
331
+ import { computed, reactive, toRefs } from "vue";
332
+ import type { CSSProperties } from "vue";
333
+ import type IProps from "./typing";
334
+ import defaultProps from "./props";
335
+ import { addUnit, error, FormTypeEnum } from "../../libs";
336
+ import type { FormColumnsType, RulesVo } from "../../libs/typing";
282
337
 
283
338
  // 组件
284
- import HyInput from '../hy-input/hy-input.vue'
285
- import HyPicker from '../hy-picker/hy-picker.vue'
286
- import HyUpload from '../hy-upload/hy-upload.vue'
287
- import HyTextarea from '../hy-textarea/hy-textarea.vue'
288
- import HySwitch from '../hy-switch/hy-switch.vue'
289
- import HyRadio from '../hy-radio/hy-radio.vue'
290
- import HyDatetimePicker from '../hy-datetime-picker/hy-datetime-picker.vue'
291
- import HyAddressPicker from '../hy-address-picker/hy-address-picker.vue'
292
- import HyTransition from '../hy-transition/hy-transition.vue'
293
- import HyCheckButton from '../hy-check-button/hy-check-button.vue'
294
-
295
- const props = withDefaults(defineProps<IProps>(), defaultProps)
296
- const { formData, columns, labelWidth, labelAlign, labelPosition, borderBottom } = toRefs(props)
297
- const emit = defineEmits(['click'])
298
-
299
- const labelPos = labelPosition.value === 'top' ? 'column' : 'row'
339
+ import HyInput from "../hy-input/hy-input.vue";
340
+ import HyPicker from "../hy-picker/hy-picker.vue";
341
+ import HyUpload from "../hy-upload/hy-upload.vue";
342
+ import HyTextarea from "../hy-textarea/hy-textarea.vue";
343
+ import HySwitch from "../hy-switch/hy-switch.vue";
344
+ import HyRadio from "../hy-radio/hy-radio.vue";
345
+ import HyDatetimePicker from "../hy-datetime-picker/hy-datetime-picker.vue";
346
+ import HyAddressPicker from "../hy-address-picker/hy-address-picker.vue";
347
+ import HyTransition from "../hy-transition/hy-transition.vue";
348
+ import HyCheckButton from "../hy-check-button/hy-check-button.vue";
349
+
350
+ const props = withDefaults(defineProps<IProps>(), defaultProps);
351
+ const {
352
+ formData,
353
+ columns,
354
+ labelWidth,
355
+ labelAlign,
356
+ labelPosition,
357
+ borderBottom,
358
+ } = toRefs(props);
359
+ const emit = defineEmits(["click"]);
360
+
361
+ const labelPos = labelPosition.value === "top" ? "column" : "row";
300
362
  const isInput = (type: FormTypeEnum) =>
301
- type === FormTypeEnum.TEXT || type === FormTypeEnum.NUMBER || type === FormTypeEnum.PASSWORD
363
+ type === FormTypeEnum.TEXT ||
364
+ type === FormTypeEnum.NUMBER ||
365
+ type === FormTypeEnum.PASSWORD;
302
366
 
303
367
  /**
304
368
  * @description 错误输入框样式
305
369
  * */
306
370
  const errorStyle = computed(() => {
307
371
  return (err: boolean) => {
308
- const style: CSSProperties = {}
372
+ const style: CSSProperties = {};
309
373
  if (err) {
310
- style.background = '#dd6161'
374
+ style.background = "#dd6161";
311
375
  }
312
376
 
313
- return style
314
- }
315
- })
377
+ return style;
378
+ };
379
+ });
316
380
 
317
381
  const isRequired = computed(() => {
318
382
  return (temp: any) => {
319
383
  if (Array.isArray(temp)) {
320
- return temp.some((item) => item?.required)
384
+ return temp.some((item) => item?.required);
321
385
  } else {
322
- return temp?.required
386
+ return temp?.required;
323
387
  }
324
- }
325
- })
388
+ };
389
+ });
326
390
 
327
- const errors: AnyObject = reactive({})
391
+ const errors: AnyObject = reactive({});
328
392
 
329
393
  /**
330
394
  * @description 标题行内样式
@@ -333,36 +397,44 @@ const labelStyle = computed(() => {
333
397
  return {
334
398
  textAlign: labelAlign.value,
335
399
  width: addUnit(labelWidth.value),
336
- }
337
- })
400
+ };
401
+ });
338
402
 
339
403
  /**
340
404
  * @description 错误信息校验
341
405
  * */
342
406
  const errorMsg = (rule: RulesVo, value: string): string => {
343
407
  // 手机正则
344
- const phoneExpression = /^1[3-9]\d{9}$/
408
+ const phoneExpression = /^1[3-9]\d{9}$/;
345
409
  // 邮箱正则
346
- const emitExpression = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/
410
+ const emitExpression = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,6}$/;
347
411
  // 复杂密码正则
348
412
  const passwordExpression =
349
- /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]).{8,}$/
413
+ /^(?=.*[a-z])(?=.*[A-Z])(?=.*\d)(?=.*[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]).{8,}$/;
350
414
  if (rule.required && !value) {
351
- return rule.message!
352
- } else if ((rule?.min || rule?.max) && (value.length < rule?.min! || value.length > rule?.max!)) {
353
- return rule.message!
354
- } else if (rule.type === 'phone' && !phoneExpression.test(String(value))) {
355
- return rule.message || '请输入正确的手机号'
356
- } else if (rule.type === 'email' && !emitExpression.test(String(value))) {
357
- return rule.message || '请输入正确的邮箱格式'
358
- } else if (rule.type === 'password' && !passwordExpression.test(String(value))) {
359
- return rule.message || '至少8个字符串,并且包含大、小写字母、数字和特殊符号'
415
+ return rule.message!;
416
+ } else if (
417
+ (rule?.min || rule?.max) &&
418
+ (value.length < rule?.min! || value.length > rule?.max!)
419
+ ) {
420
+ return rule.message!;
421
+ } else if (rule.type === "phone" && !phoneExpression.test(String(value))) {
422
+ return rule.message || "请输入正确的手机号";
423
+ } else if (rule.type === "email" && !emitExpression.test(String(value))) {
424
+ return rule.message || "请输入正确的邮箱格式";
425
+ } else if (
426
+ rule.type === "password" &&
427
+ !passwordExpression.test(String(value))
428
+ ) {
429
+ return (
430
+ rule.message || "至少8个字符串,并且包含大、小写字母、数字和特殊符号"
431
+ );
360
432
  } else if (rule?.validator && !rule.validator(rule, value)) {
361
- return rule.message || ''
433
+ return rule.message || "";
362
434
  } else {
363
- return ''
435
+ return "";
364
436
  }
365
- }
437
+ };
366
438
 
367
439
  /**
368
440
  * @description 校验字段
@@ -371,28 +443,28 @@ const validateField = (
371
443
  rules: RulesVo | RulesVo[] | undefined,
372
444
  value: string,
373
445
  field: string,
374
- event?: 'blur' | 'change',
446
+ event?: "blur" | "change",
375
447
  ) => {
376
- if (!rules) return
448
+ if (!rules) return;
377
449
 
378
- let errorMessage = ''
450
+ let errorMessage = "";
379
451
 
380
452
  if (Array.isArray(rules)) {
381
453
  // 遍历所有规则
382
454
  for (const index in rules) {
383
455
  // 判断是否有change事件或者blur事件
384
- if (event && !rules[index]?.trigger?.includes(event)) continue
385
- errorMessage = errorMsg(rules[index], value)
456
+ if (event && !rules[index]?.trigger?.includes(event)) continue;
457
+ errorMessage = errorMsg(rules[index], value);
386
458
  if (errorMessage) {
387
- errors[field] = errorMessage
388
- return
459
+ errors[field] = errorMessage;
460
+ return;
389
461
  }
390
462
  // 可以继续添加更多规则
391
463
  }
392
464
  } else {
393
465
  // 必填校验
394
- if (event && !rules?.trigger?.includes(event)) return
395
- errorMessage = errorMsg(rules, value)
466
+ if (event && !rules?.trigger?.includes(event)) return;
467
+ errorMessage = errorMsg(rules, value);
396
468
  }
397
469
 
398
470
  // 自定义校验规则
@@ -403,61 +475,61 @@ const validateField = (
403
475
  // }
404
476
  // }
405
477
 
406
- errors[field] = errorMessage
407
- }
478
+ errors[field] = errorMessage;
479
+ };
408
480
 
409
481
  /**
410
482
  * @description 提交表单
411
483
  * */
412
484
  const handleSubmit = () => {
413
485
  return new Promise((resolve, reject) => {
414
- let isValid = true
486
+ let isValid = true;
415
487
 
416
488
  // 校验所有字段
417
489
  props.columns.forEach((col) => {
418
- validateField(col.rules, formData.value[col.field], col.field)
490
+ validateField(col.rules, formData.value[col.field], col.field);
419
491
  if (errors[col.field]) {
420
- isValid = false
492
+ isValid = false;
421
493
  }
422
- })
494
+ });
423
495
 
424
496
  if (isValid) {
425
497
  // alert("表单提交成功!");
426
- resolve(formData.value)
498
+ resolve(formData.value);
427
499
  } else {
428
- reject()
429
- error('表单校验失败,请检查输入!')
500
+ reject();
501
+ error("表单校验失败,请检查输入!");
430
502
  }
431
- })
432
- }
503
+ });
504
+ };
433
505
 
434
506
  /**
435
507
  * @description 输入值触发
436
508
  * */
437
509
  const handleChange = (event: string, temp: FormColumnsType) => {
438
510
  if (isInput(temp.type) && temp?.input?.onChange) {
439
- temp.input.onChange(event, temp)
511
+ temp.input.onChange(event, temp);
440
512
  }
441
- validateField(temp.rules, event, temp.field, 'change')
442
- }
513
+ validateField(temp.rules, event, temp.field, "change");
514
+ };
443
515
  /**
444
516
  * @description 输入值触发
445
517
  * */
446
518
  const handleBlur = (event: string, temp: FormColumnsType) => {
447
519
  if (isInput(temp.type) && temp?.input?.onBlur) {
448
- temp.input.onBlur(event, temp)
520
+ temp.input.onBlur(event, temp);
449
521
  }
450
- validateField(temp.rules, event, temp.field, 'blur')
451
- }
522
+ validateField(temp.rules, event, temp.field, "blur");
523
+ };
452
524
 
453
525
  defineExpose({
454
526
  validateField,
455
527
  handleSubmit,
456
- })
528
+ });
457
529
  </script>
458
530
 
459
531
  <style lang="scss" scoped>
460
- @import './index.scss';
532
+ @import "./index.scss";
461
533
  .hy-form--item {
462
534
  flex-direction: v-bind(labelPos);
463
535
  }
@@ -1,4 +1,4 @@
1
- import type { FormColumnsType } from "../../typing";
1
+ import type { FormColumnsType } from "../../libs";
2
2
  import type HyInputProps from "../hy-input/typing";
3
3
  import type HyTextareaProps from "../hy-textarea/typing";
4
4
  import type HySwitchProps from "../hy-switch/typing";
@@ -33,7 +33,7 @@ export default {
33
33
  import { computed, inject, onMounted, onUnmounted, provide, ref } from "vue";
34
34
  import type { PropType } from "vue";
35
35
  import type { IFormContext } from "./typing";
36
- import { addUnit } from "../../utils";
36
+ import { addUnit } from "../../libs";
37
37
 
38
38
  /**
39
39
  * 表单组件子组件,需要搭配hy-form
@@ -49,7 +49,7 @@ export default {
49
49
  import { computed } from "vue";
50
50
  import type { CSSProperties, PropType } from "vue";
51
51
  import type { CustomKeysVo, GridItemVo, IGridEmits } from "./typing";
52
- import { addUnit } from "../../utils";
52
+ import { addUnit } from "../../libs";
53
53
  import type HyIconProps from "../hy-icon/typing";
54
54
  // 组件
55
55
  import HyIcon from "../hy-icon/hy-icon.vue";
@@ -46,7 +46,7 @@ export default {
46
46
  <script setup lang="ts">
47
47
  import { computed } from "vue";
48
48
  import type { PropType, CSSProperties } from "vue";
49
- import { addUnit } from "../../utils";
49
+ import { addUnit } from "../../libs";
50
50
  import type { IIconEmits } from "./typing";
51
51
 
52
52
  /**
@@ -1,5 +1,5 @@
1
1
  @use "../../libs/css/mixin.scss" as *;
2
- @use "../../static/font/iconfont.css" as *;
2
+ @use "../../libs/css/iconfont.css" as *;
3
3
  @use "../../libs/css/theme" as *;
4
4
 
5
5
 
@@ -69,8 +69,7 @@ export default {
69
69
  import { computed, onMounted, ref, watch } from "vue";
70
70
  import type { PropType, CSSProperties } from "vue";
71
71
  import type { IImageEmits } from "./typing";
72
- import { addUnit, getPx } from "../../utils";
73
- import { IconConfig } from "../../config";
72
+ import { IconConfig, addUnit, getPx } from "../../libs";
74
73
  // 组件
75
74
  import HyIcon from "../hy-icon/hy-icon.vue";
76
75
  import HyTransition from "../hy-transition/hy-transition.vue";
@@ -1,12 +1,12 @@
1
- import type IProps from './typing'
2
- import { IconConfig } from '../../config'
1
+ import type IProps from "./typing";
2
+ import { IconConfig } from "../../libs/config";
3
3
 
4
4
  const defaultProps: IProps = {
5
- src: '',
6
- mode: 'aspectFill',
7
- width: '',
8
- height: '',
9
- shape: 'square',
5
+ src: "",
6
+ mode: "aspectFill",
7
+ width: "",
8
+ height: "",
9
+ shape: "square",
10
10
  radius: 0,
11
11
  lazyLoad: true,
12
12
  showMenuByLongPress: true,
@@ -17,9 +17,9 @@ const defaultProps: IProps = {
17
17
  fade: true,
18
18
  webp: false,
19
19
  duration: 500,
20
- bgColor: '',
20
+ bgColor: "",
21
21
  indistinct: false,
22
22
  previewImage: false,
23
- }
23
+ };
24
24
 
25
- export default defaultProps
25
+ export default defaultProps;
@@ -113,8 +113,7 @@ export default {
113
113
  import { computed, nextTick, ref, watch, inject } from "vue";
114
114
  import type { CSSProperties, PropType } from "vue";
115
115
  import HyIcon from "../hy-icon/hy-icon.vue";
116
- import { addUnit, formatObject, sleep } from "../../utils";
117
- import { IconConfig } from "../../config";
116
+ import { addUnit, formatObject, sleep, IconConfig } from "../../libs";
118
117
  import type { IInputEmits } from "./typing";
119
118
  import type HyIconProps from "../hy-icon/typing";
120
119
  import type { FormItemContext } from "../hy-form-item/typing";
@@ -16,7 +16,7 @@ export default {
16
16
  <script setup lang="ts">
17
17
  import { computed } from "vue";
18
18
  import type { CSSProperties, PropType } from "vue";
19
- import { addUnit } from "../../utils";
19
+ import { addUnit } from "../../libs";
20
20
 
21
21
  /**
22
22
  * 一般用于显示一根线条,用于分隔内容块,有横向和竖向两种模式,且能设置0.5px线条,使用也很简单。
@@ -40,12 +40,11 @@ import { computed, getCurrentInstance, onMounted, ref, watch } from "vue";
40
40
  import type { CSSProperties, PropType } from "vue";
41
41
  import {
42
42
  addUnit,
43
- getPx,
44
43
  getRect,
45
44
  range,
46
45
  type RectResultType,
47
46
  sleep,
48
- } from "../../utils";
47
+ } from "../../libs";
49
48
 
50
49
  /**
51
50
  * 展示操作或任务的当前进度,比如上传文件,是一个线形的进度条。
@@ -88,7 +88,7 @@ import {
88
88
  watch,
89
89
  } from "vue";
90
90
  import type { CSSProperties } from "vue";
91
- import { addUnit, getPx, getRect } from "../../utils";
91
+ import { addUnit, getPx, getRect } from "../../libs";
92
92
  import type { IListEmits } from "./typing";
93
93
 
94
94
  /**
@@ -59,7 +59,7 @@ export default {
59
59
  <script setup lang="ts">
60
60
  import { ref, computed } from "vue";
61
61
  import type { CSSProperties, PropType } from "vue";
62
- import { addUnit, colorGradient } from "../../utils";
62
+ import { addUnit, colorGradient } from "../../libs";
63
63
 
64
64
  /**
65
65
  * 目前用在华玥的loadMore加载更多等组件的正在加载状态场景。