bk-magic-vue 2.4.9 → 2.4.10-beta.1

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.
@@ -8990,6 +8990,15 @@ span.bk-date-picker-cells-cell-disabled.bk-date-picker-cells-cell-selected em{
8990
8990
  width:100%;
8991
8991
  z-index:777;
8992
8992
  }
8993
+ .bk-select-tag-input{
8994
+ height:22px;
8995
+ max-width:190px;
8996
+ padding:0;
8997
+ margin:4px 5px 4px 0;
8998
+ overflow:hidden;
8999
+ border:none;
9000
+ outline:none;
9001
+ }
8993
9002
  .bk-sideslider-show{
8994
9003
  overflow-y:hidden !important;
8995
9004
  }
@@ -31809,7 +31809,8 @@
31809
31809
  data: function data() {
31810
31810
  return {
31811
31811
  overflowTagNode: null,
31812
- overflowTagIndex: null
31812
+ overflowTagIndex: null,
31813
+ newOptionName: ''
31813
31814
  };
31814
31815
  },
31815
31816
  mounted: function mounted() {
@@ -31817,12 +31818,22 @@
31817
31818
  this.calcOverflow();
31818
31819
  this.$watch(function () {
31819
31820
  return _this.select.focus;
31820
- }, this.calcOverflow);
31821
+ }, function (isFocus) {
31822
+ _this.calcOverflow();
31823
+ if (isFocus) {
31824
+ _this.focusInput();
31825
+ } else {
31826
+ _this.newOptionName = '';
31827
+ }
31828
+ });
31821
31829
  this.$watch(function () {
31822
31830
  return _this.select.selected;
31823
31831
  }, this.calcOverflow);
31824
31832
  },
31825
31833
  methods: {
31834
+ focusInput: function focusInput() {
31835
+ this.$refs.inputRef && this.$refs.inputRef.focus();
31836
+ },
31826
31837
  handleRemoveSelected: function handleRemoveSelected(event, option) {
31827
31838
  if (this.select.disabled || this.select.readonly) {
31828
31839
  return false;
@@ -31898,6 +31909,10 @@
31898
31909
  if (this.overflowTagNode && this.overflowTagNode.parentNode === this.$el) {
31899
31910
  this.$el.removeChild(this.overflowTagNode);
31900
31911
  }
31912
+ },
31913
+ handleCreateTag: function handleCreateTag(e) {
31914
+ this.$emit('create-tag', e.target.value);
31915
+ this.newOptionName = '';
31901
31916
  }
31902
31917
  }
31903
31918
  };
@@ -31925,7 +31940,7 @@
31925
31940
  'is-small-size': _vm.select.size === 'small',
31926
31941
  'has-prefix-icon': !!_vm.select.prefixIcon
31927
31942
  }
31928
- }, _vm._l(_vm.select.selectedOptions, function (option) {
31943
+ }, [_vm._l(_vm.select.selectedOptions, function (option) {
31929
31944
  return _c('div', {
31930
31945
  key: option.id,
31931
31946
  staticClass: "bk-select-tag",
@@ -31940,7 +31955,36 @@
31940
31955
  }
31941
31956
  }
31942
31957
  })]);
31943
- }), 0);
31958
+ }), _vm.select.allowCreate ? _c('input', {
31959
+ directives: [{
31960
+ name: "model",
31961
+ rawName: "v-model",
31962
+ value: _vm.newOptionName,
31963
+ expression: "newOptionName"
31964
+ }],
31965
+ ref: "inputRef",
31966
+ staticClass: "bk-select-tag-input",
31967
+ domProps: {
31968
+ "value": _vm.newOptionName
31969
+ },
31970
+ on: {
31971
+ "blur": _vm.handleCreateTag,
31972
+ "keyup": function keyup($event) {
31973
+ if (!('button' in $event) && _vm._k($event.keyCode, "enter", 13, $event.key, "Enter")) {
31974
+ return null;
31975
+ }
31976
+
31977
+ return _vm.handleCreateTag($event);
31978
+ },
31979
+ "input": function input($event) {
31980
+ if ($event.target.composing) {
31981
+ return;
31982
+ }
31983
+
31984
+ _vm.newOptionName = $event.target.value;
31985
+ }
31986
+ }
31987
+ }) : _vm._e()], 2);
31944
31988
  };
31945
31989
 
31946
31990
  var __vue_staticRenderFns__$J = [];
@@ -32676,7 +32720,8 @@
32676
32720
  bkSelectTag: __vue_component__$J,
32677
32721
  bkVirtualScroll: __vue_component__$K,
32678
32722
  virtualOption: virtualOption,
32679
- bkSpin: __vue_component__$7
32723
+ bkSpin: __vue_component__$7,
32724
+ bkOption: __vue_component__$F
32680
32725
  },
32681
32726
  directives: {
32682
32727
  bkloading: bkLoading
@@ -32836,7 +32881,8 @@
32836
32881
  autoUpdate: false,
32837
32882
  renderPopoverOptions: {},
32838
32883
  popoverDistance: 10 + _parseInt$2(variable_1),
32839
- optionList: null
32884
+ optionList: null,
32885
+ allowCreateData: []
32840
32886
  };
32841
32887
  },
32842
32888
  computed: {
@@ -32957,6 +33003,11 @@
32957
33003
  if (this.shouldUpdate || this.autoUpdate) {
32958
33004
  this.setSelectedOptions();
32959
33005
  }
33006
+ if (this.allowCreate && this.displayTag && this.multiple && isArray$1(value)) {
33007
+ this.allowCreateData = this.allowCreateData.filter(function (item) {
33008
+ return value.includes(item.id);
33009
+ });
33010
+ }
32960
33011
  this.$emit('input', value);
32961
33012
  this.$emit('change', value, oldValue);
32962
33013
  this.dispatch('bk-form-item', 'form-change');
@@ -33100,7 +33151,6 @@
33100
33151
  this.focus = false;
33101
33152
  },
33102
33153
  handleInputChange: function handleInputChange(e) {
33103
- console.log(e.target.value);
33104
33154
  var value = e.target.value;
33105
33155
  this.$emit('input', value);
33106
33156
  this.$emit('change', value, this.value);
@@ -33134,6 +33184,7 @@
33134
33184
  this.$nextTick(function () {
33135
33185
  _this7.$emit('selected', _this7.selected, _this7.selectedOptions);
33136
33186
  });
33187
+ this.focusTagInput();
33137
33188
  },
33138
33189
  unselectOption: function unselectOption(option) {
33139
33190
  var _this8 = this;
@@ -33266,6 +33317,19 @@
33266
33317
  if (optionList.scrollHeight - (optionList.clientHeight + optionList.scrollTop) < 30) {
33267
33318
  this.$emit('scroll-end', true);
33268
33319
  }
33320
+ },
33321
+ handleCreateTag: function handleCreateTag(value) {
33322
+ if (!value || this.optionsMap[value] || this.allowCreateData.find(function (item) {
33323
+ return item.id === value;
33324
+ })) return;
33325
+ this.allowCreateData.push({
33326
+ id: value,
33327
+ name: value
33328
+ });
33329
+ this.selected.push(value);
33330
+ },
33331
+ focusTagInput: function focusTagInput() {
33332
+ this.$refs.bkSelectTag && this.$refs.bkSelectTag.focusInput();
33269
33333
  }
33270
33334
  }
33271
33335
  };
@@ -33357,10 +33421,14 @@
33357
33421
  }, [_vm.prefixIcon ? _c('i', {
33358
33422
  class: ['bk-select-prefix-icon', _vm.prefixIcon]
33359
33423
  }) : _vm._e(), _vm._t("trigger", [_vm.multiple && _vm.displayTag ? _c('bk-select-tag', {
33424
+ ref: "bkSelectTag",
33360
33425
  attrs: {
33361
33426
  "width-limit": _vm.isTagWidthLimit
33427
+ },
33428
+ on: {
33429
+ "create-tag": _vm.handleCreateTag
33362
33430
  }
33363
- }) : [_vm.allowCreate ? _c('input', {
33431
+ }) : [_vm.allowCreate && !_vm.multiple ? _c('input', {
33364
33432
  staticClass: "bk-select-name",
33365
33433
  class: _vm.fontSizeCls,
33366
33434
  attrs: {
@@ -33455,7 +33523,21 @@
33455
33523
  }
33456
33524
  }, [_vm.multiple && _vm.showSelectAll && !_vm.searchValue ? _c('bk-option-all', {
33457
33525
  ref: "selectAllOption"
33458
- }) : _vm._e(), _vm.enableVirtualScroll ? _c('bk-virtual-scroll', {
33526
+ }) : _vm._e(), _vm._l(_vm.allowCreateData, function (item) {
33527
+ return _c('bk-option', {
33528
+ directives: [{
33529
+ name: "show",
33530
+ rawName: "v-show",
33531
+ value: false,
33532
+ expression: "false"
33533
+ }],
33534
+ key: item.id,
33535
+ attrs: {
33536
+ "id": item.id,
33537
+ "name": item.name
33538
+ }
33539
+ });
33540
+ }), _vm.enableVirtualScroll ? _c('bk-virtual-scroll', {
33459
33541
  ref: "virtualScroll",
33460
33542
  staticClass: "bk-virtual-select",
33461
33543
  style: {
@@ -37184,7 +37266,7 @@
37184
37266
  type: String,
37185
37267
  default: '',
37186
37268
  validator: function validator(value) {
37187
- if (['', 'large', 'small'].indexOf(value) < 0) {
37269
+ if (['', 'normal', 'large', 'small'].indexOf(value) < 0) {
37188
37270
  console.error("size property is not valid: '".concat(value, "'"));
37189
37271
  return false;
37190
37272
  }