uview-pro 0.3.3 → 0.3.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.
package/changelog.md CHANGED
@@ -1,21 +1,64 @@
1
- ## 0.3.3(2025-10-16
2
-
3
- ### 🐛 Bug Fixes | Bug 修复
4
-
5
- - **u-read-more:** 修复 init 方法无法在外部调用的问题 ([415d401](https://github.com/anyup/uView-Pro/commit/415d401883a3567653ab1f311b28b075b7bb5603))
6
- - **u-button:** 修复 hover-class 属性被忽略的问题 ([b919c58](https://github.com/anyup/uView-Pro/commit/b919c58cea048f9e559a6448cebe5abbf1490acf))
7
-
8
- ### ♻️ Code Refactoring | 代码重构
9
-
10
- - **component-relation:** 重构组件关系逻辑并添加新功能 ([85d0cd2](https://github.com/anyup/uView-Pro/commit/85d0cd20db839a61733887f82825d47de0a1b1a6))
11
- - **u-talbe:** 重构u-td和u-th组件,增强u-table的兼容性 ([3fbbc52](https://github.com/anyup/uView-Pro/commit/3fbbc5233bd41b91ca829f9a65cf95ee3b599e36))
12
- - 修改 uView Pro 日志配置 ([6b9bb68](https://github.com/anyup/uView-Pro/commit/6b9bb6852af3eb24f109207f864145771c3e9c79))
13
- - **clipboard:** add clipboard function ([efdaa58](https://github.com/anyup/uView-Pro/commit/efdaa58dda923b281d9b764a82a7492f36717ac4))
14
-
15
- ### 👥 Contributors
16
-
17
- <a href="https://github.com/koboshi"><img src="https://github.com/koboshi.png?size=40" width="40" height="40" alt="koboshi" title="koboshi"/></a> <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>
18
-
1
+ ## 0.3.5(2025-10-21
2
+
3
+ ### 🐛 Bug Fixes | Bug 修复
4
+
5
+ - **u-input:** 修复input组件不支持input事件的问题 ([52d6a6a](https://github.com/anyup/uView-Pro/commit/52d6a6aaeec9ec78e4088234ff7ba056cc10fd9c))
6
+ - **u-search:** 修复search组件不支持input事件的问题 ([603b96f](https://github.com/anyup/uView-Pro/commit/603b96f7eeb16d3e54c82b0be7dd03deb930aef5))
7
+ - **u-popup:** 修复微信小程序环境下,u-popup 组件 mode=center 时,设置关闭图标位置无效的问题 ([f08197a](https://github.com/anyup/uView-Pro/commit/f08197aafdc3f874b1efcddf6cc6ff9c9edde954))
8
+ - **u-line-progress:** type 属性设置后仍被 active-color 内联样式覆盖的问题 ([c6f29f9](https://github.com/anyup/uView-Pro/commit/c6f29f9dc8437035a0e698e869af2fd418d0bd65))
9
+
10
+ ### Features | 新功能
11
+
12
+ - **useChildren:** 添加子组件索引功能 ([8ad744f](https://github.com/anyup/uView-Pro/commit/8ad744fd51df934cc20c099686cbdc5512b22c79))
13
+ - **addUnit:** 增强 addUnit 函数支持多值空格分隔 ([6d89cd3](https://github.com/anyup/uView-Pro/commit/6d89cd3c5aacc0770f6f2684fd737d0f05a6e929))
14
+ - **u-action-sheet:** 新增自定义 ActionSheet 组件 ([f709523](https://github.com/anyup/uView-Pro/commit/f709523cba5a089eed7c717cc36b9ab199ae24da))
15
+
16
+ ### 📝 Documentation | 文档
17
+
18
+ - 移除issue模板中的提交格式参考 ([83799e8](https://github.com/anyup/uView-Pro/commit/83799e882f69b0e8787a014cfab9f16ab34ba57c))
19
+
20
+ ### ♻️ Code Refactoring | 代码重构
21
+
22
+ - **u-popup:** 移除弹窗组件中的冗余代码 ([40c5b64](https://github.com/anyup/uView-Pro/commit/40c5b641539fce56af4f9a4ad2440b9240464a89))
23
+
24
+ ### 👥 Contributors
25
+
26
+ <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/sunjianwei"><img src="https://github.com/sunjianwei.png?size=40" width="40" height="40" alt="sunjianwei" title="sunjianwei"/></a> <a href="https://github.com/koboshi"><img src="https://github.com/koboshi.png?size=40" width="40" height="40" alt="koboshi" title="koboshi"/></a>
27
+
28
+ ## 0.3.4(2025-10-20)
29
+
30
+ ### ♻️ Code Refactoring | 代码重构
31
+
32
+ - **components:** 移除不必要的父组件和事件总线相关代码,优化组件间通信 ([280c2f8](https://github.com/anyup/uView-Pro/commit/280c2f8acc75764a7706ec38c742cc16703c941a))
33
+ - **u-safe-bottom:** 优化底部安全区组件 ([161f2d3](https://github.com/anyup/uView-Pro/commit/161f2d32ff6b9abbb6f8221a4dd99c438a606e94))
34
+ - **u-status-bar:** 优化状态栏组件 ([53c50ab](https://github.com/anyup/uView-Pro/commit/53c50ab8b6314a7d702b90e6b48b79301a334090))
35
+
36
+ ### 🐛 Bug Fixes | Bug 修复
37
+
38
+ - **u-subsection:** 优化列表和模式变化的监听逻辑,移除不必要的初始化调用 ([f77ee7c](https://github.com/anyup/uView-Pro/commit/f77ee7ccc7521ec2472f72dcf2fb47362ca0abd9))
39
+
40
+ ### 👥 Contributors
41
+
42
+ <a href="https://github.com/anyup"><img src="https://github.com/anyup.png?size=40" width="40" height="40" alt="anyup" title="anyup"/></a>
43
+
44
+ ## 0.3.3(2025-10-16)
45
+
46
+ ### 🐛 Bug Fixes | Bug 修复
47
+
48
+ - **u-read-more:** 修复 init 方法无法在外部调用的问题 ([415d401](https://github.com/anyup/uView-Pro/commit/415d401883a3567653ab1f311b28b075b7bb5603))
49
+ - **u-button:** 修复 hover-class 属性被忽略的问题 ([b919c58](https://github.com/anyup/uView-Pro/commit/b919c58cea048f9e559a6448cebe5abbf1490acf))
50
+
51
+ ### ♻️ Code Refactoring | 代码重构
52
+
53
+ - **component-relation:** 重构组件关系逻辑并添加新功能 ([85d0cd2](https://github.com/anyup/uView-Pro/commit/85d0cd20db839a61733887f82825d47de0a1b1a6))
54
+ - **u-talbe:** 重构u-td和u-th组件,增强u-table的兼容性 ([3fbbc52](https://github.com/anyup/uView-Pro/commit/3fbbc5233bd41b91ca829f9a65cf95ee3b599e36))
55
+ - 修改 uView Pro 日志配置 ([6b9bb68](https://github.com/anyup/uView-Pro/commit/6b9bb6852af3eb24f109207f864145771c3e9c79))
56
+ - **clipboard:** add clipboard function ([efdaa58](https://github.com/anyup/uView-Pro/commit/efdaa58dda923b281d9b764a82a7492f36717ac4))
57
+
58
+ ### 👥 Contributors
59
+
60
+ <a href="https://github.com/koboshi"><img src="https://github.com/koboshi.png?size=40" width="40" height="40" alt="koboshi" title="koboshi"/></a> <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>
61
+
19
62
  ## 0.3.2(2025-10-15)
20
63
 
21
64
  ### 📝 Documentation | 文档
@@ -1,6 +1,7 @@
1
1
  import { type ExtractPropTypes, type PropType } from 'vue';
2
2
  import type { ActionSheetItem, ActionSheetTips } from '../../types/global';
3
3
  import { baseProps } from '../common/props';
4
+ import { $u } from '../../';
4
5
 
5
6
  /**
6
7
  * actionSheet 操作菜单
@@ -8,7 +9,7 @@ import { baseProps } from '../common/props';
8
9
  */
9
10
  export const ActionSheetProps = {
10
11
  ...baseProps,
11
- /** 点击遮罩是否可以关闭actionsheet */
12
+ /** 点击遮罩是否可以关闭actionSheet */
12
13
  maskCloseAble: { type: Boolean, default: true },
13
14
  /** 按钮的文字数组,可以自定义颜色和字体大小,字体单位为rpx */
14
15
  list: {
@@ -18,7 +19,7 @@ export const ActionSheetProps = {
18
19
  /** 顶部的提示文字 */
19
20
  tips: {
20
21
  type: Object as unknown as PropType<ActionSheetTips>,
21
- default: () => ({ text: '', color: '', fontSize: '26' })
22
+ default: () => ({ text: '', color: $u.color.tipsColor, fontSize: '26rpx' })
22
23
  },
23
24
  /** 底部的取消按钮 */
24
25
  cancelBtn: { type: Boolean, default: true },
@@ -31,7 +32,13 @@ export const ActionSheetProps = {
31
32
  /** 弹出的z-index值 */
32
33
  zIndex: { type: [String, Number], default: 0 },
33
34
  /** 取消按钮的文字提示 */
34
- cancelText: { type: String, default: '取消' }
35
+ cancelText: { type: String, default: '取消' },
36
+ /** 字体颜色 */
37
+ color: { type: String, default: $u.color.mainColor },
38
+ /** 字体大小 */
39
+ fontSize: { type: [String, Number], default: '32rpx' },
40
+ /** 是否异步关闭 */
41
+ asyncClose: { type: Boolean, default: false }
35
42
  };
36
43
 
37
44
  export type ActionSheetProps = ExtractPropTypes<typeof ActionSheetProps>;
@@ -15,7 +15,7 @@
15
15
  <view class="u-tips u-border-bottom" v-if="tips.text" :style="[tipsStyle]">
16
16
  {{ tips.text }}
17
17
  </view>
18
- <block v-for="(item, index) in list" :key="index">
18
+ <block v-if="list && list.length > 0" v-for="(item, index) in list" :key="index">
19
19
  <view
20
20
  @touchmove.stop.prevent
21
21
  @tap="itemClick(index)"
@@ -28,10 +28,13 @@
28
28
  <text class="u-action-sheet-item__subtext u-line-1" v-if="item.subText">{{ item.subText }}</text>
29
29
  </view>
30
30
  </block>
31
+ <template v-else>
32
+ <slot></slot>
33
+ </template>
31
34
  <view class="u-gab" v-if="cancelBtn"> </view>
32
35
  <view
33
36
  @touchmove.stop.prevent
34
- class="u-actionsheet-cancel u-action-sheet-item"
37
+ class="u-action-sheet-cancel u-action-sheet-item"
35
38
  hover-class="u-hover-class"
36
39
  :hover-stay-time="150"
37
40
  v-if="cancelBtn"
@@ -57,7 +60,7 @@ export default {
57
60
 
58
61
  <script setup lang="ts">
59
62
  import { computed } from 'vue';
60
- import { $u } from '../..';
63
+ import { $u, useParent } from '../..';
61
64
  import { ActionSheetProps } from './types';
62
65
 
63
66
  /**
@@ -82,6 +85,8 @@ const props = defineProps(ActionSheetProps);
82
85
 
83
86
  const emit = defineEmits(['update:modelValue', 'click', 'close']);
84
87
 
88
+ useParent('u-action-sheet');
89
+
85
90
  const popupValue = computed({
86
91
  get: () => props.modelValue,
87
92
  set: (val: boolean) => emit('update:modelValue', val)
@@ -90,18 +95,18 @@ const popupValue = computed({
90
95
  // 顶部提示的样式
91
96
  const tipsStyle = computed(() => {
92
97
  let style: Record<string, string> = {};
93
- if (props.tips.color) style.color = props.tips.color;
94
- if (props.tips.fontSize) style.fontSize = props.tips.fontSize + 'rpx';
98
+ style.color = props.tips?.color || $u.color.tipsColor;
99
+ style.fontSize = $u.addUnit(props.tips?.fontSize || '26rpx');
95
100
  return style;
96
101
  });
97
102
 
98
103
  // 操作项目的样式
99
104
  const itemStyle = (index: number) => {
100
105
  let style: Record<string, string> = {};
101
- if (props.list[index]?.color) style.color = props.list[index].color;
102
- if (props.list[index]?.fontSize) style.fontSize = props.list[index].fontSize + 'rpx';
106
+ style.color = props.list[index]?.color || props.color;
107
+ style.fontSize = $u.addUnit(props.list[index]?.fontSize || props.fontSize);
103
108
  // 选项被禁用的样式
104
- if (props.list[index]?.disabled) style.color = '#c0c4cc';
109
+ if (props.list[index]?.disabled) style.color = $u.color.lightColor;
105
110
  return style;
106
111
  };
107
112
 
@@ -136,8 +141,15 @@ function itemClick(index: number) {
136
141
  // disabled的项禁止点击
137
142
  if (props.list[index]?.disabled) return;
138
143
  emit('click', index);
144
+ if (props.asyncClose) return;
139
145
  emit('update:modelValue', false);
140
146
  }
147
+
148
+ defineExpose({
149
+ props,
150
+ close,
151
+ itemClick
152
+ });
141
153
  </script>
142
154
 
143
155
  <style lang="scss" scoped>
@@ -172,7 +184,7 @@ function itemClick(index: number) {
172
184
  background-color: rgb(234, 234, 236);
173
185
  }
174
186
 
175
- .u-actionsheet-cancel {
187
+ .u-action-sheet-cancel {
176
188
  color: $u-main-color;
177
189
  }
178
190
  </style>
@@ -0,0 +1,27 @@
1
+ import { type ExtractPropTypes, type PropType } from 'vue';
2
+ import { baseProps } from '../common/props';
3
+ import { $u } from '../../';
4
+
5
+ /**
6
+ * actionSheet 操作菜单
7
+ * @description 本组件用于从底部弹出一个操作菜单,供用户选择并返回结果。本组件功能类似于uni的uni.showActionSheetAPI,配置更加灵活,所有平台都表现一致。
8
+ */
9
+ export const ActionSheetItemProps = {
10
+ ...baseProps,
11
+ /** 标题 */
12
+ text: { type: String, default: '' },
13
+ /** 描述 */
14
+ subText: { type: String, default: '' },
15
+ /** 边距 */
16
+ padding: { type: [Number, String] as PropType<number | string>, default: '34rpx 0' },
17
+ /** 字体颜色 */
18
+ color: { type: String, default: $u.color.mainColor },
19
+ /** 字体大小 */
20
+ fontSize: { type: [String, Number], default: '32rpx' },
21
+ /** 是否禁用 */
22
+ disabled: { type: Boolean, default: false },
23
+ /** 是否异步关闭 */
24
+ asyncClose: { type: Boolean, default: false }
25
+ };
26
+
27
+ export type ActionSheetItemProps = ExtractPropTypes<typeof ActionSheetItemProps>;
@@ -0,0 +1,85 @@
1
+ <template>
2
+ <view
3
+ class="u-action-sheet-item u-line-1"
4
+ :class="[!isLast ? 'u-border-bottom' : '', disabled ? 'u-action-sheet-item--disabled' : '', customClass]"
5
+ :style="$u.toStyle(itemStyle, customStyle)"
6
+ @click="handleClick"
7
+ @touchmove.stop.prevent
8
+ hover-class="u-hover-class"
9
+ :hover-stay-time="150"
10
+ >
11
+ <slot>
12
+ <text>{{ text }}</text>
13
+ <text class="u-action-sheet-item__subtext u-line-1" v-if="subText">{{ subText }}</text>
14
+ </slot>
15
+ </view>
16
+ </template>
17
+
18
+ <script lang="ts">
19
+ export default {
20
+ name: 'u-action-sheet-item',
21
+ options: {
22
+ addGlobalClass: true,
23
+ // #ifndef MP-TOUTIAO
24
+ virtualHost: true,
25
+ // #endif
26
+ styleIsolation: 'shared'
27
+ }
28
+ };
29
+ </script>
30
+
31
+ <script setup lang="ts">
32
+ import { computed } from 'vue';
33
+ import { ActionSheetItemProps } from './types';
34
+ import { $u, useChildren } from '../../libs';
35
+
36
+ const props = defineProps(ActionSheetItemProps);
37
+ const emit = defineEmits(['click']);
38
+
39
+ const { parent, parentExposed, childIndex, emitToParent } = useChildren('u-action-sheet-item', 'u-action-sheet');
40
+
41
+ const isLast = computed(() => {
42
+ return (childIndex?.value ?? 0) + 1 >= (parent?.value?.getChildren()?.length ?? 0);
43
+ });
44
+
45
+ const itemStyle = computed(() => {
46
+ const style: Record<string, string> = {};
47
+ style.color = props.color || parentExposed?.value?.props?.color;
48
+ style.fontSize = $u.addUnit(props.fontSize || parentExposed?.value?.props?.fontSize);
49
+ style.padding = $u.addUnit(props.padding);
50
+ if (props.disabled) style.color = '#c0c4cc';
51
+ return style;
52
+ });
53
+
54
+ function handleClick() {
55
+ if (props.disabled) return;
56
+ emit('click', childIndex?.value || 0);
57
+ if (!props.asyncClose && !parentExposed?.value?.props?.asyncClose) {
58
+ emitToParent('itemClick', childIndex?.value || 0);
59
+ }
60
+ }
61
+ </script>
62
+
63
+ <style lang="scss" scoped>
64
+ @import '../../libs/css/style.components.scss';
65
+
66
+ .u-action-sheet-item {
67
+ @include vue-flex;
68
+ line-height: 1;
69
+ justify-content: center;
70
+ align-items: center;
71
+ font-size: 32rpx;
72
+ padding: 34rpx 0;
73
+ flex-direction: column;
74
+ }
75
+
76
+ .u-action-sheet-item--disabled {
77
+ color: $u-light-color;
78
+ }
79
+
80
+ .u-action-sheet-item__subtext {
81
+ font-size: 24rpx;
82
+ color: $u-tips-color;
83
+ margin-top: 20rpx;
84
+ }
85
+ </style>
@@ -19,7 +19,7 @@ export default {
19
19
 
20
20
  <script setup lang="ts">
21
21
  import { getCurrentInstance, computed } from 'vue';
22
- import { $u, useParent } from '../..';
22
+ import { $u, useParent, useChildren } from '../..';
23
23
  import { CheckboxGroupProps } from './types';
24
24
 
25
25
  /**
@@ -44,6 +44,7 @@ const emit = defineEmits(['update:modelValue', 'change']);
44
44
 
45
45
  // 使用父组件Hook
46
46
  const { children, broadcast } = useParent('u-checkbox-group');
47
+ const { emitToParent } = useChildren('u-checkbox-group', 'u-form-item');
47
48
 
48
49
  /**
49
50
  * 派发 change 事件和表单校验
@@ -58,7 +59,7 @@ function emitEvent() {
58
59
  });
59
60
  emit('change', values);
60
61
  setTimeout(() => {
61
- $u.dispatch(instance, 'u-form-item', 'on-form-change', values);
62
+ emitToParent('onFormChange', values);
62
63
  }, 60);
63
64
  }
64
65
 
@@ -88,15 +88,16 @@ export default {
88
88
  </script>
89
89
 
90
90
  <script setup lang="ts">
91
- import { ref, computed, onMounted, onBeforeUnmount, watch, getCurrentInstance, nextTick } from 'vue';
92
- import { $u, useChildren } from '../..';
93
- import { broadcast } from '../../libs/util/emitter';
91
+ import { ref, computed, onMounted, onBeforeUnmount, watch, nextTick } from 'vue';
92
+ import { $u, useChildren, useParent } from '../..';
94
93
  // @ts-ignore
95
94
  import schema from '../../libs/util/async-validator';
96
95
  import { FormItemProps } from './types';
97
96
  // 去除警告信息
98
97
  schema.warning = function () {};
99
98
 
99
+ const { broadcast } = useParent('u-form-item');
100
+
100
101
  /**
101
102
  * form-item 表单item
102
103
  * @description 此组件一般用于表单场景,可以配置Input输入框,Select弹出框,进行表单验证等。
@@ -120,8 +121,6 @@ const props = defineProps(FormItemProps);
120
121
 
121
122
  const { parentExposed } = useChildren('u-form-item', 'u-form');
122
123
 
123
- const instance = getCurrentInstance();
124
-
125
124
  // 组件状态
126
125
  const initialValue = ref(''); // 存储初始值,用于重置
127
126
  const validateState = ref(''); // 校验状态 success/error/validating
@@ -136,6 +135,15 @@ const parentData = ref({
136
135
  labelAlign: 'left' // 父表单 label 对齐
137
136
  });
138
137
 
138
+ // 显示错误提示
139
+ // errorType: ['message', 'toast', 'border-bottom', 'none']
140
+ const showError = computed(() => (type: string) => {
141
+ // 如果errorType数组中含有none,或者toast提示类型
142
+ if (errorType.value.indexOf('none') >= 0) return false;
143
+ else if (errorType.value.indexOf(type) >= 0) return true;
144
+ else return false;
145
+ });
146
+
139
147
  // 监听校验状态和父表单 errorType 变化
140
148
  watch(validateState, () => {
141
149
  broadcastInputError();
@@ -161,15 +169,6 @@ const uLabelWidth = computed(() => {
161
169
  : '100%';
162
170
  });
163
171
 
164
- // 显示错误提示
165
- // errorType: ['message', 'toast', 'border-bottom', 'none']
166
- const showError = computed(() => (type: string) => {
167
- // 如果errorType数组中含有none,或者toast提示类型
168
- if (errorType.value.indexOf('none') >= 0) return false;
169
- else if (errorType.value.indexOf(type) >= 0) return true;
170
- else return false;
171
- });
172
-
173
172
  // label的宽度
174
173
  const elLabelWidth = computed(() => {
175
174
  // label默认宽度为90,优先使用本组件的值,如果没有(如果设置为0,也算是配置了值,依然起效),则用u-form的值
@@ -215,17 +214,8 @@ const elBorderBottom = computed(() => {
215
214
 
216
215
  // 事件派发/广播工具
217
216
  function broadcastInputError() {
218
- // 子组件发出事件,第三个参数为true或者false,true代表有错误
219
- if (instance) {
220
- // 这里可用 emitter 工具库的 broadcast 方法
221
- // 子组件发出事件,第三个参数为true或者false,true代表有错误
222
- broadcast(
223
- instance,
224
- 'u-input',
225
- 'on-form-item-error',
226
- validateState.value === 'error' && showError.value('border')
227
- );
228
- }
217
+ // 子组件发出事件,参数为true或者false,true代表有错误
218
+ broadcast('onFormItemError', validateState.value === 'error' && showError.value('border'));
229
219
  }
230
220
 
231
221
  /**
@@ -105,13 +105,14 @@ export default {
105
105
  </script>
106
106
 
107
107
  <script setup lang="ts">
108
- import { ref, computed, watch, getCurrentInstance } from 'vue';
109
- import { $u } from '../..';
110
- import { dispatch } from '../../libs/util/emitter';
108
+ import { ref, computed, watch } from 'vue';
109
+ import { $u, useChildren } from '../..';
111
110
  import { InputProps } from './types';
112
111
 
113
112
  const props = defineProps(InputProps);
114
- const emit = defineEmits(['update:modelValue', 'blur', 'focus', 'confirm', 'click']);
113
+ const emit = defineEmits(['update:modelValue', 'input', 'blur', 'focus', 'confirm', 'click']);
114
+
115
+ const { emitToParent } = useChildren('u-input', 'u-form-item');
115
116
 
116
117
  const defaultValue = ref(props.modelValue);
117
118
  const inputHeight = 70; // input的高度
@@ -158,10 +159,6 @@ const uSelectionStart = computed(() => String(props.selectionStart));
158
159
  // 光标结束位置
159
160
  const uSelectionEnd = computed(() => String(props.selectionEnd));
160
161
 
161
- const instance = getCurrentInstance();
162
-
163
- // 监听u-form-item发出的错误事件,将输入框边框变红色,失效了
164
- // uni.$on('on-form-item-error', onFormItemError);
165
162
  /**
166
163
  * change 事件
167
164
  * @param event
@@ -171,6 +168,7 @@ function handleInput(event: any) {
171
168
  // 判断是否去除空格
172
169
  if (props.trim) value = $u.trim(value);
173
170
  emit('update:modelValue', value);
171
+ emit('input', value);
174
172
  // 当前model 赋值
175
173
  defaultValue.value = value;
176
174
  // 过一个生命周期再发送事件给u-form-item,否则this.$emit('update:modelValue')更新了父组件的值,但是微信小程序上
@@ -183,7 +181,7 @@ function handleInput(event: any) {
183
181
  lastValue.value = value;
184
182
  // #endif
185
183
  // 通过 emitter 派发事件
186
- dispatch(instance, 'u-form-item', 'on-form-change', value);
184
+ emitToParent('onFormChange', value);
187
185
  }, 40);
188
186
  }
189
187
 
@@ -205,12 +203,11 @@ function handleBlur(event: any) {
205
203
  if ($u.trim(value) == lastValue.value) return;
206
204
  lastValue.value = value;
207
205
  // #endif
208
- dispatch(instance, 'u-form-item', 'on-form-blur', value);
206
+ emitToParent('onFormBlur', value);
209
207
  }, 40);
210
208
  }
211
209
 
212
210
  function onFormItemError(status: boolean) {
213
- console.log('onFormItemError', status);
214
211
  validateState.value = status;
215
212
  }
216
213
 
@@ -235,6 +232,10 @@ function onClear(event: any) {
235
232
  function inputClick() {
236
233
  emit('click');
237
234
  }
235
+
236
+ defineExpose({
237
+ onFormItemError
238
+ });
238
239
  </script>
239
240
 
240
241
  <style lang="scss" scoped>
@@ -65,7 +65,7 @@ const slots = useSlots();
65
65
  const progressStyle = computed(() => {
66
66
  let style: Record<string, string> = {};
67
67
  style.width = props.percent + '%';
68
- if (props.activeColor) style.backgroundColor = props.activeColor;
68
+ if (!props.type && props.activeColor) style.backgroundColor = props.activeColor;
69
69
  return style;
70
70
  });
71
71
  </script>
@@ -28,21 +28,16 @@
28
28
  :style="[style]"
29
29
  >
30
30
  <view
31
+ v-if="mode == 'center'"
31
32
  class="u-mode-center-box"
32
33
  @tap.stop.prevent
33
34
  @touchmove.stop.prevent
34
- v-if="mode == 'center'"
35
35
  :style="[centerStyle]"
36
36
  >
37
- <u-icon
38
- @click="close"
39
- v-if="closeable"
40
- class="u-close"
41
- :class="['u-close--' + closeIconPos]"
42
- :name="closeIcon"
43
- :color="closeIconColor"
44
- :size="closeIconSize"
45
- ></u-icon>
37
+ <view v-if="closeable" @click="close" class="u-close" :class="['u-close--' + closeIconPos]">
38
+ <u-icon :name="closeIcon" :color="closeIconColor" :size="closeIconSize"></u-icon>
39
+ </view>
40
+
46
41
  <scroll-view class="u-drawer__scroll-view" scroll-y="true">
47
42
  <slot />
48
43
  </scroll-view>
@@ -50,13 +45,13 @@
50
45
  <scroll-view class="u-drawer__scroll-view" scroll-y="true" v-else>
51
46
  <slot />
52
47
  </scroll-view>
53
- <view @tap="close" class="u-close" :class="['u-close--' + closeIconPos]">
54
- <u-icon
55
- v-if="mode != 'center' && closeable"
56
- :name="closeIcon"
57
- :color="closeIconColor"
58
- :size="closeIconSize"
59
- ></u-icon>
48
+ <view
49
+ v-if="mode != 'center' && closeable"
50
+ @click="close"
51
+ class="u-close"
52
+ :class="['u-close--' + closeIconPos]"
53
+ >
54
+ <u-icon :name="closeIcon" :color="closeIconColor" :size="closeIconSize"></u-icon>
60
55
  </view>
61
56
  </view>
62
57
  </view>
@@ -18,8 +18,7 @@ export default {
18
18
  </script>
19
19
 
20
20
  <script setup lang="ts">
21
- import { getCurrentInstance } from 'vue';
22
- import { $u, useParent } from '../..';
21
+ import { $u, useParent, useChildren } from '../..';
23
22
  import { RadioGroupProps } from './types';
24
23
 
25
24
  /**
@@ -42,6 +41,7 @@ const props = defineProps(RadioGroupProps);
42
41
 
43
42
  const emit = defineEmits(['update:modelValue', 'change']);
44
43
 
44
+ const { emitToParent } = useChildren('u-radio-group', 'u-form-item');
45
45
  useParent('u-radio-group');
46
46
 
47
47
  /**
@@ -73,7 +73,7 @@ function setValue(val: string | number) {
73
73
  // 由于头条小程序执行迟钝,故需要用几十毫秒的延时
74
74
  setTimeout(() => {
75
75
  // 将当前的值发送到 u-form-item 进行校验
76
- $u.dispatch(getCurrentInstance(), 'u-form-item', 'on-form-change', val);
76
+ emitToParent('onFormChange', val);
77
77
  }, 60);
78
78
  }
79
79
 
@@ -0,0 +1,11 @@
1
+ import type { ExtractPropTypes } from 'vue';
2
+ import { baseProps } from '../common/props';
3
+
4
+ /**
5
+ * SafeBottomProps SafeBottom 底部安全区
6
+ */
7
+ export const SafeBottomProps = {
8
+ ...baseProps,
9
+ };
10
+
11
+ export type SafeBottomProps = ExtractPropTypes<typeof SafeBottomProps>;
@@ -1,5 +1,9 @@
1
1
  <template>
2
- <view class="u-safe-bottom" :style="style" :class="[!isNVue && 'safe-area-inset-bottom']"></view>
2
+ <view
3
+ class="u-safe-bottom"
4
+ :style="$u.toStyle(style, customStyle)"
5
+ :class="[!isNVue && 'safe-area-inset-bottom', customClass]"
6
+ ></view>
3
7
  </template>
4
8
 
5
9
  <script lang="ts">
@@ -16,11 +20,9 @@ export default {
16
20
  </script>
17
21
 
18
22
  <script setup lang="ts">
19
- import { ref, computed, onMounted, withDefaults, type CSSProperties } from 'vue';
20
- import { sys } from '../../libs/function/sys';
21
- import addUnit from '../../libs/function/addUnit';
22
- import deepMerge from '../../libs/function/deepMerge';
23
- import { mergeStyles } from '../../libs/function/styleUtils';
23
+ import { ref, computed, onMounted, type CSSProperties } from 'vue';
24
+ import { SafeBottomProps } from './props';
25
+ import { $u } from '../../';
24
26
 
25
27
  /**
26
28
  * SafeBottom 底部安全区
@@ -28,24 +30,17 @@ import { mergeStyles } from '../../libs/function/styleUtils';
28
30
  * @property {String | Object} customStyle 自定义样式
29
31
  * @example <u-safe-bottom></u-safe-bottom>
30
32
  */
31
- const props = withDefaults(
32
- defineProps<{
33
- customStyle?: string | CSSProperties;
34
- }>(),
35
- {
36
- customStyle: () => ({})
37
- }
38
- );
33
+ const props = defineProps(SafeBottomProps);
39
34
 
40
35
  const isNVue = ref(false);
41
36
 
42
37
  const style = computed(() => {
43
- let r: CSSProperties = {};
38
+ let result: CSSProperties = {};
44
39
  // #ifdef APP-NVUE || MP-TOUTIAO
45
40
  // nvue下,高度使用js计算填充
46
- r.height = addUnit(sys().safeAreaInsets.bottom, 'px');
41
+ result.height = $u.addUnit($u.sys().safeAreaInsets.bottom, 'px');
47
42
  // #endif
48
- return deepMerge(r, mergeStyles(props.customStyle));
43
+ return result;
49
44
  });
50
45
 
51
46
  onMounted(() => {