| 1234567891011121314151617181920212223242526272829303132333435 |
- import { isArray, isFunction, isString } from "../../../utils/types.mjs";
- import { selectKey } from "./token.mjs";
- import { isEqual } from "lodash-unified";
- import { defineComponent, inject } from "vue";
- //#region ../../packages/components/select/src/options.ts
- var options_default = defineComponent({
- name: "ElOptions",
- setup(_, { slots }) {
- const select = inject(selectKey);
- let cachedValueList = [];
- return () => {
- const children = slots.default?.();
- const valueList = [];
- function filterOptions(children) {
- if (!isArray(children)) return;
- children.forEach((item) => {
- const name = (item?.type || {})?.name;
- if (name === "ElOptionGroup") filterOptions(!isString(item.children) && !isArray(item.children) && isFunction(item.children?.default) ? item.children?.default() : item.children);
- else if (name === "ElOption") valueList.push(item.props?.value);
- else if (isArray(item.children)) filterOptions(item.children);
- });
- }
- if (children.length) filterOptions(children[0]?.children);
- if (!isEqual(valueList, cachedValueList)) {
- cachedValueList = valueList;
- if (select) select.states.optionValues = valueList;
- }
- return children;
- };
- }
- });
- //#endregion
- export { options_default as default };
- //# sourceMappingURL=options.mjs.map
|