uview-pro 0.6.3 → 0.6.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 (38) hide show
  1. package/changelog.md +27 -0
  2. package/components/u-action-sheet/types.ts +2 -4
  3. package/components/u-action-sheet/u-action-sheet.vue +7 -2
  4. package/components/u-calendar/types.ts +4 -6
  5. package/components/u-calendar/u-calendar.vue +8 -3
  6. package/components/u-field/types.ts +2 -0
  7. package/components/u-field/u-field.vue +25 -6
  8. package/components/u-input/types.ts +6 -4
  9. package/components/u-input/u-input.vue +12 -5
  10. package/components/u-keyboard/types.ts +2 -5
  11. package/components/u-keyboard/u-keyboard.vue +6 -2
  12. package/components/u-link/types.ts +2 -4
  13. package/components/u-link/u-link.vue +9 -3
  14. package/components/u-loadmore/types.ts +1 -5
  15. package/components/u-loadmore/u-loadmore.vue +13 -4
  16. package/components/u-modal/types.ts +4 -6
  17. package/components/u-modal/u-modal.vue +20 -3
  18. package/components/u-no-network/types.ts +1 -4
  19. package/components/u-no-network/u-no-network.vue +4 -1
  20. package/components/u-pagination/types.ts +2 -5
  21. package/components/u-pagination/u-pagination.vue +9 -3
  22. package/components/u-picker/types.ts +3 -5
  23. package/components/u-picker/u-picker.vue +9 -3
  24. package/components/u-read-more/types.ts +3 -5
  25. package/components/u-read-more/u-read-more.vue +7 -2
  26. package/components/u-search/types.ts +65 -68
  27. package/components/u-search/u-search.vue +296 -291
  28. package/components/u-section/types.ts +1 -4
  29. package/components/u-section/u-section.vue +7 -2
  30. package/components/u-select/types.ts +3 -5
  31. package/components/u-select/u-select.vue +9 -4
  32. package/components/u-textarea/types.ts +2 -0
  33. package/components/u-textarea/u-textarea.vue +18 -2
  34. package/components/u-upload/types.ts +1 -4
  35. package/components/u-upload/u-upload.vue +1 -1
  36. package/components/u-verification-code/types.ts +3 -6
  37. package/components/u-verification-code/u-verification-code.vue +16 -9
  38. package/package.json +1 -1
@@ -28,7 +28,7 @@
28
28
  :hover-stay-time="150"
29
29
  @tap="getResult('cancel')"
30
30
  >
31
- {{ cancelText }}
31
+ {{ getCancelText }}
32
32
  </view>
33
33
  <view class="u-select__header__title u-line-1"> {{ title }}</view>
34
34
  <view
@@ -39,7 +39,7 @@
39
39
  @touchmove.stop=""
40
40
  @tap.stop="getResult('confirm')"
41
41
  >
42
- {{ confirmText }}
42
+ {{ getConfirmText }}
43
43
  </view>
44
44
  </view>
45
45
  <view class="u-select__body">
@@ -86,7 +86,7 @@ export default {
86
86
  import { ref, computed, watch, nextTick } from 'vue';
87
87
  import { SelectProps } from './types';
88
88
  import type { SelectListItem } from '../../types/global';
89
- import { $u } from '../..';
89
+ import { $u, useLocale } from '../..';
90
90
 
91
91
  /**
92
92
  * select 列选择器
@@ -112,8 +112,9 @@ import { $u } from '../..';
112
112
 
113
113
  const props = defineProps(SelectProps);
114
114
  const emit = defineEmits(['update:modelValue', 'confirm', 'cancel', 'click']);
115
- // 用于列改变时,保存当前的索引,下一次变化时比较得出是哪一列发生了变化
115
+ const { t } = useLocale();
116
116
 
117
+ // 用于列改变时,保存当前的索引,下一次变化时比较得出是哪一列发生了变化
117
118
  const defaultSelector = ref<number[]>([0]);
118
119
  // picker-view的数据
119
120
  const columnData = ref<SelectListItem[][]>([]);
@@ -139,6 +140,10 @@ const popupValue = computed({
139
140
  set: (val: boolean) => emit('update:modelValue', val)
140
141
  });
141
142
 
143
+ // 国际化计算属性
144
+ const getCancelText = computed(() => props.cancelText || t('uSelect.cancelText'));
145
+ const getConfirmText = computed(() => props.confirmText || t('uSelect.confirmText'));
146
+
142
147
  watch(
143
148
  () => props.modelValue,
144
149
  async val => {
@@ -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;
@@ -1,8 +1,5 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
2
  import type { ImgMode, UploadSizeType, UploadSourceType, UploadAcceptType, UploadFileItem } from '../../types/global';
3
- import { useLocale } from '../../';
4
-
5
- const { t } = useLocale();
6
3
 
7
4
  /**
8
5
  * UploadProps upload props 类型定义
@@ -48,7 +45,7 @@ export const UploadProps = {
48
45
  /** 是否自定义上传按钮 */
49
46
  customBtn: { type: Boolean, default: false },
50
47
  /** 上传按钮文字 */
51
- uploadText: { type: String, default: () => t('uUpload.uploadText') },
48
+ uploadText: { type: String, default: '' },
52
49
  /** 上传地址 */
53
50
  action: { type: String, default: '' },
54
51
  /** 是否禁用 */
@@ -400,7 +400,7 @@ const extTypeMap: Record<string, string> = {
400
400
  */
401
401
  const uploadBtnText = computed(() => {
402
402
  // 如果用户自定义了 uploadText,优先使用
403
- if (props.uploadText !== t('uUpload.uploadText')) {
403
+ if (props.uploadText) {
404
404
  return props.uploadText;
405
405
  }
406
406
  // 根据 accept 类型返回对应的国际化文本
@@ -1,7 +1,4 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
- import { useLocale } from '../../';
3
-
4
- const { t } = useLocale();
5
2
 
6
3
  /**
7
4
  * VerificationCodeProps 验证码输入框 props 类型定义
@@ -21,11 +18,11 @@ export const VerificationCodeProps = {
21
18
  /** 倒计时时长,单位秒 */
22
19
  seconds: { type: [String, Number] as PropType<string | number>, default: 60 },
23
20
  /** 开始时按钮文字 */
24
- startText: { type: String, default: () => t('uVerificationCode.startText') },
21
+ startText: { type: String, default: '' },
25
22
  /** 倒计时进行中按钮文字,X为剩余秒数 */
26
- changeText: { type: String, default: () => t('uVerificationCode.changeText') },
23
+ changeText: { type: String, default: '' },
27
24
  /** 结束时按钮文字 */
28
- endText: { type: String, default: () => t('uVerificationCode.endText') },
25
+ endText: { type: String, default: '' },
29
26
  /** 是否保持倒计时不中断(如页面切换) */
30
27
  keepRunning: { type: Boolean, default: false },
31
28
  /** 唯一标识key,用于区分多个验证码组件 */
@@ -18,9 +18,9 @@ export default {
18
18
  </script>
19
19
 
20
20
  <script setup lang="ts">
21
- import { ref, watch, onMounted, onBeforeUnmount } from 'vue';
21
+ import { ref, watch, onMounted, onBeforeUnmount, computed } from 'vue';
22
22
  import { VerificationCodeProps } from './types';
23
- import { $u } from '../../';
23
+ import { $u, useLocale } from '../../';
24
24
 
25
25
  /**
26
26
  * verificationCode 验证码输入框
@@ -38,9 +38,16 @@ import { $u } from '../../';
38
38
  * @example <u-verification-code :seconds="seconds" @end="end" @start="start" ref="uCode" />
39
39
  */
40
40
 
41
+ const props = defineProps(VerificationCodeProps);
42
+
41
43
  const emit = defineEmits(['change', 'start', 'end']);
42
44
 
43
- const props = defineProps(VerificationCodeProps);
45
+ const { t } = useLocale();
46
+
47
+ // 国际化计算属性
48
+ const getStartText = computed(() => props.startText || t('uVerificationCode.startText'));
49
+ const getChangeText = computed(() => props.changeText || t('uVerificationCode.changeText'));
50
+ const getEndText = computed(() => props.endText || t('uVerificationCode.endText'));
44
51
 
45
52
  /** 当前倒计时秒数 */
46
53
  const secNum = ref(Number(props.seconds));
@@ -75,7 +82,7 @@ onBeforeUnmount(() => {
75
82
  function checkKeepRunning() {
76
83
  // 获取上一次退出页面(H5还包括刷新)时的时间戳,如果没有上次的保存,此值可能为空
77
84
  const lastTimestamp = Number(uni.getStorageSync(props.uniqueKey + '_$uCountDownTimestamp'));
78
- if (!lastTimestamp) return changeEvent(props.startText);
85
+ if (!lastTimestamp) return changeEvent(getStartText.value);
79
86
  // 当前秒的时间戳
80
87
  const nowTimestamp = Math.floor(+new Date() / 1000);
81
88
  // 判断当前的时间戳,是否小于上一次的本该按设定结束,却提前结束的时间戳
@@ -88,7 +95,7 @@ function checkKeepRunning() {
88
95
  start();
89
96
  } else {
90
97
  // 如果不存在需要继续上一次的倒计时,执行正常的逻辑
91
- changeEvent(props.startText);
98
+ changeEvent(getStartText.value);
92
99
  }
93
100
  }
94
101
 
@@ -104,16 +111,16 @@ function start() {
104
111
  emit('start');
105
112
  canGetCode.value = false;
106
113
  // 一开始时就提示,否则要等setInterval的1秒后才会有提示
107
- changeEvent(props.changeText.replace(/x|X/, String(secNum.value)));
114
+ changeEvent(getChangeText.value.replace(/x|X/, String(secNum.value)));
108
115
  setTimeToStorage();
109
116
  timer = setInterval(() => {
110
117
  if (--secNum.value) {
111
118
  // 用当前倒计时的秒数替换提示字符串中的"x"字母
112
- changeEvent(props.changeText.replace(/x|X/, String(secNum.value)));
119
+ changeEvent(getChangeText.value.replace(/x|X/, String(secNum.value)));
113
120
  } else {
114
121
  clearInterval(timer!);
115
122
  timer = null;
116
- changeEvent(props.endText);
123
+ changeEvent(getEndText.value);
117
124
  secNum.value = Number(props.seconds);
118
125
  emit('end');
119
126
  canGetCode.value = true;
@@ -129,7 +136,7 @@ function reset() {
129
136
  if (timer) clearInterval(timer);
130
137
  timer = null;
131
138
  secNum.value = Number(props.seconds);
132
- changeEvent(props.endText);
139
+ changeEvent(getEndText.value);
133
140
  }
134
141
 
135
142
  /**
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.5",
6
6
  "description": "uView Pro是基于Vue3+TS的多平台UI框架,提供80+高质量组件、便捷工具和常用模板,支持多主题、暗黑模式、多语言,支持H5/APP/鸿蒙/小程序多端开发。已在鸿蒙应用商店上架,欢迎体验!",
7
7
  "main": "index.ts",
8
8
  "module": "index.ts",