@deppon/deppon-template 2.4.1 → 2.4.2

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.
@@ -13,25 +13,21 @@ var _hoisted_1 = {
13
13
  "class": "field-tag-input-readonly"
14
14
  };
15
15
  var _hoisted_2 = {
16
- key: 1,
17
- "class": "field-tag-input"
18
- };
19
- var _hoisted_3 = {
20
16
  "class": "tag-input-input-wrap"
21
17
  };
22
- var _hoisted_4 = {
18
+ var _hoisted_3 = {
23
19
  key: 0,
24
20
  "class": "tag-input-tip-wrap"
25
21
  };
26
- var _hoisted_5 = {
22
+ var _hoisted_4 = {
27
23
  key: 0,
28
24
  "class": "tag-input-add-error"
29
25
  };
30
- var _hoisted_6 = {
26
+ var _hoisted_5 = {
31
27
  key: 1,
32
28
  "class": "tag-input-list-row"
33
29
  };
34
- var _hoisted_7 = {
30
+ var _hoisted_6 = {
35
31
  key: 0,
36
32
  "class": "tag-input-list-label"
37
33
  };
@@ -63,12 +59,14 @@ var script = {
63
59
  var __emit = _ref.emit;
64
60
  var props = __props;
65
61
  var emit = __emit;
62
+ var rootRef = ref(null);
66
63
  var inputRef = ref(null);
67
64
  var inputValue = ref('');
68
65
  var addLoading = ref(false);
69
66
  var removingIndex = ref(-1);
70
67
  /** 添加时校验失败的错误信息,在输入框下方展示 */
71
68
  var addError = ref('');
69
+ var inFormItem = ref(false);
72
70
  var readonlyRef = ref(null);
73
71
  var readonlyOverflow = ref(false);
74
72
  var tipRef = ref(null);
@@ -103,6 +101,10 @@ var script = {
103
101
  });
104
102
  onMounted(function () {
105
103
  nextTick(runOverflowChecks);
104
+ var rootEl = rootRef.value;
105
+ if (rootEl && typeof rootEl.closest === 'function') {
106
+ inFormItem.value = !!rootEl.closest('.el-form-item');
107
+ }
106
108
  window.addEventListener('resize', runOverflowChecks);
107
109
  });
108
110
  onUnmounted(function () {
@@ -156,6 +158,11 @@ var script = {
156
158
  var _props$fieldProps0;
157
159
  return ((_props$fieldProps0 = props.fieldProps) === null || _props$fieldProps0 === void 0 ? void 0 : _props$fieldProps0.disabled) === true;
158
160
  });
161
+ /** 在 el-form-item 内时,空输入提示优先复用外层错误区,避免双重提示 */
162
+ var useFormItemRequiredError = computed(function () {
163
+ var _props$fieldProps1;
164
+ return ((_props$fieldProps1 = props.fieldProps) === null || _props$fieldProps1 === void 0 ? void 0 : _props$fieldProps1.useFormItemRequiredError) !== false;
165
+ });
159
166
  var tagList = computed(function () {
160
167
  var val = props.text;
161
168
  if (Array.isArray(val)) return val;
@@ -171,9 +178,8 @@ var script = {
171
178
  var trimmed = (value || '').trim();
172
179
  var rules = addRules.value;
173
180
  if (!rules.length) {
174
- // 未显式配置添加校验规则时,空输入仅拦截,不展示内部错误,
175
- // 避免与外层 el-form-item 的必填提示重复显示。
176
- if (!trimmed) return '';
181
+ // 未配置规则时,至少保证空输入有基础提示。
182
+ if (!trimmed) return '请输入';
177
183
  return '';
178
184
  }
179
185
  var _iterator = _createForOfIteratorHelper(rules),
@@ -214,7 +220,7 @@ var script = {
214
220
  }
215
221
  function _addItem() {
216
222
  _addItem = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
217
- var _inputValue$value, _props$fieldProps1;
223
+ var _inputValue$value, _props$fieldProps10;
218
224
  var raw, name, list, err, onAdd, result, nextList;
219
225
  return _regeneratorRuntime.wrap(function (_context) {
220
226
  while (1) switch (_context.prev = _context.next) {
@@ -230,40 +236,46 @@ var script = {
230
236
  name = raw.trim();
231
237
  list = _toConsumableArray(tagList.value);
232
238
  if (name) {
233
- _context.next = 2;
239
+ _context.next = 3;
234
240
  break;
235
241
  }
236
- // 空值不允许加入;未配置 addRules 时静默拦截,避免与外层必填提示重复。
237
- if (addRules.value.length) {
238
- addError.value = validateAddInput(raw, list);
242
+ if (!(useFormItemRequiredError.value && inFormItem.value)) {
243
+ _context.next = 2;
244
+ break;
239
245
  }
246
+ // 主动触发一次 update:text,让外层 ProForm 执行 validateField 并展示 el-form-item 错误。
247
+ emit('update:text', list);
240
248
  return _context.abrupt("return");
241
249
  case 2:
250
+ // 非表单场景保留组件内提示。
251
+ addError.value = validateAddInput(raw, list);
252
+ return _context.abrupt("return");
253
+ case 3:
242
254
  err = validateAddInput(raw, list);
243
255
  if (!err) {
244
- _context.next = 3;
256
+ _context.next = 4;
245
257
  break;
246
258
  }
247
259
  addError.value = err;
248
260
  return _context.abrupt("return");
249
- case 3:
261
+ case 4:
250
262
  if (!(list.length >= maxCount.value)) {
251
- _context.next = 4;
263
+ _context.next = 5;
252
264
  break;
253
265
  }
254
266
  addError.value = "\u6700\u591A\u6DFB\u52A0".concat(maxCount.value, "\u4E2A");
255
267
  return _context.abrupt("return");
256
- case 4:
257
- onAdd = (_props$fieldProps1 = props.fieldProps) === null || _props$fieldProps1 === void 0 ? void 0 : _props$fieldProps1.onAdd;
268
+ case 5:
269
+ onAdd = (_props$fieldProps10 = props.fieldProps) === null || _props$fieldProps10 === void 0 ? void 0 : _props$fieldProps10.onAdd;
258
270
  if (!(typeof onAdd === 'function')) {
259
- _context.next = 10;
271
+ _context.next = 11;
260
272
  break;
261
273
  }
262
274
  addLoading.value = true;
263
- _context.prev = 5;
264
- _context.next = 6;
275
+ _context.prev = 6;
276
+ _context.next = 7;
265
277
  return Promise.resolve(onAdd(name, list));
266
- case 6:
278
+ case 7:
267
279
  result = _context.sent;
268
280
  if (Array.isArray(result)) {
269
281
  emit('update:text', result);
@@ -283,18 +295,18 @@ var script = {
283
295
  return (_inputRef$value2 = inputRef.value) === null || _inputRef$value2 === void 0 || (_inputRef$value2$focu = _inputRef$value2.focus) === null || _inputRef$value2$focu === void 0 ? void 0 : _inputRef$value2$focu.call(_inputRef$value2);
284
296
  });
285
297
  }
286
- _context.next = 8;
298
+ _context.next = 9;
287
299
  break;
288
- case 7:
289
- _context.prev = 7;
290
- _context["catch"](5);
291
300
  case 8:
292
301
  _context.prev = 8;
293
- addLoading.value = false;
294
- return _context.finish(8);
302
+ _context["catch"](6);
295
303
  case 9:
296
- return _context.abrupt("return");
304
+ _context.prev = 9;
305
+ addLoading.value = false;
306
+ return _context.finish(9);
297
307
  case 10:
308
+ return _context.abrupt("return");
309
+ case 11:
298
310
  list.push(name);
299
311
  emit('update:text', list);
300
312
  inputValue.value = '';
@@ -303,11 +315,11 @@ var script = {
303
315
  var _inputRef$value3, _inputRef$value3$focu;
304
316
  return (_inputRef$value3 = inputRef.value) === null || _inputRef$value3 === void 0 || (_inputRef$value3$focu = _inputRef$value3.focus) === null || _inputRef$value3$focu === void 0 ? void 0 : _inputRef$value3$focu.call(_inputRef$value3);
305
317
  });
306
- case 11:
318
+ case 12:
307
319
  case "end":
308
320
  return _context.stop();
309
321
  }
310
- }, _callee, null, [[5, 7, 8, 9]]);
322
+ }, _callee, null, [[6, 8, 9, 10]]);
311
323
  }));
312
324
  return _addItem.apply(this, arguments);
313
325
  }
@@ -316,7 +328,7 @@ var script = {
316
328
  }
317
329
  function _removeItem() {
318
330
  _removeItem = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(index) {
319
- var _props$fieldProps10;
331
+ var _props$fieldProps11;
320
332
  var list, name, onRemove, result, nextList;
321
333
  return _regeneratorRuntime.wrap(function (_context2) {
322
334
  while (1) switch (_context2.prev = _context2.next) {
@@ -335,7 +347,7 @@ var script = {
335
347
  }
336
348
  return _context2.abrupt("return");
337
349
  case 2:
338
- onRemove = (_props$fieldProps10 = props.fieldProps) === null || _props$fieldProps10 === void 0 ? void 0 : _props$fieldProps10.onRemove;
350
+ onRemove = (_props$fieldProps11 = props.fieldProps) === null || _props$fieldProps11 === void 0 ? void 0 : _props$fieldProps11.onRemove;
339
351
  if (!(typeof onRemove === 'function')) {
340
352
  _context2.next = 8;
341
353
  break;
@@ -390,11 +402,16 @@ var script = {
390
402
  }, toDisplayString(displayText.value), 513 /* TEXT, NEED_PATCH */)];
391
403
  }),
392
404
  _: 1 /* STABLE */
393
- }, 8 /* PROPS */, ["content", "disabled"])])) : __props.mode === 'edit' || __props.mode === 'update' ? (openBlock(), createElementBlock("div", _hoisted_2, [createCommentVNode(" 输入 + 添加 区域 "), createElementVNode("div", {
405
+ }, 8 /* PROPS */, ["content", "disabled"])])) : __props.mode === 'edit' || __props.mode === 'update' ? (openBlock(), createElementBlock("div", {
406
+ key: 1,
407
+ ref_key: "rootRef",
408
+ ref: rootRef,
409
+ "class": "field-tag-input"
410
+ }, [createCommentVNode(" 输入 + 添加 区域 "), createElementVNode("div", {
394
411
  "class": normalizeClass(["tag-input-input-row", {
395
412
  'has-error': addError.value
396
413
  }])
397
- }, [createElementVNode("div", _hoisted_3, [createVNode(unref(ElInput), {
414
+ }, [createElementVNode("div", _hoisted_2, [createVNode(unref(ElInput), {
398
415
  ref_key: "inputRef",
399
416
  ref: inputRef,
400
417
  modelValue: inputValue.value,
@@ -435,7 +452,7 @@ var script = {
435
452
  }, 8 /* PROPS */, ["loading", "disabled"]))];
436
453
  }),
437
454
  _: 3 /* FORWARDED */
438
- }, 8 /* PROPS */, ["modelValue", "placeholder", "disabled"])]), tip.value ? (openBlock(), createElementBlock("div", _hoisted_4, [createVNode(unref(ElTooltip), {
455
+ }, 8 /* PROPS */, ["modelValue", "placeholder", "disabled"])]), tip.value ? (openBlock(), createElementBlock("div", _hoisted_3, [createVNode(unref(ElTooltip), {
439
456
  content: tip.value,
440
457
  placement: "top",
441
458
  disabled: !tipOverflow.value
@@ -448,7 +465,7 @@ var script = {
448
465
  }, toDisplayString(tip.value), 513 /* TEXT, NEED_PATCH */)];
449
466
  }),
450
467
  _: 1 /* STABLE */
451
- }, 8 /* PROPS */, ["content", "disabled"])])) : createCommentVNode("v-if", true)], 2 /* CLASS */), addError.value ? (openBlock(), createElementBlock("div", _hoisted_5, toDisplayString(addError.value), 1 /* TEXT */)) : createCommentVNode("v-if", true), createCommentVNode(" 标签列表:有数据时才显示 "), tagList.value.length > 0 ? (openBlock(), createElementBlock("div", _hoisted_6, [listLabel.value ? (openBlock(), createElementBlock("div", _hoisted_7, toDisplayString(listLabel.value) + "(" + toDisplayString(tagList.value.length) + "/" + toDisplayString(maxCount.value) + ") ", 1 /* TEXT */)) : createCommentVNode("v-if", true), createElementVNode("div", {
468
+ }, 8 /* PROPS */, ["content", "disabled"])])) : createCommentVNode("v-if", true)], 2 /* CLASS */), addError.value ? (openBlock(), createElementBlock("div", _hoisted_4, toDisplayString(addError.value), 1 /* TEXT */)) : createCommentVNode("v-if", true), createCommentVNode(" 标签列表:有数据时才显示 "), tagList.value.length > 0 ? (openBlock(), createElementBlock("div", _hoisted_5, [listLabel.value ? (openBlock(), createElementBlock("div", _hoisted_6, toDisplayString(listLabel.value) + "(" + toDisplayString(tagList.value.length) + "/" + toDisplayString(maxCount.value) + ") ", 1 /* TEXT */)) : createCommentVNode("v-if", true), createElementVNode("div", {
452
469
  "class": normalizeClass(["tag-input-list-content", {
453
470
  'is-removing': removingIndex.value >= 0
454
471
  }])
@@ -477,7 +494,7 @@ var script = {
477
494
  }), 128 /* KEYED_FRAGMENT */))];
478
495
  }),
479
496
  _: 1 /* STABLE */
480
- })], 2 /* CLASS */)])) : createCommentVNode("v-if", true)])) : createCommentVNode("v-if", true);
497
+ })], 2 /* CLASS */)])) : createCommentVNode("v-if", true)], 512 /* NEED_PATCH */)) : createCommentVNode("v-if", true);
481
498
  };
482
499
  }
483
500
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@deppon/deppon-template",
3
- "version": "2.4.1",
3
+ "version": "2.4.2",
4
4
  "main": "es/index.js",
5
5
  "module": "es/index.js",
6
6
  "typings": "es/index.d.ts",
@@ -43,11 +43,11 @@
43
43
  "less": "^4.2.0"
44
44
  },
45
45
  "dependencies": {
46
- "@deppon/deppon-assets": "2.4.1",
47
- "@deppon/deppon-request": "2.4.1",
48
- "@deppon/deppon-router": "2.4.1",
49
- "@deppon/deppon-ui": "2.4.1",
50
- "@deppon/deppon-utils": "2.4.1",
46
+ "@deppon/deppon-assets": "2.4.2",
47
+ "@deppon/deppon-request": "2.4.2",
48
+ "@deppon/deppon-router": "2.4.2",
49
+ "@deppon/deppon-ui": "2.4.2",
50
+ "@deppon/deppon-utils": "2.4.2",
51
51
  "dayjs": "^1.11.10",
52
52
  "lodash-es": "^4.17.21",
53
53
  "mitt": "^3.0.1"