bkui-vue 0.0.1-beta.345 → 0.0.1-beta.347
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +34 -34
- package/dist/index.esm.js +92 -43
- package/dist/index.umd.js +37 -37
- package/dist/style.css +1 -1
- package/dist/style.variable.css +1 -1
- package/lib/search-select/index.d.ts +120 -7
- package/lib/search-select/index.js +1 -1
- package/lib/search-select/input.d.ts +4 -2
- package/lib/search-select/search-select.css +3 -2
- package/lib/search-select/search-select.d.ts +71 -20
- package/lib/search-select/search-select.less +8 -3
- package/lib/search-select/search-select.variable.css +3 -2
- package/lib/search-select/selected.d.ts +6 -4
- package/lib/search-select/utils.d.ts +7 -2
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
@@ -37598,9 +37598,10 @@ var SearchInputMode = /* @__PURE__ */ ((SearchInputMode2) => {
|
|
37598
37598
|
return SearchInputMode2;
|
37599
37599
|
})(SearchInputMode || {});
|
37600
37600
|
class SelectedItem {
|
37601
|
-
constructor(searchItem, type = "default") {
|
37601
|
+
constructor(searchItem, type = "default", splitCode = "|") {
|
37602
37602
|
this.searchItem = searchItem;
|
37603
37603
|
this.type = type;
|
37604
|
+
this.splitCode = splitCode;
|
37604
37605
|
this.values = [];
|
37605
37606
|
this.id = searchItem.id;
|
37606
37607
|
this.name = searchItem.name;
|
@@ -37621,13 +37622,13 @@ class SelectedItem {
|
|
37621
37622
|
var _a;
|
37622
37623
|
if (this.isSpecialType())
|
37623
37624
|
return this.name;
|
37624
|
-
return `${this.keyInnerHtml}${((_a = this.values) == null ? void 0 : _a.map((item) => item.name).join(
|
37625
|
+
return `${this.keyInnerHtml}${((_a = this.values) == null ? void 0 : _a.map((item) => item.name).join(this.splitCode)) || ""}`;
|
37625
37626
|
}
|
37626
37627
|
get inputInnerText() {
|
37627
37628
|
var _a;
|
37628
37629
|
if (this.isSpecialType())
|
37629
37630
|
return this.name;
|
37630
|
-
return `${this.keyInnerText}${((_a = this.values) == null ? void 0 : _a.map((item) => item.name).join(
|
37631
|
+
return `${this.keyInnerText}${((_a = this.values) == null ? void 0 : _a.map((item) => item.name).join(this.splitCode)) || ""}`;
|
37631
37632
|
}
|
37632
37633
|
get keyInnerHtml() {
|
37633
37634
|
if (this.isSpecialType())
|
@@ -37697,7 +37698,7 @@ var SearchSelectInput = defineComponent({
|
|
37697
37698
|
type: String,
|
37698
37699
|
default: SearchInputMode.DEFAULT
|
37699
37700
|
},
|
37700
|
-
|
37701
|
+
getMenuList: Function,
|
37701
37702
|
validateValues: Function
|
37702
37703
|
},
|
37703
37704
|
emits: ["focus", "add", "delete"],
|
@@ -37720,7 +37721,8 @@ var SearchSelectInput = defineComponent({
|
|
37720
37721
|
const menuList = ref([]);
|
37721
37722
|
const {
|
37722
37723
|
editKey,
|
37723
|
-
onValidate
|
37724
|
+
onValidate,
|
37725
|
+
valueSplitCode
|
37724
37726
|
} = useSearchSelectInject();
|
37725
37727
|
watch(editKey, () => {
|
37726
37728
|
if (props2.mode === SearchInputMode.DEFAULT && editKey.value) {
|
@@ -37801,23 +37803,25 @@ var SearchSelectInput = defineComponent({
|
|
37801
37803
|
e && setMenuList();
|
37802
37804
|
}
|
37803
37805
|
function handleInputChange(event) {
|
37804
|
-
var _a, _b, _c, _d, _e, _f;
|
37806
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
37805
37807
|
clearInput();
|
37806
37808
|
let text = event.target.innerText;
|
37807
37809
|
if (/(\r|\n)/gm.test(text) || /\s{2}/gm.test(text)) {
|
37808
37810
|
event.preventDefault();
|
37809
|
-
text = text.replace(/(\r|\n)/gm,
|
37811
|
+
text = text.replace(/(\r|\n)/gm, valueSplitCode.value).replace(/\s{2}/gm, "");
|
37810
37812
|
inputRef.value.innerText = text;
|
37811
37813
|
setInputFocus();
|
37812
|
-
keyword.value = text;
|
37814
|
+
keyword.value = text.replace(((_a = usingItem.value) == null ? void 0 : _a.keyInnerText) || "", "").trim();
|
37813
37815
|
debounceSetMenuList();
|
37814
|
-
} else if (!keyword.value && text.length < (((
|
37815
|
-
const outerText = text.replace("\xA0", " ").replace(((
|
37816
|
-
outerText
|
37816
|
+
} else if (!keyword.value && text.length < (((_c = (_b = usingItem.value) == null ? void 0 : _b.inputInnerText) == null ? void 0 : _c.length) || 1)) {
|
37817
|
+
const outerText = text.replace("\xA0", " ").replace(((_d = usingItem.value) == null ? void 0 : _d.keyInnerText.replace("\xA0", " ").trim()) || "", "").trim();
|
37818
|
+
if (outerText || !(text == null ? void 0 : text.length)) {
|
37819
|
+
usingItem.value = null;
|
37820
|
+
}
|
37817
37821
|
keyword.value = outerText ? text : "";
|
37818
37822
|
debounceSetMenuList();
|
37819
|
-
} else if (!((
|
37820
|
-
keyword.value = text.replace("\xA0", " ").replace(((
|
37823
|
+
} else if (!((_f = (_e = usingItem.value) == null ? void 0 : _e.values) == null ? void 0 : _f.length)) {
|
37824
|
+
keyword.value = text.replace("\xA0", " ").replace(((_g = usingItem.value) == null ? void 0 : _g.keyInnerText.replace("\xA0", " ")) || "", "").trim();
|
37821
37825
|
setInputFocus();
|
37822
37826
|
debounceSetMenuList();
|
37823
37827
|
}
|
@@ -37848,7 +37852,7 @@ var SearchSelectInput = defineComponent({
|
|
37848
37852
|
const res2 = await validateUsingItemValues(value);
|
37849
37853
|
if (!res2)
|
37850
37854
|
return;
|
37851
|
-
emit("add", new SelectedItem(value, "text"));
|
37855
|
+
emit("add", new SelectedItem(value, "text", valueSplitCode.value));
|
37852
37856
|
keyword.value = "";
|
37853
37857
|
setMenuList();
|
37854
37858
|
return;
|
@@ -37858,14 +37862,28 @@ var SearchSelectInput = defineComponent({
|
|
37858
37862
|
} = usingItem.value;
|
37859
37863
|
if (!(values == null ? void 0 : values.length)) {
|
37860
37864
|
if ((_a = keyword.value) == null ? void 0 : _a.length) {
|
37861
|
-
|
37862
|
-
|
37863
|
-
|
37864
|
-
|
37865
|
-
|
37866
|
-
|
37867
|
-
|
37868
|
-
|
37865
|
+
if (keyword.value.includes(valueSplitCode.value)) {
|
37866
|
+
const valueList = keyword.value.split(valueSplitCode.value);
|
37867
|
+
const res2 = await validateUsingItemValues({
|
37868
|
+
id: keyword.value,
|
37869
|
+
name: keyword.value
|
37870
|
+
});
|
37871
|
+
if (!res2)
|
37872
|
+
return;
|
37873
|
+
valueList.forEach((v2) => usingItem.value.addValue({
|
37874
|
+
id: v2,
|
37875
|
+
name: v2
|
37876
|
+
}));
|
37877
|
+
} else {
|
37878
|
+
const value = {
|
37879
|
+
id: keyword.value,
|
37880
|
+
name: keyword.value
|
37881
|
+
};
|
37882
|
+
const res2 = await validateUsingItemValues(value);
|
37883
|
+
if (!res2)
|
37884
|
+
return;
|
37885
|
+
usingItem.value.addValue(value);
|
37886
|
+
}
|
37869
37887
|
emit("add", usingItem.value);
|
37870
37888
|
keyword.value = "";
|
37871
37889
|
usingItem.value = null;
|
@@ -37883,6 +37901,7 @@ var SearchSelectInput = defineComponent({
|
|
37883
37901
|
var _a, _b;
|
37884
37902
|
if (!usingItem.value && !keyword.value) {
|
37885
37903
|
emit("delete");
|
37904
|
+
nextTick(setMenuList);
|
37886
37905
|
return;
|
37887
37906
|
}
|
37888
37907
|
if ((_a = usingItem.value) == null ? void 0 : _a.values.length) {
|
@@ -37900,13 +37919,13 @@ var SearchSelectInput = defineComponent({
|
|
37900
37919
|
if ((_a = item.value) == null ? void 0 : _a.id) {
|
37901
37920
|
const seleted = new SelectedItem(__spreadProps(__spreadValues({}, item), {
|
37902
37921
|
id: (_b = item.realId) != null ? _b : item.id
|
37903
|
-
}), type);
|
37922
|
+
}), type, valueSplitCode.value);
|
37904
37923
|
seleted.addValue(item.value);
|
37905
37924
|
setSelectedItem(seleted);
|
37906
37925
|
return;
|
37907
37926
|
}
|
37908
37927
|
if (!usingItem.value || !((_c = inputRef == null ? void 0 : inputRef.value) == null ? void 0 : _c.innerText)) {
|
37909
|
-
usingItem.value = new SelectedItem(item, type);
|
37928
|
+
usingItem.value = new SelectedItem(item, type, valueSplitCode.value);
|
37910
37929
|
keyword.value = "";
|
37911
37930
|
const isCondition = type === "condition";
|
37912
37931
|
isCondition && setSelectedItem();
|
@@ -37915,7 +37934,7 @@ var SearchSelectInput = defineComponent({
|
|
37915
37934
|
return;
|
37916
37935
|
}
|
37917
37936
|
if (((_d = usingItem.value) == null ? void 0 : _d.type) === "condition") {
|
37918
|
-
usingItem.value = new SelectedItem(item, type);
|
37937
|
+
usingItem.value = new SelectedItem(item, type, valueSplitCode.value);
|
37919
37938
|
setSelectedItem();
|
37920
37939
|
return;
|
37921
37940
|
}
|
@@ -37984,15 +38003,15 @@ var SearchSelectInput = defineComponent({
|
|
37984
38003
|
async function setMenuList() {
|
37985
38004
|
var _a, _b, _c, _d, _e;
|
37986
38005
|
let list = [];
|
37987
|
-
if (typeof props2.
|
38006
|
+
if (typeof props2.getMenuList === "function" && (typeof ((_b = (_a = usingItem.value) == null ? void 0 : _a.searchItem) == null ? void 0 : _b.async) === "undefined" || usingItem.value.searchItem.async === true)) {
|
37988
38007
|
loading2.value = true;
|
37989
|
-
list = await props2.
|
38008
|
+
list = await props2.getMenuList((_c = usingItem.value) == null ? void 0 : _c.searchItem, keyword.value).catch(() => []);
|
37990
38009
|
loading2.value = false;
|
37991
38010
|
} else if (!(usingItem == null ? void 0 : usingItem.value)) {
|
37992
38011
|
if (!((_d = keyword.value) == null ? void 0 : _d.length)) {
|
37993
|
-
list = props2.data.slice();
|
38012
|
+
list = props2.data.filter((item) => !item.isSelected).slice();
|
37994
38013
|
} else
|
37995
|
-
props2.data.forEach((item) => {
|
38014
|
+
props2.data.filter((item) => !item.isSelected).forEach((item) => {
|
37996
38015
|
var _a2, _b2;
|
37997
38016
|
const isMatched = item.name.toLocaleLowerCase().includes(keyword.value.toLocaleLowerCase());
|
37998
38017
|
if (isMatched) {
|
@@ -38176,11 +38195,11 @@ var SearchSelected = defineComponent({
|
|
38176
38195
|
type: Array,
|
38177
38196
|
default: () => []
|
38178
38197
|
},
|
38179
|
-
|
38198
|
+
getMenuList: Function,
|
38180
38199
|
validateValues: Function
|
38181
38200
|
},
|
38182
38201
|
emits: ["delete"],
|
38183
|
-
setup(
|
38202
|
+
setup(_props, {
|
38184
38203
|
emit
|
38185
38204
|
}) {
|
38186
38205
|
const inputRef = ref(null);
|
@@ -38188,7 +38207,8 @@ var SearchSelected = defineComponent({
|
|
38188
38207
|
onEditClick,
|
38189
38208
|
onEditEnter,
|
38190
38209
|
onEditBlur,
|
38191
|
-
editKey
|
38210
|
+
editKey,
|
38211
|
+
valueSplitCode
|
38192
38212
|
} = useSearchSelectInject();
|
38193
38213
|
function handleDeleteSelected(index) {
|
38194
38214
|
emit("delete", index);
|
@@ -38211,7 +38231,7 @@ var SearchSelected = defineComponent({
|
|
38211
38231
|
return true;
|
38212
38232
|
}
|
38213
38233
|
function copySeletedItem(item) {
|
38214
|
-
const newItem = new SelectedItem(item.searchItem, item.type);
|
38234
|
+
const newItem = new SelectedItem(item.searchItem, item.type, valueSplitCode.value);
|
38215
38235
|
newItem.values = item.values.slice();
|
38216
38236
|
return newItem;
|
38217
38237
|
}
|
@@ -38239,7 +38259,7 @@ var SearchSelected = defineComponent({
|
|
38239
38259
|
"conditions": this.conditions,
|
38240
38260
|
"defautUsingItem": this.copySeletedItem(item),
|
38241
38261
|
"clickOutside": this.handleInputOutside,
|
38242
|
-
"
|
38262
|
+
"getMenuList": this.getMenuList,
|
38243
38263
|
"validateValues": this.validateValues,
|
38244
38264
|
"onAdd": (v2) => this.handleAddSelected(v2, index),
|
38245
38265
|
"onFocus": this.handleInputFocus
|
@@ -38296,7 +38316,15 @@ const SearchSelectProps = {
|
|
38296
38316
|
default: true
|
38297
38317
|
},
|
38298
38318
|
getMenuList: Function,
|
38299
|
-
validateValues: Function
|
38319
|
+
validateValues: Function,
|
38320
|
+
valueSplitCode: {
|
38321
|
+
type: String,
|
38322
|
+
default: "|"
|
38323
|
+
},
|
38324
|
+
uniqueSelect: {
|
38325
|
+
type: Boolean,
|
38326
|
+
default: false
|
38327
|
+
}
|
38300
38328
|
};
|
38301
38329
|
var Component = defineComponent({
|
38302
38330
|
name: "SearchSelect",
|
@@ -38316,14 +38344,29 @@ var Component = defineComponent({
|
|
38316
38344
|
const debounceResize = debounce(32, handleResize);
|
38317
38345
|
const editKey = ref("");
|
38318
38346
|
const validateStr = ref("");
|
38347
|
+
const splitCode = computed(() => props2.valueSplitCode);
|
38348
|
+
let copyData;
|
38349
|
+
watch(() => props2.data, () => {
|
38350
|
+
var _a;
|
38351
|
+
copyData = ref(JSON.parse(JSON.stringify(props2.data)));
|
38352
|
+
(_a = copyData.value) == null ? void 0 : _a.forEach((item) => {
|
38353
|
+
item.isSelected = !!props2.modelValue.some((set) => set.id === item.id);
|
38354
|
+
});
|
38355
|
+
}, {
|
38356
|
+
immediate: true
|
38357
|
+
});
|
38319
38358
|
watch(() => props2.modelValue, (v2) => {
|
38359
|
+
var _a, _b;
|
38320
38360
|
if (!(v2 == null ? void 0 : v2.length)) {
|
38321
38361
|
selectedList.value = [];
|
38362
|
+
(_a = copyData.value) == null ? void 0 : _a.forEach((item) => {
|
38363
|
+
item.isSelected = false;
|
38364
|
+
});
|
38322
38365
|
return;
|
38323
38366
|
}
|
38324
38367
|
const list = [];
|
38325
38368
|
v2.forEach((item) => {
|
38326
|
-
var
|
38369
|
+
var _a2;
|
38327
38370
|
const seleted = selectedList.value.find((set) => set.id === item.id && set.name === item.name);
|
38328
38371
|
if ((seleted == null ? void 0 : seleted.toValueKey()) === JSON.stringify(item)) {
|
38329
38372
|
seleted.values = item.values || [];
|
@@ -38335,15 +38378,18 @@ var Component = defineComponent({
|
|
38335
38378
|
searchItem = props2.conditions.find((set) => set.id === item.id);
|
38336
38379
|
searchItem && (searchType = "condition");
|
38337
38380
|
}
|
38338
|
-
if (!searchItem && !((
|
38381
|
+
if (!searchItem && !((_a2 = item.values) == null ? void 0 : _a2.length)) {
|
38339
38382
|
searchType = "text";
|
38340
38383
|
}
|
38341
|
-
const newSelected = new SelectedItem(searchItem || item, searchType);
|
38384
|
+
const newSelected = new SelectedItem(searchItem || item, searchType, splitCode.value);
|
38342
38385
|
newSelected.values = item.values || [];
|
38343
38386
|
list.push(newSelected);
|
38344
38387
|
}
|
38345
38388
|
});
|
38346
38389
|
selectedList.value = list;
|
38390
|
+
(_b = copyData.value) == null ? void 0 : _b.forEach((item) => {
|
38391
|
+
item.isSelected = !!list.some((set) => set.id === item.id);
|
38392
|
+
});
|
38347
38393
|
}, {
|
38348
38394
|
immediate: true,
|
38349
38395
|
deep: true
|
@@ -38359,7 +38405,8 @@ var Component = defineComponent({
|
|
38359
38405
|
onEditEnter,
|
38360
38406
|
onEditBlur,
|
38361
38407
|
onValidate,
|
38362
|
-
editKey
|
38408
|
+
editKey,
|
38409
|
+
valueSplitCode: splitCode
|
38363
38410
|
});
|
38364
38411
|
function onEditClick(item, index) {
|
38365
38412
|
editKey.value = `${item.id}_${index}`;
|
@@ -38440,9 +38487,11 @@ var Component = defineComponent({
|
|
38440
38487
|
inputRef,
|
38441
38488
|
wrapRef,
|
38442
38489
|
isFocus,
|
38490
|
+
copyData,
|
38443
38491
|
selectedList,
|
38444
38492
|
overflowIndex,
|
38445
38493
|
validateStr,
|
38494
|
+
splitCode,
|
38446
38495
|
onEditClick,
|
38447
38496
|
onEditEnter,
|
38448
38497
|
handleWrapClick,
|
@@ -38481,23 +38530,23 @@ var Component = defineComponent({
|
|
38481
38530
|
maxHeight
|
38482
38531
|
}
|
38483
38532
|
}, [createVNode(SearchSelected, {
|
38484
|
-
"data": this.
|
38533
|
+
"data": this.copyData,
|
38485
38534
|
"conditions": this.conditions,
|
38486
38535
|
"selectedList": this.selectedList,
|
38487
38536
|
"overflowIndex": this.overflowIndex,
|
38488
|
-
"
|
38537
|
+
"getMenuList": this.getMenuList,
|
38489
38538
|
"validateValues": this.validateValues,
|
38490
38539
|
"onDelete": this.handleDeleteSelected
|
38491
38540
|
}, __spreadValues({}, menuSlots)), createVNode("div", {
|
38492
38541
|
"class": "search-container-input"
|
38493
38542
|
}, [createVNode(SearchSelectInput, {
|
38494
38543
|
"ref": "inputRef",
|
38495
|
-
"data": this.
|
38544
|
+
"data": this.copyData,
|
38496
38545
|
"showInputBefore": !this.selectedList.length,
|
38497
38546
|
"showCondition": showCondition,
|
38498
38547
|
"conditions": this.conditions,
|
38499
38548
|
"clickOutside": this.handleInputOutside,
|
38500
|
-
"
|
38549
|
+
"getMenuList": this.getMenuList,
|
38501
38550
|
"validateValues": this.validateValues,
|
38502
38551
|
"onAdd": this.handleAddSelected,
|
38503
38552
|
"onDelete": this.handleDeleteSelected,
|