@cloudbase/weda-ui-mp 3.10.1 → 3.11.0

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.
@@ -378,6 +378,8 @@
378
378
  color: var(--wd-form-readonly-font-color);
379
379
  width: 100%;
380
380
  word-break: break-word;
381
+ display: flex;
382
+ align-items: center;
381
383
  }
382
384
  .wd-form-item__readonly-web.size-font-sm {
383
385
  font: var(--wd-typography-body-sm);
@@ -1,5 +1,7 @@
1
1
  import { validType } from './validator';
2
2
  import equal from '../../utils/deepEqual';
3
+ import { errorHandler } from '../../utils/error';
4
+
3
5
  import { autorun, untracked } from 'mobx';
4
6
  import {
5
7
  convertStatus,
@@ -40,6 +42,10 @@ export default Behavior({
40
42
  type: Boolean,
41
43
  value: true,
42
44
  },
45
+ label: {
46
+ type: String,
47
+ value: '标题',
48
+ },
43
49
  requiredMsg: {
44
50
  type: String,
45
51
  value: '该项为必填项',
@@ -93,7 +99,7 @@ export default Behavior({
93
99
  setHidden() {
94
100
  that.setVisible(false);
95
101
  },
96
- async handleValidate() {
102
+ async handleValidate(throwError = true) {
97
103
  let finalValue = that.data.value;
98
104
  const {
99
105
  required,
@@ -101,6 +107,7 @@ export default Behavior({
101
107
  requiredMsg,
102
108
  privateRules,
103
109
  selfDefineRules,
110
+ label,
104
111
  } = that.data;
105
112
  const _rules = [].concat(rules, privateRules, selfDefineRules);
106
113
  if (!required && !_rules.length) return;
@@ -189,6 +196,14 @@ export default Behavior({
189
196
  validateState: 'error',
190
197
  validateErrorMsg: errorArr[0].message,
191
198
  });
199
+ if (throwError) {
200
+ const { compError } = errorHandler({
201
+ code: 'VALIDATE_ERROR',
202
+ error: errorArr,
203
+ message: `【${label}】${errorArr[0]?.message}`,
204
+ });
205
+ throw compError;
206
+ }
192
207
  } else {
193
208
  // console.log("校验成功>>>>>>>")
194
209
  that.setData({
@@ -13,9 +13,10 @@ const pattern = {
13
13
  userName: /^[\da-zA-Z\u2E80-\uFE4F \s]{2,}$/,
14
14
  carId:
15
15
  /^[京津沪渝冀豫云辽黑湘皖鲁新苏浙赣鄂桂甘晋蒙陕吉闽贵粤青藏川宁琼使领A-Z]{1}[A-Z]{1}[A-Z0-9]{4}[A-Z0-9挂学警港澳]{1}$/,
16
- mobile:
16
+ mobile: /^1[3-9]\d{9}$/,
17
+ tel: /(^(0\d{2,3}-)?|^\(\d{3}\)?|^(400|800)-?)(\d{3,8})(-\d{1,4})?$/,
18
+ internationalTel:
17
19
  /^(\+\d{1,4}[\s-]?)?(\(?\d{1,4}\)?[\s-]?)?(\d{1,4}[\s-]?)?(\d{1,4})?\d{1,9}(\s?(x|ext)\s?\d{1,6})?$/,
18
- tel: /^(\+\d{1,4}[\s-]?)?(\(?\d{1,4}\)?[\s-]?)?(\d{1,4}[\s-]?)?(\d{1,4})?\d{1,9}(\s?(x|ext)\s?\d{1,6})?$/,
19
20
  address: /^[\da-zA-Z\u2E80-\uFE4F \s-]{4,400}$/,
20
21
  date: /((^((1[8-9]\d{2})|([2-9]\d{3}))([-\/\._])(10|12|0?[13578])([-\/\._])(3[01]|[12][0-9]|0?[1-9])$)|(^((1[8-9]\d{2})|([2-9]\d{3}))([-\/\._])(11|0?[469])([-\/\._])(30|[12][0-9]|0?[1-9])$)|(^((1[8-9]\d{2})|([2-9]\d{3}))([-\/\._])(0?2)([-\/\._])(2[0-8]|1[0-9]|0?[1-9])$)|(^([2468][048]00)([-\/\._])(0?2)([-\/\._])(29)$)|(^([3579][26]00)([-\/\._])(0?2)([-\/\._])(29)$)|(^([1][89][0][48])([-\/\._])(0?2)([-\/\._])(29)$)|(^([2-9][0-9][0][48])([-\/\._])(0?2)([-\/\._])(29)$)|(^([1][89][2468][048])([-\/\._])(0?2)([-\/\._])(29)$)|(^([2-9][0-9][2468][048])([-\/\._])(0?2)([-\/\._])(29)$)|(^([1][89][13579][26])([-\/\._])(0?2)([-\/\._])(29)$)|(^([2-9][0-9][13579][26])([-\/\._])(0?2)([-\/\._])(29)$))/,
21
22
  numVcode: /^[0-9]{4,8}$/,
@@ -67,6 +68,9 @@ export const validType = {
67
68
  tel(value) {
68
69
  return pattern.tel.test(String(value).trim());
69
70
  },
71
+ internationalTel(value) {
72
+ return pattern.internationalTel.test(String(value).trim());
73
+ },
70
74
  // 邮箱检测
71
75
  email(value) {
72
76
  return typeof value === 'string' && pattern.email.test(value.trim());
@@ -110,7 +110,11 @@
110
110
  width: 100%;
111
111
  height: 100%;
112
112
  }
113
-
113
+ .weda-grid-navigation__icon {
114
+ display: flex;
115
+ align-items: center;
116
+ justify-content: center;
117
+ }
114
118
  .weda-grid-navigation .weda-grid-navigation__col .weda-grid-navigation__text {
115
119
  font-size: 0.85714em;
116
120
  line-height: 1.42857em;
@@ -136,7 +136,7 @@ Component({
136
136
  }
137
137
  items.forEach((item) => {
138
138
  if (item.handleValidate) {
139
- const validate = item.handleValidate();
139
+ const validate = item.handleValidate(false);
140
140
  const { name, label } = item;
141
141
 
142
142
  if (validate) {
@@ -378,6 +378,8 @@
378
378
  color: var(--wd-form-readonly-font-color);
379
379
  width: 100%;
380
380
  word-break: break-word;
381
+ display: flex;
382
+ align-items: center;
381
383
  }
382
384
  .wd-form-item__readonly-web.size-font-sm {
383
385
  font: var(--wd-typography-body-sm);
@@ -378,6 +378,8 @@
378
378
  color: var(--wd-form-readonly-font-color);
379
379
  width: 100%;
380
380
  word-break: break-word;
381
+ display: flex;
382
+ align-items: center;
381
383
  }
382
384
  .wd-form-item__readonly-web.size-font-sm {
383
385
  font: var(--wd-typography-body-sm);
@@ -378,6 +378,8 @@
378
378
  color: var(--wd-form-readonly-font-color);
379
379
  width: 100%;
380
380
  word-break: break-word;
381
+ display: flex;
382
+ align-items: center;
381
383
  }
382
384
  .wd-form-item__readonly-web.size-font-sm {
383
385
  font: var(--wd-typography-body-sm);
@@ -540,6 +540,8 @@
540
540
  color: var(--wd-form-readonly-font-color);
541
541
  width: 100%;
542
542
  word-break: break-word;
543
+ display: flex;
544
+ align-items: center;
543
545
  }
544
546
  .wd-form-item__readonly-web.size-font-sm {
545
547
  font: var(--wd-typography-body-sm);
@@ -1387,6 +1389,9 @@ textarea {
1387
1389
  display: flex;
1388
1390
  align-items: center;
1389
1391
  }
1392
+ .wd-form-input-wrap__content .weui-cell_active:active::after {
1393
+ background-color: unset;
1394
+ }
1390
1395
  .wd-form-input-wrap.wd-input-input-search.template.search-box.color-grey.is-pc-bordered {
1391
1396
  background-color: #f2f2f2;
1392
1397
  border-color: #f2f2f2;
@@ -119,6 +119,9 @@
119
119
  display: flex;
120
120
  align-items: center;
121
121
  }
122
+ .wd-form-input-wrap__content .weui-cell_active:active::after {
123
+ background-color: unset;
124
+ }
122
125
  .wd-form-input-wrap.wd-input-input-search.template.search-box.color-grey.is-pc-bordered {
123
126
  background-color: #f2f2f2;
124
127
  border-color: #f2f2f2;
@@ -83,7 +83,7 @@ Component({
83
83
  * 设置选中菜单项
84
84
  * @param {*} params
85
85
  */
86
- setSelectedInfo(params, isNavigate = false) {
86
+ setSelectedInfo({ params, isNavigate = false } = {}) {
87
87
  const { key, item } = params || {};
88
88
  let selectItem = item;
89
89
  if (key || !item) {
@@ -133,7 +133,7 @@ Component({
133
133
  (menu.isMultiTerminal ? menu.mobileMenuData : menu.menuData) || []
134
134
  );
135
135
  const selectItem = this.findSelectItem(menuData) || {};
136
- this.setSelectedInfo({ item: selectItem });
136
+ this.setSelectedInfo({ params: { item: selectItem } });
137
137
  this.setData({
138
138
  menuData: this.generateMenuData({
139
139
  menuData,
@@ -410,6 +410,8 @@
410
410
  color: var(--wd-form-readonly-font-color);
411
411
  width: 100%;
412
412
  word-break: break-word;
413
+ display: flex;
414
+ align-items: center;
413
415
  }
414
416
  .wd-form-item__readonly-web.size-font-sm {
415
417
  font: var(--wd-typography-body-sm);
@@ -403,6 +403,8 @@
403
403
  color: var(--wd-form-readonly-font-color);
404
404
  width: 100%;
405
405
  word-break: break-word;
406
+ display: flex;
407
+ align-items: center;
406
408
  }
407
409
  .wd-form-item__readonly-web.size-font-sm {
408
410
  font: var(--wd-typography-body-sm);
@@ -742,4 +742,8 @@
742
742
  .wd-custom-calendar__days-item.no-select {
743
743
  color: #c1c1c1;
744
744
  cursor: not-allowed;
745
+ }
746
+
747
+ .wd-mp-form-item .wd-form-select_input {
748
+ cursor: unset;
745
749
  }
@@ -499,6 +499,8 @@
499
499
  color: var(--wd-form-readonly-font-color);
500
500
  width: 100%;
501
501
  word-break: break-word;
502
+ display: flex;
503
+ align-items: center;
502
504
  }
503
505
  .wd-form-item__readonly-web.size-font-sm {
504
506
  font: var(--wd-typography-body-sm);
@@ -90,4 +90,7 @@
90
90
 
91
91
  .wd-mp-tabbar .wd-tabbar__item {
92
92
  cursor: unset;
93
+ }
94
+ .wd-mp-tabbar .wd-tabbar__item-icon {
95
+ display: contents;
93
96
  }
@@ -540,6 +540,8 @@
540
540
  color: var(--wd-form-readonly-font-color);
541
541
  width: 100%;
542
542
  word-break: break-word;
543
+ display: flex;
544
+ align-items: center;
543
545
  }
544
546
  .wd-form-item__readonly-web.size-font-sm {
545
547
  font: var(--wd-typography-body-sm);
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "miniprogram": "./",
4
4
  "packageManager": "yarn@3.0.2",
5
5
  "dependencies": {},
6
- "version": "3.10.1",
6
+ "version": "3.11.0",
7
7
  "main": "./",
8
8
  "publishConfig": {
9
9
  "access": "public"
package/utils/enum.js CHANGED
@@ -709,13 +709,17 @@ export const WD_INPUT_RULES = [
709
709
  value: 'cn',
710
710
  },
711
711
  {
712
- label: '手机号',
712
+ label: '大陆手机号',
713
713
  value: 'mobile',
714
714
  },
715
715
  {
716
716
  label: '固定电话',
717
717
  value: 'tel',
718
718
  },
719
+ {
720
+ label: '通用电话(国内及境外手机号、电话)',
721
+ value: 'internationalTel',
722
+ },
719
723
  {
720
724
  label: '网址',
721
725
  value: 'url',
package/utils/error.js CHANGED
@@ -11,12 +11,14 @@ export class WdCompError extends Error {
11
11
  }
12
12
  }
13
13
 
14
- export const errorHandler = ({ id = '', code, error }) => {
14
+ export const errorHandler = ({ id = '', code, error, message = '' }) => {
15
15
  const comErrorInfo = {
16
16
  code,
17
17
  requestId: error?.requestId,
18
18
  original: error,
19
- message: `[组件${id}:${code}]${error?.message || error?.errMsg || code}`,
19
+ message:
20
+ message ||
21
+ `[组件${id}:${code}]${error?.message || error?.errMsg || code}`,
20
22
  };
21
23
  const compError = new WdCompError(comErrorInfo.message, comErrorInfo);
22
24
  console.error(`${comErrorInfo.code}:`, comErrorInfo);