1import { N as createVNode, a8 as render, $ as isVNode, r as ref, g as getCurrentInstance, u as unref, c as computed, e as watch, a6 as toRefs, n as nextTick, f as isRef, k as defineComponent, a2 as resolveComponent, al as resolveDirective, D as createBlock, m as openBlock, E as withCtx, L as withDirectives, l as createElementBlock, C as normalizeClass, q as renderSlot, v as createBaseVNode, F as Fragment, Z as renderList, _ as createTextVNode, H as toDisplayString, V as onBeforeMount, d as onMounted, P as onUpdated, y as onUnmounted, i as inject, a1 as h$1, h as reactive, K as onBeforeUnmount, w as watchEffect, B as createCommentVNode, I as normalizeStyle, M as vShow, p as provide, R as Comment } from "./quill-vendor-Bitzq2B7.js"; 2import { bv as setToString, bw as overRest, bx as identity, a9 as isObject, ai as isArrayLike, by as isIndex, bz as eq, $ as keys, af as baseAssignValue, a5 as isObjectLike, aa as isBuffer, bA as isTypedArray, ad as isArray, bB as isArguments, bC as isFunction, ab as Stack, au as arrayMap, bD as baseFlatten, bE as hasOwn, av as isUndefined, an as isNumber, D as isString, O as isFunction$1, C as isArray$1, f as ElTooltip, R as throwError, F as isBoolean, W as getProp, ao as isObject$1, bF as get, J as castArray, M as useNamespace, b0 as debounce, be as isClient, K as _export_sfc, bG as useTooltipContentProps, bH as ClickOutside, bI as arrow_up_default, bJ as arrow_down_default, w as ElIcon, bK as ElScrollbar, aU as useLocale, aL as isPropAbsent, bL as hasClass, bM as removeClass, bf as isElement, bN as addClass, b5 as useEventListener, S as useResizeObserver, L as useFormSize, aK as useSizeProp, aA as arrow_right_default, bO as loading_default, X as withInstall, Y as withNoopInstall } from "./index-C7I5J-ck.js"; 3import { c as copyObject, k as keysIn, d as copyArray, e as cloneBuffer, b as cloneTypedArray, i as initCloneObject } from "./_initCloneObject-BOTjGYWm.js"; 4import { i as isPlainObject, r as rAF } from "./raf-DVQvm2ab.js"; 5import { b as baseIteratee } from "./_baseIteratee-M5sC8FDm.js"; 6import { E as ElCheckbox } from "./el-checkbox-V7e63btM.js"; 7function baseRest(func, start) { 8 return setToString(overRest(func, start, identity), func + ""); 9} 10function isIterateeCall(value, index, object) { 11 if (!isObject(object)) { 12 return false; 13 } 14 var type = typeof index; 15 if (type == "number" ? isArrayLike(object) && isIndex(index, object.length) : type == "string" && index in object) { 16 return eq(object[index], value); 17 } 18 return false; 19} 20function createAssigner(assigner) { 21 return baseRest(function(object, sources) { 22 var index = -1, length = sources.length, customizer = length > 1 ? sources[length - 1] : void 0, guard = length > 2 ? sources[2] : void 0; 23 customizer = assigner.length > 3 && typeof customizer == "function" ? (length--, customizer) : void 0; 24 if (guard && isIterateeCall(sources[0], sources[1], guard)) { 25 customizer = length < 3 ? void 0 : customizer; 26 length = 1; 27 } 28 object = Object(object); 29 while (++index < length) { 30 var source = sources[index]; 31 if (source) { 32 assigner(object, source, index, customizer); 33 } 34 } 35 return object; 36 }); 37} 38function createBaseFor(fromRight) { 39 return function(object, iteratee, keysFunc) { 40 var index = -1, iterable = Object(object), props = keysFunc(object), length = props.length; 41 while (length--) { 42 var key = props[++index]; 43 if (iteratee(iterable[key], key, iterable) === false) { 44 break; 45 } 46 } 47 return object; 48 }; 49} 50var baseFor = createBaseFor(); 51function baseForOwn(object, iteratee) { 52 return object && baseFor(object, iteratee, keys); 53} 54function createBaseEach(eachFunc, fromRight) { 55 return function(collection, iteratee) { 56 if (collection == null) { 57 return collection; 58 } 59 if (!isArrayLike(collection)) { 60 return eachFunc(collection, iteratee); 61 } 62 var length = collection.length, index = -1, iterable = Object(collection); 63 while (++index < length) { 64 if (iteratee(iterable[index], index, iterable) === false) { 65 break; 66 } 67 } 68 return collection; 69 }; 70} 71var baseEach = createBaseEach(baseForOwn); 72function assignMergeValue(object, key, value) { 73 if (value !== void 0 && !eq(object[key], value) || value === void 0 && !(key in object)) { 74 baseAssignValue(object, key, value); 75 } 76} 77function isArrayLikeObject(value) { 78 return isObjectLike(value) && isArrayLike(value); 79} 80function safeGet(object, key) { 81 if (key === "constructor" && typeof object[key] === "function") { 82 return; 83 } 84 if (key == "__proto__") { 85 return; 86 } 87 return object[key]; 88} 89function toPlainObject(value) { 90 return copyObject(value, keysIn(value)); 91} 92function baseMergeDeep(object, source, key, srcIndex, mergeFunc, customizer, stack) { 93 var objValue = safeGet(object, key), srcValue = safeGet(source, key), stacked = stack.get(srcValue); 94 if (stacked) { 95 assignMergeValue(object, key, stacked); 96 return; 97 } 98 var newValue = customizer ? customizer(objValue, srcValue, key + "", object, source, stack) : void 0; 99 var isCommon = newValue === void 0; 100 if (isCommon) { 101 var isArr = isArray(srcValue), isBuff = !isArr && isBuffer(srcValue), isTyped = !isArr && !isBuff && isTypedArray(srcValue); 102 newValue = srcValue; 103 if (isArr || isBuff || isTyped) { 104 if (isArray(objValue)) { 105 newValue = objValue; 106 } else if (isArrayLikeObject(objValue)) { 107 newValue = copyArray(objValue); 108 } else if (isBuff) { 109 isCommon = false;
110 newValue = cloneBuffer(srcValue, true); 111 } else if (isTyped) { 112 isCommon = false; 113 newValue = cloneTypedArray(srcValue, true); 114 } else { 115 newValue = []; 116 } 117 } else if (isPlainObject(srcValue) || isArguments(srcValue)) { 118 newValue = objValue; 119 if (isArguments(objValue)) { 120 newValue = toPlainObject(objValue); 121 } else if (!isObject(objValue) || isFunction(objValue)) { 122 newValue = initCloneObject(srcValue); 123 } 124 } else { 125 isCommon = false; 126 } 127 } 128 if (isCommon) { 129 stack.set(srcValue, newValue); 130 mergeFunc(newValue, srcValue, srcIndex, customizer, stack); 131 stack["delete"](srcValue); 132 } 133 assignMergeValue(object, key, newValue); 134} 135function baseMerge(object, source, srcIndex, customizer, stack) { 136 if (object === source) { 137 return; 138 } 139 baseFor(source, function(srcValue, key) { 140 stack || (stack = new Stack()); 141 if (isObject(srcValue)) { 142 baseMergeDeep(object, source, key, srcIndex, baseMerge, customizer, stack); 143 } else { 144 var newValue = customizer ? customizer(safeGet(object, key), srcValue, key + "", object, source, stack) : void 0; 145 if (newValue === void 0) { 146 newValue = srcValue; 147 } 148 assignMergeValue(object, key, newValue); 149 } 150 }, keysIn); 151} 152function baseMap(collection, iteratee) { 153 var index = -1, result = isArrayLike(collection) ? Array(collection.length) : []; 154 baseEach(collection, function(value, key, collection2) { 155 result[++index] = iteratee(value, key, collection2); 156 }); 157 return result; 158} 159function map(collection, iteratee) { 160 var func = isArray(collection) ? arrayMap : baseMap; 161 return func(collection, baseIteratee(iteratee)); 162} 163function flatMap(collection, iteratee) { 164 return baseFlatten(map(collection, iteratee)); 165} 166function isNull(value) { 167 return value === null; 168} 169var merge = createAssigner(function(object, source, srcIndex) { 170 baseMerge(object, source, srcIndex); 171}); 172const getCell = function(event) { 173 var _a; 174 return (_a = event.target) == null ? void 0 : _a.closest("td"); 175}; 176const orderBy = function(array, sortKey, reverse, sortMethod, sortBy) { 177 if (!sortKey && !sortMethod && (!sortBy || isArray$1(sortBy) && !sortBy.length)) { 178 return array; 179 } 180 if (isString(reverse)) { 181 reverse = reverse === "descending" ? -1 : 1; 182 } else { 183 reverse = reverse && reverse < 0 ? -1 : 1; 184 } 185 const getKey = sortMethod ? null : function(value, index) { 186 if (sortBy) { 187 return flatMap(castArray(sortBy), (by) => { 188 if (isString(by)) { 189 return get(value, by); 190 } else { 191 return by(value, index, array); 192 } 193 }); 194 } 195 if (sortKey !== "$key") { 196 if (isObject$1(value) && "$value" in value) 197 value = value.$value; 198 } 199 return [ 200 isObject$1(value) ? sortKey ? get(value, sortKey) : null : value 201 ]; 202 }; 203 const compare = function(a2, b2) { 204 var _a, _b, _c, _d, _e, _f; 205 if (sortMethod) { 206 return sortMethod(a2.value, b2.value); 207 } 208 for (let i = 0, len = (_b = (_a = a2.key) == null ? void 0 : _a.length) != null ? _b : 0; i < len; i++) { 209 if (((_c = a2.key) == null ? void 0 : _c[i]) < ((_d = b2.key) == null ? void 0 : _d[i])) { 210 return -1; 211 } 212 if (((_e = a2.key) == null ? void 0 : _e[i]) > ((_f = b2.key) == null ? void 0 : _f[i])) { 213 return 1; 214 } 215 } 216 return 0; 217 }; 218 return array.map((value, index) => { 219 return { 220 value, 221 index, 222 key: getKey ? getKey(value, index) : null 223 }; 224 }).sort((a2, b2) => { 225 let order = compare(a2, b2); 226 if (!order) { 227 order = a2.index - b2.index; 228 } 229 return order * +reverse; 230 }).map((item) => item.value); 231}; 232const getColumnById = function(table, columnId) { 233 let column = null; 234 table.columns.forEach((item) => { 235 if (item.id === columnId) { 236 column = item; 237 } 238 }); 239 return column; 240}; 241const getColumnByKey = function(table, columnKey) { 242 let column = null; 243 for (let i = 0; i < table.columns.length; i++) { 244 const item = table.columns[i]; 245 if (item.columnKey === columnKey) { 246 column = item; 247 break; 248 } 249 } 250 if (!column) 251 throwError("ElTable", `No column matching with column-key: ${columnKey}`); 252 return column; 253}; 254const getColumnByCell = function(table, cell, namespace) { 255 const matches = (cell.className || "").match(new RegExp(`${namespace}-table_[^\\s]+`, "gm")); 256 if (matches) { 257 return getColumnById(table, matches[0]); 258 } 259 return null; 260}; 261const getRowIdentity = (row, rowKey) => { 262 if (!row) 263 throw new Error("Row is required when get row identity"); 264 if (isString(rowKey)) { 265 if (!rowKey.includes(".")) { 266 return `${row[rowKey]}`; 267 }
268 const key = rowKey.split("."); 269 let current = row; 270 for (const element of key) { 271 current = current[element]; 272 } 273 return `${current}`; 274 } else if (isFunction$1(rowKey)) { 275 return rowKey.call(null, row); 276 } 277 return ""; 278}; 279const getKeysMap = function(array, rowKey, flatten = false, childrenKey = "children") { 280 const data = array || []; 281 const arrayMap2 = {}; 282 data.forEach((row, index) => { 283 arrayMap2[getRowIdentity(row, rowKey)] = { row, index }; 284 if (flatten) { 285 const children = row[childrenKey]; 286 if (isArray$1(children)) { 287 Object.assign(arrayMap2, getKeysMap(children, rowKey, true, childrenKey)); 288 } 289 } 290 }); 291 return arrayMap2; 292}; 293function mergeOptions(defaults, config) { 294 const options = {}; 295 let key; 296 for (key in defaults) { 297 options[key] = defaults[key]; 298 } 299 for (key in config) { 300 if (hasOwn(config, key)) { 301 const value = config[key]; 302 if (!isUndefined(value)) { 303 options[key] = value; 304 } 305 } 306 } 307 return options; 308} 309function parseWidth(width) { 310 if (width === "") 311 return width; 312 if (!isUndefined(width)) { 313 width = Number.parseInt(width, 10); 314 if (Number.isNaN(width)) { 315 width = ""; 316 } 317 } 318 return width; 319} 320function parseMinWidth(minWidth) { 321 if (minWidth === "") 322 return minWidth; 323 if (!isUndefined(minWidth)) { 324 minWidth = parseWidth(minWidth); 325 if (Number.isNaN(minWidth)) { 326 minWidth = 80; 327 } 328 } 329 return minWidth; 330} 331function parseHeight(height) { 332 if (isNumber(height)) { 333 return height; 334 } 335 if (isString(height)) { 336 if (/^\d+(?:px)?$/.test(height)) { 337 return Number.parseInt(height, 10); 338 } else { 339 return height; 340 } 341 } 342 return null; 343} 344function compose(...funcs) { 345 if (funcs.length === 0) { 346 return (arg) => arg; 347 } 348 if (funcs.length === 1) { 349 return funcs[0]; 350 } 351 return funcs.reduce((a2, b2) => (...args) => a2(b2(...args))); 352} 353function toggleRowStatus(statusArr, row, newVal, tableTreeProps, selectable, rowIndex, rowKey) { 354 let _rowIndex = rowIndex != null ? rowIndex : 0; 355 let changed = false; 356 const getIndex = () => { 357 if (!rowKey) { 358 return statusArr.indexOf(row); 359 } 360 const id = getRowIdentity(row, rowKey); 361 return statusArr.findIndex((item) => getRowIdentity(item, rowKey) === id); 362 }; 363 const index = getIndex(); 364 const included = index !== -1; 365 const isRowSelectable = selectable == null ? void 0 : selectable.call(null, row, _rowIndex); 366 const toggleStatus = (type) => { 367 if (type === "add") { 368 statusArr.push(row); 369 } else { 370 statusArr.splice(index, 1); 371 } 372 changed = true; 373 }; 374 const getChildrenCount = (row2) => {
375 let count = 0; 376 const children = (tableTreeProps == null ? void 0 : tableTreeProps.children) && row2[tableTreeProps.children]; 377 if (children && isArray$1(children)) { 378 count += children.length; 379 children.forEach((item) => { 380 count += getChildrenCount(item); 381 }); 382 } 383 return count; 384 }; 385 if (!selectable || isRowSelectable) { 386 if (isBoolean(newVal)) { 387 if (newVal && !included) { 388 toggleStatus("add"); 389 } else if (!newVal && included) { 390 toggleStatus("remove"); 391 } 392 } else { 393 included ? toggleStatus("remove") : toggleStatus("add"); 394 } 395 } 396 if (!(tableTreeProps == null ? void 0 : tableTreeProps.checkStrictly) && (tableTreeProps == null ? void 0 : tableTreeProps.children) && isArray$1(row[tableTreeProps.children])) { 397 row[tableTreeProps.children].forEach((item) => { 398 const childChanged = toggleRowStatus(statusArr, item, newVal != null ? newVal : !included, tableTreeProps, selectable, _rowIndex + 1, rowKey); 399 _rowIndex += getChildrenCount(item) + 1; 400 if (childChanged) { 401 changed = childChanged; 402 } 403 }); 404 } 405 return changed; 406} 407function walkTreeNode(root, cb, childrenKey = "children", lazyKey = "hasChildren", lazy = false) { 408 const isNil = (array) => !(isArray$1(array) && array.length); 409 function _walker(parent, children, level) { 410 cb(parent, children, level); 411 children.forEach((item) => { 412 if (item[lazyKey] && lazy) { 413 cb(item, null, level + 1); 414 return; 415 } 416 const children2 = item[childrenKey]; 417 if (!isNil(children2)) { 418 _walker(item, children2, level + 1); 419 } 420 }); 421 } 422 root.forEach((item) => { 423 if (item[lazyKey] && lazy) { 424 cb(item, null, 0); 425 return; 426 } 427 const children = item[childrenKey]; 428 if (!isNil(children)) { 429 _walker(item, children, 0); 430 } 431 }); 432} 433const getTableOverflowTooltipProps = (props, innerText, row, column) => { 434 const popperOptions = { 435 strategy: "fixed", 436 ...props.popperOptions 437 }; 438 const tooltipFormatterContent = isFunction$1(column == null ? void 0 : column.tooltipFormatter) ? column.tooltipFormatter({ 439 row, 440 column, 441 cellValue: getProp(row, column.property).value 442 }) : void 0; 443 if (isVNode(tooltipFormatterContent)) { 444 return { 445 slotContent: tooltipFormatterContent, 446 content: null, 447 ...props, 448 popperOptions 449 }; 450 } 451 return { 452 slotContent: null, 453 content: tooltipFormatterContent != null ? tooltipFormatterContent : innerText, 454 ...props, 455 popperOptions 456 }; 457}; 458let removePopper = null; 459function createTablePopper(props, popperContent, row, column, trigger, table) { 460 var _a; 461 const tableOverflowTooltipProps = getTableOverflowTooltipProps(props, popperContent, row, column); 462 const mergedProps = { 463 ...tableOverflowTooltipProps, 464 slotContent: void 0 465 }; 466 if ((removePopper == null ? void 0 : removePopper.trigger) === trigger) { 467 const comp = (_a = removePopper.vm) == null ? void 0 : _a.component; 468 merge(comp == null ? void 0 : comp.props, mergedProps); 469 if (comp && tableOverflowTooltipProps.slotContent) { 470 comp.slots.content = () => [tableOverflowTooltipProps.slotContent]; 471 } 472 return; 473 } 474 removePopper == null ? void 0 : removePopper(); 475 const parentNode = table == null ? void 0 : table.refs.tableWrapper; 476 const ns = parentNode == null ? void 0 : parentNode.dataset.prefix; 477 const vm = createVNode(ElTooltip, { 478 virtualTriggering: true, 479 virtualRef: trigger, 480 appendTo: parentNode, 481 placement: "top", 482 transition: "none", 483 offset: 0, 484 hideAfter: 0, 485 ...mergedProps 486 }, tableOverflowTooltipProps.slotContent ? { 487 content: () => tableOverflowTooltipProps.slotContent 488 } : void 0); 489 vm.appContext = { ...table.appContext, ...table }; 490 const container = document.createElement("div"); 491 render(vm, container); 492 vm.component.exposed.onOpen(); 493 const scrollContainer = parentNode == null ? void 0 : parentNode.querySelector(`.${ns}-scrollbar__wrap`); 494 removePopper = () => { 495 var _a2, _b; 496 if ((_b = (_a2 = vm.component) == null ? void 0 : _a2.exposed) == null ? void 0 : _b.onClose) { 497 vm.component.exposed.onClose(); 498 } 499 render(null, container); 500 const currentRemovePopper = removePopper;
501 scrollContainer == null ? void 0 : scrollContainer.removeEventListener("scroll", currentRemovePopper); 502 currentRemovePopper.trigger = void 0; 503 currentRemovePopper.vm = void 0; 504 removePopper = null; 505 }; 506 removePopper.trigger = trigger != null ? trigger : void 0; 507 removePopper.vm = vm; 508 scrollContainer == null ? void 0 : scrollContainer.addEventListener("scroll", removePopper); 509} 510function getCurrentColumns(column) { 511 if (column.children) { 512 return flatMap(column.children, getCurrentColumns); 513 } else { 514 return [column]; 515 } 516} 517function getColSpan(colSpan, column) { 518 return colSpan + column.colSpan; 519} 520const isFixedColumn = (index, fixed, store, realColumns) => { 521 let start = 0; 522 let after = index; 523 const columns = store.states.columns.value; 524 if (realColumns) { 525 const curColumns = getCurrentColumns(realColumns[index]); 526 const preColumns = columns.slice(0, columns.indexOf(curColumns[0])); 527 start = preColumns.reduce(getColSpan, 0); 528 after = start + curColumns.reduce(getColSpan, 0) - 1; 529 } else { 530 start = index; 531 } 532 let fixedLayout; 533 switch (fixed) { 534 case "left": 535 if (after < store.states.fixedLeafColumnsLength.value) { 536 fixedLayout = "left"; 537 } 538 break; 539 case "right": 540 if (start >= columns.length - store.states.rightFixedLeafColumnsLength.value) { 541 fixedLayout = "right"; 542 } 543 break; 544 default: 545 if (after < store.states.fixedLeafColumnsLength.value) { 546 fixedLayout = "left"; 547 } else if (start >= columns.length - store.states.rightFixedLeafColumnsLength.value) { 548 fixedLayout = "right"; 549 } 550 } 551 return fixedLayout ? { 552 direction: fixedLayout, 553 start, 554 after 555 } : {}; 556}; 557const getFixedColumnsClass = (namespace, index, fixed, store, realColumns, offset = 0) => { 558 const classes = []; 559 const { direction, start, after } = isFixedColumn(index, fixed, store, realColumns); 560 if (direction) { 561 const isLeft = direction === "left"; 562 classes.push(`${namespace}-fixed-column--${direction}`); 563 if (isLeft && after + offset === store.states.fixedLeafColumnsLength.value - 1) { 564 classes.push("is-last-column"); 565 } else if (!isLeft && start - offset === store.states.columns.value.length - store.states.rightFixedLeafColumnsLength.value) { 566 classes.push("is-first-column"); 567 } 568 } 569 return classes; 570}; 571function getOffset(offset, column) { 572 return offset + (isNull(column.realWidth) || Number.isNaN(column.realWidth) ? Number(column.width) : column.realWidth); 573} 574const getFixedColumnOffset = (index, fixed, store, realColumns) => { 575 const { 576 direction, 577 start = 0, 578 after = 0 579 } = isFixedColumn(index, fixed, store, realColumns); 580 if (!direction) { 581 return; 582 } 583 const styles = {}; 584 const isLeft = direction === "left"; 585 const columns = store.states.columns.value; 586 if (isLeft) { 587 styles.left = columns.slice(0, start).reduce(getOffset, 0); 588 } else { 589 styles.right = columns.slice(after + 1).reverse().reduce(getOffset, 0); 590 } 591 return styles; 592}; 593const ensurePosition = (style, key) => { 594 if (!style) 595 return; 596 if (!Number.isNaN(style[key])) { 597 style[key] = `${style[key]}px`; 598 } 599}; 600function useExpand(watcherData) { 601 const instance = getCurrentInstance(); 602 const defaultExpandAll = ref(false); 603 const expandRows = ref([]); 604 const updateExpandRows = () => { 605 const data = watcherData.data.value || []; 606 const rowKey = watcherData.rowKey.value; 607 if (defaultExpandAll.value) { 608 expandRows.value = data.slice(); 609 } else if (rowKey) { 610 const expandRowsMap = getKeysMap(expandRows.value, rowKey); 611 expandRows.value = data.reduce((prev, row) => { 612 const rowId = getRowIdentity(row, rowKey); 613 const rowInfo = expandRowsMap[rowId]; 614 if (rowInfo) { 615 prev.push(row); 616 } 617 return prev; 618 }, []); 619 } else { 620 expandRows.value = []; 621 } 622 }; 623 const toggleRowExpansion = (row, expanded) => { 624 const changed = toggleRowStatus(expandRows.value, row, expanded, void 0, void 0, void 0, watcherData.rowKey.value); 625 if (changed) {
626 instance.emit("expand-change", row, expandRows.value.slice()); 627 } 628 }; 629 const setExpandRowKeys = (rowKeys) => { 630 instance.store.assertRowKey(); 631 const data = watcherData.data.value || []; 632 const rowKey = watcherData.rowKey.value; 633 const keysMap = getKeysMap(data, rowKey); 634 expandRows.value = rowKeys.reduce((prev, cur) => { 635 const info = keysMap[cur]; 636 if (info) { 637 prev.push(info.row); 638 } 639 return prev; 640 }, []); 641 }; 642 const isRowExpanded = (row) => { 643 const rowKey = watcherData.rowKey.value; 644 if (rowKey) { 645 const expandMap = getKeysMap(expandRows.value, rowKey); 646 return !!expandMap[getRowIdentity(row, rowKey)]; 647 } 648 return expandRows.value.includes(row); 649 }; 650 return { 651 updateExpandRows, 652 toggleRowExpansion, 653 setExpandRowKeys, 654 isRowExpanded, 655 states: { 656 expandRows, 657 defaultExpandAll 658 } 659 }; 660} 661function useCurrent(watcherData) { 662 const instance = getCurrentInstance(); 663 const _currentRowKey = ref(null); 664 const currentRow = ref(null); 665 const setCurrentRowKey = (key) => { 666 instance.store.assertRowKey(); 667 _currentRowKey.value = key; 668 setCurrentRowByKey(key); 669 }; 670 const restoreCurrentRowKey = () => { 671 _currentRowKey.value = null; 672 }; 673 const setCurrentRowByKey = (key) => { 674 var _a; 675 const { data, rowKey } = watcherData; 676 let _currentRow = null; 677 if (rowKey.value) { 678 _currentRow = (_a = (unref(data) || []).find((item) => getRowIdentity(item, rowKey.value) === key)) != null ? _a : null; 679 } 680 currentRow.value = _currentRow != null ? _currentRow : null; 681 instance.emit("current-change", currentRow.value, null); 682 }; 683 const updateCurrentRow = (_currentRow) => { 684 const oldCurrentRow = currentRow.value; 685 if (_currentRow && _currentRow !== oldCurrentRow) { 686 currentRow.value = _currentRow; 687 instance.emit("current-change", currentRow.value, oldCurrentRow); 688 return; 689 } 690 if (!_currentRow && oldCurrentRow) { 691 currentRow.value = null; 692 instance.emit("current-change", null, oldCurrentRow); 693 } 694 }; 695 const updateCurrentRowData = () => { 696 const rowKey = watcherData.rowKey.value; 697 const data = watcherData.data.value || []; 698 const oldCurrentRow = currentRow.value; 699 if (oldCurrentRow && !data.includes(oldCurrentRow)) { 700 if (rowKey) { 701 const currentRowKey = getRowIdentity(oldCurrentRow, rowKey); 702 setCurrentRowByKey(currentRowKey); 703 } else { 704 currentRow.value = null; 705 } 706 if (isNull(currentRow.value)) { 707 instance.emit("current-change", null, oldCurrentRow); 708 } 709 } else if (_currentRowKey.value) { 710 setCurrentRowByKey(_currentRowKey.value); 711 restoreCurrentRowKey(); 712 } 713 }; 714 return { 715 setCurrentRowKey, 716 restoreCurrentRowKey, 717 setCurrentRowByKey, 718 updateCurrentRow, 719 updateCurrentRowData, 720 states: { 721 _currentRowKey, 722 currentRow 723 } 724 }; 725} 726function useTree(watcherData) { 727 const expandRowKeys = ref([]); 728 const treeData = ref({}); 729 const indent = ref(16); 730 const lazy = ref(false); 731 const lazyTreeNodeMap = ref({}); 732 const lazyColumnIdentifier = ref("hasChildren"); 733 const childrenColumnName = ref("children"); 734 const checkStrictly = ref(false); 735 const instance = getCurrentInstance(); 736 const normalizedData = computed(() => { 737 if (!watcherData.rowKey.value) 738 return {}; 739 const data = watcherData.data.value || []; 740 return normalize(data); 741 }); 742 const normalizedLazyNode = computed(() => { 743 const rowKey = watcherData.rowKey.value; 744 const keys2 = Object.keys(lazyTreeNodeMap.value); 745 const res = {}; 746 if (!keys2.length) 747 return res; 748 keys2.forEach((key) => { 749 if (lazyTreeNodeMap.value[key].length) { 750 const item = { children: [] }; 751 lazyTreeNodeMap.value[key].forEach((row) => { 752 const currentRowKey = getRowIdentity(row, rowKey); 753 item.children.push(currentRowKey); 754 if (row[lazyColumnIdentifier.value] && !res[currentRowKey]) { 755 res[currentRowKey] = { children: [] }; 756 } 757 }); 758 res[key] = item; 759 } 760 }); 761 return res; 762 }); 763 const normalize = (data) => { 764 const rowKey = watcherData.rowKey.value; 765 const res = {}; 766 walkTreeNode(data, (parent, children, level) => { 767 const parentId = getRowIdentity(parent, rowKey); 768 if (isArray$1(children)) { 769 res[parentId] = { 770 children: children.map((row) => getRowIdentity(row, rowKey)), 771 level 772 }; 773 } else if (lazy.value) { 774 res[parentId] = { 775 children: [], 776 lazy: true, 777 level 778 }; 779 } 780 }, childrenColumnName.value, lazyColumnIdentifier.value, lazy.value); 781 return res; 782 }; 783 const updateTreeData = (ifChangeExpandRowKeys = false, ifExpandAll) => { 784 var _a, _b; 785 ifExpandAll || (ifExpandAll = (_a = instance.store) == null ? void 0 : _a.states.defaultExpandAll.value); 786 const nested = normalizedData.value;
787 const normalizedLazyNode_ = normalizedLazyNode.value; 788 const keys2 = Object.keys(nested); 789 const newTreeData = {}; 790 if (keys2.length) { 791 const oldTreeData = unref(treeData); 792 const rootLazyRowKeys = []; 793 const getExpanded = (oldValue, key) => { 794 if (ifChangeExpandRowKeys) { 795 if (expandRowKeys.value) { 796 return ifExpandAll || expandRowKeys.value.includes(key); 797 } else { 798 return !!(ifExpandAll || (oldValue == null ? void 0 : oldValue.expanded)); 799 } 800 } else { 801 const included = ifExpandAll || expandRowKeys.value && expandRowKeys.value.includes(key); 802 return !!((oldValue == null ? void 0 : oldValue.expanded) || included); 803 } 804 }; 805 keys2.forEach((key) => { 806 const oldValue = oldTreeData[key]; 807 const newValue = { ...nested[key] }; 808 newValue.expanded = getExpanded(oldValue, key); 809 if (newValue.lazy) { 810 const { loaded = false, loading = false } = oldValue || {}; 811 newValue.loaded = !!loaded; 812 newValue.loading = !!loading; 813 rootLazyRowKeys.push(key); 814 } 815 newTreeData[key] = newValue; 816 }); 817 const lazyKeys = Object.keys(normalizedLazyNode_); 818 if (lazy.value && lazyKeys.length && rootLazyRowKeys.length) { 819 lazyKeys.forEach((key) => { 820 var _a2; 821 const oldValue = oldTreeData[key]; 822 const lazyNodeChildren = normalizedLazyNode_[key].children; 823 if (rootLazyRowKeys.includes(key)) { 824 if (((_a2 = newTreeData[key].children) == null ? void 0 : _a2.length) !== 0) { 825 throw new Error("[ElTable]children must be an empty array."); 826 } 827 newTreeData[key].children = lazyNodeChildren; 828 } else { 829 const { loaded = false, loading = false } = oldValue || {}; 830 newTreeData[key] = { 831 lazy: true, 832 loaded: !!loaded, 833 loading: !!loading, 834 expanded: getExpanded(oldValue, key), 835 children: lazyNodeChildren, 836 level: void 0 837 }; 838 } 839 }); 840 } 841 } 842 treeData.value = newTreeData; 843 (_b = instance.store) == null ? void 0 : _b.updateTableScrollY(); 844 }; 845 watch(() => expandRowKeys.value, () => { 846 updateTreeData(true); 847 }); 848 watch(() => normalizedData.value, () => { 849 updateTreeData(); 850 }); 851 watch(() => normalizedLazyNode.value, () => { 852 updateTreeData(); 853 }); 854 const updateTreeExpandKeys = (value) => { 855 expandRowKeys.value = value; 856 updateTreeData(); 857 }; 858 const isUseLazy = (data) => { 859 return lazy.value && data && "loaded" in data && !data.loaded; 860 }; 861 const toggleTreeExpansion = (row, expanded) => { 862 instance.store.assertRowKey(); 863 const rowKey = watcherData.rowKey.value; 864 const id = getRowIdentity(row, rowKey); 865 const data = id && treeData.value[id]; 866 if (id && data && "expanded" in data) { 867 const oldExpanded = data.expanded; 868 expanded = isUndefined(expanded) ? !data.expanded : expanded; 869 treeData.value[id].expanded = expanded; 870 if (oldExpanded !== expanded) { 871 instance.emit("expand-change", row, expanded); 872 } 873 isUseLazy(data) && loadData(row, id, data); 874 instance.store.updateTableScrollY(); 875 } 876 }; 877 const loadOrToggle = (row) => { 878 instance.store.assertRowKey(); 879 const rowKey = watcherData.rowKey.value; 880 const id = getRowIdentity(row, rowKey); 881 const data = treeData.value[id]; 882 if (isUseLazy(data)) { 883 loadData(row, id, data); 884 } else { 885 toggleTreeExpansion(row, void 0); 886 } 887 }; 888 const loadData = (row, key, treeNode) => { 889 const { load } = instance.props; 890 if (load && !treeData.value[key].loaded) { 891 treeData.value[key].loading = true; 892 load(row, treeNode, (data) => { 893 if (!isArray$1(data)) { 894 throw new TypeError("[ElTable] data must be an array"); 895 } 896 treeData.value[key].loading = false; 897 treeData.value[key].loaded = true; 898 treeData.value[key].expanded = true; 899 if (data.length) { 900 lazyTreeNodeMap.value[key] = data; 901 }
902 instance.emit("expand-change", row, true); 903 }); 904 } 905 }; 906 const updateKeyChildren = (key, data) => { 907 const { lazy: lazy2, rowKey } = instance.props; 908 if (!lazy2) 909 return; 910 if (!rowKey) 911 throw new Error("[Table] rowKey is required in updateKeyChild"); 912 if (lazyTreeNodeMap.value[key]) { 913 lazyTreeNodeMap.value[key] = data; 914 } 915 }; 916 return { 917 loadData, 918 loadOrToggle, 919 toggleTreeExpansion, 920 updateTreeExpandKeys, 921 updateTreeData, 922 updateKeyChildren, 923 normalize, 924 states: { 925 expandRowKeys, 926 treeData, 927 indent, 928 lazy, 929 lazyTreeNodeMap, 930 lazyColumnIdentifier, 931 childrenColumnName, 932 checkStrictly 933 } 934 }; 935} 936const sortData = (data, states) => { 937 const sortingColumn = states.sortingColumn; 938 if (!sortingColumn || isString(sortingColumn.sortable)) { 939 return data; 940 } 941 return orderBy(data, states.sortProp, states.sortOrder, sortingColumn.sortMethod, sortingColumn.sortBy); 942}; 943const doFlattenColumns = (columns) => { 944 const result = []; 945 columns.forEach((column) => { 946 if (column.children && column.children.length > 0) { 947 result.push.apply(result, doFlattenColumns(column.children)); 948 } else { 949 result.push(column); 950 } 951 }); 952 return result; 953}; 954function useWatcher$1() { 955 var _a; 956 const instance = getCurrentInstance(); 957 const { size: tableSize } = toRefs((_a = instance.proxy) == null ? void 0 : _a.$props); 958 const rowKey = ref(null); 959 const data = ref([]); 960 const _data = ref([]); 961 const isComplex = ref(false); 962 const _columns = ref([]); 963 const originColumns = ref([]); 964 const columns = ref([]); 965 const fixedColumns = ref([]); 966 const rightFixedColumns = ref([]); 967 const leafColumns = ref([]); 968 const fixedLeafColumns = ref([]); 969 const rightFixedLeafColumns = ref([]); 970 const updateOrderFns = []; 971 const leafColumnsLength = ref(0); 972 const fixedLeafColumnsLength = ref(0); 973 const rightFixedLeafColumnsLength = ref(0); 974 const isAllSelected = ref(false); 975 const selection = ref([]); 976 const reserveSelection = ref(false); 977 const selectOnIndeterminate = ref(false); 978 const selectable = ref(null); 979 const filters = ref({}); 980 const filteredData = ref(null); 981 const sortingColumn = ref(null); 982 const sortProp = ref(null); 983 const sortOrder = ref(null); 984 const hoverRow = ref(null); 985 const selectedMap = computed(() => { 986 return rowKey.value ? getKeysMap(selection.value, rowKey.value) : void 0; 987 }); 988 watch(data, () => { 989 var _a2; 990 if (instance.state) { 991 scheduleLayout(false); 992 const needUpdateFixed = instance.props.tableLayout === "auto"; 993 if (needUpdateFixed) { 994 (_a2 = instance.refs.tableHeaderRef) == null ? void 0 : _a2.updateFixedColumnStyle(); 995 } 996 } 997 }, { 998 deep: true 999 }); 1000 const assertRowKey = () => { 1001 if (!rowKey.value) 1002 throw new Error("[ElTable] prop row-key is required"); 1003 }; 1004 const updateChildFixed = (column) => { 1005 var _a2; 1006 (_a2 = column.children) == null ? void 0 : _a2.forEach((childColumn) => { 1007 childColumn.fixed = column.fixed; 1008 updateChildFixed(childColumn); 1009 }); 1010 }; 1011 const updateColumns = () => { 1012 _columns.value.forEach((column) => { 1013 updateChildFixed(column); 1014 }); 1015 fixedColumns.value = _columns.value.filter((column) => [true, "left"].includes(column.fixed)); 1016 const selectColumn = _columns.value.find((column) => column.type === "selection"); 1017 let selectColFixLeft; 1018 if (selectColumn && selectColumn.fixed !== "right" && !fixedColumns.value.includes(selectColumn)) { 1019 const selectColumnIndex = _columns.value.indexOf(selectColumn); 1020 if (selectColumnIndex === 0 && fixedColumns.value.length) { 1021 fixedColumns.value.unshift(selectColumn); 1022 selectColFixLeft = true; 1023 } 1024 } 1025 rightFixedColumns.value = _columns.value.filter((column) => column.fixed === "right"); 1026 const notFixedColumns = _columns.value.filter((column) => (selectColFixLeft ? column.type !== "selection" : true) && !column.fixed); 1027 originColumns.value = Array.from(fixedColumns.value).concat(notFixedColumns).concat(rightFixedColumns.value); 1028 const leafColumns2 = doFlattenColumns(notFixedColumns); 1029 const fixedLeafColumns2 = doFlattenColumns(fixedColumns.value); 1030 const rightFixedLeafColumns2 = doFlattenColumns(rightFixedColumns.value); 1031 leafColumnsLength.value = leafColumns2.length; 1032 fixedLeafColumnsLength.value = fixedLeafColumns2.length; 1033 rightFixedLeafColumnsLength.value = rightFixedLeafColumns2.length; 1034 columns.value = Array.from(fixedLeafColumns2).concat(leafColumns2).concat(rightFixedLeafColumns2); 1035 isComplex.value = fixedColumns.value.length > 0 || rightFixedColumns.value.length > 0; 1036 };
1037 const scheduleLayout = (needUpdateColumns, immediate = false) => { 1038 if (needUpdateColumns) { 1039 updateColumns(); 1040 } 1041 if (immediate) { 1042 instance.state.doLayout(); 1043 } else { 1044 instance.state.debouncedUpdateLayout(); 1045 } 1046 }; 1047 const isSelected = (row) => { 1048 if (selectedMap.value) { 1049 return !!selectedMap.value[getRowIdentity(row, rowKey.value)]; 1050 } else { 1051 return selection.value.includes(row); 1052 } 1053 }; 1054 const clearSelection = () => { 1055 isAllSelected.value = false; 1056 const oldSelection = selection.value; 1057 selection.value = []; 1058 if (oldSelection.length) { 1059 instance.emit("selection-change", []); 1060 } 1061 }; 1062 const cleanSelection = () => { 1063 var _a2, _b; 1064 let deleted; 1065 if (rowKey.value) { 1066 deleted = []; 1067 const childrenKey = (_b = (_a2 = instance == null ? void 0 : instance.store) == null ? void 0 : _a2.states) == null ? void 0 : _b.childrenColumnName.value; 1068 const dataMap = getKeysMap(data.value, rowKey.value, true, childrenKey); 1069 for (const key in selectedMap.value) { 1070 if (hasOwn(selectedMap.value, key) && !dataMap[key]) { 1071 deleted.push(selectedMap.value[key].row); 1072 } 1073 } 1074 } else { 1075 deleted = selection.value.filter((item) => !data.value.includes(item)); 1076 } 1077 if (deleted.length) { 1078 const newSelection = selection.value.filter((item) => !deleted.includes(item)); 1079 selection.value = newSelection; 1080 instance.emit("selection-change", newSelection.slice()); 1081 } 1082 }; 1083 const getSelectionRows = () => { 1084 return (selection.value || []).slice(); 1085 }; 1086 const toggleRowSelection = (row, selected, emitChange = true, ignoreSelectable = false) => { 1087 var _a2, _b, _c, _d; 1088 const treeProps = { 1089 children: (_b = (_a2 = instance == null ? void 0 : instance.store) == null ? void 0 : _a2.states) == null ? void 0 : _b.childrenColumnName.value, 1090 checkStrictly: (_d = (_c = instance == null ? void 0 : instance.store) == null ? void 0 : _c.states) == null ? void 0 : _d.checkStrictly.value 1091 }; 1092 const changed = toggleRowStatus(selection.value, row, selected, treeProps, ignoreSelectable ? void 0 : selectable.value, data.value.indexOf(row), rowKey.value); 1093 if (changed) { 1094 const newSelection = (selection.value || []).slice(); 1095 if (emitChange) { 1096 instance.emit("select", newSelection, row); 1097 } 1098 instance.emit("selection-change", newSelection); 1099 } 1100 }; 1101 const _toggleAllSelection = () => { 1102 var _a2, _b; 1103 const value = selectOnIndeterminate.value ? !isAllSelected.value : !(isAllSelected.value || selection.value.length); 1104 isAllSelected.value = value; 1105 let selectionChanged = false; 1106 let childrenCount = 0; 1107 const rowKey2 = (_b = (_a2 = instance == null ? void 0 : instance.store) == null ? void 0 : _a2.states) == null ? void 0 : _b.rowKey.value; 1108 const { childrenColumnName } = instance.store.states; 1109 const treeProps = { 1110 children: childrenColumnName.value, 1111 checkStrictly: false 1112 }; 1113 data.value.forEach((row, index) => { 1114 const rowIndex = index + childrenCount; 1115 if (toggleRowStatus(selection.value, row, value, treeProps, selectable.value, rowIndex, rowKey2)) { 1116 selectionChanged = true; 1117 } 1118 childrenCount += getChildrenCount(getRowIdentity(row, rowKey2)); 1119 }); 1120 if (selectionChanged) { 1121 instance.emit("selection-change", selection.value ? selection.value.slice() : []); 1122 } 1123 instance.emit("select-all", (selection.value || []).slice()); 1124 }; 1125 const updateAllSelected = () => { 1126 var _a2; 1127 if (((_a2 = data.value) == null ? void 0 : _a2.length) === 0) { 1128 isAllSelected.value = false; 1129 return; 1130 } 1131 const { childrenColumnName } = instance.store.states; 1132 let rowIndex = 0; 1133 let selectedCount = 0; 1134 const checkSelectedStatus = (data2) => { 1135 var _a3; 1136 for (const row of data2) { 1137 const isRowSelectable = selectable.value && selectable.value.call(null, row, rowIndex); 1138 if (!isSelected(row)) { 1139 if (!selectable.value || isRowSelectable) { 1140 return false;
1141 } 1142 } else { 1143 selectedCount++; 1144 } 1145 rowIndex++; 1146 if (((_a3 = row[childrenColumnName.value]) == null ? void 0 : _a3.length) && !checkSelectedStatus(row[childrenColumnName.value])) { 1147 return false; 1148 } 1149 } 1150 return true; 1151 }; 1152 const isAllSelected_ = checkSelectedStatus(data.value || []); 1153 isAllSelected.value = selectedCount === 0 ? false : isAllSelected_; 1154 }; 1155 const getChildrenCount = (rowKey2) => { 1156 var _a2; 1157 if (!instance || !instance.store) 1158 return 0; 1159 const { treeData } = instance.store.states; 1160 let count = 0; 1161 const children = (_a2 = treeData.value[rowKey2]) == null ? void 0 : _a2.children; 1162 if (children) { 1163 count += children.length; 1164 children.forEach((childKey) => { 1165 count += getChildrenCount(childKey); 1166 }); 1167 } 1168 return count; 1169 }; 1170 const updateFilters = (column, values) => { 1171 const filters_ = {}; 1172 castArray(column).forEach((col) => { 1173 filters.value[col.id] = values; 1174 filters_[col.columnKey || col.id] = values; 1175 }); 1176 return filters_; 1177 }; 1178 const updateSort = (column, prop, order) => { 1179 if (sortingColumn.value && sortingColumn.value !== column) { 1180 sortingColumn.value.order = null; 1181 } 1182 sortingColumn.value = column; 1183 sortProp.value = prop; 1184 sortOrder.value = order; 1185 }; 1186 const execFilter = () => { 1187 let sourceData = unref(_data); 1188 Object.keys(filters.value).forEach((columnId) => { 1189 const values = filters.value[columnId]; 1190 if (!values || values.length === 0) 1191 return; 1192 const column = getColumnById({ 1193 columns: columns.value 1194 }, columnId); 1195 if (column && column.filterMethod) { 1196 sourceData = sourceData.filter((row) => { 1197 return values.some((value) => column.filterMethod.call(null, value, row, column)); 1198 }); 1199 } 1200 }); 1201 filteredData.value = sourceData; 1202 }; 1203 const execSort = () => { 1204 var _a2; 1205 data.value = sortData((_a2 = filteredData.value) != null ? _a2 : [], { 1206 sortingColumn: sortingColumn.value, 1207 sortProp: sortProp.value, 1208 sortOrder: sortOrder.value 1209 }); 1210 }; 1211 const execQuery = (ignore = void 0) => { 1212 if (!(ignore == null ? void 0 : ignore.filter)) { 1213 execFilter(); 1214 } 1215 execSort(); 1216 }; 1217 const clearFilter = (columnKeys) => { 1218 const { tableHeaderRef } = instance.refs; 1219 if (!tableHeaderRef) 1220 return; 1221 const panels = Object.assign({}, tableHeaderRef.filterPanels); 1222 const keys2 = Object.keys(panels); 1223 if (!keys2.length) 1224 return; 1225 if (isString(columnKeys)) { 1226 columnKeys = [columnKeys]; 1227 } 1228 if (isArray$1(columnKeys)) { 1229 const columns_ = columnKeys.map((key) => getColumnByKey({ 1230 columns: columns.value 1231 }, key)); 1232 keys2.forEach((key) => { 1233 const column = columns_.find((col) => col.id === key); 1234 if (column) { 1235 column.filteredValue = []; 1236 } 1237 }); 1238 instance.store.commit("filterChange", { 1239 column: columns_, 1240 values: [], 1241 silent: true, 1242 multi: true 1243 }); 1244 } else { 1245 keys2.forEach((key) => { 1246 const column = columns.value.find((col) => col.id === key); 1247 if (column) { 1248 column.filteredValue = []; 1249 } 1250 }); 1251 filters.value = {}; 1252 instance.store.commit("filterChange", { 1253 column: {}, 1254 values: [], 1255 silent: true 1256 }); 1257 } 1258 }; 1259 const clearSort = () => { 1260 if (!sortingColumn.value) 1261 return; 1262 updateSort(null, null, null); 1263 instance.store.commit("changeSortCondition", { 1264 silent: true 1265 }); 1266 }; 1267 const { 1268 setExpandRowKeys, 1269 toggleRowExpansion, 1270 updateExpandRows, 1271 states: expandStates, 1272 isRowExpanded 1273 } = useExpand({ 1274 data, 1275 rowKey 1276 }); 1277 const { 1278 updateTreeExpandKeys, 1279 toggleTreeExpansion, 1280 updateTreeData, 1281 updateKeyChildren, 1282 loadOrToggle, 1283 states: treeStates 1284 } = useTree({ 1285 data, 1286 rowKey 1287 }); 1288 const { 1289 updateCurrentRowData, 1290 updateCurrentRow, 1291 setCurrentRowKey, 1292 states: currentData 1293 } = useCurrent({ 1294 data, 1295 rowKey 1296 }); 1297 const setExpandRowKeysAdapter = (val) => { 1298 setExpandRowKeys(val); 1299 updateTreeExpandKeys(val); 1300 }; 1301 const toggleRowExpansionAdapter = (row, expanded) => { 1302 const hasExpandColumn = columns.value.some(({ type }) => type === "expand"); 1303 if (hasExpandColumn) { 1304 toggleRowExpansion(row, expanded); 1305 } else { 1306 toggleTreeExpansion(row, expanded); 1307 } 1308 }; 1309 return { 1310 assertRowKey, 1311 updateColumns, 1312 scheduleLayout, 1313 isSelected, 1314 clearSelection, 1315 cleanSelection, 1316 getSelectionRows, 1317 toggleRowSelection, 1318 _toggleAllSelection, 1319 toggleAllSelection: null, 1320 updateAllSelected, 1321 updateFilters, 1322 updateCurrentRow, 1323 updateSort, 1324 execFilter, 1325 execSort, 1326 execQuery, 1327 clearFilter, 1328 clearSort, 1329 toggleRowExpansion,
1330 setExpandRowKeysAdapter, 1331 setCurrentRowKey, 1332 toggleRowExpansionAdapter, 1333 isRowExpanded, 1334 updateExpandRows, 1335 updateCurrentRowData, 1336 loadOrToggle, 1337 updateTreeData, 1338 updateKeyChildren, 1339 states: { 1340 tableSize, 1341 rowKey, 1342 data, 1343 _data, 1344 isComplex, 1345 _columns, 1346 originColumns, 1347 columns, 1348 fixedColumns, 1349 rightFixedColumns, 1350 leafColumns, 1351 fixedLeafColumns, 1352 rightFixedLeafColumns, 1353 updateOrderFns, 1354 leafColumnsLength, 1355 fixedLeafColumnsLength, 1356 rightFixedLeafColumnsLength, 1357 isAllSelected, 1358 selection, 1359 reserveSelection, 1360 selectOnIndeterminate, 1361 selectable, 1362 filters, 1363 filteredData, 1364 sortingColumn, 1365 sortProp, 1366 sortOrder, 1367 hoverRow, 1368 ...expandStates, 1369 ...treeStates, 1370 ...currentData 1371 } 1372 }; 1373} 1374function replaceColumn(array, column) { 1375 return array.map((item) => { 1376 var _a; 1377 if (item.id === column.id) { 1378 return column; 1379 } else if ((_a = item.children) == null ? void 0 : _a.length) { 1380 item.children = replaceColumn(item.children, column); 1381 } 1382 return item; 1383 }); 1384} 1385function sortColumn(array) { 1386 array.forEach((item) => { 1387 var _a, _b; 1388 item.no = (_a = item.getColumnIndex) == null ? void 0 : _a.call(item); 1389 if ((_b = item.children) == null ? void 0 : _b.length) { 1390 sortColumn(item.children); 1391 } 1392 }); 1393 array.sort((cur, pre) => cur.no - pre.no); 1394} 1395function useStore() { 1396 const instance = getCurrentInstance(); 1397 const watcher = useWatcher$1(); 1398 const ns = useNamespace("table"); 1399 const mutations = { 1400 setData(states, data) { 1401 const dataInstanceChanged = unref(states._data) !== data; 1402 states.data.value = data; 1403 states._data.value = data; 1404 instance.store.execQuery(); 1405 instance.store.updateCurrentRowData(); 1406 instance.store.updateExpandRows(); 1407 instance.store.updateTreeData(instance.store.states.defaultExpandAll.value); 1408 if (unref(states.reserveSelection)) { 1409 instance.store.assertRowKey(); 1410 } else { 1411 if (dataInstanceChanged) { 1412 instance.store.clearSelection(); 1413 } else { 1414 instance.store.cleanSelection(); 1415 } 1416 } 1417 instance.store.updateAllSelected(); 1418 if (instance.$ready) { 1419 instance.store.scheduleLayout(); 1420 } 1421 }, 1422 insertColumn(states, column, parent, updateColumnOrder) { 1423 var _a; 1424 const array = unref(states._columns); 1425 let newColumns = []; 1426 if (!parent) { 1427 array.push(column); 1428 newColumns = array; 1429 } else { 1430 if (parent && !parent.children) { 1431 parent.children = []; 1432 } 1433 (_a = parent.children) == null ? void 0 : _a.push(column); 1434 newColumns = replaceColumn(array, parent); 1435 } 1436 sortColumn(newColumns); 1437 states._columns.value = newColumns; 1438 states.updateOrderFns.push(updateColumnOrder); 1439 if (column.type === "selection") { 1440 states.selectable.value = column.selectable; 1441 states.reserveSelection.value = column.reserveSelection; 1442 } 1443 if (instance.$ready) { 1444 instance.store.updateColumns(); 1445 instance.store.scheduleLayout(); 1446 } 1447 }, 1448 updateColumnOrder(states, column) { 1449 var _a; 1450 const newColumnIndex = (_a = column.getColumnIndex) == null ? void 0 : _a.call(column); 1451 if (newColumnIndex === column.no) 1452 return; 1453 sortColumn(states._columns.value); 1454 if (instance.$ready) { 1455 instance.store.updateColumns(); 1456 } 1457 }, 1458 removeColumn(states, column, parent, updateColumnOrder) { 1459 var _a; 1460 const array = unref(states._columns) || []; 1461 if (parent) { 1462 (_a = parent.children) == null ? void 0 : _a.splice(parent.children.findIndex((item) => item.id === column.id), 1); 1463 nextTick(() => { 1464 var _a2; 1465 if (((_a2 = parent.children) == null ? void 0 : _a2.length) === 0) { 1466 delete parent.children; 1467 } 1468 }); 1469 states._columns.value = replaceColumn(array, parent); 1470 } else { 1471 const index = array.indexOf(column); 1472 if (index > -1) { 1473 array.splice(index, 1); 1474 states._columns.value = array; 1475 } 1476 } 1477 const updateFnIndex = states.updateOrderFns.indexOf(updateColumnOrder); 1478 updateFnIndex > -1 && states.updateOrderFns.splice(updateFnIndex, 1); 1479 if (instance.$ready) { 1480 instance.store.updateColumns(); 1481 instance.store.scheduleLayout(); 1482 } 1483 }, 1484 sort(states, options) { 1485 const { prop, order, init } = options; 1486 if (prop) { 1487 const column = unref(states.columns).find((column2) => column2.property === prop); 1488 if (column) { 1489 column.order = order; 1490 instance.store.updateSort(column, prop, order); 1491 instance.store.commit("changeSortCondition", { init }); 1492 } 1493 } 1494 }, 1495 changeSortCondition(states, options) { 1496 const { sortingColumn, sortProp, sortOrder } = states; 1497 const columnValue = unref(sortingColumn), propValue = unref(sortProp), orderValue = unref(sortOrder); 1498 if (isNull(orderValue)) { 1499 states.sortingColumn.value = null; 1500 states.sortProp.value = null; 1501 } 1502 const ignore = { filter: true }; 1503 instance.store.execQuery(ignore); 1504 if (!options || !(options.silent || options.init)) { 1505 instance.emit("sort-change", { 1506 column: columnValue, 1507 prop: propValue, 1508 order: orderValue 1509 }); 1510 } 1511 instance.store.updateTableScrollY(); 1512 }, 1513 filterChange(_states, options) { 1514 const { column, values, silent } = options; 1515 const newFilters = instance.store.updateFilters(column, values); 1516 instance.store.execQuery(); 1517 if (!silent) { 1518 instance.emit("filter-change", newFilters); 1519 } 1520 instance.store.updateTableScrollY(); 1521 }, 1522 toggleAllSelection() { 1523 var _a, _b; 1524 (_b = (_a = instance.store).toggleAllSelection) == null ? void 0 : _b.call(_a); 1525 }, 1526 rowSelectedChanged(_states, row) { 1527 instance.store.toggleRowSelection(row); 1528 instance.store.updateAllSelected(); 1529 }, 1530 setHoverRow(states, row) { 1531 states.hoverRow.value = row; 1532 }, 1533 setCurrentRow(_states, row) { 1534 instance.store.updateCurrentRow(row); 1535 } 1536 }; 1537 const commit = function(name, ...args) { 1538 const mutations2 = instance.store.mutations; 1539 if (mutations2[name]) { 1540 mutations2[name].apply(instance, [ 1541 instance.store.states, 1542 ...args 1543 ]); 1544 } else { 1545 throw new Error(`Action not found: ${name}`); 1546 } 1547 }; 1548 const updateTableScrollY = function() { 1549 nextTick(() => instance.layout.updateScrollY.apply(instance.layout)); 1550 }; 1551 return { 1552 ns, 1553 ...watcher, 1554 mutations, 1555 commit, 1556 updateTableScrollY 1557 }; 1558} 1559const InitialStateMap = { 1560 rowKey: "rowKey", 1561 defaultExpandAll: "defaultExpandAll", 1562 selectOnIndeterminate: "selectOnIndeterminate", 1563 indent: "indent", 1564 lazy: "lazy", 1565 data: "data", 1566 ["treeProps.hasChildren"]: { 1567 key: "lazyColumnIdentifier", 1568 default: "hasChildren" 1569 }, 1570 ["treeProps.children"]: { 1571 key: "childrenColumnName", 1572 default: "children" 1573 }, 1574 ["treeProps.checkStrictly"]: { 1575 key: "checkStrictly", 1576 default: false 1577 } 1578}; 1579function createStore(table, props) { 1580 if (!table) { 1581 throw new Error("Table is required."); 1582 } 1583 const store = useStore(); 1584 store.toggleAllSelection = debounce(store._toggleAllSelection, 10);
1585 Object.keys(InitialStateMap).forEach((key) => { 1586 handleValue(getArrKeysValue(props, key), key, store); 1587 }); 1588 proxyTableProps(store, props); 1589 return store; 1590} 1591function proxyTableProps(store, props) { 1592 Object.keys(InitialStateMap).forEach((key) => { 1593 watch(() => getArrKeysValue(props, key), (value) => { 1594 handleValue(value, key, store); 1595 }); 1596 }); 1597} 1598function handleValue(value, propsKey, store) { 1599 let newVal = value; 1600 let storeKey = InitialStateMap[propsKey]; 1601 if (isObject$1(storeKey)) { 1602 newVal = newVal || storeKey.default; 1603 storeKey = storeKey.key; 1604 } 1605 store.states[storeKey].value = newVal; 1606} 1607function getArrKeysValue(props, key) { 1608 if (key.includes(".")) { 1609 const keyList = key.split("."); 1610 let value = props; 1611 keyList.forEach((k) => { 1612 value = value[k]; 1613 }); 1614 return value; 1615 } else { 1616 return props[key]; 1617 } 1618} 1619class TableLayout { 1620 constructor(options) { 1621 this.observers = []; 1622 this.table = null; 1623 this.store = null; 1624 this.columns = []; 1625 this.fit = true; 1626 this.showHeader = true; 1627 this.height = ref(null); 1628 this.scrollX = ref(false); 1629 this.scrollY = ref(false); 1630 this.bodyWidth = ref(null); 1631 this.fixedWidth = ref(null); 1632 this.rightFixedWidth = ref(null); 1633 this.gutterWidth = 0; 1634 for (const name in options) { 1635 if (hasOwn(options, name)) { 1636 if (isRef(this[name])) { 1637 this[name].value = options[name]; 1638 } else { 1639 this[name] = options[name]; 1640 } 1641 } 1642 } 1643 if (!this.table) { 1644 throw new Error("Table is required for Table Layout"); 1645 } 1646 if (!this.store) { 1647 throw new Error("Store is required for Table Layout"); 1648 } 1649 } 1650 updateScrollY() { 1651 const height = this.height.value; 1652 if (isNull(height)) 1653 return false; 1654 const scrollBarRef = this.table.refs.scrollBarRef; 1655 if (this.table.vnode.el && (scrollBarRef == null ? void 0 : scrollBarRef.wrapRef)) { 1656 let scrollY = true; 1657 const prevScrollY = this.scrollY.value; 1658 scrollY = scrollBarRef.wrapRef.scrollHeight > scrollBarRef.wrapRef.clientHeight; 1659 this.scrollY.value = scrollY; 1660 return prevScrollY !== scrollY; 1661 } 1662 return false; 1663 } 1664 setHeight(value, prop = "height") { 1665 if (!isClient) 1666 return; 1667 const el = this.table.vnode.el; 1668 value = parseHeight(value); 1669 this.height.value = Number(value); 1670 if (!el && (value || value === 0)) { 1671 nextTick(() => this.setHeight(value, prop)); 1672 return; 1673 } 1674 if (el && isNumber(value)) { 1675 el.style[prop] = `${value}px`; 1676 this.updateElsHeight(); 1677 } else if (el && isString(value)) { 1678 el.style[prop] = value; 1679 this.updateElsHeight(); 1680 } 1681 } 1682 setMaxHeight(value) { 1683 this.setHeight(value, "max-height"); 1684 } 1685 getFlattenColumns() { 1686 const flattenColumns = []; 1687 const columns = this.table.store.states.columns.value; 1688 columns.forEach((column) => { 1689 if (column.isColumnGroup) { 1690 flattenColumns.push.apply(flattenColumns, column.columns); 1691 } else { 1692 flattenColumns.push(column); 1693 } 1694 }); 1695 return flattenColumns; 1696 } 1697 updateElsHeight() { 1698 this.updateScrollY(); 1699 this.notifyObservers("scrollable"); 1700 } 1701 headerDisplayNone(elm) { 1702 if (!elm) 1703 return true; 1704 let headerChild = elm; 1705 while (headerChild.tagName !== "DIV") { 1706 if (getComputedStyle(headerChild).display === "none") { 1707 return true; 1708 } 1709 headerChild = headerChild.parentElement; 1710 } 1711 return false; 1712 } 1713 updateColumnsWidth() { 1714 var _a; 1715 if (!isClient) 1716 return; 1717 const fit = this.fit; 1718 const bodyWidth = (_a = this.table.vnode.el) == null ? void 0 : _a.clientWidth; 1719 let bodyMinWidth = 0; 1720 const flattenColumns = this.getFlattenColumns(); 1721 const flexColumns = flattenColumns.filter((column) => !isNumber(column.width)); 1722 flattenColumns.forEach((column) => { 1723 if (isNumber(column.width) && column.realWidth) 1724 column.realWidth = null; 1725 }); 1726 if (flexColumns.length > 0 && fit) { 1727 flattenColumns.forEach((column) => { 1728 bodyMinWidth += Number(column.width || column.minWidth || 80); 1729 }); 1730 if (bodyMinWidth <= bodyWidth) { 1731 this.scrollX.value = false;
1732 const totalFlexWidth = bodyWidth - bodyMinWidth; 1733 if (flexColumns.length === 1) { 1734 flexColumns[0].realWidth = Number(flexColumns[0].minWidth || 80) + totalFlexWidth; 1735 } else { 1736 const allColumnsWidth = flexColumns.reduce((prev, column) => prev + Number(column.minWidth || 80), 0); 1737 const flexWidthPerPixel = totalFlexWidth / allColumnsWidth; 1738 let noneFirstWidth = 0; 1739 flexColumns.forEach((column, index) => { 1740 if (index === 0) 1741 return; 1742 const flexWidth = Math.floor(Number(column.minWidth || 80) * flexWidthPerPixel); 1743 noneFirstWidth += flexWidth; 1744 column.realWidth = Number(column.minWidth || 80) + flexWidth; 1745 }); 1746 flexColumns[0].realWidth = Number(flexColumns[0].minWidth || 80) + totalFlexWidth - noneFirstWidth; 1747 } 1748 } else { 1749 this.scrollX.value = true; 1750 flexColumns.forEach((column) => { 1751 column.realWidth = Number(column.minWidth); 1752 }); 1753 } 1754 this.bodyWidth.value = Math.max(bodyMinWidth, bodyWidth); 1755 this.table.state.resizeState.value.width = this.bodyWidth.value; 1756 } else { 1757 flattenColumns.forEach((column) => { 1758 if (!column.width && !column.minWidth) { 1759 column.realWidth = 80; 1760 } else { 1761 column.realWidth = Number(column.width || column.minWidth); 1762 } 1763 bodyMinWidth += column.realWidth; 1764 }); 1765 this.scrollX.value = bodyMinWidth > bodyWidth; 1766 this.bodyWidth.value = bodyMinWidth; 1767 } 1768 const fixedColumns = this.store.states.fixedColumns.value; 1769 if (fixedColumns.length > 0) { 1770 let fixedWidth = 0; 1771 fixedColumns.forEach((column) => { 1772 fixedWidth += Number(column.realWidth || column.width); 1773 }); 1774 this.fixedWidth.value = fixedWidth; 1775 } 1776 const rightFixedColumns = this.store.states.rightFixedColumns.value; 1777 if (rightFixedColumns.length > 0) { 1778 let rightFixedWidth = 0; 1779 rightFixedColumns.forEach((column) => { 1780 rightFixedWidth += Number(column.realWidth || column.width); 1781 }); 1782 this.rightFixedWidth.value = rightFixedWidth; 1783 } 1784 this.notifyObservers("columns"); 1785 } 1786 addObserver(observer) { 1787 this.observers.push(observer); 1788 } 1789 removeObserver(observer) { 1790 const index = this.observers.indexOf(observer); 1791 if (index !== -1) { 1792 this.observers.splice(index, 1); 1793 } 1794 } 1795 notifyObservers(event) { 1796 const observers = this.observers; 1797 observers.forEach((observer) => { 1798 var _a, _b; 1799 switch (event) { 1800 case "columns": 1801 (_a = observer.state) == null ? void 0 : _a.onColumnsChange(this); 1802 break; 1803 case "scrollable": 1804 (_b = observer.state) == null ? void 0 : _b.onScrollableChange(this); 1805 break; 1806 default: 1807 throw new Error(`Table Layout don't have event ${event}.`); 1808 } 1809 }); 1810 } 1811} 1812const { CheckboxGroup: ElCheckboxGroup } = ElCheckbox; 1813const _sfc_main$2 = defineComponent({ 1814 name: "ElTableFilterPanel", 1815 components: { 1816 ElCheckbox, 1817 ElCheckboxGroup, 1818 ElScrollbar, 1819 ElTooltip, 1820 ElIcon, 1821 ArrowDown: arrow_down_default, 1822 ArrowUp: arrow_up_default 1823 }, 1824 directives: { ClickOutside }, 1825 props: { 1826 placement: { 1827 type: String, 1828 default: "bottom-start" 1829 }, 1830 store: { 1831 type: Object 1832 }, 1833 column: { 1834 type: Object 1835 }, 1836 upDataColumn: { 1837 type: Function 1838 }, 1839 appendTo: useTooltipContentProps.appendTo 1840 }, 1841 setup(props) { 1842 const instance = getCurrentInstance(); 1843 const { t } = useLocale(); 1844 const ns = useNamespace("table-filter"); 1845 const parent = instance == null ? void 0 : instance.parent; 1846 if (props.column && !parent.filterPanels.value[props.column.id]) { 1847 parent.filterPanels.value[props.column.id] = instance; 1848 } 1849 const tooltipVisible = ref(false); 1850 const tooltip = ref(null); 1851 const filters = computed(() => { 1852 return props.column && props.column.filters; 1853 }); 1854 const filterClassName = computed(() => { 1855 if (props.column && props.column.filterClassName) { 1856 return `${ns.b()} ${props.column.filterClassName}`; 1857 } 1858 return ns.b(); 1859 }); 1860 const filterValue = computed({ 1861 get: () => { 1862 var _a; 1863 return (((_a = props.column) == null ? void 0 : _a.filteredValue) || [])[0]; 1864 }, 1865 set: (value) => { 1866 if (filteredValue.value) { 1867 if (!isPropAbsent(value)) { 1868 filteredValue.value.splice(0, 1, value); 1869 } else { 1870 filteredValue.value.splice(0, 1); 1871 } 1872 } 1873 } 1874 }); 1875 const filteredValue = computed({ 1876 get() { 1877 if (props.column) { 1878 return props.column.filteredValue || []; 1879 } 1880 return []; 1881 }, 1882 set(value) { 1883 var _a; 1884 if (props.column) { 1885 (_a = props.upDataColumn) == null ? void 0 : _a.call(props, "filteredValue", value); 1886 } 1887 } 1888 }); 1889 const multiple = computed(() => { 1890 if (props.column) { 1891 return props.column.filterMultiple; 1892 } 1893 return true; 1894 }); 1895 const isActive = (filter) => { 1896 return filter.value === filterValue.value; 1897 }; 1898 const hidden = () => { 1899 tooltipVisible.value = false;
1900 }; 1901 const showFilterPanel = (e) => { 1902 e.stopPropagation(); 1903 tooltipVisible.value = !tooltipVisible.value; 1904 }; 1905 const hideFilterPanel = () => { 1906 tooltipVisible.value = false; 1907 }; 1908 const handleConfirm = () => { 1909 confirmFilter(filteredValue.value); 1910 hidden(); 1911 }; 1912 const handleReset = () => { 1913 filteredValue.value = []; 1914 confirmFilter(filteredValue.value); 1915 hidden(); 1916 }; 1917 const handleSelect = (_filterValue) => { 1918 filterValue.value = _filterValue; 1919 if (!isPropAbsent(_filterValue)) { 1920 confirmFilter(filteredValue.value); 1921 } else { 1922 confirmFilter([]); 1923 } 1924 hidden(); 1925 }; 1926 const confirmFilter = (filteredValue2) => { 1927 var _a, _b; 1928 (_a = props.store) == null ? void 0 : _a.commit("filterChange", { 1929 column: props.column, 1930 values: filteredValue2 1931 }); 1932 (_b = props.store) == null ? void 0 : _b.updateAllSelected(); 1933 }; 1934 watch(tooltipVisible, (value) => { 1935 var _a; 1936 if (props.column) { 1937 (_a = props.upDataColumn) == null ? void 0 : _a.call(props, "filterOpened", value); 1938 } 1939 }, { 1940 immediate: true 1941 }); 1942 const popperPaneRef = computed(() => { 1943 var _a, _b; 1944 return (_b = (_a = tooltip.value) == null ? void 0 : _a.popperRef) == null ? void 0 : _b.contentRef; 1945 }); 1946 return { 1947 tooltipVisible, 1948 multiple, 1949 filterClassName, 1950 filteredValue, 1951 filterValue, 1952 filters, 1953 handleConfirm, 1954 handleReset, 1955 handleSelect, 1956 isPropAbsent, 1957 isActive, 1958 t, 1959 ns, 1960 showFilterPanel, 1961 hideFilterPanel, 1962 popperPaneRef, 1963 tooltip 1964 }; 1965 } 1966}); 1967function _sfc_render$1(_ctx, _cache, $props, $setup, $data, $options) { 1968 const _component_el_checkbox = resolveComponent("el-checkbox"); 1969 const _component_el_checkbox_group = resolveComponent("el-checkbox-group"); 1970 const _component_el_scrollbar = resolveComponent("el-scrollbar"); 1971 const _component_arrow_up = resolveComponent("arrow-up"); 1972 const _component_arrow_down = resolveComponent("arrow-down"); 1973 const _component_el_icon = resolveComponent("el-icon"); 1974 const _component_el_tooltip = resolveComponent("el-tooltip"); 1975 const _directive_click_outside = resolveDirective("click-outside"); 1976 return openBlock(), createBlock(_component_el_tooltip, { 1977 ref: "tooltip", 1978 visible: _ctx.tooltipVisible, 1979 offset: 0, 1980 placement: _ctx.placement, 1981 "show-arrow": false, 1982 "stop-popper-mouse-event": false, 1983 teleported: "", 1984 effect: "light", 1985 pure: "", 1986 "popper-class": _ctx.filterClassName, 1987 persistent: "", 1988 "append-to": _ctx.appendTo 1989 }, { 1990 content: withCtx(() => [ 1991 _ctx.multiple ? (openBlock(), createElementBlock("div", { key: 0 }, [ 1992 createBaseVNode("div", { 1993 class: normalizeClass(_ctx.ns.e("content")) 1994 }, [ 1995 createVNode(_component_el_scrollbar, { 1996 "wrap-class": _ctx.ns.e("wrap") 1997 }, { 1998 default: withCtx(() => [ 1999 createVNode(_component_el_checkbox_group, { 2000 modelValue: _ctx.filteredValue, 2001 "onUpdate:modelValue": ($event) => _ctx.filteredValue = $event, 2002 class: normalizeClass(_ctx.ns.e("checkbox-group")) 2003 }, { 2004 default: withCtx(() => [ 2005 (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.filters, (filter) => { 2006 return openBlock(), createBlock(_component_el_checkbox, { 2007 key: filter.value, 2008 value: filter.value 2009 }, { 2010 default: withCtx(() => [ 2011 createTextVNode(toDisplayString(filter.text), 1) 2012 ]), 2013 _: 2 2014 }, 1032, ["value"]); 2015 }), 128)) 2016 ]), 2017 _: 1 2018 }, 8, ["modelValue", "onUpdate:modelValue", "class"]) 2019 ]), 2020 _: 1 2021 }, 8, ["wrap-class"]) 2022 ], 2), 2023 createBaseVNode("div", { 2024 class: normalizeClass(_ctx.ns.e("bottom")) 2025 }, [ 2026 createBaseVNode("button", { 2027 class: normalizeClass({ [_ctx.ns.is("disabled")]: _ctx.filteredValue.length === 0 }), 2028 disabled: _ctx.filteredValue.length === 0, 2029 type: "button", 2030 onClick: _ctx.handleConfirm 2031 }, toDisplayString(_ctx.t("el.table.confirmFilter")), 11, ["disabled", "onClick"]), 2032 createBaseVNode("button", { 2033 type: "button", 2034 onClick: _ctx.handleReset 2035 }, toDisplayString(_ctx.t("el.table.resetFilter")), 9, ["onClick"]) 2036 ], 2) 2037 ])) : (openBlock(), createElementBlock("ul", { 2038 key: 1, 2039 class: normalizeClass(_ctx.ns.e("list")) 2040 }, [ 2041 createBaseVNode("li", { 2042 class: normalizeClass([ 2043 _ctx.ns.e("list-item"), 2044 { 2045 [_ctx.ns.is("active")]: _ctx.isPropAbsent(_ctx.filterValue) 2046 } 2047 ]), 2048 onClick: ($event) => _ctx.handleSelect(null) 2049 }, toDisplayString(_ctx.t("el.table.clearFilter")), 11, ["onClick"]), 2050 (openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.filters, (filter) => { 2051 return openBlock(), createElementBlock("li", { 2052 key: filter.value, 2053 class: normalizeClass([_ctx.ns.e("list-item"), _ctx.ns.is("active", _ctx.isActive(filter))]), 2054 label: filter.value, 2055 onClick: ($event) => _ctx.handleSelect(filter.value) 2056 }, toDisplayString(filter.text), 11, ["label", "onClick"]); 2057 }), 128)) 2058 ], 2)) 2059 ]), 2060 default: withCtx(() => [ 2061 withDirectives((openBlock(), createElementBlock("span", { 2062 class: normalizeClass([ 2063 `${_ctx.ns.namespace.value}-table__column-filter-trigger`, 2064 `${_ctx.ns.namespace.value}-none-outline` 2065 ]), 2066 onClick: _ctx.showFilterPanel 2067 }, [ 2068 createVNode(_component_el_icon, null, { 2069 default: withCtx(() => [ 2070 renderSlot(_ctx.$slots, "filter-icon", {}, () => { 2071 var _a; 2072 return [ 2073 ((_a = _ctx.column) == null ? void 0 : _a.filterOpened) ? (openBlock(), createBlock(_component_arrow_up, { key: 0 })) : (openBlock(), createBlock(_component_arrow_down, { key: 1 })) 2074 ]; 2075 }) 2076 ]), 2077 _: 3 2078 }) 2079 ], 10, ["onClick"])), [ 2080 [_directive_click_outside, _ctx.hideFilterPanel, _ctx.popperPaneRef] 2081 ]) 2082 ]), 2083 _: 3 2084 }, 8, ["visible", "placement", "popper-class", "append-to"]); 2085} 2086var FilterPanel = /* @__PURE__ */ _export_sfc(_sfc_main$2, [["render", _sfc_render$1], ["__file", "filter-panel.vue"]]); 2087function useLayoutObserver(root) { 2088 const instance = getCurrentInstance(); 2089 onBeforeMount(() => { 2090 tableLayout.value.addObserver(instance); 2091 }); 2092 onMounted(() => { 2093 onColumnsChange(tableLayout.value); 2094 onScrollableChange(tableLayout.value); 2095 }); 2096 onUpdated(() => { 2097 onColumnsChange(tableLayout.value); 2098 onScrollableChange(tableLayout.value); 2099 }); 2100 onUnmounted(() => { 2101 tableLayout.value.removeObserver(instance); 2102 }); 2103 const tableLayout = computed(() => { 2104 const layout = root.layout; 2105 if (!layout) { 2106 throw new Error("Can not find table layout."); 2107 } 2108 return layout; 2109 }); 2110 const onColumnsChange = (layout) => { 2111 var _a; 2112 const cols = ((_a = root.vnode.el) == null ? void 0 : _a.querySelectorAll("colgroup > col")) || []; 2113 if (!cols.length) 2114 return; 2115 const flattenColumns = layout.getFlattenColumns(); 2116 const columnsMap = {}; 2117 flattenColumns.forEach((column) => { 2118 columnsMap[column.id] = column; 2119 }); 2120 for (let i = 0, j = cols.length; i < j; i++) { 2121 const col = cols[i]; 2122 const name = col.getAttribute("name"); 2123 const column = columnsMap[name]; 2124 if (column) { 2125 col.setAttribute("width", column.realWidth || column.width); 2126 } 2127 } 2128 }; 2129 const onScrollableChange = (layout) => { 2130 var _a, _b; 2131 const cols = ((_a = root.vnode.el) == null ? void 0 : _a.querySelectorAll("colgroup > col[name=gutter]")) || []; 2132 for (let i = 0, j = cols.length; i < j; i++) { 2133 const col = cols[i]; 2134 col.setAttribute("width", layout.scrollY.value ? layout.gutterWidth : "0"); 2135 } 2136 const ths = ((_b = root.vnode.el) == null ? void 0 : _b.querySelectorAll("th.gutter")) || []; 2137 for (let i = 0, j = ths.length; i < j; i++) { 2138 const th = ths[i]; 2139 th.style.width = layout.scrollY.value ? `${layout.gutterWidth}px` : "0"; 2140 th.style.display = layout.scrollY.value ? "" : "none"; 2141 } 2142 }; 2143 return { 2144 tableLayout: tableLayout.value, 2145 onColumnsChange, 2146 onScrollableChange 2147 }; 2148} 2149const TABLE_INJECTION_KEY = Symbol("ElTable"); 2150function useEvent(props, emit) { 2151 const instance = getCurrentInstance(); 2152 const parent = inject(TABLE_INJECTION_KEY); 2153 const handleFilterClick = (event) => { 2154 event.stopPropagation(); 2155 return; 2156 }; 2157 const handleHeaderClick = (event, column) => { 2158 if (!column.filters && column.sortable) { 2159 handleSortClick(event, column, false); 2160 } else if (column.filterable && !column.sortable) { 2161 handleFilterClick(event); 2162 } 2163 parent == null ? void 0 : parent.emit("header-click", column, event); 2164 }; 2165 const handleHeaderContextMenu = (event, column) => { 2166 parent == null ? void 0 : parent.emit("header-contextmenu",
2166column, event); 2167 }; 2168 const draggingColumn = ref(null); 2169 const dragging = ref(false); 2170 const dragState = ref(); 2171 const handleMouseDown = (event, column) => { 2172 var _a, _b; 2173 if (!isClient) 2174 return; 2175 if (column.children && column.children.length > 0) 2176 return; 2177 if (draggingColumn.value && props.border) { 2178 dragging.value = true; 2179 const table = parent; 2180 emit("set-drag-visible", true); 2181 const tableEl = table == null ? void 0 : table.vnode.el; 2182 const tableLeft = tableEl == null ? void 0 : tableEl.getBoundingClientRect().left; 2183 const columnEl = (_b = (_a = instance == null ? void 0 : instance.vnode) == null ? void 0 : _a.el) == null ? void 0 : _b.querySelector(`th.${column.id}`); 2184 const columnRect = columnEl.getBoundingClientRect(); 2185 const minLeft = columnRect.left - tableLeft + 30; 2186 addClass(columnEl, "noclick"); 2187 dragState.value = { 2188 startMouseLeft: event.clientX, 2189 startLeft: columnRect.right - tableLeft, 2190 startColumnLeft: columnRect.left - tableLeft, 2191 tableLeft 2192 }; 2193 const resizeProxy = table == null ? void 0 : table.refs.resizeProxy; 2194 resizeProxy.style.left = `${dragState.value.startLeft}px`; 2195 document.onselectstart = function() { 2196 return false; 2197 }; 2198 document.ondragstart = function() { 2199 return false; 2200 }; 2201 const handleMouseMove2 = (event2) => { 2202 const deltaLeft = event2.clientX - dragState.value.startMouseLeft; 2203 const proxyLeft = dragState.value.startLeft + deltaLeft; 2204 resizeProxy.style.left = `${Math.max(minLeft, proxyLeft)}px`; 2205 }; 2206 const handleMouseUp = () => { 2207 if (dragging.value) { 2208 const { startColumnLeft, startLeft } = dragState.value; 2209 const finalLeft = Number.parseInt(resizeProxy.style.left, 10); 2210 const columnWidth = finalLeft - startColumnLeft; 2211 column.width = column.realWidth = columnWidth; 2212 table == null ? void 0 : table.emit("header-dragend", column.width, startLeft - startColumnLeft, column, event); 2213 requestAnimationFrame(() => { 2214 props.store.scheduleLayout(false, true); 2215 }); 2216 document.body.style.cursor = ""; 2217 dragging.value = false; 2218 draggingColumn.value = null; 2219 dragState.value = void 0; 2220 emit("set-drag-visible", false); 2221 } 2222 document.removeEventListener("mousemove", handleMouseMove2); 2223 document.removeEventListener("mouseup", handleMouseUp); 2224 document.onselectstart = null; 2225 document.ondragstart = null; 2226 setTimeout(() => { 2227 removeClass(columnEl, "noclick"); 2228 }, 0); 2229 }; 2230 document.addEventListener("mousemove", handleMouseMove2); 2231 document.addEventListener("mouseup", handleMouseUp); 2232 } 2233 }; 2234 const handleMouseMove = (event, column) => { 2235 var _a; 2236 if (column.children && column.children.length > 0) 2237 return; 2238 const el = event.target; 2239 if (!isElement(el)) { 2240 return; 2241 } 2242 const target = el == null ? void 0 : el.closest("th"); 2243 if (!column || !column.resizable || !target) 2244 return; 2245 if (!dragging.value && props.border) { 2246 const rect = target.getBoundingClientRect(); 2247 const bodyStyle = document.body.style; 2248 const isLastTh = ((_a = target.parentNode) == null ? void 0 : _a.lastElementChild) === target; 2249 const allowDarg = props.allowDragLastColumn || !isLastTh; 2250 if (rect.width > 12 && rect.right - event.clientX < 8 && allowDarg) { 2251 bodyStyle.cursor = "col-resize"; 2252 if (hasClass(target, "is-sortable")) { 2253 target.style.cursor = "col-resize"; 2254 } 2255 draggingColumn.value = column; 2256 } else if (!dragging.value) { 2257 bodyStyle.cursor = ""; 2258 if (hasClass(target, "is-sortable")) { 2259 target.style.cursor = "pointer"; 2260 } 2261 draggingColumn.value = null; 2262 } 2263 } 2264 }; 2265 const handleMouseOut = () => { 2266 if (!isClient) 2267 return; 2268 document.body.style.cursor = ""; 2269 }; 2270 const toggleOrder = ({ order, sortOrders }) => { 2271 if (order === "") 2272 return sortOrders[0]; 2273 const index = sortOrders.indexOf(order || null); 2274 return sortOrders[index > sortOrders.length - 2 ? 0 : index + 1]; 2275 }; 2276 const handleSortClick = (event, column, givenOrder) => { 2277 var _a; 2278 event.stopPropagation(); 2279 const order = column.order === givenOrder ? null : givenOrder || toggleOrder(column); 2280 const target = (_a = event.target) == null ? void 0 : _a.closest("th"); 2281 if (target) { 2282 if (hasClass(target, "noclick")) { 2283 removeClass(target, "noclick"); 2284 return; 2285 } 2286 } 2287 if (!column.sortable) 2288 return; 2289 const clickTarget = event.currentTarget; 2290 if (["ascending", "descending"].some((str) => hasClass(clickTarget, str) && !column.sortOrders.includes(str))) { 2291 return; 2292 } 2293 const states = props.store.states; 2294 let sortProp = states.sortProp.value; 2295 let sortOrder; 2296 const sortingColumn = states.sortingColumn.value; 2297 if (sortingColumn !== column || sortingColumn === column && isNull(sortingColumn.order)) { 2298 if (sortingColumn) { 2299 sortingColumn.order = null; 2300 } 2301 states.sortingColumn.value = column; 2302 sortProp = column.property; 2303 } 2304 if (!order) { 2305 sortOrder = column.order = null; 2306 } else { 2307 sortOrder = column.order = order; 2308 } 2309 states.sortProp.value = sortProp; 2310 states.sortOrder.value = sortOrder; 2311 parent == null ? void 0 : parent.store.commit("changeSortCondition"); 2312 }; 2313 return { 2314 handleHeaderClick, 2315 handleHeaderContextMenu, 2316 handleMouseDown, 2317 handleMouseMove, 2318 handleMouseOut, 2319 handleSortClick, 2320 handleFilterClick 2321 }; 2322} 2323function useStyle$2(props) { 2324 const parent = inject(TABLE_INJECTION_KEY); 2325 const ns = useNamespace("table"); 2326 const getHeaderRowStyle = (rowIndex) => { 2327 const headerRowStyle = parent == null ? void 0 : parent.props.headerRowStyle; 2328 if (isFunction$1(headerRowStyle)) { 2329 return headerRowStyle.call(null, { rowIndex }); 2330 } 2331 return headerRowStyle; 2332 }; 2333 const getHeaderRowClass = (rowIndex) => { 2334 const classes = []; 2335 const headerRowClassName = parent == null ? void 0 : parent.props.headerRowClassName; 2336 if (isString(headerRowClassName)) { 2337 classes.push(headerRowClassName); 2338 } else if (isFunction$1(headerRowClassName)) { 2339 classes.push(headerRowClassName.call(null, { rowIndex })); 2340 } 2341 return classes.join(" "); 2342 };
2343 const getHeaderCellStyle = (rowIndex, columnIndex, row, column) => { 2344 var _a; 2345 let headerCellStyles = (_a = parent == null ? void 0 : parent.props.headerCellStyle) != null ? _a : {}; 2346 if (isFunction$1(headerCellStyles)) { 2347 headerCellStyles = headerCellStyles.call(null, { 2348 rowIndex, 2349 columnIndex, 2350 row, 2351 column 2352 }); 2353 } 2354 const fixedStyle = getFixedColumnOffset(columnIndex, column.fixed, props.store, row); 2355 ensurePosition(fixedStyle, "left"); 2356 ensurePosition(fixedStyle, "right"); 2357 return Object.assign({}, headerCellStyles, fixedStyle); 2358 }; 2359 const getHeaderCellClass = (rowIndex, columnIndex, row, column) => { 2360 const fixedClasses = getFixedColumnsClass(ns.b(), columnIndex, column.fixed, props.store, row); 2361 const classes = [ 2362 column.id, 2363 column.order, 2364 column.headerAlign, 2365 column.className, 2366 column.labelClassName, 2367 ...fixedClasses 2368 ]; 2369 if (!column.children) { 2370 classes.push("is-leaf"); 2371 } 2372 if (column.sortable) { 2373 classes.push("is-sortable"); 2374 } 2375 const headerCellClassName = parent == null ? void 0 : parent.props.headerCellClassName; 2376 if (isString(headerCellClassName)) { 2377 classes.push(headerCellClassName); 2378 } else if (isFunction$1(headerCellClassName)) { 2379 classes.push(headerCellClassName.call(null, { 2380 rowIndex, 2381 columnIndex, 2382 row, 2383 column 2384 })); 2385 } 2386 classes.push(ns.e("cell")); 2387 return classes.filter((className) => Boolean(className)).join(" "); 2388 }; 2389 return { 2390 getHeaderRowStyle, 2391 getHeaderRowClass, 2392 getHeaderCellStyle, 2393 getHeaderCellClass 2394 }; 2395} 2396const getAllColumns = (columns) => { 2397 const result = []; 2398 columns.forEach((column) => { 2399 if (column.children) { 2400 result.push(column); 2401 result.push.apply(result, getAllColumns(column.children)); 2402 } else { 2403 result.push(column); 2404 } 2405 }); 2406 return result; 2407}; 2408const convertToRows = (originColumns) => { 2409 let maxLevel = 1; 2410 const traverse = (column, parent) => { 2411 if (parent) { 2412 column.level = parent.level + 1; 2413 if (maxLevel < column.level) { 2414 maxLevel = column.level; 2415 } 2416 } 2417 if (column.children) { 2418 let colSpan = 0; 2419 column.children.forEach((subColumn) => { 2420 traverse(subColumn, column); 2421 colSpan += subColumn.colSpan; 2422 }); 2423 column.colSpan = colSpan; 2424 } else { 2425 column.colSpan = 1; 2426 } 2427 }; 2428 originColumns.forEach((column) => { 2429 column.level = 1; 2430 traverse(column, void 0); 2431 }); 2432 const rows = []; 2433 for (let i = 0; i < maxLevel; i++) { 2434 rows.push([]); 2435 } 2436 const allColumns = getAllColumns(originColumns); 2437 allColumns.forEach((column) => { 2438 if (!column.children) { 2439 column.rowSpan = maxLevel - column.level + 1; 2440 } else { 2441 column.rowSpan = 1; 2442 column.children.forEach((col) => col.isSubColumn = true); 2443 } 2444 rows[column.level - 1].push(column); 2445 }); 2446 return rows; 2447}; 2448function useUtils$1(props) { 2449 const parent = inject(TABLE_INJECTION_KEY); 2450 const columnRows = computed(() => { 2451 return convertToRows(props.store.states.originColumns.value); 2452 }); 2453 const isGroup = computed(() => { 2454 const result = columnRows.value.length > 1; 2455 if (result && parent) { 2456 parent.state.isGroup.value = true; 2457 } 2458 return result; 2459 }); 2460 const toggleAllSelection = (event) => { 2461 event.stopPropagation(); 2462 parent == null ? void 0 : parent.store.commit("toggleAllSelection"); 2463 }; 2464 return { 2465 isGroup, 2466 toggleAllSelection, 2467 columnRows 2468 }; 2469} 2470var TableHeader = defineComponent({ 2471 name: "ElTableHeader", 2472 components: { 2473 ElCheckbox 2474 }, 2475 props: { 2476 fixed: { 2477 type: String, 2478 default: "" 2479 }, 2480 store: { 2481 required: true, 2482 type: Object 2483 }, 2484 border: Boolean, 2485 defaultSort: { 2486 type: Object, 2487 default: () => { 2488 return { 2489 prop: "", 2490 order: "" 2491 }; 2492 } 2493 }, 2494 appendFilterPanelTo: { 2495 type: String 2496 }, 2497 allowDragLastColumn: { 2498 type: Boolean 2499 } 2500 }, 2501 setup(props, { emit }) { 2502 const instance = getCurrentInstance(); 2503 const parent = inject(TABLE_INJECTION_KEY); 2504 const ns = useNamespace("table"); 2505 const filterPanels = ref({}); 2506 const { onColumnsChange, onScrollableChange } = useLayoutObserver(parent); 2507 const isTableLayoutAuto = (parent == null ? void 0 : parent.props.tableLayout) === "auto"; 2508 const saveIndexSelection = reactive(/* @__PURE__ */ new Map()); 2509 const theadRef = ref(); 2510 let delayId; 2511 const updateFixedColumnStyle = () => { 2512 delayId = setTimeout(() => { 2513 if (saveIndexSelection.size > 0) { 2514 saveIndexSelection.forEach((column, key) => { 2515 const el = theadRef.value.querySelector(`.${key.replace(/\s/g, ".")}`); 2516 if (el) { 2517 const width = el.getBoundingClientRect().width; 2518 column.width = width || column.width; 2519 } 2520 }); 2521 saveIndexSelection.clear(); 2522 } 2523 }); 2524 }; 2525 watch(saveIndexSelection, updateFixedColumnStyle); 2526 onBeforeUnmount(() => { 2527 if (delayId) { 2528 clearTimeout(delayId); 2529 delayId = void 0; 2530 } 2531 }); 2532 onMounted(async () => { 2533 await nextTick(); 2534 await nextTick(); 2535 const { prop, order } = props.defaultSort; 2536 parent == null ? void 0 : parent.store.commit("sort", { prop, order, init: true }); 2537 updateFixedColumnStyle(); 2538 }); 2539 const { 2540 handleHeaderClick, 2541 handleHeaderContextMenu, 2542 handleMouseDown, 2543 handleMouseMove, 2544 handleMouseOut, 2545 handleSortClick, 2546 handleFilterClick 2547 } = useEvent(props, emit); 2548 const { 2549 getHeaderRowStyle, 2550 getHeaderRowClass, 2551 getHeaderCellStyle, 2552 getHeaderCellClass 2553 } = useStyle$2(props); 2554 const { isGroup, toggleAllSelection, columnRows } = useUtils$1(props); 2555 instance.state = { 2556 onColumnsChange, 2557 onScrollableChange 2558 }; 2559 instance.filterPanels = filterPanels; 2560 return { 2561 ns, 2562 filterPanels, 2563 onColumnsChange, 2564 onScrollableChange, 2565 columnRows, 2566 getHeaderRowClass, 2567 getHeaderRowStyle, 2568 getHeaderCellClass, 2569 getHeaderCellStyle, 2570 handleHeaderClick, 2571 handleHeaderContextMenu, 2572 handleMouseDown, 2573 handleMouseMove, 2574 handleMouseOut, 2575 handleSortClick, 2576 handleFilterClick, 2577 isGroup, 2578 toggleAllSelection, 2579 saveIndexSelection, 2580 isTableLayoutAuto, 2581 theadRef, 2582 updateFixedColumnStyle 2583 }; 2584 }, 2585 render() { 2586 const { 2587 ns, 2588 isGroup, 2589 columnRows, 2590 getHeaderCellStyle, 2591 getHeaderCellClass, 2592 getHeaderRowClass, 2593 getHeaderRowStyle, 2594 handleHeaderClick, 2595 handleHeaderContextMenu, 2596 handleMouseDown, 2597 handleMouseMove, 2598 handleSortClick, 2599 handleMouseOut, 2600 store, 2601 $parent, 2602 saveIndexSelection, 2603 isTableLayoutAuto 2604 } = this; 2605 let rowSpan = 1; 2606 return h$1("thead", { 2607 ref: "theadRef", 2608 class: { [ns.is("group")]: isGroup } 2609 }, columnRows.map((subColumns, rowIndex) => h$1("tr", { 2610 class: getHeaderRowClass(rowIndex), 2611 key: rowIndex, 2612 style: getHeaderRowStyle(rowIndex) 2613 }, subColumns.map((column, cellIndex) => { 2614 if (column.rowSpan > rowSpan) { 2615 rowSpan = column.rowSpan; 2616 } 2617 const _class = getHeaderCellClass(rowIndex, cellIndex, subColumns, column); 2618 if (isTableLayoutAuto && column.fixed) { 2619 saveIndexSelection.set(_class, column); 2620 } 2621 return h$1("th", { 2622 class: _class, 2623 colspan: column.colSpan, 2624 key: `${column.id}-thead`, 2625 rowspan: column.rowSpan, 2626 style: getHeaderCellStyle(rowIndex, cellIndex, subColumns, column), 2627 onClick: ($event) => { 2628 var _a; 2629 if ((_a = $event.currentTarget) == null ? void 0 : _a.classList.contains("noclick")) { 2630 return; 2631 } 2632 handleHeaderClick($event, column); 2633 }, 2634 onContextmenu: ($event) => handleHeaderContextMenu($event, column), 2635 onMousedown: ($event) => handleMouseDown($event, column), 2636 onMousemove: ($event) => handleMouseMove($event, column), 2637 onMouseout: handleMouseOut 2638 }, [ 2639 h$1("div", { 2640 class: [ 2641 "cell", 2642 column.filteredValue && column.filteredValue.length > 0 ? "highlight" : "" 2643 ] 2644 }, [ 2645 column.renderHeader ? column.renderHeader({ 2646 column, 2647 $index: cellIndex, 2648 store, 2649 _self: $parent 2650 }) : column.label, 2651 column.sortable && h$1("span", { 2652 onClick: ($event) => handleSortClick($event, column), 2653 class: "caret-wrapper" 2654 }, [ 2655 h$1("i", { 2656 onClick: ($event) => handleSortClick($event, column, "ascending"), 2657 class: "sort-caret ascending" 2658 }), 2659 h$1("i", { 2660 onClick: ($event) =>
2660 handleSortClick($event, column, "descending"), 2661 class: "sort-caret descending" 2662 }) 2663 ]), 2664 column.filterable && h$1(FilterPanel, { 2665 store, 2666 placement: column.filterPlacement || "bottom-start", 2667 appendTo: $parent == null ? void 0 : $parent.appendFilterPanelTo, 2668 column, 2669 upDataColumn: (key, value) => { 2670 column[key] = value; 2671 } 2672 }, { 2673 "filter-icon": () => column.renderFilterIcon ? column.renderFilterIcon({ 2674 filterOpened: column.filterOpened 2675 }) : null 2676 }) 2677 ]) 2678 ]); 2679 })))); 2680 } 2681}); 2682function isGreaterThan(a2, b2, epsilon = 0.03) { 2683 return a2 - b2 > epsilon; 2684} 2685function useEvents(props) { 2686 const parent = inject(TABLE_INJECTION_KEY); 2687 const tooltipContent = ref(""); 2688 const tooltipTrigger = ref(h$1("div")); 2689 const handleEvent = (event, row, name) => { 2690 var _a, _b, _c; 2691 const table = parent; 2692 const cell = getCell(event); 2693 let column = null; 2694 const namespace = (_a = table == null ? void 0 : table.vnode.el) == null ? void 0 : _a.dataset.prefix; 2695 if (cell) { 2696 column = getColumnByCell({ 2697 columns: (_c = (_b = props.store) == null ? void 0 : _b.states.columns.value) != null ? _c : [] 2698 }, cell, namespace); 2699 if (column) { 2700 table == null ? void 0 : table.emit(`cell-${name}`, row, column, cell, event); 2701 } 2702 } 2703 table == null ? void 0 : table.emit(`row-${name}`, row, column, event); 2704 }; 2705 const handleDoubleClick = (event, row) => { 2706 handleEvent(event, row, "dblclick"); 2707 }; 2708 const handleClick = (event, row) => { 2709 var _a; 2710 (_a = props.store) == null ? void 0 : _a.commit("setCurrentRow", row); 2711 handleEvent(event, row, "click"); 2712 }; 2713 const handleContextMenu = (event, row) => { 2714 handleEvent(event, row, "contextmenu"); 2715 }; 2716 const handleMouseEnter = debounce((index) => { 2717 var _a; 2718 (_a = props.store) == null ? void 0 : _a.commit("setHoverRow", index); 2719 }, 30); 2720 const handleMouseLeave = debounce(() => { 2721 var _a; 2722 (_a = props.store) == null ? void 0 : _a.commit("setHoverRow", null); 2723 }, 30); 2724 const getPadding = (el) => { 2725 const style = window.getComputedStyle(el, null); 2726 const paddingLeft = Number.parseInt(style.paddingLeft, 10) || 0; 2727 const paddingRight = Number.parseInt(style.paddingRight, 10) || 0; 2728 const paddingTop = Number.parseInt(style.paddingTop, 10) || 0; 2729 const paddingBottom = Number.parseInt(style.paddingBottom, 10) || 0; 2730 return { 2731 left: paddingLeft, 2732 right: paddingRight, 2733 top: paddingTop, 2734 bottom: paddingBottom 2735 }; 2736 }; 2737 const toggleRowClassByCell = (rowSpan, event, toggle) => { 2738 var _a; 2739 let node = (_a = event == null ? void 0 : event.target) == null ? void 0 : _a.parentNode; 2740 while (rowSpan > 1) { 2741 node = node == null ? void 0 : node.nextSibling; 2742 if (!node || node.nodeName !== "TR") 2743 break; 2744 toggle(node, "hover-row hover-fixed-row"); 2745 rowSpan--; 2746 } 2747 }; 2748 const handleCellMouseEnter = (event, row, tooltipOptions) => { 2749 var _a, _b, _c, _d, _e, _f, _g, _h; 2750 if (!parent) 2751 return; 2752 const table = parent; 2753 const cell = getCell(event); 2754 const namespace = (_a = table == null ? void 0 : table.vnode.el) == null ? void 0 : _a.dataset.prefix; 2755 let column = null; 2756 if (cell) { 2757 column = getColumnByCell({ 2758 columns: (_c = (_b = props.store) == null ? void 0 : _b.states.columns.value) != null ? _c : [] 2759 }, cell, namespace); 2760 if (!column) { 2761 return; 2762 } 2763 if (cell.rowSpan > 1) { 2764 toggleRowClassByCell(cell.rowSpan, event, addClass); 2765 } 2766 const hoverState = table.hoverState = { 2767 cell, 2768 column, 2769 row 2770 }; 2771 table == null ? void 0 : table.emit("cell-mouse-enter", hoverState.row, hoverState.column, hoverState.cell, event); 2772 } 2773 if (!tooltipOptions) { 2774 if (((_d = removePopper) == null ? void 0 : _d.trigger) === cell) { 2775 (_e = removePopper) == null ? void 0 : _e(); 2776 } 2777 return; 2778 } 2779 const cellChild = event.target.querySelector(".cell"); 2780 if (!(hasClass(cellChild, `${namespace}-tooltip`) && cellChild.childNodes.length)) { 2781 return; 2782 } 2783 const range = document.createRange(); 2784 range.setStart(cellChild, 0); 2785 range.setEnd(cellChild, cellChild.childNodes.length); 2786 const { width: rangeWidth, height: rangeHeight } = range.getBoundingClientRect();
2787 const { width: cellChildWidth, height: cellChildHeight } = cellChild.getBoundingClientRect(); 2788 const { top, left, right, bottom } = getPadding(cellChild); 2789 const horizontalPadding = left + right; 2790 const verticalPadding = top + bottom; 2791 if (isGreaterThan(rangeWidth + horizontalPadding, cellChildWidth) || isGreaterThan(rangeHeight + verticalPadding, cellChildHeight) || isGreaterThan(cellChild.scrollWidth, cellChildWidth)) { 2792 createTablePopper(tooltipOptions, (_f = (cell == null ? void 0 : cell.innerText) || (cell == null ? void 0 : cell.textContent)) != null ? _f : "", row, column, cell, table); 2793 } else if (((_g = removePopper) == null ? void 0 : _g.trigger) === cell) { 2794 (_h = removePopper) == null ? void 0 : _h(); 2795 } 2796 }; 2797 const handleCellMouseLeave = (event) => { 2798 const cell = getCell(event); 2799 if (!cell) 2800 return; 2801 if (cell.rowSpan > 1) { 2802 toggleRowClassByCell(cell.rowSpan, event, removeClass); 2803 } 2804 const oldHoverState = parent == null ? void 0 : parent.hoverState; 2805 parent == null ? void 0 : parent.emit("cell-mouse-leave", oldHoverState == null ? void 0 : oldHoverState.row, oldHoverState == null ? void 0 : oldHoverState.column, oldHoverState == null ? void 0 : oldHoverState.cell, event); 2806 }; 2807 return { 2808 handleDoubleClick, 2809 handleClick, 2810 handleContextMenu, 2811 handleMouseEnter, 2812 handleMouseLeave, 2813 handleCellMouseEnter, 2814 handleCellMouseLeave, 2815 tooltipContent, 2816 tooltipTrigger 2817 }; 2818} 2819function useStyles(props) { 2820 const parent = inject(TABLE_INJECTION_KEY); 2821 const ns = useNamespace("table"); 2822 const getRowStyle = (row, rowIndex) => { 2823 const rowStyle = parent == null ? void 0 : parent.props.rowStyle; 2824 if (isFunction$1(rowStyle)) { 2825 return rowStyle.call(null, { 2826 row, 2827 rowIndex 2828 }); 2829 } 2830 return rowStyle || null; 2831 }; 2832 const getRowClass = (row, rowIndex, displayIndex) => { 2833 var _a; 2834 const classes = [ns.e("row")]; 2835 if ((parent == null ? void 0 : parent.props.highlightCurrentRow) && row === ((_a = props.store) == null ? void 0 : _a.states.currentRow.value)) { 2836 classes.push("current-row"); 2837 } 2838 if (props.stripe && displayIndex % 2 === 1) { 2839 classes.push(ns.em("row", "striped")); 2840 } 2841 const rowClassName = parent == null ? void 0 : parent.props.rowClassName; 2842 if (isString(rowClassName)) { 2843 classes.push(rowClassName); 2844 } else if (isFunction$1(rowClassName)) { 2845 classes.push(rowClassName.call(null, { 2846 row, 2847 rowIndex 2848 })); 2849 } 2850 return classes; 2851 }; 2852 const getCellStyle = (rowIndex, columnIndex, row, column) => { 2853 const cellStyle = parent == null ? void 0 : parent.props.cellStyle;
2854 let cellStyles = cellStyle != null ? cellStyle : {}; 2855 if (isFunction$1(cellStyle)) { 2856 cellStyles = cellStyle.call(null, { 2857 rowIndex, 2858 columnIndex, 2859 row, 2860 column 2861 }); 2862 } 2863 const fixedStyle = getFixedColumnOffset(columnIndex, props == null ? void 0 : props.fixed, props.store); 2864 ensurePosition(fixedStyle, "left"); 2865 ensurePosition(fixedStyle, "right"); 2866 return Object.assign({}, cellStyles, fixedStyle); 2867 }; 2868 const getCellClass = (rowIndex, columnIndex, row, column, offset) => { 2869 const fixedClasses = getFixedColumnsClass(ns.b(), columnIndex, props == null ? void 0 : props.fixed, props.store, void 0, offset); 2870 const classes = [column.id, column.align, column.className, ...fixedClasses]; 2871 const cellClassName = parent == null ? void 0 : parent.props.cellClassName; 2872 if (isString(cellClassName)) { 2873 classes.push(cellClassName); 2874 } else if (isFunction$1(cellClassName)) { 2875 classes.push(cellClassName.call(null, { 2876 rowIndex, 2877 columnIndex, 2878 row, 2879 column 2880 })); 2881 } 2882 classes.push(ns.e("cell")); 2883 return classes.filter((className) => Boolean(className)).join(" "); 2884 }; 2885 const getSpan = (row, column, rowIndex, columnIndex) => { 2886 let rowspan = 1; 2887 let colspan = 1; 2888 const fn = parent == null ? void 0 : parent.props.spanMethod; 2889 if (isFunction$1(fn)) { 2890 const result = fn({ 2891 row, 2892 column, 2893 rowIndex, 2894 columnIndex 2895 }); 2896 if (isArray$1(result)) { 2897 rowspan = result[0]; 2898 colspan = result[1]; 2899 } else if (isObject$1(result)) { 2900 rowspan = result.rowspan; 2901 colspan = result.colspan; 2902 } 2903 } 2904 return { rowspan, colspan }; 2905 }; 2906 const getColspanRealWidth = (columns, colspan, index) => { 2907 if (colspan < 1) { 2908 return columns[index].realWidth; 2909 } 2910 const widthArr = columns.map(({ realWidth, width }) => realWidth || width).slice(index, index + colspan); 2911 return Number(widthArr.reduce((acc, width) => Number(acc) + Number(width), -1)); 2912 }; 2913 return { 2914 getRowStyle, 2915 getRowClass, 2916 getCellStyle, 2917 getCellClass, 2918 getSpan, 2919 getColspanRealWidth 2920 }; 2921} 2922const __default__ = defineComponent({ 2923 name: "TableTdWrapper" 2924}); 2925const _sfc_main$1 = /* @__PURE__ */ defineComponent({ 2926 ...__default__, 2927 props: { 2928 colspan: { 2929 type: Number, 2930 default: 1 2931 }, 2932 rowspan: { 2933 type: Number, 2934 default: 1 2935 } 2936 }, 2937 setup(__props) { 2938 return (_ctx, _cache) => { 2939 return openBlock(), createElementBlock("td", { 2940 colspan: __props.colspan, 2941 rowspan: __props.rowspan 2942 }, [ 2943 renderSlot(_ctx.$slots, "default") 2944 ], 8, ["colspan", "rowspan"]); 2945 }; 2946 } 2947}); 2948var TdWrapper = /* @__PURE__ */ _export_sfc(_sfc_main$1, [["__file", "td-wrapper.vue"]]); 2949function useRender$1(props) { 2950 const parent = inject(TABLE_INJECTION_KEY); 2951 const ns = useNamespace("table"); 2952 const { 2953 handleDoubleClick, 2954 handleClick, 2955 handleContextMenu, 2956 handleMouseEnter, 2957 handleMouseLeave, 2958 handleCellMouseEnter, 2959 handleCellMouseLeave, 2960 tooltipContent, 2961 tooltipTrigger 2962 } = useEvents(props); 2963 const { 2964 getRowStyle, 2965 getRowClass, 2966 getCellStyle, 2967 getCellClass, 2968 getSpan, 2969 getColspanRealWidth 2970 } = useStyles(props); 2971 let displayIndex = -1; 2972 const firstDefaultColumnIndex = computed(() => { 2973 var _a; 2974 return (_a = props.store) == null ? void 0 : _a.states.columns.value.findIndex(({ type }) => type === "default"); 2975 }); 2976 const getKeyOfRow = (row, index) => { 2977 var _a; 2978 const rowKey = (_a = parent == null ? void 0 : parent.props) == null ? void 0 : _a.rowKey; 2979 if (rowKey) { 2980 return getRowIdentity(row, rowKey); 2981 } 2982 return index; 2983 }; 2984 const rowRender = (row, $index, treeRowData, expanded = false) => { 2985 const { tooltipEffect, tooltipOptions, store } = props; 2986 const { indent, columns } = store.states; 2987 const rowClasses = []; 2988 let display = true; 2989 if (treeRowData) { 2990 rowClasses.push(ns.em("row", `level-${treeRowData.level}`)); 2991 display = !!treeRowData.display; 2992 } 2993 if ($index === 0) { 2994 displayIndex = -1; 2995 } 2996 if (props.stripe && display) { 2997 displayIndex++; 2998 }
2999 rowClasses.push(...getRowClass(row, $index, displayIndex)); 3000 const displayStyle = display ? null : { display: "none" }; 3001 return h$1("tr", { 3002 style: [displayStyle, getRowStyle(row, $index)], 3003 class: rowClasses, 3004 key: getKeyOfRow(row, $index), 3005 onDblclick: ($event) => handleDoubleClick($event, row), 3006 onClick: ($event) => handleClick($event, row), 3007 onContextmenu: ($event) => handleContextMenu($event, row), 3008 onMouseenter: () => handleMouseEnter($index), 3009 onMouseleave: handleMouseLeave 3010 }, columns.value.map((column, cellIndex) => { 3011 const { rowspan, colspan } = getSpan(row, column, $index, cellIndex); 3012 if (!rowspan || !colspan) { 3013 return null; 3014 } 3015 const columnData = Object.assign({}, column); 3016 columnData.realWidth = getColspanRealWidth(columns.value, colspan, cellIndex); 3017 const data = { 3018 store, 3019 _self: props.context || parent, 3020 column: columnData, 3021 row, 3022 $index, 3023 cellIndex, 3024 expanded 3025 }; 3026 if (cellIndex === firstDefaultColumnIndex.value && treeRowData) { 3027 data.treeNode = { 3028 indent: treeRowData.level && treeRowData.level * indent.value, 3029 level: treeRowData.level 3030 }; 3031 if (isBoolean(treeRowData.expanded)) { 3032 data.treeNode.expanded = treeRowData.expanded; 3033 if ("loading" in treeRowData) { 3034 data.treeNode.loading = treeRowData.loading; 3035 } 3036 if ("noLazyChildren" in treeRowData) { 3037 data.treeNode.noLazyChildren = treeRowData.noLazyChildren; 3038 } 3039 } 3040 } 3041 const baseKey = `${getKeyOfRow(row, $index)},${cellIndex}`; 3042 const patchKey = columnData.columnKey || columnData.rawColumnKey || ""; 3043 const mergedTooltipOptions = column.showOverflowTooltip && merge({ 3044 effect: tooltipEffect 3045 }, tooltipOptions, column.showOverflowTooltip); 3046 return h$1(TdWrapper, { 3047 style: getCellStyle($index, cellIndex, row, column), 3048 class: getCellClass($index, cellIndex, row, column, colspan - 1), 3049 key: `${patchKey}${baseKey}`, 3050 rowspan, 3051 colspan, 3052 onMouseenter: ($event) => handleCellMouseEnter($event, row, mergedTooltipOptions), 3053 onMouseleave: handleCellMouseLeave 3054 }, { 3055 default: () => cellChildren(cellIndex, column, data) 3056 }); 3057 })); 3058 }; 3059 const cellChildren = (_cellIndex, column, data) => { 3060 return column.renderCell(data); 3061 }; 3062 const wrappedRowRender = (row, $index) => { 3063 const store = props.store; 3064 const { isRowExpanded, assertRowKey } = store; 3065 const { treeData, lazyTreeNodeMap, childrenColumnName, rowKey } = store.states; 3066 const columns = store.states.columns.value; 3067 const hasExpandColumn = columns.some(({ type }) => type === "expand"); 3068 if (hasExpandColumn) { 3069 const expanded = isRowExpanded(row); 3070 const tr = rowRender(row, $index, void 0, expanded); 3071 const renderExpanded = parent == null ? void 0 : parent.renderExpanded; 3072 if (!renderExpanded) { 3073 console.error("[Element Error]renderExpanded is required."); 3074 return tr; 3075 } 3076 const rows = [[tr]]; 3077 if (parent.props.preserveExpandedContent || expanded) { 3078 rows[0].push(h$1("tr", { 3079 key: `expanded-row__${tr.key}`, 3080 style: { display: expanded ? "" : "none" } 3081 }, [ 3082 h$1("td", { 3083 colspan: columns.length, 3084 class: `${ns.e("cell")} ${ns.e("expanded-cell")}` 3085 }, [renderExpanded({ row, $index, store, expanded })]) 3086 ])); 3087 } 3088 return rows; 3089 } else if (Object.keys(treeData.value).length) { 3090 assertRowKey(); 3091 const key = getRowIdentity(row, rowKey.value); 3092 let cur = treeData.value[key]; 3093 let treeRowData = null; 3094 if (cur) { 3095 treeRowData = { 3096 expanded: cur.expanded, 3097 level: cur.level, 3098 display: true, 3099 noLazyChildren: void 0, 3100 loading: void 0 3101 }; 3102 if (isBoolean(cur.lazy)) { 3103 if (treeRowData && isBoolean(cur.loaded) && cur.loaded) { 3104 treeRowData.noLazyChildren = !(cur.children && cur.children.length); 3105 } 3106 treeRowData.loading = cur.loading; 3107 } 3108 } 3109 const tmp = [rowRender(row, $index, treeRowData != null ? treeRowData : void 0)]; 3110 if (cur) { 3111 let i = 0; 3112 const traverse = (children, parent2) => { 3113 if (!(children && children.length && parent2)) 3114 return;
3115 children.forEach((node) => { 3116 const innerTreeRowData = { 3117 display: parent2.display && parent2.expanded, 3118 level: parent2.level + 1, 3119 expanded: false, 3120 noLazyChildren: false, 3121 loading: false 3122 }; 3123 const childKey = getRowIdentity(node, rowKey.value); 3124 if (isPropAbsent(childKey)) { 3125 throw new Error("For nested data item, row-key is required."); 3126 } 3127 cur = { ...treeData.value[childKey] }; 3128 if (cur) { 3129 innerTreeRowData.expanded = cur.expanded; 3130 cur.level = cur.level || innerTreeRowData.level; 3131 cur.display = !!(cur.expanded && innerTreeRowData.display); 3132 if (isBoolean(cur.lazy)) { 3133 if (isBoolean(cur.loaded) && cur.loaded) { 3134 innerTreeRowData.noLazyChildren = !(cur.children && cur.children.length); 3135 } 3136 innerTreeRowData.loading = cur.loading; 3137 } 3138 } 3139 i++; 3140 tmp.push(rowRender(node, $index + i, innerTreeRowData)); 3141 if (cur) { 3142 const nodes2 = lazyTreeNodeMap.value[childKey] || node[childrenColumnName.value]; 3143 traverse(nodes2, cur); 3144 } 3145 }); 3146 }; 3147 cur.display = true; 3148 const nodes = lazyTreeNodeMap.value[key] || row[childrenColumnName.value]; 3149 traverse(nodes, cur); 3150 } 3151 return tmp; 3152 } else { 3153 return rowRender(row, $index, void 0); 3154 } 3155 }; 3156 return { 3157 wrappedRowRender, 3158 tooltipContent, 3159 tooltipTrigger 3160 }; 3161} 3162const defaultProps$2 = { 3163 store: { 3164 required: true, 3165 type: Object 3166 }, 3167 stripe: Boolean, 3168 tooltipEffect: String, 3169 tooltipOptions: { 3170 type: Object 3171 }, 3172 context: { 3173 default: () => ({}), 3174 type: Object 3175 }, 3176 rowClassName: [String, Function], 3177 rowStyle: [Object, Function], 3178 fixed: { 3179 type: String, 3180 default: "" 3181 }, 3182 highlight: Boolean 3183}; 3184var TableBody = defineComponent({ 3185 name: "ElTableBody", 3186 props: defaultProps$2, 3187 setup(props) { 3188 var _a; 3189 const instance = getCurrentInstance(); 3190 const parent = inject(TABLE_INJECTION_KEY); 3191 const ns = useNamespace("table"); 3192 const { wrappedRowRender, tooltipContent, tooltipTrigger } = useRender$1(props); 3193 const { onColumnsChange, onScrollableChange } = useLayoutObserver(parent); 3194 const hoveredCellList = []; 3195 watch((_a = props.store) == null ? void 0 : _a.states.hoverRow, (newVal, oldVal) => { 3196 var _a2, _b; 3197 const el = instance == null ? void 0 : instance.vnode.el; 3198 const rows = Array.from((el == null ? void 0 : el.children) || []).filter((e) => e == null ? void 0 : e.classList.contains(`${ns.e("row")}`)); 3199 let rowNum = newVal; 3200 const childNodes = (_a2 = rows[rowNum]) == null ? void 0 : _a2.childNodes; 3201 if (childNodes == null ? void 0 : childNodes.length) { 3202 let control = 0; 3203 const indexes = Array.from(childNodes).reduce((acc, item, index) => { 3204 var _a3, _b2; 3205 if (((_a3 = childNodes[index]) == null ? void 0 : _a3.colSpan) > 1) { 3206 control = (_b2 = childNodes[index]) == null ? void 0 : _b2.colSpan; 3207 } 3208 if (item.nodeName !== "TD" && control === 0) { 3209 acc.push(index); 3210 } 3211 control > 0 && control--; 3212 return acc; 3213 }, []); 3214 indexes.forEach((rowIndex) => { 3215 var _a3; 3216 rowNum = newVal; 3217 while (rowNum > 0) { 3218 const preChildNodes = (_a3 = rows[rowNum - 1]) == null ? void 0 : _a3.childNodes; 3219 if (preChildNodes[rowIndex] && preChildNodes[rowIndex].nodeName === "TD" && preChildNodes[rowIndex].rowSpan > 1) { 3220 addClass(preChildNodes[rowIndex], "hover-cell"); 3221 hoveredCellList.push(preChildNodes[rowIndex]); 3222 break; 3223 } 3224 rowNum--; 3225 } 3226 }); 3227 } else { 3228 hoveredCellList.forEach((item) => removeClass(item, "hover-cell")); 3229 hoveredCellList.length = 0; 3230 } 3231 if (!((_b = props.store) == null ? void 0 : _b.states.isComplex.value) || !isClient) 3232 return; 3233 rAF(() => { 3234 const oldRow = rows[oldVal]; 3235 const newRow = rows[newVal]; 3236 if (oldRow && !oldRow.classList.contains("hover-fixed-row")) { 3237 removeClass(oldRow, "hover-row"); 3238 } 3239 if (newRow) { 3240 addClass(newRow, "hover-row"); 3241 } 3242 }); 3243 }); 3244 onUnmounted(() => { 3245 var _a2; 3246 (_a2 = removePopper) == null ? void 0 : _a2(); 3247 }); 3248 return { 3249 ns, 3250 onColumnsChange, 3251 onScrollableChange, 3252 wrappedRowRender, 3253 tooltipContent, 3254 tooltipTrigger 3255 }; 3256 }, 3257 render() { 3258 const { wrappedRowRender, store } = this; 3259 const data = (store == null ? void 0 : store.states.data.value) || []; 3260 return h$1("tbody", { tabIndex: -1 }, [ 3261 data.reduce((acc, row) => { 3262 return acc.concat(wrappedRowRender(row, acc.length)); 3263 }, []) 3264 ]); 3265 } 3266}); 3267function useMapState() { 3268 const table = inject(TABLE_INJECTION_KEY); 3269 const store = table == null ? void 0 : table.store; 3270 const leftFixedLeafCount = computed(() => { 3271 var _a; 3272 return (_a = store == null ? void 0 : store.states.fixedLeafColumnsLength.value) != null ? _a : 0; 3273 }); 3274 const rightFixedLeafCount = computed(() => { 3275 var _a; 3276 return (_a = store == null ? void 0 : store.states.rightFixedColumns.value.length) != null ? _a : 0; 3277 }); 3278 const columnsCount = computed(() => { 3279 var _a; 3280 return (_a = store == null ? void 0 : store.states.columns.value.length) != null ? _a : 0; 3281 }); 3282 const leftFixedCount = computed(() => { 3283 var _a; 3284 return (_a = store == null ? void 0 : store.states.fixedColumns.value.length) != null ? _a : 0; 3285 }); 3286 const rightFixedCount = computed(() => { 3287 var _a; 3288 return (_a = store == null ? void 0 : store.states.rightFixedColumns.value.length) != null ? _a : 0; 3289 }); 3290 return { 3291 leftFixedLeafCount, 3292 rightFixedLeafCount, 3293 columnsCount, 3294 leftFixedCount, 3295 rightFixedCount, 3296 columns: computed(() => { 3297 var _a; 3298 return (_a = store == null ? void 0 : store.states.columns.value) != null ? _a : []; 3299 }) 3300 }; 3301} 3302function useStyle$1(props) { 3303 const { columns } = useMapState(); 3304 const ns = useNamespace("table"); 3305 const getCellClasses = (columns2, cellIndex) => { 3306 const column = columns2[cellIndex]; 3307 const classes = [ 3308 ns.e("cell"), 3309 column.id, 3310 column.align, 3311 column.labelClassName, 3312 ...getFixedColumnsClass(ns.b(), cellIndex, column.fixed, props.store) 3313 ]; 3314 if (column.className) { 3315 classes.push(column.className); 3316 } 3317 if (!column.children) { 3318 classes.push(ns.is("leaf")); 3319 } 3320 return classes; 3321 }; 3322 const getCellStyles = (column, cellIndex) => { 3323 const fixedStyle = getFixedColumnOffset(cellIndex, column.fixed, props.store); 3324 ensurePosition(fixedStyle, "left"); 3325 ensurePosition(fixedStyle, "right"); 3326 return fixedStyle; 3327 }; 3328 return { 3329 getCellClasses, 3330 getCellStyles, 3331 columns 3332 }; 3333} 3334var TableFooter = defineComponent({ 3335 name: "ElTableFooter", 3336 props: { 3337 fixed: { 3338 type: String, 3339 default: "" 3340 }, 3341 store: { 3342 required: true, 3343 type: Object 3344 }, 3345 summaryMethod: Function, 3346 sumText: String, 3347 border: Boolean, 3348 defaultSort: { 3349 type: Object, 3350 default: () => { 3351 return { 3352 prop: "", 3353 order: "" 3354 }; 3355 } 3356 } 3357 }, 3358 setup(props) { 3359 const parent = inject(TABLE_INJECTION_KEY); 3360 const ns = useNamespace("table"); 3361 const { getCellClasses, getCellStyles, columns } = useStyle$1(props); 3362 const { onScrollableChange, onColumnsChange } = useLayoutObserver(parent); 3363 return { 3364 ns, 3365 onScrollableChange, 3366 onColumnsChange, 3367 getCellClasses, 3368 getCellStyles, 3369 columns 3370 }; 3371 }, 3372 render() { 3373 const { columns, getCellStyles, getCellClasses, summaryMethod, sumText } = this; 3374 const data = this.store.states.data.value; 3375 let sums = []; 3376 if (summaryMethod) { 3377 sums = summaryMethod({ 3378 columns, 3379 data 3380 }); 3381 } else { 3382 columns.forEach((column, index) => { 3383 if (index === 0) { 3384 sums[index] = sumText; 3385 return; 3386 } 3387 const values = data.map((item) => Number(item[column.property])); 3388 const precisions = []; 3389 let notNumber = true;
3390 values.forEach((value) => { 3391 if (!Number.isNaN(+value)) { 3392 notNumber = false; 3393 const decimal = `${value}`.split(".")[1]; 3394 precisions.push(decimal ? decimal.length : 0); 3395 } 3396 }); 3397 const precision = Math.max.apply(null, precisions); 3398 if (!notNumber) { 3399 sums[index] = values.reduce((prev, curr) => { 3400 const value = Number(curr); 3401 if (!Number.isNaN(+value)) { 3402 return Number.parseFloat((prev + curr).toFixed(Math.min(precision, 20))); 3403 } else { 3404 return prev; 3405 } 3406 }, 0); 3407 } else { 3408 sums[index] = ""; 3409 } 3410 }); 3411 } 3412 return h$1(h$1("tfoot", [ 3413 h$1("tr", {}, [ 3414 ...columns.map((column, cellIndex) => h$1("td", { 3415 key: cellIndex, 3416 colspan: column.colSpan, 3417 rowspan: column.rowSpan, 3418 class: getCellClasses(columns, cellIndex), 3419 style: getCellStyles(column, cellIndex) 3420 }, [ 3421 h$1("div", { 3422 class: ["cell", column.labelClassName] 3423 }, [sums[cellIndex]]) 3424 ])) 3425 ]) 3426 ])); 3427 } 3428}); 3429function useUtils(store) { 3430 const setCurrentRow = (row) => { 3431 store.commit("setCurrentRow", row); 3432 }; 3433 const getSelectionRows = () => { 3434 return store.getSelectionRows(); 3435 }; 3436 const toggleRowSelection = (row, selected, ignoreSelectable = true) => { 3437 store.toggleRowSelection(row, selected, false, ignoreSelectable); 3438 store.updateAllSelected(); 3439 }; 3440 const clearSelection = () => { 3441 store.clearSelection(); 3442 }; 3443 const clearFilter = (columnKeys) => { 3444 store.clearFilter(columnKeys); 3445 }; 3446 const toggleAllSelection = () => { 3447 store.commit("toggleAllSelection"); 3448 }; 3449 const toggleRowExpansion = (row, expanded) => { 3450 store.toggleRowExpansionAdapter(row, expanded); 3451 }; 3452 const clearSort = () => { 3453 store.clearSort(); 3454 }; 3455 const sort = (prop, order) => { 3456 store.commit("sort", { prop, order }); 3457 }; 3458 const updateKeyChildren = (key, data) => { 3459 store.updateKeyChildren(key, data); 3460 }; 3461 return { 3462 setCurrentRow, 3463 getSelectionRows, 3464 toggleRowSelection, 3465 clearSelection, 3466 clearFilter, 3467 toggleAllSelection, 3468 toggleRowExpansion, 3469 clearSort, 3470 sort, 3471 updateKeyChildren 3472 }; 3473} 3474function useStyle(props, layout, store, table) { 3475 const isHidden = ref(false); 3476 const renderExpanded = ref(null); 3477 const resizeProxyVisible = ref(false); 3478 const setDragVisible = (visible) => { 3479 resizeProxyVisible.value = visible; 3480 }; 3481 const resizeState = ref({ 3482 width: null, 3483 height: null, 3484 headerHeight: null 3485 }); 3486 const isGroup = ref(false); 3487 const scrollbarViewStyle = { 3488 display: "inline-block", 3489 verticalAlign: "middle" 3490 }; 3491 const tableWidth = ref(); 3492 const tableScrollHeight = ref(0); 3493 const bodyScrollHeight = ref(0); 3494 const headerScrollHeight = ref(0); 3495 const footerScrollHeight = ref(0); 3496 const appendScrollHeight = ref(0); 3497 watchEffect(() => { 3498 var _a; 3499 layout.setHeight((_a = props.height) != null ? _a : null); 3500 }); 3501 watchEffect(() => { 3502 var _a; 3503 layout.setMaxHeight((_a = props.maxHeight) != null ? _a : null); 3504 }); 3505 watch(() => [props.currentRowKey, store.states.rowKey], ([currentRowKey, rowKey]) => { 3506 if (!unref(rowKey) || !unref(currentRowKey)) 3507 return; 3508 store.setCurrentRowKey(`${currentRowKey}`); 3509 }, { 3510 immediate: true 3511 }); 3512 watch(() => props.data, (data) => { 3513 table.store.commit("setData", data); 3514 }, { 3515 immediate: true, 3516 deep: true 3517 }); 3518 watchEffect(() => { 3519 if (props.expandRowKeys) { 3520 store.setExpandRowKeysAdapter(props.expandRowKeys); 3521 } 3522 }); 3523 const handleMouseLeave = () => { 3524 table.store.commit("setHoverRow", null); 3525 if (table.hoverState) 3526 table.hoverState = null; 3527 }; 3528 const handleHeaderFooterMousewheel = (_event, data) => { 3529 const { pixelX, pixelY } = data; 3530 if (Math.abs(pixelX) >= Math.abs(pixelY)) { 3531 table.refs.bodyWrapper.scrollLeft += data.pixelX / 5; 3532 } 3533 }; 3534 const shouldUpdateHeight = computed(() => { 3535 return props.height || props.maxHeight || store.states.fixedColumns.value.length > 0 || store.states.rightFixedColumns.value.length > 0; 3536 }); 3537 const tableBodyStyles = computed(() => { 3538 return { 3539 width: layout.bodyWidth.value ? `${layout.bodyWidth.value}px` : "" 3540 }; 3541 }); 3542 const doLayout = () => { 3543 if (shouldUpdateHeight.value) { 3544 layout.updateElsHeight(); 3545 } 3546 layout.updateColumnsWidth(); 3547 if (typeof window === "undefined") 3548 return; 3549 requestAnimationFrame(syncPosition); 3550 }; 3551 onMounted(async () => { 3552 await nextTick(); 3553 store.updateColumns(); 3554 bindEvents(); 3555 requestAnimationFrame(doLayout); 3556 const el = table.vnode.el; 3557 const tableHeader = table.refs.headerWrapper; 3558 if (props.flexible && el && el.parentElement) { 3559 el.parentElement.style.minWidth = "0"; 3560 } 3561 resizeState.value = { 3562 width: tableWidth.value = el.offsetWidth, 3563 height: el.offsetHeight, 3564 headerHeight: props.showHeader && tableHeader ? tableHeader.offsetHeight : null 3565 }; 3566 store.states.columns.value.forEach((column) => { 3567 if (column.filteredValue && column.filteredValue.length) { 3568 table.store.commit("filterChange", { 3569 column, 3570 values: column.filteredValue, 3571 silent: true 3572 }); 3573 } 3574 }); 3575 table.$ready = true; 3576 }); 3577 const setScrollClassByEl = (el, className) => { 3578 if (!el) 3579 return; 3580 const classList = Array.from(el.classList).filter((item) => !item.startsWith("is-scrolling-")); 3581 classList.push(layout.scrollX.value ? className : "is-scrolling-none"); 3582 el.className = classList.join(" "); 3583 }; 3584 const setScrollClass = (className) => { 3585 const { tableWrapper }
3585 = table.refs; 3586 setScrollClassByEl(tableWrapper, className); 3587 }; 3588 const hasScrollClass = (className) => { 3589 const { tableWrapper } = table.refs; 3590 return !!(tableWrapper && tableWrapper.classList.contains(className)); 3591 }; 3592 const syncPosition = function() { 3593 if (!table.refs.scrollBarRef) 3594 return; 3595 if (!layout.scrollX.value) { 3596 const scrollingNoneClass = "is-scrolling-none"; 3597 if (!hasScrollClass(scrollingNoneClass)) { 3598 setScrollClass(scrollingNoneClass); 3599 } 3600 return; 3601 } 3602 const scrollContainer = table.refs.scrollBarRef.wrapRef; 3603 if (!scrollContainer) 3604 return; 3605 const { scrollLeft, offsetWidth, scrollWidth } = scrollContainer; 3606 const { headerWrapper, footerWrapper } = table.refs; 3607 if (headerWrapper) 3608 headerWrapper.scrollLeft = scrollLeft; 3609 if (footerWrapper) 3610 footerWrapper.scrollLeft = scrollLeft; 3611 const maxScrollLeftPosition = scrollWidth - offsetWidth - 1; 3612 if (scrollLeft >= maxScrollLeftPosition) { 3613 setScrollClass("is-scrolling-right"); 3614 } else if (scrollLeft === 0) { 3615 setScrollClass("is-scrolling-left"); 3616 } else { 3617 setScrollClass("is-scrolling-middle"); 3618 } 3619 }; 3620 const bindEvents = () => { 3621 if (!table.refs.scrollBarRef) 3622 return; 3623 if (table.refs.scrollBarRef.wrapRef) { 3624 useEventListener(table.refs.scrollBarRef.wrapRef, "scroll", syncPosition, { 3625 passive: true 3626 }); 3627 } 3628 if (props.fit) { 3629 useResizeObserver(table.vnode.el, resizeListener); 3630 } else { 3631 useEventListener(window, "resize", resizeListener); 3632 } 3633 useResizeObserver(table.refs.bodyWrapper, () => { 3634 var _a, _b; 3635 resizeListener(); 3636 (_b = (_a = table.refs) == null ? void 0 : _a.scrollBarRef) == null ? void 0 : _b.update(); 3637 }); 3638 }; 3639 const resizeListener = () => { 3640 var _a, _b, _c, _d; 3641 const el = table.vnode.el; 3642 if (!table.$ready || !el) 3643 return; 3644 let shouldUpdateLayout = false; 3645 const { 3646 width: oldWidth, 3647 height: oldHeight, 3648 headerHeight: oldHeaderHeight 3649 } = resizeState.value; 3650 const width = tableWidth.value = el.offsetWidth; 3651 if (oldWidth !== width) { 3652 shouldUpdateLayout = true; 3653 } 3654 const height = el.offsetHeight; 3655 if ((props.height || shouldUpdateHeight.value) && oldHeight !== height) { 3656 shouldUpdateLayout = true; 3657 } 3658 const tableHeader = props.tableLayout === "fixed" ? table.refs.headerWrapper : (_a = table.refs.tableHeaderRef) == null ? void 0 : _a.$el; 3659 if (props.showHeader && (tableHeader == null ? void 0 : tableHeader.offsetHeight) !== oldHeaderHeight) { 3660 shouldUpdateLayout = true; 3661 } 3662 tableScrollHeight.value = ((_b = table.refs.tableWrapper) == null ? void 0 : _b.scrollHeight) || 0; 3663 headerScrollHeight.value = (tableHeader == null ? void 0 : tableHeader.scrollHeight) || 0; 3664 footerScrollHeight.value = ((_c = table.refs.footerWrapper) == null ? void 0 : _c.offsetHeight) || 0; 3665 appendScrollHeight.value = ((_d = table.refs.appendWrapper) == null ? void 0 : _d.offsetHeight) || 0; 3666 bodyScrollHeight.value = tableScrollHeight.value - headerScrollHeight.value - footerScrollHeight.value - appendScrollHeight.value; 3667 if (shouldUpdateLayout) { 3668 resizeState.value = { 3669 width, 3670 height, 3671 headerHeight: props.showHeader && (tableHeader == null ? void 0 : tableHeader.offsetHeight) || 0 3672 }; 3673 doLayout(); 3674 } 3675 }; 3676 const tableSize = useFormSize(); 3677 const bodyWidth = computed(() => { 3678 const { bodyWidth: bodyWidth_, scrollY, gutterWidth } = layout; 3679 return bodyWidth_.value ? `${bodyWidth_.value - (scrollY.value ? gutterWidth : 0)}px` : ""; 3680 }); 3681 const tableLayout = computed(() => { 3682 if (props.maxHeight) 3683 return "fixed"; 3684 return props.tableLayout; 3685 }); 3686 const emptyBlockStyle = computed(() => { 3687 if (props.data && props.data.length) 3688 return; 3689 let height = "100%"; 3690 if (props.height && bodyScrollHeight.value) { 3691 height = `${bodyScrollHeight.value}px`; 3692 } 3693 const width = tableWidth.value; 3694 return { 3695 width: width ? `${width}px` : "", 3696 height 3697 }; 3698 }); 3699 const scrollbarStyle = computed(() => { 3700 if (props.height) { 3701 return { 3702 height: "100%" 3703 }; 3704 } 3705 if (props.maxHeight) { 3706 if (!Number.isNaN(Number(props.maxHeight))) { 3707 return { 3708 maxHeight: `${+props.maxHeight - headerScrollHeight.value - footerScrollHeight.value}px` 3709 }; 3710 } else { 3711 return { 3712 maxHeight: `calc(${props.maxHeight} - ${headerScrollHeight.value + footerScrollHeight.value}px)` 3713 }; 3714 } 3715 } 3716 return {}; 3717 }); 3718 return { 3719 isHidden, 3720 renderExpanded, 3721 setDragVisible, 3722 isGroup, 3723 handleMouseLeave, 3724 handleHeaderFooterMousewheel, 3725 tableSize, 3726 emptyBlockStyle, 3727 resizeProxyVisible, 3728 bodyWidth, 3729 resizeState, 3730 doLayout, 3731 tableBodyStyles, 3732 tableLayout, 3733 scrollbarViewStyle, 3734 scrollbarStyle 3735 }; 3736} 3737function useKeyRender(table) { 3738 const observer = ref(); 3739 const initWatchDom = () => { 3740 const el = table.vnode.el; 3741 const columnsWrapper = el.querySelector(".hidden-columns"); 3742 const config = { childList: true, subtree: true }; 3743 const updateOrderFns = table.store.states.updateOrderFns; 3744 observer.value = new MutationObserver(() => { 3745 updateOrderFns.forEach((fn) => fn()); 3746 }); 3747 observer.value.observe(columnsWrapper, config); 3748 }; 3749 onMounted(() => { 3750 initWatchDom(); 3751 }); 3752 onUnmounted(() => { 3753 var _a; 3754 (_a = observer.value) == null ? void 0 : _a.disconnect(); 3755 }); 3756} 3757var defaultProps$1 = { 3758 data: { 3759 type: Array, 3760 default: () => [] 3761 }, 3762 size: useSizeProp, 3763 width: [String, Number], 3764 height: [String, Number], 3765 maxHeight: [String, Number], 3766 fit: { 3767 type: Boolean, 3768 default: true 3769 }, 3770 stripe: Boolean, 3771 border: Boolean, 3772 rowKey: [String, Function], 3773 showHeader: { 3774 type: Boolean, 3775 default: true 3776 }, 3777 showSummary: Boolean, 3778 sumText: String, 3779 summaryMethod: Function, 3780 rowClassName: [String, Function], 3781 rowStyle: [Object, Function], 3782 cellClassName: [String, Function], 3783 cellStyle: [Object, Function], 3784 headerRowClassName: [String, Function], 3785 headerRowStyle: [Object, Function], 3786 headerCellClassName: [String, Function], 3787 headerCellStyle: [Object, Function], 3788 highlightCurrentRow: Boolean,
3789 currentRowKey: [String, Number], 3790 emptyText: String, 3791 expandRowKeys: Array, 3792 defaultExpandAll: Boolean, 3793 defaultSort: Object, 3794 tooltipEffect: String, 3795 tooltipOptions: Object, 3796 spanMethod: Function, 3797 selectOnIndeterminate: { 3798 type: Boolean, 3799 default: true 3800 }, 3801 indent: { 3802 type: Number, 3803 default: 16 3804 }, 3805 treeProps: { 3806 type: Object, 3807 default: () => { 3808 return { 3809 hasChildren: "hasChildren", 3810 children: "children", 3811 checkStrictly: false 3812 }; 3813 } 3814 }, 3815 lazy: Boolean, 3816 load: Function, 3817 style: { 3818 type: Object, 3819 default: () => ({}) 3820 }, 3821 className: { 3822 type: String, 3823 default: "" 3824 }, 3825 tableLayout: { 3826 type: String, 3827 default: "fixed" 3828 }, 3829 scrollbarAlwaysOn: Boolean, 3830 flexible: Boolean, 3831 showOverflowTooltip: [Boolean, Object], 3832 tooltipFormatter: Function, 3833 appendFilterPanelTo: String, 3834 scrollbarTabindex: { 3835 type: [Number, String], 3836 default: void 0 3837 }, 3838 allowDragLastColumn: { 3839 type: Boolean, 3840 default: true 3841 }, 3842 preserveExpandedContent: Boolean, 3843 nativeScrollbar: Boolean 3844}; 3845function hColgroup(props) { 3846 const isAuto = props.tableLayout === "auto"; 3847 let columns = props.columns || []; 3848 if (isAuto) { 3849 if (columns.every(({ width }) => isUndefined(width))) { 3850 columns = []; 3851 } 3852 } 3853 const getPropsData = (column) => { 3854 const propsData = { 3855 key: `${props.tableLayout}_${column.id}`, 3856 style: {}, 3857 name: void 0 3858 }; 3859 if (isAuto) { 3860 propsData.style = { 3861 width: `${column.width}px` 3862 }; 3863 } else { 3864 propsData.name = column.id; 3865 } 3866 return propsData; 3867 }; 3868 return h$1("colgroup", {}, columns.map((column) => h$1("col", getPropsData(column)))); 3869} 3870hColgroup.props = ["columns", "tableLayout"]; 3871const useScrollbar = () => { 3872 const scrollBarRef = ref(); 3873 const scrollTo = (options, yCoord) => { 3874 const scrollbar = scrollBarRef.value; 3875 if (scrollbar) { 3876 scrollbar.scrollTo(options, yCoord); 3877 } 3878 }; 3879 const setScrollPosition = (position, offset) => { 3880 const scrollbar = scrollBarRef.value; 3881 if (scrollbar && isNumber(offset) && ["Top", "Left"].includes(position)) { 3882 scrollbar[`setScroll${position}`](offset); 3883 } 3884 }; 3885 const setScrollTop = (top) => setScrollPosition("Top", top); 3886 const setScrollLeft = (left) => setScrollPosition("Left", left); 3887 return { 3888 scrollBarRef, 3889 scrollTo, 3890 setScrollTop, 3891 setScrollLeft 3892 }; 3893}; 3894var v = false, o, f, s, u, d, N, l, p, m, w, D, x, E, M, F; 3895function a() { 3896 if (!v) { 3897 v = true; 3898 var e = navigator.userAgent, n = /(?:MSIE.(\d+\.\d+))|(?:(?:Firefox|GranParadiso|Ice
3898weasel).(\d+\.\d+))|(?:Opera(?:.+Version.|.)(\d+\.\d+))|(?:AppleWebKit.(\d+(?:\.\d+)?))|(?:Trident\/\d+\.\d+.*rv:(\d+\.\d+))/.exec(e), i = /(Mac OS X)|(Windows)|(Linux)/.exec(e); 3899 if (x = /\b(iPhone|iP[ao]d)/.exec(e), E = /\b(iP[ao]d)/.exec(e), w = /Android/i.exec(e), M = /FBAN\/\w+;/i.exec(e), F = /Mobile/i.exec(e), D = !!/Win64/.exec(e), n) { 3900 o = n[1] ? parseFloat(n[1]) : n[5] ? parseFloat(n[5]) : NaN, o && document && document.documentMode && (o = document.documentMode); 3901 var r = /(?:Trident\/(\d+.\d+))/.exec(e); 3902 N = r ? parseFloat(r[1]) + 4 : o, f = n[2] ? parseFloat(n[2]) : NaN, s = n[3] ? parseFloat(n[3]) : NaN, u = n[4] ? parseFloat(n[4]) : NaN, u ? (n = /(?:Chrome\/(\d+\.\d+))/.exec(e), d = n && n[1] ? parseFloat(n[1]) : NaN) : d = NaN; 3903 } else 3904 o = f = s = d = u = NaN; 3905 if (i) { 3906 if (i[1]) { 3907 var t = /(?:Mac OS X (\d+(?:[._]\d+)?))/.exec(e); 3908 l = t ? parseFloat(t[1].replace("_", ".")) : true; 3909 } else 3910 l = false; 3911 p = !!i[2], m = !!i[3]; 3912 } else 3913 l = p = m = false; 3914 } 3915} 3916var _ = { ie: function() { 3917 return a() || o; 3918}, ieCompatibilityMode: function() { 3919 return a() || N > o; 3920}, ie64: function() { 3921 return _.ie() && D; 3922}, firefox: function() { 3923 return a() || f; 3924}, opera: function() { 3925 return a() || s; 3926}, webkit: function() { 3927 return a() || u; 3928}, safari: function() { 3929 return _.webkit(); 3930}, chrome: function() { 3931 return a() || d; 3932}, windows: function() { 3933 return a() || p; 3934}, osx: function() { 3935 return a() || l; 3936}, linux: function() { 3937 return a() || m; 3938}, iphone: function() { 3939 return a() || x; 3940}, mobile: function() { 3941 return a() || x || E || w || F; 3942}, nativeApp: function() { 3943 return a() || M; 3944}, android: function() { 3945 return a() || w; 3946}, ipad: function() { 3947 return a() || E; 3948} }, A = _; 3949var c = !!(typeof window < "u" && window.document && window.document.createElement), U = { canUseDOM: c }, h = U; 3950var X; 3951h.canUseDOM && (X = document.implementation && document.implementation.hasFeature && document.implementation.hasFeature("", "") !== true); 3952function S(e, n) { 3953 if (!h.canUseDOM || n && !("addEventListener" in document)) 3954 return false; 3955 var i = "on" + e, r = i in document; 3956 if (!r) { 3957 var t = document.createElement("div"); 3958 t.setAttribute(i, "return;"), r = typeof t[i] == "function"; 3959 } 3960 return !r && X && e === "wheel" && (r = document.implementation.hasFeature("Events.wheel", "3.0")), r; 3961} 3962var b = S; 3963var O = 10, I = 40, P = 800; 3964function T(e) { 3965 var n = 0, i = 0, r = 0, t = 0; 3966 return "detail" in e && (i = e.detail), "wheelDelta" in e && (i = -e.wheelDelta / 120), "wheelDeltaY" in e && (i = -e.wheelDeltaY / 120), "wheelDeltaX" in e && (n = -e.wheelDeltaX / 120), "axis" in e && e.axis === e.HORIZONTAL_AXIS && (n = i, i = 0), r = n * O, t = i * O, "deltaY" in e && (t = e.deltaY), "deltaX" in e && (r = e.deltaX), (r || t) && e.deltaMode && (e.deltaMode == 1 ? (r *= I, t *= I) : (r *= P, t *= P)), r && !n && (n = r < 1 ? -1 : 1), t && !i && (i = t < 1 ? -1 : 1), { spinX: n, spinY: i, pixelX: r, pixelY: t }; 3967} 3968T.getEventType = function() { 3969 return A.firefox() ? "DOMMouseScroll" : b("wheel") ? "wheel" : "mousewheel"; 3970}; 3971var Y = T; 3972/** 3973* Checks if an event is supported in the current execution environment. 3974* 3975* NOTE: This will not work correctly for non-generic events such as `change`, 3976* `reset`, `load`, `error`, and `select`. 3977* 3978* Borrows from Modernizr. 3979* 3980* @param {string} eventNameSuffix Event name, e.g. "click". 3981* @param {?boolean} capture Check if the capture phase is supported. 3982* @return {boolean} True if the event is supported. 3983* @internal 3984* @license Modernizr 3.0.0pre (Custom Build) | MIT 3985*/ 3986const mousewheel = function(element, callback) { 3987 if (element && element.addEventListener) { 3988 const fn = function(event) { 3989 const normalized = Y(event); 3990 callback && Reflect.apply(callback, this, [event, normalized]); 3991 }; 3992 element.addEventListener("wheel", fn, { passive: true }); 3993 } 3994}; 3995const Mousewheel = { 3996 beforeMount(el, binding) { 3997 mousewheel(el, binding.value); 3998 } 3999}; 4000let tableIdSeed = 1;
4001const _sfc_main = defineComponent({ 4002 name: "ElTable", 4003 directives: { 4004 Mousewheel 4005 }, 4006 components: { 4007 TableHeader, 4008 TableBody, 4009 TableFooter, 4010 ElScrollbar, 4011 hColgroup 4012 }, 4013 props: defaultProps$1, 4014 emits: [ 4015 "select", 4016 "select-all", 4017 "selection-change", 4018 "cell-mouse-enter", 4019 "cell-mouse-leave", 4020 "cell-contextmenu", 4021 "cell-click", 4022 "cell-dblclick", 4023 "row-click", 4024 "row-contextmenu", 4025 "row-dblclick", 4026 "header-click", 4027 "header-contextmenu", 4028 "sort-change", 4029 "filter-change", 4030 "current-change", 4031 "header-dragend", 4032 "expand-change", 4033 "scroll" 4034 ], 4035 setup(props) { 4036 const { t } = useLocale(); 4037 const ns = useNamespace("table"); 4038 const table = getCurrentInstance(); 4039 provide(TABLE_INJECTION_KEY, table); 4040 const store = createStore(table, props); 4041 table.store = store; 4042 const layout = new TableLayout({ 4043 store: table.store, 4044 table, 4045 fit: props.fit, 4046 showHeader: props.showHeader 4047 }); 4048 table.layout = layout; 4049 const isEmpty = computed(() => (store.states.data.value || []).length === 0); 4050 const { 4051 setCurrentRow, 4052 getSelectionRows, 4053 toggleRowSelection, 4054 clearSelection, 4055 clearFilter, 4056 toggleAllSelection, 4057 toggleRowExpansion, 4058 clearSort, 4059 sort, 4060 updateKeyChildren 4061 } = useUtils(store); 4062 const { 4063 isHidden, 4064 renderExpanded, 4065 setDragVisible, 4066 isGroup, 4067 handleMouseLeave, 4068 handleHeaderFooterMousewheel, 4069 tableSize, 4070 emptyBlockStyle, 4071 resizeProxyVisible, 4072 bodyWidth, 4073 resizeState, 4074 doLayout, 4075 tableBodyStyles, 4076 tableLayout, 4077 scrollbarViewStyle, 4078 scrollbarStyle 4079 } = useStyle(props, layout, store, table); 4080 const { scrollBarRef, scrollTo, setScrollLeft, setScrollTop } = useScrollbar(); 4081 const debouncedUpdateLayout = debounce(doLayout, 50); 4082 const tableId = `${ns.namespace.value}-table_${tableIdSeed++}`; 4083 table.tableId = tableId; 4084 table.state = { 4085 isGroup, 4086 resizeState, 4087 doLayout, 4088 debouncedUpdateLayout 4089 }; 4090 const computedSumText = computed(() => { 4091 var _a; 4092 return (_a = props.sumText) != null ? _a : t("el.table.sumText"); 4093 }); 4094 const computedEmptyText = computed(() => { 4095 var _a; 4096 return (_a = props.emptyText) != null ? _a : t("el.table.emptyText"); 4097 }); 4098 const columns = computed(() => { 4099 return convertToRows(store.states.originColumns.value)[0]; 4100 }); 4101 useKeyRender(table); 4102 onBeforeUnmount(() => { 4103 debouncedUpdateLayout.cancel(); 4104 }); 4105 return { 4106 ns, 4107 layout, 4108 store, 4109 columns, 4110 handleHeaderFooterMousewheel, 4111 handleMouseLeave, 4112 tableId, 4113 tableSize, 4114 isHidden, 4115 isEmpty, 4116 renderExpanded, 4117 resizeProxyVisible, 4118 resizeState, 4119 isGroup, 4120 bodyWidth, 4121 tableBodyStyles, 4122 emptyBlockStyle, 4123 debouncedUpdateLayout, 4124 setCurrentRow, 4125 getSelectionRows, 4126 toggleRowSelection, 4127 clearSelection, 4128 clearFilter, 4129 toggleAllSelection, 4130 toggleRowExpansion, 4131 clearSort, 4132 doLayout, 4133 sort, 4134 updateKeyChildren, 4135 t, 4136 setDragVisible, 4137 context: table, 4138 computedSumText, 4139 computedEmptyText, 4140 tableLayout, 4141 scrollbarViewStyle, 4142 scrollbarStyle, 4143 scrollBarRef, 4144 scrollTo, 4145 setScrollLeft, 4146 setScrollTop, 4147 allowDragLastColumn: props.allowDragLastColumn 4148 }; 4149 } 4150}); 4151function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { 4152 const _component_hColgroup = resolveComponent("hColgroup"); 4153 const _component_table_header = resolveComponent("table-header"); 4154 const _component_table_body = resolveComponent("table-body"); 4155 const _component_table_footer = resolveComponent("table-footer"); 4156 const _component_el_scrollbar = resolveComponent("el-scrollbar"); 4157 const _directive_mousewheel = resolveDirective("mousewheel"); 4158 return openBlock(), createElementBlock("div", { 4159 ref: "tableWrapper", 4160 class: normalizeClass([ 4161 { 4162 [_ctx.ns.m("fit")]: _ctx.fit, 4163 [_ctx.ns.m("striped")]: _ctx.stripe, 4164 [_ctx.ns.m("border")]: _ctx.border || _ctx.isGroup, 4165 [_ctx.ns.m("hidden")]: _ctx.isHidden, 4166 [_ctx.ns.m("group")]: _ctx.isGroup, 4167 [_ctx.ns.m("fluid-height")]: _ctx.maxHeight, 4168 [_ctx.ns.m("scrollable-x")]: _ctx.layout.scrollX.value, 4169 [_ctx.ns.m("scrollable-y")]: _ctx.layout.scrollY.value, 4170 [_ctx.ns.m("enable-row-hover")]: !_ctx.store.states.isComplex.value, 4171 [_ctx.ns.m("enable-row-transition")]: (_ctx.store.states.data.value || []).length !== 0 && (_ctx.store.states.data.value || []).length < 100, 4172 "has-footer": _ctx.showSummary 4173 }, 4174 _ctx.ns.m(_ctx.tableSize), 4175 _ctx.className, 4176 _ctx.ns.b(), 4177 _ctx.ns.m(`layout-${_ctx.tableLayout}`) 4178 ]), 4179 style: normalizeStyle(_ctx.style), 4180 "data-prefix": _ctx.ns.namespace.value, 4181 onMouseleave: _ctx.handleMouseLeave 4182 }, [ 4183 createBaseVNode("div", { 4184 class: normalizeClass(_ctx.ns.e("inner-wrapper")) 4185 }, [ 4186 createBaseVNode("div", { 4187 ref: "hiddenColumns", 4188 class: "hidden-columns" 4189 }, [ 4190 renderSlot(_ctx.$slots, "default") 4191 ], 512), 4192 _ctx.showHeader && _ctx.tableLayout === "fixed" ? withDirectives((openBlock(), createElementBlock("div", { 4193 key: 0, 4194 ref: "headerWrapper", 4195 class: normalizeClass(_ctx.ns.e("header-wrapper")) 4196 }, [ 4197 createBaseVNode("table", { 4198 ref: "tableHeader", 4199 class: normalizeClass(_ctx.ns.e("header")), 4200 style: normalizeStyle(_ctx.tableBodyStyles), 4201 border: "0", 4202 cellpadding: "0", 4203 cellspacing: "0" 4204 }, [ 4205 createVNode(_component_hColgroup, { 4206 columns: _ctx.store.states.columns.value, 4207 "table-layout": _ctx.tableLayout 4208 }, null, 8, ["columns", "table-layout"]), 4209 createVNode(_component_table_header, { 4210 ref: "tableHeaderRef", 4211 border: _ctx.border, 4212 "default-sort": _ctx.defaultSort, 4213 store: _ctx.store, 4214 "append-filter-panel-to": _ctx.appendFilterPanelTo, 4215 "allow-drag-last-column": _ctx.allowDragLastColumn, 4216 onSetDragVisible: _ctx.setDragVisible 4217 }, null, 8, ["border", "default-sort", "store", "append-filter-panel-to", "allow-drag-last-column", "onSetDragVisible"])
4218 ], 6) 4219 ], 2)), [ 4220 [_directive_mousewheel, _ctx.handleHeaderFooterMousewheel] 4221 ]) : createCommentVNode("v-if", true), 4222 createBaseVNode("div", { 4223 ref: "bodyWrapper", 4224 class: normalizeClass(_ctx.ns.e("body-wrapper")) 4225 }, [ 4226 createVNode(_component_el_scrollbar, { 4227 ref: "scrollBarRef", 4228 "view-style": _ctx.scrollbarViewStyle, 4229 "wrap-style": _ctx.scrollbarStyle, 4230 always: _ctx.scrollbarAlwaysOn, 4231 tabindex: _ctx.scrollbarTabindex, 4232 native: _ctx.nativeScrollbar, 4233 onScroll: ($event) => _ctx.$emit("scroll", $event) 4234 }, { 4235 default: withCtx(() => [ 4236 createBaseVNode("table", { 4237 ref: "tableBody", 4238 class: normalizeClass(_ctx.ns.e("body")), 4239 cellspacing: "0", 4240 cellpadding: "0", 4241 border: "0", 4242 style: normalizeStyle({ 4243 width: _ctx.bodyWidth, 4244 tableLayout: _ctx.tableLayout 4245 }) 4246 }, [ 4247 createVNode(_component_hColgroup, { 4248 columns: _ctx.store.states.columns.value, 4249 "table-layout": _ctx.tableLayout 4250 }, null, 8, ["columns", "table-layout"]), 4251 _ctx.showHeader && _ctx.tableLayout === "auto" ? (openBlock(), createBlock(_component_table_header, { 4252 key: 0, 4253 ref: "tableHeaderRef", 4254 class: normalizeClass(_ctx.ns.e("body-header")), 4255 border: _ctx.border, 4256 "default-sort": _ctx.defaultSort, 4257 store: _ctx.store, 4258 "append-filter-panel-to": _ctx.appendFilterPanelTo, 4259 onSetDragVisible: _ctx.setDragVisible 4260 }, null, 8, ["class", "border", "default-sort", "store", "append-filter-panel-to", "onSetDragVisible"])) : createCommentVNode("v-if", true), 4261 createVNode(_component_table_body, { 4262 context: _ctx.context, 4263 highlight: _ctx.highlightCurrentRow, 4264 "row-class-name": _ctx.rowClassName, 4265 "tooltip-effect": _ctx.tooltipEffect, 4266 "tooltip-options": _ctx.tooltipOptions, 4267 "row-style": _ctx.rowStyle, 4268 store: _ctx.store, 4269 stripe: _ctx.stripe 4270 }, null, 8, ["context", "highlight", "row-class-name", "tooltip-effect", "tooltip-options", "row-style", "store", "stripe"]), 4271 _ctx.showSummary && _ctx.tableLayout === "auto" ? (openBlock(), createBlock(_component_table_footer, { 4272 key: 1, 4273 class: normalizeClass(_ctx.ns.e("body-footer")), 4274 border: _ctx.border, 4275 "default-sort": _ctx.defaultSort, 4276 store: _ctx.store, 4277 "sum-text": _ctx.computedSumText, 4278 "summary-method": _ctx.summaryMethod 4279 }, null, 8, ["class", "border", "default-sort", "store", "sum-text", "summary-method"])) : createCommentVNode("v-if", true) 4280 ], 6), 4281 _ctx.isEmpty ? (openBlock(), createElementBlock("div", { 4282 key: 0, 4283 ref: "emptyBlock", 4284 style: normalizeStyle(_ctx.emptyBlockStyle), 4285 class: normalizeClass(_ctx.ns.e("empty-block")) 4286 }, [ 4287 createBaseVNode("span", { 4288 class: normalizeClass(_ctx.ns.e("empty-text")) 4289 }, [ 4290 renderSlot(_ctx.$slots, "empty", {}, () => [ 4291 createTextVNode(toDisplayString(_ctx.computedEmptyText), 1) 4292 ]) 4293 ], 2) 4294 ], 6)) : createCommentVNode("v-if", true), 4295 _ctx.$slots.append ? (openBlock(), createElementBlock("div", { 4296 key: 1, 4297 ref: "appendWrapper", 4298 class: normalizeClass(_ctx.ns.e("append-wrapper")) 4299 }, [ 4300 renderSlot(_ctx.$slots, "append") 4301 ], 2)) : createCommentVNode("v-if", true) 4302 ]), 4303 _: 3 4304 }, 8, ["view-style", "wrap-style", "always", "tabindex", "native", "onScroll"]) 4305 ], 2), 4306 _ctx.showSummary && _ctx.tableLayout === "fixed" ? withDirectives((openBlock(), createElementBlock("div", { 4307 key: 1, 4308 ref: "footerWrapper", 4309 class: normalizeClass(_ctx.ns.e("footer-wrapper")) 4310 }, [ 4311 createBaseVNode("table", { 4312 class: normalizeClass(_ctx.ns.e("footer")), 4313 cellspacing: "0", 4314 cellpadding: "0", 4315 border: "0", 4316 style: normalizeStyle(_ctx.tableBodyStyles) 4317 }, [ 4318 createVNode(_component_hColgroup, { 4319 columns: _ctx.store.states.columns.value, 4320 "table-layout": _ctx.tableLayout 4321 }, null, 8, ["columns", "table-layout"]), 4322 createVNode(_component_table_footer, { 4323 border: _ctx.border, 4324 "default-sort": _ctx.defaultSort, 4325 store: _ctx.store, 4326 "sum-text": _ctx.computedSumText, 4327 "summary-method": _ctx.summaryMethod 4328 }, null, 8, ["border", "default-sort", "store", "sum-text", "summary-method"])
4329 ], 6) 4330 ], 2)), [ 4331 [vShow, !_ctx.isEmpty], 4332 [_directive_mousewheel, _ctx.handleHeaderFooterMousewheel] 4333 ]) : createCommentVNode("v-if", true), 4334 _ctx.border || _ctx.isGroup ? (openBlock(), createElementBlock("div", { 4335 key: 2, 4336 class: normalizeClass(_ctx.ns.e("border-left-patch")) 4337 }, null, 2)) : createCommentVNode("v-if", true) 4338 ], 2), 4339 withDirectives(createBaseVNode("div", { 4340 ref: "resizeProxy", 4341 class: normalizeClass(_ctx.ns.e("column-resize-proxy")) 4342 }, null, 2), [ 4343 [vShow, _ctx.resizeProxyVisible] 4344 ]) 4345 ], 46, ["data-prefix", "onMouseleave"]); 4346} 4347var Table = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render], ["__file", "table.vue"]]); 4348const defaultClassNames = { 4349 selection: "table-column--selection", 4350 expand: "table__expand-column" 4351}; 4352const cellStarts = { 4353 default: { 4354 order: "" 4355 }, 4356 selection: { 4357 width: 48, 4358 minWidth: 48, 4359 realWidth: 48, 4360 order: "" 4361 }, 4362 expand: { 4363 width: 48, 4364 minWidth: 48, 4365 realWidth: 48, 4366 order: "" 4367 }, 4368 index: { 4369 width: 48, 4370 minWidth: 48, 4371 realWidth: 48, 4372 order: "" 4373 } 4374}; 4375const getDefaultClassName = (type) => { 4376 return defaultClassNames[type] || ""; 4377}; 4378const cellForced = { 4379 selection: { 4380 renderHeader({ 4381 store, 4382 column 4383 }) { 4384 var _a; 4385 function isDisabled() { 4386 return store.states.data.value && store.states.data.value.length === 0; 4387 } 4388 return h$1(ElCheckbox, { 4389 disabled: isDisabled(), 4390 size: store.states.tableSize.value, 4391 indeterminate: store.states.selection.value.length > 0 && !store.states.isAllSelected.value, 4392 "onUpdate:modelValue": (_a = store.toggleAllSelection) != null ? _a : void 0, 4393 modelValue: store.states.isAllSelected.value, 4394 ariaLabel: column.label 4395 }); 4396 }, 4397 renderCell({ 4398 row, 4399 column, 4400 store, 4401 $index 4402 }) { 4403 return h$1(ElCheckbox, { 4404 disabled: column.selectable ? !column.selectable.call(null, row, $index) : false, 4405 size: store.states.tableSize.value, 4406 onChange: () => { 4407 store.commit("rowSelectedChanged", row); 4408 }, 4409 onClick: (event) => event.stopPropagation(), 4410 modelValue: store.isSelected(row), 4411 ariaLabel: column.label 4412 }); 4413 }, 4414 sortable: false, 4415 resizable: false 4416 }, 4417 index: { 4418 renderHeader({ 4419 column 4420 }) { 4421 return column.label || "#"; 4422 }, 4423 renderCell({ 4424 column, 4425 $index 4426 }) { 4427 let i = $index + 1; 4428 const index = column.index; 4429 if (isNumber(index)) { 4430 i = $index + index; 4431 } else if (isFunction$1(index)) { 4432 i = index($index); 4433 } 4434 return h$1("div", {}, [i]); 4435 }, 4436 sortable: false 4437 }, 4438 expand: { 4439 renderHeader({ 4440 column 4441 }) { 4442 return column.label || ""; 4443 }, 4444 renderCell({ 4445 column, 4446 row, 4447 store, 4448 expanded 4449 }) { 4450 const { ns } = store; 4451 const classes = [ns.e("expand-icon")]; 4452 if (!column.renderExpand && expanded) { 4453 classes.push(ns.em("expand-icon", "expanded")); 4454 } 4455 const callback = function(e) { 4456 e.stopPropagation(); 4457 store.toggleRowExpansion(row); 4458 }; 4459 return h$1("div", { 4460 class: classes, 4461 onClick: callback 4462 }, { 4463 default: () => { 4464 if (column.renderExpand) { 4465 return [ 4466 column.renderExpand({ 4467 expanded 4468 }) 4469 ]; 4470 } 4471 return [ 4472 h$1(ElIcon, null, { 4473 default: () => { 4474 return [h$1(arrow_right_default)]; 4475 } 4476 }) 4477 ]; 4478 } 4479 }); 4480 }, 4481 sortable: false, 4482 resizable: false 4483 } 4484}; 4485function defaultRenderCell({ 4486 row, 4487 column, 4488 $index 4489}) { 4490 var _a; 4491 const property = column.property; 4492 const value = property && getProp(row, property).value; 4493 if (column && column.formatter) { 4494 return column.formatter(row, column, value, $index); 4495 } 4496 return ((_a = value == null ? void 0 : value.toString) == null ? void 0 : _a.call(value)) || ""; 4497}
4498function treeCellPrefix({ 4499 row, 4500 treeNode, 4501 store 4502}, createPlaceholder = false) { 4503 const { ns } = store; 4504 if (!treeNode) { 4505 if (createPlaceholder) { 4506 return [ 4507 h$1("span", { 4508 class: ns.e("placeholder") 4509 }) 4510 ]; 4511 } 4512 return null; 4513 } 4514 const ele = []; 4515 const callback = function(e) { 4516 e.stopPropagation(); 4517 if (treeNode.loading) { 4518 return; 4519 } 4520 store.loadOrToggle(row); 4521 }; 4522 if (treeNode.indent) { 4523 ele.push(h$1("span", { 4524 class: ns.e("indent"), 4525 style: { "padding-left": `${treeNode.indent}px` } 4526 })); 4527 } 4528 if (isBoolean(treeNode.expanded) && !treeNode.noLazyChildren) { 4529 const expandClasses = [ 4530 ns.e("expand-icon"), 4531 treeNode.expanded ? ns.em("expand-icon", "expanded") : "" 4532 ]; 4533 let icon = arrow_right_default; 4534 if (treeNode.loading) { 4535 icon = loading_default; 4536 } 4537 ele.push(h$1("div", { 4538 class: expandClasses, 4539 onClick: callback 4540 }, { 4541 default: () => { 4542 return [ 4543 h$1(ElIcon, { class: { [ns.is("loading")]: treeNode.loading } }, { 4544 default: () => [h$1(icon)] 4545 }) 4546 ]; 4547 } 4548 })); 4549 } else { 4550 ele.push(h$1("span", { 4551 class: ns.e("placeholder") 4552 })); 4553 } 4554 return ele; 4555} 4556function getAllAliases(props, aliases) { 4557 return props.reduce((prev, cur) => { 4558 prev[cur] = cur; 4559 return prev; 4560 }, aliases); 4561} 4562function useWatcher(owner, props_) { 4563 const instance = getCurrentInstance(); 4564 const registerComplexWatchers = () => { 4565 const props = ["fixed"]; 4566 const aliases = { 4567 realWidth: "width", 4568 realMinWidth: "minWidth" 4569 }; 4570 const allAliases = getAllAliases(props, aliases); 4571 Object.keys(allAliases).forEach((key) => { 4572 const columnKey = aliases[key]; 4573 if (hasOwn(props_, columnKey)) { 4574 watch(() => props_[columnKey], (newVal) => { 4575 let value = newVal; 4576 if (columnKey === "width" && key === "realWidth") { 4577 value = parseWidth(newVal); 4578 } 4579 if (columnKey === "minWidth" && key === "realMinWidth") { 4580 value = parseMinWidth(newVal); 4581 } 4582 instance.columnConfig.value[columnKey] = value; 4583 instance.columnConfig.value[key] = value; 4584 const updateColumns = columnKey === "fixed"; 4585 owner.value.store.scheduleLayout(updateColumns); 4586 }); 4587 } 4588 }); 4589 }; 4590 const registerNormalWatchers = () => { 4591 const props = [ 4592 "label", 4593 "filters", 4594 "filterMultiple", 4595 "filteredValue", 4596 "sortable", 4597 "index", 4598 "formatter", 4599 "className", 4600 "labelClassName", 4601 "filterClassName", 4602 "showOverflowTooltip", 4603 "tooltipFormatter" 4604 ]; 4605 const parentProps = ["showOverflowTooltip"]; 4606 const aliases = { 4607 property: "prop", 4608 align: "realAlign", 4609 headerAlign: "realHeaderAlign" 4610 }; 4611 const allAliases = getAllAliases(props, aliases); 4612 Object.keys(allAliases).forEach((key) => { 4613 const columnKey = aliases[key]; 4614 if (hasOwn(props_, columnKey)) { 4615 watch(() => props_[columnKey], (newVal) => { 4616 instance.columnConfig.value[key] = newVal; 4617 }); 4618 } 4619 }); 4620 parentProps.forEach((key) => { 4621 if (hasOwn(owner.value.props, key)) { 4622 watch(() => owner.value.props[key], (newVal) => { 4623 instance.columnConfig.value[key] = newVal; 4624 }); 4625 } 4626 }); 4627 }; 4628 return { 4629 registerComplexWatchers, 4630 registerNormalWatchers 4631 }; 4632} 4633function useRender(props, slots, owner) { 4634 const instance = getCurrentInstance(); 4635 const columnId = ref(""); 4636 const isSubColumn = ref(false); 4637 const realAlign = ref(); 4638 const realHeaderAlign = ref(); 4639 const ns = useNamespace("table"); 4640 watchEffect(() => { 4641 realAlign.value = props.align ? `is-${props.align}` : null; 4642 realAlign.value; 4643 }); 4644 watchEffect(() => { 4645 realHeaderAlign.value = props.headerAlign ? `is-${props.headerAlign}` : realAlign.value; 4646 realHeaderAlign.value; 4647 }); 4648 const columnOrTableParent = computed(() => { 4649 let parent = instance.vnode.vParent || instance.parent; 4650 while (parent && !parent.tableId && !parent.columnId) { 4651 parent = parent.vnode.vParent || parent.parent; 4652 } 4653 return parent; 4654 }); 4655 const hasTreeColumn = computed(() => { 4656 const { store } = instance.parent; 4657 if (!store) 4658 return false;
4659 const { treeData } = store.states; 4660 const treeDataValue = treeData.value; 4661 return treeDataValue && Object.keys(treeDataValue).length > 0; 4662 }); 4663 const realWidth = ref(parseWidth(props.width)); 4664 const realMinWidth = ref(parseMinWidth(props.minWidth)); 4665 const setColumnWidth = (column) => { 4666 if (realWidth.value) 4667 column.width = realWidth.value; 4668 if (realMinWidth.value) { 4669 column.minWidth = realMinWidth.value; 4670 } 4671 if (!realWidth.value && realMinWidth.value) { 4672 column.width = void 0; 4673 } 4674 if (!column.minWidth) { 4675 column.minWidth = 80; 4676 } 4677 column.realWidth = Number(isUndefined(column.width) ? column.minWidth : column.width); 4678 return column; 4679 }; 4680 const setColumnForcedProps = (column) => { 4681 const type = column.type; 4682 const source = cellForced[type] || {}; 4683 Object.keys(source).forEach((prop) => { 4684 const value = source[prop]; 4685 if (prop !== "className" && !isUndefined(value)) { 4686 column[prop] = value; 4687 } 4688 }); 4689 const className = getDefaultClassName(type); 4690 if (className) { 4691 const forceClass = `${unref(ns.namespace)}-${className}`; 4692 column.className = column.className ? `${column.className} ${forceClass}` : forceClass; 4693 } 4694 return column; 4695 }; 4696 const checkSubColumn = (children) => { 4697 if (isArray$1(children)) { 4698 children.forEach((child) => check(child)); 4699 } else { 4700 check(children); 4701 } 4702 function check(item) { 4703 var _a; 4704 if (((_a = item == null ? void 0 : item.type) == null ? void 0 : _a.name) === "ElTableColumn") { 4705 item.vParent = instance; 4706 } 4707 } 4708 }; 4709 const setColumnRenders = (column) => { 4710 if (props.renderHeader) 4711 ; 4712 else if (column.type !== "selection") { 4713 column.renderHeader = (scope) => { 4714 instance.columnConfig.value["label"]; 4715 return renderSlot(slots, "header", scope, () => [column.label]); 4716 }; 4717 } 4718 if (slots["filter-icon"]) { 4719 column.renderFilterIcon = (scope) => { 4720 return renderSlot(slots, "filter-icon", scope); 4721 }; 4722 } 4723 if (slots.expand) { 4724 column.renderExpand = (scope) => { 4725 return renderSlot(slots, "expand", scope); 4726 }; 4727 } 4728 let originRenderCell = column.renderCell; 4729 if (column.type === "expand") { 4730 column.renderCell = (data) => h$1("div", { 4731 class: "cell" 4732 }, [originRenderCell(data)]); 4733 owner.value.renderExpanded = (row) => { 4734 return slots.default ? slots.default(row) : slots.default; 4735 }; 4736 } else { 4737 originRenderCell = originRenderCell || defaultRenderCell; 4738 column.renderCell = (data) => { 4739 let children = null; 4740 if (slots.default) { 4741 const vnodes = slots.default(data); 4742 children = vnodes.some((v2) => v2.type !== Comment) ? vnodes : originRenderCell(data); 4743 } else { 4744 children = originRenderCell(data); 4745 } 4746 const { columns } = owner.value.store.states; 4747 const firstUserColumnIndex = columns.value.findIndex((item) => item.type === "default"); 4748 const shouldCreatePlaceholder = hasTreeColumn.value && data.cellIndex === firstUserColumnIndex; 4749 const prefix = treeCellPrefix(data, shouldCreatePlaceholder); 4750 const props2 = { 4751 class: "cell", 4752 style: {} 4753 }; 4754 if (column.showOverflowTooltip) { 4755 props2.class = `${props2.class} ${unref(ns.namespace)}-tooltip`; 4756 props2.style = { 4757 width: `${(data.column.realWidth || Number(data.column.width)) - 1}px` 4758 }; 4759 } 4760 checkSubColumn(children); 4761 return h$1("div", props2, [prefix, children]); 4762 }; 4763 } 4764 return column; 4765 }; 4766 const getPropsData = (...propsKey) => { 4767 return propsKey.reduce((prev, cur) => { 4768 if (isArray$1(cur)) { 4769 cur.forEach((key) => { 4770 prev[key] = props[key]; 4771 }); 4772 } 4773 return prev; 4774 }, {}); 4775 }; 4776 const getColumnElIndex = (children, child) => { 4777 return Array.prototype.indexOf.call(children, child); 4778 }; 4779 const updateColumnOrder = () => { 4780 owner.value.store.commit("updateColumnOrder", instance.columnConfig.value); 4781 }; 4782 return { 4783 columnId, 4784 realAlign, 4785 isSubColumn, 4786 realHeaderAlign, 4787 columnOrTableParent, 4788 setColumnWidth, 4789 setColumnForcedProps, 4790 setColumnRenders, 4791 getPropsData, 4792 getColumnElIndex, 4793 updateColumnOrder 4794 }; 4795} 4796var defaultProps = { 4797 type: { 4798 type: String, 4799 default: "default" 4800 }, 4801 label: String, 4802 className: String, 4803 labelClassName: String, 4804 property: String, 4805 prop: String, 4806 width: { 4807 type: [String, Number], 4808 default: "" 4809 }, 4810 minWidth: { 4811 type: [String, Number], 4812 default: "" 4813 }, 4814 renderHeader: Function, 4815 sortable: { 4816 type: [Boolean, String], 4817 default: false 4818 }, 4819 sortMethod: Function, 4820 sortBy: [String, Function, Array], 4821 resizable: { 4822 type: Boolean, 4823 default: true 4824 }, 4825 columnKey: String, 4826 align: String, 4827 headerAlign: String, 4828 showOverflowTooltip: { 4829 type: [Boolean, Object], 4830 default: void 0 4831 }, 4832 tooltipFormatter: Function, 4833 fixed: [Boolean, String], 4834 formatter: Function, 4835 selectable: Function, 4836 reserveSelection: Boolean, 4837 filterMethod: Function, 4838 filteredValue: Array, 4839 filters: Array, 4840 filterPlacement: String, 4841 filterMultiple: { 4842 type: Boolean, 4843 default: true 4844 }, 4845 filterClassName: String, 4846 index: [Number, Function], 4847 sortOrders: { 4848 type: Array, 4849 default: () => { 4850 return ["ascending", "descending", null]; 4851 }, 4852 validator: (val) => { 4853 return val.every((order) => ["ascending", "descending", null].includes(order)); 4854 } 4855 } 4856}; 4857let columnIdSeed = 1; 4858var ElTableColumn$1 = defineComponent({ 4859 name: "ElTableColumn", 4860 components: { 4861 ElCheckbox 4862 }, 4863 props: defaultProps, 4864 setup(props, { slots }) { 4865 const instance = getCurrentInstance(); 4866 const columnConfig = ref({}); 4867 const owner = computed(() => { 4868 let parent2 = instance.parent; 4869 while (parent2 && !parent2.tableId) { 4870 parent2 = parent2.parent; 4871 } 4872 return parent2; 4873 }); 4874 const { registerNormalWatchers, registerComplexWatchers } = useWatcher(owner, props); 4875 const { 4876 columnId, 4877 isSubColumn, 4878 realHeaderAlign, 4879 columnOrTableParent, 4880 setColumnWidth, 4881 setColumnForcedProps, 4882 setColumnRenders, 4883 getPropsData, 4884 getColumnElIndex, 4885 realAlign, 4886 updateColumnOrder 4887 } = useRender(props, slots, owner); 4888 const parent = columnOrTableParent.value; 4889 columnId.value = `${"tableId" in parent && parent.tableId || "columnId" in parent && parent.columnId}_column_${columnIdSeed++}`; 4890 onBeforeMount(() => { 4891 isSubColumn.value = owner.value !== parent; 4892 const type = props.type || "default"; 4893 const sortable = props.sortable === "" ? true : props.sortable; 4894 const showOverflowTooltip = type === "selection" ? false : isUndefined(props.showOverflowTooltip) ? parent.props.showOverflowTooltip : props.showOverflowTooltip; 4895 const tooltipFormatter = isUndefined(props.tooltipFormatter) ? parent.props.tooltipFormatter : props.tooltipFormatter; 4896 const defaults = { 4897 ...cellStarts[type], 4898 id: columnId.value, 4899 type, 4900 property: props.prop || props.property, 4901 align: realAlign, 4902 headerAlign: realHeaderAlign, 4903 showOverflowTooltip, 4904 tooltipFormatter, 4905 filterable: props.filters || props.filterMethod, 4906 filteredValue: [], 4907 filterPlacement: "", 4908 filterClassName: "", 4909 isColumnGroup: false, 4910 isSubColumn: false, 4911 filterOpened: false, 4912 sortable, 4913 index: props.index, 4914 rawColumnKey: instance.vnode.key 4915 }; 4916 const basicProps = [ 4917 "columnKey", 4918 "label", 4919 "className", 4920 "labelClassName", 4921 "type", 4922 "renderHeader", 4923 "formatter", 4924 "fixed", 4925 "resizable" 4926 ]; 4927 const sortProps = ["sortMethod", "sortBy", "sortOrders"]; 4928 const selectProps = ["selectable", "reserveSelection"]; 4929 const filterProps = [ 4930 "filterMethod", 4931 "filters", 4932 "filterMultiple", 4933 "filterOpened", 4934 "filteredValue", 4935 "filterPlacement", 4936 "filterClassName" 4937 ]; 4938 let column = getPropsData(basicProps, sortProps, selectProps, filterProps); 4939 column = mergeOptions(defaults, column); 4940 const chains = compose(setColumnRenders, setColumnWidth, setColumnForcedProps); 4941 column = chains(column); 4942 columnConfig.value = column; 4943 registerNormalWatchers(); 4944 registerComplexWatchers(); 4945 }); 4946 onMounted(() => { 4947 var _a, _b; 4948 const parent2 = columnOrTableParent.value; 4949 const children = isSubColumn.value ? (_a = parent2.vnode.el) == null ? void 0 : _a.children : (_b = parent2.refs.hiddenColumns) == null ? void 0 : _b.children; 4950 const getColumnIndex = () => getColumnElIndex(children || [], instance.vnode.el); 4951 columnConfig.value.getColumnIndex = getColumnIndex; 4952 const columnIndex = getColumnIndex(); 4953 columnIndex > -1 && owner.value.store.commit("insertColumn", columnConfig.value, isSubColumn.value ? "columnConfig" in parent2 && parent2.columnConfig.value : null, updateColumnOrder); 4954 }); 4955 onBeforeUnmount(() => { 4956 const getColumnIndex = columnConfig.value.getColumnIndex; 4957 const columnIndex = getColumnIndex ? getColumnIndex() : -1; 4958 columnIndex > -1 && owner.value.store.commit("removeColumn", columnConfig.value, isSubColumn.value ? "columnConfig" in parent && parent.columnConfig.value : null, updateColumnOrder); 4959 }); 4960 instance.columnId = columnId.value; 4961 instance.columnConfig = columnConfig; 4962 return; 4963 }, 4964 render() { 4965 var _a, _b, _c; 4966 try { 4967 const renderDefault = (_b = (_a = this.$slots).default) == null ? void 0 : _b.call(_a, { 4968 row: {}, 4969 column: {}, 4970 $index: -1 4971 }); 4972 const children = []; 4973 if (isArray$1(renderDefault)) { 4974 for (const childNode of renderDefault) { 4975 if (((_c = childNode.type) == null ? void 0 : _c.name) === "ElTableColumn" || childNode.shapeFlag & 2) { 4976 children.push(childNode); 4977 } else if (childNode.type === Fragment && isArray$1(childNode.children)) {
4978 childNode.children.forEach((vnode2) => { 4979 if ((vnode2 == null ? void 0 : vnode2.patchFlag) !== 1024 && !isString(vnode2 == null ? void 0 : vnode2.children)) { 4980 children.push(vnode2); 4981 } 4982 }); 4983 } 4984 } 4985 } 4986 const vnode = h$1("div", children); 4987 return vnode; 4988 } catch (e) { 4989 return h$1("div", []); 4990 } 4991 } 4992}); 4993const ElTable = withInstall(Table, { 4994 TableColumn: ElTableColumn$1 4995}); 4996const ElTableColumn = withNoopInstall(ElTableColumn$1); 4997export { 4998 ElTableColumn as E, 4999 ElTable as a 5000};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.