iov-design 2.15.56 → 2.15.58

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/lib/cascader.js CHANGED
@@ -316,32 +316,169 @@ var render = function() {
316
316
  ],
317
317
  2
318
318
  ),
319
- _vm.multiple
319
+ _vm.multiple && _vm.collapseTags && _vm.checkedNodes.length
320
320
  ? _c(
321
- "div",
322
- { staticClass: "el-cascader__tags" },
321
+ "transition-group",
322
+ {
323
+ staticClass: "el-cascader__tags",
324
+ on: { "after-leave": _vm.updateStyle }
325
+ },
323
326
  [
324
- _vm._l(_vm.presentTags, function(tag) {
325
- return _c(
326
- "el-tag",
327
- {
328
- key: tag.key,
329
- class: { "is-disabled": !tag.closable && tag.key !== -1 },
327
+ _vm._l(_vm.presentTags, function(tag, index) {
328
+ return [
329
+ _vm.collapseTags && index <= _vm.multipleLimitShow - 1
330
+ ? _c(
331
+ "el-tag",
332
+ {
333
+ key: tag.key,
334
+ class: {
335
+ "is-disabled": !tag.closable && tag.key !== -1
336
+ },
337
+ attrs: {
338
+ type: "info",
339
+ size: _vm.tagSize,
340
+ hit: tag.hitState,
341
+ maxWidth: _vm.maxWidth,
342
+ closable: tag.closable,
343
+ "disable-transitions": ""
344
+ },
345
+ on: {
346
+ close: function($event) {
347
+ _vm.deleteTag(tag)
348
+ }
349
+ }
350
+ },
351
+ [_c("span", [_vm._v(_vm._s(tag.text))])]
352
+ )
353
+ : _vm._e()
354
+ ]
355
+ }),
356
+ _vm.collapseTags &&
357
+ ((_vm.checkedNodes.length > 1 &&
358
+ _vm.checkedNodes.length > _vm.multipleLimitShow) ||
359
+ (_vm.checkedNodes.length > 0 && _vm.collapseTagsFixed))
360
+ ? _c(
361
+ "el-tag",
362
+ {
363
+ key: "count",
364
+ ref: "tagsCount",
365
+ staticClass: "el-cascader__tags-count",
366
+ class: {
367
+ "el-cascader__tags-count-fixed": _vm.collapseTagsFixed
368
+ },
369
+ attrs: {
370
+ closable: false,
371
+ size: _vm.tagSize,
372
+ type: "info",
373
+ "disable-transitions": ""
374
+ }
375
+ },
376
+ [
377
+ _c("span", { staticClass: "el-cascader__tags-text" }, [
378
+ _vm._v(
379
+ _vm._s(_vm.collapseTagsFixed ? "" : "+") +
380
+ _vm._s(
381
+ _vm.collapseTagsFixed
382
+ ? _vm.checkedNodes.length
383
+ : _vm.checkedNodes.length -
384
+ _vm.multipleLimitShow
385
+ ) +
386
+ _vm._s(_vm.collapseTagsSuffix)
387
+ )
388
+ ])
389
+ ]
390
+ )
391
+ : _vm._e(),
392
+ _vm.filterable && !_vm.isDisabled
393
+ ? _c("input", {
394
+ directives: [
395
+ {
396
+ name: "model",
397
+ rawName: "v-model.trim",
398
+ value: _vm.inputValue,
399
+ expression: "inputValue",
400
+ modifiers: { trim: true }
401
+ }
402
+ ],
403
+ staticClass: "el-cascader__search-input",
330
404
  attrs: {
331
- type: "info",
332
- size: _vm.tagSize,
333
- hit: tag.hitState,
334
- closable: tag.closable,
335
- "disable-transitions": ""
405
+ type: "text",
406
+ placeholder: _vm.presentTags.length ? "" : _vm.placeholder
336
407
  },
408
+ domProps: { value: _vm.inputValue },
337
409
  on: {
338
- close: function($event) {
339
- _vm.deleteTag(tag)
410
+ input: [
411
+ function($event) {
412
+ if ($event.target.composing) {
413
+ return
414
+ }
415
+ _vm.inputValue = $event.target.value.trim()
416
+ },
417
+ function(e) {
418
+ return _vm.handleInput(_vm.inputValue, e)
419
+ }
420
+ ],
421
+ click: function($event) {
422
+ $event.stopPropagation()
423
+ _vm.toggleDropDownVisible(true)
424
+ },
425
+ keydown: function($event) {
426
+ if (
427
+ !("button" in $event) &&
428
+ _vm._k(
429
+ $event.keyCode,
430
+ "delete",
431
+ [8, 46],
432
+ $event.key,
433
+ ["Backspace", "Delete", "Del"]
434
+ )
435
+ ) {
436
+ return null
437
+ }
438
+ return _vm.handleDelete($event)
439
+ },
440
+ blur: function($event) {
441
+ _vm.$forceUpdate()
340
442
  }
341
443
  }
342
- },
343
- [_c("span", [_vm._v(_vm._s(tag.text))])]
344
- )
444
+ })
445
+ : _vm._e()
446
+ ],
447
+ 2
448
+ )
449
+ : _vm._e(),
450
+ !_vm.collapseTags
451
+ ? _c(
452
+ "transition-group",
453
+ {
454
+ staticClass: "el-cascader__tags",
455
+ on: { "after-leave": _vm.updateStyle }
456
+ },
457
+ [
458
+ _vm._l(_vm.presentTags, function(tag) {
459
+ return [
460
+ _c(
461
+ "el-tag",
462
+ {
463
+ key: tag.key,
464
+ class: { "is-disabled": !tag.closable && tag.key !== -1 },
465
+ attrs: {
466
+ type: "info",
467
+ size: _vm.tagSize,
468
+ hit: tag.hitState,
469
+ maxWidth: _vm.maxWidth,
470
+ closable: tag.closable,
471
+ "disable-transitions": ""
472
+ },
473
+ on: {
474
+ close: function($event) {
475
+ _vm.deleteTag(tag)
476
+ }
477
+ }
478
+ },
479
+ [_c("span", [_vm._v(_vm._s(tag.text))])]
480
+ )
481
+ ]
345
482
  }),
346
483
  _vm.filterable && !_vm.isDisabled
347
484
  ? _c("input", {
@@ -704,6 +841,47 @@ var debounce_default = /*#__PURE__*/__webpack_require__.n(debounce_);
704
841
  //
705
842
  //
706
843
  //
844
+ //
845
+ //
846
+ //
847
+ //
848
+ //
849
+ //
850
+ //
851
+ //
852
+ //
853
+ //
854
+ //
855
+ //
856
+ //
857
+ //
858
+ //
859
+ //
860
+ //
861
+ //
862
+ //
863
+ //
864
+ //
865
+ //
866
+ //
867
+ //
868
+ //
869
+ //
870
+ //
871
+ //
872
+ //
873
+ //
874
+ //
875
+ //
876
+ //
877
+ //
878
+ //
879
+ //
880
+ //
881
+ //
882
+ //
883
+ //
884
+ //
707
885
 
708
886
 
709
887
 
@@ -814,6 +992,22 @@ var InputSizeMap = {
814
992
  default: true
815
993
  },
816
994
  collapseTags: Boolean,
995
+ multipleLimitShow: {
996
+ type: Number,
997
+ default: 1
998
+ },
999
+ multipleTagMaxWidth: {
1000
+ type: String,
1001
+ default: 'none'
1002
+ },
1003
+ collapseTagsSuffix: {
1004
+ type: String,
1005
+ default: ''
1006
+ },
1007
+ collapseTagsFixed: {
1008
+ type: Boolean,
1009
+ default: false
1010
+ },
817
1011
  debounce: {
818
1012
  type: Number,
819
1013
  default: 300
@@ -839,7 +1033,10 @@ var InputSizeMap = {
839
1033
  filtering: false,
840
1034
  suggestions: [],
841
1035
  inputInitialHeight: 0,
842
- pressDeleteCount: 0
1036
+ pressDeleteCount: 0,
1037
+ inputWidth: 0,
1038
+ tagsLeft: 0,
1039
+ maxWidth: 'none'
843
1040
  };
844
1041
  },
845
1042
 
@@ -959,6 +1156,8 @@ var InputSizeMap = {
959
1156
 
960
1157
  if (input && input.$el) {
961
1158
  this.inputInitialHeight = Math.max(input.$el.offsetHeight, InputSizeMap[this.realSize]) || 36;
1159
+ this.resetInputWidth();
1160
+ this.resetTagsLeft();
962
1161
  }
963
1162
 
964
1163
  if (!this.isEmptyValue(this.value)) {
@@ -992,6 +1191,37 @@ var InputSizeMap = {
992
1191
 
993
1192
 
994
1193
  methods: {
1194
+ resetInputWidth: function resetInputWidth() {
1195
+ this.inputWidth = this.$refs.input.$el.getBoundingClientRect().width;
1196
+ },
1197
+ resetTagsLeft: function resetTagsLeft() {
1198
+ var _this2 = this;
1199
+
1200
+ this.$nextTick(function () {
1201
+ var prefixLabel = _this2.$el.querySelector('.el-input-group__prefix-label');
1202
+ var prefix = _this2.$el.querySelector('.el-input__prefix');
1203
+ var inputInner = _this2.$el.querySelector('.el-input__inner');
1204
+ var prefixLabelWidth = prefixLabel && Math.round(prefixLabel.getBoundingClientRect().width) || 0;
1205
+ var inputPaddingLeft = prefixLabel || prefix ? Math.round(window.getComputedStyle(inputInner).paddingLeft.replace(/px/, '')) : 0;
1206
+ _this2.tagsLeft = prefixLabelWidth + inputPaddingLeft;
1207
+ });
1208
+ },
1209
+ getMaxWidth: function getMaxWidth() {
1210
+ var _this3 = this;
1211
+
1212
+ this.$nextTick(function () {
1213
+ if (_this3.collapseTags) {
1214
+ if (_this3.multipleTagMaxWidth && _this3.multipleTagMaxWidth !== 'none') {
1215
+ _this3.maxWidth = _this3.multipleTagMaxWidth;
1216
+ }
1217
+ var tagsCountWidth = _this3.$refs.tagsCount && _this3.$refs.tagsCount.$el.clientWidth || 0;
1218
+ var count = _this3.checkedNodes.length <= _this3.multipleLimitShow ? _this3.checkedNodes.length : _this3.multipleLimitShow;
1219
+ _this3.maxWidth = Math.floor((_this3.inputWidth - _this3.tagsLeft - 32 - tagsCountWidth - 20 - count * 16) / count) + 'px';
1220
+ } else {
1221
+ _this3.maxWidth = _this3.multipleTagMaxWidth || 'none';
1222
+ }
1223
+ });
1224
+ },
995
1225
  getMigratingConfig: function getMigratingConfig() {
996
1226
  return {
997
1227
  props: {
@@ -1005,7 +1235,7 @@ var InputSizeMap = {
1005
1235
  };
1006
1236
  },
1007
1237
  toggleDropDownVisible: function toggleDropDownVisible(visible) {
1008
- var _this2 = this;
1238
+ var _this4 = this;
1009
1239
 
1010
1240
  if (this.isDisabled) return;
1011
1241
 
@@ -1017,8 +1247,8 @@ var InputSizeMap = {
1017
1247
  this.dropDownVisible = visible;
1018
1248
  if (visible) {
1019
1249
  this.$nextTick(function () {
1020
- _this2.updatePopper();
1021
- _this2.panel.scrollIntoView();
1250
+ _this4.updatePopper();
1251
+ _this4.panel.scrollIntoView();
1022
1252
  });
1023
1253
  }
1024
1254
  input.$refs.input.setAttribute('aria-expanded', visible);
@@ -1072,11 +1302,11 @@ var InputSizeMap = {
1072
1302
  this.$emit('active-item-change', value); // Deprecated
1073
1303
  },
1074
1304
  focusFirstNode: function focusFirstNode() {
1075
- var _this3 = this;
1305
+ var _this5 = this;
1076
1306
 
1077
1307
  this.$nextTick(function () {
1078
- var filtering = _this3.filtering;
1079
- var _$refs = _this3.$refs,
1308
+ var filtering = _this5.filtering;
1309
+ var _$refs = _this5.$refs,
1080
1310
  popper = _$refs.popper,
1081
1311
  suggestionPanel = _$refs.suggestionPanel;
1082
1312
 
@@ -1096,15 +1326,15 @@ var InputSizeMap = {
1096
1326
  });
1097
1327
  },
1098
1328
  computePresentContent: function computePresentContent() {
1099
- var _this4 = this;
1329
+ var _this6 = this;
1100
1330
 
1101
1331
  // nextTick is required, because checked nodes may not change right now
1102
1332
  this.$nextTick(function () {
1103
- if (_this4.config.multiple) {
1104
- _this4.computePresentTags();
1105
- _this4.presentText = _this4.presentTags.length ? ' ' : null;
1333
+ if (_this6.config.multiple) {
1334
+ _this6.computePresentTags();
1335
+ _this6.presentText = _this6.presentTags.length ? ' ' : null;
1106
1336
  } else {
1107
- _this4.computePresentText();
1337
+ _this6.computePresentText();
1108
1338
  }
1109
1339
  });
1110
1340
  },
@@ -1134,8 +1364,7 @@ var InputSizeMap = {
1134
1364
  var isDisabled = this.isDisabled,
1135
1365
  leafOnly = this.leafOnly,
1136
1366
  showAllLevels = this.showAllLevels,
1137
- separator = this.separator,
1138
- collapseTags = this.collapseTags;
1367
+ separator = this.separator;
1139
1368
 
1140
1369
  var checkedNodes = this.getCheckedNodes(leafOnly);
1141
1370
  var tags = [];
@@ -1151,32 +1380,34 @@ var InputSizeMap = {
1151
1380
  };
1152
1381
 
1153
1382
  if (checkedNodes.length) {
1154
- var first = checkedNodes[0],
1155
- rest = checkedNodes.slice(1);
1156
-
1157
- var restCount = rest.length;
1158
- tags.push(genTag(first));
1159
-
1160
- if (restCount) {
1161
- if (collapseTags) {
1162
- tags.push({
1163
- key: -1,
1164
- text: '+' + restCount,
1165
- closable: false
1166
- });
1167
- } else {
1168
- rest.forEach(function (node) {
1169
- return tags.push(genTag(node));
1170
- });
1171
- }
1172
- }
1383
+ checkedNodes.forEach(function (node) {
1384
+ return tags.push(genTag(node));
1385
+ });
1386
+ // const [first, ...rest] = checkedNodes;
1387
+ // const restCount = rest.length;
1388
+ // tags.push(genTag(first));
1389
+
1390
+ // console.log(restCount, 'restCount============');
1391
+ // this.restCount = restCount;
1392
+ // if (restCount) {
1393
+ // if (collapseTags) {
1394
+ // tags.push({
1395
+ // key: -1,
1396
+ // text: `+${restCount}`,
1397
+ // closable: false
1398
+ // });
1399
+ // } else {
1400
+ // rest.forEach(node => tags.push(genTag(node)));
1401
+ // }
1402
+ // }
1173
1403
  }
1174
1404
 
1175
1405
  this.checkedNodes = checkedNodes;
1176
1406
  this.presentTags = tags;
1407
+ this.getMaxWidth();
1177
1408
  },
1178
1409
  getSuggestions: function getSuggestions() {
1179
- var _this5 = this;
1410
+ var _this7 = this;
1180
1411
 
1181
1412
  var filterMethod = this.filterMethod;
1182
1413
 
@@ -1189,8 +1420,8 @@ var InputSizeMap = {
1189
1420
 
1190
1421
  var suggestions = this.panel.getFlattedNodes(this.leafOnly).filter(function (node) {
1191
1422
  if (node.isDisabled) return false;
1192
- node.text = node.getText(_this5.showAllLevels, _this5.separator) || '';
1193
- return filterMethod(node, _this5.inputValue);
1423
+ node.text = node.getText(_this7.showAllLevels, _this7.separator) || '';
1424
+ return filterMethod(node, _this7.inputValue);
1194
1425
  });
1195
1426
 
1196
1427
  if (this.multiple) {
@@ -1199,7 +1430,7 @@ var InputSizeMap = {
1199
1430
  });
1200
1431
  } else {
1201
1432
  suggestions.forEach(function (node) {
1202
- node.checked = Object(util_["isEqual"])(_this5.checkedValue, node.getValueByOption());
1433
+ node.checked = Object(util_["isEqual"])(_this7.checkedValue, node.getValueByOption());
1203
1434
  });
1204
1435
  }
1205
1436
 
@@ -1307,7 +1538,10 @@ var InputSizeMap = {
1307
1538
  } else {
1308
1539
  inputInner.style.height = height;
1309
1540
  }
1310
- tags.style.left = prefixLabelWidth + inputPaddingLeft + 'px';
1541
+ tags.style.left = prefixLabel ? prefixLabelWidth + inputPaddingLeft - 4 + 'px' : '0px';
1542
+ if (this.checkedNodes.length === 0 && !prefixLabel) {
1543
+ tags.style.left = '12px';
1544
+ }
1311
1545
  if (this.dropDownVisible) {
1312
1546
  this.updatePopper();
1313
1547
  }