uview-pro 0.6.3 → 0.6.4

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.
package/changelog.md CHANGED
@@ -1,3 +1,15 @@
1
+ ## 0.6.4(2026-06-02)
2
+
3
+ ### ✨ Features | 新功能
4
+
5
+ - **u-input:** 新增readonly输入属性,支持设置输入框只读状态,新增禁用与只读示例页面及配置项(#160) ([6a92373](https://github.com/anyup/uView-Pro/commit/6a92373a6c8a1c2875b93d6dbb3985df34887c4e))
6
+ - **u-textarea:** 新增click事件支持,在只读/非禁用状态下可触发点击回调,更新演示页面(#160) ([a79dc57](https://github.com/anyup/uView-Pro/commit/a79dc57262bfb3909d2f35bbf26589906e9a4c8d))
7
+ - **u-field:** 新增readonly属性支持,设置后可点击但无法输入,调整disabled和readonly状态的遮罩逻辑与样式(#160) ([708f13b](https://github.com/anyup/uView-Pro/commit/708f13bb3601c0c77a0a75f1b4d1c148f28c7229))
8
+
9
+ ### 👥 Contributors
10
+
11
+ <a href="https://github.com/anyup"><img src="https://github.com/anyup.png?size=40" width="40" height="40" alt="anyup" title="anyup"/></a>
12
+
1
13
  ## 0.6.3(2026-05-28)
2
14
 
3
15
  ### 🐛 Bug Fixes | Bug 修复
@@ -56,6 +56,8 @@ export const FieldProps = {
56
56
  type: { type: String as PropType<InputType>, default: 'text' },
57
57
  /** 是否不可输入(默认false) */
58
58
  disabled: { type: Boolean, default: false },
59
+ /** 是否只读,禁止输入但可点击,样式不变,可触发click事件(默认false) */
60
+ readonly: { type: Boolean, default: false },
59
61
  /** 最大输入长度,设置为 -1 的时候不限制最大长度(默认140) */
60
62
  maxlength: { type: [Number, String] as PropType<string | number>, default: 140 },
61
63
  /** 设置键盘右下角按钮的文字,仅在type="text"时生效(默认done) */
@@ -1,7 +1,14 @@
1
1
  <template>
2
2
  <view
3
3
  class="u-field"
4
- :class="[{ 'u-border-top': props.borderTop, 'u-border-bottom': props.borderBottom }, customClass]"
4
+ :class="[
5
+ {
6
+ 'u-border-top': props.borderTop,
7
+ 'u-border-bottom': props.borderBottom,
8
+ 'u-field--disabled': props.disabled
9
+ },
10
+ customClass
11
+ ]"
5
12
  :style="$u.toStyle(customStyle)"
6
13
  >
7
14
  <view
@@ -40,6 +47,7 @@
40
47
  :placeholder="String(props.placeholder)"
41
48
  :placeholderStyle="props.placeholderStyle"
42
49
  :disabled="props.disabled"
50
+ :readonly="props.readonly"
43
51
  :maxlength="inputMaxlength"
44
52
  :focus="props.focus"
45
53
  :autoHeight="props.autoHeight"
@@ -48,7 +56,6 @@
48
56
  @blur="onBlur"
49
57
  @focus="onFocus"
50
58
  @confirm="onConfirm"
51
- @tap="fieldClick"
52
59
  />
53
60
  <!-- prettier-ignore -->
54
61
  <input
@@ -61,6 +68,7 @@
61
68
  :placeholder="String(props.placeholder)"
62
69
  :placeholderStyle="props.placeholderStyle"
63
70
  :disabled="props.disabled"
71
+ :readonly="props.readonly"
64
72
  :maxlength="inputMaxlength"
65
73
  :focus="props.focus"
66
74
  :confirmType="props.confirmType"
@@ -68,10 +76,9 @@
68
76
  @blur="onBlur"
69
77
  @input="onInput"
70
78
  @confirm="onConfirm"
71
- @tap="fieldClick"
72
79
  />
73
- <!-- 透明遮罩,只在disabled时显示,用于响应点击事件 -->
74
- <view v-if="props.disabled" class="u-field-disabled-overlay" @tap="fieldClick"></view>
80
+ <!-- 透明遮罩,在disabled或readonly时显示,用于捕获点击事件(原生input设置disabled会阻止点击冒泡) -->
81
+ <view v-if="props.readonly" class="u-field__readonly-overlay" @tap.stop="fieldClick"></view>
75
82
  </view>
76
83
  <u-icon
77
84
  v-if="props.clearable && inputValue !== '' && focused && !props.disabled"
@@ -256,6 +263,7 @@ function rightIconClick() {
256
263
  }
257
264
 
258
265
  function fieldClick() {
266
+ if (props.disabled) return;
259
267
  emit('click');
260
268
  }
261
269
  </script>
@@ -366,7 +374,7 @@ function fieldClick() {
366
374
  position: relative;
367
375
  }
368
376
 
369
- .u-field-disabled-overlay {
377
+ .u-field__readonly-overlay {
370
378
  position: absolute;
371
379
  top: 0;
372
380
  left: 0;
@@ -375,4 +383,15 @@ function fieldClick() {
375
383
  background-color: transparent;
376
384
  z-index: 1;
377
385
  }
386
+
387
+ .u-field--disabled {
388
+ background-color: $u-bg-gray-light;
389
+ }
390
+
391
+ .u-field--disabled .u-textarea-class,
392
+ .u-field--disabled .u-field__input-wrap {
393
+ background-color: transparent;
394
+ color: $u-light-color;
395
+ -webkit-text-fill-color: $u-light-color;
396
+ }
378
397
  </style>
@@ -50,6 +50,11 @@ export const InputProps = {
50
50
  type: Boolean,
51
51
  default: false
52
52
  },
53
+ /** 是否只读,禁止输入但可点击,样式不变,可触发click事件(默认false) */
54
+ readonly: {
55
+ type: Boolean,
56
+ default: false
57
+ },
53
58
  /** 输入框的最大可输入长度(默认140) */
54
59
  maxlength: {
55
60
  type: [Number, String] as PropType<number | string>,
@@ -24,6 +24,7 @@
24
24
  :placeholder="placeholder"
25
25
  :placeholderStyle="getPlaceholderStyle"
26
26
  :disabled="disabled"
27
+ :readonly="readonly"
27
28
  :maxlength="inputMaxlength"
28
29
  :fixed="fixed"
29
30
  :focus="focus"
@@ -49,6 +50,7 @@
49
50
  :placeholder="placeholder"
50
51
  :placeholderStyle="getPlaceholderStyle"
51
52
  :disabled="disabled || type === 'select'"
53
+ :readonly="readonly"
52
54
  :maxlength="inputMaxlength"
53
55
  :focus="focus"
54
56
  :confirmType="confirmType"
@@ -62,7 +64,8 @@
62
64
  @input="handleInput"
63
65
  @confirm="onConfirm"
64
66
  />
65
- <view class="u-input__select-overlay" v-if="type === 'select'" @tap.stop="inputClick"></view>
67
+ <!-- 透明遮罩,在readonly时显示,用于捕获点击事件(原生input设置disabled会阻止点击冒泡) -->
68
+ <view v-if="readonly || type === 'select'" class="u-input__readonly-overlay" @tap.stop="inputClick"></view>
66
69
  <view class="u-input__right-icon u-flex">
67
70
  <view
68
71
  class="u-input__right-icon__clear u-input__right-icon__item"
@@ -347,7 +350,7 @@ defineExpose({
347
350
  @include vue-flex;
348
351
  align-items: center;
349
352
 
350
- &__select-overlay {
353
+ &__readonly-overlay {
351
354
  position: absolute;
352
355
  inset: 0;
353
356
  z-index: 1;
@@ -55,6 +55,8 @@ export const TextareaProps = {
55
55
  confirmType: { type: String as PropType<string>, default: textarea.confirmType },
56
56
  // 是否禁用
57
57
  disabled: { type: Boolean as PropType<boolean>, default: textarea.disabled },
58
+ // 是否只读,禁止输入但可点击,样式不变,可触发click事件
59
+ readonly: { type: Boolean as PropType<boolean>, default: false },
58
60
  // 是否显示统计字数
59
61
  count: { type: Boolean as PropType<boolean>, default: textarea.count },
60
62
  // 是否自动获取焦点,nvue不支持,H5取决于浏览器的实现
@@ -3,7 +3,8 @@
3
3
  class="u-textarea"
4
4
  :class="[
5
5
  {
6
- 'u-textarea--error': validateState
6
+ 'u-textarea--error': validateState,
7
+ 'u-textarea--disabled': props.disabled
7
8
  },
8
9
  textareaClass,
9
10
  customClass
@@ -19,6 +20,7 @@
19
20
  :placeholder-style="getPlaceholderStyle"
20
21
  :placeholder-class="props.placeholderClass"
21
22
  :disabled="props.disabled"
23
+ :readonly="props.readonly"
22
24
  :focus="props.focus"
23
25
  :autoHeight="props.autoHeight"
24
26
  :fixed="props.fixed"
@@ -51,6 +53,8 @@
51
53
  {{ innerValue.length }}/{{ props.maxlength }}
52
54
  </text>
53
55
 
56
+ <!-- 透明遮罩,在readonly时显示,用于捕获点击事件(原生textarea设置disabled会阻止点击冒泡) -->
57
+ <view v-if="props.readonly" class="u-textarea__readonly-overlay" @tap.stop="textareaClick"></view>
54
58
  <view class="u-textarea__right-icon u-flex">
55
59
  <view
56
60
  class="u-textarea__right-icon__clear u-textarea__right-icon__item"
@@ -132,7 +136,8 @@ const emit = defineEmits([
132
136
  'input',
133
137
  'confirm',
134
138
  'keyboardheightchange',
135
- 'change'
139
+ 'change',
140
+ 'click'
136
141
  ]);
137
142
 
138
143
  const { emitToParent } = useChildren('u-textarea', 'u-form-item');
@@ -359,6 +364,11 @@ function onClear(event: any) {
359
364
  valueChange();
360
365
  }
361
366
 
367
+ function textareaClick() {
368
+ if (props.disabled) return;
369
+ emit('click');
370
+ }
371
+
362
372
  defineExpose({
363
373
  onFormItemError
364
374
  });
@@ -374,6 +384,12 @@ defineExpose({
374
384
  @include flex;
375
385
  flex: 1;
376
386
 
387
+ &__readonly-overlay {
388
+ position: absolute;
389
+ inset: 0;
390
+ z-index: 1;
391
+ }
392
+
377
393
  &--border {
378
394
  border-radius: 4px;
379
395
  border: 1px solid $u-border-color;
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "id": "uview-pro",
3
3
  "name": "uview-pro",
4
4
  "displayName": "【支持鸿蒙】uView Pro|基于Vue3+TS的高质量UI组件库,支持多主题、暗黑模式、多语言",
5
- "version": "0.6.3",
5
+ "version": "0.6.4",
6
6
  "description": "uView Pro是基于Vue3+TS的多平台UI框架,提供80+高质量组件、便捷工具和常用模板,支持多主题、暗黑模式、多语言,支持H5/APP/鸿蒙/小程序多端开发。已在鸿蒙应用商店上架,欢迎体验!",
7
7
  "main": "index.ts",
8
8
  "module": "index.ts",