fast-element-plus 2.0.1 → 2.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (88) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/README.md +2 -0
  3. package/README.zh.md +2 -0
  4. package/dist/components/avatar/index.d.ts +2 -2
  5. package/dist/components/avatar/index.mjs.map +1 -1
  6. package/dist/components/button/index.d.ts +1 -1
  7. package/dist/components/button/index.mjs.map +1 -1
  8. package/dist/components/contextMenu/src/contextMenu.d.ts +4 -4
  9. package/dist/components/contextMenu/src/contextMenu.type.d.ts +3 -3
  10. package/dist/components/dialog/index.d.ts +1 -1
  11. package/dist/components/dialog/index.mjs.map +1 -1
  12. package/dist/components/drawer/index.d.ts +2 -2
  13. package/dist/components/drawer/index.mjs.map +1 -1
  14. package/dist/components/form/index.d.ts +1 -1
  15. package/dist/components/form/index.mjs.map +1 -1
  16. package/dist/components/form/src/form.d.ts +5 -2
  17. package/dist/components/form/src/form.mjs.map +1 -1
  18. package/dist/components/formItemTip/index.d.ts +1 -1
  19. package/dist/components/formItemTip/index.mjs.map +1 -1
  20. package/dist/components/icon/index.d.ts +2 -2
  21. package/dist/components/icon/index.mjs.map +1 -1
  22. package/dist/components/image/index.d.ts +1 -1
  23. package/dist/components/image/index.mjs.map +1 -1
  24. package/dist/components/inputDialogPage/index.d.ts +1 -1
  25. package/dist/components/inputDialogPage/index.mjs.map +1 -1
  26. package/dist/components/inputDialogPage/src/inputDialogPage.d.ts +15 -15
  27. package/dist/components/inputDialogPage/src/inputDialogPage.mjs.map +1 -1
  28. package/dist/components/layoutGrid/src/layoutGrid.mjs.map +1 -1
  29. package/dist/components/layoutGrid/src/layoutGridItem.mjs.map +1 -1
  30. package/dist/components/select/index.d.ts +2 -2
  31. package/dist/components/select/index.mjs.map +1 -1
  32. package/dist/components/select/src/select.d.ts +15 -14
  33. package/dist/components/select/src/select.mjs.map +1 -1
  34. package/dist/components/select/src/select.type.d.ts +4 -4
  35. package/dist/components/select/src/selectOption.d.ts +5 -5
  36. package/dist/components/selectPage/index.d.ts +1 -1
  37. package/dist/components/selectPage/index.mjs.map +1 -1
  38. package/dist/components/selectPage/src/selectPage.d.ts +10 -10
  39. package/dist/components/selectPage/src/selectPage.mjs.map +1 -1
  40. package/dist/components/selectV2/index.d.ts +2 -2
  41. package/dist/components/selectV2/index.mjs.map +1 -1
  42. package/dist/components/selectV2/src/selectV2.d.ts +28 -36
  43. package/dist/components/selectV2/src/selectV2.mjs.map +1 -1
  44. package/dist/components/table/index.d.ts +1 -1
  45. package/dist/components/table/index.mjs.map +1 -1
  46. package/dist/components/table/src/page.type.d.ts +3 -1
  47. package/dist/components/table/src/page.type.mjs.map +1 -1
  48. package/dist/components/table/src/table.d.ts +38 -39
  49. package/dist/components/table/src/table.mjs +4 -2
  50. package/dist/components/table/src/table.mjs.map +1 -1
  51. package/dist/components/table/src/table.state.d.ts +5 -5
  52. package/dist/components/table/src/table.type.d.ts +13 -10
  53. package/dist/components/table/src/table.type.mjs.map +1 -1
  54. package/dist/components/table/src/tableColumn.d.ts +3 -4
  55. package/dist/components/table/src/tableColumn.mjs +1 -1
  56. package/dist/components/table/src/tableColumn.mjs.map +1 -1
  57. package/dist/components/table/src/tableColumnSettingDialog.mjs.map +1 -1
  58. package/dist/components/table/src/tableSearchForm.d.ts +1 -1
  59. package/dist/components/table/src/tableSearchForm.mjs.map +1 -1
  60. package/dist/components/table/src/tableSearchFormItem.mjs.map +1 -1
  61. package/dist/components/table/src/useTable.d.ts +5 -5
  62. package/dist/components/table/src/useTable.mjs.map +1 -1
  63. package/dist/components/table/utils/table.d.ts +3 -2
  64. package/dist/components/table/utils/table.mjs.map +1 -1
  65. package/dist/components/tree/index.d.ts +1 -1
  66. package/dist/components/tree/index.mjs.map +1 -1
  67. package/dist/components/tree/src/tree.d.ts +27 -25
  68. package/dist/components/tree/src/tree.mjs +3 -1
  69. package/dist/components/tree/src/tree.mjs.map +1 -1
  70. package/dist/components/tree/src/tree.props.d.ts +1 -4
  71. package/dist/components/tree/src/tree.type.d.ts +4 -4
  72. package/dist/components/treeSelect/index.d.ts +1 -1
  73. package/dist/components/treeSelect/index.mjs.map +1 -1
  74. package/dist/components/treeSelect/src/treeSelect.d.ts +32 -31
  75. package/dist/components/treeSelect/src/treeSelect.mjs.map +1 -1
  76. package/dist/components/upload/index.d.ts +1 -1
  77. package/dist/components/upload/index.mjs.map +1 -1
  78. package/dist/components/uploadImage/index.d.ts +1 -1
  79. package/dist/components/uploadImage/index.mjs.map +1 -1
  80. package/dist/components/uploadImages/index.d.ts +2 -2
  81. package/dist/components/uploadImages/index.mjs.map +1 -1
  82. package/dist/directives/click-icon-copy/index.mjs.map +1 -1
  83. package/dist/index.global.min.js +2 -2
  84. package/dist/index.global.min.js.map +1 -1
  85. package/dist/version.d.ts +1 -1
  86. package/dist/version.mjs +1 -1
  87. package/dist/version.mjs.map +1 -1
  88. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useTable.mjs","names":[],"sources":["../../../../src/components/table/src/useTable.ts"],"sourcesContent":["import { computed, nextTick, provide, reactive, ref, watch } from \"vue\";\nimport { dayjs, useGlobalSize } from \"element-plus\";\nimport { isArray, isFunction } from \"lodash-unified\";\nimport { callOptionalFunction, debounce, type makeSlots } from \"../../../utils\";\nimport { tableUtil } from \"../utils/table\";\nimport { getTableDefaultSlots } from \"./table.type\";\nimport type { PagedInput, PagedResult } from \"./page.type\";\nimport type { FaTableSlots, faTableEmits, faTableProps } from \"./table\";\nimport type { FaTableRow, FaTableState } from \"./table.state\";\nimport type { FaTableColumnCtx, FaTableEnumColumnCtx } from \"./table.type\";\nimport type { TableInstance } from \"element-plus\";\nimport type { ExtractPropTypes, InjectionKey, Ref, SetupContext } from \"vue\";\n\n/** FaTable 状态的依赖注入键。 */\nexport const tableStateKey: InjectionKey<FaTableState> = Symbol(\"tableState\");\n/** FaTable 枚举映射的依赖注入键。 */\nexport const enumMapKey: InjectionKey<Map<string, FaTableEnumColumnCtx[]>> = Symbol(\"enumMap\");\n\ntype TableSetupContext = SetupContext<typeof faTableEmits, ReturnType<typeof makeSlots<FaTableSlots>>>;\n\ninterface TableComposable {\n\t_globalSize: ReturnType<typeof useGlobalSize>;\n\tstate: FaTableState;\n\telementRef: Ref<HTMLElement | undefined>;\n\ttableRef: Ref<TableInstance | undefined>;\n\thandleTableColumnAutoWidth: () => void;\n\tgetRequestParam: () => PagedInput;\n\tloadTableColumns: () => void;\n\thandleSizeChange: (pageSize: number) => void;\n\thandlePaginationChange: (value: number) => void;\n\tdefaultSearchTime: () => void;\n\ttableSearch: () => Promise<void>;\n\ttableReset: () => Promise<void>;\n\tdoRender: () => Promise<void>;\n\tdoLoading: (loadingFunction: () => void | Promise<void>, loadingText?: string) => void;\n\thandleCustomCellClick: (emitName: string, context: { row: FaTableRow; column: FaTableColumnCtx; $index: number }) => void;\n}\n\n/**\n * 创建 FaTable 的状态和操作方法。\n *\n * @param props - FaTable 的 Props。\n * @param slots - FaTable 的插槽。\n * @param emit - FaTable 的事件触发器。\n * @returns FaTable 的状态、引用和操作方法。\n */\nexport const useTable = (\n\tprops: ExtractPropTypes<typeof faTableProps>,\n\tslots: TableSetupContext[\"slots\"],\n\temit: TableSetupContext[\"emit\"]\n): TableComposable => {\n\tconst _globalSize = useGlobalSize();\n\n\tconst elementRef = ref<HTMLElement>();\n\tconst tableRef = ref<TableInstance>();\n\n\t/**\n\t * 定义 enumMap 存储 enum 值(避免异步请求无法格式化单元格内容 || 无法填充搜索下拉选择)\n\t */\n\tconst enumMap = reactive(new Map<string, FaTableEnumColumnCtx[]>());\n\tprovide(enumMapKey, enumMap);\n\n\tconst state: FaTableState = reactive({\n\t\tloading: false,\n\t\tloadingText: \"加载中...\",\n\t\torgColumns: [],\n\t\ttableColumns: computed(() => state.orgColumns.filter((f) => f.prop && !f.pureSearch)),\n\t\tsearchColumns: computed(() =>\n\t\t\tstate.orgColumns\n\t\t\t\t.filter((item) => item.pureSearch === true || item.search !== undefined)\n\t\t\t\t.sort((a, b) => {\n\t\t\t\t\treturn (a.search?.order ?? 0) - (b.search?.order ?? 0);\n\t\t\t\t})\n\t\t),\n\t\tspanColumns: computed(() => [\n\t\t\t...state.orgColumns.flatMap((column) => (column.spanProp ? [{ prop: column.prop ?? \"\", spanProp: column.spanProp }] : [])),\n\t\t\t...(props.props.span\n\t\t\t\t? [\n\t\t\t\t\t\t{ prop: \"__table-index\", spanProp: props.props.span },\n\t\t\t\t\t\t{ prop: \"__table-selection\", spanProp: props.props.span },\n\t\t\t\t\t\t{ prop: \"__table-operation\", spanProp: props.props.span },\n\t\t\t\t\t]\n\t\t\t\t: []),\n\t\t]),\n\t\ttableData: [],\n\t\ttableSpanData: computed(() => {\n\t\t\tif (state.spanColumns?.length > 0 && state.tableData?.length > 0) {\n\t\t\t\tconst result: Record<string, number[]> = {};\n\t\t\t\tconst spanIndexes: Record<string, number> = {};\n\t\t\t\tstate.spanColumns.forEach((item) => {\n\t\t\t\t\tresult[item.prop] = new Array<number>(state.tableData.length).fill(1, 0, 1).fill(0, 1);\n\t\t\t\t\tspanIndexes[item.prop] = 0;\n\t\t\t\t});\n\t\t\t\tfor (let i = 1; i < state.tableData.length; i++) {\n\t\t\t\t\tstate.spanColumns.forEach((item) => {\n\t\t\t\t\t\tconst currentRow = state.tableData[i];\n\t\t\t\t\t\tconst previousRow = state.tableData[i - 1];\n\t\t\t\t\t\tconst spanValues = result[item.prop];\n\t\t\t\t\t\tconst spanIndex = spanIndexes[item.prop];\n\t\t\t\t\t\tif (currentRow === undefined || previousRow === undefined || spanValues === undefined || spanIndex === undefined) return;\n\t\t\t\t\t\tif (currentRow[item.spanProp] === previousRow[item.spanProp]) {\n\t\t\t\t\t\t\tspanValues[spanIndex] = (spanValues[spanIndex] ?? 0) + 1;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tspanIndexes[item.prop] = i;\n\t\t\t\t\t\t\tspanValues[i] = 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\treturn {};\n\t\t}),\n\t\ttablePagination: {\n\t\t\tpageIndex: 1,\n\t\t\tpageSize: 20,\n\t\t\ttotalRows: 0,\n\t\t},\n\t\tinitParam: {},\n\t\tsearchParam: {},\n\t\tsearchValueUpdate: \"\",\n\t\tsearchForm: props.searchForm,\n\t\tselected: false,\n\t\tselectedList: [],\n\t\tselectedListIds: computed(() =>\n\t\t\tstate.selectedList.flatMap((item) => {\n\t\t\t\tconst rowKey = isFunction(props.rowKey) ? props.rowKey(item) : tableUtil.handleRowAccordingToProp(item, props.rowKey);\n\t\t\t\treturn typeof rowKey === \"string\" || typeof rowKey === \"number\" ? [rowKey] : [];\n\t\t\t})\n\t\t),\n\t\tindeterminateSelectedListIds: [],\n\t\toperationColumnWidth: computed(() => {\n\t\t\tconst findAutoCol = state.autoColumnWidth.find((f) => f.prop === \"__table-operation\");\n\t\t\tif (findAutoCol) {\n\t\t\t\treturn `${findAutoCol.width}px`;\n\t\t\t}\n\t\t\tswitch (_globalSize.value) {\n\t\t\t\tcase \"large\":\n\t\t\t\tcase \"default\":\n\t\t\t\t\treturn \"54px\";\n\t\t\t\tcase \"small\":\n\t\t\t\t\treturn \"42px\";\n\t\t\t\tdefault:\n\t\t\t\t\treturn \"auto\";\n\t\t\t}\n\t\t}),\n\t\timagePreview: false,\n\t\tpreviewList: [],\n\t\ttableWidth: 0,\n\t\ttableHeight: 0,\n\t\tautoColumnWidth: [],\n\t});\n\tlet requestVersion = 0;\n\n\tprovide(tableStateKey, state);\n\n\tconst handleTableColumnAutoWidth = (): void => {\n\t\tstate.loading = true;\n\t\tstate.loadingText = \"加载中...\";\n\t\tstate.autoColumnWidth = [];\n\t\tconst autoWidthColumns = state.tableColumns.filter((f) => f.autoWidth);\n\t\tif (slots?.operation) {\n\t\t\t// 操作列自动宽度\n\t\t\tautoWidthColumns.push({\n\t\t\t\tprop: \"__table-operation\",\n\t\t\t});\n\t\t}\n\t\tif (autoWidthColumns.length > 0) {\n\t\t\t// padding24/16 + border1\n\t\t\tconst otherWidth = _globalSize.value === \"default\" ? 25 : 17;\n\t\t\tvoid nextTick(() => {\n\t\t\t\tconst tableDom = document.querySelector(`.fa-table__${props.tableKey}`);\n\t\t\t\tif (tableDom) {\n\t\t\t\t\tautoWidthColumns.forEach((item) => {\n\t\t\t\t\t\tconst headerColumnDom = tableDom.querySelector(`.__fa-table__auto-width-column__cell-header__${item?.prop}`);\n\t\t\t\t\t\tconst cellColumnDoms = tableDom.querySelectorAll(`.__fa-table__auto-width-column__cell__${item?.prop}`);\n\t\t\t\t\t\tlet maxWidth = 0;\n\t\t\t\t\t\tif (headerColumnDom) {\n\t\t\t\t\t\t\tmaxWidth = Math.ceil(headerColumnDom.scrollWidth) + otherWidth;\n\t\t\t\t\t\t\tif (item?.sortable) {\n\t\t\t\t\t\t\t\tmaxWidth += 24;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcellColumnDoms.forEach((cellDom) => {\n\t\t\t\t\t\t\tconst curWidth = Math.ceil(cellDom.scrollWidth) + otherWidth;\n\t\t\t\t\t\t\tif (curWidth > maxWidth) {\n\t\t\t\t\t\t\t\tmaxWidth = curWidth;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst findInfo = state.autoColumnWidth.find((f) => f.prop === item?.prop);\n\t\t\t\t\t\tif (findInfo) {\n\t\t\t\t\t\t\tfindInfo.width = Math.max(findInfo.width, maxWidth);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (item.prop) {\n\t\t\t\t\t\t\t\tstate.autoColumnWidth.push({\n\t\t\t\t\t\t\t\t\tprop: item.prop,\n\t\t\t\t\t\t\t\t\twidth: maxWidth,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}).finally(() => {\n\t\t\t\tstate.loading = false;\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tstate.loading = false;\n\t};\n\n\tconst handleTableData = (data: FaTableRow[]): FaTableRow[] => {\n\t\tif (props.treeData) {\n\t\t\tconst result: FaTableRow[] = [];\n\t\t\tdata.forEach((row) => {\n\t\t\t\tconst rowList = row[props.props.children ?? \"children\"];\n\t\t\t\tif (isArray(rowList)) {\n\t\t\t\t\t// 如果 rowList 是数组,遍历并合并每个子项\n\t\t\t\t\tconst childRows: unknown[] = rowList;\n\t\t\t\t\tchildRows.forEach((childRow) => {\n\t\t\t\t\t\tresult.push(typeof childRow === \"object\" && childRow !== null ? { ...row, ...childRow } : row);\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tresult.push(typeof rowList === \"object\" && rowList !== null ? { ...row, ...rowList } : row);\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn result;\n\t\t} else {\n\t\t\treturn data;\n\t\t}\n\t};\n\n\tconst getRequestParam = (): PagedInput => {\n\t\tconst params = { ...state.searchParam, ...(props.pagination ? state.tablePagination : {}) };\n\t\t// 删除总条数\n\t\tdelete params.totalRows;\n\t\treturn params;\n\t};\n\n\tconst loadData = async (): Promise<void> => {\n\t\tconst currentRequestVersion = ++requestVersion;\n\t\tstate.loading = true;\n\t\tstate.loadingText = \"加载中...\";\n\t\tif (props.requestApi) {\n\t\t\tconst params = getRequestParam();\n\t\t\temit(\"refresh\", params);\n\t\t\tlet pageData: FaTableRow[];\n\t\t\ttry {\n\t\t\t\tconst resData = await props.requestApi(params);\n\t\t\t\tif (currentRequestVersion !== requestVersion) return;\n\t\t\t\t// 数据回调\n\t\t\t\tprops.dataCallback?.(resData);\n\t\t\t\t// 解析 API 接口返回的分页数据(如果有分页更新分页信息)\n\t\t\t\tif (props.pagination) {\n\t\t\t\t\tif (isArray(resData)) {\n\t\t\t\t\t\tpageData = resData;\n\t\t\t\t\t\tstate.tablePagination.totalRows = resData.length;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst pageRes = resData as PagedResult;\n\t\t\t\t\t\tpageData = pageRes.rows ?? [];\n\t\t\t\t\t\tObject.assign(state.tablePagination, {\n\t\t\t\t\t\t\tpageIndex: pageRes.pageIndex ?? state.tablePagination.pageIndex,\n\t\t\t\t\t\t\tpageSize: pageRes.pageSize ?? state.tablePagination.pageSize,\n\t\t\t\t\t\t\ttotalRows: pageRes.totalRows ?? pageData.length,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tpageData = resData as FaTableRow[];\n\t\t\t\t\t// 更新分页信息\n\t\t\t\t\tObject.assign(state.tablePagination, {\n\t\t\t\t\t\tpageIndex: 1,\n\t\t\t\t\t\tpageSize: 0,\n\t\t\t\t\t\ttotalRows: pageData.length,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tstate.tableData = handleTableData(pageData);\n\t\t\t} catch (error) {\n\t\t\t\tif (currentRequestVersion !== requestVersion) return;\n\t\t\t\tstate.tableData = [];\n\t\t\t\tthrow error;\n\t\t\t} finally {\n\t\t\t\tif (currentRequestVersion === requestVersion) state.loading = false;\n\t\t\t}\n\t\t} else {\n\t\t\temit(\"refresh\", { searchValue: state.searchParam.searchValue });\n\t\t\tlet _value = handleTableData([...props.data]);\n\t\t\t_value = _value.filter((f) => {\n\t\t\t\tconst searchValue = state.searchParam.searchValue;\n\t\t\t\tif (typeof searchValue !== \"string\" || searchValue.length === 0) return true;\n\t\t\t\treturn state.tableColumns.some((col) => {\n\t\t\t\t\tconst value = tableUtil.handleRowAccordingToProp(f, col.prop ?? \"\");\n\t\t\t\t\tconst text =\n\t\t\t\t\t\ttypeof value === \"string\" || typeof value === \"number\" || typeof value === \"bigint\" || typeof value === \"boolean\"\n\t\t\t\t\t\t\t? String(value)\n\t\t\t\t\t\t\t: \"\";\n\t\t\t\t\treturn text.toLowerCase().includes(searchValue.toLowerCase());\n\t\t\t\t});\n\t\t\t});\n\t\t\tif (isArray(state.searchParam.sortList) && state.searchParam.sortList.length > 0) {\n\t\t\t\t_value = _value.sort(tableUtil.arrayDynamicSort(state.searchParam.sortList));\n\t\t\t}\n\t\t\tif (props.pagination) {\n\t\t\t\t// 更新分页信息\n\t\t\t\tObject.assign(state.tablePagination, {\n\t\t\t\t\ttotalRows: _value.length,\n\t\t\t\t});\n\t\t\t\tconst pageStart = (state.tablePagination.pageIndex - 1) * state.tablePagination.pageSize;\n\t\t\t\tconst pageEnd = pageStart + state.tablePagination.pageSize;\n\t\t\t\tstate.tableData = _value.slice(pageStart, pageEnd);\n\t\t\t} else {\n\t\t\t\tstate.tableData = _value;\n\t\t\t\t// 更新分页信息\n\t\t\t\tObject.assign(state.tablePagination, {\n\t\t\t\t\tpageIndex: 1,\n\t\t\t\t\tpageSize: 0,\n\t\t\t\t\ttotalRows: _value.length,\n\t\t\t\t});\n\t\t\t}\n\t\t\tstate.loading = false;\n\t\t}\n\t\thandleTableColumnAutoWidth();\n\t};\n\n\tconst cloneColumns = (columns: FaTableColumnCtx[]): FaTableColumnCtx[] =>\n\t\tcolumns.map((column) => ({\n\t\t\t...column,\n\t\t\t...(column.search && { search: { ...column.search, ...(column.search.props && { props: { ...column.search.props } }) } }),\n\t\t\t...(column._children && { _children: cloneColumns(column._children) }),\n\t\t}));\n\n\tconst loadTableColumns = (): void => {\n\t\tlet columns: FaTableColumnCtx[] = props.columns ? cloneColumns(props.columns) : [];\n\t\t// 默认值处理\n\t\tcolumns.forEach((col) => {\n\t\t\t// 处理搜索项的 key 和 label\n\t\t\tif (col.pureSearch || col.search) {\n\t\t\t\tcol.search ??= { el: \"\" };\n\t\t\t\tcol.search.key ??= col.prop;\n\t\t\t\tcol.search.label ??= col.label;\n\t\t\t\t// 处理默认值\n\t\t\t\tif (col.search.key && col.search.defaultValue !== undefined) {\n\t\t\t\t\tstate.searchParam[col.search.key] = col.search.defaultValue;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// 排序\n\t\tcolumns = columns.sort((a, b) => {\n\t\t\treturn (a.order ?? 0) - (b.order ?? 0);\n\t\t});\n\n\t\t// TODO:这里的扁平化暂时没用到\n\t\tstate.orgColumns = tableUtil.flatColumns(columns, enumMap);\n\t};\n\n\tconst handleSizeChange = (pageSize: number): void => {\n\t\tstate.tablePagination.pageIndex = 1;\n\t\tstate.tablePagination.pageSize = pageSize;\n\t\temit(\"sizeChange\", pageSize);\n\t\temit(\"paginationChange\", 1, pageSize);\n\t\tvoid loadData();\n\t};\n\tconst handlePaginationChange = (val: number): void => {\n\t\tstate.tablePagination.pageIndex = val;\n\t\temit(\"paginationChange\", val, state.tablePagination.pageSize);\n\t\tvoid loadData();\n\t};\n\n\tconst updatedTotalParam = (): void => {\n\t\t// 处理查询参数,可以给查询参数加自定义前缀操作\n\t\tconst newSearchParam: Record<string, unknown> = {};\n\t\t// 防止手动清空输入框携带参数(这里可以自定义查询参数前缀)\n\t\tfor (const key in state.searchParam) {\n\t\t\t// * 某些情况下参数为 false/0 也应该携带参数\n\t\t\tif (state.searchParam[key] || state.searchParam[key] === false || state.searchParam[key] === 0) {\n\t\t\t\tnewSearchParam[key] = state.searchParam[key];\n\t\t\t}\n\t\t\t// 处理某些情况下如果为空字符串,其实是不需要传到后端的\n\t\t\telse if (!state.searchParam[key]) {\n\t\t\t\tdelete state.searchParam[key];\n\t\t\t}\n\t\t}\n\t\tObject.assign(state.searchParam, newSearchParam);\n\t};\n\n\tconst defaultSearchTime = (): void => {\n\t\tif (props.hideSearchTime) {\n\t\t\tstate.searchParam.searchTimeList = undefined;\n\t\t} else {\n\t\t\tconst end = new Date();\n\t\t\tconst start = new Date();\n\t\t\tif (props.futureSearchTime) {\n\t\t\t\tswitch (props.dataSearchRange) {\n\t\t\t\t\tcase \"Past1D\":\n\t\t\t\t\t\tend.setDate(end.getDate() + 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past3D\":\n\t\t\t\t\t\tend.setDate(end.getDate() + 3);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past1W\":\n\t\t\t\t\t\tend.setDate(end.getDate() + 7);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past1M\":\n\t\t\t\t\t\tend.setMonth(end.getMonth() + 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past3M\":\n\t\t\t\t\t\tend.setMonth(end.getMonth() + 3);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past6M\":\n\t\t\t\t\t\tend.setMonth(end.getMonth() + 6);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past1Y\":\n\t\t\t\t\t\tend.setFullYear(end.getFullYear() + 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past3Y\":\n\t\t\t\t\t\tend.setFullYear(end.getFullYear() + 3);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tswitch (props.dataSearchRange) {\n\t\t\t\t\tcase \"Past1D\":\n\t\t\t\t\t\tstart.setDate(start.getDate() - 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past3D\":\n\t\t\t\t\t\tstart.setDate(start.getDate() - 3);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past1W\":\n\t\t\t\t\t\tstart.setDate(start.getDate() - 7);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past1M\":\n\t\t\t\t\t\tstart.setMonth(start.getMonth() - 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past3M\":\n\t\t\t\t\t\tstart.setMonth(start.getMonth() - 3);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past6M\":\n\t\t\t\t\t\tstart.setMonth(start.getMonth() - 6);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past1Y\":\n\t\t\t\t\t\tstart.setFullYear(start.getFullYear() - 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past3Y\":\n\t\t\t\t\t\tstart.setFullYear(start.getFullYear() - 3);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tstate.searchParam.searchTimeList = [dayjs(start).format(\"YYYY-MM-DD 00:00:00\"), dayjs(end).format(\"YYYY-MM-DD 23:59:59\")];\n\t\t}\n\t};\n\n\tconst tableSearch = async (): Promise<void> => {\n\t\t// 重置到第一页\n\t\tstate.tablePagination.pageIndex = 1;\n\t\tupdatedTotalParam();\n\t\tawait loadData();\n\t};\n\tconst renderTable = debounce((): Promise<void> => {\n\t\tloadTableColumns();\n\t\treturn tableSearch();\n\t}, 300);\n\n\tconst tableReset = async (): Promise<void> => {\n\t\t// 重置到第一页\n\t\tstate.tablePagination.pageIndex = 1;\n\t\t// 清除搜索条件\n\t\tstate.searchParam = {};\n\t\tdefaultSearchTime();\n\t\t// 重置搜索表单的时候,如果有默认搜索参数,则重置默认的搜索参数\n\t\tif (typeof state.initParam === \"object\" && state.initParam !== null) {\n\t\t\tObject.assign(state.searchParam, state.initParam);\n\t\t}\n\t\temit(\"reset\", state.searchParam);\n\t\tawait loadData();\n\t};\n\n\tconst doRender = async (): Promise<void> => {\n\t\tstate.orgColumns = [];\n\t\tstate.autoColumnWidth = [];\n\t\tstate.tableData = [];\n\t\tawait renderTable();\n\t};\n\n\tconst doLoading = (loadingFunction: () => void | Promise<void>, loadingText = \"加载中...\"): void => {\n\t\tstate.loading = true;\n\t\tstate.loadingText = loadingText;\n\t\tvoid callOptionalFunction(loadingFunction).finally(() => {\n\t\t\tstate.loading = false;\n\t\t});\n\t};\n\n\tconst handleCustomCellClick = (\n\t\temitName: string,\n\t\t{ row, column, $index }: { row: FaTableRow; column: FaTableColumnCtx; $index: number }\n\t): void => {\n\t\temit(\"customCellClick\", emitName, { row, column, $index, ...getTableDefaultSlots(state) });\n\t};\n\n\twatch(\n\t\t() => props.tableKey,\n\t\t() => doRender()\n\t);\n\n\twatch(\n\t\t() => props.searchForm,\n\t\t(newValue) => {\n\t\t\tstate.searchForm = newValue;\n\t\t}\n\t);\n\n\treturn {\n\t\t_globalSize,\n\t\tstate,\n\t\telementRef,\n\t\ttableRef,\n\t\thandleTableColumnAutoWidth,\n\t\tgetRequestParam,\n\t\tloadTableColumns,\n\t\thandleSizeChange,\n\t\thandlePaginationChange,\n\t\tdefaultSearchTime,\n\t\ttableSearch,\n\t\ttableReset,\n\t\tdoRender,\n\t\tdoLoading,\n\t\thandleCustomCellClick,\n\t};\n};\n"],"mappings":";;;;;;;;;AAcA,MAAa,gBAA4C,OAAO,YAAY;;AAE5E,MAAa,aAAgE,OAAO,SAAS;;;;;;;;;AA8B7F,MAAa,YACZ,OACA,OACA,SACqB;CACrB,MAAM,cAAc,cAAc;CAElC,MAAM,aAAa,IAAiB;CACpC,MAAM,WAAW,IAAmB;;;;CAKpC,MAAM,UAAU,yBAAS,IAAI,IAAoC,CAAC;CAClE,QAAQ,YAAY,OAAO;CAE3B,MAAM,QAAsB,SAAS;EACpC,SAAS;EACT,aAAa;EACb,YAAY,CAAC;EACb,cAAc,eAAe,MAAM,WAAW,QAAQ,MAAM,EAAE,QAAQ,CAAC,EAAE,UAAU,CAAC;EACpF,eAAe,eACd,MAAM,WACJ,QAAQ,SAAS,KAAK,eAAe,QAAQ,KAAK,WAAW,KAAA,CAAS,CAAC,CACvE,MAAM,GAAG,MAAM;GACf,QAAQ,EAAE,QAAQ,SAAS,MAAM,EAAE,QAAQ,SAAS;EACrD,CAAC,CACH;EACA,aAAa,eAAe,CAC3B,GAAG,MAAM,WAAW,SAAS,WAAY,OAAO,WAAW,CAAC;GAAE,MAAM,OAAO,QAAQ;GAAI,UAAU,OAAO;EAAS,CAAC,IAAI,CAAC,CAAE,GACzH,GAAI,MAAM,MAAM,OACb;GACA;IAAE,MAAM;IAAiB,UAAU,MAAM,MAAM;GAAK;GACpD;IAAE,MAAM;IAAqB,UAAU,MAAM,MAAM;GAAK;GACxD;IAAE,MAAM;IAAqB,UAAU,MAAM,MAAM;GAAK;EACzD,IACC,C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E,CAAC;CAC1F;CAEA,YACO,MAAM,gBACN,SAAS,CAChB;CAEA,YACO,MAAM,aACX,aAAa;EACb,MAAM,aAAa;CACpB,CACD;CAEA,OAAO;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD;AACD"}
1
+ {"version":3,"file":"useTable.mjs","names":[],"sources":["../../../../src/components/table/src/useTable.ts"],"sourcesContent":["import { computed, nextTick, provide, reactive, ref, watch } from \"vue\";\nimport { dayjs, useGlobalSize } from \"element-plus\";\nimport { isArray, isFunction } from \"lodash-unified\";\nimport { callOptionalFunction, debounce } from \"../../../utils\";\nimport { tableUtil } from \"../utils/table\";\nimport { getTableDefaultSlots } from \"./table.type\";\nimport type { TableInstance } from \"element-plus\";\nimport type { ExtractPropTypes, InjectionKey, Ref, SetupContext } from \"vue\";\nimport type { makeSlots } from \"../../../utils\";\nimport type { PagedInput, PagedResult } from \"./page.type\";\nimport type { FaTableSlots, faTableEmits, faTableProps } from \"./table\";\nimport type { DefaultRow, FaTableState } from \"./table.state\";\nimport type { FaTableColumnCtx, FaTableEnumColumnCtx } from \"./table.type\";\n\n/** FaTable 状态的依赖注入键。 */\nexport const tableStateKey: InjectionKey<FaTableState> = Symbol(\"tableState\");\n/** FaTable 枚举映射的依赖注入键。 */\nexport const enumMapKey: InjectionKey<Map<string, FaTableEnumColumnCtx[]>> = Symbol(\"enumMap\");\n\ntype TableSetupContext = SetupContext<typeof faTableEmits, ReturnType<typeof makeSlots<FaTableSlots>>>;\n\ninterface TableComposable {\n\t_globalSize: ReturnType<typeof useGlobalSize>;\n\tstate: FaTableState;\n\telementRef: Ref<HTMLElement | undefined>;\n\ttableRef: Ref<TableInstance | undefined>;\n\thandleTableColumnAutoWidth: () => void;\n\tgetRequestParam: () => PagedInput;\n\tloadTableColumns: () => void;\n\thandleSizeChange: (pageSize: number) => void;\n\thandlePaginationChange: (value: number) => void;\n\tdefaultSearchTime: () => void;\n\ttableSearch: () => Promise<void>;\n\ttableReset: () => Promise<void>;\n\tdoRender: () => Promise<void>;\n\tdoLoading: (loadingFunction: () => void | Promise<void>, loadingText?: string) => void;\n\thandleCustomCellClick: (emitName: string, context: { row: DefaultRow; column: FaTableColumnCtx; $index: number }) => void;\n}\n\n/**\n * 创建 FaTable 的状态和操作方法。\n *\n * @param props - FaTable 的 Props。\n * @param slots - FaTable 的插槽。\n * @param emit - FaTable 的事件触发器。\n * @returns FaTable 的状态、引用和操作方法。\n */\nexport const useTable = (\n\tprops: ExtractPropTypes<typeof faTableProps>,\n\tslots: TableSetupContext[\"slots\"],\n\temit: TableSetupContext[\"emit\"]\n): TableComposable => {\n\tconst _globalSize = useGlobalSize();\n\n\tconst elementRef = ref<HTMLElement>();\n\tconst tableRef = ref<TableInstance>();\n\n\t/**\n\t * 定义 enumMap 存储 enum 值(避免异步请求无法格式化单元格内容 || 无法填充搜索下拉选择)\n\t */\n\tconst enumMap = reactive(new Map<string, FaTableEnumColumnCtx[]>());\n\tprovide(enumMapKey, enumMap);\n\n\tconst state: FaTableState = reactive({\n\t\tloading: false,\n\t\tloadingText: \"加载中...\",\n\t\torgColumns: [],\n\t\ttableColumns: computed(() => state.orgColumns.filter((f) => f.prop && !f.pureSearch)),\n\t\tsearchColumns: computed(() =>\n\t\t\tstate.orgColumns\n\t\t\t\t.filter((item) => item.pureSearch === true || item.search !== undefined)\n\t\t\t\t.sort((a, b) => {\n\t\t\t\t\treturn (a.search?.order ?? 0) - (b.search?.order ?? 0);\n\t\t\t\t})\n\t\t),\n\t\tspanColumns: computed(() => [\n\t\t\t...state.orgColumns.flatMap((column) => (column.spanProp ? [{ prop: column.prop ?? \"\", spanProp: column.spanProp }] : [])),\n\t\t\t...(props.props.span\n\t\t\t\t? [\n\t\t\t\t\t\t{ prop: \"__table-index\", spanProp: props.props.span },\n\t\t\t\t\t\t{ prop: \"__table-selection\", spanProp: props.props.span },\n\t\t\t\t\t\t{ prop: \"__table-operation\", spanProp: props.props.span },\n\t\t\t\t\t]\n\t\t\t\t: []),\n\t\t]),\n\t\ttableData: [],\n\t\ttableSpanData: computed(() => {\n\t\t\tif (state.spanColumns?.length > 0 && state.tableData?.length > 0) {\n\t\t\t\tconst result: Record<string, number[]> = {};\n\t\t\t\tconst spanIndexes: Record<string, number> = {};\n\t\t\t\tstate.spanColumns.forEach((item) => {\n\t\t\t\t\tresult[item.prop] = new Array<number>(state.tableData.length).fill(1, 0, 1).fill(0, 1);\n\t\t\t\t\tspanIndexes[item.prop] = 0;\n\t\t\t\t});\n\t\t\t\tfor (let i = 1; i < state.tableData.length; i++) {\n\t\t\t\t\tstate.spanColumns.forEach((item) => {\n\t\t\t\t\t\tconst currentRow = state.tableData[i];\n\t\t\t\t\t\tconst previousRow = state.tableData[i - 1];\n\t\t\t\t\t\tconst spanValues = result[item.prop];\n\t\t\t\t\t\tconst spanIndex = spanIndexes[item.prop];\n\t\t\t\t\t\tif (currentRow === undefined || previousRow === undefined || spanValues === undefined || spanIndex === undefined) return;\n\t\t\t\t\t\tif (currentRow[item.spanProp] === previousRow[item.spanProp]) {\n\t\t\t\t\t\t\tspanValues[spanIndex] = (spanValues[spanIndex] ?? 0) + 1;\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tspanIndexes[item.prop] = i;\n\t\t\t\t\t\t\tspanValues[i] = 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\treturn result;\n\t\t\t}\n\t\t\treturn {};\n\t\t}),\n\t\ttablePagination: {\n\t\t\tpageIndex: 1,\n\t\t\tpageSize: 20,\n\t\t\ttotalRows: 0,\n\t\t},\n\t\tinitParam: {},\n\t\tsearchParam: {},\n\t\tsearchValueUpdate: \"\",\n\t\tsearchForm: props.searchForm,\n\t\tselected: false,\n\t\tselectedList: [],\n\t\tselectedListIds: computed(() =>\n\t\t\tstate.selectedList.flatMap((item) => {\n\t\t\t\tconst rowKey: unknown = isFunction(props.rowKey) ? props.rowKey(item) : tableUtil.handleRowAccordingToProp(item, props.rowKey);\n\t\t\t\treturn typeof rowKey === \"string\" || typeof rowKey === \"number\" ? [rowKey] : [];\n\t\t\t})\n\t\t),\n\t\tindeterminateSelectedListIds: [],\n\t\toperationColumnWidth: computed(() => {\n\t\t\tconst findAutoCol = state.autoColumnWidth.find((f) => f.prop === \"__table-operation\");\n\t\t\tif (findAutoCol) {\n\t\t\t\treturn `${findAutoCol.width}px`;\n\t\t\t}\n\t\t\tswitch (_globalSize.value) {\n\t\t\t\tcase \"large\":\n\t\t\t\tcase \"default\":\n\t\t\t\t\treturn \"54px\";\n\t\t\t\tcase \"small\":\n\t\t\t\t\treturn \"42px\";\n\t\t\t\tdefault:\n\t\t\t\t\treturn \"auto\";\n\t\t\t}\n\t\t}),\n\t\timagePreview: false,\n\t\tpreviewList: [],\n\t\ttableWidth: 0,\n\t\ttableHeight: 0,\n\t\tautoColumnWidth: [],\n\t});\n\tlet requestVersion = 0;\n\n\tprovide(tableStateKey, state);\n\n\tconst handleTableColumnAutoWidth = (): void => {\n\t\tstate.loading = true;\n\t\tstate.loadingText = \"加载中...\";\n\t\tstate.autoColumnWidth = [];\n\t\tconst autoWidthColumns = state.tableColumns.filter((f) => f.autoWidth);\n\t\tif (slots?.operation) {\n\t\t\t// 操作列自动宽度\n\t\t\tautoWidthColumns.push({\n\t\t\t\tprop: \"__table-operation\",\n\t\t\t});\n\t\t}\n\t\tif (autoWidthColumns.length > 0) {\n\t\t\t// padding24/16 + border1\n\t\t\tconst otherWidth = _globalSize.value === \"default\" ? 25 : 17;\n\t\t\tvoid nextTick(() => {\n\t\t\t\tconst tableDom = document.querySelector(`.fa-table__${props.tableKey}`);\n\t\t\t\tif (tableDom) {\n\t\t\t\t\tautoWidthColumns.forEach((item) => {\n\t\t\t\t\t\tconst headerColumnDom = tableDom.querySelector(`.__fa-table__auto-width-column__cell-header__${item?.prop}`);\n\t\t\t\t\t\tconst cellColumnDoms = tableDom.querySelectorAll(`.__fa-table__auto-width-column__cell__${item?.prop}`);\n\t\t\t\t\t\tlet maxWidth = 0;\n\t\t\t\t\t\tif (headerColumnDom) {\n\t\t\t\t\t\t\tmaxWidth = Math.ceil(headerColumnDom.scrollWidth) + otherWidth;\n\t\t\t\t\t\t\tif (item?.sortable) {\n\t\t\t\t\t\t\t\tmaxWidth += 24;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t\tcellColumnDoms.forEach((cellDom) => {\n\t\t\t\t\t\t\tconst curWidth = Math.ceil(cellDom.scrollWidth) + otherWidth;\n\t\t\t\t\t\t\tif (curWidth > maxWidth) {\n\t\t\t\t\t\t\t\tmaxWidth = curWidth;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t});\n\t\t\t\t\t\tconst findInfo = state.autoColumnWidth.find((f) => f.prop === item?.prop);\n\t\t\t\t\t\tif (findInfo) {\n\t\t\t\t\t\t\tfindInfo.width = Math.max(findInfo.width, maxWidth);\n\t\t\t\t\t\t} else {\n\t\t\t\t\t\t\tif (item.prop) {\n\t\t\t\t\t\t\t\tstate.autoColumnWidth.push({\n\t\t\t\t\t\t\t\t\tprop: item.prop,\n\t\t\t\t\t\t\t\t\twidth: maxWidth,\n\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t}).finally(() => {\n\t\t\t\tstate.loading = false;\n\t\t\t});\n\t\t\treturn;\n\t\t}\n\t\tstate.loading = false;\n\t};\n\n\tconst handleTableData = (data: DefaultRow[]): DefaultRow[] => {\n\t\tif (props.treeData) {\n\t\t\tconst result: DefaultRow[] = [];\n\t\t\tdata.forEach((row) => {\n\t\t\t\tconst rowList: unknown = row[props.props.children ?? \"children\"];\n\t\t\t\tif (isArray(rowList)) {\n\t\t\t\t\t// 如果 rowList 是数组,遍历并合并每个子项\n\t\t\t\t\tconst childRows: unknown[] = rowList;\n\t\t\t\t\tchildRows.forEach((childRow) => {\n\t\t\t\t\t\tresult.push(typeof childRow === \"object\" && childRow !== null ? { ...row, ...childRow } : row);\n\t\t\t\t\t});\n\t\t\t\t} else {\n\t\t\t\t\tresult.push(typeof rowList === \"object\" && rowList !== null ? { ...row, ...rowList } : row);\n\t\t\t\t}\n\t\t\t});\n\t\t\treturn result;\n\t\t} else {\n\t\t\treturn data;\n\t\t}\n\t};\n\n\tconst getRequestParam = (): PagedInput => {\n\t\tconst params = { ...state.searchParam, ...(props.pagination ? state.tablePagination : {}) };\n\t\t// 删除总条数\n\t\tdelete params.totalRows;\n\t\treturn params;\n\t};\n\n\tconst loadData = async (): Promise<void> => {\n\t\tconst currentRequestVersion = ++requestVersion;\n\t\tstate.loading = true;\n\t\tstate.loadingText = \"加载中...\";\n\t\tif (props.requestApi) {\n\t\t\tconst params = getRequestParam();\n\t\t\temit(\"refresh\", params);\n\t\t\tlet pageData: DefaultRow[];\n\t\t\ttry {\n\t\t\t\tconst resData = await props.requestApi(params);\n\t\t\t\tif (currentRequestVersion !== requestVersion) return;\n\t\t\t\t// 数据回调\n\t\t\t\tprops.dataCallback?.(resData);\n\t\t\t\t// 解析 API 接口返回的分页数据(如果有分页更新分页信息)\n\t\t\t\tif (props.pagination) {\n\t\t\t\t\tif (isArray(resData)) {\n\t\t\t\t\t\tpageData = resData;\n\t\t\t\t\t\tstate.tablePagination.totalRows = resData.length;\n\t\t\t\t\t} else {\n\t\t\t\t\t\tconst pageRes = resData as PagedResult;\n\t\t\t\t\t\tpageData = pageRes.rows ?? [];\n\t\t\t\t\t\tObject.assign(state.tablePagination, {\n\t\t\t\t\t\t\tpageIndex: pageRes.pageIndex ?? state.tablePagination.pageIndex,\n\t\t\t\t\t\t\tpageSize: pageRes.pageSize ?? state.tablePagination.pageSize,\n\t\t\t\t\t\t\ttotalRows: pageRes.totalRows ?? pageData.length,\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tpageData = resData as DefaultRow[];\n\t\t\t\t\t// 更新分页信息\n\t\t\t\t\tObject.assign(state.tablePagination, {\n\t\t\t\t\t\tpageIndex: 1,\n\t\t\t\t\t\tpageSize: 0,\n\t\t\t\t\t\ttotalRows: pageData.length,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t\tstate.tableData = handleTableData(pageData);\n\t\t\t} catch (error) {\n\t\t\t\tif (currentRequestVersion !== requestVersion) return;\n\t\t\t\tstate.tableData = [];\n\t\t\t\tthrow error;\n\t\t\t} finally {\n\t\t\t\tif (currentRequestVersion === requestVersion) state.loading = false;\n\t\t\t}\n\t\t} else {\n\t\t\temit(\"refresh\", { searchValue: state.searchParam.searchValue });\n\t\t\tlet _value = handleTableData([...props.data]);\n\t\t\t_value = _value.filter((f) => {\n\t\t\t\tconst searchValue = state.searchParam.searchValue;\n\t\t\t\tif (typeof searchValue !== \"string\" || searchValue.length === 0) return true;\n\t\t\t\treturn state.tableColumns.some((col) => {\n\t\t\t\t\tconst value: unknown = tableUtil.handleRowAccordingToProp(f, col.prop ?? \"\");\n\t\t\t\t\tconst text =\n\t\t\t\t\t\ttypeof value === \"string\" || typeof value === \"number\" || typeof value === \"bigint\" || typeof value === \"boolean\"\n\t\t\t\t\t\t\t? String(value)\n\t\t\t\t\t\t\t: \"\";\n\t\t\t\t\treturn text.toLowerCase().includes(searchValue.toLowerCase());\n\t\t\t\t});\n\t\t\t});\n\t\t\tif (isArray(state.searchParam.sortList) && state.searchParam.sortList.length > 0) {\n\t\t\t\t_value = _value.sort(tableUtil.arrayDynamicSort(state.searchParam.sortList));\n\t\t\t}\n\t\t\tif (props.pagination) {\n\t\t\t\t// 更新分页信息\n\t\t\t\tObject.assign(state.tablePagination, {\n\t\t\t\t\ttotalRows: _value.length,\n\t\t\t\t});\n\t\t\t\tconst pageStart = (state.tablePagination.pageIndex - 1) * state.tablePagination.pageSize;\n\t\t\t\tconst pageEnd = pageStart + state.tablePagination.pageSize;\n\t\t\t\tstate.tableData = _value.slice(pageStart, pageEnd);\n\t\t\t} else {\n\t\t\t\tstate.tableData = _value;\n\t\t\t\t// 更新分页信息\n\t\t\t\tObject.assign(state.tablePagination, {\n\t\t\t\t\tpageIndex: 1,\n\t\t\t\t\tpageSize: 0,\n\t\t\t\t\ttotalRows: _value.length,\n\t\t\t\t});\n\t\t\t}\n\t\t\tstate.loading = false;\n\t\t}\n\t\thandleTableColumnAutoWidth();\n\t};\n\n\tconst cloneColumns = (columns: FaTableColumnCtx[]): FaTableColumnCtx[] =>\n\t\tcolumns.map((column) => ({\n\t\t\t...column,\n\t\t\t...(column.search && { search: { ...column.search, ...(column.search.props && { props: { ...column.search.props } }) } }),\n\t\t\t...(column._children && { _children: cloneColumns(column._children) }),\n\t\t}));\n\n\tconst loadTableColumns = (): void => {\n\t\tlet columns: FaTableColumnCtx[] = props.columns ? cloneColumns(props.columns) : [];\n\t\t// 默认值处理\n\t\tcolumns.forEach((col) => {\n\t\t\t// 处理搜索项的 key 和 label\n\t\t\tif (col.pureSearch || col.search) {\n\t\t\t\tcol.search ??= { el: \"\" };\n\t\t\t\tcol.search.key ??= col.prop;\n\t\t\t\tcol.search.label ??= col.label;\n\t\t\t\t// 处理默认值\n\t\t\t\tif (col.search.key && col.search.defaultValue !== undefined) {\n\t\t\t\t\tstate.searchParam[col.search.key] = col.search.defaultValue;\n\t\t\t\t}\n\t\t\t}\n\t\t});\n\n\t\t// 排序\n\t\tcolumns = columns.sort((a, b) => {\n\t\t\treturn (a.order ?? 0) - (b.order ?? 0);\n\t\t});\n\n\t\t// TODO:这里的扁平化暂时没用到\n\t\tstate.orgColumns = tableUtil.flatColumns(columns, enumMap);\n\t};\n\n\tconst handleSizeChange = (pageSize: number): void => {\n\t\tstate.tablePagination.pageIndex = 1;\n\t\tstate.tablePagination.pageSize = pageSize;\n\t\temit(\"sizeChange\", pageSize);\n\t\temit(\"paginationChange\", 1, pageSize);\n\t\tvoid loadData();\n\t};\n\tconst handlePaginationChange = (val: number): void => {\n\t\tstate.tablePagination.pageIndex = val;\n\t\temit(\"paginationChange\", val, state.tablePagination.pageSize);\n\t\tvoid loadData();\n\t};\n\n\tconst updatedTotalParam = (): void => {\n\t\t// 处理查询参数,可以给查询参数加自定义前缀操作\n\t\tconst newSearchParam: Record<string, unknown> = {};\n\t\t// 防止手动清空输入框携带参数(这里可以自定义查询参数前缀)\n\t\tfor (const key in state.searchParam) {\n\t\t\t// * 某些情况下参数为 false/0 也应该携带参数\n\t\t\tif (state.searchParam[key] || state.searchParam[key] === false || state.searchParam[key] === 0) {\n\t\t\t\tnewSearchParam[key] = state.searchParam[key];\n\t\t\t}\n\t\t\t// 处理某些情况下如果为空字符串,其实是不需要传到后端的\n\t\t\telse if (!state.searchParam[key]) {\n\t\t\t\tdelete state.searchParam[key];\n\t\t\t}\n\t\t}\n\t\tObject.assign(state.searchParam, newSearchParam);\n\t};\n\n\tconst defaultSearchTime = (): void => {\n\t\tif (props.hideSearchTime) {\n\t\t\tstate.searchParam.searchTimeList = undefined;\n\t\t} else {\n\t\t\tconst end = new Date();\n\t\t\tconst start = new Date();\n\t\t\tif (props.futureSearchTime) {\n\t\t\t\tswitch (props.dataSearchRange) {\n\t\t\t\t\tcase \"Past1D\":\n\t\t\t\t\t\tend.setDate(end.getDate() + 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past3D\":\n\t\t\t\t\t\tend.setDate(end.getDate() + 3);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past1W\":\n\t\t\t\t\t\tend.setDate(end.getDate() + 7);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past1M\":\n\t\t\t\t\t\tend.setMonth(end.getMonth() + 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past3M\":\n\t\t\t\t\t\tend.setMonth(end.getMonth() + 3);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past6M\":\n\t\t\t\t\t\tend.setMonth(end.getMonth() + 6);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past1Y\":\n\t\t\t\t\t\tend.setFullYear(end.getFullYear() + 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past3Y\":\n\t\t\t\t\t\tend.setFullYear(end.getFullYear() + 3);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tswitch (props.dataSearchRange) {\n\t\t\t\t\tcase \"Past1D\":\n\t\t\t\t\t\tstart.setDate(start.getDate() - 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past3D\":\n\t\t\t\t\t\tstart.setDate(start.getDate() - 3);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past1W\":\n\t\t\t\t\t\tstart.setDate(start.getDate() - 7);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past1M\":\n\t\t\t\t\t\tstart.setMonth(start.getMonth() - 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past3M\":\n\t\t\t\t\t\tstart.setMonth(start.getMonth() - 3);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past6M\":\n\t\t\t\t\t\tstart.setMonth(start.getMonth() - 6);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past1Y\":\n\t\t\t\t\t\tstart.setFullYear(start.getFullYear() - 1);\n\t\t\t\t\t\tbreak;\n\t\t\t\t\tcase \"Past3Y\":\n\t\t\t\t\t\tstart.setFullYear(start.getFullYear() - 3);\n\t\t\t\t\t\tbreak;\n\t\t\t\t}\n\t\t\t}\n\t\t\tstate.searchParam.searchTimeList = [dayjs(start).format(\"YYYY-MM-DD 00:00:00\"), dayjs(end).format(\"YYYY-MM-DD 23:59:59\")];\n\t\t}\n\t};\n\n\tconst tableSearch = async (): Promise<void> => {\n\t\t// 重置到第一页\n\t\tstate.tablePagination.pageIndex = 1;\n\t\tupdatedTotalParam();\n\t\tawait loadData();\n\t};\n\tconst renderTable = debounce((): Promise<void> => {\n\t\tloadTableColumns();\n\t\treturn tableSearch();\n\t}, 300);\n\n\tconst tableReset = async (): Promise<void> => {\n\t\t// 重置到第一页\n\t\tstate.tablePagination.pageIndex = 1;\n\t\t// 清除搜索条件\n\t\tstate.searchParam = {};\n\t\tdefaultSearchTime();\n\t\t// 重置搜索表单的时候,如果有默认搜索参数,则重置默认的搜索参数\n\t\tif (typeof state.initParam === \"object\" && state.initParam !== null) {\n\t\t\tObject.assign(state.searchParam, state.initParam);\n\t\t}\n\t\temit(\"reset\", state.searchParam);\n\t\tawait loadData();\n\t};\n\n\tconst doRender = async (): Promise<void> => {\n\t\tstate.orgColumns = [];\n\t\tstate.autoColumnWidth = [];\n\t\tstate.tableData = [];\n\t\tawait renderTable();\n\t};\n\n\tconst doLoading = (loadingFunction: () => void | Promise<void>, loadingText = \"加载中...\"): void => {\n\t\tstate.loading = true;\n\t\tstate.loadingText = loadingText;\n\t\tvoid callOptionalFunction(loadingFunction).finally(() => {\n\t\t\tstate.loading = false;\n\t\t});\n\t};\n\n\tconst handleCustomCellClick = (\n\t\temitName: string,\n\t\t{ row, column, $index }: { row: DefaultRow; column: FaTableColumnCtx; $index: number }\n\t): void => {\n\t\temit(\"customCellClick\", emitName, { row, column, $index, ...getTableDefaultSlots(state) });\n\t};\n\n\twatch(\n\t\t() => props.tableKey,\n\t\t() => doRender()\n\t);\n\n\twatch(\n\t\t() => props.searchForm,\n\t\t(newValue) => {\n\t\t\tstate.searchForm = newValue;\n\t\t}\n\t);\n\n\treturn {\n\t\t_globalSize,\n\t\tstate,\n\t\telementRef,\n\t\ttableRef,\n\t\thandleTableColumnAutoWidth,\n\t\tgetRequestParam,\n\t\tloadTableColumns,\n\t\thandleSizeChange,\n\t\thandlePaginationChange,\n\t\tdefaultSearchTime,\n\t\ttableSearch,\n\t\ttableReset,\n\t\tdoRender,\n\t\tdoLoading,\n\t\thandleCustomCellClick,\n\t};\n};\n"],"mappings":";;;;;;;;;AAeA,MAAa,gBAA4C,OAAO,YAAY;;AAE5E,MAAa,aAAgE,OAAO,SAAS;;;;;;;;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AAM,GAAG,CAAC,CAAC,OAAO,qBAAqB,CAAC;EACzH;CACD;CAEA,MAAM,cAAc,YAA2B;EAE9C,MAAM,gBAAgB,YAAY;EAClC,kBAAkB;EAClB,MAAM,SAAS;CAChB;CACA,MAAM,cAAc,eAA8B;EACjD,iBAAiB;EACjB,OAAO,YAAY;CACpB,GAAG,GAAG;CAEN,MAAM,aAAa,YAA2B;EAE7C,MAAM,gBAAgB,YAAY;EAElC,MAAM,cAAc,CAAC;EACrB,kBAAkB;EAElB,IAAI,OAAO,MAAM,cAAc,YAAY,MAAM,cAAc,MAC9D,OAAO,OAAO,MAAM,aAAa,MAAM,SAAS;EAEjD,KAAK,SAAS,MAAM,WAAW;EAC/B,MAAM,SAAS;CAChB;CAEA,MAAM,WAAW,YAA2B;EAC3C,MAAM,aAAa,CAAC;EACpB,MAAM,kBAAkB,CAAC;EACzB,MAAM,YAAY,CAAC;EACnB,MAAM,YAAY;CACnB;CAEA,MAAM,aAAa,iBAA6C,cAAc,aAAmB;EAChG,MAAM,UAAU;EAChB,MAAM,cAAc;EACpB,qBAA0B,eAAe,CAAC,CAAC,cAAc;GACxD,MAAM,UAAU;EACjB,CAAC;CACF;CAEA,MAAM,yBACL,UACA,EAAE,KAAK,QAAQ,aACL;EACV,KAAK,mBAAmB,UAAU;GAAE;GAAK;GAAQ;GAAQ,GAAG,qBAAqB,KAAK;EAAE,CAAC;CAC1F;CAEA,YACO,MAAM,gBACN,SAAS,CAChB;CAEA,YACO,MAAM,aACX,aAAa;EACb,MAAM,aAAa;CACpB,CACD;CAEA,OAAO;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD;AACD"}
@@ -1,4 +1,5 @@
1
1
  import type { PagedSortInput } from "../src/page.type";
2
+ import type { DefaultRow } from "../src/table.state";
2
3
  import type { FaTableColumnCtx, FaTableEnumColumnCtx, FaTableEnumColumnType } from "../src/table.type";
3
4
  /**
4
5
  * 表格工具类
@@ -14,7 +15,7 @@ export declare const tableUtil: {
14
15
  * @param {Object} row 当前行数据
15
16
  * @param {String} prop 当前 prop
16
17
  */
17
- handleRowAccordingToProp(row: Record<string, unknown>, prop: string): unknown;
18
+ handleRowAccordingToProp(row: DefaultRow, prop: string): unknown;
18
19
  /**
19
20
  * @description 处理 prop,当 prop 为多级嵌套时 ==> 返回最后一级 prop
20
21
  * @param {String} prop 当前 prop
@@ -34,7 +35,7 @@ export declare const tableUtil: {
34
35
  /**
35
36
  * 数组动态排序
36
37
  */
37
- arrayDynamicSort(sortList: PagedSortInput[]): (a: Record<string, unknown>, b: Record<string, unknown>) => number;
38
+ arrayDynamicSort(sortList: PagedSortInput[]): (a: DefaultRow, b: DefaultRow) => number;
38
39
  /**
39
40
  * 设置枚举
40
41
  */
@@ -1 +1 @@
1
- {"version":3,"file":"table.mjs","names":[],"sources":["../../../../src/components/table/utils/table.ts"],"sourcesContent":["import { isArray, isFunction, isString } from \"lodash-unified\";\nimport type { PagedSortInput } from \"../src/page.type\";\nimport type { FaTableColumnCtx, FaTableEnumColumnCtx, FaTableEnumColumnType } from \"../src/table.type\";\n\n/**\n * 表格工具类\n */\nexport const tableUtil = {\n\t/**\n\t * @description 处理无数据情况\n\t * @param {String} callValue 需要处理的值\n\t */\n\tformatValue(callValue: unknown): unknown {\n\t\t// 如果当前值为数组,使用 / 拼接(根据需求自定义)\n\t\tif (isArray(callValue)) return callValue.length ? callValue.join(` , `) : null;\n\t\treturn callValue;\n\t},\n\t/**\n\t * @description 处理 prop 为多级嵌套的情况(列如: prop:user.name)\n\t * @param {Object} row 当前行数据\n\t * @param {String} prop 当前 prop\n\t */\n\thandleRowAccordingToProp(row: Record<string, unknown>, prop: string): unknown {\n\t\tlet value: unknown = row;\n\t\tfor (const item of prop.split(\".\")) {\n\t\t\tif (typeof value !== \"object\" || value === null) return undefined;\n\t\t\tvalue = (value as Record<string, unknown>)[item];\n\t\t}\n\t\treturn value;\n\t},\n\t/**\n\t * @description 处理 prop,当 prop 为多级嵌套时 ==> 返回最后一级 prop\n\t * @param {String} prop 当前 prop\n\t */\n\thandleProp(prop: string): string {\n\t\tconst propArr = prop.split(\".\");\n\t\tif (propArr.length === 1) return prop;\n\t\treturn propArr.at(-1) ?? prop;\n\t},\n\t/**\n\t * @description 根据枚举列表查询当需要的数据(如果指定了 label 和 value 的 key值,会自动识别格式化)\n\t * @param {String} callValue 当前单元格值\n\t * @param {Array} enumData 字典列表\n\t * @param {Array} fieldNames 指定 label && value 的 key 值\n\t * @param {String} type 过滤类型(目前只有 tag)\n\t */\n\tfilterEnum(callValue: unknown, enumData: FaTableEnumColumnCtx[], fieldNames?: { label: string; value: string }, type?: \"tag\"): unknown {\n\t\tconst value = fieldNames?.value ?? \"value\";\n\t\tconst label = fieldNames?.label ?? \"label\";\n\t\tlet filterData: FaTableEnumColumnCtx | undefined;\n\t\tif (isArray(enumData)) {\n\t\t\tfilterData = enumData.find((item) => (item as unknown as Record<string, unknown>)[value] === callValue);\n\t\t}\n\t\tif (type === \"tag\") {\n\t\t\treturn filterData?.type ?? \"info\";\n\t\t}\n\t\treturn filterData ? (filterData as unknown as Record<string, unknown>)[label] : null;\n\t},\n\t/**\n\t * 数组动态排序\n\t */\n\tarrayDynamicSort(sortList: PagedSortInput[]): (a: Record<string, unknown>, b: Record<string, unknown>) => number {\n\t\treturn (a, b) => {\n\t\t\tif (sortList && sortList.length > 0) {\n\t\t\t\tfor (const condition of sortList) {\n\t\t\t\t\tconst property = condition.enField;\n\t\t\t\t\tconst order = condition.mode;\n\t\t\t\t\tif (!property) continue;\n\n\t\t\t\t\tconst aValue = a[property];\n\t\t\t\t\tconst bValue = b[property];\n\n\t\t\t\t\tif (typeof aValue === \"string\" && typeof bValue === \"string\") {\n\t\t\t\t\t\tif (order === \"ascending\") {\n\t\t\t\t\t\t\tconst comparison = aValue.localeCompare(bValue, \"zh-CN\");\n\t\t\t\t\t\t\tif (comparison !== 0) {\n\t\t\t\t\t\t\t\treturn comparison;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (order === \"descending\") {\n\t\t\t\t\t\t\tconst comparison = bValue.localeCompare(aValue, \"zh-CN\");\n\t\t\t\t\t\t\tif (comparison !== 0) {\n\t\t\t\t\t\t\t\treturn comparison;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (typeof aValue === \"number\" && typeof bValue === \"number\") {\n\t\t\t\t\t\tif (order === \"ascending\") {\n\t\t\t\t\t\t\tif (aValue < bValue) return -1;\n\t\t\t\t\t\t\tif (aValue > bValue) return 1;\n\t\t\t\t\t\t} else if (order === \"descending\") {\n\t\t\t\t\t\t\tif (aValue > bValue) return -1;\n\t\t\t\t\t\t\tif (aValue < bValue) return 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn 0;\n\t\t};\n\t},\n\t/**\n\t * 设置枚举\n\t */\n\tsetEnumMap(columnEnum: FaTableEnumColumnType, prop: string, enumMap: Map<string, FaTableEnumColumnCtx[]>): void {\n\t\tif (!columnEnum) return;\n\t\tif (isFunction(columnEnum)) {\n\t\t\tenumMap.set(prop, columnEnum());\n\t\t} else if (isArray(columnEnum)) {\n\t\t\tenumMap.set(prop, columnEnum);\n\t\t}\n\t},\n\t/**\n\t * 扁平化 columns\n\t */\n\tflatColumns(columns: FaTableColumnCtx[], enumMap?: Map<string, FaTableEnumColumnCtx[]>): FaTableColumnCtx[] {\n\t\tconst flatArr: FaTableColumnCtx[] = [];\n\t\tcolumns.forEach((col) => {\n\t\t\tif (col._children?.length) {\n\t\t\t\tflatArr.push(...this.flatColumns(col._children));\n\t\t\t}\n\n\t\t\tflatArr.push(col);\n\n\t\t\t// 给每一项 column 添加 show && filterEnum 默认属性\n\t\t\tcol.show ??= true;\n\t\t\t// col.filterEnum = col.filterEnum ?? col.tag ?? false;\n\n\t\t\tlet enumKey = col.prop ?? col.search?.key;\n\n\t\t\tif (col.enum && isString(col.enum)) {\n\t\t\t\tenumKey = col.enum;\n\t\t\t}\n\n\t\t\t// 设置 enumMap\n\t\t\tif (col.enum && enumKey && enumMap) this.setEnumMap(col.enum, enumKey, enumMap);\n\t\t});\n\t\treturn flatArr.filter((item) => !item._children?.length);\n\t},\n};\n"],"mappings":";;;;;AAOA,MAAa,YAAY;;;;;CAKxB,YAAY,WAA6B;EAExC,IAAI,QAAQ,SAAS,GAAG,OAAO,UAAU,SAAS,UAAU,KAAK,KAAK,IAAI;EAC1E,OAAO;CACR;;;;;;CAMA,yBAAyB,KAA8B,MAAuB;EAC7E,IAAI,QAAiB;EACrB,KAAK,MAAM,QAAQ,KAAK,MAAM,GAAG,GAAG;GACnC,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO,KAAA;GACxD,QAAS,MAAkC;EAC5C;EACA,OAAO;CACR;;;;;CAKA,WAAW,MAAsB;EAChC,MAAM,UAAU,KAAK,MAAM,GAAG;EAC9B,IAAI,QAAQ,WAAW,GAAG,OAAO;EACjC,OAAO,QAAQ,GAAG,EAAE,KAAK;CAC1B;;;;;;;;CAQA,WAAW,WAAoB,UAAkC,YAA+C,MAAuB;EACtI,MAAM,QAAQ,YAAY,SAAS;EACnC,MAAM,QAAQ,YAAY,SAAS;EACnC,IAAI;EACJ,IAAI,QAAQ,QAAQ,GACnB,aAAa,SAAS,MAAM,SAAU,KAA4C,WAAW,SAAS;EAEvG,IAAI,SAAS,OACZ,OAAO,YAAY,QAAQ;EAE5B,OAAO,aAAc,WAAkD,SAAS;CACjF;;;;CAIA,iBAAiB,UAAgG;EAChH,QAAQ,GAAG,MAAM;GAChB,IAAI,YAAY,SAAS,SAAS,GACjC,KAAK,MAAM,aAAa,UAAU;IACjC,MAAM,WAAW,UAAU;IAC3B,MAAM,QAAQ,UAAU;IACxB,IAAI,CAAC,UAAU;IAEf,MAAM,SAAS,EAAE;IACjB,MAAM,SAAS,EAAE;IAEjB,IAAI,OAAO,WAAW,YAAY,OAAO,WAAW,UAAU;KAC7D,IAAI,UAAU,aAAa;MAC1B,MAAM,aAAa,OAAO,cAAc,QAAQ,OAAO;MACvD,IAAI,eAAe,GAClB,OAAO;KAET,OAAO,IAAI,UAAU,cAAc;MAClC,MAAM,aAAa,OAAO,cAAc,QAAQ,OAAO;MACvD,IAAI,eAAe,GAClB,OAAO;KAET;IACD,OAAO,IAAI,OAAO,WAAW,YAAY,OAAO,WAAW,UAAU;KACpE,IAAI,UAAU,aAAa;MAC1B,IAAI,SAAS,QAAQ,OAAO;MAC5B,IAAI,SAAS,QAAQ,OAAO;KAC7B,OAAO,IAAI,UAAU,cAAc;MAClC,IAAI,SAAS,QAAQ,OAAO;MAC5B,IAAI,SAAS,QAAQ,OAAO;KAC7B;IACD;GACD;GAGD,OAAO;EACR;CACD;;;;CAIA,WAAW,YAAmC,MAAc,SAAoD;EAC/G,IAAI,CAAC,YAAY;EACjB,IAAI,WAAW,UAAU,GACxB,QAAQ,IAAI,MAAM,WAAW,CAAC;OACxB,IAAI,QAAQ,UAAU,GAC5B,QAAQ,IAAI,MAAM,UAAU;CAE9B;;;;CAIA,YAAY,SAA6B,SAAmE;EAC3G,MAAM,UAA8B,CAAC;EACrC,QAAQ,SAAS,QAAQ;GACxB,IAAI,IAAI,WAAW,QAClB,QAAQ,KAAK,GAAG,KAAK,YAAY,IAAI,SAAS,CAAC;GAGhD,QAAQ,KAAK,GAAG;GAGhB,IAAI,SAAS;GAGb,IAAI,UAAU,IAAI,QAAQ,IAAI,QAAQ;GAEtC,IAAI,IAAI,QAAQ,SAAS,IAAI,IAAI,GAChC,UAAU,IAAI;GAIf,IAAI,IAAI,QAAQ,WAAW,SAAS,KAAK,WAAW,IAAI,MAAM,SAAS,OAAO;EAC/E,CAAC;EACD,OAAO,QAAQ,QAAQ,SAAS,CAAC,KAAK,WAAW,MAAM;CACxD;AACD"}
1
+ {"version":3,"file":"table.mjs","names":[],"sources":["../../../../src/components/table/utils/table.ts"],"sourcesContent":["import { isArray, isFunction, isString } from \"lodash-unified\";\nimport type { PagedSortInput } from \"../src/page.type\";\nimport type { DefaultRow } from \"../src/table.state\";\nimport type { FaTableColumnCtx, FaTableEnumColumnCtx, FaTableEnumColumnType } from \"../src/table.type\";\n\n/**\n * 表格工具类\n */\nexport const tableUtil = {\n\t/**\n\t * @description 处理无数据情况\n\t * @param {String} callValue 需要处理的值\n\t */\n\tformatValue(callValue: unknown): unknown {\n\t\t// 如果当前值为数组,使用 / 拼接(根据需求自定义)\n\t\tif (isArray(callValue)) return callValue.length ? callValue.join(` , `) : null;\n\t\treturn callValue;\n\t},\n\t/**\n\t * @description 处理 prop 为多级嵌套的情况(列如: prop:user.name)\n\t * @param {Object} row 当前行数据\n\t * @param {String} prop 当前 prop\n\t */\n\thandleRowAccordingToProp(row: DefaultRow, prop: string): unknown {\n\t\tlet value: unknown = row;\n\t\tfor (const item of prop.split(\".\")) {\n\t\t\tif (typeof value !== \"object\" || value === null) return undefined;\n\t\t\tvalue = (value as Record<string, unknown>)[item];\n\t\t}\n\t\treturn value;\n\t},\n\t/**\n\t * @description 处理 prop,当 prop 为多级嵌套时 ==> 返回最后一级 prop\n\t * @param {String} prop 当前 prop\n\t */\n\thandleProp(prop: string): string {\n\t\tconst propArr = prop.split(\".\");\n\t\tif (propArr.length === 1) return prop;\n\t\treturn propArr.at(-1) ?? prop;\n\t},\n\t/**\n\t * @description 根据枚举列表查询当需要的数据(如果指定了 label 和 value 的 key值,会自动识别格式化)\n\t * @param {String} callValue 当前单元格值\n\t * @param {Array} enumData 字典列表\n\t * @param {Array} fieldNames 指定 label && value 的 key 值\n\t * @param {String} type 过滤类型(目前只有 tag)\n\t */\n\tfilterEnum(callValue: unknown, enumData: FaTableEnumColumnCtx[], fieldNames?: { label: string; value: string }, type?: \"tag\"): unknown {\n\t\tconst value = fieldNames?.value ?? \"value\";\n\t\tconst label = fieldNames?.label ?? \"label\";\n\t\tlet filterData: FaTableEnumColumnCtx | undefined;\n\t\tif (isArray(enumData)) {\n\t\t\tfilterData = enumData.find((item) => item[value] === callValue);\n\t\t}\n\t\tif (type === \"tag\") {\n\t\t\treturn filterData?.type ?? \"info\";\n\t\t}\n\t\treturn filterData ? filterData[label] : null;\n\t},\n\t/**\n\t * 数组动态排序\n\t */\n\tarrayDynamicSort(sortList: PagedSortInput[]): (a: DefaultRow, b: DefaultRow) => number {\n\t\treturn (a, b) => {\n\t\t\tif (sortList && sortList.length > 0) {\n\t\t\t\tfor (const condition of sortList) {\n\t\t\t\t\tconst property = condition.enField;\n\t\t\t\t\tconst order = condition.mode;\n\t\t\t\t\tif (!property) continue;\n\n\t\t\t\t\tconst aValue: unknown = a[property];\n\t\t\t\t\tconst bValue: unknown = b[property];\n\n\t\t\t\t\tif (typeof aValue === \"string\" && typeof bValue === \"string\") {\n\t\t\t\t\t\tif (order === \"ascending\") {\n\t\t\t\t\t\t\tconst comparison = aValue.localeCompare(bValue, \"zh-CN\");\n\t\t\t\t\t\t\tif (comparison !== 0) {\n\t\t\t\t\t\t\t\treturn comparison;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t} else if (order === \"descending\") {\n\t\t\t\t\t\t\tconst comparison = bValue.localeCompare(aValue, \"zh-CN\");\n\t\t\t\t\t\t\tif (comparison !== 0) {\n\t\t\t\t\t\t\t\treturn comparison;\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t}\n\t\t\t\t\t} else if (typeof aValue === \"number\" && typeof bValue === \"number\") {\n\t\t\t\t\t\tif (order === \"ascending\") {\n\t\t\t\t\t\t\tif (aValue < bValue) return -1;\n\t\t\t\t\t\t\tif (aValue > bValue) return 1;\n\t\t\t\t\t\t} else if (order === \"descending\") {\n\t\t\t\t\t\t\tif (aValue > bValue) return -1;\n\t\t\t\t\t\t\tif (aValue < bValue) return 1;\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn 0;\n\t\t};\n\t},\n\t/**\n\t * 设置枚举\n\t */\n\tsetEnumMap(columnEnum: FaTableEnumColumnType, prop: string, enumMap: Map<string, FaTableEnumColumnCtx[]>): void {\n\t\tif (!columnEnum) return;\n\t\tif (isFunction(columnEnum)) {\n\t\t\tenumMap.set(prop, columnEnum());\n\t\t} else if (isArray(columnEnum)) {\n\t\t\tenumMap.set(prop, columnEnum);\n\t\t}\n\t},\n\t/**\n\t * 扁平化 columns\n\t */\n\tflatColumns(columns: FaTableColumnCtx[], enumMap?: Map<string, FaTableEnumColumnCtx[]>): FaTableColumnCtx[] {\n\t\tconst flatArr: FaTableColumnCtx[] = [];\n\t\tcolumns.forEach((col) => {\n\t\t\tif (col._children?.length) {\n\t\t\t\tflatArr.push(...this.flatColumns(col._children));\n\t\t\t}\n\n\t\t\tflatArr.push(col);\n\n\t\t\t// 给每一项 column 添加 show && filterEnum 默认属性\n\t\t\tcol.show ??= true;\n\t\t\t// col.filterEnum = col.filterEnum ?? col.tag ?? false;\n\n\t\t\tlet enumKey = col.prop ?? col.search?.key;\n\n\t\t\tif (col.enum && isString(col.enum)) {\n\t\t\t\tenumKey = col.enum;\n\t\t\t}\n\n\t\t\t// 设置 enumMap\n\t\t\tif (col.enum && enumKey && enumMap) this.setEnumMap(col.enum, enumKey, enumMap);\n\t\t});\n\t\treturn flatArr.filter((item) => !item._children?.length);\n\t},\n};\n"],"mappings":";;;;;AAQA,MAAa,YAAY;;;;;CAKxB,YAAY,WAA6B;EAExC,IAAI,QAAQ,SAAS,GAAG,OAAO,UAAU,SAAS,UAAU,KAAK,KAAK,IAAI;EAC1E,OAAO;CACR;;;;;;CAMA,yBAAyB,KAAiB,MAAuB;EAChE,IAAI,QAAiB;EACrB,KAAK,MAAM,QAAQ,KAAK,MAAM,GAAG,GAAG;GACnC,IAAI,OAAO,UAAU,YAAY,UAAU,MAAM,OAAO,KAAA;GACxD,QAAS,MAAkC;EAC5C;EACA,OAAO;CACR;;;;;CAKA,WAAW,MAAsB;EAChC,MAAM,UAAU,KAAK,MAAM,GAAG;EAC9B,IAAI,QAAQ,WAAW,GAAG,OAA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AAQ,UAAU,GAC5B,QAAQ,IAAI,MAAM,UAAU;CAE9B;;;;CAIA,YAAY,SAA6B,SAAmE;EAC3G,MAAM,UAA8B,CAAC;EACrC,QAAQ,SAAS,QAAQ;GACxB,IAAI,IAAI,WAAW,QAClB,QAAQ,KAAK,GAAG,KAAK,YAAY,IAAI,SAAS,CAAC;GAGhD,QAAQ,KAAK,GAAG;GAGhB,IAAI,SAAS;GAGb,IAAI,UAAU,IAAI,QAAQ,IAAI,QAAQ;GAEtC,IAAI,IAAI,QAAQ,SAAS,IAAI,IAAI,GAChC,UAAU,IAAI;GAIf,IAAI,IAAI,QAAQ,WAAW,SAAS,KAAK,WAAW,IAAI,MAAM,SAAS,OAAO;EAC/E,CAAC;EACD,OAAO,QAAQ,QAAQ,SAAS,CAAC,KAAK,WAAW,MAAM;CACxD;AACD"}
@@ -1,6 +1,6 @@
1
1
  import Tree, { faTreeEmits, faTreeProps } from "./src/tree";
2
- import type { TSXWithInstall } from "../../utils";
3
2
  import type { ExtractPropTypes } from "vue";
3
+ import type { TSXWithInstall } from "../../utils";
4
4
  /** 支持远程加载、筛选和节点操作的树组件。 */
5
5
  export declare const FaTree: TSXWithInstall<typeof Tree>;
6
6
  export default FaTree;
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["Tree"],"sources":["../../../src/components/tree/index.ts"],"sourcesContent":["import { withInstall } from \"../../utils\";\nimport Tree, { faTreeEmits, faTreeProps } from \"./src/tree\";\nimport type { TSXWithInstall } from \"../../utils\";\nimport type { ExtractPropTypes } from \"vue\";\n\n/** 支持远程加载、筛选和节点操作的树组件。 */\nexport const FaTree: TSXWithInstall<typeof Tree> = withInstall(Tree);\nexport default FaTree;\n\nexport { faTreeProps, faTreeEmits };\nexport type { FaTreeSlots } from \"./src/tree\";\nexport * from \"./src/tree.type\";\n\n/** FaTree 暴露的组件实例类型。 */\nexport type FaTreeInstance = InstanceType<typeof Tree>;\n\n/** FaTree 的完整 Props 类型。 */\nexport type FaTreeProps = ExtractPropTypes<typeof faTreeProps>;\n\n/** FaTree 的 Emits 类型。 */\nexport type FaTreeEmits = typeof faTreeEmits;\n"],"mappings":";;;;AAMA,MAAa,SAAsC,YAAYA,YAAI"}
1
+ {"version":3,"file":"index.mjs","names":["Tree"],"sources":["../../../src/components/tree/index.ts"],"sourcesContent":["import { withInstall } from \"../../utils\";\nimport Tree, { faTreeEmits, faTreeProps } from \"./src/tree\";\nimport type { ExtractPropTypes } from \"vue\";\nimport type { TSXWithInstall } from \"../../utils\";\n\n/** 支持远程加载、筛选和节点操作的树组件。 */\nexport const FaTree: TSXWithInstall<typeof Tree> = withInstall(Tree);\nexport default FaTree;\n\nexport { faTreeProps, faTreeEmits };\nexport type { FaTreeSlots } from \"./src/tree\";\nexport * from \"./src/tree.type\";\n\n/** FaTree 暴露的组件实例类型。 */\nexport type FaTreeInstance = InstanceType<typeof Tree>;\n\n/** FaTree 的完整 Props 类型。 */\nexport type FaTreeProps = ExtractPropTypes<typeof faTreeProps>;\n\n/** FaTree 的 Emits 类型。 */\nexport type FaTreeEmits = typeof faTreeEmits;\n"],"mappings":";;;;AAMA,MAAa,SAAsC,YAAYA,YAAI"}
@@ -1,6 +1,8 @@
1
+ import type { FilterValue, TreeNodeData } from "element-plus";
2
+ import type { ComponentInternalInstance } from "vue";
3
+ import type { PagedInput } from "../../table";
1
4
  import type { FilterNodeMethodFunction, TreeNode } from "./tree.props";
2
5
  import type { ElTreeOutput } from "./tree.type";
3
- import type { ComponentInternalInstance } from "vue";
4
6
  /** FaTree 的运行时 Props 定义。 */
5
7
  export declare const faTreeProps: {
6
8
  /** 树节点筛选方法。 */
@@ -63,15 +65,15 @@ export declare const faTreeProps: {
63
65
  };
64
66
  /** @description 树形数据 */
65
67
  data: {
66
- type: import("vue").PropType<ElTreeOutput<import("./tree.type").ElTreeValue>[]>;
68
+ type: import("vue").PropType<ElTreeOutput<import("./tree.type").ElTreeValue, any>[]>;
67
69
  default: () => ElTreeOutput[];
68
70
  };
69
71
  /** @description 请求api */
70
72
  requestApi: {
71
- type: import("vue").PropType<(params?: unknown) => Promise<ElTreeOutput[]>>;
73
+ type: import("vue").PropType<(params?: string | number | PagedInput) => Promise<ElTreeOutput[]>>;
72
74
  };
73
75
  /** 初始化参数 */
74
- initParam: import("vue").PropType<unknown>;
76
+ initParam: import("vue").PropType<string | number | PagedInput>;
75
77
  emptyText: {
76
78
  readonly type: import("vue").PropType<string>;
77
79
  readonly required: false;
@@ -244,15 +246,15 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
244
246
  };
245
247
  /** @description 树形数据 */
246
248
  data: {
247
- type: import("vue").PropType<ElTreeOutput<import("./tree.type").ElTreeValue>[]>;
249
+ type: import("vue").PropType<ElTreeOutput<import("./tree.type").ElTreeValue, any>[]>;
248
250
  default: () => ElTreeOutput[];
249
251
  };
250
252
  /** @description 请求api */
251
253
  requestApi: {
252
- type: import("vue").PropType<(params?: unknown) => Promise<ElTreeOutput[]>>;
254
+ type: import("vue").PropType<(params?: string | number | PagedInput) => Promise<ElTreeOutput[]>>;
253
255
  };
254
256
  /** 初始化参数 */
255
- initParam: import("vue").PropType<unknown>;
257
+ initParam: import("vue").PropType<string | number | PagedInput>;
256
258
  emptyText: {
257
259
  readonly type: import("vue").PropType<string>;
258
260
  readonly required: false;
@@ -325,15 +327,15 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
325
327
  };
326
328
  }>, {
327
329
  /** @description 过滤所有树节点,过滤后的节点将被隐藏 */
328
- filter: import("vue").ComputedRef<((value: import("element-plus").FilterValue) => void) | undefined>;
330
+ filter: import("vue").ComputedRef<((value: FilterValue) => void) | undefined>;
329
331
  /** @description 获取节点的唯一标识。 */
330
332
  getNodeKey: import("vue").ComputedRef<((node: import("element-plus/es/components/tree/src/model/node.mjs").default) => any) | undefined>;
331
333
  /** @description 获取指定节点的路径数据。 */
332
- getNodePath: import("vue").ComputedRef<((data: import("element-plus").TreeKey | import("element-plus").TreeNodeData) => import("element-plus").TreeNodeData[]) | undefined>;
334
+ getNodePath: import("vue").ComputedRef<((data: import("element-plus").TreeKey | TreeNodeData) => TreeNodeData[]) | undefined>;
333
335
  /** @description 为节点设置新数据,只有当设置 node-key 属性的时候才可用 */
334
336
  updateKeyChildren: import("vue").ComputedRef<((key: import("element-plus").TreeKey, data: import("element-plus").TreeData) => void) | undefined>;
335
337
  /** @description 如果节点可以被选中,(show-checkbox 为 true), 本方法将返回当前选中节点的数组 */
336
- getCheckedNodes: import("vue").ComputedRef<((leafOnly?: boolean, includeHalfChecked?: boolean) => import("element-plus").TreeNodeData[]) | undefined>;
338
+ getCheckedNodes: import("vue").ComputedRef<((leafOnly?: boolean, includeHalfChecked?: boolean) => TreeNodeData[]) | undefined>;
337
339
  /** @description 设置目前勾选的节点,使用此方法必须提前设置 node-key 属性 */
338
340
  setCheckedNodes: import("vue").ComputedRef<((nodes: import("element-plus/es/components/tree/src/model/node.mjs").default[], leafOnly?: boolean) => void) | undefined>;
339
341
  /** @description 若节点可用被选中 (show-checkbox 为 true), 它将返回当前选中节点 key 的数组 */
@@ -341,29 +343,29 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
341
343
  /** @description 设置目前选中的节点,使用此方法必须设置 node-key 属性 */
342
344
  setCheckedKeys: import("vue").ComputedRef<((keys: import("element-plus").TreeKey[], leafOnly?: boolean) => void) | undefined>;
343
345
  /** @description 设置节点是否被选中, 使用此方法必须设置 node-key 属性 */
344
- setChecked: import("vue").ComputedRef<((data: import("element-plus").TreeKey | import("element-plus").TreeNodeData, checked: boolean, deep?: boolean) => void) | undefined>;
346
+ setChecked: import("vue").ComputedRef<((data: import("element-plus").TreeKey | TreeNodeData, checked: boolean, deep?: boolean) => void) | undefined>;
345
347
  /** @description 如果节点可用被选中 (show-checkbox 为 true), 它将返回当前半选中的节点组成的数组 */
346
- getHalfCheckedNodes: import("vue").ComputedRef<(() => import("element-plus").TreeNodeData[]) | undefined>;
348
+ getHalfCheckedNodes: import("vue").ComputedRef<(() => TreeNodeData[]) | undefined>;
347
349
  /** @description 若节点可被选中(show-checkbox 为 true),则返回目前半选中的节点的 key 所组成的数组 */
348
350
  getHalfCheckedKeys: import("vue").ComputedRef<(() => import("element-plus").TreeKey[]) | undefined>;
349
351
  /** @description 返回当前被选中节点的数据 (如果没有则返回 null) */
350
352
  getCurrentKey: import("vue").ComputedRef<(() => import("element-plus").TreeKey | null) | undefined>;
351
353
  /** @description 返回当前被选中节点的数据 (如果没有则返回 null) */
352
- getCurrentNode: import("vue").ComputedRef<(() => import("element-plus").TreeNodeData | null) | undefined>;
354
+ getCurrentNode: import("vue").ComputedRef<(() => TreeNodeData | null) | undefined>;
353
355
  /** @description 通过 key 设置某个节点的当前选中状态,使用此方法必须设置 node-key 属性 */
354
356
  setCurrentKey: import("vue").ComputedRef<((key?: import("element-plus").TreeKey | null, shouldAutoExpandParent?: boolean) => void) | undefined>;
355
357
  /** @description 设置节点为选中状态,使用此方法必须设置 node-key 属性 */
356
358
  setCurrentNode: import("vue").ComputedRef<((node: import("element-plus/es/components/tree/src/model/node.mjs").default, shouldAutoExpandParent?: boolean) => void) | undefined>;
357
359
  /** @description 根据 data 或者 key 拿到 Tree 组件中的 node */
358
- getNode: import("vue").ComputedRef<((data: import("element-plus").TreeKey | import("element-plus").TreeNodeData) => import("element-plus/es/components/tree/src/model/node.mjs").default) | undefined>;
360
+ getNode: import("vue").ComputedRef<((data: import("element-plus").TreeKey | TreeNodeData) => import("element-plus/es/components/tree/src/model/node.mjs").default) | undefined>;
359
361
  /** @description 删除 Tree 中的一个节点,使用此方法必须设置 node-key 属性 */
360
- remove: import("vue").ComputedRef<((data: import("element-plus").TreeNodeData | import("element-plus/es/components/tree/src/model/node.mjs").default) => void) | undefined>;
362
+ remove: import("vue").ComputedRef<((data: TreeNodeData | import("element-plus/es/components/tree/src/model/node.mjs").default) => void) | undefined>;
361
363
  /** @description 为 Tree 中的一个节点追加一个子节点 */
362
- append: import("vue").ComputedRef<((data: import("element-plus").TreeNodeData, parentNode: import("element-plus").TreeNodeData | import("element-plus").TreeKey | import("element-plus/es/components/tree/src/model/node.mjs").default) => void) | undefined>;
364
+ append: import("vue").ComputedRef<((data: TreeNodeData, parentNode: TreeNodeData | import("element-plus").TreeKey | import("element-plus/es/components/tree/src/model/node.mjs").default) => void) | undefined>;
363
365
  /** @description 在 Tree 中给定节点前插入一个节点 */
364
- insertBefore: import("vue").ComputedRef<((data: import("element-plus").TreeNodeData, refNode: import("element-plus").TreeKey | import("element-plus").TreeNodeData | import("element-plus/es/components/tree/src/model/node.mjs").default) => void) | undefined>;
366
+ insertBefore: import("vue").ComputedRef<((data: TreeNodeData, refNode: import("element-plus").TreeKey | TreeNodeData | import("element-plus/es/components/tree/src/model/node.mjs").default) => void) | undefined>;
365
367
  /** @description 在 Tree 中给定节点后插入一个节点 */
366
- insertAfter: import("vue").ComputedRef<((data: import("element-plus").TreeNodeData, refNode: import("element-plus").TreeKey | import("element-plus").TreeNodeData | import("element-plus/es/components/tree/src/model/node.mjs").default) => void) | undefined>;
368
+ insertAfter: import("vue").ComputedRef<((data: TreeNodeData, refNode: import("element-plus").TreeKey | TreeNodeData | import("element-plus/es/components/tree/src/model/node.mjs").default) => void) | undefined>;
367
369
  /** @description 加载状态 */
368
370
  loading: import("vue").ComputedRef<boolean>;
369
371
  /** @description 刷新 */
@@ -452,15 +454,15 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
452
454
  };
453
455
  /** @description 树形数据 */
454
456
  data: {
455
- type: import("vue").PropType<ElTreeOutput<import("./tree.type").ElTreeValue>[]>;
457
+ type: import("vue").PropType<ElTreeOutput<import("./tree.type").ElTreeValue, any>[]>;
456
458
  default: () => ElTreeOutput[];
457
459
  };
458
460
  /** @description 请求api */
459
461
  requestApi: {
460
- type: import("vue").PropType<(params?: unknown) => Promise<ElTreeOutput[]>>;
462
+ type: import("vue").PropType<(params?: string | number | PagedInput) => Promise<ElTreeOutput[]>>;
461
463
  };
462
464
  /** 初始化参数 */
463
- initParam: import("vue").PropType<unknown>;
465
+ initParam: import("vue").PropType<string | number | PagedInput>;
464
466
  emptyText: {
465
467
  readonly type: import("vue").PropType<string>;
466
468
  readonly required: false;
@@ -532,12 +534,12 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
532
534
  __epPropKey: true;
533
535
  };
534
536
  }>> & Readonly<{
535
- onChange?: ((_data: ElTreeOutput<import("./tree.type").ElTreeValue>, _node: TreeNode, _instance: ComponentInternalInstance, _event: MouseEvent) => any) | undefined;
537
+ onChange?: ((_data: ElTreeOutput<import("./tree.type").ElTreeValue, any>, _node: TreeNode, _instance: ComponentInternalInstance, _event: MouseEvent) => any) | undefined;
536
538
  "onUpdate:modelValue"?: ((value: string | number | boolean | object | null) => any) | undefined;
537
539
  "onCurrent-change"?: ((data: any, node: import("element-plus/es/components/tree/src/model/node.mjs").default | null) => any) | undefined;
538
540
  "onUpdate:label"?: ((value: string) => any) | undefined;
539
- onDataChangeCallBack?: ((data: ElTreeOutput<import("./tree.type").ElTreeValue>[]) => any) | undefined;
540
- "onNode-click"?: ((_data: ElTreeOutput<import("./tree.type").ElTreeValue>, _node: TreeNode, _instance: ComponentInternalInstance, _event: MouseEvent) => any) | undefined;
541
+ onDataChangeCallBack?: ((data: ElTreeOutput<import("./tree.type").ElTreeValue, any>[]) => any) | undefined;
542
+ "onNode-click"?: ((_data: ElTreeOutput<import("./tree.type").ElTreeValue, any>, _node: TreeNode, _instance: ComponentInternalInstance, _event: MouseEvent) => any) | undefined;
541
543
  "onCheck-change"?: ((data: any, checked: boolean, indeterminate: boolean) => any) | undefined;
542
544
  "onNode-contextmenu"?: ((evt: Event, data: any, node: import("element-plus/es/components/tree/src/model/node.mjs").default, nodeInstance: ComponentInternalInstance | null) => any) | undefined;
543
545
  "onNode-collapse"?: ((data: any, node: import("element-plus/es/components/tree/src/model/node.mjs").default, nodeInstance: ComponentInternalInstance | null) => any) | undefined;
@@ -550,7 +552,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
550
552
  "onNode-drag-enter"?: ((draggingNode: import("element-plus/es/components/tree/src/model/node.mjs").default, dropNode: import("element-plus/es/components/tree/src/model/node.mjs").default, evt: DragEvent) => any) | undefined;
551
553
  "onNode-drag-over"?: ((draggingNode: import("element-plus/es/components/tree/src/model/node.mjs").default, dropNode: import("element-plus/es/components/tree/src/model/node.mjs").default, evt: DragEvent) => any) | undefined;
552
554
  }>, {
553
- data: ElTreeOutput<import("./tree.type").ElTreeValue>[];
555
+ data: ElTreeOutput<import("./tree.type").ElTreeValue, any>[];
554
556
  props: import("element-plus").TreeOptionProps;
555
557
  disabled: boolean;
556
558
  modelValue: string | number | boolean | object | null;
@@ -187,7 +187,9 @@ var tree_default = defineComponent({
187
187
  };
188
188
  const handleFilterNode = (value, data, child) => {
189
189
  if (!value) return true;
190
- let parentNode = child.parent, labels = data["all"] ? [data["label"]] : [child.label], level = 1;
190
+ const isAll = data["all"];
191
+ const dataLabel = data["label"];
192
+ let parentNode = child.parent, labels = isAll ? [dataLabel] : [child.label], level = 1;
191
193
  while (level < child.level && parentNode) {
192
194
  labels = [...labels, parentNode.label];
193
195
  parentNode = parentNode.parent;
@@ -1 +1 @@
1
- {"version":3,"file":"tree.mjs","names":["update:modelValue","update:label","node-click"],"sources":["../../../../src/components/tree/src/tree.tsx"],"sourcesContent":["import { useVModel } from \"@vueuse/core\";\nimport { computed, defineComponent, nextTick, onMounted, reactive, ref, watch } from \"vue\";\nimport { Expand, Fold } from \"@element-plus/icons-vue\";\nimport { ElIcon, ElInput, ElScrollbar, ElTree, treeEmits, treeProps, useGlobalSize } from \"element-plus\";\nimport { isArray, isBoolean, isNull, isNumber, isObject, isString } from \"lodash-unified\";\nimport { addCssUnit, definePropType, makeSlots, useEmits, useExpose, useProps, useRender, withDefineType } from \"../../../utils\";\nimport type { FilterNodeMethodFunction, FilterValue, TreeNode, TreeNodeData } from \"./tree.props\";\nimport type { ElTreeOutput } from \"./tree.type\";\nimport type { ComponentInternalInstance, VNode } from \"vue\";\n\n/** FaTree 的运行时 Props 定义。 */\nexport const faTreeProps = {\n\t...treeProps,\n\t/** 树节点筛选方法。 */\n\tfilterNodeMethod: {\n\t\ttype: definePropType<FilterNodeMethodFunction>(Function),\n\t},\n\t/** @description whether Select is disabled 重载使其支持 ElForm*/\n\tdisabled: {\n\t\ttype: Boolean,\n\t\tdefault: undefined,\n\t},\n\t/** 每个树节点用来作为唯一标识的属性,整棵树应该是唯一的 */\n\tnodeKey: {\n\t\ttype: String,\n\t\tdefault: \"value\",\n\t},\n\t/** @description 是否默认展开所有节点 */\n\tdefaultExpandAll: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t},\n\t/** @description 是否在点击节点的时候选中节点 */\n\tcheckOnClickNode: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t},\n\t/** @description 是否高亮当前选中节点 */\n\thighlightCurrent: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t},\n\t/** @description 点击折叠节点,需要开启 'expandOnClickNode' */\n\tcollapseOnClickNode: Boolean,\n\t/** @description v-model绑定值 */\n\tmodelValue: {\n\t\ttype: definePropType<string | number | boolean | object | null>([String, Number, Boolean, Object]),\n\t\tdefault: undefined,\n\t},\n\t/** @description v-model:label绑定值 */\n\tlabel: String,\n\t/** @description 宽度 */\n\twidth: {\n\t\ttype: [String, Number],\n\t\tdefault: 180,\n\t},\n\t/** @description 默认选择 */\n\tdefaultSelection: [String, Number],\n\t/** @description 标题 */\n\ttitle: String,\n\t/** @description 折叠 */\n\thamburger: Boolean,\n\t/** @description 隐藏全部 */\n\thideAll: Boolean,\n\t/** @description 隐藏过滤 */\n\thideFilter: Boolean,\n\t/** @description 全部值 */\n\tallValue: {\n\t\ttype: definePropType<string | number | boolean | object | null>([String, Number, Boolean, Object]),\n\t\tdefault: \"\",\n\t},\n\t/** @description 树形数据 */\n\tdata: {\n\t\ttype: definePropType<ElTreeOutput[]>(Array),\n\t\tdefault: (): ElTreeOutput[] => [],\n\t},\n\t/** @description 请求api */\n\trequestApi: {\n\t\ttype: definePropType<(params?: unknown) => Promise<ElTreeOutput[]>>(Function),\n\t},\n\t/** 初始化参数 */\n\tinitParam: definePropType<unknown>([String, Number, Object]),\n};\n\n/** FaTree 的运行时 Emits 定义。 */\nexport const faTreeEmits = {\n\t...treeEmits,\n\t/** @description v-model 回调 */\n\t\"update:modelValue\": (value: string | number | boolean | object | null): boolean =>\n\t\tisString(value) || isNumber(value) || isBoolean(value) || isObject(value) || isNull(value),\n\t/** @description v-model:label 回调 */\n\t\"update:label\": (value: string): boolean => isString(value) || isNull(value),\n\t/** @description 数据改变 */\n\tdataChangeCallBack: (data: ElTreeOutput[]): boolean => isArray(data),\n\t/** @description 改变 */\n\tchange: (_data: ElTreeOutput, _node: TreeNode, _instance: ComponentInternalInstance, _event: MouseEvent): boolean => true,\n\t/** @description 节点点击 */\n\t\"node-click\": (_data: ElTreeOutput, _node: TreeNode, _instance: ComponentInternalInstance, _event: MouseEvent): boolean => true,\n};\n\n/** FaTree 的插槽参数。 */\nexport interface FaTreeSlots extends Record<string, unknown> {\n\t/** @description 默认内容插槽 */\n\tdefault: { node: TreeNode; data: ElTreeOutput };\n\t/** @description 当数据为空时自定义的内容 */\n\tempty: never;\n\t/** @description 显示内容插槽 */\n\tlabel: { node: TreeNode; data: ElTreeOutput };\n}\n\nexport default defineComponent({\n\tname: \"FaTree\",\n\tprops: faTreeProps,\n\temits: faTreeEmits,\n\tslots: makeSlots<FaTreeSlots>(),\n\tsetup(props, { slots, emit, expose }) {\n\t\tconst selectedLabel = useVModel(props, \"label\", emit, { passive: true });\n\t\tconst _globalSize = useGlobalSize();\n\n\t\tconst state = reactive({\n\t\t\tvalue: withDefineType<string | number | boolean | object | null>(props.modelValue),\n\t\t\tloading: false,\n\t\t\tsearchValue: withDefineType<string>(),\n\t\t\torgTreeData: withDefineType<ElTreeOutput[]>([]),\n\t\t\ttreeData: withDefineType<ElTreeOutput[]>([]),\n\t\t\thamburger: props.hamburger || false,\n\t\t\twidth: computed(() => {\n\t\t\t\tif (state.hamburger) {\n\t\t\t\t\treturn \"130px\";\n\t\t\t\t} else {\n\t\t\t\t\tconst width = addCssUnit(props.width);\n\t\t\t\t\tif (_globalSize.value === \"small\") {\n\t\t\t\t\t\treturn `calc(${width} * 0.9)`;\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn width;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}),\n\t\t});\n\n\t\t/** @description 只有一层节点 */\n\t\tconst fold = computed<boolean>(() => {\n\t\t\tconst childrenKey = props.props.children ?? \"children\";\n\t\t\treturn state.orgTreeData.every((item) => !Array.isArray(item[childrenKey]) || item[childrenKey].length === 0);\n\t\t});\n\n\t\tconst treeRef = ref<InstanceType<typeof ElTree>>();\n\t\tlet requestVersion = 0;\n\n\t\tconst loadData = async (): Promise<void> => {\n\t\t\tconst currentRequestVersion = ++requestVersion;\n\t\t\tlet curSelectedData: string | number | undefined;\n\t\t\tif (props.nodeKey) {\n\t\t\t\t// 记录原本选中的值\n\t\t\t\tconst currentKey: unknown = treeRef.value?.getCurrentKey();\n\t\t\t\tif (typeof currentKey === \"string\" || typeof currentKey === \"number\") curSelectedData = currentKey;\n\t\t\t}\n\t\t\tlet treeData: ElTreeOutput[];\n\t\t\t// 判断是否需要自动请求\n\t\t\tif (props.requestApi) {\n\t\t\t\tstate.loading = true;\n\t\t\t\tconst params = {\n\t\t\t\t\t...(typeof props.initParam === \"object\" && props.initParam !== null ? props.initParam : {}),\n\t\t\t\t\tsearchValue: state.searchValue,\n\t\t\t\t};\n\t\t\t\ttry {\n\t\t\t\t\tconst responseData = await props.requestApi(params);\n\t\t\t\t\ttreeData = responseData.map((item) => ({ ...item }));\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (currentRequestVersion !== requestVersion) return;\n\t\t\t\t\tthrow error;\n\t\t\t\t} finally {\n\t\t\t\t\tif (currentRequestVersion === requestVersion) state.loading = false;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttreeData = props.data.map((item) => ({ ...item }));\n\t\t\t}\n\t\t\tif (currentRequestVersion !== requestVersion) return;\n\t\t\tif (!props.hideAll) {\n\t\t\t\ttreeData.unshift({ [props.nodeKey]: props.allValue, label: \"全部\", value: null, all: true });\n\t\t\t}\n\t\t\tstate.orgTreeData = treeData;\n\t\t\tstate.treeData = treeData;\n\t\t\temit(\"dataChangeCallBack\", state.treeData);\n\t\t\tconst selectedKey = curSelectedData ?? props.modelValue ?? props.defaultSelection;\n\t\t\tif (props.nodeKey && (typeof selectedKey === \"string\" || typeof selectedKey === \"number\")) {\n\t\t\t\tvoid nextTick(() => {\n\t\t\t\t\t// 设置原本选中的值\n\t\t\t\t\ttreeRef.value?.setCurrentKey(selectedKey);\n\t\t\t\t});\n\t\t\t}\n\t\t};\n\n\t\tconst handleHamburgerClick = (): void => {\n\t\t\tif (state.hamburger) {\n\t\t\t\tstate.treeData = state.orgTreeData;\n\t\t\t} else {\n\t\t\t\t// 折叠只显示一级数据\n\t\t\t\tstate.treeData = state.orgTreeData.map((item) => ({ ...item, [props.props.children ?? \"children\"]: [] }));\n\t\t\t}\n\t\t\tstate.hamburger = !state.hamburger;\n\t\t};\n\n\t\tconst handleFilterNode = (value: FilterValue, data: TreeNodeData, child: TreeNode): boolean => {\n\t\t\tif (!value) return true;\n\t\t\tlet parentNode = child.parent,\n\t\t\t\tlabels = data[\"all\"] ? [data[\"label\"]] : [child.label],\n\t\t\t\tlevel = 1;\n\t\t\twhile (level < child.level && parentNode) {\n\t\t\t\tlabels = [...labels, parentNode.label];\n\t\t\t\tparentNode = parentNode.parent;\n\t\t\t\tlevel++;\n\t\t\t}\n\t\t\tconst filterText = typeof value === \"string\" || typeof value === \"number\" ? String(value) : \"\";\n\t\t\tconst result = labels.some((label) =>\n\t\t\t\ttypeof label === \"string\" || typeof label === \"number\" ? String(label).includes(filterText) : false\n\t\t\t);\n\t\t\tif (props.filterNodeMethod) {\n\t\t\t\treturn result && props.filterNodeMethod(value, data, child);\n\t\t\t}\n\t\t\treturn result;\n\t\t};\n\n\t\tconst handleNodeClick = (data: ElTreeOutput, node: TreeNode, instance: ComponentInternalInstance | null, event: MouseEvent): void => {\n\t\t\tif (!instance) return;\n\t\t\t// 判断是否开启点击展开节点,并且节点是折叠状态,则自动展开,否则需要点击箭头图标才能折叠或开启 'collapseOnClickNode'\n\t\t\tif (props.expandOnClickNode) {\n\t\t\t\tif (!node.expanded) {\n\t\t\t\t\tnode.expand();\n\t\t\t\t} else if (node.expanded && props.collapseOnClickNode) {\n\t\t\t\t\tnode.collapse();\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!data[\"all\"] && (node.key === undefined || node.key === null)) return;\n\t\t\tstate.value = data[\"all\"] ? (props.allValue ?? null) : (node.key ?? null);\n\t\t\tselectedLabel.value = node.label;\n\t\t\temit(\"update:modelValue\", state.value);\n\t\t\temit(\"change\", data, node, instance, event);\n\t\t\temit(\"node-click\", data, node, instance, event);\n\t\t};\n\n\t\tonMounted(async () => {\n\t\t\tawait loadData();\n\t\t\twatch(\n\t\t\t\t() => props.data,\n\t\t\t\t() => {\n\t\t\t\t\tif (!props.requestApi) {\n\t\t\t\t\t\treturn loadData();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{ deep: true }\n\t\t\t);\n\t\t});\n\n\t\twatch(\n\t\t\t() => props.modelValue,\n\t\t\t(newValue) => {\n\t\t\t\tstate.value = newValue ?? null;\n\t\t\t\tif (typeof newValue === \"string\" || typeof newValue === \"number\") treeRef.value?.setCurrentKey(newValue);\n\t\t\t}\n\t\t);\n\n\t\tconst elTreeProps = useProps(props, treeProps, [\"data\", \"expandOnClickNode\", \"filterNodeMethod\"]);\n\t\tconst elTreeEmits = useEmits(treeEmits, emit, [\"node-click\"]);\n\n\t\tuseRender(() => (\n\t\t\t<div\n\t\t\t\tclass={[\"el-card fa-tree\", `fa-tree-${_globalSize.value}`, { \"fa-tree__fold\": state.hamburger || fold.value }]}\n\t\t\t\tstyle={{ width: state.width }}\n\t\t\t\tvLoading={state.loading}\n\t\t\t>\n\t\t\t\t{(props.title !== undefined || props.hamburger) && (\n\t\t\t\t\t<div class=\"fa-tree__title\">\n\t\t\t\t\t\t{props.title && <h4>{props.title}</h4>}\n\t\t\t\t\t\t{props.hamburger &&\n\t\t\t\t\t\t\t(state.hamburger ? (\n\t\t\t\t\t\t\t\t<ElIcon onClick={handleHamburgerClick} title=\"展开\">\n\t\t\t\t\t\t\t\t\t<Expand />\n\t\t\t\t\t\t\t\t</ElIcon>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<ElIcon onClick={handleHamburgerClick} title=\"折叠\">\n\t\t\t\t\t\t\t\t\t<Fold />\n\t\t\t\t\t\t\t\t</ElIcon>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t\t{!props.hideFilter && (\n\t\t\t\t\t<ElInput\n\t\t\t\t\t\tclass=\"fa-tree__search-input\"\n\t\t\t\t\t\tvModel_trim={state.searchValue}\n\t\t\t\t\t\tplaceholder={state.hamburger ? \"关键字过滤\" : \"输入关键字进行过滤\"}\n\t\t\t\t\t\tclearable={Boolean(state.searchValue)}\n\t\t\t\t\t\tonInput={(value) => treeRef.value?.filter(value)}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t<ElScrollbar class=\"fa-tree__scrollbar\">\n\t\t\t\t\t<ElTree\n\t\t\t\t\t\t{...elTreeProps.value}\n\t\t\t\t\t\t{...elTreeEmits.value}\n\t\t\t\t\t\tref={treeRef}\n\t\t\t\t\t\tdata={state.treeData}\n\t\t\t\t\t\texpandOnClickNode={props.checkOnClickNode ? false : props.expandOnClickNode}\n\t\t\t\t\t\tfilterNodeMethod={handleFilterNode}\n\t\t\t\t\t\tonNode-click={handleNodeClick}\n\t\t\t\t\t>\n\t\t\t\t\t\t{{\n\t\t\t\t\t\t\tdefault: ({ node, data }: { node: TreeNode; data: ElTreeOutput }) => (\n\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\tclass=\"el-tree-node__label\"\n\t\t\t\t\t\t\t\t\ttitle={data[\"all\"] ? data.label : node.label}\n\t\t\t\t\t\t\t\t\tstyle={{ paddingLeft: fold.value ? \"3px\" : \"\" }}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<div>{data[\"all\"] ? data.label : slots.label ? slots.label({ node, data }) : node.label}</div>\n\t\t\t\t\t\t\t\t\t{node.key && data.showQuantity ? <span>[{data.quantity}]</span> : null}\n\t\t\t\t\t\t\t\t\t{!data[\"all\"] && slots.default && <span>{slots.default({ node, data })}</span>}\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t...(slots.empty && { empty: (): VNode[] => slots.empty?.() ?? [] }),\n\t\t\t\t\t\t}}\n\t\t\t\t\t</ElTree>\n\t\t\t\t</ElScrollbar>\n\t\t\t</div>\n\t\t));\n\n\t\treturn useExpose(expose, {\n\t\t\t/** @description 过滤所有树节点,过滤后的节点将被隐藏 */\n\t\t\tfilter: computed(() => treeRef.value?.filter),\n\t\t\t/** @description 获取节点的唯一标识。 */\n\t\t\tgetNodeKey: computed(() => treeRef.value?.getNodeKey),\n\t\t\t/** @description 获取指定节点的路径数据。 */\n\t\t\tgetNodePath: computed(() => treeRef.value?.getNodePath),\n\t\t\t/** @description 为节点设置新数据,只有当设置 node-key 属性的时候才可用 */\n\t\t\tupdateKeyChildren: computed(() => treeRef.value?.updateKeyChildren),\n\t\t\t/** @description 如果节点可以被选中,(show-checkbox 为 true), 本方法将返回当前选中节点的数组 */\n\t\t\tgetCheckedNodes: computed(() => treeRef.value?.getCheckedNodes),\n\t\t\t/** @description 设置目前勾选的节点,使用此方法必须提前设置 node-key 属性 */\n\t\t\tsetCheckedNodes: computed(() => treeRef.value?.setCheckedNodes),\n\t\t\t/** @description \t若节点可用被选中 (show-checkbox 为 true), 它将返回当前选中节点 key 的数组 */\n\t\t\tgetCheckedKeys: computed(() => treeRef.value?.getCheckedKeys),\n\t\t\t/** @description 设置目前选中的节点,使用此方法必须设置 node-key 属性 */\n\t\t\tsetCheckedKeys: computed(() => treeRef.value?.setCheckedKeys),\n\t\t\t/** @description 设置节点是否被选中, 使用此方法必须设置 node-key 属性 */\n\t\t\tsetChecked: computed(() => treeRef.value?.setChecked),\n\t\t\t/** @description 如果节点可用被选中 (show-checkbox 为 true), 它将返回当前半选中的节点组成的数组 */\n\t\t\tgetHalfCheckedNodes: computed(() => treeRef.value?.getHalfCheckedNodes),\n\t\t\t/** @description 若节点可被选中(show-checkbox 为 true),则返回目前半选中的节点的 key 所组成的数组 */\n\t\t\tgetHalfCheckedKeys: computed(() => treeRef.value?.getHalfCheckedKeys),\n\t\t\t/** @description 返回当前被选中节点的数据 (如果没有则返回 null) */\n\t\t\tgetCurrentKey: computed(() => treeRef.value?.getCurrentKey),\n\t\t\t/** @description 返回当前被选中节点的数据 (如果没有则返回 null) */\n\t\t\tgetCurrentNode: computed(() => treeRef.value?.getCurrentNode),\n\t\t\t/** @description 通过 key 设置某个节点的当前选中状态,使用此方法必须设置 node-key 属性 */\n\t\t\tsetCurrentKey: computed(() => treeRef.value?.setCurrentKey),\n\t\t\t/** @description 设置节点为选中状态,使用此方法必须设置 node-key 属性 */\n\t\t\tsetCurrentNode: computed(() => treeRef.value?.setCurrentNode),\n\t\t\t/** @description 根据 data 或者 key 拿到 Tree 组件中的 node */\n\t\t\tgetNode: computed(() => treeRef.value?.getNode),\n\t\t\t/** @description 删除 Tree 中的一个节点,使用此方法必须设置 node-key 属性 */\n\t\t\tremove: computed(() => treeRef.value?.remove),\n\t\t\t/** @description 为 Tree 中的一个节点追加一个子节点 */\n\t\t\tappend: computed(() => treeRef.value?.append),\n\t\t\t/** @description 在 Tree 中给定节点前插入一个节点 */\n\t\t\tinsertBefore: computed(() => treeRef.value?.insertBefore),\n\t\t\t/** @description 在 Tree 中给定节点后插入一个节点 */\n\t\t\tinsertAfter: computed(() => treeRef.value?.insertAfter),\n\t\t\t/** @description 加载状态 */\n\t\t\tloading: computed(() => state.loading),\n\t\t\t/** @description 刷新 */\n\t\t\trefresh: loadData,\n\t\t});\n\t},\n});\n"],"mappings":";;;;;;;;;;;;;;AAWA,MAAa,cAAc;CAC1B,GAAG;;CAEH,kBAAkB,EACjB,MAAM,eAAyC,QAAQ,EACxD;;CAEA,UAAU;EACT,MAAM;EACN,SAAS,KAAA;CACV;;CAEA,SAAS;EACR,MAAM;EACN,SAAS;CACV;;CAEA,kBAAkB;EACjB,MAAM;EACN,SAAS;CACV;;CAEA,kBAAkB;EACjB,MAAM;EACN,SAAS;CACV;;CAEA,kBAAkB;EACjB,MAAM;EACN,SAAS;CACV;;CAEA,qBAAqB;;CAErB,YAAY;EACX,MAAM,eAA0D;GAAC;GAAQ;GAAQ;GAAS;EAAM,CAAC;EACjG,SAAS,KAAA;CACV;;CAEA,OAAO;;CAEP,OAAO;EACN,MAAM,CAAC,QAAQ,MAAM;EACrB,SAAS;CACV;;CAEA,kBAAkB,CAAC,QAAQ,MAAM;;CAEjC,OAAO;;CAEP,WAAW;;CAEX,SAAS;;CAET,YAAY;;CAEZ,UAAU;EACT,MAAM,eAA0D;GAAC;GAAQ;GAAQ;GAAS;EAAM,CAAC;EACjG,SAAS;CACV;;CAEA,MAAM;EACL,MAAM,eAA+B,KAAK;EAC1C,eAA+B,CAAA;CAChC;;CAEA,YAAY,EACX,MAAM,eAA8D,QAAQ,EAC7E;;CAEA,WAAW,eAAwB;EAAC;EAAQ;EAAQ;CAAM,CAAC;AAC5D;;AAGA,MAAa,cAAc;CAC1B,GAAG;;CAEH,sBAAsB,UACrB,SAAS,KAAK,KAAK,SAAS,KAAK,KAAK,UAAU,KAAK,KAAK,SAAS,KAAK,KAAK,OAAO,KAAK;;CAE1F,iBAAiB,UAA2B,SAAS,KAAK,KAAK,OAAO,KAAK;;CAE3E,qBAAqB,SAAkC,QAAQ,IAAI;;CAEnE,SAAS,OAAqB,OAAiB,WAAsC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AAe,MAAM,OAAO;;GAErC,SAAS;EACV,CAAC;CACF;AACD,CAAC"}
1
+ {"version":3,"file":"tree.mjs","names":["update:modelValue","update:label","node-click"],"sources":["../../../../src/components/tree/src/tree.tsx"],"sourcesContent":["import { useVModel } from \"@vueuse/core\";\nimport { computed, defineComponent, nextTick, onMounted, reactive, ref, watch } from \"vue\";\nimport { Expand, Fold } from \"@element-plus/icons-vue\";\nimport { ElIcon, ElInput, ElScrollbar, ElTree, treeEmits, treeProps, useGlobalSize } from \"element-plus\";\nimport { isArray, isBoolean, isNull, isNumber, isObject, isString } from \"lodash-unified\";\nimport { addCssUnit, definePropType, makeSlots, useEmits, useExpose, useProps, useRender, withDefineType } from \"../../../utils\";\nimport type { FilterValue, TreeNodeData } from \"element-plus\";\nimport type { ComponentInternalInstance, VNode } from \"vue\";\nimport type { PagedInput } from \"../../table\";\nimport type { FilterNodeMethodFunction, TreeNode } from \"./tree.props\";\nimport type { ElTreeOutput } from \"./tree.type\";\n\n/** FaTree 的运行时 Props 定义。 */\nexport const faTreeProps = {\n\t...treeProps,\n\t/** 树节点筛选方法。 */\n\tfilterNodeMethod: {\n\t\ttype: definePropType<FilterNodeMethodFunction>(Function),\n\t},\n\t/** @description whether Select is disabled 重载使其支持 ElForm*/\n\tdisabled: {\n\t\ttype: Boolean,\n\t\tdefault: undefined,\n\t},\n\t/** 每个树节点用来作为唯一标识的属性,整棵树应该是唯一的 */\n\tnodeKey: {\n\t\ttype: String,\n\t\tdefault: \"value\",\n\t},\n\t/** @description 是否默认展开所有节点 */\n\tdefaultExpandAll: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t},\n\t/** @description 是否在点击节点的时候选中节点 */\n\tcheckOnClickNode: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t},\n\t/** @description 是否高亮当前选中节点 */\n\thighlightCurrent: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t},\n\t/** @description 点击折叠节点,需要开启 'expandOnClickNode' */\n\tcollapseOnClickNode: Boolean,\n\t/** @description v-model绑定值 */\n\tmodelValue: {\n\t\ttype: definePropType<string | number | boolean | object | null>([String, Number, Boolean, Object]),\n\t\tdefault: undefined,\n\t},\n\t/** @description v-model:label绑定值 */\n\tlabel: String,\n\t/** @description 宽度 */\n\twidth: {\n\t\ttype: [String, Number],\n\t\tdefault: 180,\n\t},\n\t/** @description 默认选择 */\n\tdefaultSelection: [String, Number],\n\t/** @description 标题 */\n\ttitle: String,\n\t/** @description 折叠 */\n\thamburger: Boolean,\n\t/** @description 隐藏全部 */\n\thideAll: Boolean,\n\t/** @description 隐藏过滤 */\n\thideFilter: Boolean,\n\t/** @description 全部值 */\n\tallValue: {\n\t\ttype: definePropType<string | number | boolean | object | null>([String, Number, Boolean, Object]),\n\t\tdefault: \"\",\n\t},\n\t/** @description 树形数据 */\n\tdata: {\n\t\ttype: definePropType<ElTreeOutput[]>(Array),\n\t\tdefault: (): ElTreeOutput[] => [],\n\t},\n\t/** @description 请求api */\n\trequestApi: {\n\t\ttype: definePropType<(params?: string | number | PagedInput) => Promise<ElTreeOutput[]>>(Function),\n\t},\n\t/** 初始化参数 */\n\tinitParam: definePropType<string | number | PagedInput>([String, Number, Object]),\n};\n\n/** FaTree 的运行时 Emits 定义。 */\nexport const faTreeEmits = {\n\t...treeEmits,\n\t/** @description v-model 回调 */\n\t\"update:modelValue\": (value: string | number | boolean | object | null): boolean =>\n\t\tisString(value) || isNumber(value) || isBoolean(value) || isObject(value) || isNull(value),\n\t/** @description v-model:label 回调 */\n\t\"update:label\": (value: string): boolean => isString(value) || isNull(value),\n\t/** @description 数据改变 */\n\tdataChangeCallBack: (data: ElTreeOutput[]): boolean => isArray(data),\n\t/** @description 改变 */\n\tchange: (_data: ElTreeOutput, _node: TreeNode, _instance: ComponentInternalInstance, _event: MouseEvent): boolean => true,\n\t/** @description 节点点击 */\n\t\"node-click\": (_data: ElTreeOutput, _node: TreeNode, _instance: ComponentInternalInstance, _event: MouseEvent): boolean => true,\n};\n\n/** FaTree 的插槽参数。 */\nexport interface FaTreeSlots extends Record<string, unknown> {\n\t/** @description 默认内容插槽 */\n\tdefault: { node: TreeNode; data: ElTreeOutput };\n\t/** @description 当数据为空时自定义的内容 */\n\tempty: never;\n\t/** @description 显示内容插槽 */\n\tlabel: { node: TreeNode; data: ElTreeOutput };\n}\n\nexport default defineComponent({\n\tname: \"FaTree\",\n\tprops: faTreeProps,\n\temits: faTreeEmits,\n\tslots: makeSlots<FaTreeSlots>(),\n\tsetup(props, { slots, emit, expose }) {\n\t\tconst selectedLabel = useVModel(props, \"label\", emit, { passive: true });\n\t\tconst _globalSize = useGlobalSize();\n\n\t\tconst state = reactive({\n\t\t\tvalue: withDefineType<string | number | boolean | object | null>(props.modelValue),\n\t\t\tloading: false,\n\t\t\tsearchValue: withDefineType<string>(),\n\t\t\torgTreeData: withDefineType<ElTreeOutput[]>([]),\n\t\t\ttreeData: withDefineType<ElTreeOutput[]>([]),\n\t\t\thamburger: props.hamburger || false,\n\t\t\twidth: computed(() => {\n\t\t\t\tif (state.hamburger) {\n\t\t\t\t\treturn \"130px\";\n\t\t\t\t} else {\n\t\t\t\t\tconst width = addCssUnit(props.width);\n\t\t\t\t\tif (_globalSize.value === \"small\") {\n\t\t\t\t\t\treturn `calc(${width} * 0.9)`;\n\t\t\t\t\t} else {\n\t\t\t\t\t\treturn width;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}),\n\t\t});\n\n\t\t/** @description 只有一层节点 */\n\t\tconst fold = computed<boolean>(() => {\n\t\t\tconst childrenKey = props.props.children ?? \"children\";\n\t\t\treturn state.orgTreeData.every((item) => !Array.isArray(item[childrenKey]) || item[childrenKey].length === 0);\n\t\t});\n\n\t\tconst treeRef = ref<InstanceType<typeof ElTree>>();\n\t\tlet requestVersion = 0;\n\n\t\tconst loadData = async (): Promise<void> => {\n\t\t\tconst currentRequestVersion = ++requestVersion;\n\t\t\tlet curSelectedData: string | number | undefined;\n\t\t\tif (props.nodeKey) {\n\t\t\t\t// 记录原本选中的值\n\t\t\t\tconst currentKey = treeRef.value?.getCurrentKey();\n\t\t\t\tif (typeof currentKey === \"string\" || typeof currentKey === \"number\") curSelectedData = currentKey;\n\t\t\t}\n\t\t\tlet treeData: ElTreeOutput[];\n\t\t\t// 判断是否需要自动请求\n\t\t\tif (props.requestApi) {\n\t\t\t\tstate.loading = true;\n\t\t\t\tconst params = {\n\t\t\t\t\t...(typeof props.initParam === \"object\" && props.initParam !== null ? props.initParam : {}),\n\t\t\t\t\tsearchValue: state.searchValue,\n\t\t\t\t};\n\t\t\t\ttry {\n\t\t\t\t\tconst responseData = await props.requestApi(params);\n\t\t\t\t\ttreeData = responseData.map((item) => ({ ...item }));\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (currentRequestVersion !== requestVersion) return;\n\t\t\t\t\tthrow error;\n\t\t\t\t} finally {\n\t\t\t\t\tif (currentRequestVersion === requestVersion) state.loading = false;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\ttreeData = props.data.map((item) => ({ ...item }));\n\t\t\t}\n\t\t\tif (currentRequestVersion !== requestVersion) return;\n\t\t\tif (!props.hideAll) {\n\t\t\t\ttreeData.unshift({ [props.nodeKey]: props.allValue, label: \"全部\", value: null, all: true });\n\t\t\t}\n\t\t\tstate.orgTreeData = treeData;\n\t\t\tstate.treeData = treeData;\n\t\t\temit(\"dataChangeCallBack\", state.treeData);\n\t\t\tconst selectedKey = curSelectedData ?? props.modelValue ?? props.defaultSelection;\n\t\t\tif (props.nodeKey && (typeof selectedKey === \"string\" || typeof selectedKey === \"number\")) {\n\t\t\t\tvoid nextTick(() => {\n\t\t\t\t\t// 设置原本选中的值\n\t\t\t\t\ttreeRef.value?.setCurrentKey(selectedKey);\n\t\t\t\t});\n\t\t\t}\n\t\t};\n\n\t\tconst handleHamburgerClick = (): void => {\n\t\t\tif (state.hamburger) {\n\t\t\t\tstate.treeData = state.orgTreeData;\n\t\t\t} else {\n\t\t\t\t// 折叠只显示一级数据\n\t\t\t\tstate.treeData = state.orgTreeData.map((item) => ({ ...item, [props.props.children ?? \"children\"]: [] }));\n\t\t\t}\n\t\t\tstate.hamburger = !state.hamburger;\n\t\t};\n\n\t\tconst handleFilterNode = (value: FilterValue, data: TreeNodeData, child: TreeNode): boolean => {\n\t\t\tif (!value) return true;\n\t\t\tconst isAll: unknown = data[\"all\"];\n\t\t\tconst dataLabel: unknown = data[\"label\"];\n\t\t\tlet parentNode = child.parent,\n\t\t\t\tlabels: unknown[] = isAll ? [dataLabel] : [child.label],\n\t\t\t\tlevel = 1;\n\t\t\twhile (level < child.level && parentNode) {\n\t\t\t\tlabels = [...labels, parentNode.label];\n\t\t\t\tparentNode = parentNode.parent;\n\t\t\t\tlevel++;\n\t\t\t}\n\t\t\tconst filterText = typeof value === \"string\" || typeof value === \"number\" ? String(value) : \"\";\n\t\t\tconst result = labels.some((label) =>\n\t\t\t\ttypeof label === \"string\" || typeof label === \"number\" ? String(label).includes(filterText) : false\n\t\t\t);\n\t\t\tif (props.filterNodeMethod) {\n\t\t\t\treturn result && props.filterNodeMethod(value, data, child);\n\t\t\t}\n\t\t\treturn result;\n\t\t};\n\n\t\tconst handleNodeClick = (data: ElTreeOutput, node: TreeNode, instance: ComponentInternalInstance | null, event: MouseEvent): void => {\n\t\t\tif (!instance) return;\n\t\t\t// 判断是否开启点击展开节点,并且节点是折叠状态,则自动展开,否则需要点击箭头图标才能折叠或开启 'collapseOnClickNode'\n\t\t\tif (props.expandOnClickNode) {\n\t\t\t\tif (!node.expanded) {\n\t\t\t\t\tnode.expand();\n\t\t\t\t} else if (node.expanded && props.collapseOnClickNode) {\n\t\t\t\t\tnode.collapse();\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (!data[\"all\"] && (node.key === undefined || node.key === null)) return;\n\t\t\tstate.value = data[\"all\"] ? (props.allValue ?? null) : (node.key ?? null);\n\t\t\tselectedLabel.value = node.label;\n\t\t\temit(\"update:modelValue\", state.value);\n\t\t\temit(\"change\", data, node, instance, event);\n\t\t\temit(\"node-click\", data, node, instance, event);\n\t\t};\n\n\t\tonMounted(async () => {\n\t\t\tawait loadData();\n\t\t\twatch(\n\t\t\t\t() => props.data,\n\t\t\t\t() => {\n\t\t\t\t\tif (!props.requestApi) {\n\t\t\t\t\t\treturn loadData();\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{ deep: true }\n\t\t\t);\n\t\t});\n\n\t\twatch(\n\t\t\t() => props.modelValue,\n\t\t\t(newValue) => {\n\t\t\t\tstate.value = newValue ?? null;\n\t\t\t\tif (typeof newValue === \"string\" || typeof newValue === \"number\") treeRef.value?.setCurrentKey(newValue);\n\t\t\t}\n\t\t);\n\n\t\tconst elTreeProps = useProps(props, treeProps, [\"data\", \"expandOnClickNode\", \"filterNodeMethod\"]);\n\t\tconst elTreeEmits = useEmits(treeEmits, emit, [\"node-click\"]);\n\n\t\tuseRender(() => (\n\t\t\t<div\n\t\t\t\tclass={[\"el-card fa-tree\", `fa-tree-${_globalSize.value}`, { \"fa-tree__fold\": state.hamburger || fold.value }]}\n\t\t\t\tstyle={{ width: state.width }}\n\t\t\t\tvLoading={state.loading}\n\t\t\t>\n\t\t\t\t{(props.title !== undefined || props.hamburger) && (\n\t\t\t\t\t<div class=\"fa-tree__title\">\n\t\t\t\t\t\t{props.title && <h4>{props.title}</h4>}\n\t\t\t\t\t\t{props.hamburger &&\n\t\t\t\t\t\t\t(state.hamburger ? (\n\t\t\t\t\t\t\t\t<ElIcon onClick={handleHamburgerClick} title=\"展开\">\n\t\t\t\t\t\t\t\t\t<Expand />\n\t\t\t\t\t\t\t\t</ElIcon>\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<ElIcon onClick={handleHamburgerClick} title=\"折叠\">\n\t\t\t\t\t\t\t\t\t<Fold />\n\t\t\t\t\t\t\t\t</ElIcon>\n\t\t\t\t\t\t\t))}\n\t\t\t\t\t</div>\n\t\t\t\t)}\n\t\t\t\t{!props.hideFilter && (\n\t\t\t\t\t<ElInput\n\t\t\t\t\t\tclass=\"fa-tree__search-input\"\n\t\t\t\t\t\tvModel_trim={state.searchValue}\n\t\t\t\t\t\tplaceholder={state.hamburger ? \"关键字过滤\" : \"输入关键字进行过滤\"}\n\t\t\t\t\t\tclearable={Boolean(state.searchValue)}\n\t\t\t\t\t\tonInput={(value) => treeRef.value?.filter(value)}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t\t<ElScrollbar class=\"fa-tree__scrollbar\">\n\t\t\t\t\t<ElTree\n\t\t\t\t\t\t{...elTreeProps.value}\n\t\t\t\t\t\t{...elTreeEmits.value}\n\t\t\t\t\t\tref={treeRef}\n\t\t\t\t\t\tdata={state.treeData}\n\t\t\t\t\t\texpandOnClickNode={props.checkOnClickNode ? false : props.expandOnClickNode}\n\t\t\t\t\t\tfilterNodeMethod={handleFilterNode}\n\t\t\t\t\t\tonNode-click={handleNodeClick}\n\t\t\t\t\t>\n\t\t\t\t\t\t{{\n\t\t\t\t\t\t\tdefault: ({ node, data }: { node: TreeNode; data: ElTreeOutput }) => (\n\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\tclass=\"el-tree-node__label\"\n\t\t\t\t\t\t\t\t\ttitle={data[\"all\"] ? data.label : node.label}\n\t\t\t\t\t\t\t\t\tstyle={{ paddingLeft: fold.value ? \"3px\" : \"\" }}\n\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t<div>{data[\"all\"] ? data.label : slots.label ? slots.label({ node, data }) : node.label}</div>\n\t\t\t\t\t\t\t\t\t{node.key && data.showQuantity ? <span>[{data.quantity}]</span> : null}\n\t\t\t\t\t\t\t\t\t{!data[\"all\"] && slots.default && <span>{slots.default({ node, data })}</span>}\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\t\t...(slots.empty && { empty: (): VNode[] => slots.empty?.() ?? [] }),\n\t\t\t\t\t\t}}\n\t\t\t\t\t</ElTree>\n\t\t\t\t</ElScrollbar>\n\t\t\t</div>\n\t\t));\n\n\t\treturn useExpose(expose, {\n\t\t\t/** @description 过滤所有树节点,过滤后的节点将被隐藏 */\n\t\t\tfilter: computed(() => treeRef.value?.filter),\n\t\t\t/** @description 获取节点的唯一标识。 */\n\t\t\tgetNodeKey: computed(() => treeRef.value?.getNodeKey),\n\t\t\t/** @description 获取指定节点的路径数据。 */\n\t\t\tgetNodePath: computed(() => treeRef.value?.getNodePath),\n\t\t\t/** @description 为节点设置新数据,只有当设置 node-key 属性的时候才可用 */\n\t\t\tupdateKeyChildren: computed(() => treeRef.value?.updateKeyChildren),\n\t\t\t/** @description 如果节点可以被选中,(show-checkbox 为 true), 本方法将返回当前选中节点的数组 */\n\t\t\tgetCheckedNodes: computed(() => treeRef.value?.getCheckedNodes),\n\t\t\t/** @description 设置目前勾选的节点,使用此方法必须提前设置 node-key 属性 */\n\t\t\tsetCheckedNodes: computed(() => treeRef.value?.setCheckedNodes),\n\t\t\t/** @description \t若节点可用被选中 (show-checkbox 为 true), 它将返回当前选中节点 key 的数组 */\n\t\t\tgetCheckedKeys: computed(() => treeRef.value?.getCheckedKeys),\n\t\t\t/** @description 设置目前选中的节点,使用此方法必须设置 node-key 属性 */\n\t\t\tsetCheckedKeys: computed(() => treeRef.value?.setCheckedKeys),\n\t\t\t/** @description 设置节点是否被选中, 使用此方法必须设置 node-key 属性 */\n\t\t\tsetChecked: computed(() => treeRef.value?.setChecked),\n\t\t\t/** @description 如果节点可用被选中 (show-checkbox 为 true), 它将返回当前半选中的节点组成的数组 */\n\t\t\tgetHalfCheckedNodes: computed(() => treeRef.value?.getHalfCheckedNodes),\n\t\t\t/** @description 若节点可被选中(show-checkbox 为 true),则返回目前半选中的节点的 key 所组成的数组 */\n\t\t\tgetHalfCheckedKeys: computed(() => treeRef.value?.getHalfCheckedKeys),\n\t\t\t/** @description 返回当前被选中节点的数据 (如果没有则返回 null) */\n\t\t\tgetCurrentKey: computed(() => treeRef.value?.getCurrentKey),\n\t\t\t/** @description 返回当前被选中节点的数据 (如果没有则返回 null) */\n\t\t\tgetCurrentNode: computed(() => treeRef.value?.getCurrentNode),\n\t\t\t/** @description 通过 key 设置某个节点的当前选中状态,使用此方法必须设置 node-key 属性 */\n\t\t\tsetCurrentKey: computed(() => treeRef.value?.setCurrentKey),\n\t\t\t/** @description 设置节点为选中状态,使用此方法必须设置 node-key 属性 */\n\t\t\tsetCurrentNode: computed(() => treeRef.value?.setCurrentNode),\n\t\t\t/** @description 根据 data 或者 key 拿到 Tree 组件中的 node */\n\t\t\tgetNode: computed(() => treeRef.value?.getNode),\n\t\t\t/** @description 删除 Tree 中的一个节点,使用此方法必须设置 node-key 属性 */\n\t\t\tremove: computed(() => treeRef.value?.remove),\n\t\t\t/** @description 为 Tree 中的一个节点追加一个子节点 */\n\t\t\tappend: computed(() => treeRef.value?.append),\n\t\t\t/** @description 在 Tree 中给定节点前插入一个节点 */\n\t\t\tinsertBefore: computed(() => treeRef.value?.insertBefore),\n\t\t\t/** @description 在 Tree 中给定节点后插入一个节点 */\n\t\t\tinsertAfter: computed(() => treeRef.value?.insertAfter),\n\t\t\t/** @description 加载状态 */\n\t\t\tloading: computed(() => state.loading),\n\t\t\t/** @description 刷新 */\n\t\t\trefresh: loadData,\n\t\t});\n\t},\n});\n"],"mappings":";;;;;;;;;;;;;;AAaA,MAAa,cAAc;CAC1B,GAAG;;CAEH,kBAAkB,EACjB,MAAM,eAAyC,QAAQ,EACxD;;CAEA,UAAU;EACT,MAAM;EACN,SAAS,KAAA;CACV;;CAEA,SAAS;EACR,MAAM;EACN,SAAS;CACV;;CAEA,kBAAkB;EACjB,MAAM;EACN,SAAS;CACV;;CAEA,kBAAkB;EACjB,MAAM;EACN,SAAS;CACV;;CAEA,kBAAkB;EACjB,MAAM;EACN,SAAS;CACV;;CAEA,qBAAqB;;CAErB,YAAY;EACX,MAAM,eAA0D;GAAC;GAAQ;GAAQ;GAAS;EAAM,CAAC;EACjG,SAAS,KAAA;CACV;;CAEA,OAAO;;CAEP,O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e,QAAQ,OAAO,iBAAiB;;GAElE,iBAAiB,eAAe,QAAQ,OAAO,eAAe;;GAE9D,iBAAiB,eAAe,QAAQ,OAAO,eAAe;;GAE9D,gBAAgB,eAAe,QAAQ,OAAO,cAAc;;GAE5D,gBAAgB,eAAe,QAAQ,OAAO,cAAc;;GAE5D,YAAY,eAAe,QAAQ,OAAO,UAAU;;GAEpD,qBAAqB,eAAe,QAAQ,OAAO,mBAAmB;;GAEtE,oBAAoB,eAAe,QAAQ,OAAO,kBAAkB;;GAEpE,eAAe,eAAe,QAAQ,OAAO,aAAa;;GAE1D,gBAAgB,eAAe,QAAQ,OAAO,cAAc;;GAE5D,eAAe,eAAe,QAAQ,OAAO,aAAa;;GAE1D,gBAAgB,eAAe,QAAQ,OAAO,cAAc;;GAE5D,SAAS,eAAe,QAAQ,OAAO,OAAO;;GAE9C,QAAQ,eAAe,QAAQ,OAAO,MAAM;;GAE5C,QAAQ,eAAe,QAAQ,OAAO,MAAM;;GAE5C,cAAc,eAAe,QAAQ,OAAO,YAAY;;GAExD,aAAa,eAAe,QAAQ,OAAO,WAAW;;GAEtD,SAAS,eAAe,MAAM,OAAO;;GAErC,SAAS;EACV,CAAC;CACF;AACD,CAAC"}
@@ -1,3 +1,4 @@
1
+ import type { FilterValue, TreeNodeData } from "element-plus";
1
2
  /** 树组件运行时节点公开使用的最小结构。 */
2
3
  export interface TreeNode {
3
4
  key?: string | number | null;
@@ -9,8 +10,6 @@ export interface TreeNode {
9
10
  expand: () => void;
10
11
  collapse: () => void;
11
12
  }
12
- /** 树节点的数据结构。 */
13
- export type TreeNodeData = Record<string, unknown>;
14
13
  /** 树组件的数据集合。 */
15
14
  export type TreeData = TreeNodeData[];
16
15
  /** 树节点的唯一键类型。 */
@@ -25,8 +24,6 @@ export interface TreeOptionProps {
25
24
  isLeaf?: string | ((data: TreeNodeData, node: TreeNode) => boolean);
26
25
  class?: (data: TreeNodeData, node: TreeNode) => string | Record<string, boolean>;
27
26
  }
28
- /** 树节点筛选值。 */
29
- export type FilterValue = unknown;
30
27
  /** 树节点筛选方法。 */
31
28
  export type FilterNodeMethodFunction = (value: FilterValue, data: TreeNodeData, child: TreeNode) => boolean;
32
29
  /** 树节点拖放位置。 */
@@ -1,7 +1,7 @@
1
1
  /** 树组件支持的节点值类型。 */
2
2
  export type ElTreeValue = string | number | boolean | object | null;
3
3
  /** 树组件标准化后的节点数据。 */
4
- export interface ElTreeOutput<T = ElTreeValue> {
4
+ export interface ElTreeOutput<T = ElTreeValue, Data = any> {
5
5
  /**
6
6
  * 显示
7
7
  */
@@ -13,7 +13,7 @@ export interface ElTreeOutput<T = ElTreeValue> {
13
13
  /**
14
14
  * 附加数据
15
15
  */
16
- data?: unknown;
16
+ data?: Data;
17
17
  /**
18
18
  * 是否隐藏
19
19
  */
@@ -25,7 +25,7 @@ export interface ElTreeOutput<T = ElTreeValue> {
25
25
  /**
26
26
  * 子节点
27
27
  */
28
- children?: ElTreeOutput<T>[];
28
+ children?: ElTreeOutput<T, Data>[];
29
29
  /**
30
30
  * 是否显示数量
31
31
  */
@@ -34,5 +34,5 @@ export interface ElTreeOutput<T = ElTreeValue> {
34
34
  * 数量
35
35
  */
36
36
  quantity?: number;
37
- [key: string]: unknown;
37
+ [key: string]: any;
38
38
  }
@@ -1,6 +1,6 @@
1
1
  import TreeSelect, { faTreeSelectEmits, faTreeSelectProps } from "./src/treeSelect";
2
- import type { TSXWithInstall } from "../../utils";
3
2
  import type { ExtractPropTypes } from "vue";
3
+ import type { TSXWithInstall } from "../../utils";
4
4
  /** 组合树结构浏览与选择交互的树选择器组件。 */
5
5
  export declare const FaTreeSelect: TSXWithInstall<typeof TreeSelect>;
6
6
  export default FaTreeSelect;
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["TreeSelect"],"sources":["../../../src/components/treeSelect/index.ts"],"sourcesContent":["import { withInstall } from \"../../utils\";\nimport TreeSelect, { faTreeSelectEmits, faTreeSelectProps } from \"./src/treeSelect\";\nimport type { TSXWithInstall } from \"../../utils\";\nimport type { ExtractPropTypes } from \"vue\";\n\n/** 组合树结构浏览与选择交互的树选择器组件。 */\nexport const FaTreeSelect: TSXWithInstall<typeof TreeSelect> = withInstall(TreeSelect);\nexport default FaTreeSelect;\n\nexport { faTreeSelectProps, faTreeSelectEmits };\nexport type { FaTreeSelectSlots } from \"./src/treeSelect\";\n\n/** FaTreeSelect 暴露的组件实例类型。 */\nexport type FaTreeSelectInstance = InstanceType<typeof TreeSelect>;\n\n/** FaTreeSelect 的完整 Props 类型。 */\nexport type FaTreeSelectProps = ExtractPropTypes<typeof faTreeSelectProps>;\n\n/** FaTreeSelect 的 Emits 类型。 */\nexport type FaTreeSelectEmits = typeof faTreeSelectEmits;\n"],"mappings":";;;;AAMA,MAAa,eAAkD,YAAYA,kBAAU"}
1
+ {"version":3,"file":"index.mjs","names":["TreeSelect"],"sources":["../../../src/components/treeSelect/index.ts"],"sourcesContent":["import { withInstall } from \"../../utils\";\nimport TreeSelect, { faTreeSelectEmits, faTreeSelectProps } from \"./src/treeSelect\";\nimport type { ExtractPropTypes } from \"vue\";\nimport type { TSXWithInstall } from \"../../utils\";\n\n/** 组合树结构浏览与选择交互的树选择器组件。 */\nexport const FaTreeSelect: TSXWithInstall<typeof TreeSelect> = withInstall(TreeSelect);\nexport default FaTreeSelect;\n\nexport { faTreeSelectProps, faTreeSelectEmits };\nexport type { FaTreeSelectSlots } from \"./src/treeSelect\";\n\n/** FaTreeSelect 暴露的组件实例类型。 */\nexport type FaTreeSelectInstance = InstanceType<typeof TreeSelect>;\n\n/** FaTreeSelect 的完整 Props 类型。 */\nexport type FaTreeSelectProps = ExtractPropTypes<typeof faTreeSelectProps>;\n\n/** FaTreeSelect 的 Emits 类型。 */\nexport type FaTreeSelectEmits = typeof faTreeSelectEmits;\n"],"mappings":";;;;AAMA,MAAa,eAAkD,YAAYA,kBAAU"}