{"version":3,"file":"options.js","sources":["../../../../../../packages/components/select/src/options.ts"],"sourcesContent":["import { defineComponent, inject } from 'vue'\nimport { isEqual } from 'lodash-unified'\nimport { isArray, isFunction, isString } from '@element-plus/utils'\nimport { selectKey } from './token'\nimport type { Component, VNode, VNodeNormalizedChildren } from 'vue'\n\nexport default defineComponent({\n name: 'ElOptions',\n setup(_, { slots }) {\n const select = inject(selectKey)\n let cachedValueList: any[] = []\n\n return () => {\n const children = slots.default?.()!\n const valueList: any[] = []\n\n function filterOptions(children?: VNodeNormalizedChildren) {\n if (!isArray(children)) return\n ;(children as VNode[]).forEach((item) => {\n const name = ((item?.type || {}) as Component)?.name\n\n if (name === 'ElOptionGroup') {\n filterOptions(\n !isString(item.children) &&\n !isArray(item.children) &&\n isFunction(item.children?.default)\n ? item.children?.default()\n : item.children\n )\n } else if (name === 'ElOption') {\n valueList.push(item.props?.value)\n } else if (isArray(item.children)) {\n filterOptions(item.children)\n }\n })\n }\n\n if (children.length) {\n filterOptions(children[0]?.children)\n }\n\n if (!isEqual(valueList, cachedValueList)) {\n cachedValueList = valueList\n if (select) {\n select.states.optionValues = valueList\n }\n }\n\n return children\n }\n },\n})\n"],"names":["defineComponent","inject","selectKey","isArray","isString","isFunction","isEqual"],"mappings":";;;;;;;;;;AAIA,gBAAeA,mBAAe,CAAC;AAC/B,EAAE,IAAI,EAAE,WAAW;AACnB,EAAE,KAAK,CAAC,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE;AACtB,IAAI,MAAM,MAAM,GAAGC,UAAM,CAACC,eAAS,CAAC,CAAC;AACrC,IAAI,IAAI,eAAe,GAAG,EAAE,CAAC;AAC7B,IAAI,OAAO,MAAM;AACjB,MAAM,IAAI,EAAE,EAAE,EAAE,CAAC;AACjB,MAAM,MAAM,QAAQ,GAAG,CAAC,EAAE,GAAG,KAAK,CAAC,OAAO,KAAK,IAAI,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;A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