1 line
44 KiB
JSON
1 line
44 KiB
JSON
|
{"ast":null,"code":"\"use client\";\n\nimport _toConsumableArray from \"@babel/runtime/helpers/esm/toConsumableArray\";\nvar __awaiter = this && this.__awaiter || function (thisArg, _arguments, P, generator) {\n function adopt(value) {\n return value instanceof P ? value : new P(function (resolve) {\n resolve(value);\n });\n }\n return new (P || (P = Promise))(function (resolve, reject) {\n function fulfilled(value) {\n try {\n step(generator.next(value));\n } catch (e) {\n reject(e);\n }\n }\n function rejected(value) {\n try {\n step(generator[\"throw\"](value));\n } catch (e) {\n reject(e);\n }\n }\n function step(result) {\n result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);\n }\n step((generator = generator.apply(thisArg, _arguments || [])).next());\n });\n};\nimport * as React from 'react';\nimport { flushSync } from 'react-dom';\nimport classNames from 'classnames';\nimport RcUpload from 'rc-upload';\nimport useMergedState from \"rc-util/es/hooks/useMergedState\";\nimport { devUseWarning } from '../_util/warning';\nimport { ConfigContext } from '../config-provider';\nimport DisabledContext from '../config-provider/DisabledContext';\nimport { useLocale } from '../locale';\nimport defaultLocale from '../locale/en_US';\nimport useStyle from './style';\nimport UploadList from './UploadList';\nimport { file2Obj, getFileItem, removeFileItem, updateFileList } from './utils';\nexport const LIST_IGNORE = `__LIST_IGNORE_${Date.now()}__`;\nconst InternalUpload = (props, ref) => {\n const {\n fileList,\n defaultFileList,\n onRemove,\n showUploadList = true,\n listType = 'text',\n onPreview,\n onDownload,\n onChange,\n onDrop,\n previewFile,\n disabled: customDisabled,\n locale: propLocale,\n iconRender,\n isImageUrl,\n progress,\n prefixCls: customizePrefixCls,\n className,\n type = 'select',\n children,\n style,\n itemRender,\n maxCount,\n data = {},\n multiple = false,\n hasControlInside = true,\n action = '',\n accept = '',\n supportServerRender = true,\n rootClassName\n } = props;\n // ===================== Disabled =====================\n const disabled = React.useContext(DisabledContext);\n const mergedDisabled = customDisabled !== null && customDisabled !== void 0 ? customDisabled : disabled;\n const [mergedFileList, setMergedFileList] = useMergedState(defaultFileList || [], {\n value: fileList,\n postState: list => list !== null && list !== void 0 ? list : []\n });\n const [dragState, setDragState] = React.useState('drop');\n const upload = React.useRef(null);\n const wrapRef = React.useRef(null);\n if (process.env.NODE_ENV !== 'production') {\n const warning = devUseWarning('Upload');\n process.env.NODE_ENV !== \"production\" ? warning('fileList' in props || !('value' in props), 'usage', '`value` is not a valid prop, do you mean `fileList`?') : void 0;\n warning.deprecated(!('transformFile' in props), 'transformFile', 'beforeUpload');\n }\n // Control mode will auto fill file uid if not provided\n React.useMemo(() => {\n const timestamp = Date.now();\n (fileList || []).forEach((file, index) => {\n if (!file.uid && !Object.isFrozen(file)) {\n file.uid = `__AUTO__${timestamp}_${index}__`;\n }\n });\n }, [fileList]);\n const onInternalChange = (file, changedFileList, event) => {\n let cloneList = _toConsumableArray(changedFileList);\n let exceedMaxCount = false;\n // Cut to match count\n if (maxCount === 1) {\n cloneList = cloneList.slice(-1);\n } else if (maxCount) {\n exceedMaxCount = cloneList.length > maxCount;\n cloneList = cloneList.slice(0, maxCount);\n }\n // Prevent React18 auto batch since input[upload] trigger process at same time\n // which makes fileList closure problem\n flushSync(() => {\n setMergedFileList(cloneList);\n });\n const changeInfo = {\n file: file,\n fileLis
|