{"version":3,"file":"index.js","sources":["../../../../../../../packages/components/table/src/table-column/index.ts"],"sourcesContent":["// @ts-nocheck\nimport {\n Fragment,\n computed,\n defineComponent,\n getCurrentInstance,\n h,\n onBeforeMount,\n onBeforeUnmount,\n onMounted,\n ref,\n} from 'vue'\nimport ElCheckbox from '@element-plus/components/checkbox'\nimport { isString, isUndefined } from '@element-plus/utils'\nimport { cellStarts } from '../config'\nimport { compose, mergeOptions } from '../util'\nimport useWatcher from './watcher-helper'\nimport useRender from './render-helper'\nimport defaultProps from './defaults'\nimport type { TableColumn, TableColumnCtx } from './defaults'\n\nimport type { DefaultRow } from '../table/defaults'\n\nlet columnIdSeed = 1\n\nexport default defineComponent({\n name: 'ElTableColumn',\n components: {\n ElCheckbox,\n },\n props: defaultProps,\n setup(props, { slots }) {\n const instance = getCurrentInstance() as TableColumn\n const columnConfig = ref>>({})\n const owner = computed(() => {\n let parent = instance.parent as any\n while (parent && !parent.tableId) {\n parent = parent.parent\n }\n return parent\n })\n\n const { registerNormalWatchers, registerComplexWatchers } = useWatcher(\n owner,\n props\n )\n const {\n columnId,\n isSubColumn,\n realHeaderAlign,\n columnOrTableParent,\n setColumnWidth,\n setColumnForcedProps,\n setColumnRenders,\n getPropsData,\n getColumnElIndex,\n realAlign,\n updateColumnOrder,\n } = useRender(props as unknown as TableColumnCtx, slots, owner)\n\n const parent = columnOrTableParent.value\n columnId.value = `${\n parent.tableId || parent.columnId\n }_column_${columnIdSeed++}`\n onBeforeMount(() => {\n isSubColumn.value = owner.value !== parent\n\n const type = props.type || 'default'\n const sortable = props.sortable === '' ? true : props.sortable\n const showOverflowTooltip = isUndefined(props.showOverflowTooltip)\n ? parent.props.showOverflowTooltip\n : props.showOverflowTooltip\n const defaults = {\n ...cellStarts[type],\n id: columnId.value,\n type,\n property: props.prop || props.property,\n align: realAlign,\n headerAlign: realHeaderAlign,\n showOverflowTooltip,\n // filter 相关属性\n filterable: props.filters || props.filterMethod,\n filteredValue: [],\n filterPlacement: '',\n filterClassName: '',\n isColumnGroup: false,\n isSubColumn: false,\n filterOpened: false,\n // sort 相关属性\n sortable,\n // index 列\n index: props.index,\n // \n rawColumnKey: instance.vnode.key,\n }\n\n const basicProps = [\n 'columnKey',\n 'label',\n 'className',\n 'labelClassName',\n 'type',\n 'renderHeader',\n 'formatter',\n 'fixed',\n 'resizable',\n ]\n const sortProps = ['sortMethod', 'sortBy', 'sortOrders']\n const selectProps = ['selectable', 'reserveSelection']\n const filterProps = [\n 'filterMethod',\n 'filters',\n 'filterMultiple',\n 'filterOpened',\n 'filteredValue',\n 'filterPlacement',\n 'filterClassName',\n ]\n\n let column = getPropsData(basicProps, sortProps, selectProps, filterProps)\n\n column = mergeOptions(defaults, column)\n // 注意 compose 中函数执行的顺序是从右到左\n const chains = compose(\n setColumnRenders,\n setColumnWidth,\n setColumnForcedProps\n )\n column = chains(column)\n columnConfig.value = column\n\n // 注册 watcher\n registerNormalWatchers()\n registerComplexWatchers()\n })\n onMounted(() => {\n const parent = columnOrTableParent.value\n const children = isSubColumn.value\n ? parent.vnode.el.children\n : parent.refs.hiddenColumns?.children\n const getColumnIndex = () =>\n getColumnElIndex(children || [], instance.vnode.el)\n columnConfig.value.getColumnIndex = getColumnIndex\n const columnIndex = getColumnIndex()\n columnIndex > -1 &&\n owner.value.store.commit(\n 'insertColumn',\n columnConfig.value,\n isSubColumn.value ? parent.columnConfig.value : null,\n updateColumnOrder\n )\n })\n onBeforeUnmount(() => {\n const getColumnIndex = columnConfig.value.getColumnIndex\n const columnIndex = getColumnIndex ? getColumnIndex() : -1\n columnIndex > -1 &&\n owner.value.store.commit(\n 'removeColumn',\n columnConfig.value,\n isSubColumn.value ? parent.columnConfig.value : null,\n updateColumnOrder\n )\n })\n instance.columnId = columnId.value\n\n instance.columnConfig = columnConfig\n return\n },\n render() {\n try {\n const renderDefault = this.$slots.default?.({\n row: {},\n column: {},\n $index: -1,\n })\n const children = []\n if (Array.isArray(renderDefault)) {\n for (const childNode of renderDefault) {\n if (\n childNode.type?.name === 'ElTableColumn' ||\n childNode.shapeFlag & 2\n ) {\n children.push(childNode)\n } else if (\n childNode.type === Fragment &&\n Array.isArray(childNode.children)\n ) {\n childNode.children.forEach((vnode) => {\n // No rendering when vnode is dynamic slot or text\n if (vnode?.patchFlag !== 1024 && !isString(vnode?.children)) {\n children.push(vnode)\n }\n })\n }\n }\n }\n const vnode = h('div', children)\n return vnode\n } catch {\n return h('div', [])\n }\n },\n})\n"],"names":["defineComponent","ElCheckbox","defaultProps","getCurrentInstance","ref","computed","useWatcher","useRender","onBeforeMount","isUndefined","cellStarts","mergeOptions","compose","onMounted","onBeforeUnmount","Fragment","isString","h"],"mappings":";;;;;;;;;;;;;;;AAkBA,IAAI,YAAY,GAAG,CAAC,CAAC;AACrB,oBAAeA,mBAAe,CAAC;AAC/B,EAAE,IAAI,EAAE,eAAe;AACvB,EAAE,UAAU,EAAE;AACd,gBAAIC,gBAAU;AACd,GAAG;AACH,EAAE,KAAK,EAAEC,mBAAY;AACrB,EAAE,KAAK,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE;AAC1B,IAAI,MAAM,QAAQ,GAAGC,sBAAkB,EAAE,CAAC;AAC1C,IAAI,MAAM,YAAY,GAAGC,OAAG,CAAC,EAAE,CAAC,CAAC;AACjC,IAAI,MAAM,KAAK,GAAGC,YAAQ,CAAC,MAAM;AACjC,MAAM,IAAI,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC;AACpC,MAAM,OAAO,OAAO,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;AAC1C,QAAQ,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC;AACjC,OAAO;AACP,MAAM,OAAO,OAAO,CAAC;AACrB,KAAK,CAAC,CAAC;AACP,IAAI,MAAM,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,GAAGC,wBAAU,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;AACzF,IAAI,MAAM;AACV,MAAM,QAAQ;AACd,MAAM,WAA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