You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

0 lines
22 KiB

1 month ago
  1. {"ast":null,"code":"import { defineComponent, getCurrentInstance, inject, ref, reactive, watch, onMounted, nextTick, h } from 'vue';\nimport { ElCheckbox } from '../../../checkbox/index.mjs';\nimport FilterPanel from '../filter-panel.mjs';\nimport useLayoutObserver from '../layout-observer.mjs';\nimport { TABLE_INJECTION_KEY } from '../tokens.mjs';\nimport useEvent from './event-helper.mjs';\nimport useStyle from './style.helper.mjs';\nimport useUtils from './utils-helper.mjs';\nimport { useNamespace } from '../../../../hooks/use-namespace/index.mjs';\nvar TableHeader = 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\n },\n border: Boolean,\n defaultSort: {\n type: Object,\n default: () => {\n return {\n prop: \"\",\n order: \"\"\n };\n }\n },\n appendFilterPanelTo: {\n type: String\n },\n allowDragLastColumn: {\n type: Boolean\n }\n },\n setup(props, {\n emit\n }) {\n const instance = getCurrentInstance();\n const parent = inject(TABLE_INJECTION_KEY);\n const ns = useNamespace(\"table\");\n const filterPanels = ref({});\n const {\n onColumnsChange,\n onScrollableChange\n } = useLayoutObserver(parent);\n const isTableLayoutAuto = (parent == null ? void 0 : parent.props.tableLayout) === \"auto\";\n const saveIndexSelection = reactive(/* @__PURE__ */new Map());\n const theadRef = ref();\n const updateFixedColumnStyle = () => {\n setTimeout(() => {\n if (saveIndexSelection.size > 0) {\n saveIndexSelection.forEach((column, key) => {\n const el = theadRef.value.querySelector(`.${key.replace(/\\s/g, \".\")}`);\n if (el) {\n const width = el.getBoundingClientRect().width;\n column.width = width;\n }\n });\n saveIndexSelection.clear();\n }\n });\n };\n watch(saveIndexSelection, updateFixedColumnStyle);\n onMounted(async () => {\n await nextTick();\n await nextTick();\n const {\n prop,\n order\n } = props.defaultSort;\n parent == null ? void 0 : parent.store.commit(\"sort\", {\n prop,\n order,\n init: true\n });\n updateFixedColumnStyle();\n });\n const {\n handleHeaderClick,\n handleHeaderContextMenu,\n handleMouseDown,\n handleMouseMove,\n handleMouseOut,\n handleSortClick,\n handleFilterClick\n } = useEvent(props, emit);\n const {\n getHeaderRowStyle,\n getHeaderRowClass,\n getHeaderCellStyle,\n getHeaderCellClass\n } = useStyle(props);\n const {\n isGroup,\n toggleAllSelection,\n columnRows\n } = useUtils(props);\n instance.state = {\n onColumnsChange,\n onScrollableChange\n };\n instance.filterPanels = filterPanels;\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 saveIndexSelection,\n isTableLayoutAuto,\n theadRef,\n updateFixedColumnStyle\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 saveIndexSelection,\n isTableLayoutAuto\n } = this;\n let rowSpan = 1;\n return h(\"thead\", {\n