fast-element-plus 2.0.15 → 2.0.17

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 (145) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/component.d.ts +6570 -2
  3. package/dist/component.mjs.map +1 -1
  4. package/dist/components/avatar/src/avatar.d.ts +19 -7
  5. package/dist/components/avatar/src/avatar.mjs +5 -0
  6. package/dist/components/avatar/src/avatar.mjs.map +1 -1
  7. package/dist/components/button/src/button.d.ts +4 -4
  8. package/dist/components/button/src/button.mjs +3 -4
  9. package/dist/components/button/src/button.mjs.map +1 -1
  10. package/dist/components/carNumber/src/carNumber.mjs +7 -9
  11. package/dist/components/carNumber/src/carNumber.mjs.map +1 -1
  12. package/dist/components/contextMenu/index.d.ts +1 -1
  13. package/dist/components/contextMenu/index.mjs.map +1 -1
  14. package/dist/components/contextMenu/src/contextMenu.d.ts +2 -2
  15. package/dist/components/contextMenu/src/contextMenu.mjs +10 -9
  16. package/dist/components/contextMenu/src/contextMenu.mjs.map +1 -1
  17. package/dist/components/dialog/src/dialog.d.ts +7 -4
  18. package/dist/components/dialog/src/dialog.mjs +10 -11
  19. package/dist/components/dialog/src/dialog.mjs.map +1 -1
  20. package/dist/components/drawer/src/drawer.d.ts +2 -2
  21. package/dist/components/drawer/src/drawer.mjs +18 -18
  22. package/dist/components/drawer/src/drawer.mjs.map +1 -1
  23. package/dist/components/form/src/form.d.ts +34 -16
  24. package/dist/components/form/src/form.mjs +8 -9
  25. package/dist/components/form/src/form.mjs.map +1 -1
  26. package/dist/components/form/src/formItem.d.ts +4 -4
  27. package/dist/components/form/src/formItem.mjs +18 -17
  28. package/dist/components/form/src/formItem.mjs.map +1 -1
  29. package/dist/components/form/utils/form.d.ts +3 -3
  30. package/dist/components/form/utils/form.mjs +6 -10
  31. package/dist/components/form/utils/form.mjs.map +1 -1
  32. package/dist/components/icon/src/icon.mjs.map +1 -1
  33. package/dist/components/iconSelector/src/iconSelector.d.ts +2 -2
  34. package/dist/components/iconSelector/src/iconSelector.mjs +4 -5
  35. package/dist/components/iconSelector/src/iconSelector.mjs.map +1 -1
  36. package/dist/components/image/src/image.d.ts +1 -1
  37. package/dist/components/image/src/image.mjs +3 -3
  38. package/dist/components/image/src/image.mjs.map +1 -1
  39. package/dist/components/inputDialogPage/src/inputDialogPage.d.ts +4 -4
  40. package/dist/components/inputDialogPage/src/inputDialogPage.mjs +11 -15
  41. package/dist/components/inputDialogPage/src/inputDialogPage.mjs.map +1 -1
  42. package/dist/components/layoutGrid/index.d.ts +1 -1
  43. package/dist/components/layoutGrid/index.mjs.map +1 -1
  44. package/dist/components/layoutGrid/src/layoutGrid.d.ts +23 -11
  45. package/dist/components/layoutGrid/src/layoutGrid.mjs +44 -45
  46. package/dist/components/layoutGrid/src/layoutGrid.mjs.map +1 -1
  47. package/dist/components/layoutGrid/src/layoutGrid.type.d.ts +1 -1
  48. package/dist/components/layoutGrid/src/layoutGridItem.mjs +13 -14
  49. package/dist/components/layoutGrid/src/layoutGridItem.mjs.map +1 -1
  50. package/dist/components/select/index.d.ts +1 -1
  51. package/dist/components/select/index.mjs.map +1 -1
  52. package/dist/components/select/src/select.d.ts +29 -14
  53. package/dist/components/select/src/select.mjs +47 -45
  54. package/dist/components/select/src/select.mjs.map +1 -1
  55. package/dist/components/select/src/selectOption.mjs +4 -5
  56. package/dist/components/select/src/selectOption.mjs.map +1 -1
  57. package/dist/components/selectPage/src/selectPage.d.ts +29 -14
  58. package/dist/components/selectPage/src/selectPage.mjs +45 -52
  59. package/dist/components/selectPage/src/selectPage.mjs.map +1 -1
  60. package/dist/components/selectV2/src/selectV2.d.ts +51 -31
  61. package/dist/components/selectV2/src/selectV2.mjs +66 -64
  62. package/dist/components/selectV2/src/selectV2.mjs.map +1 -1
  63. package/dist/components/table/index.d.ts +3 -3
  64. package/dist/components/table/index.mjs +1 -3
  65. package/dist/components/table/index.mjs.map +1 -1
  66. package/dist/components/table/src/table.d.ts +72 -38
  67. package/dist/components/table/src/table.mjs +98 -104
  68. package/dist/components/table/src/table.mjs.map +1 -1
  69. package/dist/components/table/src/table.type.d.ts +2 -2
  70. package/dist/components/table/src/table.type.mjs.map +1 -1
  71. package/dist/components/table/src/tableColumn.d.ts +7 -7
  72. package/dist/components/table/src/tableColumn.mjs +25 -45
  73. package/dist/components/table/src/tableColumn.mjs.map +1 -1
  74. package/dist/components/table/src/tableColumnSettingDialog.mjs +32 -22
  75. package/dist/components/table/src/tableColumnSettingDialog.mjs.map +1 -1
  76. package/dist/components/table/src/tablePagination.mjs +2 -3
  77. package/dist/components/table/src/tablePagination.mjs.map +1 -1
  78. package/dist/components/table/src/tableSearchForm.d.ts +4 -4
  79. package/dist/components/table/src/tableSearchForm.mjs +35 -44
  80. package/dist/components/table/src/tableSearchForm.mjs.map +1 -1
  81. package/dist/components/table/src/tableSearchFormItem.d.ts +1 -7
  82. package/dist/components/table/src/tableSearchFormItem.mjs +3 -6
  83. package/dist/components/table/src/tableSearchFormItem.mjs.map +1 -1
  84. package/dist/components/table/src/useTable.d.ts +4 -4
  85. package/dist/components/table/src/useTable.mjs +19 -20
  86. package/dist/components/table/src/useTable.mjs.map +1 -1
  87. package/dist/components/table/utils/table.mjs +6 -8
  88. package/dist/components/table/utils/table.mjs.map +1 -1
  89. package/dist/components/tree/index.d.ts +1 -1
  90. package/dist/components/tree/index.mjs.map +1 -1
  91. package/dist/components/tree/src/tree.d.ts +9 -9
  92. package/dist/components/tree/src/tree.mjs +29 -27
  93. package/dist/components/tree/src/tree.mjs.map +1 -1
  94. package/dist/components/treeSelect/src/treeSelect.d.ts +38 -35
  95. package/dist/components/treeSelect/src/treeSelect.mjs +47 -45
  96. package/dist/components/treeSelect/src/treeSelect.mjs.map +1 -1
  97. package/dist/components/upload/src/upload.d.ts +1 -1
  98. package/dist/components/upload/src/upload.mjs +5 -6
  99. package/dist/components/upload/src/upload.mjs.map +1 -1
  100. package/dist/components/upload/src/useUpload.mjs +8 -10
  101. package/dist/components/upload/src/useUpload.mjs.map +1 -1
  102. package/dist/components/upload/utils/upload.d.ts +1 -1
  103. package/dist/components/upload/utils/upload.mjs +1 -1
  104. package/dist/components/upload/utils/upload.mjs.map +1 -1
  105. package/dist/components/uploadImage/src/uploadImage.d.ts +8 -5
  106. package/dist/components/uploadImage/src/uploadImage.mjs +18 -13
  107. package/dist/components/uploadImage/src/uploadImage.mjs.map +1 -1
  108. package/dist/components/uploadImages/src/uploadImages.d.ts +8 -5
  109. package/dist/components/uploadImages/src/uploadImages.mjs +16 -11
  110. package/dist/components/uploadImages/src/uploadImages.mjs.map +1 -1
  111. package/dist/directives/click-copy/index.d.ts +1 -1
  112. package/dist/directives/click-copy/index.mjs +5 -9
  113. package/dist/directives/click-copy/index.mjs.map +1 -1
  114. package/dist/directives/click-debounce/index.d.ts +1 -1
  115. package/dist/directives/click-draggable/index.d.ts +1 -1
  116. package/dist/directives/click-icon-copy/index.d.ts +1 -1
  117. package/dist/directives/click-icon-copy/index.mjs.map +1 -1
  118. package/dist/directives/click-longpress/index.d.ts +1 -1
  119. package/dist/directives/click-throttle/index.d.ts +1 -1
  120. package/dist/element-plus.mjs +5 -6
  121. package/dist/element-plus.mjs.map +1 -1
  122. package/dist/hooks/use-screenFull/index.mjs.map +1 -1
  123. package/dist/index.css +1 -1
  124. package/dist/index.css.map +1 -1
  125. package/dist/index.global.min.js +4 -4
  126. package/dist/index.global.min.js.map +1 -1
  127. package/dist/index.mjs +1 -3
  128. package/dist/index.mjs.map +1 -1
  129. package/dist/utils/async/index.mjs +6 -4
  130. package/dist/utils/async/index.mjs.map +1 -1
  131. package/dist/utils/index.d.ts +1 -0
  132. package/dist/utils/object/index.d.ts +8 -0
  133. package/dist/utils/object/index.mjs +113 -0
  134. package/dist/utils/object/index.mjs.map +1 -0
  135. package/dist/utils/string/index.mjs +19 -11
  136. package/dist/utils/string/index.mjs.map +1 -1
  137. package/dist/utils/vue/emits.mjs.map +1 -1
  138. package/dist/utils/vue/install.mjs.map +1 -1
  139. package/dist/utils/vue/render.mjs.map +1 -1
  140. package/dist/version.d.ts +1 -1
  141. package/dist/version.mjs +1 -1
  142. package/dist/version.mjs.map +1 -1
  143. package/package.json +5 -10
  144. package/dist/components/table/src/page.type.mjs +0 -45
  145. package/dist/components/table/src/page.type.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"treeSelect.mjs","names":["update:modelValue","update:label","node-click"],"sources":["../../../../src/components/treeSelect/src/treeSelect.tsx"],"sourcesContent":["import { useVModel } from \"@vueuse/core\";\nimport { computed, defineComponent, onMounted, reactive, ref, watch } from \"vue\";\nimport { ElTreeSelect, selectEmits, selectProps, treeEmits, treeProps } from \"element-plus\";\nimport { isArray, isBoolean, isEqual, isNil, isNull, isNumber, isObject, isString } from \"lodash-unified\";\nimport { addCssUnit, definePropType, makeSlots, useEmits, useExpose, useProps, useRender, withDefineType } from \"../../../utils\";\nimport type { FilterValue, SelectInstance, TreeInstance, TreeNodeData } from \"element-plus\";\nimport type { ComponentInternalInstance, VNode } from \"vue\";\nimport type { ElSelectorModelValue, ElSelectorOutput, ElSelectorValue } from \"../../select\";\nimport type { SelectComponentProps } from \"../../select/src/select\";\nimport type { PagedInput } from \"../../table\";\nimport type { FilterNodeMethodFunction, TreeNode } from \"../../tree/src/tree.props\";\n\n/** 补充 Element Plus TreeSelect 运行时支持但类型声明缺失的事件。 */\ntype ElTreeSelectRuntimeType = typeof ElTreeSelect &\n\t(new () => {\n\t\t$props: InstanceType<typeof ElTreeSelect>[\"$props\"] & {\n\t\t\tonNodeClick?: (data: ElSelectorOutput, node: TreeNode, instance: ComponentInternalInstance | null) => void;\n\t\t\tonChange?: (value: ElSelectorModelValue) => void;\n\t\t\t\"onUpdate:modelValue\"?: (value: ElSelectorModelValue) => void;\n\t\t};\n\t});\n\nconst ElTreeSelectRuntime = ElTreeSelect as ElTreeSelectRuntimeType;\n\n/** Element Plus TreeSelect 运行时实际暴露的方法集合。 */\ntype ElTreeSelectExposes = Pick<SelectInstance, \"focus\" | \"blur\" | \"selectedLabel\"> &\n\tPick<\n\t\tTreeInstance,\n\t\t| \"filter\"\n\t\t| \"updateKeyChildren\"\n\t\t| \"getCheckedNodes\"\n\t\t| \"setCheckedNodes\"\n\t\t| \"getCheckedKeys\"\n\t\t| \"setCheckedKeys\"\n\t\t| \"setChecked\"\n\t\t| \"getHalfCheckedNodes\"\n\t\t| \"getHalfCheckedKeys\"\n\t\t| \"getCurrentKey\"\n\t\t| \"getCurrentNode\"\n\t\t| \"setCurrentKey\"\n\t\t| \"setCurrentNode\"\n\t\t| \"getNode\"\n\t\t| \"remove\"\n\t\t| \"append\"\n\t\t| \"insertBefore\"\n\t\t| \"insertAfter\"\n\t> & {\n\t\ttreeRef: TreeInstance;\n\t\tselectRef: SelectInstance;\n\t};\n\n/** FaTreeSelect 的运行时 Props 定义。 */\nexport const faTreeSelectProps = {\n\t...selectProps,\n\t...treeProps,\n\t/** 树节点筛选方法。 */\n\tfilterNodeMethod: {\n\t\ttype: definePropType<FilterNodeMethodFunction>(Function),\n\t},\n\t/**\n\t * 懒加载节点的缓存数据,结构与数据相同,用于获取未加载数据的标签\n\t * @description The cached data of the lazy node, the structure is the same as the data, used to get the label of the unloaded data\n\t */\n\tcacheData: {\n\t\ttype: definePropType<\n\t\t\t{\n\t\t\t\tvalue: string | number | boolean | object;\n\t\t\t\tcurrentLabel: string | number;\n\t\t\t\tisDisabled: boolean;\n\t\t\t}[]\n\t\t>(Array),\n\t\tdefault: [] as {\n\t\t\tvalue: string | number | boolean | object;\n\t\t\tcurrentLabel: string | number;\n\t\t\tisDisabled: boolean;\n\t\t}[],\n\t},\n\t/** @description whether Select is disabled 重载使其支持 ElForm*/\n\tdisabled: {\n\t\ttype: Boolean,\n\t\tdefault: undefined,\n\t},\n\t/** @description displayed text while loading data from server, default is 'Loading' */\n\tloadingText: {\n\t\ttype: String,\n\t\tdefault: \"加载中...\",\n\t},\n\t/** @description displayed text when no data matches the filtering query, you can also use slot `empty`, default is 'No matching data' */\n\tnoMatchText: {\n\t\ttype: String,\n\t\tdefault: \"暂无匹配的数据\",\n\t},\n\t/** @description displayed text when there is no options, you can also use slot `empty`, default is 'No data' */\n\tnoDataText: {\n\t\ttype: String,\n\t\tdefault: \"暂无数据\",\n\t},\n\t/** @description whether to collapse tags to a text when multiple selecting */\n\tcollapseTags: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t},\n\t/** @description whether show all selected tags when mouse hover text of collapse-tags. To use this, `collapse-tags` must be true */\n\tcollapseTagsTooltip: {\n\t\ttype: Boolean,\n\t\tdefault: true,\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 是否在点击节点的时候展开或者收缩节点, 默认值为 true,如果为 false,则只有点箭头图标的时候才会展开或者收缩节点。 */\n\texpandOnClickNode: Boolean,\n\t/** @description 点击折叠节点,需要开启 'expandOnClickNode' */\n\tcollapseOnClickNode: Boolean,\n\t/** @description v-model绑定值 */\n\tmodelValue: {\n\t\ttype: definePropType<ElSelectorModelValue>([String, Number, Boolean, Object, Array]),\n\t\tdefault: undefined,\n\t},\n\t/** @description v-model:label绑定值 */\n\tlabel: definePropType<string | string[] | null>([String, Array]),\n\t/** @description 宽度 */\n\twidth: {\n\t\ttype: [String, Number],\n\t\tdefault: \"100%\",\n\t},\n\t/** @description 更多细节,只有使用slot的时候有用 */\n\tmoreDetail: Boolean,\n\t/** @description 懒加载远程数据,默认 true。当下拉框第一次显示的时候才会加载远程数据*/\n\tlazy: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t},\n\t/** @description 默认选中。不能和懒加载一起使用 */\n\tdefaultSelected: Boolean,\n\t/** @description 配置选项 */\n\tprops: {\n\t\ttype: definePropType<SelectComponentProps>(Object),\n\t\tdefault: (): Partial<SelectComponentProps> => ({\n\t\t\tlabel: \"label\",\n\t\t\thide: \"hide\",\n\t\t\tdisabled: \"disabled\",\n\t\t\tchildren: \"children\",\n\t\t}),\n\t},\n\t/** @description 下拉框数据 */\n\tdata: {\n\t\ttype: definePropType<ElSelectorOutput[]>(Array),\n\t\tdefault: (): ElSelectorOutput[] => [],\n\t},\n\t/** @description 请求api */\n\trequestApi: {\n\t\ttype: definePropType<(params?: string | number | PagedInput) => Promise<ElSelectorOutput[]>>(Function),\n\t},\n\t/** 初始化参数 */\n\tinitParam: definePropType<string | number | PagedInput>([String, Number, Object]),\n};\n\n/** FaTreeSelect 的运行时 Emits 定义。 */\nexport const faTreeSelectEmits = {\n\t...selectEmits,\n\t...treeEmits,\n\t/** @description v-model 回调 */\n\t\"update:modelValue\": (value: ElSelectorModelValue): boolean =>\n\t\tisString(value) || isNumber(value) || isBoolean(value) || isObject(value) || isArray(value) || isNil(value),\n\t/** @description 选中数据改变 */\n\tchange: (_data: ElSelectorOutput | ElSelectorOutput[] | null, _value?: ElSelectorModelValue): boolean => true,\n\t/** @description v-model:label 回调 */\n\t\"update:label\": (value: string | string[] | null): boolean => isString(value) || isArray(value) || isNull(value),\n\n\t/** @description 数据改变 */\n\tdataChangeCallBack: (data: ElSelectorOutput[]): boolean => isArray(data),\n\t/** @description 节点点击 */\n\t\"node-click\": (_data: ElSelectorOutput, _node: TreeNode, _instance: ComponentInternalInstance | null): boolean => true,\n};\n\n/** FaTreeSelect 的插槽参数。 */\nexport interface FaTreeSelectSlots extends Record<string, unknown> {\n\t/** @description 默认内容插槽 */\n\tdefault: { node: TreeNode; data: ElSelectorOutput };\n\n\t/** @description 下拉列表顶部的内容 */\n\theader: never;\n\t/** @description 下拉列表底部的内容 */\n\tfooter: never;\n\t/** @description Select 组件头部内容 */\n\tprefix: never;\n\t/** @description 无选项时的列表 */\n\tempty: never;\n\t/** @description select 组件自定义标签内容 */\n\ttag: never;\n\t/** @description select 组件自定义 loading内容 */\n\tloading: never;\n\t/** @description select 组件自定义标签内容 */\n\tlabel: { label: string; value: string | number | boolean | object };\n}\n\nexport default defineComponent({\n\tname: \"FaTreeSelect\",\n\tprops: faTreeSelectProps,\n\temits: faTreeSelectEmits,\n\tslots: makeSlots<FaTreeSelectSlots>(),\n\tsetup(props, { slots, emit, expose }) {\n\t\tconst selectedLabel = useVModel(props, \"label\", emit, { passive: true });\n\n\t\tconst state = reactive({\n\t\t\tvalue: withDefineType<ElSelectorModelValue>(),\n\t\t\tloading: false,\n\t\t\tselectorData: withDefineType<ElSelectorOutput[]>([]),\n\t\t\t/** 首次出现 */\n\t\t\tdebut: true,\n\t\t\t/** 回显 */\n\t\t\techo: props.data?.length > 0 ? false : true,\n\t\t\t/** 下次刷新 */\n\t\t\tnextRefresh: false,\n\t\t});\n\n\t\tconst treeSelectRef = ref<ElTreeSelectExposes>();\n\t\tlet requestVersion = 0;\n\n\t\tconst handleData = (data: ElSelectorOutput[]): ElSelectorOutput[] => {\n\t\t\treturn data\n\t\t\t\t.map((item): ElSelectorOutput => {\n\t\t\t\t\tconst value: unknown = item[props.nodeKey];\n\t\t\t\t\tconst label: unknown = typeof props.props.label === \"function\" ? props.props.label(item) : item[props.props.label ?? \"label\"];\n\t\t\t\t\tconst hide: unknown = typeof props.props.hide === \"function\" ? props.props.hide(item) : item[props.props.hide ?? \"hide\"];\n\t\t\t\t\tconst disabled: unknown =\n\t\t\t\t\t\ttypeof props.props.disabled === \"function\" ? props.props.disabled(item) : item[props.props.disabled ?? \"disabled\"];\n\t\t\t\t\tconst children: unknown = item[props.props.children ?? \"children\"];\n\t\t\t\t\tconst selectorValue: ElSelectorValue | undefined =\n\t\t\t\t\t\tvalue !== null &&\n\t\t\t\t\t\t(typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\" || typeof value === \"object\")\n\t\t\t\t\t\t\t? value\n\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...item,\n\t\t\t\t\t\tchildren: Array.isArray(children) ? handleData(children as ElSelectorOutput[]) : [],\n\t\t\t\t\t\tdisabled: typeof disabled === \"boolean\" ? disabled : undefined,\n\t\t\t\t\t\thide: typeof hide === \"boolean\" ? hide : undefined,\n\t\t\t\t\t\tlabel: typeof label === \"string\" ? label : undefined,\n\t\t\t\t\t\tvalue: selectorValue,\n\t\t\t\t\t};\n\t\t\t\t})\n\t\t\t\t.filter((item) => item.hide !== true);\n\t\t};\n\n\t\tconst handleModelValueUpdate = (value: ElSelectorModelValue): void => {\n\t\t\tstate.value = value;\n\t\t\temit(\"update:modelValue\", value);\n\t\t};\n\n\t\tconst loadData = async (): Promise<void> => {\n\t\t\tconst currentRequestVersion = ++requestVersion;\n\t\t\t// 判断是否需要自动请求\n\t\t\tif (props.requestApi) {\n\t\t\t\tstate.loading = true;\n\t\t\t\tconst params = props.initParam ?? {};\n\t\t\t\ttry {\n\t\t\t\t\tconst resData = await props.requestApi(params);\n\t\t\t\t\tif (currentRequestVersion !== requestVersion) return;\n\t\t\t\t\t// 这里不允许回显了\n\t\t\t\t\tstate.echo = false;\n\t\t\t\t\tstate.selectorData = handleData(resData);\n\t\t\t\t\temit(\"dataChangeCallBack\", state.selectorData);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (currentRequestVersion !== requestVersion) return;\n\t\t\t\t\tstate.selectorData = [];\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\tif (currentRequestVersion !== requestVersion) return;\n\t\t\t\t// 这里不允许回显了\n\t\t\t\tstate.echo = false;\n\t\t\t\tstate.selectorData = handleData(props.data);\n\t\t\t}\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 = [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) => label.includes(filterText));\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: ElSelectorOutput, node: TreeNode, instance: ComponentInternalInstance | null): void => {\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\temit(\"node-click\", data, node, instance);\n\t\t};\n\n\t\t/**\n\t\t * 下拉框出现/隐藏时触发\n\t\t */\n\t\tconst handleVisibleChange = async (visible: boolean): Promise<void> => {\n\t\t\tif (visible) {\n\t\t\t\tif (state.debut) {\n\t\t\t\t\t// 首次出现\n\t\t\t\t\tstate.debut = false;\n\t\t\t\t\t// 懒加载\n\t\t\t\t\tprops.lazy && (await loadData());\n\t\t\t\t} else {\n\t\t\t\t\t// 判断再次出现是否需要刷新数据\n\t\t\t\t\tif (state.nextRefresh) {\n\t\t\t\t\t\tstate.nextRefresh = false;\n\t\t\t\t\t\tawait loadData();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\temit(\"visible-change\", visible);\n\t\t};\n\n\t\twatch(\n\t\t\t() => props.modelValue,\n\t\t\t(newValue) => {\n\t\t\t\tif (state.echo && !isNil(newValue)) {\n\t\t\t\t\tconst hasLabel = !isNil(props.label);\n\t\t\t\t\t// 判断是否为多选\n\t\t\t\t\tif (props.multiple) {\n\t\t\t\t\t\t// 判断是否为数组\n\t\t\t\t\t\tif (!Array.isArray(newValue)) {\n\t\t\t\t\t\t\tconsole.error(\"[Fast:FaTreeSelect]\", \"当启用 multiple 时,传入的 modelValue 必须是 Array。\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (hasLabel && !isArray(props.label)) {\n\t\t\t\t\t\t\tconsole.error(\"[Fast:FaTreeSelect]\", \"当启用 multiple 时,传入的 modelValue:label 必须是 Array。\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstate.selectorData = newValue\n\t\t\t\t\t\t\t// 最大选项截取\n\t\t\t\t\t\t\t.slice(0, props.multipleLimit > 0 ? props.multipleLimit : newValue.length)\n\t\t\t\t\t\t\t.map((item, index) => {\n\t\t\t\t\t\t\t\tconst value: unknown = item;\n\t\t\t\t\t\t\t\tconst label: unknown = Array.isArray(props.label) ? props.label[index] : undefined;\n\t\t\t\t\t\t\t\tconst selectorValue: ElSelectorValue | undefined =\n\t\t\t\t\t\t\t\t\tvalue !== null &&\n\t\t\t\t\t\t\t\t\t(typeof value === \"string\" ||\n\t\t\t\t\t\t\t\t\t\ttypeof value === \"number\" ||\n\t\t\t\t\t\t\t\t\t\ttypeof value === \"boolean\" ||\n\t\t\t\t\t\t\t\t\t\ttypeof value === \"object\")\n\t\t\t\t\t\t\t\t\t\t? value\n\t\t\t\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tvalue: selectorValue,\n\t\t\t\t\t\t\t\t\tlabel: hasLabel && typeof label === \"string\" ? label : undefined,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (Array.isArray(newValue)) {\n\t\t\t\t\t\t\tconsole.error(\"[Fast:FaTreeSelect]\", \"当禁用 multiple 时,传入的 modelValue 不能是 Array。\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (hasLabel && isArray(props.label)) {\n\t\t\t\t\t\t\tconsole.error(\"[Fast:FaTreeSelect]\", \"当禁用 multiple 时,传入的 modelValue:label 不能是 Array。\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstate.selectorData = [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvalue: newValue,\n\t\t\t\t\t\t\t\tlabel: typeof props.label === \"string\" ? props.label : undefined,\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\tstate.value = newValue;\n\t\t\t},\n\t\t\t{\n\t\t\t\timmediate: true,\n\t\t\t}\n\t\t);\n\n\t\tconst flattenOptions = (data: ElSelectorOutput[]): ElSelectorOutput[] =>\n\t\t\tdata.flatMap((item) => [item, ...flattenOptions(item.children ?? [])]);\n\n\t\tconst handleChange = (value?: ElSelectorModelValue): void => {\n\t\t\tconst selectorData = flattenOptions(state.selectorData);\n\t\t\tif (props.multiple) {\n\t\t\t\tconst valueList = Array.isArray(value) ? value : [];\n\t\t\t\tif (valueList.length === 0) {\n\t\t\t\t\temit(\"change\", null, null);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst dataList = valueList\n\t\t\t\t\t.map((item) => selectorData.find((option) => option.value !== undefined && isEqual(option.value, item)))\n\t\t\t\t\t.filter((item): item is ElSelectorOutput => item !== undefined);\n\t\t\t\temit(\"change\", dataList, value);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (isNil(value) || Array.isArray(value)) {\n\t\t\t\temit(\"change\", null, null);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst data = selectorData.find((item) => item.value !== undefined && isEqual(item.value, value));\n\t\t\temit(\"change\", data ?? null, value);\n\t\t};\n\n\t\twatch(\n\t\t\t[() => state.value, () => state.selectorData],\n\t\t\t([value]) => {\n\t\t\t\tconst selectorData = flattenOptions(state.selectorData);\n\n\t\t\t\tif (props.multiple) {\n\t\t\t\t\tif (!Array.isArray(value)) {\n\t\t\t\t\t\tselectedLabel.value = null;\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tselectedLabel.value = value.map((item, index) => {\n\t\t\t\t\t\tconst data = selectorData.find((option) => option.value !== undefined && isEqual(option.value, item));\n\n\t\t\t\t\t\treturn data?.label ?? (Array.isArray(props.label) ? (props.label[index] ?? \"\") : \"\");\n\t\t\t\t\t});\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (isNil(value) || Array.isArray(value)) {\n\t\t\t\t\tselectedLabel.value = null;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tselectedLabel.value =\n\t\t\t\t\tselectorData.find((item) => item.value !== undefined && isEqual(item.value, value))?.label ??\n\t\t\t\t\t(typeof props.label === \"string\" ? props.label : null);\n\t\t\t},\n\t\t\t{\n\t\t\t\tdeep: true,\n\t\t\t\tflush: \"sync\",\n\t\t\t\timmediate: true,\n\t\t\t}\n\t\t);\n\n\t\tonMounted(async () => {\n\t\t\tif (props.defaultSelected) {\n\t\t\t\tawait loadData();\n\t\t\t\tconst firstItem = state.selectorData[0];\n\t\t\t\tif (firstItem?.value !== undefined) {\n\t\t\t\t\tif (props.multiple) {\n\t\t\t\t\t\thandleModelValueUpdate([firstItem.value]);\n\t\t\t\t\t} else {\n\t\t\t\t\t\thandleModelValueUpdate(firstItem.value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t// 判断是否为本地数据\n\t\t\telse if (!props.requestApi && props.data?.length > 0) {\n\t\t\t\tstate.debut = false;\n\t\t\t\tawait loadData();\n\t\t\t}\n\t\t\t// 判断是否非默认选中,且未启用懒加载\n\t\t\telse if (!props.lazy) {\n\t\t\t\tawait loadData();\n\t\t\t}\n\t\t\twatch(\n\t\t\t\t() => props.initParam,\n\t\t\t\t(newValue, oldValue) => {\n\t\t\t\t\tif (!isEqual(newValue, oldValue)) {\n\t\t\t\t\t\tstate.nextRefresh = true;\n\t\t\t\t\t\tif (!isNil(state.value)) {\n\t\t\t\t\t\t\thandleModelValueUpdate(props.multiple ? [] : undefined);\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t);\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\tconst elTreeSelectProps = useProps(props, { ...selectProps, ...treeProps }, [\n\t\t\t\"modelValue\",\n\t\t\t\"popperClass\",\n\t\t\t\"lazy\",\n\t\t\t\"loading\",\n\t\t\t\"expandOnClickNode\",\n\t\t\t\"filterNodeMethod\",\n\t\t\t\"props\",\n\t\t]);\n\t\tconst elTreeSelectEmits = useEmits({ ...selectEmits, ...treeEmits }, emit, [\"update:modelValue\", \"change\", \"visible-change\", \"node-click\"]);\n\n\t\tuseRender(() => (\n\t\t\t<ElTreeSelectRuntime\n\t\t\t\t{...elTreeSelectProps.value}\n\t\t\t\t{...elTreeSelectEmits.value}\n\t\t\t\tref={treeSelectRef}\n\t\t\t\tclass=\"fa-tree-select\"\n\t\t\t\tpopperClass={[\"fa-tree-select-dropdown\", props.popperClass]}\n\t\t\t\tstyle={{ width: addCssUnit(props.width) }}\n\t\t\t\tmodelValue={state.value}\n\t\t\t\tonUpdate:modelValue={handleModelValueUpdate}\n\t\t\t\tonChange={handleChange}\n\t\t\t\tlazy={false}\n\t\t\t\tloading={state.loading}\n\t\t\t\tdata={state.selectorData}\n\t\t\t\texpandOnClickNode={props.checkOnClickNode ? false : props.expandOnClickNode}\n\t\t\t\tfilterNodeMethod={handleFilterNode as typeof props.filterNodeMethod}\n\t\t\t\tonNodeClick={handleNodeClick}\n\t\t\t\tonVisible-change={handleVisibleChange}\n\t\t\t>\n\t\t\t\t{{\n\t\t\t\t\t...(slots.default && {\n\t\t\t\t\t\tdefault: ({ node, data }: { node: TreeNode; data: ElSelectorOutput }): VNode[] => slots.default?.({ node, data }) ?? [],\n\t\t\t\t\t}),\n\t\t\t\t\t...(slots.header && { header: (): VNode[] => slots.header?.() ?? [] }),\n\t\t\t\t\t...(slots.footer && { footer: (): VNode[] => slots.footer?.() ?? [] }),\n\t\t\t\t\t...(slots.prefix && { prefix: (): VNode[] => slots.prefix?.() ?? [] }),\n\t\t\t\t\t...(slots.empty && { empty: (): VNode[] => slots.empty?.() ?? [] }),\n\t\t\t\t\t...(slots.tag && { tag: (): VNode[] => slots.tag?.() ?? [] }),\n\t\t\t\t\t...(slots.loading && { loading: (): VNode[] => slots.loading?.() ?? [] }),\n\t\t\t\t\t...(slots.label && {\n\t\t\t\t\t\tlabel: ({ label, value }: { label: string; value: string | number | boolean | object }): VNode[] =>\n\t\t\t\t\t\t\tslots.label?.({ label, value }) ?? [],\n\t\t\t\t\t}),\n\t\t\t\t}}\n\t\t\t</ElTreeSelectRuntime>\n\t\t));\n\n\t\treturn useExpose(expose, {\n\t\t\t/** @description 使选择器的输入框获取焦点。 */\n\t\t\tfocus: computed(() => treeSelectRef.value?.focus),\n\t\t\t/** @description 使选择器的输入框失去焦点,并隐藏下拉框。 */\n\t\t\tblur: computed(() => treeSelectRef.value?.blur),\n\t\t\t/** @description 获取当前选中的标签。 */\n\t\t\tselectedLabel: computed(() => treeSelectRef.value?.selectedLabel),\n\t\t\t/** @description 过滤所有树节点,过滤后的节点将被隐藏。 */\n\t\t\tfilter: computed(() => treeSelectRef.value?.filter),\n\t\t\t/** @description 为节点设置新数据,只有设置 node-key 时可用。 */\n\t\t\tupdateKeyChildren: computed(() => treeSelectRef.value?.updateKeyChildren),\n\t\t\t/** @description 获取当前选中的节点。 */\n\t\t\tgetCheckedNodes: computed(() => treeSelectRef.value?.getCheckedNodes),\n\t\t\t/** @description 设置当前选中的节点。 */\n\t\t\tsetCheckedNodes: computed(() => treeSelectRef.value?.setCheckedNodes),\n\t\t\t/** @description 获取当前选中的节点 Key。 */\n\t\t\tgetCheckedKeys: computed(() => treeSelectRef.value?.getCheckedKeys),\n\t\t\t/** @description 设置当前选中的节点 Key。 */\n\t\t\tsetCheckedKeys: computed(() => treeSelectRef.value?.setCheckedKeys),\n\t\t\t/** @description 设置节点选中状态。 */\n\t\t\tsetChecked: computed(() => treeSelectRef.value?.setChecked),\n\t\t\t/** @description 获取当前半选中的节点。 */\n\t\t\tgetHalfCheckedNodes: computed(() => treeSelectRef.value?.getHalfCheckedNodes),\n\t\t\t/** @description 获取当前半选中的节点 Key。 */\n\t\t\tgetHalfCheckedKeys: computed(() => treeSelectRef.value?.getHalfCheckedKeys),\n\t\t\t/** @description 获取当前节点 Key。 */\n\t\t\tgetCurrentKey: computed(() => treeSelectRef.value?.getCurrentKey),\n\t\t\t/** @description 获取当前节点。 */\n\t\t\tgetCurrentNode: computed(() => treeSelectRef.value?.getCurrentNode),\n\t\t\t/** @description 设置当前节点 Key。 */\n\t\t\tsetCurrentKey: computed(() => treeSelectRef.value?.setCurrentKey),\n\t\t\t/** @description 设置当前节点。 */\n\t\t\tsetCurrentNode: computed(() => treeSelectRef.value?.setCurrentNode),\n\t\t\t/** @description 根据数据或 Key 获取节点。 */\n\t\t\tgetNode: computed(() => treeSelectRef.value?.getNode),\n\t\t\t/** @description 删除节点。 */\n\t\t\tremove: computed(() => treeSelectRef.value?.remove),\n\t\t\t/** @description 追加子节点。 */\n\t\t\tappend: computed(() => treeSelectRef.value?.append),\n\t\t\t/** @description 在指定节点前插入节点。 */\n\t\t\tinsertBefore: computed(() => treeSelectRef.value?.insertBefore),\n\t\t\t/** @description 在指定节点后插入节点。 */\n\t\t\tinsertAfter: computed(() => treeSelectRef.value?.insertAfter),\n\t\t\t/** @description Element Plus Tree 实例。 */\n\t\t\ttreeRef: computed(() => treeSelectRef.value?.treeRef),\n\t\t\t/** @description Element Plus Select 实例。 */\n\t\t\tselectRef: computed(() => treeSelectRef.value?.selectRef),\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\t/** @description 设置选择 */\n\t\t\tsetSelection: (value: Exclude<ElSelectorModelValue, null | undefined>) => handleModelValueUpdate(value),\n\t\t\t/** @description 清除选择 */\n\t\t\tclearSelection: () => handleModelValueUpdate(props.multiple ? [] : undefined),\n\t\t});\n\t},\n});\n"],"mappings":";;;;;;;;;;;;AAsBA,MAAM,sBAAsB;;AA8B5B,MAAa,oBAAoB;CAChC,GAAG;CACH,GAAG;;CAEH,kBAAkB,EACjB,MAAM,eAAyC,QAAQ,EACxD;;;;;CAKA,WAAW;EACV,MAAM,eAMJ,KAAK;EACP,SAAS,CAAA;CAKV;;CAEA,UAAU;EACT,MAAM;EACN,SAAS,KAAA;CACV;;CAEA,aAAa;EACZ,MAAM;EACN,SAAS;CACV;;CAEA,aAAa;EACZ,MAAM;EACN,SAAS;CACV;;CAEA,YAAY;EACX,MAAM;EACN,SAAS;CACV;;CAEA,cAAc;EACb,MAAM;EACN,SAAS;CACV;;CAEA,qBAAqB;EACpB,MAAM;EACN,SAAS;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,mBAAmB;;CAEnB,qBAAqB;;CAErB,YAAY;EACX,MAAM,eAAqC;GAAC;GAAQ;GAAQ;GAAS;GAAQ;EAAK,CAAC;EACnF,SAAS,KAAA;CACV;;CAEA,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,cAAc,OAAO,cAAc;;GAElE,SAAS,eAAe,cAAc,OAAO,OAAO;;GAEpD,QAAQ,eAAe,cAAc,OAAO,MAAM;;GAElD,QAAQ,eAAe,cAAc,OAAO,MAAM;;GAElD,cAAc,eAAe,cAAc,OAAO,YAAY;;GAE9D,aAAa,eAAe,cAAc,OAAO,WAAW;;GAE5D,SAAS,eAAe,cAAc,OAAO,OAAO;;GAEpD,WAAW,eAAe,cAAc,OAAO,SAAS;;GAExD,SAAS,eAAe,MAAM,OAAO;;GAErC,SAAS;;GAET,eAAe,UAA2D,uBAAuB,KAAK;;GAEtG,sBAAsB,uBAAuB,MAAM,WAAW,CAAA,IAAK,KAAA,CAAS;EAC7E,CAAC;CACF;AACD,CAAC"}
1
+ {"version":3,"file":"treeSelect.mjs","names":["update:modelValue","update:label","node-click"],"sources":["../../../../src/components/treeSelect/src/treeSelect.tsx"],"sourcesContent":["import { computed, defineComponent, onMounted, reactive, shallowRef, useModel, watch } from \"vue\";\nimport { ElTreeSelect, selectEmits, selectProps, treeEmits, treeProps } from \"element-plus\";\nimport { addCssUnit, definePropType, isEqual, makeSlots, useEmits, useExpose, useProps, useRender, withDefineType } from \"../../../utils\";\nimport type { FilterValue, SelectInstance, TreeInstance, TreeNodeData } from \"element-plus\";\nimport type { ComponentInternalInstance } from \"vue\";\nimport type { ElSelectorModelValue, ElSelectorOutput, ElSelectorValue } from \"../../select\";\nimport type { SelectComponentProps } from \"../../select/src/select\";\nimport type { PagedInput } from \"../../table\";\nimport type { FilterNodeMethodFunction, TreeNode } from \"../../tree/src/tree.props\";\n\n/** 补充 Element Plus TreeSelect 运行时支持但类型声明缺失的事件。 */\ntype ElTreeSelectRuntimeType = typeof ElTreeSelect &\n\t(new () => {\n\t\t$props: InstanceType<typeof ElTreeSelect>[\"$props\"] & {\n\t\t\tonNodeClick?: (data: ElSelectorOutput, node: TreeNode, instance: ComponentInternalInstance | null) => void;\n\t\t\tonChange?: (value: ElSelectorModelValue) => void;\n\t\t\t\"onUpdate:modelValue\"?: (value: ElSelectorModelValue) => void;\n\t\t};\n\t});\n\nconst ElTreeSelectRuntime = ElTreeSelect as ElTreeSelectRuntimeType;\n\n/** Element Plus TreeSelect 运行时实际暴露的方法集合。 */\ntype ElTreeSelectExposes = Pick<SelectInstance, \"focus\" | \"blur\" | \"selectedLabel\"> &\n\tPick<\n\t\tTreeInstance,\n\t\t| \"filter\"\n\t\t| \"updateKeyChildren\"\n\t\t| \"getCheckedNodes\"\n\t\t| \"setCheckedNodes\"\n\t\t| \"getCheckedKeys\"\n\t\t| \"setCheckedKeys\"\n\t\t| \"setChecked\"\n\t\t| \"getHalfCheckedNodes\"\n\t\t| \"getHalfCheckedKeys\"\n\t\t| \"getCurrentKey\"\n\t\t| \"getCurrentNode\"\n\t\t| \"setCurrentKey\"\n\t\t| \"setCurrentNode\"\n\t\t| \"getNode\"\n\t\t| \"remove\"\n\t\t| \"append\"\n\t\t| \"insertBefore\"\n\t\t| \"insertAfter\"\n\t> & {\n\t\ttreeRef: TreeInstance;\n\t\tselectRef: SelectInstance;\n\t};\n\n/** FaTreeSelect 的运行时 Props 定义。 */\nexport const faTreeSelectProps = {\n\t...selectProps,\n\t...treeProps,\n\t/** 树节点筛选方法。 */\n\tfilterNodeMethod: {\n\t\ttype: definePropType<FilterNodeMethodFunction>(Function),\n\t},\n\t/**\n\t * 懒加载节点的缓存数据,结构与数据相同,用于获取未加载数据的标签\n\t * @description The cached data of the lazy node, the structure is the same as the data, used to get the label of the unloaded data\n\t */\n\tcacheData: {\n\t\ttype: definePropType<\n\t\t\t{\n\t\t\t\tvalue: string | number | boolean | object;\n\t\t\t\tcurrentLabel: string | number;\n\t\t\t\tisDisabled: boolean;\n\t\t\t}[]\n\t\t>(Array),\n\t\tdefault: () => [],\n\t},\n\t/** @description whether Select is disabled 重载使其支持 ElForm*/\n\tdisabled: {\n\t\ttype: Boolean,\n\t\tdefault: undefined,\n\t},\n\t/** @description displayed text while loading data from server, default is 'Loading' */\n\tloadingText: {\n\t\ttype: String,\n\t\tdefault: \"加载中...\",\n\t},\n\t/** @description displayed text when no data matches the filtering query, you can also use slot `empty`, default is 'No matching data' */\n\tnoMatchText: {\n\t\ttype: String,\n\t\tdefault: \"暂无匹配的数据\",\n\t},\n\t/** @description displayed text when there is no options, you can also use slot `empty`, default is 'No data' */\n\tnoDataText: {\n\t\ttype: String,\n\t\tdefault: \"暂无数据\",\n\t},\n\t/** @description whether to collapse tags to a text when multiple selecting */\n\tcollapseTags: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t},\n\t/** @description whether show all selected tags when mouse hover text of collapse-tags. To use this, `collapse-tags` must be true */\n\tcollapseTagsTooltip: {\n\t\ttype: Boolean,\n\t\tdefault: true,\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 是否在点击节点的时候展开或者收缩节点, 默认值为 true,如果为 false,则只有点箭头图标的时候才会展开或者收缩节点。 */\n\texpandOnClickNode: Boolean,\n\t/** @description 点击折叠节点,需要开启 'expandOnClickNode' */\n\tcollapseOnClickNode: Boolean,\n\t/** @description v-model绑定值 */\n\tmodelValue: {\n\t\ttype: definePropType<ElSelectorModelValue>([String, Number, Boolean, Object, Array]),\n\t\tdefault: undefined,\n\t},\n\t/** @description v-model:label绑定值 */\n\tlabel: definePropType<string | string[] | null>([String, Array]),\n\t/** @description 宽度 */\n\twidth: {\n\t\ttype: [String, Number],\n\t\tdefault: \"100%\",\n\t},\n\t/** @description 更多细节,只有使用slot的时候有用 */\n\tmoreDetail: Boolean,\n\t/** @description 懒加载远程数据,默认 true。当下拉框第一次显示的时候才会加载远程数据*/\n\tlazy: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t},\n\t/** @description 默认选中。不能和懒加载一起使用 */\n\tdefaultSelected: Boolean,\n\t/** @description 配置选项 */\n\tprops: {\n\t\ttype: definePropType<SelectComponentProps>(Object),\n\t\tdefault: () => ({\n\t\t\tlabel: \"label\",\n\t\t\thide: \"hide\",\n\t\t\tdisabled: \"disabled\",\n\t\t\tchildren: \"children\",\n\t\t}),\n\t},\n\t/** @description 下拉框数据 */\n\tdata: {\n\t\ttype: definePropType<ElSelectorOutput[]>(Array),\n\t\tdefault: () => [],\n\t},\n\t/** @description 请求api */\n\trequestApi: {\n\t\ttype: definePropType<(params?: string | number | PagedInput) => Promise<ElSelectorOutput[]>>(Function),\n\t},\n\t/** 初始化参数 */\n\tinitParam: definePropType<string | number | PagedInput | null>([String, Number, Object]),\n};\n\n/** FaTreeSelect 的运行时 Emits 定义。 */\nexport const faTreeSelectEmits = {\n\t...selectEmits,\n\t...treeEmits,\n\t/** @description v-model 回调 */\n\t\"update:modelValue\": (value: ElSelectorModelValue) =>\n\t\ttypeof value === \"string\" ||\n\t\ttypeof value === \"number\" ||\n\t\ttypeof value === \"boolean\" ||\n\t\t(typeof value === \"object\" && value !== null) ||\n\t\tvalue == null,\n\t/** @description 选中数据改变 */\n\tchange: (_data: ElSelectorOutput | ElSelectorOutput[] | null, _value?: ElSelectorModelValue) => true,\n\t/** @description v-model:label 回调 */\n\t\"update:label\": (value: string | string[] | null) => typeof value === \"string\" || Array.isArray(value) || value === null,\n\n\t/** @description 数据改变 */\n\tdataChange: (data: ElSelectorOutput[]) => Array.isArray(data),\n\t/** @description 节点点击 */\n\t\"node-click\": (_data: ElSelectorOutput, _node: TreeNode, _instance: ComponentInternalInstance | null) => true,\n};\n\n/** FaTreeSelect 的插槽参数。 */\nexport interface FaTreeSelectSlots extends Record<string, unknown> {\n\t/** @description 默认内容插槽 */\n\tdefault: { node: TreeNode; data: ElSelectorOutput };\n\n\t/** @description 下拉列表顶部的内容 */\n\theader: never;\n\t/** @description 下拉列表底部的内容 */\n\tfooter: never;\n\t/** @description Select 组件头部内容 */\n\tprefix: never;\n\t/** @description 无选项时的列表 */\n\tempty: never;\n\t/** @description select 组件自定义标签内容 */\n\ttag: never;\n\t/** @description select 组件自定义 loading内容 */\n\tloading: never;\n\t/** @description select 组件自定义标签内容 */\n\tlabel: { label: string; value: string | number | boolean | object };\n}\n\nexport default defineComponent({\n\tname: \"FaTreeSelect\",\n\tprops: faTreeSelectProps,\n\temits: faTreeSelectEmits,\n\tslots: makeSlots<FaTreeSelectSlots>(),\n\tsetup(props, { slots, emit, expose }) {\n\t\tconst selectedLabel = useModel(props, \"label\");\n\n\t\tconst treeSelectRef = shallowRef<ElTreeSelectExposes | null>(null);\n\n\t\tconst state = reactive({\n\t\t\tvalue: withDefineType<ElSelectorModelValue>(),\n\t\t\tloading: false,\n\t\t\tselectorData: withDefineType<ElSelectorOutput[]>([]),\n\t\t\t/** 首次出现 */\n\t\t\tdebut: true,\n\t\t\t/** 回显 */\n\t\t\techo: true,\n\t\t\t/** 下次刷新 */\n\t\t\tnextRefresh: false,\n\t\t});\n\n\t\tlet requestVersion = 0;\n\n\t\tconst handleData = (data: ElSelectorOutput[]): ElSelectorOutput[] => {\n\t\t\treturn data\n\t\t\t\t.map((item) => {\n\t\t\t\t\tconst value: unknown = item[props.nodeKey];\n\t\t\t\t\tconst label: unknown = typeof props.props.label === \"function\" ? props.props.label(item) : item[props.props.label ?? \"label\"];\n\t\t\t\t\tconst hide: unknown = typeof props.props.hide === \"function\" ? props.props.hide(item) : item[props.props.hide ?? \"hide\"];\n\t\t\t\t\tconst disabled: unknown =\n\t\t\t\t\t\ttypeof props.props.disabled === \"function\" ? props.props.disabled(item) : item[props.props.disabled ?? \"disabled\"];\n\t\t\t\t\tconst children: unknown = item[props.props.children ?? \"children\"];\n\t\t\t\t\tconst selectorValue: ElSelectorValue | undefined =\n\t\t\t\t\t\tvalue !== null &&\n\t\t\t\t\t\t(typeof value === \"string\" || typeof value === \"number\" || typeof value === \"boolean\" || typeof value === \"object\")\n\t\t\t\t\t\t\t? value\n\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\treturn {\n\t\t\t\t\t\t...item,\n\t\t\t\t\t\tchildren: Array.isArray(children) ? handleData(children as ElSelectorOutput[]) : [],\n\t\t\t\t\t\tdisabled: typeof disabled === \"boolean\" ? disabled : undefined,\n\t\t\t\t\t\thide: typeof hide === \"boolean\" ? hide : undefined,\n\t\t\t\t\t\tlabel: typeof label === \"string\" ? label : undefined,\n\t\t\t\t\t\tvalue: selectorValue,\n\t\t\t\t\t};\n\t\t\t\t})\n\t\t\t\t.filter((item) => item.hide !== true);\n\t\t};\n\n\t\tconst handleModelValueUpdate = (value: ElSelectorModelValue) => {\n\t\t\tstate.value = value;\n\t\t\temit(\"update:modelValue\", value);\n\t\t};\n\n\t\tconst loadData = async () => {\n\t\t\tconst currentRequestVersion = ++requestVersion;\n\t\t\t// 判断是否需要自动请求\n\t\t\tif (props.requestApi) {\n\t\t\t\tstate.loading = true;\n\t\t\t\tconst params = props.initParam ?? {};\n\t\t\t\ttry {\n\t\t\t\t\tconst resData = await props.requestApi(params);\n\t\t\t\t\tif (currentRequestVersion !== requestVersion) return;\n\t\t\t\t\t// 这里不允许回显了\n\t\t\t\t\tstate.echo = false;\n\t\t\t\t\tstate.selectorData = handleData(resData);\n\t\t\t\t\temit(\"dataChange\", state.selectorData);\n\t\t\t\t} catch (error) {\n\t\t\t\t\tif (currentRequestVersion !== requestVersion) return;\n\t\t\t\t\tstate.selectorData = [];\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\tif (currentRequestVersion !== requestVersion) return;\n\t\t\t\t// 这里不允许回显了\n\t\t\t\tstate.echo = false;\n\t\t\t\tstate.selectorData = handleData(props.data);\n\t\t\t}\n\t\t};\n\n\t\tconst handleFilterNode = (value: FilterValue, data: TreeNodeData, child: TreeNode) => {\n\t\t\tif (!value) return true;\n\t\t\tlet parentNode = child.parent,\n\t\t\t\tlabels = [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) => label.includes(filterText));\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: ElSelectorOutput, node: TreeNode, instance: ComponentInternalInstance | null) => {\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 (props.collapseOnClickNode) {\n\t\t\t\t\tnode.collapse();\n\t\t\t\t}\n\t\t\t}\n\t\t\t// eslint-disable-next-line vue/custom-event-name-casing -- Element Plus 的公开事件名为 node-click,需要保持原始名称透传。\n\t\t\temit(\"node-click\", data, node, instance);\n\t\t};\n\n\t\t/**\n\t\t * 下拉框出现/隐藏时触发\n\t\t */\n\t\tconst handleVisibleChange = async (visible: boolean) => {\n\t\t\tif (visible) {\n\t\t\t\tif (state.debut) {\n\t\t\t\t\t// 首次出现\n\t\t\t\t\tstate.debut = false;\n\t\t\t\t\t// 懒加载\n\t\t\t\t\tprops.lazy && (await loadData());\n\t\t\t\t} else {\n\t\t\t\t\t// 判断再次出现是否需要刷新数据\n\t\t\t\t\tif (state.nextRefresh) {\n\t\t\t\t\t\tstate.nextRefresh = false;\n\t\t\t\t\t\tawait loadData();\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t// eslint-disable-next-line vue/custom-event-name-casing -- Element Plus 的公开事件名为 visible-change,需要保持原始名称透传。\n\t\t\temit(\"visible-change\", visible);\n\t\t};\n\n\t\tconst flattenOptions = (data: ElSelectorOutput[]): ElSelectorOutput[] =>\n\t\t\tdata.flatMap((item) => [item, ...flattenOptions(item.children ?? [])]);\n\n\t\tconst handleChange = (value?: ElSelectorModelValue) => {\n\t\t\tconst selectorData = flattenOptions(state.selectorData);\n\t\t\tif (props.multiple) {\n\t\t\t\tconst valueList = Array.isArray(value) ? value : [];\n\t\t\t\tif (valueList.length === 0) {\n\t\t\t\t\temit(\"change\", null, null);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tconst dataList = valueList\n\t\t\t\t\t.map((item) => selectorData.find((option) => option.value !== undefined && isEqual(option.value, item)))\n\t\t\t\t\t.filter((item) => item !== undefined);\n\t\t\t\temit(\"change\", dataList, value);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (value == null || Array.isArray(value)) {\n\t\t\t\temit(\"change\", null, null);\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst data = selectorData.find((item) => item.value !== undefined && isEqual(item.value, value));\n\t\t\temit(\"change\", data ?? null, value);\n\t\t};\n\n\t\twatch(\n\t\t\t() => props.modelValue,\n\t\t\t(newValue) => {\n\t\t\t\tif (state.echo && newValue != null) {\n\t\t\t\t\tconst hasLabel = props.label != null;\n\t\t\t\t\t// 判断是否为多选\n\t\t\t\t\tif (props.multiple) {\n\t\t\t\t\t\t// 判断是否为数组\n\t\t\t\t\t\tif (!Array.isArray(newValue)) {\n\t\t\t\t\t\t\tconsole.error(\"[Fast:FaTreeSelect]\", \"当启用 multiple 时,传入的 modelValue 必须是 Array。\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (hasLabel && !Array.isArray(props.label)) {\n\t\t\t\t\t\t\tconsole.error(\"[Fast:FaTreeSelect]\", \"当启用 multiple 时,传入的 modelValue:label 必须是 Array。\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstate.selectorData = newValue\n\t\t\t\t\t\t\t// 最大选项截取\n\t\t\t\t\t\t\t.slice(0, props.multipleLimit > 0 ? props.multipleLimit : newValue.length)\n\t\t\t\t\t\t\t.map((item, index) => {\n\t\t\t\t\t\t\t\tconst value: unknown = item;\n\t\t\t\t\t\t\t\tconst label: unknown = Array.isArray(props.label) ? props.label[index] : undefined;\n\t\t\t\t\t\t\t\tconst selectorValue: ElSelectorValue | undefined =\n\t\t\t\t\t\t\t\t\tvalue !== null &&\n\t\t\t\t\t\t\t\t\t(typeof value === \"string\" ||\n\t\t\t\t\t\t\t\t\t\ttypeof value === \"number\" ||\n\t\t\t\t\t\t\t\t\t\ttypeof value === \"boolean\" ||\n\t\t\t\t\t\t\t\t\t\ttypeof value === \"object\")\n\t\t\t\t\t\t\t\t\t\t? value\n\t\t\t\t\t\t\t\t\t\t: undefined;\n\t\t\t\t\t\t\t\treturn {\n\t\t\t\t\t\t\t\t\tvalue: selectorValue,\n\t\t\t\t\t\t\t\t\tlabel: hasLabel && typeof label === \"string\" ? label : undefined,\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t});\n\t\t\t\t\t} else {\n\t\t\t\t\t\tif (Array.isArray(newValue)) {\n\t\t\t\t\t\t\tconsole.error(\"[Fast:FaTreeSelect]\", \"当禁用 multiple 时,传入的 modelValue 不能是 Array。\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (hasLabel && Array.isArray(props.label)) {\n\t\t\t\t\t\t\tconsole.error(\"[Fast:FaTreeSelect]\", \"当禁用 multiple 时,传入的 modelValue:label 不能是 Array。\");\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tstate.selectorData = [\n\t\t\t\t\t\t\t{\n\t\t\t\t\t\t\t\tvalue: newValue,\n\t\t\t\t\t\t\t\tlabel: typeof props.label === \"string\" ? props.label : undefined,\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\tstate.value = newValue;\n\t\t\t},\n\t\t\t{\n\t\t\t\timmediate: true,\n\t\t\t}\n\t\t);\n\n\t\twatch(\n\t\t\t[() => state.value, () => state.selectorData],\n\t\t\t([value]) => {\n\t\t\t\tconst selectorData = flattenOptions(state.selectorData);\n\n\t\t\t\tif (props.multiple) {\n\t\t\t\t\tif (!Array.isArray(value)) {\n\t\t\t\t\t\tselectedLabel.value = null;\n\t\t\t\t\t\treturn;\n\t\t\t\t\t}\n\n\t\t\t\t\tselectedLabel.value = value.map((item, index) => {\n\t\t\t\t\t\tconst data = selectorData.find((option) => option.value !== undefined && isEqual(option.value, item));\n\n\t\t\t\t\t\treturn data?.label ?? (Array.isArray(props.label) ? (props.label[index] ?? \"\") : \"\");\n\t\t\t\t\t});\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (value == null || Array.isArray(value)) {\n\t\t\t\t\tselectedLabel.value = null;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tselectedLabel.value =\n\t\t\t\t\tselectorData.find((item) => item.value !== undefined && isEqual(item.value, value))?.label ??\n\t\t\t\t\t(typeof props.label === \"string\" ? props.label : null);\n\t\t\t},\n\t\t\t{\n\t\t\t\tdeep: true,\n\t\t\t\tflush: \"sync\",\n\t\t\t\timmediate: true,\n\t\t\t}\n\t\t);\n\n\t\twatch(\n\t\t\t() => props.initParam,\n\t\t\t(newValue, oldValue) => {\n\t\t\t\tif (!isEqual(newValue, oldValue)) {\n\t\t\t\t\tstate.nextRefresh = true;\n\t\t\t\t\tif (state.value != null) {\n\t\t\t\t\t\thandleModelValueUpdate(props.multiple ? [] : undefined);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t);\n\n\t\twatch(\n\t\t\t() => props.data,\n\t\t\t() => {\n\t\t\t\tif (!props.requestApi) {\n\t\t\t\t\treturn loadData();\n\t\t\t\t}\n\t\t\t},\n\t\t\t{ deep: true }\n\t\t);\n\n\t\twatch(\n\t\t\t() => props.data.length,\n\t\t\t(length) => {\n\t\t\t\tif (state.debut) state.echo = length === 0;\n\t\t\t},\n\t\t\t{ immediate: true }\n\t\t);\n\n\t\tonMounted(async () => {\n\t\t\tif (props.defaultSelected) {\n\t\t\t\tawait loadData();\n\t\t\t\tconst firstItem = state.selectorData[0];\n\t\t\t\tif (firstItem?.value !== undefined) {\n\t\t\t\t\tif (props.multiple) {\n\t\t\t\t\t\thandleModelValueUpdate([firstItem.value]);\n\t\t\t\t\t} else {\n\t\t\t\t\t\thandleModelValueUpdate(firstItem.value);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t\t// 判断是否为本地数据\n\t\t\telse if (!props.requestApi && props.data.length > 0) {\n\t\t\t\tstate.debut = false;\n\t\t\t\tawait loadData();\n\t\t\t}\n\t\t\t// 判断是否非默认选中,且未启用懒加载\n\t\t\telse if (!props.lazy) {\n\t\t\t\tawait loadData();\n\t\t\t}\n\t\t});\n\n\t\tconst elTreeSelectProps = useProps(props, { ...selectProps, ...treeProps }, [\n\t\t\t\"modelValue\",\n\t\t\t\"popperClass\",\n\t\t\t\"lazy\",\n\t\t\t\"loading\",\n\t\t\t\"expandOnClickNode\",\n\t\t\t\"filterNodeMethod\",\n\t\t\t\"props\",\n\t\t]);\n\t\tconst elTreeSelectEmits = useEmits({ ...selectEmits, ...treeEmits }, emit, [\"update:modelValue\", \"change\", \"visible-change\", \"node-click\"]);\n\n\t\tuseRender(() => (\n\t\t\t<ElTreeSelectRuntime\n\t\t\t\t{...elTreeSelectProps.value}\n\t\t\t\t{...elTreeSelectEmits.value}\n\t\t\t\tref={treeSelectRef}\n\t\t\t\tclass=\"fa-tree-select\"\n\t\t\t\tpopperClass={[\"fa-tree-select-dropdown\", props.popperClass]}\n\t\t\t\tstyle={{ width: addCssUnit(props.width) }}\n\t\t\t\tmodelValue={state.value}\n\t\t\t\tonUpdate:modelValue={handleModelValueUpdate}\n\t\t\t\tonChange={handleChange}\n\t\t\t\tlazy={false}\n\t\t\t\tloading={state.loading}\n\t\t\t\tdata={state.selectorData}\n\t\t\t\texpandOnClickNode={props.checkOnClickNode ? false : props.expandOnClickNode}\n\t\t\t\tfilterNodeMethod={handleFilterNode as typeof props.filterNodeMethod}\n\t\t\t\tonNodeClick={handleNodeClick}\n\t\t\t\tonVisible-change={handleVisibleChange}\n\t\t\t>\n\t\t\t\t{{\n\t\t\t\t\t...(slots.default && {\n\t\t\t\t\t\tdefault: ({ node, data }: { node: TreeNode; data: ElSelectorOutput }) => slots.default?.({ node, data }) ?? [],\n\t\t\t\t\t}),\n\t\t\t\t\t...(slots.header && { header: () => slots.header?.() ?? [] }),\n\t\t\t\t\t...(slots.footer && { footer: () => slots.footer?.() ?? [] }),\n\t\t\t\t\t...(slots.prefix && { prefix: () => slots.prefix?.() ?? [] }),\n\t\t\t\t\t...(slots.empty && { empty: () => slots.empty?.() ?? [] }),\n\t\t\t\t\t...(slots.tag && { tag: () => slots.tag?.() ?? [] }),\n\t\t\t\t\t...(slots.loading && { loading: () => slots.loading?.() ?? [] }),\n\t\t\t\t\t...(slots.label && {\n\t\t\t\t\t\tlabel: ({ label, value }: { label: string; value: string | number | boolean | object }) =>\n\t\t\t\t\t\t\tslots.label?.({ label, value }) ?? [],\n\t\t\t\t\t}),\n\t\t\t\t}}\n\t\t\t</ElTreeSelectRuntime>\n\t\t));\n\n\t\treturn useExpose(expose, {\n\t\t\t/** @description 使选择器的输入框获取焦点。 */\n\t\t\tfocus: computed(() => treeSelectRef.value?.focus),\n\t\t\t/** @description 使选择器的输入框失去焦点,并隐藏下拉框。 */\n\t\t\tblur: computed(() => treeSelectRef.value?.blur),\n\t\t\t/** @description 获取当前选中的标签。 */\n\t\t\tselectedLabel: computed(() => treeSelectRef.value?.selectedLabel),\n\t\t\t/** @description 过滤所有树节点,过滤后的节点将被隐藏。 */\n\t\t\tfilter: computed(() => treeSelectRef.value?.filter),\n\t\t\t/** @description 为节点设置新数据,只有设置 node-key 时可用。 */\n\t\t\tupdateKeyChildren: computed(() => treeSelectRef.value?.updateKeyChildren),\n\t\t\t/** @description 获取当前选中的节点。 */\n\t\t\tgetCheckedNodes: computed(() => treeSelectRef.value?.getCheckedNodes),\n\t\t\t/** @description 设置当前选中的节点。 */\n\t\t\tsetCheckedNodes: computed(() => treeSelectRef.value?.setCheckedNodes),\n\t\t\t/** @description 获取当前选中的节点 Key。 */\n\t\t\tgetCheckedKeys: computed(() => treeSelectRef.value?.getCheckedKeys),\n\t\t\t/** @description 设置当前选中的节点 Key。 */\n\t\t\tsetCheckedKeys: computed(() => treeSelectRef.value?.setCheckedKeys),\n\t\t\t/** @description 设置节点选中状态。 */\n\t\t\tsetChecked: computed(() => treeSelectRef.value?.setChecked),\n\t\t\t/** @description 获取当前半选中的节点。 */\n\t\t\tgetHalfCheckedNodes: computed(() => treeSelectRef.value?.getHalfCheckedNodes),\n\t\t\t/** @description 获取当前半选中的节点 Key。 */\n\t\t\tgetHalfCheckedKeys: computed(() => treeSelectRef.value?.getHalfCheckedKeys),\n\t\t\t/** @description 获取当前节点 Key。 */\n\t\t\tgetCurrentKey: computed(() => treeSelectRef.value?.getCurrentKey),\n\t\t\t/** @description 获取当前节点。 */\n\t\t\tgetCurrentNode: computed(() => treeSelectRef.value?.getCurrentNode),\n\t\t\t/** @description 设置当前节点 Key。 */\n\t\t\tsetCurrentKey: computed(() => treeSelectRef.value?.setCurrentKey),\n\t\t\t/** @description 设置当前节点。 */\n\t\t\tsetCurrentNode: computed(() => treeSelectRef.value?.setCurrentNode),\n\t\t\t/** @description 根据数据或 Key 获取节点。 */\n\t\t\tgetNode: computed(() => treeSelectRef.value?.getNode),\n\t\t\t/** @description 删除节点。 */\n\t\t\tremove: computed(() => treeSelectRef.value?.remove),\n\t\t\t/** @description 追加子节点。 */\n\t\t\tappend: computed(() => treeSelectRef.value?.append),\n\t\t\t/** @description 在指定节点前插入节点。 */\n\t\t\tinsertBefore: computed(() => treeSelectRef.value?.insertBefore),\n\t\t\t/** @description 在指定节点后插入节点。 */\n\t\t\tinsertAfter: computed(() => treeSelectRef.value?.insertAfter),\n\t\t\t/** @description Element Plus Tree 实例。 */\n\t\t\ttreeRef: computed(() => treeSelectRef.value?.treeRef),\n\t\t\t/** @description Element Plus Select 实例。 */\n\t\t\tselectRef: computed(() => treeSelectRef.value?.selectRef),\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\t/** @description 设置选择 */\n\t\t\tsetSelection: (value: Exclude<ElSelectorModelValue, null | undefined>) => handleModelValueUpdate(value),\n\t\t\t/** @description 清除选择 */\n\t\t\tclearSelection: () => handleModelValueUpdate(props.multiple ? [] : undefined),\n\t\t});\n\t},\n});\n"],"mappings":";;;;;;;;;;;AAoBA,MAAM,sBAAsB;;AA8B5B,MAAa,oBAAoB;CAChC,GAAG;CACH,GAAG;;CAEH,kBAAkB,EACjB,MAAM,eAAyC,QAAQ,EACxD;;;;;CAKA,WAAW;EACV,MAAM,eAMJ,KAAK;EACP,eAAe,CAAA;CAChB;;CAEA,UAAU;EACT,MAAM;EACN,SAAS,KAAA;CACV;;CAEA,aAAa;EACZ,MAAM;EACN,SAAS;CACV;;CAEA,aAAa;EACZ,MAAM;EACN,SAAS;CACV;;CAEA,YAAY;EACX,MAAM;EACN,SAAS;CACV;;CAEA,cAAc;EACb,MAAM;EACN,SAAS;CACV;;CAEA,qBAAqB;EACpB,MAAM;EACN,SAAS;CACV;;CAEA,SAAS;EACR,MAAM;EACN,SAAS;CACV;;CAEA,kBAAkB;EACjB,MAAM;EACN,SAAS;CACV;;CAEA,kBAAkB;EACjB,MAAM;EACN,SAAS;CACV;;CAEA,kBA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eAAe,cAAc,OAAO,kBAAkB;;GAE1E,eAAe,eAAe,cAAc,OAAO,aAAa;;GAEhE,gBAAgB,eAAe,cAAc,OAAO,cAAc;;GAElE,eAAe,eAAe,cAAc,OAAO,aAAa;;GAEhE,gBAAgB,eAAe,cAAc,OAAO,cAAc;;GAElE,SAAS,eAAe,cAAc,OAAO,OAAO;;GAEpD,QAAQ,eAAe,cAAc,OAAO,MAAM;;GAElD,QAAQ,eAAe,cAAc,OAAO,MAAM;;GAElD,cAAc,eAAe,cAAc,OAAO,YAAY;;GAE9D,aAAa,eAAe,cAAc,OAAO,WAAW;;GAE5D,SAAS,eAAe,cAAc,OAAO,OAAO;;GAEpD,WAAW,eAAe,cAAc,OAAO,SAAS;;GAExD,SAAS,eAAe,MAAM,OAAO;;GAErC,SAAS;;GAET,eAAe,UAA2D,uBAAuB,KAAK;;GAEtG,sBAAsB,uBAAuB,MAAM,WAAW,CAAA,IAAK,KAAA,CAAS;EAC7E,CAAC;CACF;AACD,CAAC"}
@@ -461,10 +461,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
461
461
  onChange: (uploadFile: UploadFile, uploadFiles: import("element-plus").UploadFiles) => void;
462
462
  onProgress: (evt: import("element-plus").UploadProgressEvent, uploadFile: UploadFile, uploadFiles: import("element-plus").UploadFiles) => void;
463
463
  drag: boolean;
464
- onRemove: (uploadFile: UploadFile, uploadFiles: import("element-plus").UploadFiles) => void;
465
464
  multiple: boolean;
466
465
  fileList: UploadUserFile[];
467
466
  beforeUpload: (rawFile: import("element-plus").UploadRawFile) => import("element-plus/es/utils/typescript.mjs").Awaitable<void | undefined | null | boolean | File | Blob>;
467
+ onRemove: (uploadFile: UploadFile, uploadFiles: import("element-plus").UploadFiles) => void;
468
468
  onPreview: (uploadFile: UploadFile) => void;
469
469
  onSuccess: (response: any, uploadFile: UploadFile, uploadFiles: import("element-plus").UploadFiles) => void;
470
470
  onExceed: (files: File[], uploadFiles: UploadUserFile[]) => void;
@@ -3,10 +3,9 @@ import { definePropType, useProps } from "../../../utils/vue/props.mjs";
3
3
  import { useRender } from "../../../utils/vue/render.mjs";
4
4
  import { makeSlots } from "../../../utils/vue/slots.mjs";
5
5
  import { useUpload } from "./useUpload.mjs";
6
- import { Fragment, computed, createTextVNode, createVNode, defineComponent, mergeProps, ref, resolveDirective, withDirectives } from "vue";
6
+ import { Fragment, computed, createTextVNode, createVNode, defineComponent, mergeProps, resolveDirective, shallowRef, withDirectives } from "vue";
7
7
  import { UploadFilled } from "@element-plus/icons-vue";
8
8
  import { ElIcon, ElUpload, uploadProps } from "element-plus";
9
- import { isArray, isNull, isString } from "lodash-unified";
10
9
  //#region src/components/upload/src/upload.tsx
11
10
  /** FaUpload 的运行时 Props 定义。 */
12
11
  const faUploadProps = {
@@ -36,9 +35,9 @@ const faUploadProps = {
36
35
  /** FaUpload 的运行时 Emits 定义。 */
37
36
  const faUploadEmits = {
38
37
  /** @description v-model 回调 */
39
- "update:modelValue": (value) => isString(value) || isArray(value) || isNull(value),
38
+ "update:modelValue": (value) => typeof value === "string" || Array.isArray(value) || value === null,
40
39
  /** @description v-model:fileList 回调 */
41
- "update:fileList": (value) => isArray(value)
40
+ "update:fileList": (value) => Array.isArray(value)
42
41
  };
43
42
  var upload_default = defineComponent({
44
43
  name: "FaUpload",
@@ -57,14 +56,14 @@ var upload_default = defineComponent({
57
56
  return props.uploadUrl || (props.action === uploadProps.action.default ? void 0 : props.action);
58
57
  }
59
58
  });
59
+ const uploadRef = shallowRef(null);
60
60
  const disabled = computed(() => {
61
61
  return props.disabled === true || formContext?.disabled === true;
62
62
  });
63
- const uploadRef = ref();
64
63
  const httpRequest = computed(() => props.httpRequest === uploadProps.httpRequest.default ? handleHttpRequest : props.httpRequest);
65
64
  const handleBeforeUpload = (rawFile) => {
66
65
  if (!handleOnUpload(rawFile)) return false;
67
- return props.beforeUpload?.(rawFile) ?? true;
66
+ return props.beforeUpload(rawFile);
68
67
  };
69
68
  const elUploadProps = useProps(props, uploadProps, [
70
69
  "fileList",
@@ -1 +1 @@
1
- {"version":3,"file":"upload.mjs","names":["update:modelValue","update:fileList"],"sources":["../../../../src/components/upload/src/upload.tsx"],"sourcesContent":["import { Fragment, computed, defineComponent, ref } from \"vue\";\nimport { UploadFilled } from \"@element-plus/icons-vue\";\nimport { ElIcon, ElUpload, uploadProps } from \"element-plus\";\nimport { isArray, isNull, isString } from \"lodash-unified\";\nimport { definePropType, makeSlots, useExpose, useProps, useRender } from \"../../../utils\";\nimport { useUpload } from \"./useUpload\";\nimport type { UploadFile, UploadInstance, UploadProps, UploadUserFile } from \"element-plus\";\nimport type { VNode } from \"vue\";\n\n/** FaUpload 的运行时 Props 定义。 */\nexport const faUploadProps = {\n\t...uploadProps,\n\t/** @description whether to activate drag and drop mode */\n\tdrag: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t},\n\t/** @description maximum number of uploads allowed */\n\tlimit: {\n\t\ttype: Number,\n\t\tdefault: 1,\n\t},\n\t/** @description v-model绑定值 */\n\tmodelValue: definePropType<string | string[] | null>([String, Array]),\n\t/** @description 大小限制,单位kb */\n\tmaxSize: {\n\t\ttype: definePropType<string | number>([String, Number]),\n\t\tdefault: 5120,\n\t},\n\t/** @description 图片上传接口,优先级最高 */\n\tuploadApi: {\n\t\ttype: definePropType<(formData: FormData) => Promise<string>>(Function),\n\t},\n\t/** @description 图片上传地址 */\n\tuploadUrl: String,\n};\n\n/** FaUpload 的运行时 Emits 定义。 */\nexport const faUploadEmits = {\n\t/** @description v-model 回调 */\n\t\"update:modelValue\": (value: string | string[] | null): boolean => isString(value) || isArray(value) || isNull(value),\n\t/** @description v-model:fileList 回调 */\n\t\"update:fileList\": (value: UploadUserFile[]): boolean => isArray(value),\n};\n\n/** FaUpload 的插槽参数。 */\nexport interface FaUploadSlots extends Record<string, unknown> {\n\t/** @description 默认内容插槽 */\n\tdefault: never;\n\t/** @description 触发文件选择框的内容 */\n\ttrigger: never;\n\t/** @description 提示说明文字 */\n\ttip: never;\n\t/** @description 缩略图模板的内容 */\n\tfile: { file: UploadFile; index: number };\n}\n\nexport default defineComponent({\n\tname: \"FaUpload\",\n\tprops: faUploadProps,\n\temits: faUploadEmits,\n\tslots: makeSlots<FaUploadSlots>(),\n\tsetup(props, { slots, emit, expose }) {\n\t\tconst {\n\t\t\tfileList,\n\t\t\tloading,\n\t\t\tformContext,\n\t\t\tmaxSizeMB,\n\t\t\thandleHttpRequest,\n\t\t\thandleOnSuccess,\n\t\t\thandleOnError,\n\t\t\thandleOnRemove,\n\t\t\thandleOnExceed,\n\t\t\thandleOnUpload,\n\t\t\thandleOnChange,\n\t\t} = useUpload(\"FaUpload\", \"文件\", props, emit, {\n\t\t\tget maxSize() {\n\t\t\t\treturn props.maxSize;\n\t\t\t},\n\t\t\tget uploadApi() {\n\t\t\t\treturn props.uploadApi;\n\t\t\t},\n\t\t\tget uploadUrl() {\n\t\t\t\treturn props.uploadUrl || (props.action === uploadProps.action.default ? undefined : props.action);\n\t\t\t},\n\t\t});\n\n\t\tconst disabled = computed(() => {\n\t\t\treturn props.disabled === true || formContext?.disabled === true;\n\t\t});\n\n\t\tconst uploadRef = ref<UploadInstance>();\n\t\tconst httpRequest = computed(() => (props.httpRequest === uploadProps.httpRequest.default ? handleHttpRequest : props.httpRequest));\n\n\t\tconst handleBeforeUpload: UploadProps[\"beforeUpload\"] = (rawFile) => {\n\t\t\tif (!handleOnUpload(rawFile)) return false;\n\t\t\treturn props.beforeUpload?.(rawFile) ?? true;\n\t\t};\n\n\t\tconst elUploadProps = useProps(props, uploadProps, [\n\t\t\t\"fileList\",\n\t\t\t\"disabled\",\n\t\t\t\"httpRequest\",\n\t\t\t\"beforeUpload\",\n\t\t\t\"onExceed\",\n\t\t\t\"onSuccess\",\n\t\t\t\"onError\",\n\t\t\t\"onRemove\",\n\t\t\t\"onChange\",\n\t\t]);\n\n\t\tuseRender(() => (\n\t\t\t<ElUpload\n\t\t\t\t{...elUploadProps.value}\n\t\t\t\tref={uploadRef}\n\t\t\t\tclass=\"fa-upload\"\n\t\t\t\tvLoading={loading.value}\n\t\t\t\tvModel:fileList={fileList.value}\n\t\t\t\tdisabled={disabled.value}\n\t\t\t\thttpRequest={httpRequest.value}\n\t\t\t\tbeforeUpload={handleBeforeUpload}\n\t\t\t\tonExceed={handleOnExceed}\n\t\t\t\tonSuccess={handleOnSuccess}\n\t\t\t\tonError={handleOnError}\n\t\t\t\tonRemove={handleOnRemove}\n\t\t\t\tonChange={handleOnChange}\n\t\t\t>\n\t\t\t\t{{\n\t\t\t\t\tdefault: () =>\n\t\t\t\t\t\tslots.default ? (\n\t\t\t\t\t\t\tslots.default()\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<Fragment>\n\t\t\t\t\t\t\t\t<ElIcon class=\"el-icon--upload\">\n\t\t\t\t\t\t\t\t\t<UploadFilled />\n\t\t\t\t\t\t\t\t</ElIcon>\n\t\t\t\t\t\t\t\t<div class=\"el-upload__text\">\n\t\t\t\t\t\t\t\t\tDrop file here or <em>click to upload</em>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</Fragment>\n\t\t\t\t\t\t),\n\t\t\t\t\t...(slots.trigger && { trigger: (): VNode | VNode[] => slots.trigger?.() ?? [] }),\n\t\t\t\t\ttip: () =>\n\t\t\t\t\t\tslots.tip ? (\n\t\t\t\t\t\t\tslots.tip()\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<Fragment>\n\t\t\t\t\t\t\t\t<div class=\"el-upload__tip\">files with a size less than {maxSizeMB.value.toString()}MB</div>\n\t\t\t\t\t\t\t\t{!props.showFileList && fileList.value.length > 0 && (\n\t\t\t\t\t\t\t\t\t<div class=\"el-upload__tip\">\n\t\t\t\t\t\t\t\t\t\t{fileList.value.map((item, index) => (\n\t\t\t\t\t\t\t\t\t\t\t<Fragment>\n\t\t\t\t\t\t\t\t\t\t\t\t{item.name}\n\t\t\t\t\t\t\t\t\t\t\t\t{fileList.value.length <= index && <br />}\n\t\t\t\t\t\t\t\t\t\t\t</Fragment>\n\t\t\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</Fragment>\n\t\t\t\t\t\t),\n\t\t\t\t\t...(slots.file && {\n\t\t\t\t\t\tfile: ({ file, index }: { file: UploadFile; index: number }): VNode | VNode[] => slots.file?.({ file, index }) ?? [],\n\t\t\t\t\t}),\n\t\t\t\t}}\n\t\t\t</ElUpload>\n\t\t));\n\n\t\treturn useExpose(expose, {\n\t\t\t/** @description 取消上传请求 */\n\t\t\tabort: computed(() => uploadRef.value?.abort),\n\t\t\t/** @description 手动上传文件列表 */\n\t\t\tsubmit: computed(() => uploadRef.value?.submit),\n\t\t\t/** @description 清空已上传的文件列表(该方法不支持在 before-upload 中调用) */\n\t\t\tclearFiles: computed(() => uploadRef.value?.clearFiles),\n\t\t\t/** @description 手动选择文件 */\n\t\t\thandleStart: computed(() => uploadRef.value?.handleStart),\n\t\t\t/** @description 手动移除文件。file 和 rawFile 已被合并。 */\n\t\t\thandleRemove: computed(() => uploadRef.value?.handleRemove),\n\t\t\t/** @description 加载状态 */\n\t\t\tloading,\n\t\t\t/** @description 文件集合 */\n\t\t\tfileList,\n\t\t});\n\t},\n});\n"],"mappings":";;;;;;;;;;;AAUA,MAAa,gBAAgB;CAC5B,GAAG;;CAEH,MAAM;EACL,MAAM;EACN,SAAS;CACV;;CAEA,OAAO;EACN,MAAM;EACN,SAAS;CACV;;CAEA,YAAY,eAAyC,CAAC,QAAQ,KAAK,CAAC;;CAEpE,SAAS;EACR,MAAM,eAAgC,CAAC,QAAQ,MAAM,CAAC;EACtD,SAAS;CACV;;CAEA,WAAW,EACV,MAAM,eAAwD,QAAQ,EACvE;;CAEA,WAAW;AACZ;;AAGA,MAAa,gBAAgB;;CAE5B,sBAAsB,UAA6C,SAAS,KAAK,KAAK,QAAQ,KAAK,KAAK,OAAO,KAAK;;CAEpH,oBAAoB,UAAqC,QAAQ,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YAAA,OAAA,EAAA,SAAA,kBAAA,GAAA,CAAA,gBAAA,oBAAA,GAAA,YAAA,MAAA,MAAA,CAAA,gBAAA,iBAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAAA;GAWjB,GAAI,MAAM,WAAW,EAAE,eAAgC,MAAM,UAAU,KAAK,CAAA,EAAG;GAC/E,WACC,MAAM,MACL,MAAM,IAAI,IAAC,YAAA,UAAA,MAAA,CAAA,YAAA,OAAA,EAAA,SAAA,iBAAA,GAAA;IAAA,gBAAA,8BAAA;IAG+C,UAAU,MAAM,SAAS;IAAC,gBAAA,IAAA;GAAA,CAAA,GAClF,CAAC,MAAM,gBAAgB,SAAS,MAAM,SAAS,KAAC,YAAA,OAAA,EAAA,SAAA,iBAAA,GAAA,CAE9C,SAAS,MAAM,KAAK,MAAM,UAAK,YAAA,UAAA,MAAA,CAE7B,KAAK,MACL,SAAS,MAAM,UAAU,SAAK,YAAA,MAAA,MAAA,IAAA,CAAU,CAAA,CAE1C,CAAC,CAAA,CAEH,CAAA;GAGJ,GAAI,MAAM,QAAQ,EACjB,OAAO,EAAE,MAAM,YAAkE,MAAM,OAAO;IAAE;IAAM;GAAM,CAAC,KAAK,CAAA,EACnH;EAAE,CAAA,GAAA,CAAA,CAAA,iBAAA,SAAA,GA9CO,QAAQ,KAAK,CAAA,CAAA,CAiDxB;EAED,OAAO,UAAU,QAAQ;;GAExB,OAAO,eAAe,UAAU,OAAO,KAAK;;GAE5C,QAAQ,eAAe,UAAU,OAAO,MAAM;;GAE9C,YAAY,eAAe,UAAU,OAAO,UAAU;;GAEtD,aAAa,eAAe,UAAU,OAAO,WAAW;;GAExD,cAAc,eAAe,UAAU,OAAO,YAAY;;GAE1D;;GAEA;EACD,CAAC;CACF;AACD,CAAC"}
1
+ {"version":3,"file":"upload.mjs","names":["update:modelValue","update:fileList"],"sources":["../../../../src/components/upload/src/upload.tsx"],"sourcesContent":["import { Fragment, computed, defineComponent, shallowRef } from \"vue\";\nimport { UploadFilled } from \"@element-plus/icons-vue\";\nimport { ElIcon, ElUpload, uploadProps } from \"element-plus\";\nimport { definePropType, makeSlots, useExpose, useProps, useRender } from \"../../../utils\";\nimport { useUpload } from \"./useUpload\";\nimport type { UploadFile, UploadInstance, UploadProps, UploadUserFile } from \"element-plus\";\n\n/** FaUpload 的运行时 Props 定义。 */\nexport const faUploadProps = {\n\t// eslint-disable-next-line @typescript-eslint/no-deprecated -- Element Plus 2.x 尚未提供可替代的公开运行时 props 定义。\n\t...uploadProps,\n\t/** @description whether to activate drag and drop mode */\n\tdrag: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t},\n\t/** @description maximum number of uploads allowed */\n\tlimit: {\n\t\ttype: Number,\n\t\tdefault: 1,\n\t},\n\t/** @description v-model绑定值 */\n\tmodelValue: definePropType<string | string[] | null>([String, Array]),\n\t/** @description 大小限制,单位kb */\n\tmaxSize: {\n\t\ttype: definePropType<string | number>([String, Number]),\n\t\tdefault: 5120,\n\t},\n\t/** @description 图片上传接口,优先级最高 */\n\tuploadApi: {\n\t\ttype: definePropType<(formData: FormData) => Promise<string>>(Function),\n\t},\n\t/** @description 图片上传地址 */\n\tuploadUrl: String,\n};\n\n/** FaUpload 的运行时 Emits 定义。 */\nexport const faUploadEmits = {\n\t/** @description v-model 回调 */\n\t\"update:modelValue\": (value: string | string[] | null) => typeof value === \"string\" || Array.isArray(value) || value === null,\n\t/** @description v-model:fileList 回调 */\n\t\"update:fileList\": (value: UploadUserFile[]) => Array.isArray(value),\n};\n\n/** FaUpload 的插槽参数。 */\nexport interface FaUploadSlots extends Record<string, unknown> {\n\t/** @description 默认内容插槽 */\n\tdefault: never;\n\t/** @description 触发文件选择框的内容 */\n\ttrigger: never;\n\t/** @description 提示说明文字 */\n\ttip: never;\n\t/** @description 缩略图模板的内容 */\n\tfile: { file: UploadFile; index: number };\n}\n\nexport default defineComponent({\n\tname: \"FaUpload\",\n\tprops: faUploadProps,\n\temits: faUploadEmits,\n\tslots: makeSlots<FaUploadSlots>(),\n\tsetup(props, { slots, emit, expose }) {\n\t\tconst {\n\t\t\tfileList,\n\t\t\tloading,\n\t\t\tformContext,\n\t\t\tmaxSizeMB,\n\t\t\thandleHttpRequest,\n\t\t\thandleOnSuccess,\n\t\t\thandleOnError,\n\t\t\thandleOnRemove,\n\t\t\thandleOnExceed,\n\t\t\thandleOnUpload,\n\t\t\thandleOnChange,\n\t\t} = useUpload(\"FaUpload\", \"文件\", props, emit, {\n\t\t\tget maxSize() {\n\t\t\t\treturn props.maxSize;\n\t\t\t},\n\t\t\tget uploadApi() {\n\t\t\t\treturn props.uploadApi;\n\t\t\t},\n\t\t\tget uploadUrl() {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated -- 需要与 Element Plus 2.x 的运行时默认 action 比较。\n\t\t\t\treturn props.uploadUrl || (props.action === uploadProps.action.default ? undefined : props.action);\n\t\t\t},\n\t\t});\n\n\t\tconst uploadRef = shallowRef<UploadInstance | null>(null);\n\t\tconst disabled = computed(() => {\n\t\t\treturn props.disabled === true || formContext?.disabled === true;\n\t\t});\n\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated -- 需要识别 Element Plus 2.x 注入的默认请求实现。\n\t\tconst httpRequest = computed(() => (props.httpRequest === uploadProps.httpRequest.default ? handleHttpRequest : props.httpRequest));\n\n\t\tconst handleBeforeUpload: UploadProps[\"beforeUpload\"] = (rawFile) => {\n\t\t\tif (!handleOnUpload(rawFile)) return false;\n\t\t\treturn props.beforeUpload(rawFile);\n\t\t};\n\n\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated -- 透传范围必须与继承的 Element Plus 2.x 运行时 props 保持一致。\n\t\tconst elUploadProps = useProps(props, uploadProps, [\n\t\t\t\"fileList\",\n\t\t\t\"disabled\",\n\t\t\t\"httpRequest\",\n\t\t\t\"beforeUpload\",\n\t\t\t\"onExceed\",\n\t\t\t\"onSuccess\",\n\t\t\t\"onError\",\n\t\t\t\"onRemove\",\n\t\t\t\"onChange\",\n\t\t]);\n\n\t\tuseRender(() => (\n\t\t\t<ElUpload\n\t\t\t\t{...elUploadProps.value}\n\t\t\t\tref={uploadRef}\n\t\t\t\tclass=\"fa-upload\"\n\t\t\t\tvLoading={loading.value}\n\t\t\t\tvModel:fileList={fileList.value}\n\t\t\t\tdisabled={disabled.value}\n\t\t\t\thttpRequest={httpRequest.value}\n\t\t\t\tbeforeUpload={handleBeforeUpload}\n\t\t\t\tonExceed={handleOnExceed}\n\t\t\t\tonSuccess={handleOnSuccess}\n\t\t\t\tonError={handleOnError}\n\t\t\t\tonRemove={handleOnRemove}\n\t\t\t\tonChange={handleOnChange}\n\t\t\t>\n\t\t\t\t{{\n\t\t\t\t\tdefault: () =>\n\t\t\t\t\t\tslots.default ? (\n\t\t\t\t\t\t\tslots.default()\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<Fragment>\n\t\t\t\t\t\t\t\t<ElIcon class=\"el-icon--upload\">\n\t\t\t\t\t\t\t\t\t<UploadFilled />\n\t\t\t\t\t\t\t\t</ElIcon>\n\t\t\t\t\t\t\t\t<div class=\"el-upload__text\">\n\t\t\t\t\t\t\t\t\tDrop file here or <em>click to upload</em>\n\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t</Fragment>\n\t\t\t\t\t\t),\n\t\t\t\t\t...(slots.trigger && { trigger: () => slots.trigger?.() ?? [] }),\n\t\t\t\t\ttip: () =>\n\t\t\t\t\t\tslots.tip ? (\n\t\t\t\t\t\t\tslots.tip()\n\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t<Fragment>\n\t\t\t\t\t\t\t\t<div class=\"el-upload__tip\">files with a size less than {maxSizeMB.value.toString()}MB</div>\n\t\t\t\t\t\t\t\t{!props.showFileList && fileList.value.length > 0 && (\n\t\t\t\t\t\t\t\t\t<div class=\"el-upload__tip\">\n\t\t\t\t\t\t\t\t\t\t{fileList.value.map((item, index) => (\n\t\t\t\t\t\t\t\t\t\t\t<Fragment>\n\t\t\t\t\t\t\t\t\t\t\t\t{item.name}\n\t\t\t\t\t\t\t\t\t\t\t\t{fileList.value.length <= index && <br />}\n\t\t\t\t\t\t\t\t\t\t\t</Fragment>\n\t\t\t\t\t\t\t\t\t\t))}\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t</Fragment>\n\t\t\t\t\t\t),\n\t\t\t\t\t...(slots.file && {\n\t\t\t\t\t\tfile: ({ file, index }: { file: UploadFile; index: number }) => slots.file?.({ file, index }) ?? [],\n\t\t\t\t\t}),\n\t\t\t\t}}\n\t\t\t</ElUpload>\n\t\t));\n\n\t\treturn useExpose(expose, {\n\t\t\t/** @description 取消上传请求 */\n\t\t\tabort: computed(() => uploadRef.value?.abort),\n\t\t\t/** @description 手动上传文件列表 */\n\t\t\tsubmit: computed(() => uploadRef.value?.submit),\n\t\t\t/** @description 清空已上传的文件列表(该方法不支持在 before-upload 中调用) */\n\t\t\tclearFiles: computed(() => uploadRef.value?.clearFiles),\n\t\t\t/** @description 手动选择文件 */\n\t\t\thandleStart: computed(() => uploadRef.value?.handleStart),\n\t\t\t/** @description 手动移除文件。file 和 rawFile 已被合并。 */\n\t\t\thandleRemove: computed(() => uploadRef.value?.handleRemove),\n\t\t\t/** @description 加载状态 */\n\t\t\tloading,\n\t\t\t/** @description 文件集合 */\n\t\t\tfileList,\n\t\t});\n\t},\n});\n"],"mappings":";;;;;;;;;;AAQA,MAAa,gBAAgB;CAE5B,GAAG;;CAEH,MAAM;EACL,MAAM;EACN,SAAS;CACV;;CAEA,OAAO;EACN,MAAM;EACN,SAAS;CACV;;CAEA,YAAY,eAAyC,CAAC,QAAQ,KAAK,CAAC;;CAEpE,SAAS;EACR,MAAM,eAAgC,CAAC,QAAQ,MAAM,CAAC;EACtD,SAAS;CACV;;CAEA,WAAW,EACV,MAAM,eAAwD,QAAQ,EACvE;;CAEA,WAAW;AACZ;;AAGA,MAAa,gBAAgB;;CAE5B,sBAAsB,UAAoC,OAAO,UAAU,YA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, onMounted, ref, watch } from "vue";
2
+ import { computed, inject, onMounted, ref, useModel, watch } from "vue";
3
3
  import { ElMessage, ElNotification, formContextKey, formItemContextKey, genFileId, uploadProps } from "element-plus";
4
- import { isArray, isNumber } from "lodash-unified";
5
- import { useVModel } from "@vueuse/core";
6
4
  import { Decimal } from "decimal.js";
7
5
  //#region src/components/upload/src/useUpload.ts
8
6
  /**
@@ -16,7 +14,7 @@ import { Decimal } from "decimal.js";
16
14
  * @returns 文件列表、加载状态和上传操作方法。
17
15
  */
18
16
  const useUpload = (componentName, fileTypeName, props, emit, data) => {
19
- const fileListModel = useVModel(props, "fileList", emit, { passive: true });
17
+ const fileListModel = useModel(props, "fileList");
20
18
  const fileList = computed({
21
19
  get: () => fileListModel.value ?? [],
22
20
  set: (value) => {
@@ -28,10 +26,10 @@ const useUpload = (componentName, fileTypeName, props, emit, data) => {
28
26
  const formContext = inject(formContextKey, void 0);
29
27
  const formItemContext = inject(formItemContextKey, void 0);
30
28
  const mbNum = new Decimal(1024);
31
- const maxSizeKB = computed(() => new Decimal(isNumber(data?.maxSize) ? data.maxSize : Number(data?.maxSize)));
29
+ const maxSizeKB = computed(() => new Decimal(typeof data?.maxSize === "number" ? data.maxSize : Number(data?.maxSize)));
32
30
  const maxSizeMB = computed(() => maxSizeKB.value.div(mbNum));
33
31
  onMounted(() => {
34
- if (!props.disabled && props.autoUpload && !data?.uploadApi && !data?.uploadUrl && props.httpRequest === uploadProps.httpRequest.default) console.warn(`[Fast:${componentName}]`, "uploadApi 和 uploadUrl 至少需要提供一个。");
32
+ if (!props.disabled && props.autoUpload && !data?.uploadApi && !data?.uploadUrl && props.httpRequest === uploadProps.httpRequest.default) console.error(`[Fast:${componentName}]`, "uploadApi 和 uploadUrl 至少需要提供一个。");
35
33
  });
36
34
  const handleValue = (files = fileList.value) => {
37
35
  let value;
@@ -51,16 +49,16 @@ const useUpload = (componentName, fileTypeName, props, emit, data) => {
51
49
  const error = /* @__PURE__ */ new Error(`上传${fileTypeName}接口 uploadApi 或地址 uploadUrl 不能为空。`);
52
50
  ElMessage.error(`上传${fileTypeName}Api或地址不能为空`);
53
51
  console.error(`[Fast:${componentName}]`, error.message);
54
- return Promise.reject(error);
52
+ throw error;
55
53
  }
56
54
  activeUploadCount++;
57
55
  loading.value = true;
58
56
  try {
59
57
  let fileUrl;
60
- if (data?.uploadApi) fileUrl = await uploadUtil.uploadFileByApi(data.uploadApi, options.file, options.filename, propsData);
58
+ if (data.uploadApi) fileUrl = await uploadUtil.uploadFileByApi(data.uploadApi, options.file, options.filename, propsData);
61
59
  else {
62
60
  const headers = options.headers instanceof Headers ? options.headers : new Headers(Object.entries(options.headers).flatMap(([key, value]) => value === null || value === void 0 ? [] : [[key, String(value)]]));
63
- fileUrl = await uploadUtil.uploadFile(data?.uploadUrl ?? options.action, options.file, options.filename, propsData, {
61
+ fileUrl = await uploadUtil.uploadFile(data.uploadUrl ?? options.action, options.file, options.filename, propsData, {
64
62
  headers,
65
63
  method: options.method,
66
64
  withCredentials: options.withCredentials
@@ -124,7 +122,7 @@ const useUpload = (componentName, fileTypeName, props, emit, data) => {
124
122
  */
125
123
  watch(() => props.modelValue, (newValue) => {
126
124
  if (newValue) {
127
- if (isArray(newValue)) fileList.value = newValue.map((m) => {
125
+ if (Array.isArray(newValue)) fileList.value = newValue.map((m) => {
128
126
  const find = fileList.value.find((f) => f.url === m);
129
127
  const urlWithoutParams = m.split(/[?#]/u)[0] ?? "";
130
128
  const fileName = urlWithoutParams.slice(urlWithoutParams.lastIndexOf("/") + 1);
@@ -1 +1 @@
1
- {"version":3,"file":"useUpload.mjs","names":[],"sources":["../../../../src/components/upload/src/useUpload.ts"],"sourcesContent":["import { useVModel } from \"@vueuse/core\";\nimport { computed, inject, onMounted, ref, watch } from \"vue\";\nimport { ElMessage, ElNotification, formContextKey, formItemContextKey, genFileId, uploadProps } from \"element-plus\";\nimport { isArray, isNumber } from \"lodash-unified\";\nimport { Decimal } from \"decimal.js\";\nimport { uploadUtil } from \"../utils/upload\";\nimport type {\n\tFormContext,\n\tFormItemContext,\n\tUploadFile,\n\tUploadFiles,\n\tUploadProps,\n\tUploadRawFile,\n\tUploadRequestOptions,\n\tUploadUserFile,\n} from \"element-plus\";\nimport type { ComputedRef, Ref, WritableComputedRef } from \"vue\";\n\ninterface UploadComposable {\n\tfileList: WritableComputedRef<UploadUserFile[]>;\n\tloading: Ref<boolean>;\n\tformContext: FormContext | undefined;\n\tformItemContext: FormItemContext | undefined;\n\tmaxSizeMB: ComputedRef<Decimal>;\n\thandleValue: () => void;\n\thandleHttpRequest: (options: UploadRequestOptions) => Promise<void>;\n\thandleOnSuccess: (fileUrl: string, uploadFile: UploadFile, uploadFiles: UploadFiles) => void;\n\thandleOnError: (error: Error, uploadFile: UploadFile, uploadFiles: UploadFiles) => void;\n\thandleOnRemove: (uploadFile: UploadFile, uploadFiles: UploadFiles) => void;\n\thandleOnExceed: (files: File[], uploadFiles: UploadUserFile[]) => void;\n\thandleOnUpload: (file: UploadFile | UploadRawFile) => boolean;\n\thandleOnChange: (uploadFile: UploadFile, uploadFiles: UploadFiles) => void;\n}\n\n/**\n * 创建上传组件共享的文件状态和操作方法。\n *\n * @param componentName - 组件名称。\n * @param fileTypeName - 文件类型名称。\n * @param props - 上传组件的 Props。\n * @param emit - 上传组件的事件触发器。\n * @param options - 文件大小和类型校验配置。\n * @returns 文件列表、加载状态和上传操作方法。\n */\nexport const useUpload = <T extends string | string[]>(\n\tcomponentName: string,\n\tfileTypeName: string,\n\tprops: Partial<UploadProps> & {\n\t\tmodelValue?: T | null;\n\t},\n\temit: ((event: \"update:fileList\", value: UploadUserFile[]) => void) & ((event: \"update:modelValue\", value: T | null) => void),\n\tdata?: {\n\t\tmaxSize?: string | number;\n\t\tuploadApi?: (formData: FormData) => Promise<string>;\n\t\tuploadUrl?: string;\n\t}\n): UploadComposable => {\n\tconst fileListModel = useVModel(props, \"fileList\", emit, { passive: true });\n\tconst fileList = computed<UploadUserFile[]>({\n\t\tget: () => fileListModel.value ?? [],\n\t\tset: (value) => {\n\t\t\tfileListModel.value = value;\n\t\t},\n\t});\n\n\tconst loading = ref(false);\n\tlet activeUploadCount = 0;\n\n\t// 获取 el-form 组件上下文\n\tconst formContext = inject(formContextKey, undefined);\n\t// 获取 el-form-item 组件上下文\n\tconst formItemContext = inject(formItemContextKey, undefined);\n\n\tconst mbNum = new Decimal(1024);\n\tconst maxSizeKB = computed(() => new Decimal(isNumber(data?.maxSize) ? data.maxSize : Number(data?.maxSize)));\n\tconst maxSizeMB = computed(() => maxSizeKB.value.div(mbNum));\n\n\tonMounted(() => {\n\t\tif (!props.disabled && props.autoUpload && !data?.uploadApi && !data?.uploadUrl && props.httpRequest === uploadProps.httpRequest.default) {\n\t\t\tconsole.warn(`[Fast:${componentName}]`, \"uploadApi 和 uploadUrl 至少需要提供一个。\");\n\t\t}\n\t});\n\n\tconst handleValue = (files: UploadUserFile[] = fileList.value): void => {\n\t\tlet value: T | null;\n\t\tif (files.length > 0) {\n\t\t\tif (props.multiple === true) {\n\t\t\t\tvalue = files.flatMap((item) => (item.url ? [item.url] : [])) as T;\n\t\t\t} else {\n\t\t\t\tconst fileUrl = files[0]?.url;\n\t\t\t\tif (!fileUrl) return;\n\t\t\t\tvalue = fileUrl as T;\n\t\t\t}\n\t\t} else {\n\t\t\tvalue = props.multiple === true ? ([] as unknown as T) : null;\n\t\t}\n\t\temit(\"update:modelValue\", value);\n\t};\n\n\tconst handleHttpRequest = async (options: UploadRequestOptions): Promise<void> => {\n\t\tconst propsData = options.data;\n\t\tif (!data?.uploadApi && !data?.uploadUrl) {\n\t\t\tconst error = new Error(`上传${fileTypeName}接口 uploadApi 或地址 uploadUrl 不能为空。`);\n\t\t\tElMessage.error(`上传${fileTypeName}Api或地址不能为空`);\n\t\t\tconsole.error(`[Fast:${componentName}]`, error.message);\n\t\t\treturn Promise.reject(error);\n\t\t}\n\t\tactiveUploadCount++;\n\t\tloading.value = true;\n\t\ttry {\n\t\t\tlet fileUrl: string;\n\t\t\tif (data?.uploadApi) {\n\t\t\t\tfileUrl = await uploadUtil.uploadFileByApi(data.uploadApi, options.file, options.filename, propsData);\n\t\t\t} else {\n\t\t\t\tconst headers =\n\t\t\t\t\toptions.headers instanceof Headers\n\t\t\t\t\t\t? options.headers\n\t\t\t\t\t\t: new Headers(\n\t\t\t\t\t\t\t\tObject.entries(options.headers).flatMap(([key, value]) =>\n\t\t\t\t\t\t\t\t\tvalue === null || value === undefined ? [] : [[key, String(value)] as [string, string]]\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\tfileUrl = await uploadUtil.uploadFile(data?.uploadUrl ?? options.action, options.file, options.filename, propsData, {\n\t\t\t\t\theaders,\n\t\t\t\t\tmethod: options.method,\n\t\t\t\t\twithCredentials: options.withCredentials,\n\t\t\t\t});\n\t\t\t}\n\t\t\toptions.onSuccess(fileUrl);\n\t\t} finally {\n\t\t\tactiveUploadCount = Math.max(activeUploadCount - 1, 0);\n\t\t\tloading.value = activeUploadCount > 0;\n\t\t}\n\t};\n\n\tconst handleOnSuccess = (fileUrl: string, uploadFile: UploadFile, uploadFiles: UploadFiles): void => {\n\t\tif (!fileUrl) return;\n\t\tuploadFile.url = fileUrl;\n\t\tif (!props.multiple && uploadFiles.length > 1) {\n\t\t\tuploadFiles.splice(0, uploadFiles.length, uploadFile);\n\t\t}\n\t\thandleValue(uploadFiles);\n\t\t// 调用 el-form 内部的校验方法(可自动校验)\n\t\tif (formItemContext?.prop) void formContext?.validateField([formItemContext.prop]);\n\t\tElMessage.success(\"上传成功\");\n\t\tprops.onSuccess?.(fileUrl, uploadFile, uploadFiles);\n\t};\n\n\tconst handleOnError = (error: Error, uploadFile: UploadFile, uploadFiles: UploadFiles): void => {\n\t\tElNotification({\n\t\t\tmessage: `【${uploadFile.name}】${fileTypeName}上传失败,请您重新上传`,\n\t\t\ttype: \"error\",\n\t\t});\n\t\tprops.onError?.(error, uploadFile, uploadFiles);\n\t};\n\n\tconst handleOnRemove = (uploadFile: UploadFile, uploadFiles: UploadFiles): void => {\n\t\thandleValue(uploadFiles);\n\t\tprops.onRemove?.(uploadFile, uploadFiles);\n\t};\n\n\tconst handleOnExceed = (files: File[], uploadFiles: UploadUserFile[]): void => {\n\t\tElMessage.warning(`最多只能上传 ${props.limit} 个${fileTypeName},请移除后再进行上传`);\n\t\tprops.onExceed?.(files, uploadFiles);\n\t};\n\n\tconst handleOnUpload = (file: UploadFile | UploadRawFile): boolean => {\n\t\tconst fileSizeKB = new Decimal(file.size ?? 0).div(mbNum);\n\n\t\tif (fileSizeKB.greaterThan(maxSizeKB.value)) {\n\t\t\tconsole.warn(`[Fast:${componentName}]`, `【${file.name}】${fileTypeName}上传大小不能超过 ${maxSizeMB.value.toString()}MB。`);\n\t\t\tElMessage.warning(`【${file.name}】${fileTypeName}上传大小不能超过 ${maxSizeMB.value.toString()}MB`);\n\t\t\treturn false;\n\t\t}\n\n\t\tconst rawFile = \"type\" in file ? file : file.raw;\n\t\tif (!rawFile) return false;\n\t\tif (!uploadUtil.matchesAccept(rawFile, props.accept)) {\n\t\t\tconst uploadFileNames = uploadUtil.detectFileType(props.accept ?? \"\");\n\t\t\tconsole.warn(`[Fast:${componentName}]`, `只允许上传【${uploadFileNames}】格式的${fileTypeName}。`);\n\t\t\tElMessage.warning(`只允许上传【${uploadFileNames}】格式的${fileTypeName}`);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t};\n\n\tconst handleOnChange = (uploadFile: UploadFile, uploadFiles: UploadFiles): void => {\n\t\tif (props.autoUpload === false && uploadFile.status === \"ready\" && !handleOnUpload(uploadFile)) {\n\t\t\tfileList.value = uploadFiles.filter((item) => item.uid !== uploadFile.uid);\n\t\t\treturn;\n\t\t}\n\t\tprops.onChange?.(uploadFile, uploadFiles);\n\t};\n\n\t/**\n\t * 监听 v-model 绑定数据\n\t */\n\twatch(\n\t\t() => props.modelValue,\n\t\t(newValue) => {\n\t\t\tif (newValue) {\n\t\t\t\tif (isArray(newValue)) {\n\t\t\t\t\tfileList.value = newValue.map((m) => {\n\t\t\t\t\t\tconst find = fileList.value.find((f) => f.url === m);\n\t\t\t\t\t\tconst urlWithoutParams = m.split(/[?#]/u)[0] ?? \"\";\n\t\t\t\t\t\tconst fileName = urlWithoutParams.slice(urlWithoutParams.lastIndexOf(\"/\") + 1);\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\tfind ?? {\n\t\t\t\t\t\t\t\tname: fileName,\n\t\t\t\t\t\t\t\tstatus: \"success\",\n\t\t\t\t\t\t\t\tuid: genFileId(),\n\t\t\t\t\t\t\t\turl: m,\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} else {\n\t\t\t\t\tconst find = fileList.value.find((f) => f.url === newValue);\n\t\t\t\t\tconst urlWithoutParams = newValue.split(/[?#]/u)[0] ?? \"\";\n\t\t\t\t\tconst fileName = urlWithoutParams.slice(urlWithoutParams.lastIndexOf(\"/\") + 1);\n\t\t\t\t\tfileList.value = [\n\t\t\t\t\t\tfind ?? {\n\t\t\t\t\t\t\tname: fileName,\n\t\t\t\t\t\t\tstatus: \"success\",\n\t\t\t\t\t\t\tuid: genFileId(),\n\t\t\t\t\t\t\turl: newValue,\n\t\t\t\t\t\t},\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfileList.value = [];\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\timmediate: true,\n\t\t}\n\t);\n\n\treturn {\n\t\tfileList,\n\t\tloading,\n\t\tformContext,\n\t\tformItemContext,\n\t\tmaxSizeMB,\n\t\thandleValue,\n\t\thandleHttpRequest,\n\t\thandleOnSuccess,\n\t\thandleOnError,\n\t\thandleOnRemove,\n\t\thandleOnExceed,\n\t\thandleOnUpload,\n\t\thandleOnChange,\n\t};\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AA4CA,MAAa,aACZ,eACA,cACA,OAGA,MACA,SAKsB;CACtB,MAAM,gBAAgB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M,MAAM,MAAM,EAAE,QAAQ,CAAC;IACnD,MAAM,mBAAmB,EAAE,MAAM,OAAO,CAAC,CAAC,MAAM;IAChD,MAAM,WAAW,iBAAiB,MAAM,iBAAiB,YAAY,GAAG,IAAI,CAAC;IAC7E,OACC,QAAQ;KACP,MAAM;KACN,QAAQ;KACR,KAAK,UAAU;KACf,KAAK;IACN;GAEF,CAAC;QACK;IACN,MAAM,OAAO,SAAS,MAAM,MAAM,MAAM,EAAE,QAAQ,QAAQ;IAC1D,MAAM,mBAAmB,SAAS,MAAM,OAAO,CAAC,CAAC,MAAM;IACvD,MAAM,WAAW,iBAAiB,MAAM,iBAAiB,YAAY,GAAG,IAAI,CAAC;IAC7E,SAAS,QAAQ,CAChB,QAAQ;KACP,MAAM;KACN,QAAQ;KACR,KAAK,UAAU;KACf,KAAK;IACN,CACD;GACD;EACD,OACC,SAAS,QAAQ,CAAC;CAEpB,GACA,EACC,WAAW,KACZ,CACD;CAEA,OAAO;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD;AACD"}
1
+ {"version":3,"file":"useUpload.mjs","names":[],"sources":["../../../../src/components/upload/src/useUpload.ts"],"sourcesContent":["import { computed, inject, onMounted, ref, useModel, watch } from \"vue\";\nimport { ElMessage, ElNotification, formContextKey, formItemContextKey, genFileId, uploadProps } from \"element-plus\";\nimport { Decimal } from \"decimal.js\";\nimport { uploadUtil } from \"../utils/upload\";\nimport type {\n\tFormContext,\n\tFormItemContext,\n\tUploadFile,\n\tUploadFiles,\n\tUploadProps,\n\tUploadRawFile,\n\tUploadRequestOptions,\n\tUploadUserFile,\n} from \"element-plus\";\nimport type { ComputedRef, Ref, WritableComputedRef } from \"vue\";\n\ninterface UploadComposable {\n\tfileList: WritableComputedRef<UploadUserFile[]>;\n\tloading: Ref<boolean>;\n\tformContext: FormContext | undefined;\n\tformItemContext: FormItemContext | undefined;\n\tmaxSizeMB: ComputedRef<Decimal>;\n\thandleValue: () => void;\n\thandleHttpRequest: (options: UploadRequestOptions) => Promise<void>;\n\thandleOnSuccess: (fileUrl: string, uploadFile: UploadFile, uploadFiles: UploadFiles) => void;\n\thandleOnError: (error: Error, uploadFile: UploadFile, uploadFiles: UploadFiles) => void;\n\thandleOnRemove: (uploadFile: UploadFile, uploadFiles: UploadFiles) => void;\n\thandleOnExceed: (files: File[], uploadFiles: UploadUserFile[]) => void;\n\thandleOnUpload: (file: UploadFile | UploadRawFile) => boolean;\n\thandleOnChange: (uploadFile: UploadFile, uploadFiles: UploadFiles) => void;\n}\n\n/**\n * 创建上传组件共享的文件状态和操作方法。\n *\n * @param componentName - 组件名称。\n * @param fileTypeName - 文件类型名称。\n * @param props - 上传组件的 Props。\n * @param emit - 上传组件的事件触发器。\n * @param options - 文件大小和类型校验配置。\n * @returns 文件列表、加载状态和上传操作方法。\n */\nexport const useUpload = <T extends string | string[]>(\n\tcomponentName: string,\n\tfileTypeName: string,\n\tprops: Partial<UploadProps> & {\n\t\tmodelValue?: T | null;\n\t},\n\temit: ((event: \"update:fileList\", value: UploadUserFile[]) => void) & ((event: \"update:modelValue\", value: T | null) => void),\n\tdata?: {\n\t\tmaxSize?: string | number;\n\t\tuploadApi?: (formData: FormData) => Promise<string>;\n\t\tuploadUrl?: string;\n\t}\n): UploadComposable => {\n\tconst fileListModel = useModel(props, \"fileList\");\n\tconst fileList = computed<UploadUserFile[]>({\n\t\tget: () => fileListModel.value ?? [],\n\t\tset: (value) => {\n\t\t\tfileListModel.value = value;\n\t\t},\n\t});\n\n\tconst loading = ref(false);\n\tlet activeUploadCount = 0;\n\n\t// 获取 el-form 组件上下文\n\tconst formContext = inject(formContextKey, undefined);\n\t// 获取 el-form-item 组件上下文\n\tconst formItemContext = inject(formItemContextKey, undefined);\n\n\tconst mbNum = new Decimal(1024);\n\tconst maxSizeKB = computed(() => new Decimal(typeof data?.maxSize === \"number\" ? data.maxSize : Number(data?.maxSize)));\n\tconst maxSizeMB = computed(() => maxSizeKB.value.div(mbNum));\n\n\tonMounted(() => {\n\t\t// eslint-disable-next-line @typescript-eslint/no-deprecated -- 需要识别 Element Plus 2.x 注入的默认请求实现。\n\t\tif (!props.disabled && props.autoUpload && !data?.uploadApi && !data?.uploadUrl && props.httpRequest === uploadProps.httpRequest.default) {\n\t\t\tconsole.error(`[Fast:${componentName}]`, \"uploadApi 和 uploadUrl 至少需要提供一个。\");\n\t\t}\n\t});\n\n\tconst handleValue = (files: UploadUserFile[] = fileList.value): void => {\n\t\tlet value: T | null;\n\t\tif (files.length > 0) {\n\t\t\tif (props.multiple === true) {\n\t\t\t\tvalue = files.flatMap((item) => (item.url ? [item.url] : [])) as T;\n\t\t\t} else {\n\t\t\t\tconst fileUrl = files[0]?.url;\n\t\t\t\tif (!fileUrl) return;\n\t\t\t\tvalue = fileUrl as T;\n\t\t\t}\n\t\t} else {\n\t\t\tvalue = props.multiple === true ? ([] as unknown as T) : null;\n\t\t}\n\t\temit(\"update:modelValue\", value);\n\t};\n\n\tconst handleHttpRequest = async (options: UploadRequestOptions): Promise<void> => {\n\t\tconst propsData = options.data;\n\t\tif (!data?.uploadApi && !data?.uploadUrl) {\n\t\t\tconst error = new Error(`上传${fileTypeName}接口 uploadApi 或地址 uploadUrl 不能为空。`);\n\t\t\tElMessage.error(`上传${fileTypeName}Api或地址不能为空`);\n\t\t\tconsole.error(`[Fast:${componentName}]`, error.message);\n\t\t\tthrow error;\n\t\t}\n\t\tactiveUploadCount++;\n\t\tloading.value = true;\n\t\ttry {\n\t\t\tlet fileUrl: string;\n\t\t\tif (data.uploadApi) {\n\t\t\t\tfileUrl = await uploadUtil.uploadFileByApi(data.uploadApi, options.file, options.filename, propsData);\n\t\t\t} else {\n\t\t\t\tconst headers =\n\t\t\t\t\toptions.headers instanceof Headers\n\t\t\t\t\t\t? options.headers\n\t\t\t\t\t\t: new Headers(\n\t\t\t\t\t\t\t\tObject.entries(options.headers).flatMap(([key, value]) =>\n\t\t\t\t\t\t\t\t\tvalue === null || value === undefined ? [] : [[key, String(value)] as [string, string]]\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t);\n\t\t\t\tfileUrl = await uploadUtil.uploadFile(data.uploadUrl ?? options.action, options.file, options.filename, propsData, {\n\t\t\t\t\theaders,\n\t\t\t\t\tmethod: options.method,\n\t\t\t\t\twithCredentials: options.withCredentials,\n\t\t\t\t});\n\t\t\t}\n\t\t\toptions.onSuccess(fileUrl);\n\t\t} finally {\n\t\t\tactiveUploadCount = Math.max(activeUploadCount - 1, 0);\n\t\t\tloading.value = activeUploadCount > 0;\n\t\t}\n\t};\n\n\tconst handleOnSuccess = (fileUrl: string, uploadFile: UploadFile, uploadFiles: UploadFiles): void => {\n\t\tif (!fileUrl) return;\n\t\tuploadFile.url = fileUrl;\n\t\tif (!props.multiple && uploadFiles.length > 1) {\n\t\t\tuploadFiles.splice(0, uploadFiles.length, uploadFile);\n\t\t}\n\t\thandleValue(uploadFiles);\n\t\t// 调用 el-form 内部的校验方法(可自动校验)\n\t\tif (formItemContext?.prop) formContext?.validateField([formItemContext.prop]);\n\t\tElMessage.success(\"上传成功\");\n\t\tprops.onSuccess?.(fileUrl, uploadFile, uploadFiles);\n\t};\n\n\tconst handleOnError = (error: Error, uploadFile: UploadFile, uploadFiles: UploadFiles): void => {\n\t\tElNotification({\n\t\t\tmessage: `【${uploadFile.name}】${fileTypeName}上传失败,请您重新上传`,\n\t\t\ttype: \"error\",\n\t\t});\n\t\tprops.onError?.(error, uploadFile, uploadFiles);\n\t};\n\n\tconst handleOnRemove = (uploadFile: UploadFile, uploadFiles: UploadFiles): void => {\n\t\thandleValue(uploadFiles);\n\t\tprops.onRemove?.(uploadFile, uploadFiles);\n\t};\n\n\tconst handleOnExceed = (files: File[], uploadFiles: UploadUserFile[]): void => {\n\t\tElMessage.warning(`最多只能上传 ${props.limit} 个${fileTypeName},请移除后再进行上传`);\n\t\tprops.onExceed?.(files, uploadFiles);\n\t};\n\n\tconst handleOnUpload = (file: UploadFile | UploadRawFile): boolean => {\n\t\tconst fileSizeKB = new Decimal(file.size ?? 0).div(mbNum);\n\n\t\tif (fileSizeKB.greaterThan(maxSizeKB.value)) {\n\t\t\tconsole.warn(`[Fast:${componentName}]`, `【${file.name}】${fileTypeName}上传大小不能超过 ${maxSizeMB.value.toString()}MB。`);\n\t\t\tElMessage.warning(`【${file.name}】${fileTypeName}上传大小不能超过 ${maxSizeMB.value.toString()}MB`);\n\t\t\treturn false;\n\t\t}\n\n\t\tconst rawFile = \"type\" in file ? file : file.raw;\n\t\tif (!rawFile) return false;\n\t\tif (!uploadUtil.matchesAccept(rawFile, props.accept)) {\n\t\t\tconst uploadFileNames = uploadUtil.detectFileType(props.accept ?? \"\");\n\t\t\tconsole.warn(`[Fast:${componentName}]`, `只允许上传【${uploadFileNames}】格式的${fileTypeName}。`);\n\t\t\tElMessage.warning(`只允许上传【${uploadFileNames}】格式的${fileTypeName}`);\n\t\t\treturn false;\n\t\t}\n\n\t\treturn true;\n\t};\n\n\tconst handleOnChange = (uploadFile: UploadFile, uploadFiles: UploadFiles): void => {\n\t\tif (props.autoUpload === false && uploadFile.status === \"ready\" && !handleOnUpload(uploadFile)) {\n\t\t\tfileList.value = uploadFiles.filter((item) => item.uid !== uploadFile.uid);\n\t\t\treturn;\n\t\t}\n\t\tprops.onChange?.(uploadFile, uploadFiles);\n\t};\n\n\t/**\n\t * 监听 v-model 绑定数据\n\t */\n\twatch(\n\t\t() => props.modelValue,\n\t\t(newValue) => {\n\t\t\tif (newValue) {\n\t\t\t\tif (Array.isArray(newValue)) {\n\t\t\t\t\tfileList.value = newValue.map((m) => {\n\t\t\t\t\t\tconst find = fileList.value.find((f) => f.url === m);\n\t\t\t\t\t\tconst urlWithoutParams = m.split(/[?#]/u)[0] ?? \"\";\n\t\t\t\t\t\tconst fileName = urlWithoutParams.slice(urlWithoutParams.lastIndexOf(\"/\") + 1);\n\t\t\t\t\t\treturn (\n\t\t\t\t\t\t\tfind ?? {\n\t\t\t\t\t\t\t\tname: fileName,\n\t\t\t\t\t\t\t\tstatus: \"success\",\n\t\t\t\t\t\t\t\tuid: genFileId(),\n\t\t\t\t\t\t\t\turl: m,\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} else {\n\t\t\t\t\tconst find = fileList.value.find((f) => f.url === newValue);\n\t\t\t\t\tconst urlWithoutParams = newValue.split(/[?#]/u)[0] ?? \"\";\n\t\t\t\t\tconst fileName = urlWithoutParams.slice(urlWithoutParams.lastIndexOf(\"/\") + 1);\n\t\t\t\t\tfileList.value = [\n\t\t\t\t\t\tfind ?? {\n\t\t\t\t\t\t\tname: fileName,\n\t\t\t\t\t\t\tstatus: \"success\",\n\t\t\t\t\t\t\tuid: genFileId(),\n\t\t\t\t\t\t\turl: newValue,\n\t\t\t\t\t\t},\n\t\t\t\t\t];\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tfileList.value = [];\n\t\t\t}\n\t\t},\n\t\t{\n\t\t\timmediate: true,\n\t\t}\n\t);\n\n\treturn {\n\t\tfileList,\n\t\tloading,\n\t\tformContext,\n\t\tformItemContext,\n\t\tmaxSizeMB,\n\t\thandleValue,\n\t\thandleHttpRequest,\n\t\thandleOnSuccess,\n\t\thandleOnError,\n\t\thandleOnRemove,\n\t\thandleOnExceed,\n\t\thandleOnUpload,\n\t\thandleOnChange,\n\t};\n};\n"],"mappings":";;;;;;;;;;;;;;;AA0CA,MAAa,aACZ,eACA,cACA,OAGA,MACA,SAKsB;CACtB,MAAM,gBAAgB,SAAS,OAAO,UAAU;CAChD,MAAM,WAAW,SAA2B;EAC3C,WAAW,cAAc,SAAS,CAAC;EACnC,MAAM,UAAU;GACf,cAAc,QAAQ;EACvB;CACD,CAAC;CAED,MAAM,UAAU,IAAI,KAAK;CACzB,IAAI,oBAAoB;CAGxB,MAAM,cAAc,OAAO,gBAAgB,KAAA,CAAS;CAEpD,MAAM,kBAAkB,OAAO,oBAAoB,KAAA,CAAS;CAE5D,MAAM,QA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,MAAM,OAAO,CAAC,CAAC,MAAM;IACvD,MAAM,WAAW,iBAAiB,MAAM,iBAAiB,YAAY,GAAG,IAAI,CAAC;IAC7E,SAAS,QAAQ,CAChB,QAAQ;KACP,MAAM;KACN,QAAQ;KACR,KAAK,UAAU;KACf,KAAK;IACN,CACD;GACD;EACD,OACC,SAAS,QAAQ,CAAC;CAEpB,GACA,EACC,WAAW,KACZ,CACD;CAEA,OAAO;EACN;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD;AACD"}
@@ -29,6 +29,6 @@ export declare const uploadUtil: {
29
29
  * @param fileName 文件名称
30
30
  * @param params 参数
31
31
  */
32
- uploadFileByApi(api: (formData: FormData) => Promise<string>, file: File, fileName: string, params?: UploadData): Promise<string>;
32
+ uploadFileByApi(api: ((formData: FormData) => Promise<string>) | null | undefined, file: File, fileName: string, params?: UploadData): Promise<string>;
33
33
  };
34
34
  export {};
@@ -51,7 +51,7 @@ const uploadUtil = {
51
51
  if (!url) {
52
52
  console.error("[Fast:uploadUtil]", "文件上传地址为空。");
53
53
  ElMessage.error("文件上传地址为空!");
54
- return Promise.reject(/* @__PURE__ */ new Error("文件上传地址为空!"));
54
+ throw new Error("文件上传地址为空!");
55
55
  }
56
56
  const formData = new FormData();
57
57
  formData.append("file", file);
@@ -1 +1 @@
1
- {"version":3,"file":"upload.mjs","names":[],"sources":["../../../../src/components/upload/utils/upload.ts"],"sourcesContent":["import { ElMessage } from \"element-plus\";\nimport { FaMimeType } from \"../../../constants\";\ntype UploadData = Record<string, string | Blob | [string | Blob, string] | string[]>;\n\ninterface UploadRequestConfig {\n\tmethod?: string;\n\theaders?: HeadersInit;\n\twithCredentials?: boolean;\n}\n\n/** 将 Element Plus 上传附加数据写入 FormData。 */\nconst appendUploadData = (formData: FormData, params: UploadData): void => {\n\tfor (const [key, value] of Object.entries(params)) {\n\t\tif (Array.isArray(value)) {\n\t\t\tif (value.length === 2 && value[0] instanceof Blob && typeof value[1] === \"string\") {\n\t\t\t\tformData.append(key, value[0], value[1]);\n\t\t\t} else {\n\t\t\t\tvalue.forEach((item) => formData.append(key, item));\n\t\t\t}\n\t\t} else {\n\t\t\tformData.append(key, value);\n\t\t}\n\t}\n};\n\nconst FaMimeTypeNames: Record<string, keyof typeof FaMimeType> = {};\n\nfor (const [kName, vAccept] of Object.entries(FaMimeType)) {\n\tvAccept.split(\",\").forEach((tItem) => {\n\t\tFaMimeTypeNames[tItem.trim()] = kName as keyof typeof FaMimeType;\n\t});\n}\n\n/**\n * 上传工具类\n */\nexport const uploadUtil = {\n\t/**\n\t * 识别文件类型\n\t */\n\tdetectFileType(accept: string): string {\n\t\tconst detectTypes = new Set<string>();\n\t\taccept.split(\",\").forEach((mimeType) => {\n\t\t\tconst normalizedMimeType = mimeType.trim();\n\t\t\tif (normalizedMimeType) detectTypes.add(FaMimeTypeNames[normalizedMimeType] ?? normalizedMimeType);\n\t\t});\n\t\treturn Array.from(detectTypes).join(\",\");\n\t},\n\t/** 判断文件是否符合 HTML accept 规则。 */\n\tmatchesAccept(file: File, accept?: string): boolean {\n\t\tif (!accept?.trim()) return true;\n\t\tconst fileName = file.name.toLowerCase();\n\t\tconst fileType = file.type.toLowerCase();\n\t\treturn accept.split(\",\").some((item) => {\n\t\t\tconst rule = item.trim().toLowerCase();\n\t\t\tif (!rule) return false;\n\t\t\tif (rule.startsWith(\".\")) return fileName.endsWith(rule);\n\t\t\tif (rule.endsWith(\"/*\")) return fileType.startsWith(rule.slice(0, -1));\n\t\t\treturn fileType === rule;\n\t\t});\n\t},\n\t/**\n\t * 文件上传\n\t * @param url 地址\n\t * @param file 文件\n\t * @param fileName 文件名称\n\t * @param params 参数\n\t */\n\tasync uploadFile(url: string, file: File, fileName: string, params?: UploadData, request?: UploadRequestConfig): Promise<string> {\n\t\tif (!url) {\n\t\t\tconsole.error(\"[Fast:uploadUtil]\", \"文件上传地址为空。\");\n\t\t\tElMessage.error(\"文件上传地址为空!\");\n\t\t\treturn Promise.reject(new Error(\"文件上传地址为空!\"));\n\t\t}\n\t\tconst formData = new FormData();\n\t\tformData.append(\"file\", file);\n\t\tformData.append(\"fileName\", fileName);\n\t\tif (params) appendUploadData(formData, params);\n\t\ttry {\n\t\t\tconst response = await fetch(url, {\n\t\t\t\theaders: request?.headers,\n\t\t\t\tmethod: request?.method ?? \"POST\",\n\t\t\t\tcredentials: request?.withCredentials ? \"include\" : \"same-origin\",\n\t\t\t\tbody: formData,\n\t\t\t});\n\t\t\tif (!response.ok) {\n\t\t\t\tconsole.error(\"[Fast:uploadUtil]\", `文件上传失败,HTTP 状态码:${response.status.toString()}。`);\n\t\t\t\tElMessage.error(\"文件上传失败!\");\n\t\t\t\tthrow new Error(\"文件上传失败!\");\n\t\t\t}\n\t\t\treturn await response.text();\n\t\t} catch (error) {\n\t\t\tconsole.error(\"[Fast:uploadUtil]\", \"文件上传失败。\", error);\n\t\t\tElMessage.error(\"文件上传失败!\");\n\t\t\tthrow error instanceof Error ? error : new Error(\"文件上传失败!\");\n\t\t}\n\t},\n\t/**\n\t * 文件上传\n\t * @param url 地址\n\t * @param file 文件\n\t * @param fileName 文件名称\n\t * @param params 参数\n\t */\n\tasync uploadFileByApi(api: (formData: FormData) => Promise<string>, file: File, fileName: string, params?: UploadData): Promise<string> {\n\t\tif (!api) {\n\t\t\tconsole.error(\"[Fast:uploadUtil]\", \"文件上传接口为空。\");\n\t\t\tElMessage.error(\"文件上传接口为空!\");\n\t\t\tthrow new Error(\"文件上传接口为空!\");\n\t\t}\n\t\tconst formData = new FormData();\n\t\tformData.append(\"file\", file);\n\t\tformData.append(\"fileName\", fileName);\n\t\tif (params) appendUploadData(formData, params);\n\t\ttry {\n\t\t\treturn await api(formData);\n\t\t} catch (error) {\n\t\t\tconsole.error(\"[Fast:uploadUtil]\", \"文件上传失败。\", error);\n\t\t\tElMessage.error(\"文件上传失败!\");\n\t\t\tthrow error instanceof Error ? error : new Error(\"文件上传失败!\");\n\t\t}\n\t},\n};\n"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f,QAAQ,MAAM,qBAAqB,WAAW,KAAK;GACnD,UAAU,MAAM,SAAS;GACzB,MAAM,iBAAiB,QAAQ,wBAAQ,IAAI,MAAM,SAAS;EAC3D;CACD;AACD"}
1
+ {"version":3,"file":"upload.mjs","names":[],"sources":["../../../../src/components/upload/utils/upload.ts"],"sourcesContent":["import { ElMessage } from \"element-plus\";\nimport { FaMimeType } from \"../../../constants\";\ntype UploadData = Record<string, string | Blob | [string | Blob, string] | string[]>;\n\ninterface UploadRequestConfig {\n\tmethod?: string;\n\theaders?: HeadersInit;\n\twithCredentials?: boolean;\n}\n\n/** 将 Element Plus 上传附加数据写入 FormData。 */\nconst appendUploadData = (formData: FormData, params: UploadData): void => {\n\tfor (const [key, value] of Object.entries(params)) {\n\t\tif (Array.isArray(value)) {\n\t\t\tif (value.length === 2 && value[0] instanceof Blob && typeof value[1] === \"string\") {\n\t\t\t\tformData.append(key, value[0], value[1]);\n\t\t\t} else {\n\t\t\t\tvalue.forEach((item) => formData.append(key, item));\n\t\t\t}\n\t\t} else {\n\t\t\tformData.append(key, value);\n\t\t}\n\t}\n};\n\nconst FaMimeTypeNames: Record<string, keyof typeof FaMimeType> = {};\n\nfor (const [kName, vAccept] of Object.entries(FaMimeType)) {\n\tvAccept.split(\",\").forEach((tItem) => {\n\t\tFaMimeTypeNames[tItem.trim()] = kName as keyof typeof FaMimeType;\n\t});\n}\n\n/**\n * 上传工具类\n */\nexport const uploadUtil = {\n\t/**\n\t * 识别文件类型\n\t */\n\tdetectFileType(accept: string): string {\n\t\tconst detectTypes = new Set<string>();\n\t\taccept.split(\",\").forEach((mimeType) => {\n\t\t\tconst normalizedMimeType = mimeType.trim();\n\t\t\tif (normalizedMimeType) detectTypes.add(FaMimeTypeNames[normalizedMimeType] ?? normalizedMimeType);\n\t\t});\n\t\treturn Array.from(detectTypes).join(\",\");\n\t},\n\t/** 判断文件是否符合 HTML accept 规则。 */\n\tmatchesAccept(file: File, accept?: string): boolean {\n\t\tif (!accept?.trim()) return true;\n\t\tconst fileName = file.name.toLowerCase();\n\t\tconst fileType = file.type.toLowerCase();\n\t\treturn accept.split(\",\").some((item) => {\n\t\t\tconst rule = item.trim().toLowerCase();\n\t\t\tif (!rule) return false;\n\t\t\tif (rule.startsWith(\".\")) return fileName.endsWith(rule);\n\t\t\tif (rule.endsWith(\"/*\")) return fileType.startsWith(rule.slice(0, -1));\n\t\t\treturn fileType === rule;\n\t\t});\n\t},\n\t/**\n\t * 文件上传\n\t * @param url 地址\n\t * @param file 文件\n\t * @param fileName 文件名称\n\t * @param params 参数\n\t */\n\tasync uploadFile(url: string, file: File, fileName: string, params?: UploadData, request?: UploadRequestConfig): Promise<string> {\n\t\tif (!url) {\n\t\t\tconsole.error(\"[Fast:uploadUtil]\", \"文件上传地址为空。\");\n\t\t\tElMessage.error(\"文件上传地址为空!\");\n\t\t\tthrow new Error(\"文件上传地址为空!\");\n\t\t}\n\t\tconst formData = new FormData();\n\t\tformData.append(\"file\", file);\n\t\tformData.append(\"fileName\", fileName);\n\t\tif (params) appendUploadData(formData, params);\n\t\ttry {\n\t\t\tconst response = await fetch(url, {\n\t\t\t\theaders: request?.headers,\n\t\t\t\tmethod: request?.method ?? \"POST\",\n\t\t\t\tcredentials: request?.withCredentials ? \"include\" : \"same-origin\",\n\t\t\t\tbody: formData,\n\t\t\t});\n\t\t\tif (!response.ok) {\n\t\t\t\tconsole.error(\"[Fast:uploadUtil]\", `文件上传失败,HTTP 状态码:${response.status.toString()}。`);\n\t\t\t\tElMessage.error(\"文件上传失败!\");\n\t\t\t\tthrow new Error(\"文件上传失败!\");\n\t\t\t}\n\t\t\treturn await response.text();\n\t\t} catch (error) {\n\t\t\tconsole.error(\"[Fast:uploadUtil]\", \"文件上传失败。\", error);\n\t\t\tElMessage.error(\"文件上传失败!\");\n\t\t\tthrow error instanceof Error ? error : new Error(\"文件上传失败!\");\n\t\t}\n\t},\n\t/**\n\t * 文件上传\n\t * @param url 地址\n\t * @param file 文件\n\t * @param fileName 文件名称\n\t * @param params 参数\n\t */\n\tasync uploadFileByApi(\n\t\tapi: ((formData: FormData) => Promise<string>) | null | undefined,\n\t\tfile: File,\n\t\tfileName: string,\n\t\tparams?: UploadData\n\t): Promise<string> {\n\t\tif (!api) {\n\t\t\tconsole.error(\"[Fast:uploadUtil]\", \"文件上传接口为空。\");\n\t\t\tElMessage.error(\"文件上传接口为空!\");\n\t\t\tthrow new Error(\"文件上传接口为空!\");\n\t\t}\n\t\tconst formData = new FormData();\n\t\tformData.append(\"file\", file);\n\t\tformData.append(\"fileName\", fileName);\n\t\tif (params) appendUploadData(formData, params);\n\t\ttry {\n\t\t\treturn await api(formData);\n\t\t} catch (error) {\n\t\t\tconsole.error(\"[Fast:uploadUtil]\", \"文件上传失败。\", error);\n\t\t\tElMessage.error(\"文件上传失败!\");\n\t\t\tthrow error instanceof Error ? error : new Error(\"文件上传失败!\");\n\t\t}\n\t},\n};\n"],"mappings":";;;;AAWA,MAAM,oBAAoB,UAAoB,WAA6B;CAC1E,KAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,MAAM,GAC/C,IAAI,MAAM,QAAQ,KAAK,GAAG;EACzB,IAAI,MAAM,WAAW,KAAK,MAAM,cAAc,QAAQ,OAAO,MAAM,OAAO,UACzE,SAAS,OAAO,KAAK,MAAM,IAAI,MAAM,EAAE;OAEvC,MAAM,SAAS,SAAS,SAAS,OAAO,KAAK,IAAI,CAAC;CAEpD,OACC,SAAS,OAAO,KAAK,KAAK;AAG7B;AAEA,MAAM,kBAA2D,CAAC;AAElE,KAAK,MAAM,CAAC,OAAO,YAAY,OAAO,QAAQ,UAAU,GACvD,QAAQ,MAAM,GAAG,CAAC,CAAC,SAAS,UAAU;CACrC,gBAAgB,MAAM,KAAK,KAAK;AACjC,CAAC;;;;AAMF,MAAa,aAAa;;;;CAIzB,eAAe,QAAwB;EACtC,MAAM,8BAAc,IAAI,IAAY;EACpC,OAAO,MAAM,GAAG,CAAC,CAAC,SAAS,aAAa;GACv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ACA,OAAO,MAAM,SAAS,KAAK;EAC5B,SAAS,OAAO;GACf,QAAQ,MAAM,qBAAqB,WAAW,KAAK;GACnD,UAAU,MAAM,SAAS;GACzB,MAAM,iBAAiB,QAAQ,wBAAQ,IAAI,MAAM,SAAS;EAC3D;CACD;;;;;;;;CAQA,MAAM,gBACL,KACA,MACA,UACA,QACkB;EAClB,IAAI,CAAC,KAAK;GACT,QAAQ,MAAM,qBAAqB,WAAW;GAC9C,UAAU,MAAM,WAAW;GAC3B,MAAM,IAAI,MAAM,WAAW;EAC5B;EACA,MAAM,WAAW,IAAI,SAAS;EAC9B,SAAS,OAAO,QAAQ,IAAI;EAC5B,SAAS,OAAO,YAAY,QAAQ;EACpC,IAAI,QAAQ,iBAAiB,UAAU,MAAM;EAC7C,IAAI;GACH,OAAO,MAAM,IAAI,QAAQ;EAC1B,SAAS,OAAO;GACf,QAAQ,MAAM,qBAAqB,WAAW,KAAK;GACnD,UAAU,MAAM,SAAS;GACzB,MAAM,iBAAiB,QAAQ,wBAAQ,IAAI,MAAM,SAAS;EAC3D;CACD;AACD"}
@@ -13,13 +13,14 @@ export declare const faUploadImageProps: {
13
13
  };
14
14
  /** @description type of file list */
15
15
  listType: {
16
- type: import("vue").PropType<"picture" | "text" | "picture-card">;
16
+ type: import("vue").PropType<NonNullable<import("element-plus").ListType | undefined>>;
17
17
  default: string;
18
18
  };
19
19
  /** @description whether uploading multiple files is permitted */
20
20
  multiple: {
21
21
  type: BooleanConstructor;
22
22
  default: boolean;
23
+ validator: (value: boolean) => boolean;
23
24
  };
24
25
  /** @description whether to show the uploaded file list */
25
26
  showFileList: {
@@ -184,13 +185,14 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
184
185
  };
185
186
  /** @description type of file list */
186
187
  listType: {
187
- type: import("vue").PropType<"picture" | "text" | "picture-card">;
188
+ type: import("vue").PropType<NonNullable<import("element-plus").ListType | undefined>>;
188
189
  default: string;
189
190
  };
190
191
  /** @description whether uploading multiple files is permitted */
191
192
  multiple: {
192
193
  type: BooleanConstructor;
193
194
  default: boolean;
195
+ validator: (value: boolean) => boolean;
194
196
  };
195
197
  /** @description whether to show the uploaded file list */
196
198
  showFileList: {
@@ -366,13 +368,14 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
366
368
  };
367
369
  /** @description type of file list */
368
370
  listType: {
369
- type: import("vue").PropType<"picture" | "text" | "picture-card">;
371
+ type: import("vue").PropType<NonNullable<import("element-plus").ListType | undefined>>;
370
372
  default: string;
371
373
  };
372
374
  /** @description whether uploading multiple files is permitted */
373
375
  multiple: {
374
376
  type: BooleanConstructor;
375
377
  default: boolean;
378
+ validator: (value: boolean) => boolean;
376
379
  };
377
380
  /** @description whether to show the uploaded file list */
378
381
  showFileList: {
@@ -524,10 +527,10 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
524
527
  width: string | number;
525
528
  drag: boolean;
526
529
  height: string | number;
527
- onRemove: (uploadFile: UploadFile, uploadFiles: import("element-plus").UploadFiles) => void;
528
530
  multiple: boolean;
529
531
  fileList: UploadUserFile[];
530
532
  beforeUpload: (rawFile: import("element-plus").UploadRawFile) => import("element-plus/es/utils/typescript.mjs").Awaitable<void | undefined | null | boolean | File | Blob>;
533
+ onRemove: (uploadFile: UploadFile, uploadFiles: import("element-plus").UploadFiles) => void;
531
534
  onPreview: (uploadFile: UploadFile) => void;
532
535
  onSuccess: (response: any, uploadFile: UploadFile, uploadFiles: import("element-plus").UploadFiles) => void;
533
536
  onExceed: (files: File[], uploadFiles: UploadUserFile[]) => void;
@@ -537,7 +540,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
537
540
  showFileList: boolean;
538
541
  accept: string;
539
542
  autoUpload: import("element-plus/es/utils/vue/props/types.mjs").EpPropMergeType<BooleanConstructor, unknown, unknown>;
540
- listType: "picture" | "text" | "picture-card";
543
+ listType: NonNullable<import("element-plus").ListType | undefined>;
541
544
  httpRequest: import("element-plus").UploadRequestHandler;
542
545
  directory: boolean;
543
546
  maxSize: string | number;