uview-pro 0.3.5 → 0.3.7

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 (47) hide show
  1. package/changelog.md +46 -0
  2. package/components/u-calendar/types.ts +3 -2
  3. package/components/u-calendar/u-calendar.vue +2 -2
  4. package/components/u-checkbox/u-checkbox.vue +1 -1
  5. package/components/u-checkbox-group/types.ts +2 -1
  6. package/components/u-checkbox-group/u-checkbox-group.vue +1 -1
  7. package/components/u-city-select/u-city-select.vue +2 -2
  8. package/components/u-dropdown/types.ts +3 -2
  9. package/components/u-dropdown/u-dropdown.vue +1 -1
  10. package/components/u-form/u-form.vue +14 -9
  11. package/components/u-form-item/u-form-item.vue +9 -6
  12. package/components/u-index-anchor/u-index-anchor.vue +1 -1
  13. package/components/u-index-list/types.ts +2 -1
  14. package/components/u-index-list/u-index-list.vue +3 -3
  15. package/components/u-input/types.ts +5 -0
  16. package/components/u-input/u-input.vue +28 -8
  17. package/components/u-link/types.ts +2 -1
  18. package/components/u-message-input/types.ts +3 -2
  19. package/components/u-message-input/u-message-input.vue +1 -1
  20. package/components/u-modal/types.ts +3 -2
  21. package/components/u-modal/u-modal.vue +1 -1
  22. package/components/u-picker/types.ts +8 -2
  23. package/components/u-picker/u-picker.vue +276 -126
  24. package/components/u-radio/u-radio.vue +2 -2
  25. package/components/u-radio-group/types.ts +2 -1
  26. package/components/u-radio-group/u-radio-group.vue +1 -1
  27. package/components/u-read-more/types.ts +2 -1
  28. package/components/u-read-more/u-read-more.vue +1 -1
  29. package/components/u-select/types.ts +5 -2
  30. package/components/u-select/u-select.vue +56 -18
  31. package/components/u-slider/types.ts +3 -2
  32. package/components/u-slider/u-slider.vue +2 -2
  33. package/components/u-step/types.ts +29 -0
  34. package/components/u-step/u-step.vue +264 -0
  35. package/components/u-steps/types.ts +3 -2
  36. package/components/u-steps/u-steps.vue +17 -106
  37. package/components/u-switch/types.ts +2 -1
  38. package/components/u-switch/u-switch.vue +2 -2
  39. package/components/u-tabs/types.ts +3 -2
  40. package/components/u-tabs/u-tabs.vue +1 -1
  41. package/components/u-tabs-swiper/types.ts +3 -2
  42. package/components/u-tabs-swiper/u-tabs-swiper.vue +1 -1
  43. package/components/u-textarea/types.ts +88 -0
  44. package/components/u-textarea/u-textarea.vue +339 -0
  45. package/package.json +1 -1
  46. package/types/components.d.ts +2 -0
  47. package/types/global.d.ts +2 -0
package/changelog.md CHANGED
@@ -1,3 +1,49 @@
1
+ ## 0.3.7(2025-10-28)
2
+
3
+ ### 🐛 Bug Fixes | Bug 修复
4
+
5
+ - **u-index-list:** 修复 u-index-list 组件中 indexList 的响应式,确保数据正确对应,滚动到正确的锚点 ([536479b](https://github.com/anyup/uView-Pro/commit/536479b0c444f50892c789191265b373297ec0b5))
6
+ - **u-form:** 优化 u-form-item 组件样式,修复微信小程序光标样式偏移问题 ([7e6694b](https://github.com/anyup/uView-Pro/commit/7e6694b5db11f654b081d10bb83d53c99437c730))
7
+ - **u-form:** 优化 model 属性的响应式更新,修复 model 对象整体替换导致的表单校验失效问题 ([bc49b5b](https://github.com/anyup/uView-Pro/commit/bc49b5b2fa6f51c803d64252184f5eba93a0d3c1))
8
+ - **u-form:** 修复 u-form 的重置表单方法 resetFields 失效问题 ([a31f800](https://github.com/anyup/uView-Pro/commit/a31f800e206fa9671bdd0d6a46ca7a4afba6aefd))
9
+ - **u-checkbox:** 修复 u-checkbox 单独使用报错的问题 ([dad2832](https://github.com/anyup/uView-Pro/commit/dad2832a2e7219b0454ec97970c9cb8f4fac0625))
10
+
11
+ ### ✨ Features | 新功能
12
+
13
+ - **u-textarea:** 新增 u-textarea 组件及演示示例,增强 textarea 功能,分离 u-input 的 textarea 模式 ([efbb75e](https://github.com/anyup/uView-Pro/commit/efbb75e21a044a664267930396ce496fd64d33fe))
14
+ - **u-input:** 增强 u-input 的 textarea 字数统计功能 ([5e14354](https://github.com/anyup/uView-Pro/commit/5e14354a2e34768650cd2417f81b14cdbbced132))
15
+ - **u-form:** 增强表单校验功能,发射校验错误,便于自定义提示 ([a553b53](https://github.com/anyup/uView-Pro/commit/a553b53581cc470938030c0f1f8d5f7671d8c25a))
16
+
17
+ ### ♻️ Code Refactoring | 代码重构
18
+
19
+ - **form:** 优化表单组件的提示文本 ([04b5fc7](https://github.com/anyup/uView-Pro/commit/04b5fc7a071835425786958c5f6de04e233c151c))
20
+
21
+ ### 👥 Contributors
22
+
23
+ <a href="https://github.com/anyup"><img src="https://github.com/anyup.png?size=40" width="40" height="40" alt="anyup" title="anyup"/></a>
24
+
25
+ ## 0.3.6(2025-10-24)
26
+
27
+ ### ✨ Features | 新功能
28
+
29
+ - **u-select:** 优化选择器组件 u-select 默认值处理逻辑,添加 preserveSelection 属性,用于控制是否保留用户上次确认的选择 ([8493ff1](https://github.com/anyup/uView-Pro/commit/8493ff16d2eee42fabe926917d940a350b86abe0))
30
+ - **u-picker:** 优化 picker 的初始化和渲染流程,实现多次打开 picker 时保留用户选择的逻辑,新增 preserveSelection 属性支持 ([974872e](https://github.com/anyup/uView-Pro/commit/974872ec944fbb28cdb3c40fda08c9039bf0b960))
31
+
32
+ ### ♻️ Code Refactoring | 代码重构
33
+
34
+ - **components:** 使用主题色替代硬编码颜色值,统一组件的颜色风格,便于未来主题颜色的调整和维护 ([ec348d4](https://github.com/anyup/uView-Pro/commit/ec348d4a8bff4dee62da78eadd23fc3a292ebdca))
35
+ - **example:** 代码示例中使用主题色替换硬编码颜色值 ([3216497](https://github.com/anyup/uView-Pro/commit/32164973d54cfff3edcbe765a8ed27158f4bec7d))
36
+ - **u-steps:** 新增u-step ([6b86eea](https://github.com/anyup/uView-Pro/commit/6b86eeaf7699eb13f739fc038d86efb4e3b48f8a))
37
+ - **u-step:** 替换步骤条组件中的默认硬编码颜色值 ([f3408ef](https://github.com/anyup/uView-Pro/commit/f3408ef006991702895432e775f266fb196ddf12))
38
+
39
+ ### 🐛 Bug Fixes | Bug 修复
40
+
41
+ - **u-picker:** 修复使用u-picker组件选择地区不设置默认值报错的问题 ([7941135](https://github.com/anyup/uView-Pro/commit/7941135a87a3511a562ed10e34573ef7f786fb57))
42
+
43
+ ### 👥 Contributors
44
+
45
+ <a href="https://github.com/anyup"><img src="https://github.com/anyup.png?size=40" width="40" height="40" alt="anyup" title="anyup"/></a> <a href="https://github.com/lonelyflyer"><img src="https://github.com/lonelyflyer.png?size=40" width="40" height="40" alt="Lonelyflyer" title="Lonelyflyer"/></a>
46
+
1
47
  ## 0.3.5(2025-10-21)
2
48
 
3
49
  ### 🐛 Bug Fixes | Bug 修复
@@ -1,6 +1,7 @@
1
1
  import { type ExtractPropTypes, type PropType } from 'vue';
2
2
  import type { CalendarChangeDate, CalendarChangeRange, CalendarMode, ThemeType } from '../../types/global';
3
3
  import { baseProps } from '../common/props';
4
+ import { $u } from '../../';
4
5
 
5
6
  /**
6
7
  * calendar 日历类型定义
@@ -39,13 +40,13 @@ export const CalendarProps = {
39
40
  /** 默认日期字体颜色 */
40
41
  color: { type: String, default: '#303133' },
41
42
  /** 选中|起始结束日期背景色 */
42
- activeBgColor: { type: String, default: '#2979ff' },
43
+ activeBgColor: { type: String, default: $u.color.primary },
43
44
  /** 选中|起始结束日期字体颜色 */
44
45
  activeColor: { type: String, default: '#ffffff' },
45
46
  /** 范围内日期背景色 */
46
47
  rangeBgColor: { type: String, default: 'rgba(41,121,255,0.13)' },
47
48
  /** 范围内日期字体颜色 */
48
- rangeColor: { type: String, default: '#2979ff' },
49
+ rangeColor: { type: String, default: $u.color.primary },
49
50
  /** mode=range时生效,起始日期自定义文案 */
50
51
  startText: { type: String, default: '开始' },
51
52
  /** mode=range时生效,结束日期自定义文案 */
@@ -270,11 +270,11 @@ import Calendar from '../../libs/util/calendar';
270
270
  * @property {String} month-arrow-color 月份切换按钮箭头颜色(默认#606266)
271
271
  * @property {String} year-arrow-color 年份切换按钮箭头颜色(默认#909399)
272
272
  * @property {String} color 日期字体的默认颜色(默认#303133)
273
- * @property {String} active-bg-color 起始/结束日期按钮的背景色(默认#2979ff)
273
+ * @property {String} active-bg-color 起始/结束日期按钮的背景色(默认主题色primary)
274
274
  * @property {String Number} z-index 弹出时的z-index值(默认10075)
275
275
  * @property {String} active-color 起始/结束日期按钮的字体颜色(默认#ffffff)
276
276
  * @property {String} range-bg-color 起始/结束日期之间的区域的背景颜色(默认rgba(41,121,255,0.13))
277
- * @property {String} range-color 选择范围内字体颜色(默认#2979ff)
277
+ * @property {String} range-color 选择范围内字体颜色(默认主题色primary)
278
278
  * @property {String} start-text 起始日期底部的提示文字(默认 '开始')
279
279
  * @property {String} end-text 结束日期底部的提示文字(默认 '结束')
280
280
  * @property {String} btn-type 底部确定按钮的主题(默认 'primary')
@@ -180,7 +180,7 @@ function setValue() {
180
180
  emitEvent();
181
181
  emit('update:modelValue', false);
182
182
  } else {
183
- if (!parentExposed.value?.validateSelection()) {
183
+ if (parentExposed?.value?.validateSelection && !parentExposed?.value?.validateSelection()) {
184
184
  return;
185
185
  }
186
186
  emitEvent();
@@ -1,6 +1,7 @@
1
1
  import { type ExtractPropTypes, type PropType } from 'vue';
2
2
  import type { Shape } from '../../types/global';
3
3
  import { baseProps } from '../common/props';
4
+ import { $u } from '../../';
4
5
 
5
6
  /**
6
7
  * checkbox-group 复选框组类型定义
@@ -20,7 +21,7 @@ export const CheckboxGroupProps = {
20
21
  /** 形状,square为方形,circle为原型 */
21
22
  shape: { type: String as PropType<Shape>, default: 'square' },
22
23
  /** 选中状态下的颜色 */
23
- activeColor: { type: String, default: '#2979ff' },
24
+ activeColor: { type: String, default: $u.color.primary },
24
25
  /** 组件的整体大小 */
25
26
  size: { type: [String, Number], default: 34 },
26
27
  /** 每个checkbox占u-checkbox-group的宽度 */
@@ -34,7 +34,7 @@ import { CheckboxGroupProps } from './types';
34
34
  * @property {String} width 宽度,需带单位
35
35
  * @property {String} shape 外观形状,shape-方形,circle-圆形(默认circle)
36
36
  * @property {Boolean} wrap 是否每个checkbox都换行(默认false)
37
- * @property {String} active-color 选中时的颜色,应用到所有子Checkbox组件(默认#2979ff
37
+ * @property {String} active-color 选中时的颜色,应用到所有子Checkbox组件(默认主题色primary
38
38
  * @event {Function} change 任一个checkbox状态发生变化时触发,回调为一个对象
39
39
  * @example <u-checkbox-group></u-checkbox-group>
40
40
  */
@@ -116,13 +116,13 @@ import { $u } from '../..';
116
116
  * u-city-select 城市选择器
117
117
  * @description 用于选择省、市、区三级行政区域,支持回显和自定义初始值。
118
118
  * @property {Boolean} modelValue 控制弹窗显示与隐藏(v-model)
119
- * @property {Array} defaultRegion 默认选中的省市区名称数组,如 ['广东省', '广州市', '天河区']
119
+ * @property {Array} defaultRegion 默认选中的省市区名称数组,如 ['山东省', '青岛市', '崂山区']
120
120
  * @property {Array} areaCode 默认选中的省市区编码数组,如 ['440000', '440100', '440106']
121
121
  * @property {Boolean} maskCloseAble 是否允许点击遮罩关闭弹窗(默认 true)
122
122
  * @property {String|Number} zIndex 弹窗层级(默认 0,自动适配)
123
123
  * @event update:modelValue v-model 绑定值变化时触发
124
124
  * @event city-change 选择省市区后触发,返回选中的省市区对象
125
- * @example <u-city-select v-model="show" :defaultRegion="['广东省','广州市','天河区']" @city-change="onChange"></u-city-select>
125
+ * @example <u-city-select v-model="show" :defaultRegion="['山东省', '青岛市', '崂山区']" @city-change="onChange"></u-city-select>
126
126
  */
127
127
  const props = defineProps(CitySelectProps);
128
128
 
@@ -1,5 +1,6 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
2
  import { baseProps } from '../common/props';
3
+ import { $u } from '../../';
3
4
 
4
5
  /**
5
6
  * u-dropdown 下拉菜单 Props
@@ -8,9 +9,9 @@ import { baseProps } from '../common/props';
8
9
  export const DropdownProps = {
9
10
  ...baseProps,
10
11
  /** 菜单标题和选项的激活态颜色 */
11
- activeColor: { type: String, default: '#2979ff' },
12
+ activeColor: { type: String, default: $u.color.primary },
12
13
  /** 菜单标题和选项的未激活态颜色 */
13
- inactiveColor: { type: String, default: '#606266' },
14
+ inactiveColor: { type: String, default: $u.color.contentColor },
14
15
  /** 点击遮罩是否关闭菜单 */
15
16
  closeOnClickMask: { type: Boolean, default: true },
16
17
  /** 点击当前激活项标题是否关闭菜单 */
@@ -83,7 +83,7 @@ import { DropdownProps } from './types';
83
83
  * dropdown 下拉菜单
84
84
  * @description 该组件一般用于向下展开菜单,同时可切换多个选项卡的场景
85
85
  * @tutorial https://uviewpro.cn/zh/components/dropdown.html
86
- * @property {String} active-color 标题和选项卡选中的颜色(默认#2979ff
86
+ * @property {String} active-color 标题和选项卡选中的颜色(默认主题色primary
87
87
  * @property {String} inactive-color 标题和选项卡未选中的颜色(默认#606266)
88
88
  * @property {Boolean} close-on-click-mask 点击遮罩是否关闭菜单(默认true)
89
89
  * @property {Boolean} close-on-click-self 点击当前激活项标题是否关闭菜单(默认true)
@@ -19,7 +19,7 @@ export default {
19
19
 
20
20
  <script setup lang="ts">
21
21
  import { FormProps } from './types';
22
- import { ref } from 'vue';
22
+ import { computed, ref } from 'vue';
23
23
  import { $u, useParent } from '../..';
24
24
 
25
25
  /**
@@ -41,6 +41,11 @@ const props = defineProps(FormProps);
41
41
 
42
42
  useParent('u-form');
43
43
 
44
+ interface ErrorItem {
45
+ prop: string;
46
+ message: string;
47
+ }
48
+
44
49
  // 存储当前form下的所有u-form-item的实例
45
50
  const fields = ref<any[]>([]);
46
51
 
@@ -69,15 +74,15 @@ function resetFields() {
69
74
  * @param callback 校验回调
70
75
  * @returns Promise<boolean>
71
76
  */
72
- function validate(callback?: (valid: boolean) => void): Promise<boolean> {
77
+ function validate(callback?: (valid: boolean, errorArr: ErrorItem[]) => void): Promise<boolean> {
73
78
  return new Promise(resolve => {
74
79
  // 对所有的u-form-item进行校验
75
80
  let valid = true; // 默认通过
76
81
  let count = 0; // 用于标记是否检查完毕
77
- let errorArr: any[] = []; // 存放错误信息
82
+ let errorArr: ErrorItem[] = []; // 存放错误信息
78
83
  if (fields.value.length === 0) {
79
84
  resolve(true);
80
- if (typeof callback === 'function') callback(true);
85
+ if (typeof callback === 'function') callback(true, []);
81
86
  return;
82
87
  }
83
88
  // 调用每一个u-form-item实例的validation的校验方法
@@ -87,7 +92,7 @@ function validate(callback?: (valid: boolean) => void): Promise<boolean> {
87
92
  field.validation('', (error: any) => {
88
93
  if (error) {
89
94
  valid = false;
90
- errorArr.push(error);
95
+ errorArr.push({ prop: field.prop, message: error });
91
96
  }
92
97
  // 当历遍了所有的u-form-item时,调用promise的then方法
93
98
  if (++count === fields.value.length) {
@@ -96,12 +101,12 @@ function validate(callback?: (valid: boolean) => void): Promise<boolean> {
96
101
  if (
97
102
  props.errorType.indexOf('none') === -1 &&
98
103
  props.errorType.indexOf('toast') >= 0 &&
99
- errorArr.length
104
+ errorArr.length > 0
100
105
  ) {
101
- $u.toast(errorArr[0]);
106
+ errorArr[0].message && $u.toast(errorArr[0].message);
102
107
  }
103
108
  // 调用回调方法
104
- if (typeof callback === 'function') callback(valid);
109
+ if (typeof callback === 'function') callback(valid, errorArr);
105
110
  }
106
111
  });
107
112
  });
@@ -121,7 +126,7 @@ defineExpose({
121
126
  fields,
122
127
  rules,
123
128
  props,
124
- model: props.model
129
+ model: computed(() => props.model)
125
130
  });
126
131
  </script>
127
132
 
@@ -269,7 +269,7 @@ function getFilteredRule(triggerType = '') {
269
269
  */
270
270
  function validation(trigger: string, callback: (msg: string) => void = () => {}) {
271
271
  // 检验之前,先获取需要校验的值
272
- fieldValue.value = parentExposed?.value?.model?.[props.prop];
272
+ fieldValue.value = parentExposed?.value?.model?.value[props.prop];
273
273
  // blur和change是否有当前方式的校验规则
274
274
  let rules = getFilteredRule(trigger);
275
275
  // 判断是否有验证规则,如果没有规则,也调用回调方法,否则父组件u-form会因为
@@ -295,11 +295,14 @@ function validation(trigger: string, callback: (msg: string) => void = () => {})
295
295
  * 清空当前的u-form-item
296
296
  */
297
297
  function resetField() {
298
- if (parentExposed?.value?.model && props.prop) {
299
- parentExposed.value.model[props.prop] = initialValue.value;
298
+ if (parentExposed?.value?.model?.value && props.prop) {
299
+ parentExposed.value.model.value[props.prop] = initialValue.value;
300
300
  }
301
301
  // 设置为`success`状态,只是为了清空错误标记
302
- validateState.value = 'success';
302
+ // 延时50毫秒,如果立即清空状态,则无法清空错误标记
303
+ setTimeout(() => {
304
+ validateState.value = 'success';
305
+ }, 50);
303
306
  }
304
307
 
305
308
  // 组件挂载时注册到父表单
@@ -322,7 +325,7 @@ onMounted(() => {
322
325
  });
323
326
  errorType.value = parentExposed?.value?.errorType || errorType.value;
324
327
  // 设置初始值
325
- fieldValue.value = parentExposed?.value?.model?.[props.prop];
328
+ fieldValue.value = parentExposed?.value?.model?.value[props.prop];
326
329
  // 设置初始值
327
330
  initialValue.value = fieldValue.value;
328
331
  }
@@ -355,7 +358,7 @@ defineExpose({
355
358
  font-size: 28rpx;
356
359
  color: $u-main-color;
357
360
  box-sizing: border-box;
358
- line-height: $u-form-item-height;
361
+ // line-height: $u-form-item-height;
359
362
  flex-direction: column;
360
363
 
361
364
  &__border-bottom--error:after {
@@ -114,7 +114,7 @@ defineExpose({
114
114
  .u-index-anchor--active {
115
115
  right: 0;
116
116
  left: 0;
117
- color: #2979ff;
117
+ color: $u-type-primary;
118
118
  background-color: #fff;
119
119
  }
120
120
  </style>
@@ -1,4 +1,5 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
+ import { $u } from '../../';
2
3
 
3
4
  /**
4
5
  * u-index-list 组件 props 类型定义
@@ -33,7 +34,7 @@ export const IndexListProps = {
33
34
  /** 锚点和右边索引字符高亮颜色 */
34
35
  activeColor: {
35
36
  type: String,
36
- default: '#2979ff'
37
+ default: $u.color.primary
37
38
  }
38
39
  };
39
40
 
@@ -61,7 +61,7 @@ import { IndexListProps } from './types';
61
61
  * @property {Number|String} z-index 锚点吸顶时的层级(默认965)
62
62
  * @property {Boolean} sticky 是否开启锚点自动吸顶(默认true)
63
63
  * @property {Number|String} offset-top 锚点自动吸顶时与顶部的距离(默认0)
64
- * @property {String} highlight-color 锚点和右边索引字符高亮颜色(默认#2979ff
64
+ * @property {String} highlight-color 锚点和右边索引字符高亮颜色(默认主题色primary
65
65
  * @event {Function} select 选中右边索引字符时触发
66
66
  * @example <u-index-list :scrollTop="scrollTop"></u-index-list>
67
67
  */
@@ -95,7 +95,7 @@ const stickyOffsetTop = ref(0);
95
95
  // 弹出toast的z-index值
96
96
  const alertZIndex = computed(() => $u.zIndex.toast).value;
97
97
  // indexList 响应式
98
- const indexList = computed(() => props.indexList ?? getIndexList()).value;
98
+ const indexList = computed(() => props?.indexList ?? getIndexList());
99
99
  const zIndex = computed(() => props.zIndex).value;
100
100
  const activeColor = computed(() => props.activeColor).value;
101
101
 
@@ -278,7 +278,7 @@ function scrollToAnchor(index: number) {
278
278
  return;
279
279
  }
280
280
  scrollToAnchorIndex.value = index;
281
- const anchor = children.find(item => item.getExposed().props.index === indexList[index]);
281
+ const anchor = children.find(item => item.getExposed().props.index === indexList.value[index]);
282
282
  if (anchor) {
283
283
  emit('select', anchor.getExposed().props.index);
284
284
  uni.pageScrollTo({
@@ -39,6 +39,11 @@ export const InputProps = {
39
39
  type: [Number, String] as PropType<number | string>,
40
40
  default: 140
41
41
  },
42
+ // 是否显示统计字数,仅textarea有效
43
+ count: {
44
+ type: Boolean,
45
+ default: false
46
+ },
42
47
  /** placeholder的样式,字符串形式,如"color: red;"(默认 "color: #c0c4cc;") */
43
48
  placeholderStyle: {
44
49
  type: String,
@@ -9,7 +9,7 @@
9
9
  customClass
10
10
  ]"
11
11
  :style="{
12
- padding: `0 ${border ? 20 : 0}rpx`,
12
+ padding: type === 'textarea' ? (border ? '20rpx' : '0') : `0 ${border ? 20 : 0}rpx`,
13
13
  borderColor: borderColor,
14
14
  textAlign: inputAlign
15
15
  }"
@@ -88,6 +88,15 @@
88
88
  <u-icon name="arrow-down-fill" size="26" color="#c0c4cc"></u-icon>
89
89
  </view>
90
90
  </view>
91
+ <text
92
+ class="u-input__count"
93
+ :style="{
94
+ 'background-color': props.disabled ? 'transparent' : '#fff'
95
+ }"
96
+ v-if="props.type === 'textarea' && props.count"
97
+ >
98
+ {{ String(defaultValue).length }}/{{ props.maxlength }}
99
+ </text>
91
100
  </view>
92
101
  </template>
93
102
 
@@ -167,10 +176,10 @@ function handleInput(event: any) {
167
176
  let value = event.detail.value;
168
177
  // 判断是否去除空格
169
178
  if (props.trim) value = $u.trim(value);
170
- emit('update:modelValue', value);
171
- emit('input', value);
172
179
  // 当前model 赋值
173
180
  defaultValue.value = value;
181
+ emit('update:modelValue', value);
182
+ emit('input', value);
174
183
  // 过一个生命周期再发送事件给u-form-item,否则this.$emit('update:modelValue')更新了父组件的值,但是微信小程序上
175
184
  // 尚未更新到u-form-item,导致获取的值为空,从而校验混论
176
185
  // 这里不能延时时间太短,或者使用this.$nextTick,否则在头条上,会造成混乱
@@ -192,12 +201,12 @@ function handleInput(event: any) {
192
201
  function handleBlur(event: any) {
193
202
  // 最开始使用的是监听图标@touchstart事件,自从hx2.8.4后,此方法在微信小程序出错
194
203
  // 这里改为监听点击事件,手点击清除图标时,同时也发生了@blur事件,导致图标消失而无法点击,这里做一个延时
195
- let value = event.detail.value;
196
204
  setTimeout(() => {
197
205
  focused.value = false;
198
206
  }, 100);
199
- emit('blur', value);
200
207
  setTimeout(() => {
208
+ let value = String(defaultValue.value);
209
+ emit('blur', value);
201
210
  // 头条小程序由于自身bug,导致中文下,每按下一个键(尚未完成输入),都会触发一次@input,导致错误,这里进行判断处理
202
211
  // #ifdef MP-TOUTIAO
203
212
  if ($u.trim(value) == lastValue.value) return;
@@ -226,7 +235,7 @@ function onClear(event: any) {
226
235
  } catch (e) {
227
236
  console.log(e);
228
237
  }
229
- emit('update:modelValue', '');
238
+ handleInput({ detail: { value: '' } });
230
239
  }
231
240
 
232
241
  function inputClick() {
@@ -257,13 +266,24 @@ defineExpose({
257
266
  width: auto;
258
267
  font-size: 28rpx;
259
268
  color: $u-main-color;
260
- padding: 10rpx 0;
269
+ // padding: 10rpx 0;
261
270
  line-height: normal;
262
271
  flex: 1;
263
272
  }
264
273
 
274
+ &__count {
275
+ position: absolute;
276
+ right: 1px;
277
+ bottom: 0;
278
+ font-size: 12px;
279
+ color: $u-tips-color;
280
+ background-color: #ffffff;
281
+ padding: 1px 4px;
282
+ border-radius: 10px;
283
+ line-height: 16px;
284
+ }
285
+
265
286
  &--border {
266
- border-radius: 6rpx;
267
287
  border-radius: 4px;
268
288
  border: 1px solid $u-form-item-border-color;
269
289
  }
@@ -1,4 +1,5 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
+ import { $u } from '../../';
2
3
 
3
4
  /**
4
5
  * u-link 组件 props 类型定义
@@ -8,7 +9,7 @@ export const LinkProps = {
8
9
  /** 文字颜色 */
9
10
  color: {
10
11
  type: String,
11
- default: '#2979ff'
12
+ default: $u.color.primary
12
13
  },
13
14
  /** 字体大小,单位rpx */
14
15
  fontSize: {
@@ -1,5 +1,6 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
2
  import type { MessageInputMode } from '../../types/global';
3
+ import { $u } from '../../';
3
4
 
4
5
  /**
5
6
  * u-message-input 组件 props 类型定义
@@ -49,12 +50,12 @@ export const MessageInputProps = {
49
50
  /** 激活样式 */
50
51
  activeColor: {
51
52
  type: String,
52
- default: '#2979ff'
53
+ default: $u.color.primary
53
54
  },
54
55
  /** 未激活的样式 */
55
56
  inactiveColor: {
56
57
  type: String,
57
- default: '#606266'
58
+ default: $u.color.contentColor
58
59
  },
59
60
  /** 输入框的大小,单位rpx,宽等于高 */
60
61
  width: {
@@ -99,7 +99,7 @@ import { MessageInputProps } from './types';
99
99
  * @property {Boolean} focus 是否自动获取焦点(默认false)
100
100
  * @property {Boolean} bold 字体和输入横线是否加粗(默认true)
101
101
  * @property {String|Number} font-size 字体大小,单位rpx(默认60)
102
- * @property {String} active-color 当前激活输入框的样式(默认#2979ff
102
+ * @property {String} active-color 当前激活输入框的样式(默认主题色primary
103
103
  * @property {String} inactive-color 非激活输入框的样式,文字颜色同此值(默认#606266)
104
104
  * @property {String|Number} width 输入框宽度,单位rpx,高等于宽(默认80)
105
105
  * @property {Boolean} disabled-keyboard 禁止点击输入框唤起系统键盘(默认false)
@@ -1,4 +1,5 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
+ import { $u } from '../../';
2
3
 
3
4
  /**
4
5
  * u-modal 组件 props 类型定义
@@ -58,12 +59,12 @@ export const ModalProps = {
58
59
  /** 确认按钮颜色 */
59
60
  confirmColor: {
60
61
  type: String,
61
- default: '#2979ff'
62
+ default: $u.color.primary
62
63
  },
63
64
  /** 取消文字颜色 */
64
65
  cancelColor: {
65
66
  type: String,
66
- default: '#606266'
67
+ default: $u.color.contentColor
67
68
  },
68
69
  /** 圆角值 */
69
70
  borderRadius: {
@@ -88,7 +88,7 @@ import { ModalProps } from './types';
88
88
  * @property {String} confirm-text 确认按钮的文字内容(默认"确认")
89
89
  * @property {String} cancel-text 取消按钮的文字内容(默认"取消")
90
90
  * @property {String} cancel-color 取消按钮的颜色(默认"#606266")
91
- * @property {String} confirm-color 确认按钮的文字内容(默认"#2979ff"
91
+ * @property {String} confirm-color 确认按钮的文字内容(默认主题色primary
92
92
  * @property {String | Number} border-radius 模态框圆角值,单位rpx(默认16)
93
93
  * @property {Object} title-style 自定义标题样式,对象形式
94
94
  * @property {Object} content-style 自定义内容样式,对象形式
@@ -1,5 +1,6 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
2
  import type { PickerMode, PickerParams } from '../../types/global';
3
+ import { $u } from '../../';
3
4
 
4
5
  const defaultParams: PickerParams = {
5
6
  year: true,
@@ -33,6 +34,11 @@ export const PickerProps = {
33
34
  type: Array as PropType<any[]>,
34
35
  default: () => [0]
35
36
  },
37
+ /** 是否保留用户上次确认的选择(true:优先使用已保存选择;false:优先使用外部传入的 defaultSelector/defaultTime/defaultRegion) */
38
+ preserveSelection: {
39
+ type: Boolean,
40
+ default: true
41
+ },
36
42
  /** 当 range 是一个 Array<Object> 时,通过 range-key 来指定 Object 中 key 的值作为选择器显示内容 */
37
43
  rangeKey: {
38
44
  type: String,
@@ -56,12 +62,12 @@ export const PickerProps = {
56
62
  /** "取消"按钮的颜色 */
57
63
  cancelColor: {
58
64
  type: String,
59
- default: '#606266'
65
+ default: $u.color.contentColor
60
66
  },
61
67
  /** "确定"按钮的颜色 */
62
68
  confirmColor: {
63
69
  type: String,
64
- default: '#2979ff'
70
+ default: $u.color.primary
65
71
  },
66
72
  /** 默认显示的时间,2025-07-02 || 2025-07-02 13:01:00 || 2025/07/02 */
67
73
  defaultTime: {