{"version":3,"file":"watcher-helper.js","sources":["../../../../../../../packages/components/table/src/table-column/watcher-helper.ts"],"sourcesContent":["// @ts-nocheck\nimport { getCurrentInstance, watch } from 'vue'\nimport { hasOwn } from '@element-plus/utils'\nimport { parseMinWidth, parseWidth } from '../util'\n\nimport type { ComputedRef } from 'vue'\nimport type { TableColumn, TableColumnCtx, ValueOf } from './defaults'\n\nfunction getAllAliases(props, aliases) {\n return props.reduce((prev, cur) => {\n prev[cur] = cur\n return prev\n }, aliases)\n}\nfunction useWatcher(\n owner: ComputedRef,\n props_: Partial>\n) {\n const instance = getCurrentInstance() as TableColumn\n const registerComplexWatchers = () => {\n const props = ['fixed']\n const aliases = {\n realWidth: 'width',\n realMinWidth: 'minWidth',\n }\n const allAliases = getAllAliases(props, aliases)\n Object.keys(allAliases).forEach((key) => {\n const columnKey = aliases[key]\n if (hasOwn(props_, columnKey)) {\n watch(\n () => props_[columnKey],\n (newVal) => {\n let value: ValueOf> = newVal\n if (columnKey === 'width' && key === 'realWidth') {\n value = parseWidth(newVal)\n }\n if (columnKey === 'minWidth' && key === 'realMinWidth') {\n value = parseMinWidth(newVal)\n }\n instance.columnConfig.value[columnKey as any] = value\n instance.columnConfig.value[key] = value\n const updateColumns = columnKey === 'fixed'\n owner.value.store.scheduleLayout(updateColumns)\n }\n )\n }\n })\n }\n const registerNormalWatchers = () => {\n const props = [\n 'label',\n 'filters',\n 'filterMultiple',\n 'filteredValue',\n 'sortable',\n 'index',\n 'formatter',\n 'className',\n 'labelClassName',\n 'filterClassName',\n 'showOverflowTooltip',\n ]\n const aliases = {\n property: 'prop',\n align: 'realAlign',\n headerAlign: 'realHeaderAlign',\n }\n const allAliases = getAllAliases(props, aliases)\n Object.keys(allAliases).forEach((key) => {\n const columnKey = aliases[key]\n if (hasOwn(props_, columnKey)) {\n watch(\n () => props_[columnKey],\n (newVal) => {\n instance.columnConfig.value[key] = newVal\n }\n )\n }\n })\n }\n\n return {\n registerComplexWatchers,\n registerNormalWatchers,\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