{"version":3,"file":"index.js","sources":["../../../../../../../packages/components/table/src/table-header/index.ts"],"sourcesContent":["// @ts-nocheck\nimport {\n defineComponent,\n getCurrentInstance,\n h,\n inject,\n nextTick,\n onMounted,\n ref,\n} from 'vue'\nimport ElCheckbox from '@element-plus/components/checkbox'\nimport { useNamespace } from '@element-plus/hooks'\nimport FilterPanel from '../filter-panel.vue'\nimport useLayoutObserver from '../layout-observer'\nimport { TABLE_INJECTION_KEY } from '../tokens'\nimport useEvent from './event-helper'\nimport useStyle from './style.helper'\nimport useUtils from './utils-helper'\nimport type { ComponentInternalInstance, PropType, Ref } from 'vue'\nimport type { DefaultRow, Sort } from '../table/defaults'\nimport type { Store } from '../store'\nexport interface TableHeader extends ComponentInternalInstance {\n state: {\n onColumnsChange\n onScrollableChange\n }\n filterPanels: Ref\n}\nexport interface TableHeaderProps {\n fixed: string\n store: Store\n border: boolean\n defaultSort: Sort\n}\n\nexport default defineComponent({\n name: 'ElTableHeader',\n components: {\n ElCheckbox,\n },\n props: {\n fixed: {\n type: String,\n default: '',\n },\n store: {\n required: true,\n type: Object as PropType['store']>,\n },\n border: Boolean,\n defaultSort: {\n type: Object as PropType['defaultSort']>,\n default: () => {\n return {\n prop: '',\n order: '',\n }\n },\n },\n appendFilterPanelTo: {\n type: String,\n },\n },\n setup(props, { emit }) {\n const instance = getCurrentInstance() as TableHeader\n const parent = inject(TABLE_INJECTION_KEY)\n const ns = useNamespace('table')\n const filterPanels = ref({})\n const { onColumnsChange, onScrollableChange } = useLayoutObserver(parent!)\n onMounted(async () => {\n // Need double await, because updateColumns is executed after nextTick for now\n await nextTick()\n await nextTick()\n const { prop, order } = props.defaultSort\n parent?.store.commit('sort', { prop, order, init: true })\n })\n const {\n handleHeaderClick,\n handleHeaderContextMenu,\n handleMouseDown,\n handleMouseMove,\n handleMouseOut,\n handleSortClick,\n handleFilterClick,\n } = useEvent(props as TableHeaderProps, emit)\n const {\n getHeaderRowStyle,\n getHeaderRowClass,\n getHeaderCellStyle,\n getHeaderCellClass,\n } = useStyle(props as TableHeaderProps)\n const { isGroup, toggleAllSelection, columnRows } = useUtils(\n props as TableHeaderProps\n )\n\n instance.state = {\n onColumnsChange,\n onScrollableChange,\n }\n instance.filterPanels = filterPanels\n\n return {\n ns,\n filterPanels,\n onColumnsChange,\n onScrollableChange,\n columnRows,\n getHeaderRowClass,\n getHeaderRowStyle,\n getHeaderCellClass,\n getHeaderCellStyle,\n handleHeaderClick,\n handleHeaderContextMenu,\n handleMouseDown,\n handleMouseMove,\n handleMouseOut,\n handleSortClick,\n handleFilterClick,\n isGroup,\n toggleAllSelection,\n }\n },\n render() {\n const {\n ns,\n isGroup,\n columnRows,\n getHeaderCellStyle,\n getHeaderCellClass,\n getHeaderRowClass,\n getHeaderRowStyle,\n handleHeaderClick,\n handleHeaderContextMenu,\n handleMouseDown,\n handleMouseMove,\n handleSortClick,\n handleMouseOut,\n store,\n $parent,\n } = this\n let rowSpan = 1\n return h(\n 'thead',\n {\n class: { [ns.is('group')]: isGroup },\n },\n columnRows.map((subColumns, rowIndex) =>\n h(\n 'tr',\n {\n class: getHeaderRowClass(rowIndex),\n key: rowIndex,\n style: getHeaderRowStyle(rowIndex),\n },\n subColumns.map((column, cellIndex) => {\n if (column.rowSpan > rowSpan) {\n rowSpan = column.rowSpan\n }\n return h(\n 'th',\n {\n class: getHeaderCellClass(\n rowIndex,\n cellIndex,\n subColumns,\n column\n ),\n colspan: column.colSpan,\n key: `${column.id}-thead`,\n rowspan: column.rowSpan,\n style: getHeaderCellStyle(\n rowIndex,\n cellIndex,\n subColumns,\n column\n ),\n onClick: ($event) => {\n if ($event.currentTarget.classList.contains('noclick')) {\n return\n }\n handleHeaderClick($event, column)\n },\n onContextmenu: ($event) =>\n handleHeaderContextMenu($event, column),\n onMousedown: ($event) => handleMouseDown($event, column),\n onMousemove: ($event) => handleMouseMove($event, column),\n onMouseout: handleMouseOut,\n },\n [\n h(\n 'div',\n {\n class: [\n 'cell',\n column.filteredValue && column.filteredValue.length > 0\n ? 'highlight'\n : '',\n ],\n },\n [\n column.renderHeader\n ? column.renderHeader({\n column,\n $index: cellIndex,\n store,\n _self: $parent,\n })\n : column.label,\n column.sortable &&\n h(\n 'span',\n {\n onClick: ($event) => handleSortClick($event, column),\n class: 'caret-wrapper',\n },\n [\n h('i', {\n onClick: ($event) =>\n handleSortClick($event, column, 'ascending'),\n class: 'sort-caret ascending',\n }),\n h('i', {\n onClick: ($event) =>\n handleSortClick($event, column, 'descending'),\n class: 'sort-caret descending',\n }),\n ]\n ),\n column.filterable &&\n h(\n FilterPanel,\n {\n store,\n placement: column.filterPlacement || 'bottom-start',\n appendTo: $parent.appendFilterPanelTo,\n column,\n upDataColumn: (key, value) => {\n column[key] = value\n },\n },\n {\n 'filter-icon': () =>\n column.renderFilterIcon\n ? column.renderFilterIcon({\n filterOpened: column.filterOpened,\n })\n : null,\n }\n ),\n ]\n ),\n ]\n )\n })\n )\n )\n )\n },\n})\n"],"names":["defineComponent","ElCheckbox","getCurrentInstance","inject","TABLE_INJECTION_KEY","useNamespace","ref","useLayoutObserver","onMounted","nextTick","useEvent","useStyle","useUtils","h","FilterPanel"],"mappings":";;;;;;;;;;;;;;;AAiBA,kBAAeA,mBAAe,CAAC;AAC/B,EAAE,IAAI,EAAE,eAAe;AACvB,EAAE,UAAU,EAAE;AACd,gBAAIC,gBAAU;AACd,GAAG;AACH,EAAE,KAAK,EAAE;AACT,IAAI,KAAK,EAAE;AACX,MAAM,IAAI,EAAE,MAAM;AAClB,MAAM,OAAO,EAAE,EAAE;AACjB,KAAK;AACL,IAAI,KAAK,EAAE;AACX,MAAM,QAAQ,EAAE,IAAI;AACpB,MAAM,IAAI,EAAE,MAAM;AAClB,KAAK;AACL,IAAI,MAAM,EAAE,OAAO;AACnB,IAAI,WAAW,EAAE;AACjB,MAAM,IAAI,EAAE,MAAM;AAClB,MAAM,OAAO,EAAE,MAAM;AACrB,QAAQ,OAAO;AACf,UAAU,IAAI,EAAE,EAAE;AAClB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