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

1 month ago
  1. {"ast":null,"code":"import { createVNode, render } from 'vue';\nimport { merge, get, flatMap, isNull } from 'lodash-unified';\nimport { ElTooltip } from '../../tooltip/index.mjs';\nimport { isArray, isString, isFunction, hasOwn, isObject } from '@vue/shared';\nimport { throwError } from '../../../utils/error.mjs';\nimport { isUndefined, isNumber, isBoolean } from '../../../utils/types.mjs';\nconst getCell = function (event) {\n var _a;\n return (_a = event.target) == null ? void 0 : _a.closest(\"td\");\n};\nconst orderBy = function (array, sortKey, reverse, sortMethod, sortBy) {\n if (!sortKey && !sortMethod && (!sortBy || isArray(sortBy) && !sortBy.length)) {\n return array;\n }\n if (isString(reverse)) {\n reverse = reverse === \"descending\" ? -1 : 1;\n } else {\n reverse = reverse && reverse < 0 ? -1 : 1;\n }\n const getKey = sortMethod ? null : function (value, index) {\n if (sortBy) {\n if (!isArray(sortBy)) {\n sortBy = [sortBy];\n }\n return sortBy.map(by => {\n if (isString(by)) {\n return get(value, by);\n } else {\n return by(value, index, array);\n }\n });\n }\n if (sortKey !== \"$key\") {\n if (isObject(value) && \"$value\" in value) value = value.$value;\n }\n return [isObject(value) ? get(value, sortKey) : value];\n };\n const compare = function (a, b) {\n if (sortMethod) {\n return sortMethod(a.value, b.value);\n }\n for (let i = 0, len = a.key.length; i < len; i++) {\n if (a.key[i] < b.key[i]) {\n return -1;\n }\n if (a.key[i] > b.key[i]) {\n return 1;\n }\n }\n return 0;\n };\n return array.map((value, index) => {\n return {\n value,\n index,\n key: getKey ? getKey(value, index) : null\n };\n }).sort((a, b) => {\n let order = compare(a, b);\n if (!order) {\n order = a.index - b.index;\n }\n return order * +reverse;\n }).map(item => item.value);\n};\nconst getColumnById = function (table, columnId) {\n let column = null;\n table.columns.forEach(item => {\n if (item.id === columnId) {\n column = item;\n }\n });\n return column;\n};\nconst getColumnByKey = function (table, columnKey) {\n let column = null;\n for (let i = 0; i < table.columns.length; i++) {\n const item = table.columns[i];\n if (item.columnKey === columnKey) {\n column = item;\n break;\n }\n }\n if (!column) throwError(\"ElTable\", `No column matching with column-key: ${columnKey}`);\n return column;\n};\nconst getColumnByCell = function (table, cell, namespace) {\n const matches = (cell.className || \"\").match(new RegExp(`${namespace}-table_[^\\\\s]+`, \"gm\"));\n if (matches) {\n return getColumnById(table, matches[0]);\n }\n return null;\n};\nconst getRowIdentity = (row, rowKey) => {\n if (!row) throw new Error(\"Row is required when get row identity\");\n if (isString(rowKey)) {\n if (!rowKey.includes(\".\")) {\n return `${row[rowKey]}`;\n }\n const key = rowKey.split(\".\");\n let current = row;\n for (const element of key) {\n current = current[element];\n }\n return `${current}`;\n } else if (isFunction(rowKey)) {\n return rowKey.call(null, row);\n }\n};\nconst getKeysMap = function (array, rowKey) {\n const arrayMap = {};\n (array || []).forEach((row, index) => {\n arrayMap[getRowIdentity(row, rowKey)] = {\n row,\n index\n };\n });\n return arrayMap;\n};\nfunction mergeOptions(defaults, config) {\n const options = {};\n let key;\n for (key in defaults) {\n options[key] = defaults[key];\n }\n for (key in config) {\n if (hasOwn(config, key)) {\n const value = config[key];\n if (!isUndefined(value)) {\n options[key] = value;\n }\n }\n }\n return options;\n}\nfunction parseWidth(width) {\n if (width === \"\") return width;\n if (!isUndefined(width)) {\n width = Number.parseInt(width, 10);\n if (Number.isNaN(width)) {\n width = \"\";\n }\n }\n return width;\n}\nfunction parseMinWid