@cloudbase/weda-ui-mp 3.18.4 → 3.18.6

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.
@@ -97,9 +97,23 @@ export default Behavior({
97
97
  },
98
98
  async handleValidate(throwError = true) {
99
99
  let finalValue = that.data.value;
100
+ const validPromise = [];
101
+ if (that.data?.formsItemMap && Object.values(that.data?.formsItemMap)?.length) {
102
+ Object.values(that.data?.formsItemMap).forEach((field) => {
103
+ field?.forEach((item) => {
104
+ if (item.handleValidate) {
105
+ const validate = item.handleValidate(false);
106
+ if (validate) {
107
+ validPromise.push(validate);
108
+ }
109
+ }
110
+ });
111
+ });
112
+ }
113
+
100
114
  const { required, rules, requiredMsg, privateRules, selfDefineRules, label } = that.data;
101
115
  const _rules = [].concat(rules, privateRules, selfDefineRules);
102
- if (!required && !_rules.length) return;
116
+ if (!required && !_rules.length && !validPromise.length) return;
103
117
  if (finalValue) {
104
118
  if (typeof finalValue === 'string') {
105
119
  if (finalValue.trim) {
@@ -110,7 +124,6 @@ export default Behavior({
110
124
  }
111
125
  }
112
126
 
113
- const validPromise = [];
114
127
  if (required) {
115
128
  if (!validType.required(finalValue)) {
116
129
  validPromise.push(Promise.resolve({ format: 'required', message: requiredMsg }));
@@ -171,10 +184,12 @@ export default Behavior({
171
184
  }
172
185
  }
173
186
  }
174
- const errorArr = await Promise.all(validPromise).then((arr) => {
175
- return arr.filter((item) => item !== void 0);
187
+ const errorArr = await Promise.all(validPromise?.flat()).then((arr) => {
188
+ return arr
189
+ ?.filter((item) => item !== void 0)
190
+ ?.filter((i) => (Array.isArray(i) ? i.length > 0 : i))
191
+ ?.map((i) => ({ ...i, label }));
176
192
  });
177
-
178
193
  if (errorArr.length > 0) {
179
194
  that.setData({
180
195
  validateState: 'error',
@@ -76,7 +76,7 @@ Component({
76
76
  * 控制弹窗打开/关闭
77
77
  * @param {Boolean} isOpen
78
78
  */
79
- dealShow(isOpen, params) {
79
+ dealShow(isOpen, params, isTrigger = true) {
80
80
  let setImmediately = {
81
81
  maskPreToShow: true,
82
82
  isMaskShow: !isOpen,
@@ -92,8 +92,9 @@ Component({
92
92
  }
93
93
 
94
94
  this.setData(setImmediately);
95
-
96
- this.triggerEvent(isOpen ? 'open' : 'close', params);
95
+ if (isTrigger) {
96
+ this.triggerEvent(isOpen ? 'open' : 'close', params);
97
+ }
97
98
  },
98
99
  /**
99
100
  * 关闭弹窗
@@ -125,11 +126,9 @@ Component({
125
126
  position,
126
127
  isMaskShow,
127
128
  defaultMaskShow,
128
- isBdShow
129
+ isBdShow,
129
130
  ) {
130
- const defaultWidth = { center: 'calc(100% - 4.57rem)', bottom: '100%' }[
131
- position
132
- ];
131
+ const defaultWidth = { center: 'calc(100% - 4.57rem)', bottom: '100%' }[position];
133
132
  const styleShow = `width: ${defaultWidth};` + style;
134
133
  const styleMain = style?.match(/(display:).*?(;)/g)?.join('');
135
134
 
@@ -153,8 +152,7 @@ Component({
153
152
  'weda-modal-new': true,
154
153
  [`${WD_PREFIX}-modal-bd`]: true,
155
154
  [`${WD_PREFIX}-modal-bd__toggle`]: isBdShow,
156
- [`${WD_PREFIX}-modal-bd__box`]:
157
- !defaultMaskShow && position === 'center',
155
+ [`${WD_PREFIX}-modal-bd__box`]: !defaultMaskShow && position === 'center',
158
156
  });
159
157
 
160
158
  this.setData({
@@ -166,16 +164,14 @@ Component({
166
164
  });
167
165
  },
168
166
  defaultShow: function (defaultShow) {
169
- this.dealShow(defaultShow);
167
+ this.dealShow(defaultShow, {}, false);
170
168
  },
171
169
  'isBdShow,openInfo,closeInfo': function () {
172
170
  this.updateWidgetAPI();
173
171
  },
174
172
  template: function (template) {
175
173
  const modalFtClasses = classNames({
176
- [`${WD_PREFIX}-modal-bd__ft-text-btn`]: ['confirm', 'notice'].includes(
177
- template
178
- ),
174
+ [`${WD_PREFIX}-modal-bd__ft-text-btn`]: ['confirm', 'notice'].includes(template),
179
175
  [`${WD_PREFIX}-modal-bd__ft-text-btn--vertical`]: template === 'notice',
180
176
  });
181
177
  this.setData({ modalFtClasses });
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "miniprogram": "./",
4
4
  "packageManager": "yarn@3.0.2",
5
5
  "dependencies": {},
6
- "version": "3.18.4",
6
+ "version": "3.18.6",
7
7
  "main": "./",
8
8
  "publishConfig": {
9
9
  "access": "public"