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
@@ -10,7 +10,7 @@
10
10
  @click="handleChange('prev')"
11
11
  >
12
12
  <u-icon v-if="showIcon" :name="prevIcon"></u-icon>
13
- <text v-else>{{ prevText }}</text>
13
+ <text v-else>{{ getPrevText }}</text>
14
14
  </u-button>
15
15
  <view class="u-pagination-text">
16
16
  <slot>
@@ -29,7 +29,7 @@
29
29
  @click="handleChange('next')"
30
30
  >
31
31
  <u-icon v-if="showIcon" :name="nextIcon"></u-icon>
32
- <text v-else>{{ nextText }}</text>
32
+ <text v-else>{{ getNextText }}</text>
33
33
  </u-button>
34
34
  </view>
35
35
  </template>
@@ -51,7 +51,9 @@ export default {
51
51
  import { computed } from 'vue';
52
52
  import { type PaginationEmits, PaginationProps } from './types';
53
53
  import type { PaginationDirection } from '../../types/global';
54
- import { $u } from '../../';
54
+ import { $u, useLocale } from '../../';
55
+
56
+ const { t } = useLocale();
55
57
 
56
58
  const props = defineProps(PaginationProps);
57
59
  const emit = defineEmits<PaginationEmits>();
@@ -64,6 +66,10 @@ const totalPages = computed(() => {
64
66
  return Math.ceil((props.total || 0) / size);
65
67
  });
66
68
 
69
+ // 国际化计算属性
70
+ const getPrevText = computed(() => props.prevText || t('uPagination.prevText'));
71
+ const getNextText = computed(() => props.nextText || t('uPagination.nextText'));
72
+
67
73
  // 切换分页
68
74
  function handleChange(type: PaginationDirection) {
69
75
  // 先计算新值,确保获取到的是更新后的值
@@ -1,10 +1,8 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
2
  import type { PickerMode, PickerParams } from '../../types/global';
3
- import { getColor, useLocale } from '../../';
3
+ import { getColor } from '../../';
4
4
  import zIndex from '../../libs/config/zIndex';
5
5
 
6
- const { t } = useLocale();
7
-
8
6
  const defaultParams: PickerParams = {
9
7
  year: true,
10
8
  month: true,
@@ -130,12 +128,12 @@ export const PickerProps = {
130
128
  /** 取消按钮的文字 */
131
129
  cancelText: {
132
130
  type: String,
133
- default: () => t('uPicker.cancelText')
131
+ default: ''
134
132
  },
135
133
  /** 确认按钮的文字 */
136
134
  confirmText: {
137
135
  type: String,
138
- default: () => t('uPicker.confirmText')
136
+ default: ''
139
137
  }
140
138
  };
141
139
 
@@ -19,7 +19,7 @@
19
19
  :hover-stay-time="150"
20
20
  @tap="getResult('cancel')"
21
21
  >
22
- {{ cancelText }}
22
+ {{ getCancelText }}
23
23
  </view>
24
24
  <view class="u-picker__title u-line-1">
25
25
  <slot name="title">
@@ -34,7 +34,7 @@
34
34
  @touchmove.stop=""
35
35
  @tap.stop="getResult('confirm')"
36
36
  >
37
- {{ confirmText }}
37
+ {{ getConfirmText }}
38
38
  </view>
39
39
  </view>
40
40
  <view class="u-picker-body">
@@ -169,7 +169,7 @@ import provinces from '../../libs/util/province';
169
169
  import citys from '../../libs/util/city';
170
170
  import areas from '../../libs/util/area';
171
171
  import { PickerProps } from './types';
172
- import { $u } from '../..';
172
+ import { $u, useLocale } from '../..';
173
173
 
174
174
  /**
175
175
  * picker picker弹出选择器
@@ -206,6 +206,12 @@ const popupValue = computed({
206
206
 
207
207
  const emit = defineEmits(['update:modelValue', 'confirm', 'cancel', 'columnchange']);
208
208
 
209
+ const { t } = useLocale();
210
+
211
+ // 国际化计算属性
212
+ const getCancelText = computed(() => props.cancelText || t('uPicker.cancelText'));
213
+ const getConfirmText = computed(() => props.confirmText || t('uPicker.confirmText'));
214
+
209
215
  // 主要数据
210
216
  const years = ref<number[]>([]);
211
217
  const months = ref<number[]>([]);
@@ -1,7 +1,5 @@
1
1
  import type { ExtractPropTypes, PropType } from 'vue';
2
- import { getColor, useLocale } from '../../';
3
-
4
- const { t } = useLocale();
2
+ import { getColor } from '../../';
5
3
 
6
4
  /**
7
5
  * ReadMoreProps 阅读更多 props 类型定义
@@ -23,9 +21,9 @@ export const ReadMoreProps = {
23
21
  /** 展开后是否显示"收起"按钮 */
24
22
  toggle: { type: Boolean, default: false },
25
23
  /** 关闭时的提示文字 */
26
- closeText: { type: String, default: () => t('uReadMore.closeText') },
24
+ closeText: { type: String, default: '' },
27
25
  /** 展开时的提示文字 */
28
- openText: { type: String, default: () => t('uReadMore.openText') },
26
+ openText: { type: String, default: '' },
29
27
  /** 提示的文字颜色 */
30
28
  color: { type: String, default: () => getColor('primary') },
31
29
  /** 提示文字的大小 */
@@ -29,7 +29,7 @@
29
29
  color: color
30
30
  }"
31
31
  >
32
- {{ showMore ? openText : closeText }}
32
+ {{ showMore ? getOpenText : getCloseText }}
33
33
  </text>
34
34
  <view class="u-content__showmore-wrap__readmore-btn__icon u-flex">
35
35
  <u-icon :color="color" :size="fontSize" :name="showMore ? 'arrow-up' : 'arrow-down'"></u-icon>
@@ -53,7 +53,7 @@ export default {
53
53
 
54
54
  <script setup lang="ts">
55
55
  import { ref, computed, watch, onMounted, nextTick, getCurrentInstance } from 'vue';
56
- import { $u } from '../..';
56
+ import { $u, useLocale } from '../..';
57
57
  import { ReadMoreProps } from './types';
58
58
 
59
59
  /**
@@ -78,6 +78,8 @@ const props = defineProps(ReadMoreProps);
78
78
 
79
79
  const emit = defineEmits(['open', 'close']);
80
80
 
81
+ const { t } = useLocale();
82
+
81
83
  // 是否需要隐藏一部分内容
82
84
  const isLongContent = ref(false);
83
85
  // 当前隐藏与显示的状态,true-显示,false-收起
@@ -91,6 +93,9 @@ const innerShadowStyle = computed(() => {
91
93
  return showMore.value ? {} : props.shadowStyle;
92
94
  });
93
95
 
96
+ const getOpenText = computed(() => props.openText || t('uReadMore.openText'));
97
+ const getCloseText = computed(() => props.closeText || t('uReadMore.closeText'));
98
+
94
99
  // 监听 toggle 和 showHeight 变化,重新初始化
95
100
  watch(
96
101
  () => `${props.toggle}-${props.showHeight}`,
@@ -1,68 +1,65 @@
1
- import type { ExtractPropTypes, PropType } from 'vue';
2
- import type { InputAlign, SearchShape } from '../../types/global';
3
- import { useLocale } from '../../';
4
-
5
- const { t } = useLocale();
6
-
7
- /**
8
- * SearchProps 搜索框 props 类型定义
9
- * @description 集成常见搜索框功能,开箱即用
10
- */
11
- export const SearchProps = {
12
- /** 自定义根节点样式 */
13
- customStyle: {
14
- type: [String, Object] as PropType<string | Record<string, any>>,
15
- default: () => ({})
16
- },
17
- /** 自定义根节点样式类 */
18
- customClass: {
19
- type: String as unknown as PropType<string>,
20
- default: ''
21
- },
22
- /** 搜索框形状,round-圆形,square-方形 */
23
- shape: { type: String as PropType<SearchShape>, default: 'round' },
24
- /** 搜索框背景色,默认值var(--u-bg-gray-light) */
25
- bgColor: { type: String, default: 'var(--u-bg-gray-light)' },
26
- /** 占位提示文字 */
27
- placeholder: { type: String, default: () => t('uSearch.placeholder') },
28
- /** 是否启用清除控件 */
29
- clearabled: { type: Boolean, default: true },
30
- /** 是否自动聚焦 */
31
- focus: { type: Boolean, default: false },
32
- /** 是否在搜索框右侧显示取消按钮 */
33
- showAction: { type: Boolean, default: true },
34
- /** 右边控件的样式 */
35
- actionStyle: { type: Object as PropType<Record<string, any>>, default: () => ({}) },
36
- /** 取消按钮文字 */
37
- actionText: { type: String, default: () => t('uSearch.actionText') },
38
- /** 输入框内容对齐方式,可选值为 left|center|right */
39
- inputAlign: { type: String as PropType<InputAlign>, default: 'left' },
40
- /** 是否启用输入框 */
41
- disabled: { type: Boolean, default: false },
42
- /** 开启showAction时,是否在input获取焦点时才显示 */
43
- animation: { type: Boolean, default: false },
44
- /** 边框颜色,只要配置了颜色,才会有边框 */
45
- borderColor: { type: String, default: 'none' },
46
- /** 输入框的初始化内容 */
47
- modelValue: { type: String, default: '' },
48
- /** 搜索框高度,单位rpx */
49
- height: { type: [Number, String] as PropType<number | string>, default: 64 },
50
- /** input输入框的样式,可以定义文字颜色,大小等,对象形式 */
51
- inputStyle: { type: Object as PropType<Record<string, any>>, default: () => ({}) },
52
- /** 输入框最大能输入的长度,-1为不限制长度(来自uniapp文档) */
53
- maxlength: { type: [Number, String] as PropType<number | string>, default: '-1' },
54
- /** 搜索图标的颜色,默认同输入框字体颜色 */
55
- searchIconColor: { type: String, default: '' },
56
- /** 输入框字体颜色 */
57
- color: { type: String, default: 'var(--u-content-color)' },
58
- /** placeholder的颜色 */
59
- placeholderColor: { type: String, default: 'var(--u-tips-color)' },
60
- /** 组件与其他上下左右元素之间的距离,带单位的字符串形式,如"30rpx"、"30rpx 20rpx"等写法 */
61
- margin: { type: String, default: '0' },
62
- /** 左边输入框的图标,可以为uView图标名称或图片路径 */
63
- searchIcon: { type: String, default: 'search' },
64
- /** 弹出键盘时是否自动调节高度,uni-app默认值是true */
65
- adjustPosition: { type: Boolean, default: true }
66
- };
67
-
68
- export type SearchProps = ExtractPropTypes<typeof SearchProps>;
1
+ import type { ExtractPropTypes, PropType } from 'vue';
2
+ import type { InputAlign, SearchShape } from '../../types/global';
3
+
4
+ /**
5
+ * SearchProps 搜索框 props 类型定义
6
+ * @description 集成常见搜索框功能,开箱即用
7
+ */
8
+ export const SearchProps = {
9
+ /** 自定义根节点样式 */
10
+ customStyle: {
11
+ type: [String, Object] as PropType<string | Record<string, any>>,
12
+ default: () => ({})
13
+ },
14
+ /** 自定义根节点样式类 */
15
+ customClass: {
16
+ type: String as unknown as PropType<string>,
17
+ default: ''
18
+ },
19
+ /** 搜索框形状,round-圆形,square-方形 */
20
+ shape: { type: String as PropType<SearchShape>, default: 'round' },
21
+ /** 搜索框背景色,默认值var(--u-bg-gray-light) */
22
+ bgColor: { type: String, default: 'var(--u-bg-gray-light)' },
23
+ /** 占位提示文字 */
24
+ placeholder: { type: String, default: '' },
25
+ /** 是否启用清除控件 */
26
+ clearabled: { type: Boolean, default: true },
27
+ /** 是否自动聚焦 */
28
+ focus: { type: Boolean, default: false },
29
+ /** 是否在搜索框右侧显示取消按钮 */
30
+ showAction: { type: Boolean, default: true },
31
+ /** 右边控件的样式 */
32
+ actionStyle: { type: Object as PropType<Record<string, any>>, default: () => ({}) },
33
+ /** 取消按钮文字 */
34
+ actionText: { type: String, default: '' },
35
+ /** 输入框内容对齐方式,可选值为 left|center|right */
36
+ inputAlign: { type: String as PropType<InputAlign>, default: 'left' },
37
+ /** 是否启用输入框 */
38
+ disabled: { type: Boolean, default: false },
39
+ /** 开启showAction时,是否在input获取焦点时才显示 */
40
+ animation: { type: Boolean, default: false },
41
+ /** 边框颜色,只要配置了颜色,才会有边框 */
42
+ borderColor: { type: String, default: 'none' },
43
+ /** 输入框的初始化内容 */
44
+ modelValue: { type: String, default: '' },
45
+ /** 搜索框高度,单位rpx */
46
+ height: { type: [Number, String] as PropType<number | string>, default: 64 },
47
+ /** input输入框的样式,可以定义文字颜色,大小等,对象形式 */
48
+ inputStyle: { type: Object as PropType<Record<string, any>>, default: () => ({}) },
49
+ /** 输入框最大能输入的长度,-1为不限制长度(来自uniapp文档) */
50
+ maxlength: { type: [Number, String] as PropType<number | string>, default: '-1' },
51
+ /** 搜索图标的颜色,默认同输入框字体颜色 */
52
+ searchIconColor: { type: String, default: '' },
53
+ /** 输入框字体颜色 */
54
+ color: { type: String, default: 'var(--u-content-color)' },
55
+ /** placeholder的颜色 */
56
+ placeholderColor: { type: String, default: 'var(--u-tips-color)' },
57
+ /** 组件与其他上下左右元素之间的距离,带单位的字符串形式,如"30rpx"、"30rpx 20rpx"等写法 */
58
+ margin: { type: String, default: '0' },
59
+ /** 左边输入框的图标,可以为uView图标名称或图片路径 */
60
+ searchIcon: { type: String, default: 'search' },
61
+ /** 弹出键盘时是否自动调节高度,uni-app默认值是true */
62
+ adjustPosition: { type: Boolean, default: true }
63
+ };
64
+
65
+ export type SearchProps = ExtractPropTypes<typeof SearchProps>;