bkui-vue 0.0.1-beta.26 → 0.0.1-beta.29
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/bkui-vue.cjs.js +991 -46
- package/dist/bkui-vue.esm.js +991 -47
- package/dist/bkui-vue.umd.js +991 -46
- package/dist/style.css +224 -10
- package/lib/components.d.ts +1 -0
- package/lib/pagination/index.d.ts +3 -3
- package/lib/pagination/index.js +1 -1
- package/lib/pagination/pagination.d.ts +1 -1
- package/lib/pagination/type.d.ts +1 -1
- package/lib/select/select.css +6 -6
- package/lib/select/select.less +12 -7
- package/lib/select/select.variable.css +6 -6
- package/lib/styles/index.d.ts +1 -0
- package/lib/styles/index.js +1 -1
- package/lib/tag/index.js +1 -1
- package/lib/tag/tag.css +10 -4
- package/lib/tag/tag.less +11 -4
- package/lib/tag/tag.variable.css +10 -4
- package/lib/tag-input/common.d.ts +24 -0
- package/lib/tag-input/index.d.ts +2 -0
- package/lib/tag-input/index.js +1 -0
- package/lib/tag-input/list-tag-render.d.ts +47 -0
- package/lib/tag-input/tag-input.css +208 -0
- package/lib/tag-input/tag-input.d.ts +374 -0
- package/lib/tag-input/tag-input.less +250 -0
- package/lib/tag-input/tag-input.variable.css +301 -0
- package/lib/tag-input/tag-props.d.ts +131 -0
- package/lib/tag-input/tag-render.d.ts +38 -0
- package/lib/tree/index.js +1 -1
- package/package.json +1 -1
package/dist/bkui-vue.umd.js
CHANGED
@@ -82,6 +82,7 @@ var __publicField = (obj, key, value) => {
|
|
82
82
|
var pagination = "";
|
83
83
|
var timeline = "";
|
84
84
|
var resizeLayout = "";
|
85
|
+
var tagInput = "";
|
85
86
|
const BKLAYERD_INDEX_EFAULT_VALUE = {
|
86
87
|
["bottom"]: 0,
|
87
88
|
["content"]: 1,
|
@@ -10373,7 +10374,7 @@ ${$(r2)}`), n2;
|
|
10373
10374
|
unregister
|
10374
10375
|
};
|
10375
10376
|
}
|
10376
|
-
function useDebouncedRef(value, delay = 200) {
|
10377
|
+
function useDebouncedRef$1(value, delay = 200) {
|
10377
10378
|
let timeout;
|
10378
10379
|
let innerValue = value;
|
10379
10380
|
return vue.customRef((track, trigger) => ({
|
@@ -10417,7 +10418,7 @@ ${$(r2)}`), n2;
|
|
10417
10418
|
};
|
10418
10419
|
}
|
10419
10420
|
function useRemoteSearch(method) {
|
10420
|
-
const searchKey = useDebouncedRef("");
|
10421
|
+
const searchKey = useDebouncedRef$1("");
|
10421
10422
|
const searchLoading = vue.ref(false);
|
10422
10423
|
vue.watch(searchKey, async () => {
|
10423
10424
|
searchLoading.value = true;
|
@@ -11019,7 +11020,9 @@ ${$(r2)}`), n2;
|
|
11019
11020
|
"onClick": this.handleClick
|
11020
11021
|
}, [this.$slots.icon ? vue.createVNode("span", {
|
11021
11022
|
"class": "bk-tag-icon"
|
11022
|
-
}, [this.$slots.icon()]) : "", vue.createVNode("span",
|
11023
|
+
}, [this.$slots.icon()]) : "", vue.createVNode("span", {
|
11024
|
+
"class": "bk-tag-text"
|
11025
|
+
}, [(_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a)]), this.closable ? vue.createVNode(error, {
|
11023
11026
|
"class": "bk-tag-close",
|
11024
11027
|
"onClick": this.handleClose
|
11025
11028
|
}, null) : ""]);
|
@@ -12046,27 +12049,27 @@ ${$(r2)}`), n2;
|
|
12046
12049
|
const {
|
12047
12050
|
proxy
|
12048
12051
|
} = vue.getCurrentInstance();
|
12049
|
-
const localCurrent = vue.ref(
|
12052
|
+
const localCurrent = vue.ref(1);
|
12050
12053
|
const isPagePreDisabled = vue.computed(() => localCurrent.value === 1);
|
12051
|
-
const isPageNextDisabled = vue.computed(() => localCurrent.value === proxy.
|
12054
|
+
const isPageNextDisabled = vue.computed(() => localCurrent.value === proxy.totalPageNum);
|
12052
12055
|
const showPreBatch = vue.ref(false);
|
12053
12056
|
const showNextBatch = vue.ref(false);
|
12054
12057
|
const list = vue.computed(() => {
|
12055
12058
|
showPreBatch.value = false;
|
12056
12059
|
showNextBatch.value = false;
|
12057
12060
|
const stack = [];
|
12058
|
-
if (proxy.
|
12059
|
-
for (let i2 = 2; i2 <= proxy.
|
12061
|
+
if (proxy.totalPageNum <= PAGE_ITEMS_NUM) {
|
12062
|
+
for (let i2 = 2; i2 <= proxy.totalPageNum - 1; i2++) {
|
12060
12063
|
stack.push(i2);
|
12061
12064
|
}
|
12062
12065
|
return stack;
|
12063
12066
|
}
|
12064
12067
|
const pageItemsNumHalf = Math.floor(PAGE_ITEMS_NUM / 2);
|
12065
|
-
if (proxy.
|
12068
|
+
if (proxy.totalPageNum > PAGE_ITEMS_NUM) {
|
12066
12069
|
showPreBatch.value = localCurrent.value - pageItemsNumHalf > 2;
|
12067
|
-
showNextBatch.value = localCurrent.value + pageItemsNumHalf < proxy.
|
12070
|
+
showNextBatch.value = localCurrent.value + pageItemsNumHalf < proxy.totalPageNum - 1;
|
12068
12071
|
}
|
12069
|
-
const start2 = Math.min(proxy.
|
12072
|
+
const start2 = Math.min(proxy.totalPageNum - PAGE_ITEMS_NUM, Math.max(2, localCurrent.value - pageItemsNumHalf));
|
12070
12073
|
for (let i2 = start2; i2 < start2 + PAGE_ITEMS_NUM; i2++) {
|
12071
12074
|
stack.push(i2);
|
12072
12075
|
}
|
@@ -12074,19 +12077,19 @@ ${$(r2)}`), n2;
|
|
12074
12077
|
});
|
12075
12078
|
vue.watch(() => proxy.modelValue, (modelValue) => {
|
12076
12079
|
vue.nextTick(() => {
|
12077
|
-
if (modelValue >= 1 && modelValue <= proxy.
|
12080
|
+
if (modelValue >= 1 && modelValue <= proxy.totalPageNum) {
|
12078
12081
|
localCurrent.value = modelValue;
|
12079
12082
|
} else if (modelValue < 1) {
|
12080
12083
|
localCurrent.value = 1;
|
12081
12084
|
} else {
|
12082
|
-
localCurrent.value = proxy.
|
12085
|
+
localCurrent.value = proxy.totalPageNum;
|
12083
12086
|
}
|
12084
12087
|
});
|
12085
12088
|
});
|
12086
12089
|
vue.nextTick(() => {
|
12087
|
-
vue.watch(() => proxy.
|
12088
|
-
if (localCurrent.value >
|
12089
|
-
localCurrent.value =
|
12090
|
+
vue.watch(() => proxy.totalPageNum, (totalPageNum) => {
|
12091
|
+
if (localCurrent.value > totalPageNum) {
|
12092
|
+
localCurrent.value = totalPageNum;
|
12090
12093
|
}
|
12091
12094
|
});
|
12092
12095
|
});
|
@@ -12102,17 +12105,17 @@ ${$(r2)}`), n2;
|
|
12102
12105
|
}
|
12103
12106
|
localCurrent.value = localCurrent.value + 1;
|
12104
12107
|
};
|
12105
|
-
const handleItemClick = (
|
12106
|
-
if (
|
12108
|
+
const handleItemClick = (totalPageNum) => {
|
12109
|
+
if (totalPageNum === localCurrent.value) {
|
12107
12110
|
return;
|
12108
12111
|
}
|
12109
|
-
localCurrent.value =
|
12112
|
+
localCurrent.value = totalPageNum;
|
12110
12113
|
};
|
12111
12114
|
const handlePreBatch = () => {
|
12112
12115
|
localCurrent.value = Math.max(1, localCurrent.value - PAGE_ITEMS_NUM);
|
12113
12116
|
};
|
12114
12117
|
const handleNextBatch = () => {
|
12115
|
-
localCurrent.value = Math.min(proxy.
|
12118
|
+
localCurrent.value = Math.min(proxy.totalPageNum, localCurrent.value + PAGE_ITEMS_NUM);
|
12116
12119
|
};
|
12117
12120
|
const render = ({
|
12118
12121
|
isFirst,
|
@@ -12151,14 +12154,14 @@ ${$(r2)}`), n2;
|
|
12151
12154
|
"key": "next-batch",
|
12152
12155
|
"class": "bk-pagination-list-next-batch",
|
12153
12156
|
"onClick": handleNextBatch
|
12154
|
-
}, [vue.createVNode(ellipsis, null, null)]), proxy.
|
12157
|
+
}, [vue.createVNode(ellipsis, null, null)]), proxy.totalPageNum > 1 && vue.createVNode("div", {
|
12155
12158
|
"class": {
|
12156
12159
|
"bk-pagination-list-item": true,
|
12157
|
-
"is-active": localCurrent.value === proxy.
|
12160
|
+
"is-active": localCurrent.value === proxy.totalPageNum
|
12158
12161
|
},
|
12159
12162
|
"key": "last",
|
12160
|
-
"onClick": () => handleItemClick(proxy.
|
12161
|
-
}, [proxy.
|
12163
|
+
"onClick": () => handleItemClick(proxy.totalPageNum)
|
12164
|
+
}, [proxy.totalPageNum]), vue.createVNode("div", {
|
12162
12165
|
"class": {
|
12163
12166
|
"bk-pagination-list-pre": true,
|
12164
12167
|
"is-disabled": isPageNextDisabled.value
|
@@ -12178,23 +12181,23 @@ ${$(r2)}`), n2;
|
|
12178
12181
|
const isFocused = vue.ref(false);
|
12179
12182
|
const localCurrent = vue.ref(1);
|
12180
12183
|
const isPagePreDisabled = vue.computed(() => localCurrent.value === 1);
|
12181
|
-
const isPageNextDisabled = vue.computed(() => localCurrent.value === proxy.
|
12184
|
+
const isPageNextDisabled = vue.computed(() => localCurrent.value === proxy.totalPageNum);
|
12182
12185
|
let inputMemo = 0;
|
12183
12186
|
const list = vue.computed(() => {
|
12184
12187
|
const stack = [];
|
12185
|
-
for (let i2 = 1; i2 <= proxy.
|
12188
|
+
for (let i2 = 1; i2 <= proxy.totalPageNum; i2++) {
|
12186
12189
|
stack.push(i2);
|
12187
12190
|
}
|
12188
12191
|
return stack;
|
12189
12192
|
});
|
12190
12193
|
vue.watch(() => proxy.modelValue, (modelValue) => {
|
12191
12194
|
vue.nextTick(() => {
|
12192
|
-
if (modelValue >= 1 && modelValue <= proxy.
|
12195
|
+
if (modelValue >= 1 && modelValue <= proxy.totalPageNum) {
|
12193
12196
|
localCurrent.value = modelValue;
|
12194
12197
|
} else if (modelValue < 1) {
|
12195
12198
|
localCurrent.value = 1;
|
12196
12199
|
} else {
|
12197
|
-
localCurrent.value = proxy.
|
12200
|
+
localCurrent.value = proxy.totalPageNum;
|
12198
12201
|
}
|
12199
12202
|
inputMemo = localCurrent.value;
|
12200
12203
|
});
|
@@ -12202,9 +12205,9 @@ ${$(r2)}`), n2;
|
|
12202
12205
|
immediate: true
|
12203
12206
|
});
|
12204
12207
|
vue.nextTick(() => {
|
12205
|
-
vue.watch(() => proxy.
|
12206
|
-
if (localCurrent.value >
|
12207
|
-
localCurrent.value =
|
12208
|
+
vue.watch(() => proxy.totalPageNum, (totalPageNum) => {
|
12209
|
+
if (localCurrent.value > totalPageNum) {
|
12210
|
+
localCurrent.value = totalPageNum;
|
12208
12211
|
}
|
12209
12212
|
});
|
12210
12213
|
});
|
@@ -12241,7 +12244,7 @@ ${$(r2)}`), n2;
|
|
12241
12244
|
const handlePageEditorInput = (event) => {
|
12242
12245
|
const $target = event.target;
|
12243
12246
|
const value = Number($target.textContent);
|
12244
|
-
if (!value || value < 1 || value > proxy.
|
12247
|
+
if (!value || value < 1 || value > proxy.totalPageNum || value === localCurrent.value) {
|
12245
12248
|
return;
|
12246
12249
|
}
|
12247
12250
|
inputMemo = value;
|
@@ -12289,7 +12292,7 @@ ${$(r2)}`), n2;
|
|
12289
12292
|
"onKeydown": handlePageEditorKeydown
|
12290
12293
|
}, [localCurrent.value]), vue.createVNode("span", null, [vue.createTextVNode("/")]), vue.createVNode("span", {
|
12291
12294
|
"class": "bk-pagination-small-list-total"
|
12292
|
-
}, [proxy.
|
12295
|
+
}, [proxy.totalPageNum])]),
|
12293
12296
|
content: () => vue.createVNode("div", {
|
12294
12297
|
"class": "bk-pagination-picker-list"
|
12295
12298
|
}, [list.value.map((item) => vue.createVNode("div", {
|
@@ -12363,7 +12366,7 @@ ${$(r2)}`), n2;
|
|
12363
12366
|
props: paginationProps,
|
12364
12367
|
emits: ["update:modelValue", "change", "update:limit", "limit-change"],
|
12365
12368
|
setup(props, context) {
|
12366
|
-
const
|
12369
|
+
const totalPageNum = vue.ref(0);
|
12367
12370
|
const {
|
12368
12371
|
count,
|
12369
12372
|
limit
|
@@ -12382,7 +12385,8 @@ ${$(r2)}`), n2;
|
|
12382
12385
|
render: renderLimit
|
12383
12386
|
} = useLimit();
|
12384
12387
|
vue.watch([count, localLimit, limit], ([count2, localLimit2]) => {
|
12385
|
-
|
12388
|
+
const total = Math.ceil(count2 / localLimit2);
|
12389
|
+
totalPageNum.value = total < 1 ? 1 : total;
|
12386
12390
|
}, {
|
12387
12391
|
immediate: true
|
12388
12392
|
});
|
@@ -12398,7 +12402,7 @@ ${$(r2)}`), n2;
|
|
12398
12402
|
context.emit("limit-change", localLimit2);
|
12399
12403
|
});
|
12400
12404
|
return {
|
12401
|
-
|
12405
|
+
totalPageNum,
|
12402
12406
|
renderTotal,
|
12403
12407
|
renderList,
|
12404
12408
|
renderLimit,
|
@@ -12413,7 +12417,7 @@ ${$(r2)}`), n2;
|
|
12413
12417
|
});
|
12414
12418
|
const layoutMap = {
|
12415
12419
|
total: this.renderTotal,
|
12416
|
-
list: this.renderList,
|
12420
|
+
list: this.small ? this.renderSmallList : this.renderList,
|
12417
12421
|
limit: this.renderLimit
|
12418
12422
|
};
|
12419
12423
|
return vue.createVNode("div", {
|
@@ -12421,7 +12425,7 @@ ${$(r2)}`), n2;
|
|
12421
12425
|
}, [this.layout.map((layout, index) => layoutMap[layout]({
|
12422
12426
|
isFirst: index === 0,
|
12423
12427
|
isLast: index === this.layout.length - 1
|
12424
|
-
}))
|
12428
|
+
}))]);
|
12425
12429
|
}
|
12426
12430
|
});
|
12427
12431
|
const BkPagination = withInstall(Component$5);
|
@@ -12825,6 +12829,939 @@ ${$(r2)}`), n2;
|
|
12825
12829
|
}
|
12826
12830
|
});
|
12827
12831
|
const BkTable = withInstall(Component$4);
|
12832
|
+
const INPUT_MIN_WIDTH = 12;
|
12833
|
+
function useDebouncedRef(value, delay = 200) {
|
12834
|
+
let timeout;
|
12835
|
+
let innerValue = value;
|
12836
|
+
return vue.customRef((track, trigger) => ({
|
12837
|
+
get() {
|
12838
|
+
track();
|
12839
|
+
return innerValue;
|
12840
|
+
},
|
12841
|
+
set(newValue) {
|
12842
|
+
clearTimeout(timeout);
|
12843
|
+
timeout = setTimeout(() => {
|
12844
|
+
innerValue = newValue;
|
12845
|
+
trigger();
|
12846
|
+
}, delay);
|
12847
|
+
}
|
12848
|
+
}));
|
12849
|
+
}
|
12850
|
+
function usePage(pageSize) {
|
12851
|
+
const state = vue.reactive({
|
12852
|
+
curPage: 1,
|
12853
|
+
totalSize: 0,
|
12854
|
+
totalPage: 0,
|
12855
|
+
pageSize,
|
12856
|
+
isPageLoading: false,
|
12857
|
+
curPageList: [],
|
12858
|
+
renderListPaged: []
|
12859
|
+
});
|
12860
|
+
const initPage = (allList = []) => {
|
12861
|
+
state.curPage = 1;
|
12862
|
+
state.totalSize = allList.length;
|
12863
|
+
state.totalPage = Math.ceil(state.totalSize / state.pageSize) || 1;
|
12864
|
+
const list = [];
|
12865
|
+
if (state.pageSize > 0) {
|
12866
|
+
for (let i2 = 0; i2 < state.totalSize; i2 += state.pageSize) {
|
12867
|
+
list.push(allList.slice(i2, i2 + state.pageSize));
|
12868
|
+
}
|
12869
|
+
}
|
12870
|
+
state.renderListPaged.splice(0, state.renderListPaged.length, ...list);
|
12871
|
+
state.curPageList.splice(0, state.curPageList.length, ...state.renderListPaged[state.curPage - 1] || []);
|
12872
|
+
};
|
12873
|
+
const pageChange = (page) => {
|
12874
|
+
state.curPage = page;
|
12875
|
+
state.curPageList.splice(state.curPageList.length, 0, ...state.renderListPaged[state.curPage - 1] || []);
|
12876
|
+
state.isPageLoading = false;
|
12877
|
+
};
|
12878
|
+
return {
|
12879
|
+
pageState: state,
|
12880
|
+
initPage,
|
12881
|
+
pageChange
|
12882
|
+
};
|
12883
|
+
}
|
12884
|
+
function useFlatList(props) {
|
12885
|
+
const {
|
12886
|
+
useGroup,
|
12887
|
+
saveKey,
|
12888
|
+
displayKey,
|
12889
|
+
list
|
12890
|
+
} = vue.toRefs(props);
|
12891
|
+
const flatList = vue.reactive([]);
|
12892
|
+
vue.watch([useGroup, saveKey, displayKey, list], () => {
|
12893
|
+
let formatList = list.value;
|
12894
|
+
if (useGroup.value) {
|
12895
|
+
formatList = list.value.reduce((formatList2, item) => {
|
12896
|
+
let children = [];
|
12897
|
+
if (item.children) {
|
12898
|
+
children = item.children.map((child) => __spreadValues({
|
12899
|
+
group: {
|
12900
|
+
groupId: item[saveKey.value],
|
12901
|
+
groupName: item[displayKey.value]
|
12902
|
+
}
|
12903
|
+
}, child));
|
12904
|
+
}
|
12905
|
+
return formatList2.concat(children);
|
12906
|
+
}, []);
|
12907
|
+
}
|
12908
|
+
flatList.splice(0, flatList.length, ...formatList);
|
12909
|
+
}, { immediate: true, deep: true });
|
12910
|
+
return flatList;
|
12911
|
+
}
|
12912
|
+
const getCharLength = (str) => {
|
12913
|
+
const len = str.length;
|
12914
|
+
let bitLen = 0;
|
12915
|
+
for (let i2 = 0; i2 < len; i2++) {
|
12916
|
+
if ((str.charCodeAt(i2) & 65280) !== 0) {
|
12917
|
+
bitLen += 1;
|
12918
|
+
}
|
12919
|
+
bitLen += 1;
|
12920
|
+
}
|
12921
|
+
return bitLen;
|
12922
|
+
};
|
12923
|
+
var ListTagRender = vue.defineComponent({
|
12924
|
+
name: "ListTagRender",
|
12925
|
+
props: {
|
12926
|
+
node: PropTypes.object,
|
12927
|
+
searchKey: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]),
|
12928
|
+
displayKey: PropTypes.string,
|
12929
|
+
searchKeyword: PropTypes.string,
|
12930
|
+
tpl: {
|
12931
|
+
type: Function,
|
12932
|
+
default: null
|
12933
|
+
}
|
12934
|
+
},
|
12935
|
+
render() {
|
12936
|
+
const highlightKeyword = (value) => {
|
12937
|
+
if (this.searchKeyword) {
|
12938
|
+
const keywordReg = new RegExp(`(${this.searchKeyword})`, "i");
|
12939
|
+
return value.replace(keywordReg, '<strong class="highlight-text">$1</strong>');
|
12940
|
+
}
|
12941
|
+
return value;
|
12942
|
+
};
|
12943
|
+
if (this.tpl) {
|
12944
|
+
return this.tpl(this.node, highlightKeyword, vue.h, this);
|
12945
|
+
}
|
12946
|
+
const displayText = this.node[this.displayKey];
|
12947
|
+
return vue.createVNode("div", {
|
12948
|
+
"class": "bk-selector-node"
|
12949
|
+
}, [vue.createVNode("span", {
|
12950
|
+
"class": "text",
|
12951
|
+
"innerHTML": highlightKeyword(displayText)
|
12952
|
+
}, [displayText])]);
|
12953
|
+
}
|
12954
|
+
});
|
12955
|
+
const tagProps = () => ({
|
12956
|
+
modelValue: PropTypes.arrayOf(PropTypes.string).def([]),
|
12957
|
+
placeholder: PropTypes.string.def("\u8BF7\u8F93\u5165\u5E76\u6309 Enter \u7ED3\u675F"),
|
12958
|
+
list: PropTypes.arrayOf(PropTypes.object).def([]),
|
12959
|
+
disabled: PropTypes.bool.def(false),
|
12960
|
+
tooltipKey: PropTypes.string.def(""),
|
12961
|
+
saveKey: PropTypes.string.def("id"),
|
12962
|
+
displayKey: PropTypes.string.def("name"),
|
12963
|
+
hasDeleteIcon: PropTypes.bool.def(false),
|
12964
|
+
clearable: PropTypes.bool.def(true),
|
12965
|
+
trigger: PropTypes.commonType(["focus", "search"]).def("search"),
|
12966
|
+
searchKey: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.string)]).def("name"),
|
12967
|
+
useGroup: PropTypes.bool.def(false),
|
12968
|
+
allowCreate: PropTypes.bool.def(false),
|
12969
|
+
maxData: PropTypes.number.def(-1),
|
12970
|
+
maxResult: PropTypes.number.def(10),
|
12971
|
+
contentMaxHeight: PropTypes.number.def(300),
|
12972
|
+
contentWidth: PropTypes.number.def(190),
|
12973
|
+
separator: PropTypes.string.def(""),
|
12974
|
+
allowNextFocus: PropTypes.bool.def(true),
|
12975
|
+
allowAutoMatch: PropTypes.bool.def(false),
|
12976
|
+
showClearOnlyHover: PropTypes.bool.def(false),
|
12977
|
+
leftSpace: PropTypes.number.def(0),
|
12978
|
+
createTagValidator: {
|
12979
|
+
type: Function,
|
12980
|
+
default: null
|
12981
|
+
},
|
12982
|
+
filterCallback: {
|
12983
|
+
type: Function,
|
12984
|
+
default: null
|
12985
|
+
},
|
12986
|
+
tagTpl: {
|
12987
|
+
type: Function,
|
12988
|
+
default: null
|
12989
|
+
},
|
12990
|
+
tpl: {
|
12991
|
+
type: Function,
|
12992
|
+
default: null
|
12993
|
+
},
|
12994
|
+
pasteFn: {
|
12995
|
+
type: Function,
|
12996
|
+
default: null
|
12997
|
+
}
|
12998
|
+
});
|
12999
|
+
var TagRender = vue.defineComponent({
|
13000
|
+
name: "TagRender",
|
13001
|
+
props: {
|
13002
|
+
node: PropTypes.object,
|
13003
|
+
displayKey: PropTypes.string,
|
13004
|
+
tpl: {
|
13005
|
+
type: Function,
|
13006
|
+
default: null
|
13007
|
+
}
|
13008
|
+
},
|
13009
|
+
render() {
|
13010
|
+
if (this.tpl) {
|
13011
|
+
return this.tpl(this.node, vue.h, this);
|
13012
|
+
}
|
13013
|
+
return vue.createVNode("div", {
|
13014
|
+
"class": "tag"
|
13015
|
+
}, [vue.createVNode("span", {
|
13016
|
+
"class": "text"
|
13017
|
+
}, [this.node[this.displayKey]])]);
|
13018
|
+
}
|
13019
|
+
});
|
13020
|
+
var TagInput = vue.defineComponent({
|
13021
|
+
name: "BkTagInput",
|
13022
|
+
directives: {
|
13023
|
+
bkTooltips: tooltips
|
13024
|
+
},
|
13025
|
+
props: tagProps(),
|
13026
|
+
emits: ["update:modelValue", "change", "select", "blur", "remove", "removeAll"],
|
13027
|
+
setup(props, {
|
13028
|
+
emit
|
13029
|
+
}) {
|
13030
|
+
const state = vue.reactive({
|
13031
|
+
isEdit: false,
|
13032
|
+
isHover: false,
|
13033
|
+
focusItemIndex: props.allowCreate ? -1 : 0
|
13034
|
+
});
|
13035
|
+
const popoverProps = vue.reactive({
|
13036
|
+
isShow: false,
|
13037
|
+
width: 190,
|
13038
|
+
modifiers: [{
|
13039
|
+
name: "offset",
|
13040
|
+
options: {
|
13041
|
+
offset: [0, 4]
|
13042
|
+
}
|
13043
|
+
}]
|
13044
|
+
});
|
13045
|
+
const {
|
13046
|
+
maxResult
|
13047
|
+
} = vue.toRefs(props);
|
13048
|
+
const {
|
13049
|
+
pageState,
|
13050
|
+
initPage,
|
13051
|
+
pageChange
|
13052
|
+
} = usePage(maxResult);
|
13053
|
+
const curInputValue = useDebouncedRef("", 150);
|
13054
|
+
const tagInputRef = vue.ref(null);
|
13055
|
+
const bkTagSelectorRef = vue.ref(null);
|
13056
|
+
const tagListRef = vue.ref(null);
|
13057
|
+
const tagInputItemRef = vue.ref(null);
|
13058
|
+
const selectorListRef = vue.ref(null);
|
13059
|
+
const popoverRef = vue.ref(null);
|
13060
|
+
const timer = vue.ref(null);
|
13061
|
+
const showTagClose = vue.computed(() => !props.disabled && props.hasDeleteIcon);
|
13062
|
+
const isSingleSelect = vue.computed(() => props.maxData === 1);
|
13063
|
+
const isShowPlaceholder = vue.computed(() => listState.selectedTagList.length === 0 && curInputValue.value === "" && !state.isEdit);
|
13064
|
+
const isShowClear = vue.computed(() => props.clearable && !props.disabled && listState.selectedTagList.length !== 0 && (props.showClearOnlyHover ? state.isHover : true));
|
13065
|
+
const triggerClass = vue.computed(() => ({
|
13066
|
+
"bk-tag-input-trigger": true,
|
13067
|
+
active: state.isEdit,
|
13068
|
+
disabled: props.disabled
|
13069
|
+
}));
|
13070
|
+
vue.watch([() => [...props.modelValue], () => [...props.list]], () => {
|
13071
|
+
initData();
|
13072
|
+
});
|
13073
|
+
vue.watch(curInputValue, (value) => {
|
13074
|
+
const hasShowCount = pageState.curPageList.length !== 0;
|
13075
|
+
if (value !== "" && hasShowCount || value === "" && props.trigger === "focus") {
|
13076
|
+
popoverProps.isShow = true;
|
13077
|
+
} else if (props.trigger !== "focus" || !hasShowCount) {
|
13078
|
+
popoverProps.isShow = false;
|
13079
|
+
}
|
13080
|
+
});
|
13081
|
+
vue.watch(() => popoverProps.isShow, (show) => {
|
13082
|
+
changePopoverOffset();
|
13083
|
+
if (show) {
|
13084
|
+
if (selectorListRef.value) {
|
13085
|
+
vue.nextTick(() => {
|
13086
|
+
selectorListRef.value.scrollTop = 0;
|
13087
|
+
});
|
13088
|
+
selectorListRef.value.removeEventListener("scroll", scrollHandler);
|
13089
|
+
selectorListRef.value.addEventListener("scroll", scrollHandler);
|
13090
|
+
}
|
13091
|
+
}
|
13092
|
+
});
|
13093
|
+
const changePopoverOffset = () => {
|
13094
|
+
var _a, _b;
|
13095
|
+
const left2 = isSingleSelect.value ? 0 : (_a = tagInputItemRef.value) == null ? void 0 : _a.offsetLeft;
|
13096
|
+
popoverProps.modifiers = [{
|
13097
|
+
name: "offset",
|
13098
|
+
options: {
|
13099
|
+
offset: [left2, 4]
|
13100
|
+
}
|
13101
|
+
}];
|
13102
|
+
(_b = popoverRef.value) == null ? void 0 : _b.update();
|
13103
|
+
};
|
13104
|
+
const scrollHandler = () => {
|
13105
|
+
if (pageState.isPageLoading || selectorListRef.value.scrollTop === 0) {
|
13106
|
+
return;
|
13107
|
+
}
|
13108
|
+
const {
|
13109
|
+
scrollTop,
|
13110
|
+
offsetHeight,
|
13111
|
+
scrollHeight
|
13112
|
+
} = selectorListRef.value;
|
13113
|
+
if (scrollTop + offsetHeight >= scrollHeight) {
|
13114
|
+
const curPage = pageState.curPage + 1;
|
13115
|
+
if (curPage <= pageState.totalPage) {
|
13116
|
+
pageState.isPageLoading = true;
|
13117
|
+
setTimeout(() => {
|
13118
|
+
pageChange(curPage);
|
13119
|
+
}, 500);
|
13120
|
+
}
|
13121
|
+
}
|
13122
|
+
};
|
13123
|
+
const getSelectedTagNodes = () => {
|
13124
|
+
var _a;
|
13125
|
+
const nodes = Array.from(((_a = tagListRef.value) == null ? void 0 : _a.childNodes) || []);
|
13126
|
+
return nodes.filter((node) => node.nodeType !== Node.TEXT_NODE);
|
13127
|
+
};
|
13128
|
+
const focusInputTrigger = (e) => {
|
13129
|
+
if (props.disabled)
|
13130
|
+
return;
|
13131
|
+
if (e == null ? void 0 : e.target) {
|
13132
|
+
const {
|
13133
|
+
className
|
13134
|
+
} = e.target;
|
13135
|
+
if (className.indexOf("bk-tag-input-trigger") > -1 || className.indexOf("tag-list") > -1) {
|
13136
|
+
tagListRef.value.appendChild(tagInputItemRef.value);
|
13137
|
+
}
|
13138
|
+
}
|
13139
|
+
clearTimeout(timer.value);
|
13140
|
+
if (isSingleSelect.value && tagList.value.length) {
|
13141
|
+
listState.tagListCache = [...tagList.value];
|
13142
|
+
listState.selectedTagListCache = [...listState.selectedTagList];
|
13143
|
+
curInputValue.value = listState.selectedTagListCache[0][props.saveKey];
|
13144
|
+
removeTag(listState.selectedTagList[0], 0);
|
13145
|
+
handleInput();
|
13146
|
+
}
|
13147
|
+
state.isEdit = true;
|
13148
|
+
vue.nextTick(() => {
|
13149
|
+
var _a;
|
13150
|
+
(_a = tagInputRef.value) == null ? void 0 : _a.focus();
|
13151
|
+
if (props.trigger === "focus" && listState.localList.length !== 0) {
|
13152
|
+
filterData();
|
13153
|
+
if (popoverProps.isShow) {
|
13154
|
+
changePopoverOffset();
|
13155
|
+
} else {
|
13156
|
+
popoverProps.isShow = true;
|
13157
|
+
}
|
13158
|
+
}
|
13159
|
+
});
|
13160
|
+
};
|
13161
|
+
const listState = vue.reactive({
|
13162
|
+
localList: [],
|
13163
|
+
tagListCache: [],
|
13164
|
+
selectedTagList: [],
|
13165
|
+
selectedTagListCache: []
|
13166
|
+
});
|
13167
|
+
const tagList = vue.computed(() => listState.selectedTagList.map((tag2) => tag2[props.saveKey]));
|
13168
|
+
const formatList = useFlatList(props);
|
13169
|
+
const renderList = vue.computed(() => {
|
13170
|
+
if (props.useGroup) {
|
13171
|
+
const groupMap = {};
|
13172
|
+
pageState.curPageList.forEach((item, index) => {
|
13173
|
+
item.__index__ = index;
|
13174
|
+
if (!groupMap[item.group.groupId]) {
|
13175
|
+
groupMap[item.group.groupId] = {
|
13176
|
+
id: item.group.groupId,
|
13177
|
+
name: item.group.groupName,
|
13178
|
+
children: []
|
13179
|
+
};
|
13180
|
+
}
|
13181
|
+
groupMap[item.group.groupId].children.push(item);
|
13182
|
+
});
|
13183
|
+
return Object.keys(groupMap).map((key) => groupMap[key]);
|
13184
|
+
}
|
13185
|
+
return pageState.curPageList;
|
13186
|
+
});
|
13187
|
+
const initData = () => {
|
13188
|
+
const {
|
13189
|
+
saveKey,
|
13190
|
+
modelValue,
|
13191
|
+
displayKey,
|
13192
|
+
allowCreate,
|
13193
|
+
trigger
|
13194
|
+
} = props;
|
13195
|
+
listState.selectedTagList = [];
|
13196
|
+
listState.localList = [...formatList];
|
13197
|
+
if (modelValue.length) {
|
13198
|
+
modelValue.forEach((tag2) => {
|
13199
|
+
const value = listState.localList.find((val) => tag2 === val[saveKey]);
|
13200
|
+
if (value !== void 0) {
|
13201
|
+
listState.selectedTagList.push(value);
|
13202
|
+
} else if (allowCreate && !tagList.value.includes(tag2)) {
|
13203
|
+
listState.selectedTagList.push({
|
13204
|
+
[saveKey]: tag2,
|
13205
|
+
[displayKey]: tag2
|
13206
|
+
});
|
13207
|
+
}
|
13208
|
+
});
|
13209
|
+
if (!isSingleSelect.value) {
|
13210
|
+
listState.localList = listState.localList.filter((val) => !modelValue.includes(val[saveKey]));
|
13211
|
+
}
|
13212
|
+
}
|
13213
|
+
if (trigger === "focus") {
|
13214
|
+
filterData();
|
13215
|
+
}
|
13216
|
+
};
|
13217
|
+
const filterData = (value = "") => {
|
13218
|
+
const {
|
13219
|
+
searchKey,
|
13220
|
+
filterCallback
|
13221
|
+
} = props;
|
13222
|
+
const lowerCaseValue = value.toLowerCase();
|
13223
|
+
let filterData2 = [];
|
13224
|
+
if (typeof filterCallback === "function") {
|
13225
|
+
filterData2 = filterCallback(lowerCaseValue, searchKey, listState.localList) || [];
|
13226
|
+
} else {
|
13227
|
+
if (Array.isArray(searchKey)) {
|
13228
|
+
const filterDataList = searchKey.map((searchKey2) => listState.localList.filter((item) => item[searchKey2].toLowerCase().indexOf(lowerCaseValue) !== -1));
|
13229
|
+
filterData2 = Array.from(new Set(filterDataList.flat()));
|
13230
|
+
} else {
|
13231
|
+
filterData2 = listState.localList.filter((item) => item[searchKey].toLowerCase().indexOf(lowerCaseValue) !== -1);
|
13232
|
+
}
|
13233
|
+
}
|
13234
|
+
initPage(filterData2);
|
13235
|
+
};
|
13236
|
+
const activeClass = (data2, index) => {
|
13237
|
+
const style = {
|
13238
|
+
"bk-selector-actived": false,
|
13239
|
+
"bk-selector-selected": tagList.value.includes(data2[props.saveKey])
|
13240
|
+
};
|
13241
|
+
if (props.useGroup) {
|
13242
|
+
style["bk-selector-actived"] = data2.__index__ === state.focusItemIndex;
|
13243
|
+
} else {
|
13244
|
+
style["bk-selector-actived"] = index === state.focusItemIndex;
|
13245
|
+
}
|
13246
|
+
return style;
|
13247
|
+
};
|
13248
|
+
vue.onMounted(() => {
|
13249
|
+
initData();
|
13250
|
+
});
|
13251
|
+
const clearSingleCache = () => {
|
13252
|
+
listState.tagListCache = [];
|
13253
|
+
listState.selectedTagListCache = [];
|
13254
|
+
listState.selectedTagList = [];
|
13255
|
+
};
|
13256
|
+
const clearInput = () => {
|
13257
|
+
curInputValue.value = "";
|
13258
|
+
};
|
13259
|
+
const getTagInputItemSite = () => {
|
13260
|
+
if (isSingleSelect.value) {
|
13261
|
+
return 0;
|
13262
|
+
}
|
13263
|
+
const childNodes = getSelectedTagNodes();
|
13264
|
+
const index = childNodes.findIndex(({
|
13265
|
+
id
|
13266
|
+
}) => id === "tagInputItem");
|
13267
|
+
return index >= 0 ? index : 0;
|
13268
|
+
};
|
13269
|
+
const swapElementPositions = (newNode, referenceNode, isNextElementSibling = false) => {
|
13270
|
+
if (!referenceNode || !newNode)
|
13271
|
+
return;
|
13272
|
+
let swap = referenceNode;
|
13273
|
+
if (isNextElementSibling) {
|
13274
|
+
swap = referenceNode.nextElementSibling || null;
|
13275
|
+
}
|
13276
|
+
referenceNode.parentNode.insertBefore(newNode, swap);
|
13277
|
+
};
|
13278
|
+
const handleInput = (e) => {
|
13279
|
+
const {
|
13280
|
+
maxData,
|
13281
|
+
trigger,
|
13282
|
+
allowCreate
|
13283
|
+
} = props;
|
13284
|
+
if (maxData === -1 || maxData > tagList.value.length) {
|
13285
|
+
const {
|
13286
|
+
value
|
13287
|
+
} = (e == null ? void 0 : e.target) ? e.target : curInputValue;
|
13288
|
+
const charLen = getCharLength(value);
|
13289
|
+
if (charLen) {
|
13290
|
+
filterData(value);
|
13291
|
+
tagInputRef.value.style.width = `${charLen * INPUT_MIN_WIDTH}px`;
|
13292
|
+
} else {
|
13293
|
+
if (trigger === "focus") {
|
13294
|
+
filterData();
|
13295
|
+
}
|
13296
|
+
}
|
13297
|
+
} else {
|
13298
|
+
handleBlur();
|
13299
|
+
curInputValue.value = "";
|
13300
|
+
popoverProps.isShow = false;
|
13301
|
+
}
|
13302
|
+
state.isEdit = true;
|
13303
|
+
state.focusItemIndex = allowCreate ? -1 : 0;
|
13304
|
+
};
|
13305
|
+
const handleFocus = () => {
|
13306
|
+
var _a;
|
13307
|
+
popoverProps.width = isSingleSelect.value ? (_a = bkTagSelectorRef.value) == null ? void 0 : _a.clientWidth : props.contentWidth;
|
13308
|
+
};
|
13309
|
+
const handleBlur = () => {
|
13310
|
+
timer.value = setTimeout(() => {
|
13311
|
+
const inputValue = curInputValue.value;
|
13312
|
+
clearInput();
|
13313
|
+
state.isEdit = false;
|
13314
|
+
if (isSingleSelect.value) {
|
13315
|
+
const [oldValue] = listState.tagListCache;
|
13316
|
+
if (inputValue && inputValue === oldValue && listState.selectedTagListCache.length) {
|
13317
|
+
addTag(listState.selectedTagListCache[0], "select");
|
13318
|
+
} else {
|
13319
|
+
handleChange("remove");
|
13320
|
+
}
|
13321
|
+
} else if (props.allowAutoMatch && inputValue) {
|
13322
|
+
const matchItem = pageState.curPageList.find((item) => {
|
13323
|
+
if (Array.isArray(props.searchKey)) {
|
13324
|
+
const searchValue = props.searchKey.map((key) => item[key]);
|
13325
|
+
return searchValue.includes(inputValue);
|
13326
|
+
}
|
13327
|
+
return item[props.searchKey] === inputValue;
|
13328
|
+
});
|
13329
|
+
if (matchItem) {
|
13330
|
+
handleTagSelected(matchItem, "select");
|
13331
|
+
} else if (props.allowCreate) {
|
13332
|
+
handleTagSelected(inputValue, "custom");
|
13333
|
+
}
|
13334
|
+
}
|
13335
|
+
popoverProps.isShow = false;
|
13336
|
+
emit("blur", inputValue, tagList.value);
|
13337
|
+
}, 50);
|
13338
|
+
};
|
13339
|
+
const handleTagSelected = (item, type, e) => {
|
13340
|
+
e == null ? void 0 : e.stopPropagation();
|
13341
|
+
if (!item || item.disabled) {
|
13342
|
+
return;
|
13343
|
+
}
|
13344
|
+
if (isSingleSelect.value) {
|
13345
|
+
clearSingleCache();
|
13346
|
+
}
|
13347
|
+
addTag(item, type);
|
13348
|
+
handleChange("select");
|
13349
|
+
clearInput();
|
13350
|
+
popoverProps.isShow = false;
|
13351
|
+
};
|
13352
|
+
const handleTagRemove = (data2, index, e) => {
|
13353
|
+
e == null ? void 0 : e.stopPropagation();
|
13354
|
+
removeTag(data2, index);
|
13355
|
+
clearInput();
|
13356
|
+
handleChange("remove");
|
13357
|
+
tagInputRef.value.style.width = `${INPUT_MIN_WIDTH}px`;
|
13358
|
+
};
|
13359
|
+
const handleChange = (type) => {
|
13360
|
+
emit("change", tagList.value);
|
13361
|
+
emit(type);
|
13362
|
+
emit("update:modelValue", tagList.value);
|
13363
|
+
};
|
13364
|
+
const handleClear = (e) => {
|
13365
|
+
e.stopPropagation();
|
13366
|
+
const removeList = listState.selectedTagList;
|
13367
|
+
listState.selectedTagList = [];
|
13368
|
+
const existList = formatList.filter((item) => removeList.some((removeItem) => removeItem[props.saveKey] === item[props.saveKey]));
|
13369
|
+
if ((props.allowCreate && existList.length !== 0 || !props.allowCreate) && !isSingleSelect.value) {
|
13370
|
+
listState.localList.push(...existList);
|
13371
|
+
}
|
13372
|
+
handleChange("removeAll");
|
13373
|
+
};
|
13374
|
+
const updateScrollTop = () => {
|
13375
|
+
const panelInfo = {
|
13376
|
+
height: selectorListRef.value.clientHeight,
|
13377
|
+
yAxis: selectorListRef.value.getBoundingClientRect().y
|
13378
|
+
};
|
13379
|
+
vue.nextTick(() => {
|
13380
|
+
const activeObj = selectorListRef.value.querySelector(".bk-selector-actived");
|
13381
|
+
if (!activeObj) {
|
13382
|
+
return;
|
13383
|
+
}
|
13384
|
+
const activeInfo = {
|
13385
|
+
height: activeObj.clientHeight,
|
13386
|
+
yAxis: activeObj.getBoundingClientRect().y
|
13387
|
+
};
|
13388
|
+
if (activeInfo.yAxis < panelInfo.yAxis) {
|
13389
|
+
selectorListRef.value.scrollTop = selectorListRef.value.scrollTop - (panelInfo.yAxis - activeInfo.yAxis);
|
13390
|
+
}
|
13391
|
+
const distanceToBottom = activeInfo.yAxis + activeInfo.height - panelInfo.yAxis;
|
13392
|
+
if (distanceToBottom > panelInfo.height) {
|
13393
|
+
selectorListRef.value.scrollTop = selectorListRef.value.scrollTop + distanceToBottom - panelInfo.height;
|
13394
|
+
}
|
13395
|
+
});
|
13396
|
+
};
|
13397
|
+
const backspaceHandler = (index, target) => {
|
13398
|
+
const nodes = getSelectedTagNodes();
|
13399
|
+
swapElementPositions(tagInputItemRef.value, nodes[index - 1]);
|
13400
|
+
listState.selectedTagList.splice(index - 1, 1);
|
13401
|
+
focusInputTrigger();
|
13402
|
+
const isExistInit = formatList.some((item) => item === target[props.saveKey]);
|
13403
|
+
if ((props.allowCreate && isExistInit || !props.allowCreate) && !isSingleSelect.value) {
|
13404
|
+
listState.localList.push(target);
|
13405
|
+
}
|
13406
|
+
tagInputRef.value = `${INPUT_MIN_WIDTH}px`;
|
13407
|
+
handleChange("remove");
|
13408
|
+
};
|
13409
|
+
const handleKeydown = (e) => {
|
13410
|
+
if (pageState.isPageLoading) {
|
13411
|
+
return;
|
13412
|
+
}
|
13413
|
+
let target;
|
13414
|
+
const val = e.target.value;
|
13415
|
+
const valLen = getCharLength(val);
|
13416
|
+
const tagInputItemIndex = getTagInputItemSite();
|
13417
|
+
const nodes = getSelectedTagNodes();
|
13418
|
+
switch (e.code) {
|
13419
|
+
case "ArrowUp":
|
13420
|
+
e.preventDefault();
|
13421
|
+
if (!popoverProps.isShow) {
|
13422
|
+
return;
|
13423
|
+
}
|
13424
|
+
state.focusItemIndex = state.focusItemIndex - 1;
|
13425
|
+
state.focusItemIndex = state.focusItemIndex < 0 ? -1 : state.focusItemIndex;
|
13426
|
+
if (state.focusItemIndex === -1) {
|
13427
|
+
state.focusItemIndex = pageState.curPageList.length - 1;
|
13428
|
+
}
|
13429
|
+
updateScrollTop();
|
13430
|
+
break;
|
13431
|
+
case "ArrowDown":
|
13432
|
+
e.preventDefault();
|
13433
|
+
if (!popoverProps.isShow) {
|
13434
|
+
return;
|
13435
|
+
}
|
13436
|
+
state.focusItemIndex = state.focusItemIndex + 1;
|
13437
|
+
state.focusItemIndex = state.focusItemIndex > pageState.curPageList.length - 1 ? pageState.curPageList.length : state.focusItemIndex;
|
13438
|
+
if (state.focusItemIndex === pageState.curPageList.length) {
|
13439
|
+
state.focusItemIndex = 0;
|
13440
|
+
}
|
13441
|
+
updateScrollTop();
|
13442
|
+
break;
|
13443
|
+
case "ArrowLeft":
|
13444
|
+
state.isEdit = true;
|
13445
|
+
if (!valLen) {
|
13446
|
+
if (tagInputItemIndex < 1) {
|
13447
|
+
return;
|
13448
|
+
}
|
13449
|
+
swapElementPositions(tagInputItemRef.value, nodes[tagInputItemIndex - 1]);
|
13450
|
+
focusInputTrigger();
|
13451
|
+
}
|
13452
|
+
break;
|
13453
|
+
case "ArrowRight":
|
13454
|
+
state.isEdit = true;
|
13455
|
+
if (!valLen) {
|
13456
|
+
if (tagInputItemIndex === nodes.length - 1) {
|
13457
|
+
return;
|
13458
|
+
}
|
13459
|
+
swapElementPositions(nodes[tagInputItemIndex + 1], tagInputItemRef.value);
|
13460
|
+
focusInputTrigger();
|
13461
|
+
}
|
13462
|
+
break;
|
13463
|
+
case "Enter":
|
13464
|
+
case "NumpadEnter":
|
13465
|
+
if (!props.allowCreate && popoverProps.isShow || props.allowCreate && state.focusItemIndex >= 0 && popoverProps.isShow) {
|
13466
|
+
handleTagSelected(pageState.curPageList[state.focusItemIndex], "select", e);
|
13467
|
+
} else if (props.allowCreate) {
|
13468
|
+
handleTagSelected(curInputValue.value, "custom", e);
|
13469
|
+
}
|
13470
|
+
e.preventDefault();
|
13471
|
+
break;
|
13472
|
+
case "Backspace":
|
13473
|
+
if (tagInputItemIndex !== 0 && !curInputValue.value) {
|
13474
|
+
target = listState.selectedTagList[tagInputItemIndex - 1];
|
13475
|
+
backspaceHandler(tagInputItemIndex, target);
|
13476
|
+
}
|
13477
|
+
break;
|
13478
|
+
}
|
13479
|
+
};
|
13480
|
+
const defaultPasteFn = (value) => {
|
13481
|
+
const target = [];
|
13482
|
+
const textArr = value.split(";");
|
13483
|
+
textArr.forEach((item) => {
|
13484
|
+
if (item.match(/^[a-zA-Z][a-zA-Z_]+/g)) {
|
13485
|
+
const finalItem = item.match(/^[a-zA-Z][a-zA-Z_]+/g).join("");
|
13486
|
+
target.push({
|
13487
|
+
[props.saveKey]: finalItem,
|
13488
|
+
[props.displayKey]: finalItem
|
13489
|
+
});
|
13490
|
+
}
|
13491
|
+
});
|
13492
|
+
return target;
|
13493
|
+
};
|
13494
|
+
const handlePaste = (e) => {
|
13495
|
+
e.preventDefault();
|
13496
|
+
if (isSingleSelect.value) {
|
13497
|
+
return false;
|
13498
|
+
}
|
13499
|
+
const {
|
13500
|
+
maxData,
|
13501
|
+
saveKey,
|
13502
|
+
pasteFn
|
13503
|
+
} = props;
|
13504
|
+
const value = e.clipboardData.getData("text");
|
13505
|
+
const valArr = pasteFn ? pasteFn(value) : defaultPasteFn(value);
|
13506
|
+
let tags = valArr.map((value2) => value2[saveKey]);
|
13507
|
+
if (tags.length) {
|
13508
|
+
const nodes = getSelectedTagNodes();
|
13509
|
+
const index = getTagInputItemSite();
|
13510
|
+
const localInitData = listState.localList.map((data2) => data2[saveKey]);
|
13511
|
+
tags = tags.filter((tag2) => (tag2 == null ? void 0 : tag2.trim()) && !tagList.value.includes(tag2) && localInitData.includes(tag2));
|
13512
|
+
if (maxData !== -1) {
|
13513
|
+
const selectedLength = listState.selectedTagList.length;
|
13514
|
+
if (selectedLength < maxData) {
|
13515
|
+
const differ = maxData - selectedLength;
|
13516
|
+
if (tags.length > differ) {
|
13517
|
+
tags = [...tags.slice(0, differ)];
|
13518
|
+
}
|
13519
|
+
} else {
|
13520
|
+
tags = [];
|
13521
|
+
}
|
13522
|
+
}
|
13523
|
+
const localTags = listState.localList.filter((tag2) => tags.includes(tag2[saveKey]));
|
13524
|
+
if (tags.length) {
|
13525
|
+
listState.selectedTagList.splice(index, 0, ...localTags);
|
13526
|
+
swapElementPositions(tagInputItemRef.value, nodes[index]);
|
13527
|
+
tagInputRef.value.style.width = `${INPUT_MIN_WIDTH}px`;
|
13528
|
+
listState.localList = listState.localList.filter((val) => !tags.includes(val[saveKey]));
|
13529
|
+
handleChange("select");
|
13530
|
+
focusInputTrigger();
|
13531
|
+
}
|
13532
|
+
}
|
13533
|
+
};
|
13534
|
+
const tagFocus = (e) => {
|
13535
|
+
if (props.disabled) {
|
13536
|
+
return;
|
13537
|
+
}
|
13538
|
+
swapElementPositions(tagInputItemRef.value, e.currentTarget, true);
|
13539
|
+
tagInputRef.value.style.width = `${INPUT_MIN_WIDTH}px`;
|
13540
|
+
popoverProps.isShow && changePopoverOffset();
|
13541
|
+
};
|
13542
|
+
const addTag = (item, type) => {
|
13543
|
+
if (listState.selectedTagList.length >= props.maxData && props.maxData !== -1)
|
13544
|
+
return;
|
13545
|
+
const {
|
13546
|
+
separator,
|
13547
|
+
saveKey,
|
13548
|
+
displayKey,
|
13549
|
+
createTagValidator
|
13550
|
+
} = props;
|
13551
|
+
const targetIndex = getTagInputItemSite();
|
13552
|
+
let moveCount = 1;
|
13553
|
+
let isSelected = false;
|
13554
|
+
let newValue;
|
13555
|
+
const validateTag = (value) => {
|
13556
|
+
if (typeof createTagValidator === "function") {
|
13557
|
+
return createTagValidator(value);
|
13558
|
+
}
|
13559
|
+
return true;
|
13560
|
+
};
|
13561
|
+
const existTag = (value) => listState.localList.find((tag2) => tag2[saveKey] === value);
|
13562
|
+
if (type === "custom") {
|
13563
|
+
if (separator) {
|
13564
|
+
let tags = item.split(separator);
|
13565
|
+
tags = tags.filter((tag2) => (tag2 == null ? void 0 : tag2.trim()) && !tagList.value.includes(tag2) && validateTag(tag2));
|
13566
|
+
const localTags = tags.map((tag2) => existTag(tag2) || {
|
13567
|
+
[saveKey]: tag2,
|
13568
|
+
[displayKey]: tag2
|
13569
|
+
});
|
13570
|
+
if (tags.length) {
|
13571
|
+
listState.selectedTagList.splice(targetIndex, 0, ...localTags);
|
13572
|
+
moveCount = localTags.length;
|
13573
|
+
isSelected = true;
|
13574
|
+
}
|
13575
|
+
} else {
|
13576
|
+
const isObject2 = typeof item === "object";
|
13577
|
+
newValue = isObject2 ? item[saveKey] : item.trim();
|
13578
|
+
newValue = newValue.replace(/\s+/g, "");
|
13579
|
+
if (newValue !== void 0 && !tagList.value.includes(newValue) && validateTag(newValue)) {
|
13580
|
+
const localItem = existTag(newValue) || (isObject2 ? item : {
|
13581
|
+
[saveKey]: newValue,
|
13582
|
+
[displayKey]: newValue
|
13583
|
+
});
|
13584
|
+
listState.selectedTagList.splice(targetIndex, 0, localItem);
|
13585
|
+
isSelected = true;
|
13586
|
+
}
|
13587
|
+
}
|
13588
|
+
} else if (item) {
|
13589
|
+
newValue = item[saveKey];
|
13590
|
+
if (newValue !== void 0 && !tagList.value.includes(newValue)) {
|
13591
|
+
listState.selectedTagList.splice(targetIndex, 0, item);
|
13592
|
+
isSelected = true;
|
13593
|
+
}
|
13594
|
+
}
|
13595
|
+
if (isSelected) {
|
13596
|
+
vue.nextTick(() => {
|
13597
|
+
for (let count = 1; count <= moveCount; count++) {
|
13598
|
+
const nodes = getSelectedTagNodes();
|
13599
|
+
const site = nodes[targetIndex + count];
|
13600
|
+
swapElementPositions(site, tagInputItemRef.value);
|
13601
|
+
}
|
13602
|
+
tagInputRef.value.style.width = `${INPUT_MIN_WIDTH}px`;
|
13603
|
+
if (!isSingleSelect.value) {
|
13604
|
+
props.allowNextFocus && focusInputTrigger();
|
13605
|
+
listState.localList = listState.localList.filter((val) => !tagList.value.includes(val[saveKey]));
|
13606
|
+
}
|
13607
|
+
});
|
13608
|
+
}
|
13609
|
+
};
|
13610
|
+
const removeTag = (data2, index) => {
|
13611
|
+
listState.selectedTagList.splice(index, 1);
|
13612
|
+
const isExistInit = formatList.some((item) => item === data2[props.saveKey]);
|
13613
|
+
if ((props.allowCreate && isExistInit || !props.allowCreate) && !isSingleSelect.value) {
|
13614
|
+
listState.localList.push(data2);
|
13615
|
+
}
|
13616
|
+
};
|
13617
|
+
return __spreadProps(__spreadValues(__spreadValues(__spreadValues({
|
13618
|
+
popoverProps
|
13619
|
+
}, vue.toRefs(state)), vue.toRefs(listState)), vue.toRefs(pageState)), {
|
13620
|
+
isShowPlaceholder,
|
13621
|
+
isShowClear,
|
13622
|
+
curInputValue,
|
13623
|
+
formatList,
|
13624
|
+
renderList,
|
13625
|
+
showTagClose,
|
13626
|
+
tagInputRef,
|
13627
|
+
bkTagSelectorRef,
|
13628
|
+
tagListRef,
|
13629
|
+
tagInputItemRef,
|
13630
|
+
selectorListRef,
|
13631
|
+
popoverRef,
|
13632
|
+
triggerClass,
|
13633
|
+
focusInputTrigger,
|
13634
|
+
activeClass,
|
13635
|
+
handleInput,
|
13636
|
+
handleFocus,
|
13637
|
+
handleBlur,
|
13638
|
+
handleTagSelected,
|
13639
|
+
handleTagRemove,
|
13640
|
+
handleClear,
|
13641
|
+
tagFocus,
|
13642
|
+
handleKeydown,
|
13643
|
+
handlePaste
|
13644
|
+
});
|
13645
|
+
},
|
13646
|
+
render() {
|
13647
|
+
const renderSelectorList = () => {
|
13648
|
+
if (this.useGroup) {
|
13649
|
+
return this.renderList.map((group) => vue.createVNode("li", {
|
13650
|
+
"class": "bk-selector-group-item"
|
13651
|
+
}, [vue.createVNode("span", {
|
13652
|
+
"class": "group-name"
|
13653
|
+
}, [group.name, vue.createTextVNode(" ("), group.children.length, vue.createTextVNode(")")]), vue.createVNode("ul", {
|
13654
|
+
"class": "bk-selector-group-list-item"
|
13655
|
+
}, [group.children.map((item, index) => vue.createVNode("li", {
|
13656
|
+
"class": ["bk-selector-list-item", {
|
13657
|
+
disabled: item.disabled
|
13658
|
+
}, this.activeClass(item, index)],
|
13659
|
+
"onClick": this.handleTagSelected.bind(this, item, "select")
|
13660
|
+
}, [vue.createVNode(ListTagRender, {
|
13661
|
+
"node": item,
|
13662
|
+
"displayKey": this.displayKey,
|
13663
|
+
"tpl": this.tpl,
|
13664
|
+
"searchKey": this.searchKey,
|
13665
|
+
"searchKeyword": this.curInputValue
|
13666
|
+
}, null)]))])]));
|
13667
|
+
}
|
13668
|
+
return this.renderList.map((item, index) => vue.createVNode("li", {
|
13669
|
+
"class": ["bk-selector-list-item", {
|
13670
|
+
disabled: item.disabled
|
13671
|
+
}, this.activeClass(item, index)],
|
13672
|
+
"onClick": this.handleTagSelected.bind(this, item, "select")
|
13673
|
+
}, [vue.createVNode(ListTagRender, {
|
13674
|
+
"node": item,
|
13675
|
+
"displayKey": this.displayKey,
|
13676
|
+
"tpl": this.tpl,
|
13677
|
+
"searchKey": this.searchKey,
|
13678
|
+
"searchKeyword": this.curInputValue
|
13679
|
+
}, null)]));
|
13680
|
+
};
|
13681
|
+
return vue.createVNode("div", {
|
13682
|
+
"class": "bk-tag-input",
|
13683
|
+
"ref": "bkTagSelectorRef",
|
13684
|
+
"onClick": this.focusInputTrigger,
|
13685
|
+
"onMouseenter": () => this.isHover = true,
|
13686
|
+
"onMouseleave": () => this.isHover = false
|
13687
|
+
}, [vue.createVNode(BkPopover, {
|
13688
|
+
"ref": "popoverRef",
|
13689
|
+
"theme": "light",
|
13690
|
+
"trigger": "manual",
|
13691
|
+
"placement": "bottom-start",
|
13692
|
+
"arrow": false,
|
13693
|
+
"width": this.popoverProps.width,
|
13694
|
+
"isShow": this.popoverProps.isShow,
|
13695
|
+
"modifiers": this.popoverProps.modifiers
|
13696
|
+
}, {
|
13697
|
+
default: () => vue.createVNode("div", {
|
13698
|
+
"class": this.triggerClass
|
13699
|
+
}, [vue.createVNode("ul", {
|
13700
|
+
"class": "tag-list",
|
13701
|
+
"ref": "tagListRef",
|
13702
|
+
"style": {
|
13703
|
+
marginLeft: `${this.leftSpace}px`
|
13704
|
+
}
|
13705
|
+
}, [this.selectedTagList.map((item, index) => {
|
13706
|
+
const tooltips2 = {
|
13707
|
+
boundary: "window",
|
13708
|
+
theme: "light",
|
13709
|
+
distance: 12,
|
13710
|
+
content: item[this.tooltipKey],
|
13711
|
+
disabled: !this.tooltipKey
|
13712
|
+
};
|
13713
|
+
return vue.withDirectives(vue.createVNode("li", {
|
13714
|
+
"class": "tag-item",
|
13715
|
+
"onClick": this.tagFocus
|
13716
|
+
}, [vue.createVNode(TagRender, {
|
13717
|
+
"node": item,
|
13718
|
+
"tpl": this.tagTpl,
|
13719
|
+
"displayKey": this.displayKey
|
13720
|
+
}, null), this.showTagClose ? vue.createVNode(error, {
|
13721
|
+
"class": "remove-tag",
|
13722
|
+
"onClick": this.handleTagRemove.bind(this, item, index)
|
13723
|
+
}, null) : null]), [[vue.resolveDirective("bk-tooltips"), tooltips2]]);
|
13724
|
+
}), vue.withDirectives(vue.createVNode("li", {
|
13725
|
+
"ref": "tagInputItemRef",
|
13726
|
+
"id": "tagInputItem",
|
13727
|
+
"class": "tag-input-item",
|
13728
|
+
"role": "input"
|
13729
|
+
}, [vue.withDirectives(vue.createVNode("input", {
|
13730
|
+
"type": "text",
|
13731
|
+
"class": "tag-input",
|
13732
|
+
"ref": "tagInputRef",
|
13733
|
+
"onUpdate:modelValue": ($event) => this.curInputValue = $event,
|
13734
|
+
"onInput": this.handleInput,
|
13735
|
+
"onFocus": this.handleFocus,
|
13736
|
+
"onBlur": this.handleBlur,
|
13737
|
+
"onKeydown": this.handleKeydown,
|
13738
|
+
"onPaste": this.handlePaste
|
13739
|
+
}, null), [[vue.vModelText, this.curInputValue]])]), [[vue.vShow, this.isEdit]])]), vue.withDirectives(vue.createVNode("p", {
|
13740
|
+
"class": "placeholder"
|
13741
|
+
}, [this.placeholder]), [[vue.vShow, this.isShowPlaceholder]]), this.isShowClear ? vue.createVNode(close$1, {
|
13742
|
+
"class": "clear-icon",
|
13743
|
+
"onClick": this.handleClear
|
13744
|
+
}, null) : null]),
|
13745
|
+
content: () => vue.createVNode("div", {
|
13746
|
+
"class": "bk-selector-list"
|
13747
|
+
}, [vue.createVNode("ul", {
|
13748
|
+
"ref": "selectorListRef",
|
13749
|
+
"style": {
|
13750
|
+
"max-height": `${this.contentMaxHeight}px`
|
13751
|
+
},
|
13752
|
+
"class": "outside-ul"
|
13753
|
+
}, [renderSelectorList(), this.isPageLoading ? vue.createVNode("li", {
|
13754
|
+
"class": "bk-selector-list-item loading"
|
13755
|
+
}, [vue.createVNode(BkLoading, {
|
13756
|
+
"theme": "primary",
|
13757
|
+
"size": BkLoadingSize.Small
|
13758
|
+
}, null)]) : null])])
|
13759
|
+
})]);
|
13760
|
+
}
|
13761
|
+
});
|
13762
|
+
TagInput.install = (Vue) => {
|
13763
|
+
Vue.component(TagInput.name, TagInput);
|
13764
|
+
};
|
12828
13765
|
var bkDivider = vue.defineComponent({
|
12829
13766
|
name: "Divider",
|
12830
13767
|
props: {
|
@@ -18466,35 +19403,41 @@ ${$(r2)}`), n2;
|
|
18466
19403
|
const outputData = [];
|
18467
19404
|
let order2 = 0;
|
18468
19405
|
const schema = /* @__PURE__ */ new Map();
|
18469
|
-
function
|
19406
|
+
function getCachedTreeNodeAttr(uuid2, node, attr, cachedAttr) {
|
18470
19407
|
const cached = (cachedSchema || []).find((item) => item.__uuid === uuid2);
|
18471
19408
|
if (cached) {
|
18472
|
-
return cached
|
19409
|
+
return cached[cachedAttr];
|
18473
19410
|
}
|
18474
|
-
return node
|
19411
|
+
return node[attr];
|
19412
|
+
}
|
19413
|
+
function isCachedTreeNodeOpened(uuid2, node) {
|
19414
|
+
return getCachedTreeNodeAttr(uuid2, node, "isOpen", "__isOpen");
|
19415
|
+
}
|
19416
|
+
function isCachedTreeNodeChecked(uuid2, node) {
|
19417
|
+
return getCachedTreeNodeAttr(uuid2, node, "checked", "__checked");
|
18475
19418
|
}
|
18476
19419
|
function flatten(array, depth = 0, parent = null, path = null) {
|
18477
|
-
|
19420
|
+
const arrLength = array.length;
|
19421
|
+
for (let i2 = 0; i2 < arrLength; i2++) {
|
18478
19422
|
const item = array[i2];
|
18479
19423
|
if (Array.isArray(item)) {
|
18480
19424
|
flatten(item, depth, parent, path);
|
18481
19425
|
} else {
|
18482
19426
|
if (typeof item === "object" && item !== null) {
|
18483
19427
|
const uuid2 = item.__uuid || uuid_1.v4();
|
18484
|
-
const isOpen = isCachedTreeNodeOpened(uuid2, item);
|
18485
19428
|
const currentPath = path !== null ? `${path}-${i2}` : `${i2}`;
|
19429
|
+
const hasChildren = !!(item[children] || []).length;
|
18486
19430
|
const attrs = {
|
18487
19431
|
__depth: depth,
|
18488
19432
|
__index: i2,
|
18489
19433
|
__uuid: uuid2,
|
18490
19434
|
__parentId: parent,
|
18491
|
-
|
18492
|
-
__hasChild: !!(item[children] || []).length,
|
19435
|
+
__hasChild: hasChildren,
|
18493
19436
|
__path: currentPath,
|
18494
19437
|
__isRoot: parent === null,
|
18495
19438
|
__order: order2,
|
18496
|
-
__isOpen:
|
18497
|
-
__checked:
|
19439
|
+
__isOpen: isCachedTreeNodeOpened(uuid2, item) && hasChildren,
|
19440
|
+
__checked: isCachedTreeNodeChecked(uuid2, item),
|
18498
19441
|
[children]: null
|
18499
19442
|
};
|
18500
19443
|
Object.assign(item, { __uuid: uuid2 });
|
@@ -19180,6 +20123,7 @@ ${$(r2)}`), n2;
|
|
19180
20123
|
Switcher: BkSwitcher,
|
19181
20124
|
Table: BkTable,
|
19182
20125
|
Tag: BkTag,
|
20126
|
+
TagInput,
|
19183
20127
|
Divider: BkDivider,
|
19184
20128
|
Tab: BKTab,
|
19185
20129
|
TabPanel: BKTabPanel,
|
@@ -19254,6 +20198,7 @@ ${$(r2)}`), n2;
|
|
19254
20198
|
exports2.TabPanel = BKTabPanel;
|
19255
20199
|
exports2.Table = BkTable;
|
19256
20200
|
exports2.Tag = BkTag;
|
20201
|
+
exports2.TagInput = TagInput;
|
19257
20202
|
exports2.Transfer = Transfer;
|
19258
20203
|
exports2.Tree = BkTree;
|
19259
20204
|
exports2.VirtualRender = BkVirtualRender;
|