@94ai/nf-virtual-select
Advanced tools
Comparing version 3.2.76 to 3.2.77
@@ -307,3 +307,2 @@ import { PluginObject } from 'vue-demi'; | ||
placeholder: string; | ||
options: unknown[]; | ||
offset: number; | ||
@@ -335,2 +334,3 @@ start: number; | ||
virtualList: boolean; | ||
options: unknown[]; | ||
multiple: boolean; | ||
@@ -497,6 +497,7 @@ width: string; | ||
}; | ||
isVirtualSelect(): any; | ||
bindProps(): any; | ||
bindEvents(): any; | ||
formatItemOptions(): any; | ||
isVirtualSelect(): any; | ||
isMultipleSelect(): any; | ||
placeholderDesc(): any; | ||
optionsList(): any; | ||
@@ -809,6 +810,7 @@ }> & import("vue-demi").ComponentCustomProperties & Readonly<import("vue-demi").ExtractPropTypes<{ | ||
}; | ||
isVirtualSelect(): any; | ||
bindProps(): any; | ||
bindEvents(): any; | ||
formatItemOptions(): any; | ||
isVirtualSelect(): any; | ||
isMultipleSelect(): any; | ||
placeholderDesc(): any; | ||
optionsList(): any; | ||
@@ -819,3 +821,2 @@ }, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, { | ||
placeholder: string; | ||
options: unknown[]; | ||
offset: number; | ||
@@ -847,2 +848,3 @@ start: number; | ||
virtualList: boolean; | ||
options: unknown[]; | ||
multiple: boolean; | ||
@@ -849,0 +851,0 @@ width: string; |
@@ -6,3 +6,3 @@ "use strict"; | ||
const lodashEs = require("lodash-es"); | ||
const vueDemi = require("vue-demi"); | ||
require("vue-demi"); | ||
const _sfc_main$1 = { | ||
@@ -293,5 +293,2 @@ name: "ItemComponent", | ||
}, | ||
isVirtualSelect() { | ||
return this.virtualList || this.itemOptions.virtualList; | ||
}, | ||
// 绑定属性 | ||
@@ -301,4 +298,8 @@ bindProps() { | ||
clearable: true, | ||
...this.itemOptions, | ||
...this.$attrs, | ||
...this.formatItemOptions | ||
virtualList: this.isVirtualSelect, | ||
placeholder: this.placeholderDesc, | ||
multiple: this.isMultipleSelect, | ||
options: this.optionsList | ||
}; | ||
@@ -326,2 +327,8 @@ if (obj.element === "custom-select" || obj.element === "el-select") { | ||
} | ||
if (events == null ? void 0 : events.input) { | ||
delete events.input; | ||
} | ||
if (events == null ? void 0 : events["update:value"]) { | ||
delete events["update:value"]; | ||
} | ||
if ((events == null ? void 0 : events["visible-change"]) && (this.virtualList || ((_a = this.itemOptions) == null ? void 0 : _a.virtualList))) { | ||
@@ -332,18 +339,11 @@ delete events["visible-change"]; | ||
}, | ||
formatItemOptions() { | ||
const that = this; | ||
return { | ||
...this.itemOptions, | ||
...this.$attrs, | ||
virtualList: this.itemOptions.virtualList || this.virtualList, | ||
placeholder: this.itemOptions.placeholder || this.placeholder, | ||
multiple: this.itemOptions.multiple || this.multiple, | ||
options: this.optionsList, | ||
events: { | ||
change(val) { | ||
that.$emit("change", val); | ||
} | ||
} | ||
}; | ||
isVirtualSelect() { | ||
return this.virtualList || this.itemOptions.virtualList; | ||
}, | ||
isMultipleSelect() { | ||
return this.multiple || this.itemOptions.multiple; | ||
}, | ||
placeholderDesc() { | ||
return this.itemOptions.placeholder || this.placeholder; | ||
}, | ||
optionsList() { | ||
@@ -361,3 +361,3 @@ var _a; | ||
watch: { | ||
options(newVal, value) { | ||
optionsList(newVal, value) { | ||
if (!lodashEs.isEqual(newVal, value)) { | ||
@@ -385,3 +385,15 @@ this.init(); | ||
scrollToIndex(index) { | ||
this.$refs.virtualSelectList.scrollToIndex(index); | ||
var _a, _b, _c, _d, _e; | ||
try { | ||
if (this.isVirtualSelect) { | ||
(_a = this.$refs.virtualSelectList) == null ? void 0 : _a.scrollToIndex(index); | ||
} else { | ||
const container = (_e = (_d = (_c = (_b = this.$refs.nfVirtualSelect) == null ? void 0 : _b.$refs) == null ? void 0 : _c.popper) == null ? void 0 : _d.$el) == null ? void 0 : _e.querySelector(".el-select-dropdown__wrap"); | ||
if (container) { | ||
container.scrollTop = 0; | ||
} | ||
} | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
}, | ||
@@ -401,3 +413,4 @@ scrollToOffset(offset) { | ||
updatePageModeFront() { | ||
this.$refs.virtualSelectList.updatePageModeFront(); | ||
var _a; | ||
(_a = this.$refs.virtualSelectList) == null ? void 0 : _a.updatePageModeFront(); | ||
}, | ||
@@ -437,51 +450,39 @@ scroll(event) { | ||
init() { | ||
this.$nextTick(() => { | ||
var _a; | ||
if (this.isVirtualSelect) { | ||
this.selectArr = ((_a = this.optionsList) == null ? void 0 : _a.map((it) => ({ | ||
[this.keyValue[0]]: it[this.keyValue[0]], | ||
[this.keyValue[1]]: it[this.keyValue[1]], | ||
[this.dataKey]: it[this.keyValue[1]], | ||
disabled: it["disabled"] ?? false | ||
}))) ?? []; | ||
if (this.currentVal) { | ||
if ((this.itemOptions.multiple || this.multiple) && Array.isArray(this.currentVal)) { | ||
const multiple_elements = this.selectArr.filter((item) => this.currentVal.includes(item[this.keyValue[1]])); | ||
this.selectArr = [...multiple_elements, ...this.selectArr.filter((item) => !multiple_elements.includes(item))]; | ||
} else { | ||
const index = this.selectArr.findIndex((item) => item.value === this.currentVal); | ||
if (index !== -1) { | ||
const obj = this.selectArr.splice(index, 1)[0]; | ||
this.selectArr.unshift(obj); | ||
} | ||
var _a; | ||
if (this.isVirtualSelect) { | ||
this.selectArr = ((_a = this.optionsList) == null ? void 0 : _a.map((it) => ({ | ||
[this.keyValue[0]]: it[this.keyValue[0]], | ||
[this.keyValue[1]]: it[this.keyValue[1]], | ||
[this.dataKey]: it[this.keyValue[1]], | ||
disabled: it["disabled"] ?? false | ||
}))) ?? []; | ||
if (this.currentVal) { | ||
if ((this.itemOptions.multiple || this.multiple) && Array.isArray(this.currentVal)) { | ||
const multiple_elements = this.selectArr.filter((item) => this.currentVal.includes(item[this.keyValue[1]])); | ||
this.selectArr = [...multiple_elements, ...this.selectArr.filter((item) => !multiple_elements.includes(item))]; | ||
} else { | ||
const index = this.selectArr.findIndex((item) => item.value === this.currentVal); | ||
if (index !== -1) { | ||
const obj = this.selectArr.splice(index, 1)[0]; | ||
this.selectArr.unshift(obj); | ||
} | ||
} | ||
} else { | ||
this.selectArr = (this.optionsList || []).map((it) => ({ | ||
[this.keyValue[0]]: it[this.keyValue[0]], | ||
[this.keyValue[1]]: it[this.keyValue[1]], | ||
disabled: it["disabled"] ?? false | ||
})); | ||
} | ||
}); | ||
} else { | ||
this.selectArr = (this.optionsList || []).map((it) => ({ | ||
[this.keyValue[0]]: it[this.keyValue[0]], | ||
[this.keyValue[1]]: it[this.keyValue[1]], | ||
disabled: it["disabled"] ?? false | ||
})); | ||
} | ||
}, | ||
// 搜索 | ||
async filterMethod(query) { | ||
var _a, _b, _c; | ||
const filterHandler = this.bindProps["filter-method"]; | ||
if (query !== "") { | ||
this.$refs.virtualSelectList.scrollToIndex(0); | ||
await vueDemi.nextTick(); | ||
await new Promise((resolve) => { | ||
let timer = setTimeout(() => { | ||
clearTimeout(timer); | ||
timer = void 0; | ||
resolve(true); | ||
}, 30); | ||
}); | ||
if (filterHandler) { | ||
await filterHandler(query); | ||
} else { | ||
const arr = ((_b = (_a = this.itemOptions) == null ? void 0 : _a.options) == null ? void 0 : _b.length) ? this.itemOptions.options : ((_c = this.options) == null ? void 0 : _c.length) ? this.options : []; | ||
const selectArr = arr.filter((item) => { | ||
this.reset(); | ||
const selectArr = this.optionsList.filter((item) => { | ||
if (item[this.keyValue[0]]) { | ||
@@ -496,4 +497,3 @@ return item[this.keyValue[0]].toLowerCase().indexOf(query.toLowerCase()) > -1; | ||
[this.dataKey]: it[this.keyValue[1]], | ||
disabled: it["disabled"] ? it["disabled"] : false, | ||
slotContent: (it == null ? void 0 : it.slotContent) || {} | ||
disabled: it["disabled"] ? it["disabled"] : false | ||
}; | ||
@@ -523,5 +523,2 @@ }); | ||
} | ||
if (!events["visible-change"]) { | ||
this.$emit("visible-change", bool); | ||
} | ||
} | ||
@@ -528,0 +525,0 @@ }, |
import virtualList from "vue-virtual-scroll-list"; | ||
import { normalizeComponent } from "@94ai/vue2-runtime-helpers"; | ||
import { isEqual } from "lodash-es"; | ||
import { nextTick } from "vue-demi"; | ||
import "vue-demi"; | ||
const _sfc_main$1 = { | ||
@@ -290,5 +290,2 @@ name: "ItemComponent", | ||
}, | ||
isVirtualSelect() { | ||
return this.virtualList || this.itemOptions.virtualList; | ||
}, | ||
// 绑定属性 | ||
@@ -298,4 +295,8 @@ bindProps() { | ||
clearable: true, | ||
...this.itemOptions, | ||
...this.$attrs, | ||
...this.formatItemOptions | ||
virtualList: this.isVirtualSelect, | ||
placeholder: this.placeholderDesc, | ||
multiple: this.isMultipleSelect, | ||
options: this.optionsList | ||
}; | ||
@@ -323,2 +324,8 @@ if (obj.element === "custom-select" || obj.element === "el-select") { | ||
} | ||
if (events == null ? void 0 : events.input) { | ||
delete events.input; | ||
} | ||
if (events == null ? void 0 : events["update:value"]) { | ||
delete events["update:value"]; | ||
} | ||
if ((events == null ? void 0 : events["visible-change"]) && (this.virtualList || ((_a = this.itemOptions) == null ? void 0 : _a.virtualList))) { | ||
@@ -329,18 +336,11 @@ delete events["visible-change"]; | ||
}, | ||
formatItemOptions() { | ||
const that = this; | ||
return { | ||
...this.itemOptions, | ||
...this.$attrs, | ||
virtualList: this.itemOptions.virtualList || this.virtualList, | ||
placeholder: this.itemOptions.placeholder || this.placeholder, | ||
multiple: this.itemOptions.multiple || this.multiple, | ||
options: this.optionsList, | ||
events: { | ||
change(val) { | ||
that.$emit("change", val); | ||
} | ||
} | ||
}; | ||
isVirtualSelect() { | ||
return this.virtualList || this.itemOptions.virtualList; | ||
}, | ||
isMultipleSelect() { | ||
return this.multiple || this.itemOptions.multiple; | ||
}, | ||
placeholderDesc() { | ||
return this.itemOptions.placeholder || this.placeholder; | ||
}, | ||
optionsList() { | ||
@@ -358,3 +358,3 @@ var _a; | ||
watch: { | ||
options(newVal, value) { | ||
optionsList(newVal, value) { | ||
if (!isEqual(newVal, value)) { | ||
@@ -382,3 +382,15 @@ this.init(); | ||
scrollToIndex(index) { | ||
this.$refs.virtualSelectList.scrollToIndex(index); | ||
var _a, _b, _c, _d, _e; | ||
try { | ||
if (this.isVirtualSelect) { | ||
(_a = this.$refs.virtualSelectList) == null ? void 0 : _a.scrollToIndex(index); | ||
} else { | ||
const container = (_e = (_d = (_c = (_b = this.$refs.nfVirtualSelect) == null ? void 0 : _b.$refs) == null ? void 0 : _c.popper) == null ? void 0 : _d.$el) == null ? void 0 : _e.querySelector(".el-select-dropdown__wrap"); | ||
if (container) { | ||
container.scrollTop = 0; | ||
} | ||
} | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
}, | ||
@@ -398,3 +410,4 @@ scrollToOffset(offset) { | ||
updatePageModeFront() { | ||
this.$refs.virtualSelectList.updatePageModeFront(); | ||
var _a; | ||
(_a = this.$refs.virtualSelectList) == null ? void 0 : _a.updatePageModeFront(); | ||
}, | ||
@@ -434,51 +447,39 @@ scroll(event) { | ||
init() { | ||
this.$nextTick(() => { | ||
var _a; | ||
if (this.isVirtualSelect) { | ||
this.selectArr = ((_a = this.optionsList) == null ? void 0 : _a.map((it) => ({ | ||
[this.keyValue[0]]: it[this.keyValue[0]], | ||
[this.keyValue[1]]: it[this.keyValue[1]], | ||
[this.dataKey]: it[this.keyValue[1]], | ||
disabled: it["disabled"] ?? false | ||
}))) ?? []; | ||
if (this.currentVal) { | ||
if ((this.itemOptions.multiple || this.multiple) && Array.isArray(this.currentVal)) { | ||
const multiple_elements = this.selectArr.filter((item) => this.currentVal.includes(item[this.keyValue[1]])); | ||
this.selectArr = [...multiple_elements, ...this.selectArr.filter((item) => !multiple_elements.includes(item))]; | ||
} else { | ||
const index = this.selectArr.findIndex((item) => item.value === this.currentVal); | ||
if (index !== -1) { | ||
const obj = this.selectArr.splice(index, 1)[0]; | ||
this.selectArr.unshift(obj); | ||
} | ||
var _a; | ||
if (this.isVirtualSelect) { | ||
this.selectArr = ((_a = this.optionsList) == null ? void 0 : _a.map((it) => ({ | ||
[this.keyValue[0]]: it[this.keyValue[0]], | ||
[this.keyValue[1]]: it[this.keyValue[1]], | ||
[this.dataKey]: it[this.keyValue[1]], | ||
disabled: it["disabled"] ?? false | ||
}))) ?? []; | ||
if (this.currentVal) { | ||
if ((this.itemOptions.multiple || this.multiple) && Array.isArray(this.currentVal)) { | ||
const multiple_elements = this.selectArr.filter((item) => this.currentVal.includes(item[this.keyValue[1]])); | ||
this.selectArr = [...multiple_elements, ...this.selectArr.filter((item) => !multiple_elements.includes(item))]; | ||
} else { | ||
const index = this.selectArr.findIndex((item) => item.value === this.currentVal); | ||
if (index !== -1) { | ||
const obj = this.selectArr.splice(index, 1)[0]; | ||
this.selectArr.unshift(obj); | ||
} | ||
} | ||
} else { | ||
this.selectArr = (this.optionsList || []).map((it) => ({ | ||
[this.keyValue[0]]: it[this.keyValue[0]], | ||
[this.keyValue[1]]: it[this.keyValue[1]], | ||
disabled: it["disabled"] ?? false | ||
})); | ||
} | ||
}); | ||
} else { | ||
this.selectArr = (this.optionsList || []).map((it) => ({ | ||
[this.keyValue[0]]: it[this.keyValue[0]], | ||
[this.keyValue[1]]: it[this.keyValue[1]], | ||
disabled: it["disabled"] ?? false | ||
})); | ||
} | ||
}, | ||
// 搜索 | ||
async filterMethod(query) { | ||
var _a, _b, _c; | ||
const filterHandler = this.bindProps["filter-method"]; | ||
if (query !== "") { | ||
this.$refs.virtualSelectList.scrollToIndex(0); | ||
await nextTick(); | ||
await new Promise((resolve) => { | ||
let timer = setTimeout(() => { | ||
clearTimeout(timer); | ||
timer = void 0; | ||
resolve(true); | ||
}, 30); | ||
}); | ||
if (filterHandler) { | ||
await filterHandler(query); | ||
} else { | ||
const arr = ((_b = (_a = this.itemOptions) == null ? void 0 : _a.options) == null ? void 0 : _b.length) ? this.itemOptions.options : ((_c = this.options) == null ? void 0 : _c.length) ? this.options : []; | ||
const selectArr = arr.filter((item) => { | ||
this.reset(); | ||
const selectArr = this.optionsList.filter((item) => { | ||
if (item[this.keyValue[0]]) { | ||
@@ -493,4 +494,3 @@ return item[this.keyValue[0]].toLowerCase().indexOf(query.toLowerCase()) > -1; | ||
[this.dataKey]: it[this.keyValue[1]], | ||
disabled: it["disabled"] ? it["disabled"] : false, | ||
slotContent: (it == null ? void 0 : it.slotContent) || {} | ||
disabled: it["disabled"] ? it["disabled"] : false | ||
}; | ||
@@ -520,5 +520,2 @@ }); | ||
} | ||
if (!events["visible-change"]) { | ||
this.$emit("visible-change", bool); | ||
} | ||
} | ||
@@ -525,0 +522,0 @@ }, |
@@ -158,6 +158,7 @@ declare const _default: import("vue-demi").DefineComponent<{ | ||
}; | ||
isVirtualSelect(): any; | ||
bindProps(): any; | ||
bindEvents(): any; | ||
formatItemOptions(): any; | ||
isVirtualSelect(): any; | ||
isMultipleSelect(): any; | ||
placeholderDesc(): any; | ||
optionsList(): any; | ||
@@ -317,3 +318,2 @@ }, {}, import("vue/types/v3-component-options").ComponentOptionsMixin, import("vue/types/v3-component-options").ComponentOptionsMixin, {}, string, Readonly<import("vue-demi").ExtractPropTypes<{ | ||
placeholder: string; | ||
options: unknown[]; | ||
offset: number; | ||
@@ -345,2 +345,3 @@ start: number; | ||
virtualList: boolean; | ||
options: unknown[]; | ||
multiple: boolean; | ||
@@ -347,0 +348,0 @@ width: string; |
{ | ||
"name": "@94ai/nf-virtual-select", | ||
"version": "3.2.76", | ||
"version": "3.2.77", | ||
"description": "> TODO: description", | ||
@@ -17,4 +17,4 @@ "keywords": [], | ||
"dependencies": { | ||
"@94ai/common-utils": "^3.2.76", | ||
"@94ai/nf-theme-chalk": "^3.2.76", | ||
"@94ai/common-utils": "^3.2.77", | ||
"@94ai/nf-theme-chalk": "^3.2.77", | ||
"lodash-es": "^4.17.21", | ||
@@ -37,3 +37,3 @@ "vue-demi": "^0.14.5", | ||
"module": "lib/nf-virtual-select.esm-bundler.js", | ||
"gitHead": "07f6d8aca65e93849c2f70cf0b83fdf2ae2cc0f1" | ||
"gitHead": "c83df2f1fd663fdab0735f187aeab554cb743512" | ||
} |
Sorry, the diff of this file is not supported yet
84482
2734
Updated@94ai/common-utils@^3.2.77
Updated@94ai/nf-theme-chalk@^3.2.77