fast-element-plus 2.0.14 → 2.0.16
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.
- package/CHANGELOG.md +20 -0
- package/dist/components/avatar/src/avatar.mjs.map +1 -1
- package/dist/components/button/src/button.mjs +2 -2
- package/dist/components/button/src/button.mjs.map +1 -1
- package/dist/components/carNumber/src/carNumber.mjs.map +1 -1
- package/dist/components/contextMenu/index.d.ts +1 -1
- package/dist/components/contextMenu/index.mjs.map +1 -1
- package/dist/components/contextMenu/src/contextMenu.d.ts +2 -2
- package/dist/components/contextMenu/src/contextMenu.mjs +2 -2
- package/dist/components/contextMenu/src/contextMenu.mjs.map +1 -1
- package/dist/components/dialog/src/dialog.d.ts +6 -6
- package/dist/components/dialog/src/dialog.mjs +4 -4
- package/dist/components/dialog/src/dialog.mjs.map +1 -1
- package/dist/components/drawer/src/drawer.d.ts +2 -2
- package/dist/components/drawer/src/drawer.mjs +6 -6
- package/dist/components/drawer/src/drawer.mjs.map +1 -1
- package/dist/components/form/src/form.d.ts +10 -4
- package/dist/components/form/src/form.mjs.map +1 -1
- package/dist/components/form/src/formItem.d.ts +4 -4
- package/dist/components/form/src/formItem.mjs.map +1 -1
- package/dist/components/form/utils/form.d.ts +1 -1
- package/dist/components/form/utils/form.mjs +4 -8
- package/dist/components/form/utils/form.mjs.map +1 -1
- package/dist/components/image/src/image.mjs +1 -1
- package/dist/components/image/src/image.mjs.map +1 -1
- package/dist/components/inputDialogPage/src/inputDialogPage.d.ts +4 -4
- package/dist/components/inputDialogPage/src/inputDialogPage.mjs +1 -3
- package/dist/components/inputDialogPage/src/inputDialogPage.mjs.map +1 -1
- package/dist/components/layoutGrid/index.d.ts +1 -1
- package/dist/components/layoutGrid/index.mjs.map +1 -1
- package/dist/components/layoutGrid/src/layoutGrid.d.ts +3 -3
- package/dist/components/layoutGrid/src/layoutGrid.mjs +2 -2
- package/dist/components/layoutGrid/src/layoutGrid.mjs.map +1 -1
- package/dist/components/select/index.d.ts +1 -1
- package/dist/components/select/index.mjs.map +1 -1
- package/dist/components/select/src/select.d.ts +2 -2
- package/dist/components/select/src/select.mjs +2 -2
- package/dist/components/select/src/select.mjs.map +1 -1
- package/dist/components/selectPage/src/selectPage.d.ts +5 -5
- package/dist/components/selectPage/src/selectPage.mjs.map +1 -1
- package/dist/components/selectV2/src/selectV2.d.ts +2 -2
- package/dist/components/selectV2/src/selectV2.mjs +3 -3
- package/dist/components/selectV2/src/selectV2.mjs.map +1 -1
- package/dist/components/table/index.d.ts +3 -3
- package/dist/components/table/index.mjs +1 -3
- package/dist/components/table/index.mjs.map +1 -1
- package/dist/components/table/src/table.d.ts +9 -9
- package/dist/components/table/src/table.mjs +23 -24
- package/dist/components/table/src/table.mjs.map +1 -1
- package/dist/components/table/src/tableColumn.d.ts +3 -3
- package/dist/components/table/src/tableColumn.mjs +9 -16
- package/dist/components/table/src/tableColumn.mjs.map +1 -1
- package/dist/components/table/src/tableColumnSettingDialog.mjs +8 -8
- package/dist/components/table/src/tableColumnSettingDialog.mjs.map +1 -1
- package/dist/components/table/src/tableSearchForm.d.ts +3 -3
- package/dist/components/table/src/tableSearchForm.mjs +15 -21
- package/dist/components/table/src/tableSearchForm.mjs.map +1 -1
- package/dist/components/table/src/tableSearchFormItem.mjs.map +1 -1
- package/dist/components/table/src/useTable.mjs +7 -7
- package/dist/components/table/src/useTable.mjs.map +1 -1
- package/dist/components/table/utils/table.mjs +1 -1
- package/dist/components/table/utils/table.mjs.map +1 -1
- package/dist/components/tree/index.d.ts +1 -1
- package/dist/components/tree/index.mjs.map +1 -1
- package/dist/components/tree/src/tree.d.ts +3 -3
- package/dist/components/tree/src/tree.mjs +1 -1
- package/dist/components/tree/src/tree.mjs.map +1 -1
- package/dist/components/treeSelect/src/treeSelect.d.ts +8 -8
- package/dist/components/treeSelect/src/treeSelect.mjs +3 -3
- package/dist/components/treeSelect/src/treeSelect.mjs.map +1 -1
- package/dist/components/upload/src/upload.mjs +1 -1
- package/dist/components/upload/src/upload.mjs.map +1 -1
- package/dist/components/upload/src/useUpload.mjs +3 -3
- package/dist/components/upload/src/useUpload.mjs.map +1 -1
- package/dist/components/upload/utils/upload.d.ts +1 -1
- package/dist/components/upload/utils/upload.mjs.map +1 -1
- package/dist/components/uploadImage/src/uploadImage.d.ts +7 -4
- package/dist/components/uploadImage/src/uploadImage.mjs +11 -5
- package/dist/components/uploadImage/src/uploadImage.mjs.map +1 -1
- package/dist/components/uploadImages/src/uploadImages.d.ts +7 -4
- package/dist/components/uploadImages/src/uploadImages.mjs +9 -3
- package/dist/components/uploadImages/src/uploadImages.mjs.map +1 -1
- package/dist/directives/click-copy/index.d.ts +1 -1
- package/dist/directives/click-copy/index.mjs.map +1 -1
- package/dist/directives/click-debounce/index.d.ts +1 -1
- package/dist/directives/click-draggable/index.d.ts +1 -1
- package/dist/directives/click-icon-copy/index.d.ts +1 -1
- package/dist/directives/click-icon-copy/index.mjs.map +1 -1
- package/dist/directives/click-longpress/index.d.ts +1 -1
- package/dist/directives/click-throttle/index.d.ts +1 -1
- package/dist/element-plus.mjs.map +1 -1
- package/dist/hooks/use-screenFull/index.mjs.map +1 -1
- package/dist/index.global.min.js +4 -4
- package/dist/index.global.min.js.map +1 -1
- package/dist/index.mjs +1 -3
- package/dist/index.mjs.map +1 -1
- package/dist/utils/async/index.mjs +6 -4
- package/dist/utils/async/index.mjs.map +1 -1
- package/dist/utils/string/index.mjs +19 -11
- package/dist/utils/string/index.mjs.map +1 -1
- package/dist/utils/vue/install.mjs.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.mjs +1 -1
- package/dist/version.mjs.map +1 -1
- package/package.json +13 -13
- package/dist/components/table/src/page.type.mjs +0 -45
- package/dist/components/table/src/page.type.mjs.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploadImage.mjs","names":["update:modelValue","update:fileList"],"sources":["../../../../src/components/uploadImage/src/uploadImage.tsx"],"sourcesContent":["import { Fragment, computed, defineComponent, reactive, ref, withModifiers } from \"vue\";\nimport { Delete, Edit, UploadFilled, ZoomIn } from \"@element-plus/icons-vue\";\nimport { ElIcon, ElImageViewer, ElUpload, uploadProps } from \"element-plus\";\nimport { isArray, isNull, isString } from \"lodash-unified\";\nimport { FaMimeType } from \"../../../constants\";\nimport { addCssUnit, definePropType, makeSlots, randomString, useExpose, useProps, useRender, withDefineType } from \"../../../utils\";\nimport { useUpload } from \"../../upload/src/useUpload\";\nimport type { UploadFile, UploadInstance, UploadProps, UploadUserFile, uploadListTypes } from \"element-plus\";\n\n/** FaUploadImage 的运行时 Props 定义。 */\nexport const faUploadImageProps = {\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 accepted [file types](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-accept), will not work when `thumbnail-mode === true` */\n\taccept: {\n\t\ttype: String,\n\t\tdefault: (): string => FaMimeType.Image,\n\t},\n\t/** @description type of file list */\n\tlistType: {\n\t\ttype: definePropType<(typeof uploadListTypes)[number]>(String),\n\t\tdefault: \"picture\",\n\t},\n\t/** @description whether uploading multiple files is permitted */\n\tmultiple: {\n\t\ttype: Boolean,\n\t\tdefault: false,\n\t},\n\t/** @description whether to show the uploaded file list */\n\tshowFileList: {\n\t\ttype: Boolean,\n\t\tdefault: false,\n\t},\n\t/** @description v-model绑定值 */\n\tmodelValue: definePropType<string | null>(String),\n\t/** @description 大小限制,单位kb */\n\tmaxSize: {\n\t\ttype: [String, Number],\n\t\tdefault: 2048,\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\t/** @description 宽度 */\n\twidth: {\n\t\ttype: [String, Number],\n\t\tdefault: 150,\n\t},\n\t/** @description 高度 */\n\theight: {\n\t\ttype: [String, Number],\n\t\tdefault: 150,\n\t},\n};\n\n/** FaUploadImage 的运行时 Emits 定义。 */\nexport const faUploadImageEmits = {\n\t/** @description v-model 回调 */\n\t\"update:modelValue\": (value: string | null): boolean => isString(value) || isNull(value),\n\t/** @description v-model:fileList 回调 */\n\t\"update:fileList\": (value: UploadUserFile[]): boolean => isArray(value),\n};\n\n/** FaUploadImage 的插槽参数。 */\nexport interface FaUploadImageSlots extends Record<string, unknown> {\n\t/** @description 默认内容插槽 */\n\tdefault: never;\n}\n\nexport default defineComponent({\n\tname: \"FaUploadImage\",\n\tprops: faUploadImageProps,\n\temits: faUploadImageEmits,\n\tslots: makeSlots<FaUploadImageSlots>(),\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<string>(\"FaUploadImage\", \"图片\", 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 state = reactive({\n\t\t\tuploadKey: `fa-upload-image__${randomString(8)}`,\n\t\t\tpreview: false,\n\t\t\tpreviewList: withDefineType<string[]>([]),\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 handleEdit = (): void => {\n\t\t\tconst uploadInputEl = document.querySelector(`.${state.uploadKey} .el-upload__input`);\n\t\t\tuploadInputEl?.dispatchEvent(new MouseEvent(\"click\"));\n\t\t};\n\n\t\tconst handlePreview = (): void => {\n\t\t\tconst fileUrl = fileList.value[0]?.url;\n\t\t\tif (!fileUrl) return;\n\t\t\tstate.previewList = [fileUrl];\n\t\t\tstate.preview = true;\n\t\t};\n\n\t\tconst handleRemove = (): void => {\n\t\t\tconst file = fileList.value[0];\n\t\t\tif (file) uploadRef.value?.handleRemove(file as UploadFile);\n\t\t};\n\n\t\tconst handleBeforeUpload: UploadProps[\"beforeUpload\"] = (rawFile) => {\n\t\t\tif (!handleOnUpload(rawFile)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (props.beforeUpload) {\n\t\t\t\treturn props.beforeUpload(rawFile);\n\t\t\t}\n\t\t\treturn 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<Fragment>\n\t\t\t\t<ElUpload\n\t\t\t\t\t{...elUploadProps.value}\n\t\t\t\t\tref={uploadRef}\n\t\t\t\t\tclass={[\"fa-upload-image\", state.uploadKey]}\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\"--width\": addCssUnit(props.width),\n\t\t\t\t\t\t\"--height\": addCssUnit(props.height),\n\t\t\t\t\t}}\n\t\t\t\t\tvLoading={loading.value}\n\t\t\t\t\tvModel:fileList={fileList.value}\n\t\t\t\t\tmultiple={false}\n\t\t\t\t\tdisabled={disabled.value}\n\t\t\t\t\thttpRequest={httpRequest.value}\n\t\t\t\t\tbeforeUpload={handleBeforeUpload}\n\t\t\t\t\tonExceed={handleOnExceed}\n\t\t\t\t\tonSuccess={handleOnSuccess}\n\t\t\t\t\tonError={handleOnError}\n\t\t\t\t\tonRemove={handleOnRemove}\n\t\t\t\t\tonChange={handleOnChange}\n\t\t\t\t>\n\t\t\t\t\t{{\n\t\t\t\t\t\tdefault: () =>\n\t\t\t\t\t\t\tfileList.value.length > 0 ? (\n\t\t\t\t\t\t\t\t<Fragment>\n\t\t\t\t\t\t\t\t\t<img class=\"el-upload-list__item-thumbnail\" src={fileList.value[0]?.url} />\n\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\tclass=\"el-upload-list__item-actions\"\n\t\t\t\t\t\t\t\t\t\tonClick={withModifiers(() => {\n\t\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t\t}, [\"stop\"])}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<span class=\"el-upload-list__item-icon\" onClick={() => handlePreview()} title=\"查看\">\n\t\t\t\t\t\t\t\t\t\t\t<ElIcon>\n\t\t\t\t\t\t\t\t\t\t\t\t<ZoomIn />\n\t\t\t\t\t\t\t\t\t\t\t</ElIcon>\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t{!disabled.value && (\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<span class=\"el-upload-list__item-icon\" onClick={handleEdit} title=\"编辑\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<ElIcon>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<Edit />\n\t\t\t\t\t\t\t\t\t\t\t\t\t</ElIcon>\n\t\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"el-upload-list__item-icon\" onClick={() => handleRemove()} title=\"删除\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<ElIcon>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<Delete />\n\t\t\t\t\t\t\t\t\t\t\t\t\t</ElIcon>\n\t\t\t\t\t\t\t\t\t\t\t\t</span>\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</span>\n\t\t\t\t\t\t\t\t</Fragment>\n\t\t\t\t\t\t\t) : slots.default ? (\n\t\t\t\t\t\t\t\tslots.default()\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<Fragment>\n\t\t\t\t\t\t\t\t\t<ElIcon class=\"el-icon--upload\">\n\t\t\t\t\t\t\t\t\t\t<UploadFilled />\n\t\t\t\t\t\t\t\t\t</ElIcon>\n\t\t\t\t\t\t\t\t\t<div class=\"el-upload__text\">\n\t\t\t\t\t\t\t\t\t\tDrop file here <br />\n\t\t\t\t\t\t\t\t\t\t<em>click to upload</em>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</Fragment>\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\ttip: () => <div class=\"el-upload__tip\">file with a size less than {maxSizeMB.value.toString()}MB</div>,\n\t\t\t\t\t}}\n\t\t\t\t</ElUpload>\n\t\t\t\t{state.preview && (\n\t\t\t\t\t<ElImageViewer\n\t\t\t\t\t\tcloseOnPressEscape\n\t\t\t\t\t\thideOnClickModal\n\t\t\t\t\t\tteleported\n\t\t\t\t\t\tonClose={() => (state.preview = false)}\n\t\t\t\t\t\turlList={state.previewList}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</Fragment>\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\t/** @description 预览 */\n\t\t\tpreview: computed(() => state.preview),\n\t\t\t/** @description 预览集合 */\n\t\t\tpreviewList: computed(() => state.previewList),\n\t\t});\n\t},\n});\n"],"mappings":";;;;;;;;;;;;;;;AAUA,MAAa,qBAAqB;CACjC,GAAG;;CAEH,MAAM;EACL,MAAM;EACN,SAAS;CACV;;CAEA,QAAQ;EACP,MAAM;EACN,eAAuB,WAAW;CACnC;;CAEA,UAAU;EACT,MAAM,eAAiD,MAAM;EAC7D,SAAS;CACV;;CAEA,UAAU;EACT,MAAM;EACN,SAAS;CACV;;CAEA,cAAc;EACb,MAAM;EACN,SAAS;CACV;;CAEA,YAAY,eAA8B,MAAM;;CAEhD,SAAS;EACR,MAAM,CAAC,QAAQ,MAAM;EACrB,SAAS;CACV;;CAEA,WAAW,EACV,MAAM,eAAwD,QAAQ,EACvE;;CAEA,WAAW;;CAEX,OAAO;EACN,MAAM,CAAC,QAAQ,MAAM;EACrB,SAAS;CACV;;CAEA,QAAQ;EACP,MAAM,CAAC,QAAQ,MAAM;EACrB,SAAS;CACV;AACD;;AAGA,MAAa,qBAAqB;;CAEjC,sBAAsB,UAAkC,SAAS,KAAK,KAAK,OAAO,KAAK;;CAEvF,oBAAoB,UAAqC,QAAQ,KAAK;AACvE;AAQA,IAAA,sBAAe,gBAAgB;CAC9B,MAAM;CACN,OAAO;CACP,OAAO;CACP,OAAO,UAA8B;CACrC,MAAM,OAAO,EAAE,OAAO,MAAM,UAAU;EACrC,MAAM,EACL,UACA,SACA,aACA,WACA,mBACA,iBACA,eACA,gBACA,gBACA,gBACA,mBACG,UAAkB,iBAAiB,MAAM,OAAO,MAAM;GACzD,IAAI,UAAU;IACb,OAAO,MAAM;GACd;GACA,IA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A,IAAA;IAAA,YAAA,MAAA,MAAA,CAAA,gBAAA,iBAAA,CAAA,CAAA;GAAA,CAAA,CAAA,CAAA;GAYjB,WAAK,YAAA,OAAA,EAAA,SAAA,iBAAA,GAAA;IAAA,gBAAA,6BAAA;IAA8D,UAAU,MAAM,SAAS;IAAC,gBAAA,IAAA;GAAA,CAAA;EAAS,CAAA,GAAA,CAAA,CAAA,iBAAA,SAAA,GAzD7F,QAAQ,KAAK,CAAA,CAAA,GA4DvB,MAAM,WAAO,YAAA,eAAA;GAAA,sBAAA;GAAA,oBAAA;GAAA,cAAA;GAAA,iBAKI,MAAM,UAAU;GAAM,WAC7B,MAAM;EAAW,GAAA,IAAA,CAE3B,CAAA,CAEF;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;;GAEA,SAAS,eAAe,MAAM,OAAO;;GAErC,aAAa,eAAe,MAAM,WAAW;EAC9C,CAAC;CACF;AACD,CAAC"}
|
|
1
|
+
{"version":3,"file":"uploadImage.mjs","names":["update:modelValue","update:fileList"],"sources":["../../../../src/components/uploadImage/src/uploadImage.tsx"],"sourcesContent":["import { Fragment, computed, defineComponent, reactive, ref, withModifiers } from \"vue\";\nimport { Delete, Edit, UploadFilled, ZoomIn } from \"@element-plus/icons-vue\";\nimport { ElIcon, ElImageViewer, ElUpload, uploadProps } from \"element-plus\";\nimport { isArray, isNull, isString } from \"lodash-unified\";\nimport { FaMimeType } from \"../../../constants\";\nimport { addCssUnit, definePropType, makeSlots, randomString, useExpose, useProps, useRender, withDefineType } from \"../../../utils\";\nimport { useUpload } from \"../../upload/src/useUpload\";\nimport type { UploadFile, UploadInstance, UploadProps, UploadUserFile } from \"element-plus\";\n\n/** FaUploadImage 的运行时 Props 定义。 */\nexport const faUploadImageProps = {\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 accepted [file types](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-accept), will not work when `thumbnail-mode === true` */\n\taccept: {\n\t\ttype: String,\n\t\tdefault: (): string => FaMimeType.Image,\n\t},\n\t/** @description type of file list */\n\tlistType: {\n\t\ttype: definePropType<NonNullable<UploadProps[\"listType\"]>>(String),\n\t\tdefault: \"picture\",\n\t},\n\t/** @description whether uploading multiple files is permitted */\n\tmultiple: {\n\t\ttype: Boolean,\n\t\tdefault: false,\n\t\tvalidator: (value: boolean): boolean => {\n\t\t\tif (value) {\n\t\t\t\tconsole.warn(\"[Fast:FaUploadImage]\", \"'multiple' 属性固定为 false,外部设置不会生效。\");\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn true;\n\t\t},\n\t},\n\t/** @description whether to show the uploaded file list */\n\tshowFileList: {\n\t\ttype: Boolean,\n\t\tdefault: false,\n\t},\n\t/** @description v-model绑定值 */\n\tmodelValue: definePropType<string | null>(String),\n\t/** @description 大小限制,单位kb */\n\tmaxSize: {\n\t\ttype: [String, Number],\n\t\tdefault: 2048,\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\t/** @description 宽度 */\n\twidth: {\n\t\ttype: [String, Number],\n\t\tdefault: 150,\n\t},\n\t/** @description 高度 */\n\theight: {\n\t\ttype: [String, Number],\n\t\tdefault: 150,\n\t},\n};\n\n/** FaUploadImage 的运行时 Emits 定义。 */\nexport const faUploadImageEmits = {\n\t/** @description v-model 回调 */\n\t\"update:modelValue\": (value: string | null): boolean => isString(value) || isNull(value),\n\t/** @description v-model:fileList 回调 */\n\t\"update:fileList\": (value: UploadUserFile[]): boolean => isArray(value),\n};\n\n/** FaUploadImage 的插槽参数。 */\nexport interface FaUploadImageSlots extends Record<string, unknown> {\n\t/** @description 默认内容插槽 */\n\tdefault: never;\n}\n\nexport default defineComponent({\n\tname: \"FaUploadImage\",\n\tprops: faUploadImageProps,\n\temits: faUploadImageEmits,\n\tslots: makeSlots<FaUploadImageSlots>(),\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<string>(\"FaUploadImage\", \"图片\", 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 disabled = computed(() => {\n\t\t\treturn props.disabled === true || formContext?.disabled === true;\n\t\t});\n\n\t\tconst state = reactive({\n\t\t\tuploadKey: `fa-upload-image__${randomString(8)}`,\n\t\t\tpreview: false,\n\t\t\tpreviewList: withDefineType<string[]>([]),\n\t\t});\n\n\t\tconst uploadRef = ref<UploadInstance>();\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 handleEdit = (): void => {\n\t\t\tconst uploadInputEl = document.querySelector(`.${state.uploadKey} .el-upload__input`);\n\t\t\tuploadInputEl?.dispatchEvent(new MouseEvent(\"click\"));\n\t\t};\n\n\t\tconst handlePreview = (): void => {\n\t\t\tconst fileUrl = fileList.value[0]?.url;\n\t\t\tif (!fileUrl) return;\n\t\t\tstate.previewList = [fileUrl];\n\t\t\tstate.preview = true;\n\t\t};\n\n\t\tconst handleRemove = (): void => {\n\t\t\tconst file = fileList.value[0];\n\t\t\tif (file) uploadRef.value?.handleRemove(file as UploadFile);\n\t\t};\n\n\t\tconst handleBeforeUpload: UploadProps[\"beforeUpload\"] = (rawFile) => {\n\t\t\tif (!handleOnUpload(rawFile)) {\n\t\t\t\treturn false;\n\t\t\t}\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<Fragment>\n\t\t\t\t<ElUpload\n\t\t\t\t\t{...elUploadProps.value}\n\t\t\t\t\tref={uploadRef}\n\t\t\t\t\tclass={[\"fa-upload-image\", state.uploadKey]}\n\t\t\t\t\tstyle={{\n\t\t\t\t\t\t\"--width\": addCssUnit(props.width),\n\t\t\t\t\t\t\"--height\": addCssUnit(props.height),\n\t\t\t\t\t}}\n\t\t\t\t\tvLoading={loading.value}\n\t\t\t\t\tvModel:fileList={fileList.value}\n\t\t\t\t\tmultiple={false}\n\t\t\t\t\tdisabled={disabled.value}\n\t\t\t\t\thttpRequest={httpRequest.value}\n\t\t\t\t\tbeforeUpload={handleBeforeUpload}\n\t\t\t\t\tonExceed={handleOnExceed}\n\t\t\t\t\tonSuccess={handleOnSuccess}\n\t\t\t\t\tonError={handleOnError}\n\t\t\t\t\tonRemove={handleOnRemove}\n\t\t\t\t\tonChange={handleOnChange}\n\t\t\t\t>\n\t\t\t\t\t{{\n\t\t\t\t\t\tdefault: () =>\n\t\t\t\t\t\t\tfileList.value.length > 0 ? (\n\t\t\t\t\t\t\t\t<Fragment>\n\t\t\t\t\t\t\t\t\t<img class=\"el-upload-list__item-thumbnail\" src={fileList.value[0]?.url} />\n\t\t\t\t\t\t\t\t\t<span\n\t\t\t\t\t\t\t\t\t\tclass=\"el-upload-list__item-actions\"\n\t\t\t\t\t\t\t\t\t\tonClick={withModifiers(() => {\n\t\t\t\t\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t\t\t\t\t}, [\"stop\"])}\n\t\t\t\t\t\t\t\t\t>\n\t\t\t\t\t\t\t\t\t\t<span class=\"el-upload-list__item-icon\" onClick={handlePreview} title=\"查看\">\n\t\t\t\t\t\t\t\t\t\t\t<ElIcon>\n\t\t\t\t\t\t\t\t\t\t\t\t<ZoomIn />\n\t\t\t\t\t\t\t\t\t\t\t</ElIcon>\n\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t{!disabled.value && (\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<span class=\"el-upload-list__item-icon\" onClick={handleEdit} title=\"编辑\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<ElIcon>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<Edit />\n\t\t\t\t\t\t\t\t\t\t\t\t\t</ElIcon>\n\t\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"el-upload-list__item-icon\" onClick={handleRemove} title=\"删除\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<ElIcon>\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t<Delete />\n\t\t\t\t\t\t\t\t\t\t\t\t\t</ElIcon>\n\t\t\t\t\t\t\t\t\t\t\t\t</span>\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</span>\n\t\t\t\t\t\t\t\t</Fragment>\n\t\t\t\t\t\t\t) : slots.default ? (\n\t\t\t\t\t\t\t\tslots.default()\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<Fragment>\n\t\t\t\t\t\t\t\t\t<ElIcon class=\"el-icon--upload\">\n\t\t\t\t\t\t\t\t\t\t<UploadFilled />\n\t\t\t\t\t\t\t\t\t</ElIcon>\n\t\t\t\t\t\t\t\t\t<div class=\"el-upload__text\">\n\t\t\t\t\t\t\t\t\t\tDrop file here <br />\n\t\t\t\t\t\t\t\t\t\t<em>click to upload</em>\n\t\t\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t\t\t</Fragment>\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\ttip: () => <div class=\"el-upload__tip\">file with a size less than {maxSizeMB.value.toString()}MB</div>,\n\t\t\t\t\t}}\n\t\t\t\t</ElUpload>\n\t\t\t\t{state.preview && (\n\t\t\t\t\t<ElImageViewer\n\t\t\t\t\t\tcloseOnPressEscape\n\t\t\t\t\t\thideOnClickModal\n\t\t\t\t\t\tteleported\n\t\t\t\t\t\tonClose={() => (state.preview = false)}\n\t\t\t\t\t\turlList={state.previewList}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</Fragment>\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\t/** @description 预览 */\n\t\t\tpreview: computed(() => state.preview),\n\t\t\t/** @description 预览集合 */\n\t\t\tpreviewList: computed(() => state.previewList),\n\t\t});\n\t},\n});\n"],"mappings":";;;;;;;;;;;;;;;AAUA,MAAa,qBAAqB;CAEjC,GAAG;;CAEH,MAAM;EACL,MAAM;EACN,SAAS;CACV;;CAEA,QAAQ;EACP,MAAM;EACN,eAAuB,WAAW;CACnC;;CAEA,UAAU;EACT,MAAM,eAAqD,MAAM;EACjE,SAAS;CACV;;CAEA,UAAU;EACT,MAAM;EACN,SAAS;EACT,YAAY,UAA4B;GACvC,IAAI,OAAO;IACV,QAAQ,KAAK,wBAAwB,kCAAkC;IACvE,OAAO;GACR;GACA,OAAO;EACR;CACD;;CAEA,cAAc;EACb,MAAM;EACN,SAAS;CACV;;CAEA,YAAY,eAA8B,MAAM;;CAEhD,SAAS;EACR,MAAM,CAAC,QAAQ,MAAM;EACrB,SAAS;CACV;;CAEA,WAAW,EACV,MAAM,eAAwD,QAAQ,EACvE;;CAEA,WAAW;;CAEX,OAAO;EACN,MAAM,CAAC,QAAQ,MAAM;EACrB,SAAS;CACV;;CAEA,QAAQ;EACP,MAAM,CAAC,QAAQ,MAAM;EACrB,SAAS;CACV;AACD;;AAGA,MAAa,qBAAqB;;CAEjC,sBAAsB,UAAkC,SAAS,KAAK,KAAK,OAAO,KAAK;;CAEvF,oBAAoB,UAAqC,QAAQ,KAAK;AACvE;AAQA,IAAA,sBAAe,gBAAgB;CAC9B,MAAM;CACN,OAAO;CACP,OAAO;CACP,OAAO,UAA8B;CACrC,MAAM,OAAO,EAAE,OAAO,MAAM,UA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AAA,MAAA,IAAA,CAAA,EAAA,CAAA,GAAA,YAAA,OAAA,EAAA,SAAA,kBAAA,GAAA;IAAA,gBAAA,iBAAA;IAAA,YAAA,MAAA,MAAA,IAAA;IAAA,YAAA,MAAA,MAAA,CAAA,gBAAA,iBAAA,CAAA,CAAA;GAAA,CAAA,CAAA,CAAA;GAYjB,WAAK,YAAA,OAAA,EAAA,SAAA,iBAAA,GAAA;IAAA,gBAAA,6BAAA;IAA8D,UAAU,MAAM,SAAS;IAAC,gBAAA,IAAA;GAAA,CAAA;EAAS,CAAA,GAAA,CAAA,CAAA,iBAAA,SAAA,GAzD7F,QAAQ,KAAK,CAAA,CAAA,GA4DvB,MAAM,WAAO,YAAA,eAAA;GAAA,sBAAA;GAAA,oBAAA;GAAA,cAAA;GAAA,iBAKI,MAAM,UAAU;GAAM,WAC7B,MAAM;EAAW,GAAA,IAAA,CAE3B,CAAA,CAEF;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;;GAEA,SAAS,eAAe,MAAM,OAAO;;GAErC,aAAa,eAAe,MAAM,WAAW;EAC9C,CAAC;CACF;AACD,CAAC"}
|
|
@@ -8,13 +8,14 @@ export declare const faUploadImagesProps: {
|
|
|
8
8
|
};
|
|
9
9
|
/** @description type of file list */
|
|
10
10
|
listType: {
|
|
11
|
-
type: import("vue").PropType<"
|
|
11
|
+
type: import("vue").PropType<NonNullable<import("element-plus").ListType | undefined>>;
|
|
12
12
|
default: string;
|
|
13
13
|
};
|
|
14
14
|
/** @description whether uploading multiple files is permitted */
|
|
15
15
|
multiple: {
|
|
16
16
|
type: BooleanConstructor;
|
|
17
17
|
default: boolean;
|
|
18
|
+
validator: (value: boolean) => boolean;
|
|
18
19
|
};
|
|
19
20
|
/** @description maximum number of uploads allowed */
|
|
20
21
|
limit: {
|
|
@@ -165,13 +166,14 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
165
166
|
};
|
|
166
167
|
/** @description type of file list */
|
|
167
168
|
listType: {
|
|
168
|
-
type: import("vue").PropType<"
|
|
169
|
+
type: import("vue").PropType<NonNullable<import("element-plus").ListType | undefined>>;
|
|
169
170
|
default: string;
|
|
170
171
|
};
|
|
171
172
|
/** @description whether uploading multiple files is permitted */
|
|
172
173
|
multiple: {
|
|
173
174
|
type: BooleanConstructor;
|
|
174
175
|
default: boolean;
|
|
176
|
+
validator: (value: boolean) => boolean;
|
|
175
177
|
};
|
|
176
178
|
/** @description maximum number of uploads allowed */
|
|
177
179
|
limit: {
|
|
@@ -333,13 +335,14 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
333
335
|
};
|
|
334
336
|
/** @description type of file list */
|
|
335
337
|
listType: {
|
|
336
|
-
type: import("vue").PropType<"
|
|
338
|
+
type: import("vue").PropType<NonNullable<import("element-plus").ListType | undefined>>;
|
|
337
339
|
default: string;
|
|
338
340
|
};
|
|
339
341
|
/** @description whether uploading multiple files is permitted */
|
|
340
342
|
multiple: {
|
|
341
343
|
type: BooleanConstructor;
|
|
342
344
|
default: boolean;
|
|
345
|
+
validator: (value: boolean) => boolean;
|
|
343
346
|
};
|
|
344
347
|
/** @description maximum number of uploads allowed */
|
|
345
348
|
limit: {
|
|
@@ -493,7 +496,7 @@ declare const _default: import("vue").DefineComponent<import("vue").ExtractPropT
|
|
|
493
496
|
showFileList: import("element-plus/es/utils/vue/props/types.mjs").EpPropMergeType<BooleanConstructor, unknown, unknown>;
|
|
494
497
|
accept: string;
|
|
495
498
|
autoUpload: import("element-plus/es/utils/vue/props/types.mjs").EpPropMergeType<BooleanConstructor, unknown, unknown>;
|
|
496
|
-
listType: "
|
|
499
|
+
listType: NonNullable<import("element-plus").ListType | undefined>;
|
|
497
500
|
httpRequest: import("element-plus").UploadRequestHandler;
|
|
498
501
|
limit: number;
|
|
499
502
|
directory: boolean;
|
|
@@ -27,7 +27,14 @@ const faUploadImagesProps = {
|
|
|
27
27
|
/** @description whether uploading multiple files is permitted */
|
|
28
28
|
multiple: {
|
|
29
29
|
type: Boolean,
|
|
30
|
-
default: true
|
|
30
|
+
default: true,
|
|
31
|
+
validator: (value) => {
|
|
32
|
+
if (!value) {
|
|
33
|
+
console.warn("[Fast:FaUploadImages]", "'multiple' 属性固定为 true,外部设置不会生效。");
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
31
38
|
},
|
|
32
39
|
/** @description maximum number of uploads allowed */
|
|
33
40
|
limit: {
|
|
@@ -95,8 +102,7 @@ var uploadImages_default = defineComponent({
|
|
|
95
102
|
};
|
|
96
103
|
const handleBeforeUpload = (rawFile) => {
|
|
97
104
|
if (!handleOnUpload(rawFile)) return false;
|
|
98
|
-
|
|
99
|
-
return true;
|
|
105
|
+
return props.beforeUpload(rawFile);
|
|
100
106
|
};
|
|
101
107
|
const elUploadProps = useProps(props, uploadProps, [
|
|
102
108
|
"fileList",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"uploadImages.mjs","names":["update:modelValue","update:fileList"],"sources":["../../../../src/components/uploadImages/src/uploadImages.tsx"],"sourcesContent":["import { Fragment, computed, defineComponent, reactive, ref } from \"vue\";\nimport { Delete, Edit, Plus, ZoomIn } from \"@element-plus/icons-vue\";\nimport { ElIcon, ElImageViewer, ElUpload, uploadProps } from \"element-plus\";\nimport { isArray, isNull } from \"lodash-unified\";\nimport { FaMimeType } from \"../../../constants\";\nimport { definePropType, makeSlots, randomString, useExpose, useProps, useRender, withDefineType } from \"../../../utils\";\nimport { useUpload } from \"../../upload/src/useUpload\";\nimport type { UploadFile, UploadInstance, UploadProps, UploadUserFile, uploadListTypes } from \"element-plus\";\n\n/** FaUploadImages 的运行时 Props 定义。 */\nexport const faUploadImagesProps = {\n\t...uploadProps,\n\t/** @description accepted [file types](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-accept), will not work when `thumbnail-mode === true` */\n\taccept: {\n\t\ttype: String,\n\t\tdefault: (): string => FaMimeType.Image,\n\t},\n\t/** @description type of file list */\n\tlistType: {\n\t\ttype: definePropType<(typeof uploadListTypes)[number]>(String),\n\t\tdefault: \"picture-card\",\n\t},\n\t/** @description whether uploading multiple files is permitted */\n\tmultiple: {\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: 9,\n\t},\n\t/** @description v-model绑定值 */\n\tmodelValue: definePropType<string[] | null>([Array]),\n\t/** @description 大小限制,单位kb */\n\tmaxSize: {\n\t\ttype: [String, Number],\n\t\tdefault: 2048,\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/** FaUploadImages 的运行时 Emits 定义。 */\nexport const faUploadImagesEmits = {\n\t/** @description v-model 回调 */\n\t\"update:modelValue\": (value: string[] | null): boolean => isArray(value) || isNull(value),\n\t/** @description v-model:fileList 回调 */\n\t\"update:fileList\": (value: UploadUserFile[]): boolean => isArray(value),\n};\n\n/** FaUploadImages 的插槽参数。 */\nexport interface FaUploadImagesSlots extends Record<string, unknown> {\n\t/** @description 默认内容插槽 */\n\tdefault: never;\n}\n\nexport default defineComponent({\n\tname: \"FaUploadImages\",\n\tprops: faUploadImagesProps,\n\temits: faUploadImagesEmits,\n\tslots: makeSlots<FaUploadImagesSlots>(),\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<string[]>(\"FaUploadImages\", \"图片\", 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 state = reactive({\n\t\t\tuploadKey: `fa-upload-images__${randomString(8)}`,\n\t\t\tpreview: false,\n\t\t\tpreviewIndex: -1,\n\t\t\tpreviewList: withDefineType<string[]>([]),\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 handleEdit = (): void => {\n\t\t\tconst uploadInputEl = document.querySelector(`.${state.uploadKey} .el-upload__input`);\n\t\t\tuploadInputEl?.dispatchEvent(new MouseEvent(\"click\"));\n\t\t};\n\n\t\tconst handlePreview = (uploadFile: UploadFile): void => {\n\t\t\tstate.previewIndex = fileList.value.findIndex((f) => f.url === uploadFile.url);\n\t\t\tstate.previewList = fileList.value.flatMap((item) => (item.url ? [item.url] : []));\n\t\t\tstate.preview = true;\n\t\t};\n\n\t\tconst handleRemove = (index: number): void => {\n\t\t\tconst file = fileList.value[index];\n\t\t\tif (file) uploadRef.value?.handleRemove(file as UploadFile);\n\t\t};\n\n\t\tconst handleBeforeUpload: UploadProps[\"beforeUpload\"] = (rawFile) => {\n\t\t\tif (!handleOnUpload(rawFile)) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\tif (props.beforeUpload) {\n\t\t\t\treturn props.beforeUpload(rawFile);\n\t\t\t}\n\t\t\treturn true;\n\t\t};\n\n\t\tconst elUploadProps = useProps(props, uploadProps, [\n\t\t\t\"fileList\",\n\t\t\t\"multiple\",\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<Fragment>\n\t\t\t\t<ElUpload\n\t\t\t\t\t{...elUploadProps.value}\n\t\t\t\t\tref={uploadRef}\n\t\t\t\t\tclass={[\"fa-upload-images\", state.uploadKey, { \"fa-upload-images__hidden-upload\": fileList.value.length >= props.limit }]}\n\t\t\t\t\tvLoading={loading.value}\n\t\t\t\t\tvModel:fileList={fileList.value}\n\t\t\t\t\tmultiple={true}\n\t\t\t\t\tdisabled={disabled.value}\n\t\t\t\t\thttpRequest={httpRequest.value}\n\t\t\t\t\tbeforeUpload={handleBeforeUpload}\n\t\t\t\t\tonExceed={handleOnExceed}\n\t\t\t\t\tonSuccess={handleOnSuccess}\n\t\t\t\t\tonError={handleOnError}\n\t\t\t\t\tonRemove={handleOnRemove}\n\t\t\t\t\tonChange={handleOnChange}\n\t\t\t\t>\n\t\t\t\t\t{{\n\t\t\t\t\t\tdefault: () =>\n\t\t\t\t\t\t\tfileList.value.length < props.limit && slots.default ? (\n\t\t\t\t\t\t\t\tslots.default()\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<ElIcon>\n\t\t\t\t\t\t\t\t\t<Plus />\n\t\t\t\t\t\t\t\t</ElIcon>\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\ttip: () => <div class=\"el-upload__tip\">files with a size less than {maxSizeMB.value.toString()}MB</div>,\n\t\t\t\t\t\tfile: ({ file, index }: { file: UploadFile; index: number }) => (\n\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t<img class=\"el-upload-list__item-thumbnail\" src={file.url} />\n\t\t\t\t\t\t\t\t<span class=\"el-upload-list__item-actions\">\n\t\t\t\t\t\t\t\t\t<span class=\"el-upload-list__item-preview\" onClick={() => handlePreview(file)} title=\"查看\">\n\t\t\t\t\t\t\t\t\t\t<ElIcon>\n\t\t\t\t\t\t\t\t\t\t\t<ZoomIn />\n\t\t\t\t\t\t\t\t\t\t</ElIcon>\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t{!disabled.value && (\n\t\t\t\t\t\t\t\t\t\t<Fragment>\n\t\t\t\t\t\t\t\t\t\t\t<span class=\"el-upload-list__item-icon\" onClick={handleEdit} title=\"编辑\">\n\t\t\t\t\t\t\t\t\t\t\t\t<ElIcon>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<Edit />\n\t\t\t\t\t\t\t\t\t\t\t\t</ElIcon>\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t\t<span class=\"el-upload-list__item-icon\" onClick={() => handleRemove(index)} title=\"删除\">\n\t\t\t\t\t\t\t\t\t\t\t\t<ElIcon>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<Delete />\n\t\t\t\t\t\t\t\t\t\t\t\t</ElIcon>\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t</Fragment>\n\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t),\n\t\t\t\t\t}}\n\t\t\t\t</ElUpload>\n\t\t\t\t{state.preview && (\n\t\t\t\t\t<ElImageViewer\n\t\t\t\t\t\tcloseOnPressEscape\n\t\t\t\t\t\thideOnClickModal\n\t\t\t\t\t\tteleported\n\t\t\t\t\t\tinitialIndex={Math.max(state.previewIndex, 0)}\n\t\t\t\t\t\tonClose={() => (state.preview = false)}\n\t\t\t\t\t\turlList={state.previewList}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</Fragment>\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\t/** @description 预览 */\n\t\t\tpreview: computed(() => state.preview),\n\t\t\t/** @description 预览集合 */\n\t\t\tpreviewList: computed(() => state.previewList),\n\t\t});\n\t},\n});\n"],"mappings":";;;;;;;;;;;;;;AAUA,MAAa,sBAAsB;CAClC,GAAG;;CAEH,QAAQ;EACP,MAAM;EACN,eAAuB,WAAW;CACnC;;CAEA,UAAU;EACT,MAAM,eAAiD,MAAM;EAC7D,SAAS;CACV;;CAEA,UAAU;EACT,MAAM;EACN,SAAS;CACV;;CAEA,OAAO;EACN,MAAM;EACN,SAAS;CACV;;CAEA,YAAY,eAAgC,CAAC,KAAK,CAAC;;CAEnD,SAAS;EACR,MAAM,CAAC,QAAQ,MAAM;EACrB,SAAS;CACV;;CAEA,WAAW,EACV,MAAM,eAAwD,QAAQ,EACvE;;CAEA,WAAW;AACZ;;AAGA,MAAa,sBAAsB;;CAElC,sBAAsB,UAAoC,QAAQ,KAAK,KAAK,OAAO,KAAK;;CAExF,oBAAoB,UAAqC,QAAQ,KAAK;AACvE;AAQA,IAAA,uBAAe,gBAAgB;CAC9B,MAAM;CACN,OAAO;CACP,OAAO;CACP,OAAO,UAA+B;CACtC,MAAM,OAAO,EAAE,OAAO,MAAM,UAAU;EACrC,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,SAAA;IAAA,iBAKJ,aAAa,KAAK;IAAC,SAAA;GAAA,GAAA,CAAA,YAAA,QAAA,MAAA,EAAA,eAAA,CAAA,YAAA,QAAA,MAAA,IAAA,CAAA,EAAA,CAAA,CAAA,CAAA,CAAA,CAAA,CAM3E,CAAA,CAAA,CAAA;EAGH,CAAA,GAAA,CAAA,CAAA,iBAAA,SAAA,GA/CQ,QAAQ,KAAK,CAAA,CAAA,GAkDvB,MAAM,WAAO,YAAA,eAAA;GAAA,sBAAA;GAAA,oBAAA;GAAA,cAAA;GAAA,gBAKE,KAAK,IAAI,MAAM,cAAc,CAAC;GAAC,iBAC7B,MAAM,UAAU;GAAM,WAC7B,MAAM;EAAW,GAAA,IAAA,CAE3B,CAAA,CAEF;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;;GAEA,SAAS,eAAe,MAAM,OAAO;;GAErC,aAAa,eAAe,MAAM,WAAW;EAC9C,CAAC;CACF;AACD,CAAC"}
|
|
1
|
+
{"version":3,"file":"uploadImages.mjs","names":["update:modelValue","update:fileList"],"sources":["../../../../src/components/uploadImages/src/uploadImages.tsx"],"sourcesContent":["import { Fragment, computed, defineComponent, reactive, ref } from \"vue\";\nimport { Delete, Edit, Plus, ZoomIn } from \"@element-plus/icons-vue\";\nimport { ElIcon, ElImageViewer, ElUpload, uploadProps } from \"element-plus\";\nimport { isArray, isNull } from \"lodash-unified\";\nimport { FaMimeType } from \"../../../constants\";\nimport { definePropType, makeSlots, randomString, useExpose, useProps, useRender, withDefineType } from \"../../../utils\";\nimport { useUpload } from \"../../upload/src/useUpload\";\nimport type { UploadFile, UploadInstance, UploadProps, UploadUserFile } from \"element-plus\";\n\n/** FaUploadImages 的运行时 Props 定义。 */\nexport const faUploadImagesProps = {\n\t// eslint-disable-next-line @typescript-eslint/no-deprecated -- Element Plus 2.x 尚未提供可替代的公开运行时 props 定义。\n\t...uploadProps,\n\t/** @description accepted [file types](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input#attr-accept), will not work when `thumbnail-mode === true` */\n\taccept: {\n\t\ttype: String,\n\t\tdefault: (): string => FaMimeType.Image,\n\t},\n\t/** @description type of file list */\n\tlistType: {\n\t\ttype: definePropType<NonNullable<UploadProps[\"listType\"]>>(String),\n\t\tdefault: \"picture-card\",\n\t},\n\t/** @description whether uploading multiple files is permitted */\n\tmultiple: {\n\t\ttype: Boolean,\n\t\tdefault: true,\n\t\tvalidator: (value: boolean): boolean => {\n\t\t\tif (!value) {\n\t\t\t\tconsole.warn(\"[Fast:FaUploadImages]\", \"'multiple' 属性固定为 true,外部设置不会生效。\");\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn true;\n\t\t},\n\t},\n\t/** @description maximum number of uploads allowed */\n\tlimit: {\n\t\ttype: Number,\n\t\tdefault: 9,\n\t},\n\t/** @description v-model绑定值 */\n\tmodelValue: definePropType<string[] | null>([Array]),\n\t/** @description 大小限制,单位kb */\n\tmaxSize: {\n\t\ttype: [String, Number],\n\t\tdefault: 2048,\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/** FaUploadImages 的运行时 Emits 定义。 */\nexport const faUploadImagesEmits = {\n\t/** @description v-model 回调 */\n\t\"update:modelValue\": (value: string[] | null): boolean => isArray(value) || isNull(value),\n\t/** @description v-model:fileList 回调 */\n\t\"update:fileList\": (value: UploadUserFile[]): boolean => isArray(value),\n};\n\n/** FaUploadImages 的插槽参数。 */\nexport interface FaUploadImagesSlots extends Record<string, unknown> {\n\t/** @description 默认内容插槽 */\n\tdefault: never;\n}\n\nexport default defineComponent({\n\tname: \"FaUploadImages\",\n\tprops: faUploadImagesProps,\n\temits: faUploadImagesEmits,\n\tslots: makeSlots<FaUploadImagesSlots>(),\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<string[]>(\"FaUploadImages\", \"图片\", 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 disabled = computed(() => {\n\t\t\treturn props.disabled === true || formContext?.disabled === true;\n\t\t});\n\n\t\tconst state = reactive({\n\t\t\tuploadKey: `fa-upload-images__${randomString(8)}`,\n\t\t\tpreview: false,\n\t\t\tpreviewIndex: -1,\n\t\t\tpreviewList: withDefineType<string[]>([]),\n\t\t});\n\n\t\tconst uploadRef = ref<UploadInstance>();\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 handleEdit = (): void => {\n\t\t\tconst uploadInputEl = document.querySelector(`.${state.uploadKey} .el-upload__input`);\n\t\t\tuploadInputEl?.dispatchEvent(new MouseEvent(\"click\"));\n\t\t};\n\n\t\tconst handlePreview = (uploadFile: UploadFile): void => {\n\t\t\tstate.previewIndex = fileList.value.findIndex((f) => f.url === uploadFile.url);\n\t\t\tstate.previewList = fileList.value.flatMap((item) => (item.url ? [item.url] : []));\n\t\t\tstate.preview = true;\n\t\t};\n\n\t\tconst handleRemove = (index: number): void => {\n\t\t\tconst file = fileList.value[index];\n\t\t\tif (file) uploadRef.value?.handleRemove(file as UploadFile);\n\t\t};\n\n\t\tconst handleBeforeUpload: UploadProps[\"beforeUpload\"] = (rawFile) => {\n\t\t\tif (!handleOnUpload(rawFile)) {\n\t\t\t\treturn false;\n\t\t\t}\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\"multiple\",\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<Fragment>\n\t\t\t\t<ElUpload\n\t\t\t\t\t{...elUploadProps.value}\n\t\t\t\t\tref={uploadRef}\n\t\t\t\t\tclass={[\"fa-upload-images\", state.uploadKey, { \"fa-upload-images__hidden-upload\": fileList.value.length >= props.limit }]}\n\t\t\t\t\tvLoading={loading.value}\n\t\t\t\t\tvModel:fileList={fileList.value}\n\t\t\t\t\tmultiple={true}\n\t\t\t\t\tdisabled={disabled.value}\n\t\t\t\t\thttpRequest={httpRequest.value}\n\t\t\t\t\tbeforeUpload={handleBeforeUpload}\n\t\t\t\t\tonExceed={handleOnExceed}\n\t\t\t\t\tonSuccess={handleOnSuccess}\n\t\t\t\t\tonError={handleOnError}\n\t\t\t\t\tonRemove={handleOnRemove}\n\t\t\t\t\tonChange={handleOnChange}\n\t\t\t\t>\n\t\t\t\t\t{{\n\t\t\t\t\t\tdefault: () =>\n\t\t\t\t\t\t\tfileList.value.length < props.limit && slots.default ? (\n\t\t\t\t\t\t\t\tslots.default()\n\t\t\t\t\t\t\t) : (\n\t\t\t\t\t\t\t\t<ElIcon>\n\t\t\t\t\t\t\t\t\t<Plus />\n\t\t\t\t\t\t\t\t</ElIcon>\n\t\t\t\t\t\t\t),\n\t\t\t\t\t\ttip: () => <div class=\"el-upload__tip\">files with a size less than {maxSizeMB.value.toString()}MB</div>,\n\t\t\t\t\t\tfile: ({ file, index }: { file: UploadFile; index: number }) => (\n\t\t\t\t\t\t\t<div>\n\t\t\t\t\t\t\t\t<img class=\"el-upload-list__item-thumbnail\" src={file.url} />\n\t\t\t\t\t\t\t\t<span class=\"el-upload-list__item-actions\">\n\t\t\t\t\t\t\t\t\t<span class=\"el-upload-list__item-preview\" onClick={() => handlePreview(file)} title=\"查看\">\n\t\t\t\t\t\t\t\t\t\t<ElIcon>\n\t\t\t\t\t\t\t\t\t\t\t<ZoomIn />\n\t\t\t\t\t\t\t\t\t\t</ElIcon>\n\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t{!disabled.value && (\n\t\t\t\t\t\t\t\t\t\t<Fragment>\n\t\t\t\t\t\t\t\t\t\t\t<span class=\"el-upload-list__item-icon\" onClick={handleEdit} title=\"编辑\">\n\t\t\t\t\t\t\t\t\t\t\t\t<ElIcon>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<Edit />\n\t\t\t\t\t\t\t\t\t\t\t\t</ElIcon>\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t\t<span class=\"el-upload-list__item-icon\" onClick={() => handleRemove(index)} title=\"删除\">\n\t\t\t\t\t\t\t\t\t\t\t\t<ElIcon>\n\t\t\t\t\t\t\t\t\t\t\t\t\t<Delete />\n\t\t\t\t\t\t\t\t\t\t\t\t</ElIcon>\n\t\t\t\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t\t\t\t</Fragment>\n\t\t\t\t\t\t\t\t\t)}\n\t\t\t\t\t\t\t\t</span>\n\t\t\t\t\t\t\t</div>\n\t\t\t\t\t\t),\n\t\t\t\t\t}}\n\t\t\t\t</ElUpload>\n\t\t\t\t{state.preview && (\n\t\t\t\t\t<ElImageViewer\n\t\t\t\t\t\tcloseOnPressEscape\n\t\t\t\t\t\thideOnClickModal\n\t\t\t\t\t\tteleported\n\t\t\t\t\t\tinitialIndex={Math.max(state.previewIndex, 0)}\n\t\t\t\t\t\tonClose={() => (state.preview = false)}\n\t\t\t\t\t\turlList={state.previewList}\n\t\t\t\t\t/>\n\t\t\t\t)}\n\t\t\t</Fragment>\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\t/** @description 预览 */\n\t\t\tpreview: computed(() => state.preview),\n\t\t\t/** @description 预览集合 */\n\t\t\tpreviewList: computed(() => state.previewList),\n\t\t});\n\t},\n});\n"],"mappings":";;;;;;;;;;;;;;AAUA,MAAa,sBAAsB;CAElC,GAAG;;CAEH,QAAQ;EACP,MAAM;EACN,eAAuB,WAAW;CACnC;;CAEA,UAAU;EACT,MAAM,eAAqD,MAAM;EACjE,SAAS;CACV;;CAEA,UAAU;EACT,MAAM;EACN,SAAS;EACT,YAAY,UAA4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,eAAe,MAAM,OAAO;;GAErC,aAAa,eAAe,MAAM,WAAW;EAC9C,CAAC;CACF;AACD,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/** 将绑定值复制到剪贴板的 Vue 指令。 */
|
|
2
|
-
export declare const vCopy: import("../../utils").Installable<import("vue").ObjectDirective<any, any, string,
|
|
2
|
+
export declare const vCopy: import("../../utils").Installable<import("vue").ObjectDirective<any, any, string, string>>;
|
|
3
3
|
export default vCopy;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["copy","copyToClipboard"],"sources":["../../../src/directives/click-copy/index.ts"],"sourcesContent":["/**\n * v-copy\n * 复制某个值至剪贴板\n * 接收参数:string类型/Ref<string>类型/Reactive<string>类型\n */\nimport { ElMessage } from \"element-plus\";\nimport { copy as copyToClipboard, withInstallDirective } from \"../../utils\";\nimport type { Directive, DirectiveBinding } from \"vue\";\n\ninterface CopyElement extends HTMLElement {\n\tcopyData: string | number;\n\t__handleClick__: () => void;\n}\n\nconst CopyDirective: Directive = {\n\tmounted(el: CopyElement, binding: DirectiveBinding<string | number>) {\n\t\tel.copyData = binding.value;\n\n\t\tconst copy = async (): Promise<void> => {\n\t\t\tif (!el.copyData) return;\n\t\t\ttry {\n\t\t\t\tawait copyToClipboard(String(el.copyData));\n\t\t\t\tElMessage({\n\t\t\t\t\ttype: \"success\",\n\t\t\t\t\tmessage: \"复制成功\",\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tElMessage({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: \"复制失败\",\n\t\t\t\t});\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t};\n\t\tel.__handleClick__ = (): void => {\n\t\t\
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["copy","copyToClipboard"],"sources":["../../../src/directives/click-copy/index.ts"],"sourcesContent":["/**\n * v-copy\n * 复制某个值至剪贴板\n * 接收参数:string类型/Ref<string>类型/Reactive<string>类型\n */\nimport { ElMessage } from \"element-plus\";\nimport { copy as copyToClipboard, withInstallDirective } from \"../../utils\";\nimport type { Directive, DirectiveBinding } from \"vue\";\n\ninterface CopyElement extends HTMLElement {\n\tcopyData: string | number;\n\t__handleClick__: () => void;\n}\n\nconst CopyDirective: Directive = {\n\tmounted(el: CopyElement, binding: DirectiveBinding<string | number>) {\n\t\tel.copyData = binding.value;\n\n\t\tconst copy = async (): Promise<void> => {\n\t\t\tif (!el.copyData) return;\n\t\t\ttry {\n\t\t\t\tawait copyToClipboard(String(el.copyData));\n\t\t\t\tElMessage({\n\t\t\t\t\ttype: \"success\",\n\t\t\t\t\tmessage: \"复制成功\",\n\t\t\t\t});\n\t\t\t} catch (error) {\n\t\t\t\tElMessage({\n\t\t\t\t\ttype: \"error\",\n\t\t\t\t\tmessage: \"复制失败\",\n\t\t\t\t});\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t};\n\t\tel.__handleClick__ = (): void => {\n\t\t\tcopy();\n\t\t};\n\t\tel.addEventListener(\"click\", el.__handleClick__);\n\t},\n\tupdated(el: CopyElement, binding: DirectiveBinding<string | number>) {\n\t\tel.copyData = binding.value;\n\t},\n\tbeforeUnmount(el: CopyElement) {\n\t\tel.removeEventListener(\"click\", el.__handleClick__);\n\t},\n};\n\n/** 将绑定值复制到剪贴板的 Vue 指令。 */\nexport const vCopy = withInstallDirective(CopyDirective, \"copy\");\nexport default vCopy;\n"],"mappings":";;;;AAgDA,MAAa,QAAQ,qBAAqB;CAjCzC,QAAQ,IAAiB,SAA4C;EACpE,GAAG,WAAW,QAAQ;EAEtB,MAAMA,SAAO,YAA2B;GACvC,IAAI,CAAC,GAAG,UAAU;GAClB,IAAI;IACH,MAAMC,KAAgB,OAAO,GAAG,QAAQ,CAAC;IACzC,UAAU;KACT,MAAM;KACN,SAAS;IACV,CAAC;GACF,SAAS,OAAO;IACf,UAAU;KACT,MAAM;KACN,SAAS;IACV,CAAC;IACD,MAAM;GACP;EACD;EACA,GAAG,wBAA8B;GAChC,OAAK;EACN;EACA,GAAG,iBAAiB,SAAS,GAAG,eAAe;CAChD;CACA,QAAQ,IAAiB,SAA4C;EACpE,GAAG,WAAW,QAAQ;CACvB;CACA,cAAc,IAAiB;EAC9B,GAAG,oBAAoB,SAAS,GAAG,eAAe;CACnD;AAIyC,GAAe,MAAM"}
|
|
@@ -3,5 +3,5 @@ interface DebounceElement extends HTMLElement {
|
|
|
3
3
|
__debounce_originClick__?: (...arguments_: unknown[]) => unknown;
|
|
4
4
|
}
|
|
5
5
|
/** 对点击回调进行防抖处理的 Vue 指令。 */
|
|
6
|
-
export declare const vDebounce: import("../../utils").Installable<import("vue").ObjectDirective<DebounceElement, any, string,
|
|
6
|
+
export declare const vDebounce: import("../../utils").Installable<import("vue").ObjectDirective<DebounceElement, any, string, string>>;
|
|
7
7
|
export default vDebounce;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/** 使元素可在父元素范围内拖拽的 Vue 指令。 */
|
|
2
|
-
export declare const vDraggable: import("../../utils").Installable<import("vue").ObjectDirective<HTMLElement, any, string,
|
|
2
|
+
export declare const vDraggable: import("../../utils").Installable<import("vue").ObjectDirective<HTMLElement, any, string, string>>;
|
|
3
3
|
export default vDraggable;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/** 在目标元素前渲染复制图标的 Vue 指令。 */
|
|
2
|
-
export declare const vIconCopy: import("../../utils").Installable<import("vue").ObjectDirective<any, any, string,
|
|
2
|
+
export declare const vIconCopy: import("../../utils").Installable<import("vue").ObjectDirective<any, any, string, string>>;
|
|
3
3
|
export default vIconCopy;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/directives/click-icon-copy/index.ts"],"sourcesContent":["/**\n * v-iconCopy\n * 左侧插入复制图标,复制某个值至剪贴板\n * 接收参数:string类型/Ref<string>类型/Reactive<string>类型\n */\nimport { h, render } from \"vue\";\nimport { CopyDocument } from \"@element-plus/icons-vue\";\nimport { ElIcon, ElMessage } from \"element-plus\";\nimport { copy as copyToClipboard, withInstallDirective } from \"../../utils\";\nimport type { Directive, DirectiveBinding } from \"vue\";\n\ninterface IconCopyElement extends HTMLElement {\n\tcopyData: string | number;\n\t__iconElement__?: Node;\n}\n\nconst IconCopyDirective: Directive = {\n\tmounted(el: IconCopyElement, binding: DirectiveBinding<string | number>) {\n\t\tel.copyData = binding.value;\n\n\t\tif (!el.copyData) return;\n\n\t\tconst handleCopyClick = (): void => {\n\t\t\tcopyToClipboard(String(el.copyData)).then(\n\t\t\t\t() => {\n\t\t\t\t\tElMessage({\n\t\t\t\t\t\ttype: \"success\",\n\t\t\t\t\t\tmessage: \"复制成功\",\n\t\t\t\t\t});\n\t\t\t\t},\n\t\t\t\t() => {\n\t\t\t\t\tElMessage({\n\t\t\t\t\t\ttype: \"error\",\n\t\t\t\t\t\tmessage: \"复制失败\",\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t);\n\t\t};\n\n\t\t// 创建 ELIcon 组件\n\t\tconst iconEl = h(\n\t\t\tElIcon,\n\t\t\t{\n\t\t\t\tclass: \"fa__copy-icon\",\n\t\t\t\ttitle: \"复制\",\n\t\t\t\tonClick: handleCopyClick,\n\t\t\t},\n\t\t\t{\n\t\t\t\tdefault: () => h(CopyDocument),\n\t\t\t}\n\t\t);\n\n\t\tconst tempDiv = document.createElement(\"div\");\n\t\trender(iconEl, tempDiv);\n\n\t\tconst iconElement = tempDiv.firstChild;\n\t\tconst parentElement = el.parentElement;\n\t\tif (iconElement === null || parentElement === null) return;\n\t\tel.__iconElement__ = iconElement;\n\t\tparentElement.insertBefore(iconElement, el);\n\t},\n\tupdated(el: IconCopyElement, binding: DirectiveBinding<string | number>) {\n\t\tel.copyData = binding.value;\n\t},\n\tbeforeUnmount(el: IconCopyElement) {\n\t\tif (el.__iconElement__ && el.parentElement) {\n\t\t\tel.parentElement.removeChild(el.__iconElement__);\n\t\t}\n\t},\n};\n\n/** 在目标元素前渲染复制图标的 Vue 指令。 */\nexport const vIconCopy = withInstallDirective(IconCopyDirective, \"iconCopy\");\nexport default vIconCopy;\n"],"mappings":";;;;;;AAwEA,MAAa,YAAY,qBAAqB;CAvD7C,QAAQ,IAAqB,SAA4C;EACxE,GAAG,WAAW,QAAQ;EAEtB,IAAI,CAAC,GAAG,UAAU;EAElB,MAAM,wBAA8B;GACnC,KAAgB,OAAO,GAAG,QAAQ,CAAC,CAAC,CAAC,WAC9B;IACL,UAAU;KACT,MAAM;KACN,SAAS;IACV,CAAC;GACF,SACM;IACL,UAAU;KACT,MAAM;KACN,SAAS;IACV,CAAC;GACF,CACD;EACD;EAGA,MAAM,SAAS,EACd,QACA;GACC,OAAO;GACP,OAAO;GACP,SAAS;EACV,GACA,EACC,eAAe,EAAE,YAAY,EAC9B,CACD;EAEA,MAAM,UAAU,SAAS,cAAc,KAAK;EAC5C,OAAO,QAAQ,OAAO;EAEtB,MAAM,cAAc,QAAQ;EAC5B,MAAM,gBAAgB,GAAG;EACzB,IAAI,gBAAgB,QAAQ,kBAAkB,MAAM;EACpD,GAAG,kBAAkB;EACrB,cAAc,aAAa,aAAa,EAAE;CAC3C;CACA,QAAQ,IAAqB,SAA4C;EACxE,GAAG,WAAW,QAAQ;CACvB;CACA,cAAc,IAAqB;EAClC,IAAI,GAAG,mBAAmB,GAAG,eAC5B,GAAG,cAAc,YAAY,GAAG,eAAe;CAEjD;AAI6C,GAAmB,UAAU"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/** 长按时触发绑定回调的 Vue 指令。 */
|
|
2
|
-
export declare const vLongpress: import("../../utils").Installable<import("vue").ObjectDirective<any, any, string,
|
|
2
|
+
export declare const vLongpress: import("../../utils").Installable<import("vue").ObjectDirective<any, any, string, string>>;
|
|
3
3
|
export default vLongpress;
|
|
@@ -3,5 +3,5 @@ interface ThrottleElement extends HTMLElement {
|
|
|
3
3
|
disabled: boolean;
|
|
4
4
|
}
|
|
5
5
|
/** 对点击回调进行节流处理的 Vue 指令。 */
|
|
6
|
-
export declare const vThrottle: import("../../utils").Installable<import("vue").ObjectDirective<ThrottleElement, (...arguments_: unknown[]) => void, string,
|
|
6
|
+
export declare const vThrottle: import("../../utils").Installable<import("vue").ObjectDirective<ThrottleElement, (...arguments_: unknown[]) => void, string, string>>;
|
|
7
7
|
export default vThrottle;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"element-plus.mjs","names":[],"sources":["../src/element-plus.ts"],"sourcesContent":["/** Element Plus 组件全局配置 */\n\nimport * as ElementPlusIconsVue from \"@element-plus/icons-vue\";\nimport ElementPlus, { ElDialog, ElForm, ElInput, ElInputNumber, ElMessageBox, ElSelect, ElTable, ElTree, ElTreeSelect } from \"element-plus\";\nimport { isNil, isString } from \"lodash-unified\";\nimport { useOverlay } from \"./hooks\";\nimport { callOptionalFunction } from \"./utils\";\nimport type { Action, ElMessageBoxOptions, ElMessageBoxShortcutMethod, MessageBoxData, MessageBoxState } from \"element-plus\";\nimport type { App, AppContext } from \"vue\";\n\n/* Element Plus 默认值设置。 */\nElDialog.setPropsDefaults({\n\t/** 默认拖拽。 */\n\tdraggable: true,\n});\n\nElForm.setPropsDefaults({\n\t/** 默认标签宽度。 */\n\tlabelWidth: \"auto\",\n\t/** 默认标签后缀。 */\n\tlabelSuffix: \":\",\n\t/** 校验失败时默认滚动到第一个错误表单项。 */\n\tscrollToError: true,\n});\n\nElInput.setPropsDefaults({\n\t/** 默认显示字数统计。 */\n\tshowWordLimit: true,\n});\n\nElInputNumber.setPropsDefaults({\n\t/** 默认不显示控制按钮。 */\n\tcontrols: false,\n});\n\nElSelect.setPropsDefaults({\n\t/** 默认加载提示。 */\n\tloadingText: \"加载中...\",\n\t/** 默认无匹配数据提示。 */\n\tnoMatchText: \"暂无匹配的数据\",\n\t/** 默认无数据提示。 */\n\tnoDataText: \"暂无数据\",\n\t/** 多选时默认折叠标签。 */\n\tcollapseTags: true,\n\t/** 默认在悬停折叠标签时显示完整内容。 */\n\tcollapseTagsTooltip: true,\n});\n\nElTable.setPropsDefaults({\n\t/** 默认显示边框。 */\n\tborder: true,\n\t/** 默认高亮当前行。 */\n\thighlightCurrentRow: true,\n\t/** 默认行 Key。 */\n\trowKey: \"id\",\n});\n\nElTree.setPropsDefaults({\n\t/** 默认展开所有节点。 */\n\tdefaultExpandAll: true,\n\t/** 默认点击时选中节点。 */\n\tcheckOnClickNode: true,\n\t/** 默认高亮当前节点。 */\n\thighlightCurrent: true,\n});\n\nElTreeSelect.setPropsDefaults({\n\t/** 默认加载提示。 */\n\tloadingText: \"加载中...\",\n\t/** 默认无匹配数据提示。 */\n\tnoMatchText: \"暂无匹配的数据\",\n\t/** 默认无数据提示。 */\n\tnoDataText: \"暂无数据\",\n\t/** 多选时默认折叠标签。 */\n\tcollapseTags: true,\n\t/** 默认在悬停折叠标签时显示完整内容。 */\n\tcollapseTagsTooltip: true,\n\t/** 默认展开所有节点。 */\n\tdefaultExpandAll: true,\n\t/** 默认点击时选中节点。 */\n\tcheckOnClickNode: true,\n\t/** 默认高亮当前节点。 */\n\thighlightCurrent: true,\n\t/** 默认仅通过箭头展开或收起节点。 */\n\texpandOnClickNode: false,\n});\n\n// ElMessageBox 默认配置\nconst elMessageBox = (\n\ttype: \"alert\" | \"confirm\" | \"prompt\",\n\tmessage: ElMessageBoxOptions[\"message\"],\n\toptions?: ElMessageBoxOptions,\n\tappContext?: AppContext | null\n): Promise<MessageBoxData> => {\n\t// 不直接修改调用方传入的配置,避免复用同一个 Options 对象时残留本次默认值和 beforeClose 包装。\n\tconst resolvedOptions: ElMessageBoxOptions = { ...(options ?? {}) };\n\t// 默认提示\n\tresolvedOptions.title ??= \"温馨提示\";\n\tif (isNil(resolvedOptions.draggable)) {\n\t\t// 默认拖拽\n\t\tresolvedOptions.draggable = true;\n\t}\n\t// 默认 取消按钮的文本内容\n\tresolvedOptions.cancelButtonText ??= \"取消\";\n\t// 默认 确定按钮的文本内容\n\tresolvedOptions.confirmButtonText ??= \"确定\";\n\tif (isNil(resolvedOptions.closeOnClickModal)) {\n\t\t// 默认 是否可通过点击遮罩层关闭 MessageBox\n\t\tresolvedOptions.closeOnClickModal = false;\n\t}\n\tif (isNil(resolvedOptions.closeOnPressEscape)) {\n\t\t// 默认 是否可通过按下 ESC 键关闭 MessageBox\n\t\tresolvedOptions.closeOnPressEscape = false;\n\t}\n\n\t// 关闭之前的判断逻辑\n\tif (!isNil(resolvedOptions.beforeClose)) {\n\t\tconst localBeforeClose = resolvedOptions.beforeClose;\n\t\tconst localConfirmButtonText = resolvedOptions.confirmButtonText;\n\t\tconst localShowCancelButton = resolvedOptions.showCancelButton;\n\t\tresolvedOptions.beforeClose = (action: Action, instance: MessageBoxState, done: () => void): void => {\n\t\t\tif (action === \"confirm\") {\n\t\t\t\tuseOverlay.show(0);\n\t\t\t\tinstance.confirmButtonLoading = true;\n\t\t\t\tinstance.showCancelButton = false;\n\t\t\t\tinstance.confirmButtonText = \"加载中...\";\n\t\t\t\tlet completed = false;\n\n\t\t\t\tconst cancelLoading = (): void => {\n\t\t\t\t\tinstance.confirmButtonLoading = false;\n\t\t\t\t\tinstance.showCancelButton = localShowCancelButton ?? false;\n\t\t\t\t\tinstance.confirmButtonText = localConfirmButtonText;\n\t\t\t\t\tuseOverlay.hide();\n\t\t\t\t};\n\n\t\t\t\tconst newDone = (): void => {\n\t\t\t\t\tif (completed) return;\n\t\t\t\t\tcompleted = true;\n\t\t\t\t\tcancelLoading();\n\t\t\t\t\tdone();\n\t\t\t\t};\n\n\t\t\t\tcallOptionalFunction(localBeforeClose, action, instance, newDone)\n\t\t\t\t\t.then(() => newDone())\n\t\t\t\t\t.catch((error) => {\n\t\t\t\t\t\tif (!completed) cancelLoading();\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tdone();\n\t\t\t}\n\t\t};\n\t}\n\n\t// 根据类型有一些判断\n\tswitch (type) {\n\t\tcase \"alert\":\n\t\t\tbreak;\n\t\tcase \"confirm\":\n\t\t\tresolvedOptions.showCancelButton ??= true;\n\t\t\tbreak;\n\t\tcase \"prompt\":\n\t\t\tresolvedOptions.showCancelButton ??= true;\n\t\t\tbreak;\n\t}\n\n\treturn ElMessageBox({ message, ...resolvedOptions, boxType: type }, appContext);\n};\n\ntype MESSAGE_BOX_TYPE = \"alert\" | \"confirm\" | \"prompt\";\nconst MESSAGE_BOX_DEFAULT_OPTS: Record<MESSAGE_BOX_TYPE, Partial<ElMessageBoxOptions>> = {\n\talert: { closeOnPressEscape: false, closeOnClickModal: false },\n\tconfirm: { showCancelButton: true },\n\tprompt: { showCancelButton: true, showInput: true },\n};\n\nconst isAppContext = (value: ElMessageBoxOptions | AppContext | null | undefined): value is AppContext =>\n\ttypeof value === \"object\" && value !== null && \"app\" in value && \"config\" in value;\n\nconst createMessageBoxShortcut = (type: MESSAGE_BOX_TYPE): ElMessageBoxShortcutMethod => {\n\tfunction shortcut(\n\t\tmessage: ElMessageBoxOptions[\"message\"],\n\t\toptions?: ElMessageBoxOptions,\n\t\tappContext?: AppContext | null\n\t): Promise<MessageBoxData>;\n\tfunction shortcut(\n\t\tmessage: ElMessageBoxOptions[\"message\"],\n\t\ttitle: ElMessageBoxOptions[\"title\"],\n\t\toptions?: ElMessageBoxOptions,\n\t\tappContext?: AppContext | null\n\t): Promise<MessageBoxData>;\n\tfunction shortcut(\n\t\tmessage: ElMessageBoxOptions[\"message\"],\n\t\ttitleOrOptions?: string | ElMessageBoxOptions,\n\t\toptionsOrContext?: ElMessageBoxOptions | AppContext | null,\n\t\tappContext?: AppContext | null\n\t): Promise<MessageBoxData> {\n\t\tif (isString(titleOrOptions)) {\n\t\t\tconst options = isAppContext(optionsOrContext) ? undefined : optionsOrContext;\n\t\t\treturn elMessageBox(type, message, { ...MESSAGE_BOX_DEFAULT_OPTS[type], title: titleOrOptions, ...(options ?? {}) }, appContext);\n\t\t}\n\n\t\tconst context = optionsOrContext === null || isAppContext(optionsOrContext) ? optionsOrContext : undefined;\n\t\treturn elMessageBox(type, message, { ...MESSAGE_BOX_DEFAULT_OPTS[type], ...(titleOrOptions ?? {}) }, context);\n\t}\n\n\treturn shortcut;\n};\n\nElMessageBox.alert = createMessageBoxShortcut(\"alert\");\nElMessageBox.prompt = createMessageBoxShortcut(\"prompt\");\nElMessageBox.confirm = createMessageBoxShortcut(\"confirm\");\n\n/**\n * 注册 Element Plus 及其全部图标。\n *\n * @param app - Vue 应用实例。\n */\nexport const installElementPlus = (app: App): void => {\n\t/** 注册 Element Plus 全部图标,供 FaIcon 按名称解析。 */\n\tfor (const [key, component] of Object.entries(ElementPlusIconsVue)) app.component(`el-icon-${key}`, component);\n\n\t/** Element Plus 组件完整引入 */\n\tapp.use(ElementPlus);\n};\n"],"mappings":";;;;;;;AAWA,SAAS,iBAAiB;;AAEzB,WAAW,KACZ,CAAC;AAED,OAAO,iBAAiB;;CAEvB,YAAY;;CAEZ,aAAa;;CAEb,eAAe;AAChB,CAAC;AAED,QAAQ,iBAAiB;;AAExB,eAAe,KAChB,CAAC;AAED,cAAc,iBAAiB;;AAE9B,UAAU,MACX,CAAC;AAED,SAAS,iBAAiB;;CAEzB,aAAa;;CAEb,aAAa;;CAEb,YAAY;;CAEZ,cAAc;;CAEd,qBAAqB;AACtB,CAAC;AAED,QAAQ,iBAAiB;;CAExB,QAAQ;;CAER,qBAAqB;;CAErB,QAAQ;AACT,CAAC;AAED,OAAO,iBAAiB;;CAEvB,kBAAkB;;CAElB,kBAAkB;;CAElB,kBAAkB;AACnB,CAAC;AAED,aAAa,iBAAiB;;CAE7B,aAAa;;CAEb,aAAa;;CAEb,YAAY;;CAEZ,cAAc;;CAEd,qBAAqB;;CAErB,kBAAkB;;CAElB,kBAAkB;;CAElB,kBAAkB;;CAElB,mBAAmB;AACpB,CAAC;AAGD,MAAM,gBACL,MACA,SACA,SACA,eAC6B;CAE7B,MAAM,kBAAuC,EAAE,GAAI,WAAW,CAAC,EAAG;CAElE,gBAAgB,UAAU;CAC1B,IAAI,MAAM,gBAAgB,SAAS,GAElC,gBAAgB,YAAY;CAG7B,gBAAgB,qBAAqB;CAErC,gBAAgB,sBAAsB;CACtC,IAAI,MAAM,gBAAgB,iBAAiB,GAE1C,gBAAgB,oBAAoB;CAErC,IAAI,MAAM,gBAAgB,kBAAkB,GAE3C,gBAAgB,qBAAqB;CAItC,IAAI,CAAC,MAAM,gBAAgB,WAAW,GAAG;EACxC,MAAM,mBAAmB,gBAAgB;EACzC,MAAM,yBAAyB,gBAAgB;EAC/C,MAAM,wBAAwB,gBAAgB;EAC9C,gBAAgB,eAAe,QAAgB,UAA2B,SAA2B;GACpG,IAAI,WAAW,WAAW;IACzB,WAAW,KAAK,CAAC;IACjB,SAAS,uBAAuB;IAChC,SAAS,mBAAmB;IAC5B,SAAS,oBAAoB;IAC7B,IAAI,YAAY;IAEhB,MAAM,sBAA4B;KACjC,SAAS,uBAAuB;KAChC,SAAS,mBAAmB,yBAAyB;KACrD,SAAS,oBAAoB;KAC7B,WAAW,KAAK;IACjB;IAEA,MAAM,gBAAsB;KAC3B,IAAI,WAAW;KACf,YAAY;KACZ,cAAc;KACd,KAAK;IACN;IAEA,qBAAqB,kBAAkB,QAAQ,UAAU,OAAO,CAAC,CAC/D,WAAW,QAAQ,CAAC,CAAC,CACrB,OAAO,
|
|
1
|
+
{"version":3,"file":"element-plus.mjs","names":[],"sources":["../src/element-plus.ts"],"sourcesContent":["/** Element Plus 组件全局配置 */\n\nimport * as ElementPlusIconsVue from \"@element-plus/icons-vue\";\nimport ElementPlus, { ElDialog, ElForm, ElInput, ElInputNumber, ElMessageBox, ElSelect, ElTable, ElTree, ElTreeSelect } from \"element-plus\";\nimport { isNil, isString } from \"lodash-unified\";\nimport { useOverlay } from \"./hooks\";\nimport { callOptionalFunction } from \"./utils\";\nimport type { Action, ElMessageBoxOptions, ElMessageBoxShortcutMethod, MessageBoxData, MessageBoxState } from \"element-plus\";\nimport type { App, AppContext } from \"vue\";\n\n/* Element Plus 默认值设置。 */\nElDialog.setPropsDefaults({\n\t/** 默认拖拽。 */\n\tdraggable: true,\n});\n\nElForm.setPropsDefaults({\n\t/** 默认标签宽度。 */\n\tlabelWidth: \"auto\",\n\t/** 默认标签后缀。 */\n\tlabelSuffix: \":\",\n\t/** 校验失败时默认滚动到第一个错误表单项。 */\n\tscrollToError: true,\n});\n\nElInput.setPropsDefaults({\n\t/** 默认显示字数统计。 */\n\tshowWordLimit: true,\n});\n\nElInputNumber.setPropsDefaults({\n\t/** 默认不显示控制按钮。 */\n\tcontrols: false,\n});\n\nElSelect.setPropsDefaults({\n\t/** 默认加载提示。 */\n\tloadingText: \"加载中...\",\n\t/** 默认无匹配数据提示。 */\n\tnoMatchText: \"暂无匹配的数据\",\n\t/** 默认无数据提示。 */\n\tnoDataText: \"暂无数据\",\n\t/** 多选时默认折叠标签。 */\n\tcollapseTags: true,\n\t/** 默认在悬停折叠标签时显示完整内容。 */\n\tcollapseTagsTooltip: true,\n});\n\nElTable.setPropsDefaults({\n\t/** 默认显示边框。 */\n\tborder: true,\n\t/** 默认高亮当前行。 */\n\thighlightCurrentRow: true,\n\t/** 默认行 Key。 */\n\trowKey: \"id\",\n});\n\nElTree.setPropsDefaults({\n\t/** 默认展开所有节点。 */\n\tdefaultExpandAll: true,\n\t/** 默认点击时选中节点。 */\n\tcheckOnClickNode: true,\n\t/** 默认高亮当前节点。 */\n\thighlightCurrent: true,\n});\n\nElTreeSelect.setPropsDefaults({\n\t/** 默认加载提示。 */\n\tloadingText: \"加载中...\",\n\t/** 默认无匹配数据提示。 */\n\tnoMatchText: \"暂无匹配的数据\",\n\t/** 默认无数据提示。 */\n\tnoDataText: \"暂无数据\",\n\t/** 多选时默认折叠标签。 */\n\tcollapseTags: true,\n\t/** 默认在悬停折叠标签时显示完整内容。 */\n\tcollapseTagsTooltip: true,\n\t/** 默认展开所有节点。 */\n\tdefaultExpandAll: true,\n\t/** 默认点击时选中节点。 */\n\tcheckOnClickNode: true,\n\t/** 默认高亮当前节点。 */\n\thighlightCurrent: true,\n\t/** 默认仅通过箭头展开或收起节点。 */\n\texpandOnClickNode: false,\n});\n\n// ElMessageBox 默认配置\nconst elMessageBox = (\n\ttype: \"alert\" | \"confirm\" | \"prompt\",\n\tmessage: ElMessageBoxOptions[\"message\"],\n\toptions?: ElMessageBoxOptions,\n\tappContext?: AppContext | null\n): Promise<MessageBoxData> => {\n\t// 不直接修改调用方传入的配置,避免复用同一个 Options 对象时残留本次默认值和 beforeClose 包装。\n\tconst resolvedOptions: ElMessageBoxOptions = { ...(options ?? {}) };\n\t// 默认提示\n\tresolvedOptions.title ??= \"温馨提示\";\n\tif (isNil(resolvedOptions.draggable)) {\n\t\t// 默认拖拽\n\t\tresolvedOptions.draggable = true;\n\t}\n\t// 默认 取消按钮的文本内容\n\tresolvedOptions.cancelButtonText ??= \"取消\";\n\t// 默认 确定按钮的文本内容\n\tresolvedOptions.confirmButtonText ??= \"确定\";\n\tif (isNil(resolvedOptions.closeOnClickModal)) {\n\t\t// 默认 是否可通过点击遮罩层关闭 MessageBox\n\t\tresolvedOptions.closeOnClickModal = false;\n\t}\n\tif (isNil(resolvedOptions.closeOnPressEscape)) {\n\t\t// 默认 是否可通过按下 ESC 键关闭 MessageBox\n\t\tresolvedOptions.closeOnPressEscape = false;\n\t}\n\n\t// 关闭之前的判断逻辑\n\tif (!isNil(resolvedOptions.beforeClose)) {\n\t\tconst localBeforeClose = resolvedOptions.beforeClose;\n\t\tconst localConfirmButtonText = resolvedOptions.confirmButtonText;\n\t\tconst localShowCancelButton = resolvedOptions.showCancelButton;\n\t\tresolvedOptions.beforeClose = (action: Action, instance: MessageBoxState, done: () => void): void => {\n\t\t\tif (action === \"confirm\") {\n\t\t\t\tuseOverlay.show(0);\n\t\t\t\tinstance.confirmButtonLoading = true;\n\t\t\t\tinstance.showCancelButton = false;\n\t\t\t\tinstance.confirmButtonText = \"加载中...\";\n\t\t\t\tlet completed = false;\n\n\t\t\t\tconst cancelLoading = (): void => {\n\t\t\t\t\tinstance.confirmButtonLoading = false;\n\t\t\t\t\tinstance.showCancelButton = localShowCancelButton ?? false;\n\t\t\t\t\tinstance.confirmButtonText = localConfirmButtonText;\n\t\t\t\t\tuseOverlay.hide();\n\t\t\t\t};\n\n\t\t\t\tconst newDone = (): void => {\n\t\t\t\t\tif (completed) return;\n\t\t\t\t\tcompleted = true;\n\t\t\t\t\tcancelLoading();\n\t\t\t\t\tdone();\n\t\t\t\t};\n\n\t\t\t\tcallOptionalFunction(localBeforeClose, action, instance, newDone)\n\t\t\t\t\t.then(() => newDone())\n\t\t\t\t\t.catch((error: unknown) => {\n\t\t\t\t\t\tif (!completed) cancelLoading();\n\t\t\t\t\t\tthrow error;\n\t\t\t\t\t});\n\t\t\t} else {\n\t\t\t\tdone();\n\t\t\t}\n\t\t};\n\t}\n\n\t// 根据类型有一些判断\n\tswitch (type) {\n\t\tcase \"alert\":\n\t\t\tbreak;\n\t\tcase \"confirm\":\n\t\t\tresolvedOptions.showCancelButton ??= true;\n\t\t\tbreak;\n\t\tcase \"prompt\":\n\t\t\tresolvedOptions.showCancelButton ??= true;\n\t\t\tbreak;\n\t}\n\n\treturn ElMessageBox({ message, ...resolvedOptions, boxType: type }, appContext);\n};\n\ntype MESSAGE_BOX_TYPE = \"alert\" | \"confirm\" | \"prompt\";\nconst MESSAGE_BOX_DEFAULT_OPTS: Record<MESSAGE_BOX_TYPE, Partial<ElMessageBoxOptions>> = {\n\talert: { closeOnPressEscape: false, closeOnClickModal: false },\n\tconfirm: { showCancelButton: true },\n\tprompt: { showCancelButton: true, showInput: true },\n};\n\nconst isAppContext = (value: ElMessageBoxOptions | AppContext | null | undefined): value is AppContext =>\n\ttypeof value === \"object\" && value !== null && \"app\" in value && \"config\" in value;\n\nconst createMessageBoxShortcut = (type: MESSAGE_BOX_TYPE): ElMessageBoxShortcutMethod => {\n\tfunction shortcut(\n\t\tmessage: ElMessageBoxOptions[\"message\"],\n\t\toptions?: ElMessageBoxOptions,\n\t\tappContext?: AppContext | null\n\t): Promise<MessageBoxData>;\n\tfunction shortcut(\n\t\tmessage: ElMessageBoxOptions[\"message\"],\n\t\ttitle: ElMessageBoxOptions[\"title\"],\n\t\toptions?: ElMessageBoxOptions,\n\t\tappContext?: AppContext | null\n\t): Promise<MessageBoxData>;\n\tfunction shortcut(\n\t\tmessage: ElMessageBoxOptions[\"message\"],\n\t\ttitleOrOptions?: string | ElMessageBoxOptions,\n\t\toptionsOrContext?: ElMessageBoxOptions | AppContext | null,\n\t\tappContext?: AppContext | null\n\t): Promise<MessageBoxData> {\n\t\tif (isString(titleOrOptions)) {\n\t\t\tconst options = isAppContext(optionsOrContext) ? undefined : optionsOrContext;\n\t\t\treturn elMessageBox(type, message, { ...MESSAGE_BOX_DEFAULT_OPTS[type], title: titleOrOptions, ...(options ?? {}) }, appContext);\n\t\t}\n\n\t\tconst context = optionsOrContext === null || isAppContext(optionsOrContext) ? optionsOrContext : undefined;\n\t\treturn elMessageBox(type, message, { ...MESSAGE_BOX_DEFAULT_OPTS[type], ...(titleOrOptions ?? {}) }, context);\n\t}\n\n\treturn shortcut;\n};\n\nElMessageBox.alert = createMessageBoxShortcut(\"alert\");\nElMessageBox.prompt = createMessageBoxShortcut(\"prompt\");\nElMessageBox.confirm = createMessageBoxShortcut(\"confirm\");\n\n/**\n * 注册 Element Plus 及其全部图标。\n *\n * @param app - Vue 应用实例。\n */\nexport const installElementPlus = (app: App): void => {\n\t/** 注册 Element Plus 全部图标,供 FaIcon 按名称解析。 */\n\tfor (const [key, component] of Object.entries(ElementPlusIconsVue)) app.component(`el-icon-${key}`, component);\n\n\t/** Element Plus 组件完整引入 */\n\tapp.use(ElementPlus);\n};\n"],"mappings":";;;;;;;AAWA,SAAS,iBAAiB;;AAEzB,WAAW,KACZ,CAAC;AAED,OAAO,iBAAiB;;CAEvB,YAAY;;CAEZ,aAAa;;CAEb,eAAe;AAChB,CAAC;AAED,QAAQ,iBAAiB;;AAExB,eAAe,KAChB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;;AAOzD,MAAa,sBAAsB,QAAmB;;CAErD,KAAK,MAAM,CAAC,KAAK,cAAc,OAAO,QAAQ,mBAAmB,GAAG,IAAI,UAAU,WAAW,OAAO,SAAS;;CAG7G,IAAI,IAAI,WAAW;AACpB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/hooks/use-screenFull/index.ts"],"sourcesContent":["import { ref } from \"vue\";\nimport { ElMessage } from \"element-plus\";\nimport screenfull from \"screenfull\";\n\nconst isFullscreen = ref(false);\nlet initialized = false;\n\nconst handleFullscreenChange = (): void => {\n\tisFullscreen.value = screenfull.isEnabled && screenfull.isFullscreen;\n};\n\n/** 浏览器全屏状态控制器。 */\nexport const useScreenFull = {\n\t/** 获取当前全屏状态。 */\n\tisFullscreen: (): boolean => isFullscreen.value,\n\t/** 初始化全屏状态监听。 */\n\tinit: (): void => {\n\t\tif (!screenfull.isEnabled || initialized) return;\n\t\tinitialized = true;\n\t\thandleFullscreenChange();\n\t\tscreenfull.on(\"change\", handleFullscreenChange);\n\t},\n\t/** 释放全屏状态监听。 */\n\tdispose: (): void => {\n\t\tif (!screenfull.isEnabled || !initialized) return;\n\t\tscreenfull.off(\"change\", handleFullscreenChange);\n\t\tinitialized = false;\n\t},\n\t/** 切换全屏状态。 */\n\ttoggle: (): void => {\n\t\tif (!screenfull.isEnabled) {\n\t\t\tElMessage.warning(\"当前您的浏览器不支持全屏 ❌\");\n\t\t\treturn;\n\t\t}\n\t\
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../../../src/hooks/use-screenFull/index.ts"],"sourcesContent":["import { ref } from \"vue\";\nimport { ElMessage } from \"element-plus\";\nimport screenfull from \"screenfull\";\n\nconst isFullscreen = ref(false);\nlet initialized = false;\n\nconst handleFullscreenChange = (): void => {\n\tisFullscreen.value = screenfull.isEnabled && screenfull.isFullscreen;\n};\n\n/** 浏览器全屏状态控制器。 */\nexport const useScreenFull = {\n\t/** 获取当前全屏状态。 */\n\tisFullscreen: (): boolean => isFullscreen.value,\n\t/** 初始化全屏状态监听。 */\n\tinit: (): void => {\n\t\tif (!screenfull.isEnabled || initialized) return;\n\t\tinitialized = true;\n\t\thandleFullscreenChange();\n\t\tscreenfull.on(\"change\", handleFullscreenChange);\n\t},\n\t/** 释放全屏状态监听。 */\n\tdispose: (): void => {\n\t\tif (!screenfull.isEnabled || !initialized) return;\n\t\tscreenfull.off(\"change\", handleFullscreenChange);\n\t\tinitialized = false;\n\t},\n\t/** 切换全屏状态。 */\n\ttoggle: (): void => {\n\t\tif (!screenfull.isEnabled) {\n\t\t\tElMessage.warning(\"当前您的浏览器不支持全屏 ❌\");\n\t\t\treturn;\n\t\t}\n\t\tscreenfull.toggle();\n\t},\n\t/** 进入全屏状态。 */\n\tfull: (): void => {\n\t\tif (!screenfull.isEnabled) {\n\t\t\tElMessage.warning(\"当前您的浏览器不支持全屏 ❌\");\n\t\t\treturn;\n\t\t}\n\t\tif (screenfull.isFullscreen) {\n\t\t\treturn;\n\t\t}\n\t\t// const htmlEl = document.querySelector(\"html\");\n\t\t// screenfull.request(htmlEl);\n\t\tscreenfull.request();\n\t},\n\t/** 退出全屏状态。 */\n\texit: (): void => {\n\t\tif (!screenfull.isEnabled) {\n\t\t\tElMessage.warning(\"当前您的浏览器不支持全屏 ❌\");\n\t\t\treturn;\n\t\t}\n\t\tif (screenfull.isFullscreen) {\n\t\t\tscreenfull.exit();\n\t\t}\n\t},\n};\n"],"mappings":";;;;AAIA,MAAM,eAAe,IAAI,KAAK;AAC9B,IAAI,cAAc;AAElB,MAAM,+BAAqC;CAC1C,aAAa,QAAQ,WAAW,aAAa,WAAW;AACzD;;AAGA,MAAa,gBAAgB;;CAE5B,oBAA6B,aAAa;;CAE1C,YAAkB;EACjB,IAAI,CAAC,WAAW,aAAa,aAAa;EAC1C,cAAc;EACd,uBAAuB;EACvB,WAAW,GAAG,UAAU,sBAAsB;CAC/C;;CAEA,eAAqB;EACpB,IAAI,CAAC,WAAW,aAAa,CAAC,aAAa;EAC3C,WAAW,IAAI,UAAU,sBAAsB;EAC/C,cAAc;CACf;;CAEA,cAAoB;EACnB,IAAI,CAAC,WAAW,WAAW;GAC1B,UAAU,QAAQ,gBAAgB;GAClC;EACD;EACA,WAAW,OAAO;CACnB;;CAEA,YAAkB;EACjB,IAAI,CAAC,WAAW,WAAW;GAC1B,UAAU,QAAQ,gBAAgB;GAClC;EACD;EACA,IAAI,WAAW,cACd;EAID,WAAW,QAAQ;CACpB;;CAEA,YAAkB;EACjB,IAAI,CAAC,WAAW,WAAW;GAC1B,UAAU,QAAQ,gBAAgB;GAClC;EACD;EACA,IAAI,WAAW,cACd,WAAW,KAAK;CAElB;AACD"}
|