uview-plus 3.3.10 → 3.3.11

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,12 @@
1
+ ## 3.3.11(2024-08-05)
2
+ feat: 新增支持upload组件的deletable/maxCount/accept变更监听 #333
3
+
4
+ feat: 新增支持tabs在swiper中使用
5
+
6
+ feat: 新增FormItem支持独立设置验证规则rules
7
+
8
+ fix: 修复index-list未设置$slots.header时索引高亮失效
9
+
1
10
  ## 3.3.10(2024-08-02)
2
11
  fix: 修复index-list偶发的滑动最后一个索引报错top不存在
3
12
 
@@ -149,7 +149,12 @@
149
149
  const propertyName =
150
150
  propertyChain[propertyChain.length - 1];
151
151
 
152
- const rule = this.formRules[child.rule || child.prop];
152
+ let rule = []
153
+ if (child.itemRules && child.itemRules.length > 0) {
154
+ rule = child.itemRules
155
+ } else {
156
+ rule = this.formRules[child.prop];
157
+ }
153
158
  // 如果不存在对应的规则,直接返回,否则校验器会报错
154
159
  if (!rule) {
155
160
  resolve()
@@ -13,9 +13,9 @@ export const props = defineMixin({
13
13
  default: () => defProps.formItem.prop
14
14
  },
15
15
  // 绑定的规则
16
- rule: {
17
- type: String,
18
- default: () => defProps.formItem.rule
16
+ rules: {
17
+ type: Array,
18
+ default: () => defProps.formItem.rules
19
19
  },
20
20
  // 是否显示表单域的下划线边框
21
21
  borderBottom: {
@@ -87,12 +87,12 @@
87
87
  * @tutorial https://ijry.github.io/uview-plus/components/form.html
88
88
  * @property {String} label input的label提示语
89
89
  * @property {String} prop 绑定的值
90
- * @property {String} rule 绑定的规则
90
+ * @property {Array} rules 绑定的规则
91
91
  * @property {String | Boolean} borderBottom 是否显示表单域的下划线边框
92
92
  * @property {String | Number} labelWidth label的宽度,单位px
93
93
  * @property {String} rightIcon 右侧图标
94
94
  * @property {String} leftIcon 左侧图标
95
- * @property {String | Object} leftIconStyle 左侧图标的样式
95
+ * @property {String | Object} leftIconStyle 左侧图标的样式
96
96
  * @property {Boolean} required 是否显示左边的必填星号,只作显示用,具体校验必填的逻辑,请在rules中配置 (默认 false )
97
97
  *
98
98
  * @example <u-form-item label="姓名" prop="userInfo.name" borderBottom ref="item1"></u-form-item>
@@ -116,7 +116,8 @@
116
116
  // 错误提示方式
117
117
  errorType: 'message'
118
118
  },
119
- color: color
119
+ color: color,
120
+ itemRules: []
120
121
  }
121
122
  },
122
123
  // 组件创建完成时,将当前实例保存到u-form中
@@ -129,6 +130,15 @@
129
130
  this.init()
130
131
  },
131
132
  emits: ["click"],
133
+ watch: {
134
+ // 监听规则的变化
135
+ rules: {
136
+ immediate: true,
137
+ handler(n) {
138
+ this.setRules(n);
139
+ },
140
+ },
141
+ },
132
142
  methods: {
133
143
  addStyle,
134
144
  addUnit,
@@ -139,6 +149,12 @@
139
149
  error('u-form-item需要结合u-form组件使用')
140
150
  }
141
151
  },
152
+ // 手动设置校验的规则,如果规则中有函数的话,微信小程序中会过滤掉,所以只能手动调用设置规则
153
+ setRules(rules) {
154
+ // 判断是否有规则
155
+ if (rules.length === 0) return;
156
+ this.itemRules = rules;
157
+ },
142
158
  // 获取父组件的参数
143
159
  updateParentData() {
144
160
  // 此方法写在mixin中
@@ -436,6 +436,13 @@
436
436
  getHeaderRect() {
437
437
  // 获取header slot的高度,因为list组件中获取元素的尺寸是没有top值的
438
438
  return new Promise(resolve => {
439
+ if (!this.$slots.header) {
440
+ resolve({
441
+ width: 0,
442
+ height: 0
443
+ })
444
+ }
445
+
439
446
  // #ifndef APP-NVUE
440
447
  this.$uGetRect('.u-index-list__header').then(size => {
441
448
  resolve(size)
@@ -454,7 +461,6 @@
454
461
  resolve(res.size)
455
462
  })
456
463
  // #endif
457
-
458
464
  })
459
465
  },
460
466
  // scroll-view的滚动事件
@@ -178,6 +178,7 @@
178
178
  // 获取下划线的数值px表示法
179
179
  const lineWidth = getPx(this.lineWidth);
180
180
  this.lineOffsetLeft = lineOffsetLeft + (tabItem.rect.width - lineWidth) / 2
181
+ console.log(lineOffsetLeft)
181
182
  // #ifdef APP-NVUE
182
183
  // 第一次移动滑块,无需过渡时间
183
184
  this.animation(this.lineOffsetLeft, this.firstTime ? 0 : parseInt(this.duration))
@@ -257,6 +258,12 @@
257
258
  return
258
259
  }
259
260
  Promise.all([this.getTabsRect(), this.getAllItemRect()]).then(([tabsRect, itemRect = []]) => {
261
+ // 兼容在swiper组件中使用
262
+ if (tabsRect.left > tabsRect.width) {
263
+ tabsRect.right = tabsRect.right - Math.floor(tabsRect.left / tabsRect.width) * tabsRect.width
264
+ tabsRect.left = tabsRect.left % tabsRect.width
265
+ }
266
+ // console.log(tabsRect)
260
267
  this.tabsRect = tabsRect
261
268
  this.scrollViewWidth = 0
262
269
  itemRect.map((item, index) => {
@@ -196,6 +196,15 @@
196
196
  immediate: true,
197
197
  deep: true,
198
198
  },
199
+ deletable(newVal) {
200
+ this.formatFileList()
201
+ },
202
+ maxCount(newVal) {
203
+ this.formatFileList()
204
+ },
205
+ accept(newVal) {
206
+ this.formatFileList()
207
+ }
199
208
  },
200
209
  // #ifdef VUE3
201
210
  emits: ['error', 'beforeRead', 'oversize', 'afterRead', 'delete', 'clickPreview'],
@@ -12,7 +12,7 @@ export default {
12
12
  formItem: {
13
13
  label: '',
14
14
  prop: '',
15
- rule: '',
15
+ rules: [],
16
16
  borderBottom: '',
17
17
  labelPosition: '',
18
18
  labelWidth: '',
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "id": "uview-plus",
3
3
  "name": "uview-plus",
4
4
  "displayName": "uview-plus3.0重磅发布,全面的Vue3移动组件库。",
5
- "version": "3.3.10",
5
+ "version": "3.3.11",
6
6
  "description": "uview-plus已兼容vue3,全面的组件和便捷的工具会让您信手拈来,如鱼得水",
7
7
  "keywords": [
8
8
  "uview",