bkui-vue 0.0.1-beta.225 → 0.0.1-beta.226
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/dist/index.cjs.js +52 -52
- package/dist/index.esm.js +46 -1
- package/dist/index.umd.js +52 -52
- package/lib/tag-input/common.d.ts +9 -0
- package/lib/tag-input/index.d.ts +26 -1
- package/lib/tag-input/index.js +1 -1
- package/lib/tag-input/tag-input.d.ts +11 -0
- package/lib/tag-input/tag-props.d.ts +4 -0
- package/package.json +1 -1
@@ -25,3 +25,12 @@ export declare function useFlatList(props: TagProps): {
|
|
25
25
|
* @returns 字符长度
|
26
26
|
*/
|
27
27
|
export declare const getCharLength: (str: string) => number;
|
28
|
+
/**
|
29
|
+
* 获取隐藏 tag index
|
30
|
+
* @param tagInputRef 组件容器 ref
|
31
|
+
* @param collapseTags 是否折叠 tags
|
32
|
+
* @param selectedTagList 已选择 tags
|
33
|
+
*/
|
34
|
+
export declare const useTagsOverflow: (tagInputRef: Ref<HTMLDivElement>, collapseTags: Ref<Boolean>, selectedTagList: Ref<string[]>) => {
|
35
|
+
overflowTagIndex: Ref<number>;
|
36
|
+
};
|
package/lib/tag-input/index.d.ts
CHANGED
@@ -16,6 +16,7 @@ declare const TagInput: {
|
|
16
16
|
withValidate: boolean;
|
17
17
|
searchKey: string | string[];
|
18
18
|
allowCreate: boolean;
|
19
|
+
collapseTags: boolean;
|
19
20
|
displayKey: string;
|
20
21
|
tooltipKey: string;
|
21
22
|
saveKey: string;
|
@@ -245,6 +246,10 @@ declare const TagInput: {
|
|
245
246
|
}>>>>;
|
246
247
|
default: () => {};
|
247
248
|
};
|
249
|
+
collapseTags: {
|
250
|
+
type: BooleanConstructor;
|
251
|
+
default: boolean;
|
252
|
+
};
|
248
253
|
}>> & {
|
249
254
|
onBlur?: (...args: any[]) => any;
|
250
255
|
onChange?: (...args: any[]) => any;
|
@@ -252,7 +257,7 @@ declare const TagInput: {
|
|
252
257
|
"onUpdate:modelValue"?: (...args: any[]) => any;
|
253
258
|
onRemove?: (...args: any[]) => any;
|
254
259
|
onRemoveAll?: (...args: any[]) => any;
|
255
|
-
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "disabled" | "trigger" | "placeholder" | "list" | "separator" | "clearable" | "showClearOnlyHover" | "modelValue" | "withValidate" | "searchKey" | "allowCreate" | "displayKey" | "tooltipKey" | "saveKey" | "hasDeleteIcon" | "useGroup" | "maxData" | "maxResult" | "contentMaxHeight" | "contentWidth" | "allowNextFocus" | "allowAutoMatch" | "leftSpace" | "popoverProps">;
|
260
|
+
} & import("vue").VNodeProps & import("vue").AllowedComponentProps & import("vue").ComponentCustomProps, "disabled" | "trigger" | "placeholder" | "list" | "separator" | "clearable" | "showClearOnlyHover" | "modelValue" | "withValidate" | "searchKey" | "allowCreate" | "collapseTags" | "displayKey" | "tooltipKey" | "saveKey" | "hasDeleteIcon" | "useGroup" | "maxData" | "maxResult" | "contentMaxHeight" | "contentWidth" | "allowNextFocus" | "allowAutoMatch" | "leftSpace" | "popoverProps">;
|
256
261
|
$attrs: {
|
257
262
|
[x: string]: unknown;
|
258
263
|
};
|
@@ -482,6 +487,10 @@ declare const TagInput: {
|
|
482
487
|
}>>>>;
|
483
488
|
default: () => {};
|
484
489
|
};
|
490
|
+
collapseTags: {
|
491
|
+
type: BooleanConstructor;
|
492
|
+
default: boolean;
|
493
|
+
};
|
485
494
|
}>> & {
|
486
495
|
onBlur?: (...args: any[]) => any;
|
487
496
|
onChange?: (...args: any[]) => any;
|
@@ -506,6 +515,8 @@ declare const TagInput: {
|
|
506
515
|
active: boolean;
|
507
516
|
disabled: boolean;
|
508
517
|
}>;
|
518
|
+
overflowTagIndex: import("vue").Ref<number>;
|
519
|
+
localCollapseTags: import("vue").ComputedRef<boolean>;
|
509
520
|
focusInputTrigger: (e?: MouseEvent) => void;
|
510
521
|
activeClass: (data: any, index: number) => {
|
511
522
|
'bk-selector-actived': boolean;
|
@@ -558,6 +569,7 @@ declare const TagInput: {
|
|
558
569
|
withValidate: boolean;
|
559
570
|
searchKey: string | string[];
|
560
571
|
allowCreate: boolean;
|
572
|
+
collapseTags: boolean;
|
561
573
|
displayKey: string;
|
562
574
|
tooltipKey: string;
|
563
575
|
saveKey: string;
|
@@ -807,6 +819,10 @@ declare const TagInput: {
|
|
807
819
|
}>>>>;
|
808
820
|
default: () => {};
|
809
821
|
};
|
822
|
+
collapseTags: {
|
823
|
+
type: BooleanConstructor;
|
824
|
+
default: boolean;
|
825
|
+
};
|
810
826
|
}>> & {
|
811
827
|
onBlur?: (...args: any[]) => any;
|
812
828
|
onChange?: (...args: any[]) => any;
|
@@ -831,6 +847,8 @@ declare const TagInput: {
|
|
831
847
|
active: boolean;
|
832
848
|
disabled: boolean;
|
833
849
|
}>;
|
850
|
+
overflowTagIndex: import("vue").Ref<number>;
|
851
|
+
localCollapseTags: import("vue").ComputedRef<boolean>;
|
834
852
|
focusInputTrigger: (e?: MouseEvent) => void;
|
835
853
|
activeClass: (data: any, index: number) => {
|
836
854
|
'bk-selector-actived': boolean;
|
@@ -1089,6 +1107,10 @@ declare const TagInput: {
|
|
1089
1107
|
}>>>>;
|
1090
1108
|
default: () => {};
|
1091
1109
|
};
|
1110
|
+
collapseTags: {
|
1111
|
+
type: BooleanConstructor;
|
1112
|
+
default: boolean;
|
1113
|
+
};
|
1092
1114
|
}>> & {
|
1093
1115
|
onBlur?: (...args: any[]) => any;
|
1094
1116
|
onChange?: (...args: any[]) => any;
|
@@ -1113,6 +1135,8 @@ declare const TagInput: {
|
|
1113
1135
|
active: boolean;
|
1114
1136
|
disabled: boolean;
|
1115
1137
|
}>;
|
1138
|
+
overflowTagIndex: import("vue").Ref<number>;
|
1139
|
+
localCollapseTags: import("vue").ComputedRef<boolean>;
|
1116
1140
|
focusInputTrigger: (e?: MouseEvent) => void;
|
1117
1141
|
activeClass: (data: any, index: number) => {
|
1118
1142
|
'bk-selector-actived': boolean;
|
@@ -1165,6 +1189,7 @@ declare const TagInput: {
|
|
1165
1189
|
withValidate: boolean;
|
1166
1190
|
searchKey: string | string[];
|
1167
1191
|
allowCreate: boolean;
|
1192
|
+
collapseTags: boolean;
|
1168
1193
|
displayKey: string;
|
1169
1194
|
tooltipKey: string;
|
1170
1195
|
saveKey: string;
|
package/lib/tag-input/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("../shared"),require("vue"),require("lodash"),require("../directives"),require("../icon"),require("../loading"),require("../popover"));else if("function"==typeof define&&define.amd)define(["../shared","vue","lodash","../directives","../icon","../loading","../popover"],t);else{var r="object"==typeof exports?t(require("../shared"),require("vue"),require("lodash"),require("../directives"),require("../icon"),require("../loading"),require("../popover")):t(e["../shared"],e.vue,e.lodash,e["../directives"],e["../icon"],e["../loading"],e["../popover"]);for(var a in r)("object"==typeof exports?exports:e)[a]=r[a]}}(self,((e,t,r,a,n,o,l)=>(()=>{"use strict";var i={4061:e=>{e.exports=a},6870:e=>{e.exports=n},4870:e=>{e.exports=o},5537:e=>{e.exports=l},4212:t=>{t.exports=e},467:e=>{e.exports=r},748:e=>{e.exports=t}},s={};function u(e){var t=s[e];if(void 0!==t)return t.exports;var r=s[e]={exports:{}};return i[e](r,r.exports,u),r.exports}u.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return u.d(t,{a:t}),t},u.d=(e,t)=>{for(var r in t)u.o(t,r)&&!u.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},u.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),u.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var c={};return(()=>{u.r(c),u.d(c,{default:()=>L});var e=u(4212);function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,a=new Array(t);r<t;r++)a[r]=e[r];return a}function a(e,t){if(e){if("string"==typeof e)return r(e,t);var a=Object.prototype.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?r(e,t):void 0}}function n(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function o(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||a(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var l=u(748),i=u(467),s=u(4061),d=u(6870),p=u(4870),f=u.n(p),v=u(5537),g=u.n(v),h=12,y=function(e){for(var t=e.length,r=0,a=0;a<t;a++)0!=(65280&e.charCodeAt(a))&&(r+=1),r+=1;return r};const m=(0,l.defineComponent)({name:"ListTagRender",props:{node:e.PropTypes.object,searchKey:e.PropTypes.oneOfType([e.PropTypes.string,e.PropTypes.arrayOf(e.PropTypes.string)]),displayKey:e.PropTypes.string,searchKeyword:e.PropTypes.string,tpl:{type:Function}},render:function(){var e=this,t=function(t){if(e.searchKeyword){var r=new RegExp("(".concat(e.searchKeyword,")"),"i");return t.replace(r,'<strong class="highlight-text">$1</strong>')}return t};if(this.tpl)return this.tpl(this.node,t,l.h,this);var r=this.node[this.displayKey];return(0,l.createVNode)("div",{class:"bk-selector-node"},[(0,l.createVNode)("span",{class:"text",innerHTML:t(r)},[r])])}}),b=(0,l.defineComponent)({name:"TagRender",props:{node:e.PropTypes.object,displayKey:e.PropTypes.string,tpl:{type:Function}},render:function(){return this.tpl?this.tpl(this.node,l.h,this):(0,l.createVNode)("div",{class:"tag"},[(0,l.createVNode)("span",{class:"text"},[this.node[this.displayKey]])])}}),T=(0,l.defineComponent)({name:"TagInput",directives:{bkTooltips:s.bkTooltips},props:{modelValue:e.PropTypes.arrayOf(e.PropTypes.string).def([]),placeholder:e.PropTypes.string.def("请输入并按 Enter 结束"),list:e.PropTypes.arrayOf(e.PropTypes.object).def([]),disabled:e.PropTypes.bool.def(!1),tooltipKey:e.PropTypes.string.def(""),saveKey:e.PropTypes.string.def("id"),displayKey:e.PropTypes.string.def("name"),hasDeleteIcon:e.PropTypes.bool.def(!1),clearable:e.PropTypes.bool.def(!0),trigger:e.PropTypes.commonType(["focus","search"]).def("search"),searchKey:e.PropTypes.oneOfType([e.PropTypes.string,e.PropTypes.arrayOf(e.PropTypes.string)]).def("name"),useGroup:e.PropTypes.bool.def(!1),allowCreate:e.PropTypes.bool.def(!1),maxData:e.PropTypes.number.def(-1),maxResult:e.PropTypes.number.def(10),contentMaxHeight:e.PropTypes.number.def(300),contentWidth:e.PropTypes.number.def(190),separator:e.PropTypes.string.def(""),allowNextFocus:e.PropTypes.bool.def(!0),allowAutoMatch:e.PropTypes.bool.def(!1),showClearOnlyHover:e.PropTypes.bool.def(!1),leftSpace:e.PropTypes.number.def(0),createTagValidator:{type:Function},filterCallback:{type:Function},tagTpl:{type:Function},tpl:{type:Function},pasteFn:{type:Function},withValidate:{type:Boolean,default:!0},popoverProps:{type:Object,default:function(){return{}}}},emits:["update:modelValue","change","select","blur","remove","removeAll"],setup:function(r,s){var u=s.emit,c=(0,e.useFormItem)(),d=(0,l.reactive)({isEdit:!1,isHover:!1,focusItemIndex:r.allowCreate?-1:0}),p=(0,l.reactive)(Object.assign({isShow:!1,width:190,modifiers:[{name:"offset",options:{offset:[0,4]}}]},r.popoverProps)),f=function(e){var t=(0,l.reactive)({curPage:1,totalSize:0,totalPage:0,pageSize:e,isPageLoading:!1,curPageList:[],renderListPaged:[]});return{pageState:t,initPage:function(){var e,r,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];t.curPage=1,t.totalSize=a.length,t.totalPage=Math.ceil(t.totalSize/t.pageSize)||1;var n=[];if(t.pageSize>0)for(var l=0;l<t.totalSize;l+=t.pageSize)n.push(a.slice(l,l+t.pageSize));(e=t.renderListPaged).splice.apply(e,[0,t.renderListPaged.length].concat(n)),(r=t.curPageList).splice.apply(r,[0,t.curPageList.length].concat(o(t.renderListPaged[t.curPage-1]||[])))},pageChange:function(e){var r;t.curPage=e,(r=t.curPageList).splice.apply(r,[t.curPageList.length,0].concat(o(t.renderListPaged[t.curPage-1]||[]))),t.isPageLoading=!1}}}((0,l.toRefs)(r).maxResult),v=f.pageState,g=f.initPage,m=f.pageChange,b=(0,l.ref)(""),T=(0,l.ref)(null),L=(0,l.ref)(null),w=(0,l.ref)(null),P=(0,l.ref)(null),x=(0,l.ref)(null),I=(0,l.ref)(null),C=(0,l.ref)(null),S=(0,l.computed)((function(){return!r.disabled&&r.hasDeleteIcon})),K=(0,l.computed)((function(){return 1===r.maxData})),k=(0,l.computed)((function(){return 0===O.selectedTagList.length&&""===b.value&&!d.isEdit})),V=(0,l.computed)((function(){return r.clearable&&!r.disabled&&0!==O.selectedTagList.length&&(!r.showClearOnlyHover||d.isHover)})),N=(0,l.computed)((function(){return{"bk-tag-input-trigger":!0,active:d.isEdit,disabled:r.disabled}})),O=(0,l.reactive)({localList:[],tagListCache:[],selectedTagList:[],selectedTagListCache:[]}),R=(0,l.computed)((function(){return O.selectedTagList.map((function(e){return e[r.saveKey]}))})),j=function(e){var t=(0,l.toRefs)(e),r=t.useGroup,a=t.saveKey,n=t.displayKey,o=t.list,i=(0,l.ref)([]),s=(0,l.ref)({});return(0,l.watch)([r,a,n,o],(function(){i.value=[];var e=(0,l.markRaw)(o.value);r.value&&(e=e.reduce((function(e,t){var r=[];return t.children&&(r=t.children.map((function(e){return Object.assign({group:{groupId:t[a.value],groupName:t[n.value]}},e)}))),e.concat(r)}),[])),i.value=e,s.value=e.reduce((function(e,t){return e[t[a.value]]=t,e}),{})}),{immediate:!0}),{flatList:i,saveKeyMap:s}}(r),A=j.flatList,E=j.saveKeyMap,D=(0,l.computed)((function(){if(r.useGroup){var e={};return v.curPageList.forEach((function(t,r){t.__index__=r,e[t.group.groupId]||(e[t.group.groupId]={id:t.group.groupId,name:t.group.groupName,children:[]}),e[t.group.groupId].children.push(t)})),Object.keys(e).map((function(t){return e[t]}))}return v.curPageList}));(0,l.watch)([function(){return A.value}],(function(){(0,l.nextTick)((function(){z()}))})),(0,l.watch)((function(){return r.modelValue}),(function(e){var t,a,n;n=e,(a=R.value).length===n.length&&n.every((function(e,t){return a[t]===e}))||((0,l.nextTick)((function(){z()})),r.withValidate&&(null===(t=null==c?void 0:c.validate)||void 0===t||t.call(c,"change")))})),(0,l.watch)(b,(0,i.debounce)((function(){var e=0!==v.curPageList.length,t=b.value;""!==t&&e||""===t&&"focus"===r.trigger&&e?p.isShow=!0:"focus"===r.trigger&&e||(p.isShow=!1)}),150)),(0,l.watch)((function(){return p.isShow}),(function(e){F(),e&&x.value&&((0,l.nextTick)((function(){x.value.scrollTop=0})),x.value.removeEventListener("scroll",M),x.value.addEventListener("scroll",M))})),(0,l.onMounted)((function(){z()}));var F=function(){var e,t,r=K.value?0:null===(e=P.value)||void 0===e?void 0:e.offsetLeft;p.modifiers=[{name:"offset",options:{offset:[r,4]}}],null===(t=I.value)||void 0===t||t.update()},M=function(){if(!v.isPageLoading&&0!==x.value.scrollTop){var e=x.value;if(e.scrollTop+e.offsetHeight>=e.scrollHeight){var t=v.curPage+1;t<=v.totalPage&&(v.isPageLoading=!0,setTimeout((function(){m(t)}),500))}}},q=function(){var e;return Array.from((null===(e=w.value)||void 0===e?void 0:e.childNodes)||[]).filter((function(e){return e.nodeType!==Node.TEXT_NODE}))},_=function(e){if(!r.disabled){if(null==e?void 0:e.target){var t=e.target.className;(t.indexOf("bk-tag-input-trigger")>-1||t.indexOf("tag-list")>-1)&&w.value.appendChild(P.value)}clearTimeout(C.value),K.value&&R.value.length&&(O.tagListCache=o(R.value),O.selectedTagListCache=o(O.selectedTagList),b.value=O.selectedTagListCache[0][r.saveKey],Y(O.selectedTagList[0],0),W()),d.isEdit=!0,(0,l.nextTick)((function(){var e;null===(e=T.value)||void 0===e||e.focus(),"focus"===r.trigger&&0!==O.localList.length&&(H(),p.isShow?F():p.isShow=!0)}))}},z=function(){var e=r.saveKey,t=r.modelValue,a=r.displayKey,o=r.allowCreate,l=r.trigger;if(O.selectedTagList=[],O.localList=A.value,t.length){var i={};O.selectedTagList=t.map((function(t){var r,l=E.value[t];return i[t]=1,!l&&o?(n(r={},e,t),n(r,a,t),r):l})).filter((function(e){return e})),K.value||(O.localList=O.localList.filter((function(t){return!i[t[e]]})))}"focus"===l&&H()},H=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=r.searchKey,a=r.filterCallback,n=e.toLowerCase().trim();if(""!==n){var o=[];o="function"==typeof a?a(n,t,O.localList)||[]:Array.isArray(t)?O.localList.filter((function(e){return t.some((function(t){return e[t].toLowerCase().indexOf(n)>-1}))})):O.localList.filter((function(e){return e[t].toLowerCase().indexOf(n)>-1})),g(o)}else g(O.localList)},B=function(){b.value=""},G=function(){if(K.value)return 0;var e=q().findIndex((function(e){return"tagInputItem"===e.id}));return e>=0?e:0},U=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(t&&e){var a=t;r&&(a=t.nextElementSibling||null),t.parentNode.insertBefore(e,a)}},W=function(e){var t=r.maxData,a=r.trigger,n=r.allowCreate;if(-1===t||t>R.value.length){var o=((null==e?void 0:e.target)?e.target:b).value,l=y(o);l?(H(o),T.value.style.width="".concat(l*h,"px")):"focus"===a&&H()}else $(),b.value="",p.isShow=!1;d.isEdit=!0,d.focusItemIndex=n?-1:0},$=function(){C.value=setTimeout((function(){var e,t,n,o=b.value;if(B(),d.isEdit=!1,K.value){var l=(t=O.tagListCache,n=1,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var a,n,o=[],l=!0,i=!1;try{for(r=r.call(e);!(l=(a=r.next()).done)&&(o.push(a.value),!t||o.length!==t);l=!0);}catch(e){i=!0,n=e}finally{try{l||null==r.return||r.return()}finally{if(i)throw n}}return o}}(t,n)||a(t,n)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0];o&&o===l&&O.selectedTagListCache.length?Q(O.selectedTagListCache[0],"select"):X("remove")}else if(r.allowAutoMatch&&o){var i=v.curPageList.find((function(e){return Array.isArray(r.searchKey)?r.searchKey.map((function(t){return e[t]})).includes(o):e[r.searchKey]===o}));i?Z(i,"select"):r.allowCreate&&Z(o,"custom")}p.isShow=!1,u("blur",o,R.value),null===(e=null==c?void 0:c.validate)||void 0===e||e.call(c,"blur")}),200)},Z=function(e,t,r){null==r||r.stopPropagation(),e&&!e.disabled&&(K.value&&(O.tagListCache=[],O.selectedTagListCache=[],O.selectedTagList=[]),Q(e,t),X("select"),B(),p.isShow=!1)},X=function(e,t){u("change",R.value),u(e,t),u("update:modelValue",R.value)},J=function(){var e=x.value.clientHeight,t=x.value.getBoundingClientRect().y;(0,l.nextTick)((function(){var r=x.value.querySelector(".bk-selector-actived");if(r){var a=r.clientHeight,n=r.getBoundingClientRect().y;n<t&&(x.value.scrollTop=x.value.scrollTop-(t-n));var o=n+a-t;o>e&&(x.value.scrollTop=x.value.scrollTop+o-e)}}))},Q=function(e,a){if(!(O.selectedTagList.length>=r.maxData&&-1!==r.maxData)){var i,s=r.separator,u=r.saveKey,c=r.displayKey,d=r.createTagValidator,p=G(),f=1,v=!1,g=function(e){return"function"!=typeof d||d(e)};if("custom"===a)if(s){var y,m=e.split(s),b=(m=m.filter((function(e){return(null==e?void 0:e.trim())&&!R.value.includes(e)&&g(e)}))).map((function(e){var t;return E.value[e]||(n(t={},u,e),n(t,c,e),t)}));m.length&&((y=O.selectedTagList).splice.apply(y,[p,0].concat(o(b))),f=b.length,v=!0)}else{var L="object"===t(e);if(void 0!==(i=(i=L?e[u]:e.trim()).replace(/\s+/g,""))&&!R.value.includes(i)&&g(i)){var w,x=E.value[i]||(L?e:(n(w={},u,i),n(w,c,i),w));O.selectedTagList.splice(p,0,x),v=!0}}else e&&(void 0===(i=e[u])||R.value.includes(i)||(O.selectedTagList.splice(p,0,e),v=!0));v&&(0,l.nextTick)((function(){for(var e=1;e<=f;e++){var t=q()[p+e];U(t,P.value)}if(T.value.style.width="".concat(h,"px"),!K.value){r.allowNextFocus&&_();var a=R.value.reduce((function(e,t){return e[t]=1,e}),{});O.localList=O.localList.filter((function(e){return!a[e[u]]}))}}))}},Y=function(e,t){O.selectedTagList.splice(t,1);var a=E.value[e[r.saveKey]];(r.allowCreate&&a||!r.allowCreate)&&!K.value&&O.localList.push(e)};return Object.assign(Object.assign(Object.assign(Object.assign({popoverProps:p},(0,l.toRefs)(d)),(0,l.toRefs)(O)),(0,l.toRefs)(v)),{isShowPlaceholder:k,isShowClear:V,curInputValue:b,renderList:D,showTagClose:S,tagInputRef:T,bkTagSelectorRef:L,tagListRef:w,tagInputItemRef:P,selectorListRef:x,popoverRef:I,triggerClass:N,focusInputTrigger:_,activeClass:function(e,t){var a={"bk-selector-actived":!1,"bk-selector-selected":R.value.includes(e[r.saveKey])};return r.useGroup?a["bk-selector-actived"]=e.__index__===d.focusItemIndex:a["bk-selector-actived"]=t===d.focusItemIndex,a},handleInput:W,handleFocus:function(){var e;p.width=K.value?null===(e=L.value)||void 0===e?void 0:e.clientWidth:r.contentWidth},handleBlur:$,handleTagSelected:Z,handleTagRemove:function(e,t,r){null==r||r.stopPropagation(),Y(e,t),B(),X("remove",e),T.value.style.width="".concat(h,"px")},handleClear:function(e){e.stopPropagation();var t=O.selectedTagList;O.selectedTagList=[];var a,n=t.filter((function(e){return E.value[e[r.saveKey]]}));(!r.allowCreate||0===n.length)&&r.allowCreate||K.value||(a=O.localList).push.apply(a,o(n)),X("removeAll")},tagFocus:function(e){r.disabled||(U(P.value,e.currentTarget,!0),T.value.style.width="".concat(h,"px"),p.isShow&&F())},handleKeydown:function(e){if(!v.isPageLoading){var t=e.target.value,a=y(t),n=G(),o=q();switch(e.code){case"ArrowUp":if(e.preventDefault(),!p.isShow)return;d.focusItemIndex=d.focusItemIndex-1,d.focusItemIndex=d.focusItemIndex<0?-1:d.focusItemIndex,-1===d.focusItemIndex&&(d.focusItemIndex=v.curPageList.length-1),J();break;case"ArrowDown":if(e.preventDefault(),!p.isShow)return;d.focusItemIndex=d.focusItemIndex+1,d.focusItemIndex=d.focusItemIndex>v.curPageList.length-1?v.curPageList.length:d.focusItemIndex,d.focusItemIndex===v.curPageList.length&&(d.focusItemIndex=0),J();break;case"ArrowLeft":if(d.isEdit=!0,!a){if(n<1)return;U(P.value,o[n-1]),_()}break;case"ArrowRight":if(d.isEdit=!0,!a){if(n===o.length-1)return;U(o[n+1],P.value),_()}break;case"Enter":case"NumpadEnter":!r.allowCreate&&p.isShow||r.allowCreate&&d.focusItemIndex>=0&&p.isShow?Z(v.curPageList[d.focusItemIndex],"select",e):r.allowCreate&&Z(b.value,"custom",e),e.preventDefault();break;case"Backspace":0===n||b.value||function(e,t){var a=q();U(P.value,a[e-1]),O.selectedTagList.splice(e-1,1),_();var n=E.value[t[r.saveKey]];(r.allowCreate&&n||!r.allowCreate)&&!K.value&&O.localList.push(t),T.value="".concat(h,"px"),X("remove")}(n,O.selectedTagList[n-1])}}},handlePaste:function(e){if(e.preventDefault(),K.value)return!1;var t=r.maxData,a=r.saveKey,l=r.displayKey,i=r.pasteFn,s=r.allowCreate,u=e.clipboardData.getData("text"),c=i?i(u):function(e){var t=[],a=e.split(";"),o=/^[a-zA-Z][a-zA-Z_]*/g;return a.forEach((function(e){var a=e.match(o);if(a){var l,i=a.join("");t.push((n(l={},r.saveKey,i),n(l,r.displayKey,i),l))}})),t}(u),d=c.map((function(e){return e[a]}));if(d.length){var p=q(),f=G(),v=O.localList.map((function(e){return e[a]}));if(d=d.filter((function(e){var t=(null==e?void 0:e.trim())&&!R.value.includes(e);return s?t:t&&v.includes(e)})),-1!==t){var g=O.selectedTagList.length;if(g<t){var y=t-g;d.length>y&&(d=o(d.slice(0,y)))}else d=[]}var m,b=s?d.map((function(e){var t,r=O.localList.find((function(t){return t[a]===e}));return null!=r?r:(n(t={},a,e),n(t,l,e),t)})):O.localList.filter((function(e){return d.includes(e[a])}));d.length&&((m=O.selectedTagList).splice.apply(m,[f,0].concat(o(b))),U(P.value,p[f]),T.value.style.width="".concat(h,"px"),O.localList=O.localList.filter((function(e){return!d.includes(e[a])})),X("select"),_())}}})},render:function(){var e=this;return(0,l.createVNode)("div",{class:"bk-tag-input",ref:"bkTagSelectorRef",onClick:this.focusInputTrigger,onMouseenter:function(){return e.isHover=!0},onMouseleave:function(){return e.isHover=!1}},[(0,l.createVNode)(g(),(0,l.mergeProps)({ref:"popoverRef",theme:"light",trigger:"manual",placement:"bottom-start","content-cls":"bk-tag-input-popover-content",arrow:!1},this.popoverProps),{default:function(){var t,r,a;return(0,l.createVNode)("div",{class:e.triggerClass},[(0,l.createVNode)("ul",{class:"tag-list",ref:"tagListRef",style:{marginLeft:"".concat(e.leftSpace,"px")}},[e.selectedTagList.map((function(t,r){var a={boundary:"window",theme:"light",distance:12,content:t[e.tooltipKey],disabled:!e.tooltipKey};return(0,l.withDirectives)((0,l.createVNode)("li",{class:"tag-item",onClick:e.tagFocus},[(0,l.createVNode)(b,{node:t,tpl:e.tagTpl,displayKey:e.displayKey},null),e.showTagClose?(0,l.createVNode)(d.Error,{class:"remove-tag",onClick:e.handleTagRemove.bind(e,t,r)},null):null]),[[(0,l.resolveDirective)("bk-tooltips"),a]])})),(0,l.withDirectives)((0,l.createVNode)("li",{ref:"tagInputItemRef",id:"tagInputItem",class:"tag-input-item",role:"input"},[(0,l.withDirectives)((0,l.createVNode)("input",{type:"text",class:"tag-input",ref:"tagInputRef","onUpdate:modelValue":function(t){return e.curInputValue=t},onInput:e.handleInput,onFocus:e.handleFocus,onBlur:e.handleBlur,onKeydown:e.handleKeydown,onPaste:e.handlePaste},null),[[l.vModelText,e.curInputValue]])]),[[l.vShow,e.isEdit]])]),(0,l.withDirectives)((0,l.createVNode)("p",{class:"placeholder"},[e.placeholder]),[[l.vShow,e.isShowPlaceholder]]),null!==(a=null===(r=null===(t=e.$slots)||void 0===t?void 0:t.suffix)||void 0===r?void 0:r.call(t))&&void 0!==a?a:e.isShowClear&&(0,l.createVNode)(d.Close,{class:"clear-icon",onClick:e.handleClear},null)])},content:function(){return(0,l.createVNode)("div",{class:"bk-selector-list"},[(0,l.createVNode)("ul",{ref:"selectorListRef",style:{"max-height":"".concat(e.contentMaxHeight,"px")},class:"outside-ul"},[e.renderList.map((function(t,r){return e.useGroup?(0,l.createVNode)("li",{class:"bk-selector-group-item"},[(0,l.createVNode)("span",{class:"group-name"},[t.name,(0,l.createTextVNode)(" ("),t.children.length,(0,l.createTextVNode)(")")]),(0,l.createVNode)("ul",{class:"bk-selector-group-list-item"},[t.children.map((function(t,r){return(0,l.createVNode)("li",{class:["bk-selector-list-item",{disabled:t.disabled},e.activeClass(t,r)],onClick:e.handleTagSelected.bind(e,t,"select")},[(0,l.createVNode)(m,{node:t,displayKey:e.displayKey,tpl:e.tpl,searchKey:e.searchKey,searchKeyword:e.curInputValue},null)])}))])]):(0,l.createVNode)("li",{class:["bk-selector-list-item",{disabled:t.disabled},e.activeClass(t,r)],onClick:e.handleTagSelected.bind(e,t,"select")},[(0,l.createVNode)(m,{node:t,displayKey:e.displayKey,tpl:e.tpl,searchKey:e.searchKey,searchKeyword:e.curInputValue},null)])})),e.isPageLoading?(0,l.createVNode)("li",{class:"bk-selector-list-item loading"},[(0,l.createVNode)(f(),{theme:"primary",size:p.BkLoadingSize.Small},null)]):null])])}})])}}),L=(0,e.withInstall)(T)})(),c})()));
|
1
|
+
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t(require("../shared"),require("vue"),require("lodash"),require("../directives"),require("../icon"),require("../loading"),require("../popover"));else if("function"==typeof define&&define.amd)define(["../shared","vue","lodash","../directives","../icon","../loading","../popover"],t);else{var r="object"==typeof exports?t(require("../shared"),require("vue"),require("lodash"),require("../directives"),require("../icon"),require("../loading"),require("../popover")):t(e["../shared"],e.vue,e.lodash,e["../directives"],e["../icon"],e["../loading"],e["../popover"]);for(var a in r)("object"==typeof exports?exports:e)[a]=r[a]}}(self,((e,t,r,a,o,n,l)=>(()=>{"use strict";var i={4061:e=>{e.exports=a},6870:e=>{e.exports=o},4870:e=>{e.exports=n},5537:e=>{e.exports=l},4212:t=>{t.exports=e},467:e=>{e.exports=r},748:e=>{e.exports=t}},s={};function u(e){var t=s[e];if(void 0!==t)return t.exports;var r=s[e]={exports:{}};return i[e](r,r.exports,u),r.exports}u.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return u.d(t,{a:t}),t},u.d=(e,t)=>{for(var r in t)u.o(t,r)&&!u.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},u.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),u.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var c={};return(()=>{u.r(c),u.d(c,{default:()=>w});var e=u(4212);function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},t(e)}function r(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,a=new Array(t);r<t;r++)a[r]=e[r];return a}function a(e,t){if(e){if("string"==typeof e)return r(e,t);var a=Object.prototype.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?r(e,t):void 0}}function o(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function n(e){return function(e){if(Array.isArray(e))return r(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||a(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}var l=u(748),i=u(467),s=u(4061),d=u(6870),p=u(4870),f=u.n(p),v=u(5537),g=u.n(v),h=12,y=function(e){for(var t=e.length,r=0,a=0;a<t;a++)0!=(65280&e.charCodeAt(a))&&(r+=1),r+=1;return r};const m=(0,l.defineComponent)({name:"ListTagRender",props:{node:e.PropTypes.object,searchKey:e.PropTypes.oneOfType([e.PropTypes.string,e.PropTypes.arrayOf(e.PropTypes.string)]),displayKey:e.PropTypes.string,searchKeyword:e.PropTypes.string,tpl:{type:Function}},render:function(){var e=this,t=function(t){if(e.searchKeyword){var r=new RegExp("(".concat(e.searchKeyword,")"),"i");return t.replace(r,'<strong class="highlight-text">$1</strong>')}return t};if(this.tpl)return this.tpl(this.node,t,l.h,this);var r=this.node[this.displayKey];return(0,l.createVNode)("div",{class:"bk-selector-node"},[(0,l.createVNode)("span",{class:"text",innerHTML:t(r)},[r])])}}),T=(0,l.defineComponent)({name:"TagRender",props:{node:e.PropTypes.object,displayKey:e.PropTypes.string,tpl:{type:Function}},render:function(){return this.tpl?this.tpl(this.node,l.h,this):(0,l.createVNode)("div",{class:"tag"},[(0,l.createVNode)("span",{class:"text"},[this.node[this.displayKey]])])}}),b=(0,l.defineComponent)({name:"TagInput",directives:{bkTooltips:s.bkTooltips},props:{modelValue:e.PropTypes.arrayOf(e.PropTypes.string).def([]),placeholder:e.PropTypes.string.def("请输入并按 Enter 结束"),list:e.PropTypes.arrayOf(e.PropTypes.object).def([]),disabled:e.PropTypes.bool.def(!1),tooltipKey:e.PropTypes.string.def(""),saveKey:e.PropTypes.string.def("id"),displayKey:e.PropTypes.string.def("name"),hasDeleteIcon:e.PropTypes.bool.def(!1),clearable:e.PropTypes.bool.def(!0),trigger:e.PropTypes.commonType(["focus","search"]).def("search"),searchKey:e.PropTypes.oneOfType([e.PropTypes.string,e.PropTypes.arrayOf(e.PropTypes.string)]).def("name"),useGroup:e.PropTypes.bool.def(!1),allowCreate:e.PropTypes.bool.def(!1),maxData:e.PropTypes.number.def(-1),maxResult:e.PropTypes.number.def(10),contentMaxHeight:e.PropTypes.number.def(300),contentWidth:e.PropTypes.number.def(190),separator:e.PropTypes.string.def(""),allowNextFocus:e.PropTypes.bool.def(!0),allowAutoMatch:e.PropTypes.bool.def(!1),showClearOnlyHover:e.PropTypes.bool.def(!1),leftSpace:e.PropTypes.number.def(0),createTagValidator:{type:Function},filterCallback:{type:Function},tagTpl:{type:Function},tpl:{type:Function},pasteFn:{type:Function},withValidate:{type:Boolean,default:!0},popoverProps:{type:Object,default:function(){return{}}},collapseTags:{type:Boolean,default:!1}},emits:["update:modelValue","change","select","blur","remove","removeAll"],setup:function(r,s){var u=s.emit,c=(0,e.useFormItem)(),d=(0,l.reactive)({isEdit:!1,isHover:!1,focusItemIndex:r.allowCreate?-1:0}),p=(0,l.reactive)(Object.assign({isShow:!1,width:190,modifiers:[{name:"offset",options:{offset:[0,4]}}]},r.popoverProps)),f=function(e){var t=(0,l.reactive)({curPage:1,totalSize:0,totalPage:0,pageSize:e,isPageLoading:!1,curPageList:[],renderListPaged:[]});return{pageState:t,initPage:function(){var e,r,a=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];t.curPage=1,t.totalSize=a.length,t.totalPage=Math.ceil(t.totalSize/t.pageSize)||1;var o=[];if(t.pageSize>0)for(var l=0;l<t.totalSize;l+=t.pageSize)o.push(a.slice(l,l+t.pageSize));(e=t.renderListPaged).splice.apply(e,[0,t.renderListPaged.length].concat(o)),(r=t.curPageList).splice.apply(r,[0,t.curPageList.length].concat(n(t.renderListPaged[t.curPage-1]||[])))},pageChange:function(e){var r;t.curPage=e,(r=t.curPageList).splice.apply(r,[t.curPageList.length,0].concat(n(t.renderListPaged[t.curPage-1]||[]))),t.isPageLoading=!1}}}((0,l.toRefs)(r).maxResult),v=f.pageState,g=f.initPage,m=f.pageChange,T=(0,l.ref)(""),b=(0,l.ref)(null),w=(0,l.ref)(null),L=(0,l.ref)(null),x=(0,l.ref)(null),P=(0,l.ref)(null),I=(0,l.ref)(null),C=(0,l.ref)(null),S=(0,l.computed)((function(){return!r.disabled&&r.hasDeleteIcon})),K=(0,l.computed)((function(){return 1===r.maxData})),V=(0,l.computed)((function(){return 0===O.selectedTagList.length&&""===T.value&&!d.isEdit})),k=(0,l.computed)((function(){return r.clearable&&!r.disabled&&0!==O.selectedTagList.length&&(!r.showClearOnlyHover||d.isHover)})),N=(0,l.computed)((function(){return{"bk-tag-input-trigger":!0,active:d.isEdit,disabled:r.disabled}})),O=(0,l.reactive)({localList:[],tagListCache:[],selectedTagList:[],selectedTagListCache:[]}),R=(0,l.computed)((function(){return O.selectedTagList.map((function(e){return e[r.saveKey]}))})),A=function(e){var t=(0,l.toRefs)(e),r=t.useGroup,a=t.saveKey,o=t.displayKey,n=t.list,i=(0,l.ref)([]),s=(0,l.ref)({});return(0,l.watch)([r,a,o,n],(function(){i.value=[];var e=(0,l.markRaw)(n.value);r.value&&(e=e.reduce((function(e,t){var r=[];return t.children&&(r=t.children.map((function(e){return Object.assign({group:{groupId:t[a.value],groupName:t[o.value]}},e)}))),e.concat(r)}),[])),i.value=e,s.value=e.reduce((function(e,t){return e[t[a.value]]=t,e}),{})}),{immediate:!0}),{flatList:i,saveKeyMap:s}}(r),j=A.flatList,E=A.saveKeyMap,D=(0,l.computed)((function(){if(r.useGroup){var e={};return v.curPageList.forEach((function(t,r){t.__index__=r,e[t.group.groupId]||(e[t.group.groupId]={id:t.group.groupId,name:t.group.groupName,children:[]}),e[t.group.groupId].children.push(t)})),Object.keys(e).map((function(t){return e[t]}))}return v.curPageList}));(0,l.watch)([function(){return j.value}],(function(){(0,l.nextTick)((function(){z()}))})),(0,l.watch)((function(){return r.modelValue}),(function(e){var t,a,o;o=e,(a=R.value).length===o.length&&o.every((function(e,t){return a[t]===e}))||((0,l.nextTick)((function(){z()})),r.withValidate&&(null===(t=null==c?void 0:c.validate)||void 0===t||t.call(c,"change")))})),(0,l.watch)(T,(0,i.debounce)((function(){var e=0!==v.curPageList.length,t=T.value;""!==t&&e||""===t&&"focus"===r.trigger&&e?p.isShow=!0:"focus"===r.trigger&&e||(p.isShow=!1)}),150)),(0,l.watch)((function(){return p.isShow}),(function(e){F(),e&&P.value&&((0,l.nextTick)((function(){P.value.scrollTop=0})),P.value.removeEventListener("scroll",q),P.value.addEventListener("scroll",q))})),(0,l.onMounted)((function(){z()}));var F=function(){var e,t,r=K.value?0:null===(e=x.value)||void 0===e?void 0:e.offsetLeft;p.modifiers=[{name:"offset",options:{offset:[r,4]}}],null===(t=I.value)||void 0===t||t.update()},q=function(){if(!v.isPageLoading&&0!==P.value.scrollTop){var e=P.value;if(e.scrollTop+e.offsetHeight>=e.scrollHeight){var t=v.curPage+1;t<=v.totalPage&&(v.isPageLoading=!0,setTimeout((function(){m(t)}),500))}}},M=function(){var e;return Array.from((null===(e=L.value)||void 0===e?void 0:e.childNodes)||[]).filter((function(e){return e.nodeType!==Node.TEXT_NODE}))},_=function(e){if(!r.disabled){if(null==e?void 0:e.target){var t=e.target.className;(t.indexOf("bk-tag-input-trigger")>-1||t.indexOf("tag-list")>-1)&&L.value.appendChild(x.value)}clearTimeout(C.value),K.value&&R.value.length&&(O.tagListCache=n(R.value),O.selectedTagListCache=n(O.selectedTagList),T.value=O.selectedTagListCache[0][r.saveKey],Y(O.selectedTagList[0],0),W()),d.isEdit=!0,(0,l.nextTick)((function(){var e;null===(e=b.value)||void 0===e||e.focus(),"focus"===r.trigger&&0!==O.localList.length&&(H(),p.isShow?F():p.isShow=!0)}))}},z=function(){var e=r.saveKey,t=r.modelValue,a=r.displayKey,n=r.allowCreate,l=r.trigger;if(O.selectedTagList=[],O.localList=j.value,t.length){var i={};O.selectedTagList=t.map((function(t){var r,l=E.value[t];return i[t]=1,!l&&n?(o(r={},e,t),o(r,a,t),r):l})).filter((function(e){return e})),K.value||(O.localList=O.localList.filter((function(t){return!i[t[e]]})))}"focus"===l&&H()},H=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"",t=r.searchKey,a=r.filterCallback,o=e.toLowerCase().trim();if(""!==o){var n=[];n="function"==typeof a?a(o,t,O.localList)||[]:Array.isArray(t)?O.localList.filter((function(e){return t.some((function(t){return e[t].toLowerCase().indexOf(o)>-1}))})):O.localList.filter((function(e){return e[t].toLowerCase().indexOf(o)>-1})),g(n)}else g(O.localList)},B=function(){T.value=""},G=function(){if(K.value)return 0;var e=M().findIndex((function(e){return"tagInputItem"===e.id}));return e>=0?e:0},U=function(e,t){var r=arguments.length>2&&void 0!==arguments[2]&&arguments[2];if(t&&e){var a=t;r&&(a=t.nextElementSibling||null),t.parentNode.insertBefore(e,a)}},W=function(e){var t=r.maxData,a=r.trigger,o=r.allowCreate;if(-1===t||t>R.value.length){var n=((null==e?void 0:e.target)?e.target:T).value,l=y(n);l?(H(n),b.value.style.width="".concat(l*h,"px")):"focus"===a&&H()}else $(),T.value="",p.isShow=!1;d.isEdit=!0,d.focusItemIndex=o?-1:0},$=function(){C.value=setTimeout((function(){var e,t,o,n=T.value;if(B(),d.isEdit=!1,K.value){var l=(t=O.tagListCache,o=1,function(e){if(Array.isArray(e))return e}(t)||function(e,t){var r=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=r){var a,o,n=[],l=!0,i=!1;try{for(r=r.call(e);!(l=(a=r.next()).done)&&(n.push(a.value),!t||n.length!==t);l=!0);}catch(e){i=!0,o=e}finally{try{l||null==r.return||r.return()}finally{if(i)throw o}}return n}}(t,o)||a(t,o)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0];n&&n===l&&O.selectedTagListCache.length?Q(O.selectedTagListCache[0],"select"):X("remove")}else if(r.allowAutoMatch&&n){var i=v.curPageList.find((function(e){return Array.isArray(r.searchKey)?r.searchKey.map((function(t){return e[t]})).includes(n):e[r.searchKey]===n}));i?Z(i,"select"):r.allowCreate&&Z(n,"custom")}p.isShow=!1,u("blur",n,R.value),null===(e=null==c?void 0:c.validate)||void 0===e||e.call(c,"blur")}),200)},Z=function(e,t,r){null==r||r.stopPropagation(),e&&!e.disabled&&(K.value&&(O.tagListCache=[],O.selectedTagListCache=[],O.selectedTagList=[]),Q(e,t),X("select"),B(),p.isShow=!1)},X=function(e,t){u("change",R.value),u(e,t),u("update:modelValue",R.value)},J=function(){var e=P.value.clientHeight,t=P.value.getBoundingClientRect().y;(0,l.nextTick)((function(){var r=P.value.querySelector(".bk-selector-actived");if(r){var a=r.clientHeight,o=r.getBoundingClientRect().y;o<t&&(P.value.scrollTop=P.value.scrollTop-(t-o));var n=o+a-t;n>e&&(P.value.scrollTop=P.value.scrollTop+n-e)}}))},Q=function(e,a){if(!(O.selectedTagList.length>=r.maxData&&-1!==r.maxData)){var i,s=r.separator,u=r.saveKey,c=r.displayKey,d=r.createTagValidator,p=G(),f=1,v=!1,g=function(e){return"function"!=typeof d||d(e)};if("custom"===a)if(s){var y,m=e.split(s),T=(m=m.filter((function(e){return(null==e?void 0:e.trim())&&!R.value.includes(e)&&g(e)}))).map((function(e){var t;return E.value[e]||(o(t={},u,e),o(t,c,e),t)}));m.length&&((y=O.selectedTagList).splice.apply(y,[p,0].concat(n(T))),f=T.length,v=!0)}else{var w="object"===t(e);if(void 0!==(i=(i=w?e[u]:e.trim()).replace(/\s+/g,""))&&!R.value.includes(i)&&g(i)){var L,P=E.value[i]||(w?e:(o(L={},u,i),o(L,c,i),L));O.selectedTagList.splice(p,0,P),v=!0}}else e&&(void 0===(i=e[u])||R.value.includes(i)||(O.selectedTagList.splice(p,0,e),v=!0));v&&(0,l.nextTick)((function(){for(var e=1;e<=f;e++){var t=M()[p+e];U(t,x.value)}if(b.value.style.width="".concat(h,"px"),!K.value){r.allowNextFocus&&_();var a=R.value.reduce((function(e,t){return e[t]=1,e}),{});O.localList=O.localList.filter((function(e){return!a[e[u]]}))}}))}},Y=function(e,t){O.selectedTagList.splice(t,1);var a=E.value[e[r.saveKey]];(r.allowCreate&&a||!r.allowCreate)&&!K.value&&O.localList.push(e)},ee=(0,l.computed)((function(){return r.collapseTags?r.collapseTags&&!d.isEdit:r.collapseTags})),te=function(e,t,r){(0,l.watch)([r,t],(function(){o()}),{flush:"post"});var a=(0,l.ref)(null),o=function(){t.value&&(a.value=null,setTimeout((function(){var t=Array.from(e.value.querySelectorAll(".tag-item")),r=t.findIndex((function(e,r){return!!r&&t[r-1].offsetTop!==e.offsetTop}));a.value=r>0?r-1:null})))};return{overflowTagIndex:a}}(w,ee,R),re=te.overflowTagIndex;return Object.assign(Object.assign(Object.assign(Object.assign({popoverProps:p},(0,l.toRefs)(d)),(0,l.toRefs)(O)),(0,l.toRefs)(v)),{isShowPlaceholder:V,isShowClear:k,curInputValue:T,renderList:D,showTagClose:S,tagInputRef:b,bkTagSelectorRef:w,tagListRef:L,tagInputItemRef:x,selectorListRef:P,popoverRef:I,triggerClass:N,overflowTagIndex:re,localCollapseTags:ee,focusInputTrigger:_,activeClass:function(e,t){var a={"bk-selector-actived":!1,"bk-selector-selected":R.value.includes(e[r.saveKey])};return r.useGroup?a["bk-selector-actived"]=e.__index__===d.focusItemIndex:a["bk-selector-actived"]=t===d.focusItemIndex,a},handleInput:W,handleFocus:function(){var e;p.width=K.value?null===(e=w.value)||void 0===e?void 0:e.clientWidth:r.contentWidth},handleBlur:$,handleTagSelected:Z,handleTagRemove:function(e,t,r){null==r||r.stopPropagation(),Y(e,t),B(),X("remove",e),b.value.style.width="".concat(h,"px")},handleClear:function(e){e.stopPropagation();var t=O.selectedTagList;O.selectedTagList=[];var a,o=t.filter((function(e){return E.value[e[r.saveKey]]}));(!r.allowCreate||0===o.length)&&r.allowCreate||K.value||(a=O.localList).push.apply(a,n(o)),X("removeAll")},tagFocus:function(e){r.disabled||(U(x.value,e.currentTarget,!0),b.value.style.width="".concat(h,"px"),p.isShow&&F())},handleKeydown:function(e){if(!v.isPageLoading){var t=e.target.value,a=y(t),o=G(),n=M();switch(e.code){case"ArrowUp":if(e.preventDefault(),!p.isShow)return;d.focusItemIndex=d.focusItemIndex-1,d.focusItemIndex=d.focusItemIndex<0?-1:d.focusItemIndex,-1===d.focusItemIndex&&(d.focusItemIndex=v.curPageList.length-1),J();break;case"ArrowDown":if(e.preventDefault(),!p.isShow)return;d.focusItemIndex=d.focusItemIndex+1,d.focusItemIndex=d.focusItemIndex>v.curPageList.length-1?v.curPageList.length:d.focusItemIndex,d.focusItemIndex===v.curPageList.length&&(d.focusItemIndex=0),J();break;case"ArrowLeft":if(d.isEdit=!0,!a){if(o<1)return;U(x.value,n[o-1]),_()}break;case"ArrowRight":if(d.isEdit=!0,!a){if(o===n.length-1)return;U(n[o+1],x.value),_()}break;case"Enter":case"NumpadEnter":!r.allowCreate&&p.isShow||r.allowCreate&&d.focusItemIndex>=0&&p.isShow?Z(v.curPageList[d.focusItemIndex],"select",e):r.allowCreate&&Z(T.value,"custom",e),e.preventDefault();break;case"Backspace":0===o||T.value||function(e,t){var a=M();U(x.value,a[e-1]),O.selectedTagList.splice(e-1,1),_();var o=E.value[t[r.saveKey]];(r.allowCreate&&o||!r.allowCreate)&&!K.value&&O.localList.push(t),b.value="".concat(h,"px"),X("remove")}(o,O.selectedTagList[o-1])}}},handlePaste:function(e){if(e.preventDefault(),K.value)return!1;var t=r.maxData,a=r.saveKey,l=r.displayKey,i=r.pasteFn,s=r.allowCreate,u=e.clipboardData.getData("text"),c=i?i(u):function(e){var t=[],a=e.split(";"),n=/^[a-zA-Z][a-zA-Z_]*/g;return a.forEach((function(e){var a=e.match(n);if(a){var l,i=a.join("");t.push((o(l={},r.saveKey,i),o(l,r.displayKey,i),l))}})),t}(u),d=c.map((function(e){return e[a]}));if(d.length){var p=M(),f=G(),v=O.localList.map((function(e){return e[a]}));if(d=d.filter((function(e){var t=(null==e?void 0:e.trim())&&!R.value.includes(e);return s?t:t&&v.includes(e)})),-1!==t){var g=O.selectedTagList.length;if(g<t){var y=t-g;d.length>y&&(d=n(d.slice(0,y)))}else d=[]}var m,T=s?d.map((function(e){var t,r=O.localList.find((function(t){return t[a]===e}));return null!=r?r:(o(t={},a,e),o(t,l,e),t)})):O.localList.filter((function(e){return d.includes(e[a])}));d.length&&((m=O.selectedTagList).splice.apply(m,[f,0].concat(n(T))),U(x.value,p[f]),b.value.style.width="".concat(h,"px"),O.localList=O.localList.filter((function(e){return!d.includes(e[a])})),X("select"),_())}}})},render:function(){var e=this;return(0,l.createVNode)("div",{class:"bk-tag-input",ref:"bkTagSelectorRef",onClick:this.focusInputTrigger,onMouseenter:function(){return e.isHover=!0},onMouseleave:function(){return e.isHover=!1}},[(0,l.createVNode)(g(),(0,l.mergeProps)({ref:"popoverRef",theme:"light",trigger:"manual",placement:"bottom-start","content-cls":"bk-tag-input-popover-content",arrow:!1},this.popoverProps),{default:function(){var t,r,a;return(0,l.createVNode)("div",{class:e.triggerClass},[(0,l.createVNode)("ul",{class:"tag-list",ref:"tagListRef",style:{marginLeft:"".concat(e.leftSpace,"px")}},[e.selectedTagList.map((function(t,r){var a={boundary:"window",theme:"light",distance:12,content:t[e.tooltipKey],disabled:!e.tooltipKey},o=e.localCollapseTags&&e.overflowTagIndex&&r>=e.overflowTagIndex;return(0,l.withDirectives)((0,l.createVNode)("li",{class:"tag-item",style:{display:o?"none":""},onClick:e.tagFocus},[(0,l.createVNode)(T,{node:t,tpl:e.tagTpl,displayKey:e.displayKey},null),e.showTagClose?(0,l.createVNode)(d.Error,{class:"remove-tag",onClick:e.handleTagRemove.bind(e,t,r)},null):null]),[[(0,l.resolveDirective)("bk-tooltips"),a]])})),(0,l.withDirectives)((0,l.createVNode)("li",{ref:"tagInputItemRef",id:"tagInputItem",class:"tag-input-item",role:"input"},[(0,l.withDirectives)((0,l.createVNode)("input",{type:"text",class:"tag-input",ref:"tagInputRef","onUpdate:modelValue":function(t){return e.curInputValue=t},onInput:e.handleInput,onFocus:e.handleFocus,onBlur:e.handleBlur,onKeydown:e.handleKeydown,onPaste:e.handlePaste},null),[[l.vModelText,e.curInputValue]])]),[[l.vShow,e.isEdit]]),!!e.overflowTagIndex&&e.localCollapseTags&&(0,l.createVNode)("li",{class:"tag-item"},[(0,l.createVNode)("div",{class:"tag"},[(0,l.createVNode)("span",{class:"text"},[(0,l.createTextVNode)("+"),e.selectedTagList.length-e.overflowTagIndex])])])]),(0,l.withDirectives)((0,l.createVNode)("p",{class:"placeholder"},[e.placeholder]),[[l.vShow,e.isShowPlaceholder]]),null!==(a=null===(r=null===(t=e.$slots)||void 0===t?void 0:t.suffix)||void 0===r?void 0:r.call(t))&&void 0!==a?a:e.isShowClear&&(0,l.createVNode)(d.Close,{class:"clear-icon",onClick:e.handleClear},null)])},content:function(){return(0,l.createVNode)("div",{class:"bk-selector-list"},[(0,l.createVNode)("ul",{ref:"selectorListRef",style:{"max-height":"".concat(e.contentMaxHeight,"px")},class:"outside-ul"},[e.renderList.map((function(t,r){return e.useGroup?(0,l.createVNode)("li",{class:"bk-selector-group-item"},[(0,l.createVNode)("span",{class:"group-name"},[t.name,(0,l.createTextVNode)(" ("),t.children.length,(0,l.createTextVNode)(")")]),(0,l.createVNode)("ul",{class:"bk-selector-group-list-item"},[t.children.map((function(t,r){return(0,l.createVNode)("li",{class:["bk-selector-list-item",{disabled:t.disabled},e.activeClass(t,r)],onClick:e.handleTagSelected.bind(e,t,"select")},[(0,l.createVNode)(m,{node:t,displayKey:e.displayKey,tpl:e.tpl,searchKey:e.searchKey,searchKeyword:e.curInputValue},null)])}))])]):(0,l.createVNode)("li",{class:["bk-selector-list-item",{disabled:t.disabled},e.activeClass(t,r)],onClick:e.handleTagSelected.bind(e,t,"select")},[(0,l.createVNode)(m,{node:t,displayKey:e.displayKey,tpl:e.tpl,searchKey:e.searchKey,searchKeyword:e.curInputValue},null)])})),e.isPageLoading?(0,l.createVNode)("li",{class:"bk-selector-list-item loading"},[(0,l.createVNode)(f(),{theme:"primary",size:p.BkLoadingSize.Small},null)]):null])])}})])}}),w=(0,e.withInstall)(b)})(),c})()));
|
@@ -215,6 +215,10 @@ declare const _default: import("vue").DefineComponent<{
|
|
215
215
|
}>>>>;
|
216
216
|
default: () => {};
|
217
217
|
};
|
218
|
+
collapseTags: {
|
219
|
+
type: BooleanConstructor;
|
220
|
+
default: boolean;
|
221
|
+
};
|
218
222
|
}, {
|
219
223
|
isShowPlaceholder: import("vue").ComputedRef<boolean>;
|
220
224
|
isShowClear: import("vue").ComputedRef<boolean>;
|
@@ -232,6 +236,8 @@ declare const _default: import("vue").DefineComponent<{
|
|
232
236
|
active: boolean;
|
233
237
|
disabled: boolean;
|
234
238
|
}>;
|
239
|
+
overflowTagIndex: Ref<number>;
|
240
|
+
localCollapseTags: import("vue").ComputedRef<boolean>;
|
235
241
|
focusInputTrigger: (e?: MouseEvent) => void;
|
236
242
|
activeClass: (data: any, index: number) => {
|
237
243
|
'bk-selector-actived': boolean;
|
@@ -486,6 +492,10 @@ declare const _default: import("vue").DefineComponent<{
|
|
486
492
|
}>>>>;
|
487
493
|
default: () => {};
|
488
494
|
};
|
495
|
+
collapseTags: {
|
496
|
+
type: BooleanConstructor;
|
497
|
+
default: boolean;
|
498
|
+
};
|
489
499
|
}>> & {
|
490
500
|
onBlur?: (...args: any[]) => any;
|
491
501
|
onChange?: (...args: any[]) => any;
|
@@ -507,6 +517,7 @@ declare const _default: import("vue").DefineComponent<{
|
|
507
517
|
withValidate: boolean;
|
508
518
|
searchKey: string | string[];
|
509
519
|
allowCreate: boolean;
|
520
|
+
collapseTags: boolean;
|
510
521
|
displayKey: string;
|
511
522
|
tooltipKey: string;
|
512
523
|
saveKey: string;
|
@@ -207,6 +207,10 @@ declare const tagProps: () => {
|
|
207
207
|
}>>>>;
|
208
208
|
default: () => {};
|
209
209
|
};
|
210
|
+
collapseTags: {
|
211
|
+
type: BooleanConstructor;
|
212
|
+
default: boolean;
|
213
|
+
};
|
210
214
|
};
|
211
215
|
export default tagProps;
|
212
216
|
export declare type TagProps = Partial<ExtractPropTypes<ReturnType<typeof tagProps>>>;
|