vue-lazy-cascader 0.1.18 → 0.2.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.
package/README.md CHANGED
@@ -44,7 +44,27 @@ pnpm install vue-lazy-cascader --save
44
44
 
45
45
  - [demo](https://jyj1202.github.io/vue-lazy-cascader/vue-lazy-cascader.html)
46
46
 
47
+ ## description
48
+
49
+ ### Added Prop
50
+
51
+ | 属性名 | 类型 | 描述 |
52
+ |----------------|-----------|--------------------|
53
+ | remote | boolean | 是否开启远程搜索 |
54
+ | props.remoteMethod | (query: string, resolve: (any[]) => void) | 远程搜索方法,回调接收搜索的数据作为参数,会将未加载的数据插入到级联的数据store中 |
55
+ | props.total | string | 指定选项子节点总数为选项对象的某个属性值,默认'total' |
56
+
57
+
58
+ ### Added Events
59
+
60
+ | event name | callback parameter | description |
61
+ |------------------|------------------------------|--------------------------------|
62
+ | menu-scroll-bottom | (parentNode: Node, resolve: (any[]) => void) | 当菜单滚动到底部时触发,回调接收滚动加载的新数据作为参数,会将传入的未加载的数据插入到级联的数据store中。 |
63
+ | suggestion-scroll-bottom | (query: string, resolve: (any[]) => void) | 当搜索列表滚动到底部时触发,回调接收搜索的数据作为参数,会将未加载的数据插入到级联的数据store中。 |
64
+
65
+
47
66
  ## Tip
48
- - 由于该组件并未打包element-ui相关组件,所以使用时,必须已经安装element-ui
67
+ - 该组件打包了所需的element-ui组件,但是并没有引入element-ui样式,所以在使用前必须引入'element-ui/lib/theme-chalk/index.css'
49
68
  - 级联value必须唯一,否则会出错。例如相同value的子节点无法插入到不同的父节点下(待修复)
50
69
  - 是否是最后一页要判断准确,不能单纯用已加载和接口返回相加数量 == total进行判断,因为接口返回的可能已经加载过了。[详情请看代码(搜索时候会把搜索结果append到节点store中)](./src/components/cascader/src/cascader.vue)
70
+ - pop的层级如果不对,可以将appendToBody设置为false
@@ -1606,19 +1606,19 @@ if (typeof window !== 'undefined') {
1606
1606
  // Indicate to webpack that this file can be concatenated
1607
1607
  /* harmony default export */ var setPublicPath = (null);
1608
1608
 
1609
- ;// CONCATENATED MODULE: ./node_modules/.pnpm/vue-loader@15.11.1_css-loader@6.11.0_vue-template-compiler@2.6.14_webpack@5.91.0/node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/.pnpm/vue-loader@15.11.1_css-loader@6.11.0_vue-template-compiler@2.6.14_webpack@5.91.0/node_modules/vue-loader/lib/index.js??vue-loader-options!./src/components/cascader/src/cascader.vue?vue&type=template&id=2dd9cd90
1609
+ ;// CONCATENATED MODULE: ./node_modules/.pnpm/vue-loader@15.11.1_css-loader@6.11.0_vue-template-compiler@2.6.14_webpack@5.91.0/node_modules/vue-loader/lib/loaders/templateLoader.js??vue-loader-options!./node_modules/.pnpm/vue-loader@15.11.1_css-loader@6.11.0_vue-template-compiler@2.6.14_webpack@5.91.0/node_modules/vue-loader/lib/index.js??vue-loader-options!./src/components/cascader/src/cascader.vue?vue&type=template&id=73016d71
1610
1610
  var render = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{directives:[{name:"clickoutside",rawName:"v-clickoutside",value:(function () { return _vm.toggleDropDownVisible(false); }),expression:"() => toggleDropDownVisible(false)"}],ref:"reference",class:[
1611
1611
  'el-cascader',
1612
1612
  _vm.realSize && ("el-cascader--" + _vm.realSize),
1613
1613
  { 'is-disabled': _vm.isDisabled }
1614
- ],on:{"mouseenter":function($event){_vm.inputHover = true},"mouseleave":function($event){_vm.inputHover = false},"click":function () { return _vm.toggleDropDownVisible(_vm.readonly ? undefined : true); },"keydown":_vm.handleKeyDown}},[_c('el-input',{ref:"input",class:{ 'is-focus': _vm.dropDownVisible },attrs:{"size":_vm.realSize,"placeholder":_vm.placeholder,"readonly":_vm.readonly,"disabled":_vm.isDisabled,"validate-event":false},on:{"focus":_vm.handleFocus,"blur":_vm.handleBlur,"input":_vm.handleInput},model:{value:(_vm.multiple ? _vm.presentText : _vm.inputValue),callback:function ($$v) {_vm.multiple ? _vm.presentText : _vm.inputValue=$$v},expression:"multiple ? presentText : inputValue"}},[_c('template',{slot:"suffix"},[(_vm.clearBtnVisible)?_c('i',{key:"clear",staticClass:"el-input__icon el-icon-circle-close",on:{"click":function($event){$event.stopPropagation();return _vm.handleClear.apply(null, arguments)}}}):_c('i',{key:"arrow-down",class:[
1614
+ ],on:{"mouseenter":function($event){_vm.inputHover = true},"mouseleave":function($event){_vm.inputHover = false},"click":function () { return _vm.toggleDropDownVisible(_vm.readonly ? undefined : true); },"keydown":_vm.handleKeyDown}},[_c('el-input',{ref:"input",class:{ 'is-focus': _vm.dropDownVisible },attrs:{"size":_vm.realSize,"placeholder":_vm.presentTags.length ? '' : _vm.placeholder,"readonly":_vm.readonly,"disabled":_vm.isDisabled,"validate-event":false},on:{"focus":_vm.handleFocus,"blur":_vm.handleBlur,"input":_vm.handleInput},model:{value:(_vm.multiple ? _vm.presentText : _vm.inputValue),callback:function ($$v) {_vm.multiple ? _vm.presentText : _vm.inputValue=$$v},expression:"multiple ? presentText : inputValue"}},[_c('template',{slot:"suffix"},[(_vm.clearBtnVisible)?_c('i',{key:"clear",staticClass:"el-input__icon el-icon-circle-close",on:{"click":function($event){$event.stopPropagation();return _vm.handleClear.apply(null, arguments)}}}):_c('i',{key:"arrow-down",class:[
1615
1615
  'el-input__icon',
1616
1616
  'el-icon-arrow-down',
1617
1617
  _vm.dropDownVisible && 'is-reverse'
1618
- ],on:{"click":function($event){$event.stopPropagation();return _vm.toggleDropDownVisible()}}})])],2),(_vm.multiple)?_c('div',{staticClass:"el-cascader__tags"},[_vm._l((_vm.presentTags),function(tag){return _c('el-tag',{key:tag.key,attrs:{"type":"info","size":_vm.tagSize,"hit":tag.hitState,"closable":tag.closable,"disable-transitions":""},on:{"close":function($event){return _vm.deleteTag(tag)}}},[_c('span',[_vm._v(_vm._s(tag.text))])])}),(_vm.filterable && !_vm.isDisabled)?_c('input',{directives:[{name:"model",rawName:"v-model.trim",value:(_vm.inputValue),expression:"inputValue",modifiers:{"trim":true}}],staticClass:"el-cascader__search-input",attrs:{"type":"text","placeholder":_vm.presentTags.length ? '' : _vm.placeholder},domProps:{"value":(_vm.inputValue)},on:{"input":[function($event){if($event.target.composing){ return; }_vm.inputValue=$event.target.value.trim()},function (e) { return _vm.handleInput(_vm.inputValue, e); }],"click":function($event){$event.stopPropagation();return _vm.toggleDropDownVisible(true)},"keydown":function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"delete",[8,46],$event.key,["Backspace","Delete","Del"])){ return null; }return _vm.handleDelete.apply(null, arguments)},"blur":function($event){return _vm.$forceUpdate()}}}):_vm._e()],2):_vm._e(),_c('transition',{attrs:{"name":"el-zoom-in-top"},on:{"after-leave":_vm.handleDropdownLeave}},[_c('div',{directives:[{name:"show",rawName:"v-show",value:(_vm.dropDownVisible),expression:"dropDownVisible"}],ref:"popper",class:['el-popper', 'el-cascader__dropdown', _vm.popperClass]},[_c('cascader-panel',{directives:[{name:"show",rawName:"v-show",value:(!_vm.filtering),expression:"!filtering"}],ref:"panel",attrs:{"options":_vm.options,"props":_vm.config,"border":false,"render-label":_vm.$scopedSlots.default},on:{"expand-change":_vm.handleExpandChange,"close":function($event){return _vm.toggleDropDownVisible(false)},"menu-scroll-bottom":function (parentNode, resolve) { return _vm.$emit('menu-scroll-bottom', parentNode, resolve); }},model:{value:(_vm.checkedValue),callback:function ($$v) {_vm.checkedValue=$$v},expression:"checkedValue"}}),(_vm.filterable)?_c('el-scrollbar',{directives:[{name:"show",rawName:"v-show",value:(_vm.filtering),expression:"filtering"}],ref:"suggestionPanel",staticClass:"el-cascader__suggestion-panel",attrs:{"tag":"ul","view-class":"el-cascader__suggestion-list"},nativeOn:{"keydown":function($event){return _vm.handleSuggestionKeyDown.apply(null, arguments)}}},[(_vm.suggestions.length)?_vm._l((_vm.suggestions),function(item,index){return _c('li',{key:item.uid,class:[
1619
- 'el-cascader__suggestion-item',
1620
- item.checked && 'is-checked'
1621
- ],attrs:{"tabindex":-1},on:{"click":function($event){return _vm.handleSuggestionClick(index)}}},[_c('span',[_vm._v(_vm._s(item.text))]),(item.checked)?_c('i',{staticClass:"el-icon-check"}):_vm._e()])}):_vm._t("empty",function(){return [_c('li',{staticClass:"el-cascader__empty-text"},[_vm._v(_vm._s(_vm.t('el.cascader.noMatch')))])]})],2):_vm._e()],1)])],1)}
1618
+ ],on:{"click":function($event){$event.stopPropagation();return _vm.toggleDropDownVisible()}}})])],2),(_vm.multiple)?_c('div',{staticClass:"el-cascader__tags"},[_vm._l((_vm.presentTags),function(tag){return _c('el-tag',{key:tag.key,attrs:{"type":"info","size":_vm.tagSize,"hit":tag.hitState,"closable":tag.closable,"disable-transitions":""},on:{"close":function($event){return _vm.deleteTag(tag)}}},[_c('span',[_vm._v(_vm._s(tag.text))])])}),(_vm.filterable && !_vm.isDisabled)?_c('input',{directives:[{name:"model",rawName:"v-model.trim",value:(_vm.inputValue),expression:"inputValue",modifiers:{"trim":true}}],staticClass:"el-cascader__search-input",attrs:{"type":"text","placeholder":_vm.presentTags.length ? '' : _vm.placeholder},domProps:{"value":(_vm.inputValue)},on:{"input":[function($event){if($event.target.composing){ return; }_vm.inputValue=$event.target.value.trim()},function (e) { return _vm.handleInput(_vm.inputValue, e); }],"click":function($event){$event.stopPropagation();return _vm.toggleDropDownVisible(true)},"keydown":function($event){if(!$event.type.indexOf('key')&&_vm._k($event.keyCode,"delete",[8,46],$event.key,["Backspace","Delete","Del"])){ return null; }return _vm.handleDelete.apply(null, arguments)},"blur":function($event){return _vm.$forceUpdate()}}}):_vm._e()],2):_vm._e(),_c('transition',{attrs:{"name":"el-zoom-in-top"},on:{"after-leave":_vm.handleDropdownLeave}},[_c('div',{directives:[{name:"show",rawName:"v-show",value:(_vm.dropDownVisible),expression:"dropDownVisible"}],ref:"popper",class:['el-popper', 'el-cascader__dropdown', _vm.popperClass]},[_c('cascader-panel',{directives:[{name:"show",rawName:"v-show",value:(!_vm.filtering),expression:"!filtering"}],ref:"panel",attrs:{"options":_vm.options,"props":_vm.config,"border":false,"render-label":_vm.$scopedSlots.default},on:{"expand-change":_vm.handleExpandChange,"close":function($event){return _vm.toggleDropDownVisible(false)},"menu-scroll-bottom":function (parentNode, resolve) { return _vm.$emit('menu-scroll-bottom', parentNode, resolve); }},model:{value:(_vm.checkedValue),callback:function ($$v) {_vm.checkedValue=$$v},expression:"checkedValue"}}),(_vm.filterable)?_c('el-scrollbar',{directives:[{name:"show",rawName:"v-show",value:(_vm.filtering),expression:"filtering"}],ref:"suggestionPanel",staticClass:"el-cascader__suggestion-panel",attrs:{"tag":"ul","view-class":"el-cascader__suggestion-list"},nativeOn:{"keydown":function($event){return _vm.handleSuggestionKeyDown.apply(null, arguments)}}},[(_vm.suggestionLoading)?_c('span',{staticStyle:{"text-align":"center"}},[_vm._v("加载中")]):[(_vm.suggestions.length)?_vm._l((_vm.suggestions),function(item,index){return _c('li',{key:item.uid,class:[
1619
+ 'el-cascader__suggestion-item',
1620
+ item.checked && 'is-checked'
1621
+ ],attrs:{"tabindex":-1},on:{"click":function($event){return _vm.handleSuggestionClick(index)}}},[_c('span',[_vm._v(_vm._s(item.text))]),(item.checked)?_c('i',{staticClass:"el-icon-check"}):_vm._e()])}):_vm._t("empty",function(){return [_c('li',{staticClass:"el-cascader__empty-text"},[_vm._v(_vm._s(_vm.t('el.cascader.noMatch')))])]})]],2):_vm._e()],1)])],1)}
1622
1622
  var staticRenderFns = []
1623
1623
 
1624
1624
 
@@ -5487,13 +5487,14 @@ const stopPropagation = e => e.stopPropagation();
5487
5487
  const {
5488
5488
  isLeaf,
5489
5489
  isChecked,
5490
- config
5490
+ config,
5491
+ node
5491
5492
  } = this;
5492
5493
  const {
5493
5494
  checkStrictly,
5494
5495
  multiple
5495
5496
  } = config;
5496
- if (multiple) {
5497
+ if (multiple && !node.data.hideMultiple) {
5497
5498
  return this.renderCheckbox(h);
5498
5499
  } else if (checkStrictly) {
5499
5500
  return this.renderRadio(h);
@@ -5520,6 +5521,7 @@ const stopPropagation = e => e.stopPropagation();
5520
5521
  config,
5521
5522
  isDisabled
5522
5523
  } = this;
5524
+ const disabled = node.data.selfDisabled || isDisabled;
5523
5525
  const events = {
5524
5526
  on: {
5525
5527
  change: this.handleMultiCheckChange
@@ -5534,7 +5536,7 @@ const stopPropagation = e => e.stopPropagation();
5534
5536
  "attrs": {
5535
5537
  "value": node.checked,
5536
5538
  "indeterminate": node.indeterminate,
5537
- "disabled": isDisabled
5539
+ "disabled": disabled
5538
5540
  }
5539
5541
  }, events]));
5540
5542
  },
@@ -6791,6 +6793,9 @@ var debounce_default = /*#__PURE__*/__webpack_require__.n(debounce);
6791
6793
  //
6792
6794
  //
6793
6795
  //
6796
+ //
6797
+ //
6798
+ //
6794
6799
 
6795
6800
 
6796
6801
 
@@ -6919,7 +6924,8 @@ const InputSizeMap = {
6919
6924
  filtering: false,
6920
6925
  suggestions: [],
6921
6926
  inputInitialHeight: 0,
6922
- pressDeleteCount: 0
6927
+ pressDeleteCount: 0,
6928
+ suggestionLoading: false /** @author jyj */
6923
6929
  };
6924
6930
  },
6925
6931
  computed: {
@@ -7053,6 +7059,8 @@ const InputSizeMap = {
7053
7059
  remoteMethod
7054
7060
  } = this.config;
7055
7061
  if (this.remote && remoteMethod) {
7062
+ // this.suggestions = []
7063
+ this.suggestionLoading = true;
7056
7064
  remoteMethod(inputValue, this.remoteSearchResolve(inputValue));
7057
7065
  return;
7058
7066
  }
@@ -7381,6 +7389,7 @@ const InputSizeMap = {
7381
7389
  */
7382
7390
  remoteSearchResolve(inputValue) {
7383
7391
  const resolve = data => {
7392
+ this.suggestionLoading = false;
7384
7393
  if (isEmpty(data)) {
7385
7394
  this.getSuggestions();
7386
7395
  return;