1
This commit is contained in:
45
admin/node_modules/element-plus/es/components/select/src/options.mjs
generated
vendored
Normal file
45
admin/node_modules/element-plus/es/components/select/src/options.mjs
generated
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
import { defineComponent, inject } from 'vue';
|
||||
import { isEqual } from 'lodash-unified';
|
||||
import { selectKey } from './token.mjs';
|
||||
import { isArray, isString, isFunction } from '@vue/shared';
|
||||
|
||||
var ElOptions = defineComponent({
|
||||
name: "ElOptions",
|
||||
setup(_, { slots }) {
|
||||
const select = inject(selectKey);
|
||||
let cachedValueList = [];
|
||||
return () => {
|
||||
var _a, _b;
|
||||
const children = (_a = slots.default) == null ? void 0 : _a.call(slots);
|
||||
const valueList = [];
|
||||
function filterOptions(children2) {
|
||||
if (!isArray(children2))
|
||||
return;
|
||||
children2.forEach((item) => {
|
||||
var _a2, _b2, _c, _d;
|
||||
const name = (_a2 = (item == null ? void 0 : item.type) || {}) == null ? void 0 : _a2.name;
|
||||
if (name === "ElOptionGroup") {
|
||||
filterOptions(!isString(item.children) && !isArray(item.children) && isFunction((_b2 = item.children) == null ? void 0 : _b2.default) ? (_c = item.children) == null ? void 0 : _c.default() : item.children);
|
||||
} else if (name === "ElOption") {
|
||||
valueList.push((_d = item.props) == null ? void 0 : _d.value);
|
||||
} else if (isArray(item.children)) {
|
||||
filterOptions(item.children);
|
||||
}
|
||||
});
|
||||
}
|
||||
if (children.length) {
|
||||
filterOptions((_b = children[0]) == null ? void 0 : _b.children);
|
||||
}
|
||||
if (!isEqual(valueList, cachedValueList)) {
|
||||
cachedValueList = valueList;
|
||||
if (select) {
|
||||
select.states.optionValues = valueList;
|
||||
}
|
||||
}
|
||||
return children;
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
export { ElOptions as default };
|
||||
//# sourceMappingURL=options.mjs.map
|
||||
Reference in New Issue
Block a user