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