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
49 KiB

1 month ago
  1. {"ast":null,"code":"import { getCurrentInstance, toRefs, ref, computed, watch, unref } from 'vue';\nimport { getKeysMap, getRowIdentity, toggleRowStatus, getColumnById, getColumnByKey, orderBy } from '../util.mjs';\nimport useExpand from './expand.mjs';\nimport useCurrent from './current.mjs';\nimport useTree from './tree.mjs';\nimport { isUndefined } from '../../../../utils/types.mjs';\nimport { hasOwn, isArray, isString } from '@vue/shared';\nconst sortData = (data, states) => {\n const sortingColumn = states.sortingColumn;\n if (!sortingColumn || isString(sortingColumn.sortable)) {\n return data;\n }\n return orderBy(data, states.sortProp, states.sortOrder, sortingColumn.sortMethod, sortingColumn.sortBy);\n};\nconst doFlattenColumns = columns => {\n const result = [];\n columns.forEach(column => {\n if (column.children && column.children.length > 0) {\n result.push.apply(result, doFlattenColumns(column.children));\n } else {\n result.push(column);\n }\n });\n return result;\n};\nfunction useWatcher() {\n var _a;\n const instance = getCurrentInstance();\n const {\n size: tableSize\n } = toRefs((_a = instance.proxy) == null ? void 0 : _a.$props);\n const rowKey = ref(null);\n const data = ref([]);\n const _data = ref([]);\n const isComplex = ref(false);\n const _columns = ref([]);\n const originColumns = ref([]);\n const columns = ref([]);\n const fixedColumns = ref([]);\n const rightFixedColumns = ref([]);\n const leafColumns = ref([]);\n const fixedLeafColumns = ref([]);\n const rightFixedLeafColumns = ref([]);\n const updateOrderFns = [];\n const leafColumnsLength = ref(0);\n const fixedLeafColumnsLength = ref(0);\n const rightFixedLeafColumnsLength = ref(0);\n const isAllSelected = ref(false);\n const selection = ref([]);\n const reserveSelection = ref(false);\n const selectOnIndeterminate = ref(false);\n const selectable = ref(null);\n const filters = ref({});\n const filteredData = ref(null);\n const sortingColumn = ref(null);\n const sortProp = ref(null);\n const sortOrder = ref(null);\n const hoverRow = ref(null);\n const selectedMap = computed(() => {\n return rowKey.value ? getKeysMap(selection.value, rowKey.value) : void 0;\n });\n watch(data, () => {\n var _a2;\n if (instance.state) {\n scheduleLayout(false);\n const needUpdateFixed = instance.props.tableLayout === \"auto\";\n if (needUpdateFixed) {\n (_a2 = instance.refs.tableHeaderRef) == null ? void 0 : _a2.updateFixedColumnStyle();\n }\n }\n }, {\n deep: true\n });\n const assertRowKey = () => {\n if (!rowKey.value) throw new Error(\"[ElTable] prop row-key is required\");\n };\n const updateChildFixed = column => {\n var _a2;\n (_a2 = column.children) == null ? void 0 : _a2.forEach(childColumn => {\n childColumn.fixed = column.fixed;\n updateChildFixed(childColumn);\n });\n };\n let selectionInitialFixed = void 0;\n const updateColumns = () => {\n _columns.value.forEach(column => {\n updateChildFixed(column);\n });\n fixedColumns.value = _columns.value.filter(column => column.fixed === true || column.fixed === \"left\");\n rightFixedColumns.value = _columns.value.filter(column => column.fixed === \"right\");\n if (isUndefined(selectionInitialFixed) && _columns.value[0] && _columns.value[0].type === \"selection\") {\n selectionInitialFixed = Boolean(_columns.value[0].fixed);\n }\n if (fixedColumns.value.length > 0 && _columns.value[0] && _columns.value[0].type === \"selection\") {\n if (!_columns.value[0].fixed) {\n _columns.value[0].fixed = true;\n fixedColumns.value.unshift(_columns.value[0]);\n } else {\n const hasNotSelectionColumns = fixedColumns.value.some(column => column.type !== \"selection\");\n if (!hasNotSelectionColumns) {\n _columns.value[0].fixed = selectionInitialFixed;\n if (!selectionInitialFixed) fixedColumns.value.shift();\n } else {\n selectionInitialFixed = void 0;\n }\n }\n }\n