@sia.soul/sia-react-ui 0.1.28 → 0.1.29

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.
@@ -1804,119 +1804,174 @@ interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "prefix
1804
1804
  /** 输入框组件。 */
1805
1805
  declare const Input: react.ForwardRefExoticComponent<InputProps & react.RefAttributes<HTMLInputElement>>;
1806
1806
 
1807
- declare const LIST_IGNORE: unique symbol;
1808
- /** UploadFile的状态类型。 */
1807
+ /** ready 为待上传,uploading 为进行中,done 为成功,error 为校验或网络失败。 */
1809
1808
  type UploadFileStatus = "ready" | "uploading" | "done" | "error";
1810
- /** 上传文件的状态记录,包含唯一标识、文件名、原始文件和服务端响应。 */
1809
+ /** 文件记录;受控更新时应保持 uid 不变。 */
1811
1810
  interface UploadFile {
1812
- /** 文件的唯一标识。 */
1811
+ /** 列表中唯一的文件标识。 */
1813
1812
  uid: string;
1814
- /** 名称或字段标识。 */
1813
+ /** 显示文件名,不含目录。 */
1815
1814
  name: string;
1816
- /** 组件尺寸;用于调整控件高度、字号和间距。 */
1815
+ /** 文件大小,单位字节。 */
1817
1816
  size?: number;
1818
- /** 类型标识,用于选择对应的表现形式。 */
1817
+ /** MIME 类型,例如 image/png。 */
1819
1818
  type?: string;
1820
- /** 当前状态,用于选择对应的状态样式。 */
1819
+ /** 当前状态,缺省按 ready 展示。 */
1821
1820
  status?: UploadFileStatus;
1822
- /** 进度百分比。 */
1821
+ /** 上传百分比,范围 0–100。 */
1823
1822
  percent?: number;
1824
- /** 文件或资源的访问地址。 */
1823
+ /** 远程访问地址,用于预览和文件链接。 */
1825
1824
  url?: string;
1826
- /** 上传服务返回的响应数据。 */
1825
+ /** 缩略图地址,优先于本地缩略图;预览优先使用 url。 */
1826
+ thumbUrl?: string;
1827
+ /** 包含所选根目录的相对路径,例如 photos/trip/a.png;普通文件为文件名。 */
1828
+ relativePath?: string;
1829
+ /** 服务端成功响应;内置请求优先解析 JSON,否则保留文本。 */
1827
1830
  response?: unknown;
1828
- /** 错误信息或错误对象。 */
1831
+ /** 最近一次校验或上传错误。 */
1829
1832
  error?: unknown;
1830
- /** 上传前的原始 File 对象。 */
1833
+ /** 原始 File,用于本地预览与重试;beforeUpload 转换只影响当次请求。 */
1831
1834
  originFileObj?: File;
1832
1835
  }
1833
- /** UploadRequest的配置选项。 */
1836
+ /** 自定义上传参数,可用于 SDK、分片、断点续传或业务请求。 */
1834
1837
  interface UploadRequestOptions {
1835
- /** 当前操作涉及的文件。 */
1838
+ /** 已经 beforeUpload 转换的实际上传文件。 */
1836
1839
  file: File;
1837
- /** 文件名。 */
1840
+ /** 文件名,不是 multipart 字段名。 */
1838
1841
  filename: string;
1839
- /** 上传进度更新时调用。 */
1842
+ /** 本次上传的列表记录快照,uid 可关联业务任务。 */
1843
+ uploadFile: UploadFile;
1844
+ /** 相对路径;普通文件为文件名。 */
1845
+ relativePath: string;
1846
+ /** 取消、移除或卸载时中止;获取签名及分片请求也应监听此信号。 */
1847
+ signal: AbortSignal;
1848
+ /** 更新百分比 0–100;任务结束或取消后的回调会被忽略。 */
1840
1849
  onProgress: (percent: number) => void;
1841
- /** 上传成功时调用,接收响应数据。 */
1842
- onSuccess: (response?: unknown) => void;
1843
- /** 操作发生错误时调用,可用于显示业务错误提示。 */
1850
+ /** 上传完成时调用一次,保存 response;url 可指定访问地址。 */
1851
+ onSuccess: (response?: unknown, url?: string) => void;
1852
+ /** 失败时调用一次,保存错误并通知 onChange。 */
1844
1853
  onError: (error: unknown) => void;
1845
1854
  }
1846
- /** 文件上传的变更事件上下文。 */
1855
+ /** 上传取消句柄,与 signal 一起用于中止底层任务。 */
1856
+ interface UploadRequestHandle {
1857
+ /** 取消、移除或卸载时调用;应终止 SDK 或分片上传。 */
1858
+ abort?: () => void;
1859
+ }
1860
+ /** 通用 HTTP 上传配置,支持业务接口、OSS 签名表单和预签名 PUT。 */
1861
+ interface UploadHttpRequest {
1862
+ /** 上传地址;签名应由业务服务端生成。 */
1863
+ action: string;
1864
+ /** 请求方法,预签名二进制直传通常使用 PUT。 @defaultValue "POST" */
1865
+ method?: "POST" | "PUT" | "PATCH";
1866
+ /** form-data 为 multipart 表单,file 为 File 二进制。 @defaultValue "form-data" */
1867
+ body?: "form-data" | "file";
1868
+ /** multipart 文件字段名。 @defaultValue "file" */
1869
+ name?: string;
1870
+ /** multipart 额外字段,在文件之前添加,例如 key、policy、签名和令牌。 */
1871
+ data?: Readonly<Record<string, string | Blob>>;
1872
+ /** 自定义请求头,需与签名一致;multipart 不要手动设置 Content-Type。 */
1873
+ headers?: Readonly<Record<string, string>>;
1874
+ /** 是否携带跨域 Cookie。 @defaultValue false */
1875
+ withCredentials?: boolean;
1876
+ /** 超时毫秒数,0 为不设超时。 @defaultValue 0 */
1877
+ timeout?: number;
1878
+ /** 成功后写入文件记录的访问地址。 */
1879
+ url?: string;
1880
+ }
1881
+ /** 文件列表变化的上下文。 */
1847
1882
  interface UploadChangeInfo {
1848
- /** 当前操作涉及的文件。 */
1883
+ /** 本次变化的文件;移除时仍提供被移除的记录。 */
1849
1884
  file: UploadFile;
1850
- /** 受控的文件列表。 */
1885
+ /** 最新完整列表,受控模式需回填给 fileList。 */
1851
1886
  fileList: readonly UploadFile[];
1887
+ /** 触发原因:添加、开始、进度、成功、失败、移除或取消。 */
1888
+ event: "add" | "start" | "progress" | "success" | "error" | "remove" | "cancel";
1889
+ }
1890
+ /** 类型或数量限制拒绝的文件。 */
1891
+ interface UploadRejectInfo {
1892
+ /** 未加入列表的原始文件。 */
1893
+ file: File;
1894
+ /** accept 为类型不匹配,max-count 为达到数量上限。 */
1895
+ reason: "accept" | "max-count";
1852
1896
  }
1853
- /** 文件上传的属性配置。 */
1897
+ /** 自定义列表项可调用的操作,仍遵循禁用、取消和 onRemove 规则。 */
1898
+ interface UploadItemActions {
1899
+ /** 开始或重试当前文件;已上传成功或正在上传时不重复启动。 */
1900
+ upload: () => Promise<void>;
1901
+ /** 取消当前任务并回到 ready,保留文件。 */
1902
+ abort: () => void;
1903
+ /** 请求移除,等待 onRemove 允许后取消并删除。 */
1904
+ remove: () => Promise<void>;
1905
+ /** 触发自定义 onPreview,未提供时打开框架图片预览。 */
1906
+ preview: () => void;
1907
+ }
1908
+ /** Upload 的命令式句柄,适用于手动上传及业务工具栏。 */
1909
+ interface UploadRef {
1910
+ /** 开始 ready/error 文件;省略 uid 开始所有待上传项。Promise 在这些任务成功、失败或取消后完成,结果通过 onChange 通知。 */
1911
+ upload: (uid?: string) => Promise<void>;
1912
+ /** 取消指定文件,省略 uid 取消全部;保留记录为 ready,可再次 upload。 */
1913
+ abort: (uid?: string) => void;
1914
+ /** 请求移除指定文件;onRemove 拒绝时保留记录。 */
1915
+ remove: (uid: string) => Promise<void>;
1916
+ }
1917
+ /** 文件上传属性;未配置 request/customRequest 时仅选择文件,不模拟上传成功。 */
1854
1918
  interface UploadProps extends Omit<HTMLAttributes<HTMLDivElement>, "defaultValue" | "onChange"> {
1855
- /** 允许的文件类型,格式同原生 input accept。 */
1919
+ /** 扩展名或 MIME 类型,逗号分隔;点击、拖拽和粘贴均校验。 */
1856
1920
  accept?: string;
1857
- /**
1858
- 是否允许同时选择多个项目。
1859
- * @defaultValue false
1860
- */
1921
+ /** 每批是否允许多个文件;false 仅取首个,directory 模式不受此限制。 @defaultValue false */
1861
1922
  multiple?: boolean;
1862
- /**
1863
- * 是否允许选择文件夹。
1864
- * @defaultValue false
1865
- */
1923
+ /** 选择或拖入文件夹,文件路径保存在 relativePath;不会上传空目录。 @defaultValue false */
1866
1924
  directory?: boolean;
1867
- /**
1868
- * 是否禁用交互。
1869
- * @defaultValue false
1870
- */
1925
+ /** 是否包括子文件夹中的文件;false 仅处理根目录直接包含的文件。 @defaultValue true */
1926
+ recursive?: boolean;
1927
+ /** 聚焦本区域后允许粘贴文件或截图,不监听整个页面也不处理普通文本。 @defaultValue false */
1928
+ pastable?: boolean;
1929
+ /** 禁止添加、移除和启动上传;已在进行的请求不会自动取消。 @defaultValue false */
1871
1930
  disabled?: boolean;
1872
- /** 允许的最大文件数量。 */
1931
+ /** 添加后自动上传;false 为手动模式,调用 ref.upload 或自定义列表操作启动。 @defaultValue true */
1932
+ autoUpload?: boolean;
1933
+ /** 最大文件数量,包含等待及失败项;超出部分拒绝,不替换已有文件。默认不限。 */
1873
1934
  maxCount?: number;
1874
- /** 受控的文件列表。 */
1935
+ /** 受控列表,onChange 中回填;外部移除记录会取消关联请求。 */
1875
1936
  fileList?: readonly UploadFile[];
1876
- /**
1877
- * 非受控模式下的初始文件列表。
1878
- * @defaultValue []
1879
- */
1937
+ /** 非受控初始列表,后续修改不重置列表。 @defaultValue [] */
1880
1938
  defaultFileList?: readonly UploadFile[];
1881
- /**
1882
- * 上传文件列表的展示形式。
1883
- * @defaultValue "text"
1884
- */
1939
+ /** text 为文件列表,picture 为图片行,picture-card 为照片墙;照片墙满额隐藏添加入口。 @defaultValue "text" */
1885
1940
  listType?: "text" | "picture" | "picture-card";
1886
- /**
1887
- * 是否显示上传文件列表。
1888
- * @defaultValue true
1889
- */
1941
+ /** 是否显示列表;隐藏时仍执行数量限制和变更通知。 @defaultValue true */
1890
1942
  showUploadList?: boolean;
1891
- /** 上传前校验或转换文件 */
1892
- beforeUpload?: (file: File, fileList: readonly File[]) => boolean | File | typeof LIST_IGNORE | Promise<boolean | File | typeof LIST_IGNORE>;
1893
- /** 自定义上传实现 */
1894
- customRequest?: (options: UploadRequestOptions) => void | {
1895
- /** 取消当前上传请求。 */
1896
- abort?: () => void;
1897
- };
1898
- /** 值发生变化时调用;参数为新值及类型声明中列出的关联信息。 */
1943
+ /** 启动前校验,可异步;false 保留 ready,Upload.LIST_IGNORE 移除,File 转换本次上传内容;拒绝或抛错进入 error。手动上传时在调用 upload 后执行。 */
1944
+ beforeUpload?: (file: File, fileList: readonly File[]) => boolean | File | symbol | Promise<boolean | File | symbol>;
1945
+ /** HTTP 配置或逐文件异步签名函数,拒绝时进入 error;接收记录和取消信号。customRequest 优先。 */
1946
+ request?: UploadHttpRequest | ((file: UploadFile, signal: AbortSignal) => UploadHttpRequest | Promise<UploadHttpRequest>);
1947
+ /** 自定义上传,负责调用状态回调,可异步返回取消句柄;函数异常或 Promise 拒绝按失败处理。优先于 request。 */
1948
+ customRequest?: (options: UploadRequestOptions) => void | UploadRequestHandle | Promise<void | UploadRequestHandle>;
1949
+ /** 添加、开始、进度、完成、失败、取消和移除时调用;取消任务的迟到回调被忽略。 */
1899
1950
  onChange?: (info: UploadChangeInfo) => void;
1900
- /** 请求移除文件时调用;返回值控制是否允许移除。 */
1901
- onRemove?: (file: UploadFile) => boolean | Promise<boolean>;
1902
- /** 子内容;组件嵌套内容或当前节点的子项。 */
1951
+ /** 移除前调用;false 或 Promise 拒绝阻止移除,否则取消任务并删除。 */
1952
+ onRemove?: (file: UploadFile) => boolean | void | Promise<boolean | void>;
1953
+ /** 文件类型不匹配或数量超限时调用,该文件不进入列表。 */
1954
+ onReject?: (info: UploadRejectInfo) => void;
1955
+ /** 拖拽目录读取失败时调用,本次批次不上传。 */
1956
+ onReadError?: (error: unknown) => void;
1957
+ /** 点击预览时调用,提供后完全接管预览,可实现 PDF、视频或业务弹窗。 */
1958
+ onPreview?: (file: UploadFile) => void;
1959
+ /** 完全自定义列表项;接收默认节点、记录、最新列表及操作句柄,应自行提供可访问的按钮。 */
1960
+ itemRender?: (node: ReactNode, file: UploadFile, fileList: readonly UploadFile[], actions: UploadItemActions) => ReactNode;
1961
+ /** 上传按钮内容,不应嵌套其他交互控件;外层负责点击和键盘操作。 */
1903
1962
  children?: ReactNode;
1904
1963
  }
1905
- /** UploadDragger的属性配置。 */
1964
+ /** 拖拽区域继承全部 Upload 能力,ref 同样支持手动控制。 */
1906
1965
  interface UploadDraggerProps extends UploadProps {
1907
- /**
1908
- * 帮助或校验信息
1909
- * @defaultValue "支持单个或批量上传"
1910
- */
1966
+ /** 辅助说明文字。 @defaultValue "支持单个或批量上传" */
1911
1967
  hint?: ReactNode;
1912
1968
  }
1913
- declare function UploadRoot({ accept, multiple, directory, disabled, maxCount, fileList, defaultFileList, listType, showUploadList, beforeUpload, customRequest, onChange, onRemove, children, className, onDragOver, onDrop, ...props }: UploadProps): react.JSX.Element;
1914
- declare function UploadDragger({ hint, children, className, ...props }: UploadDraggerProps): react.JSX.Element;
1915
- /** 文件上传组件。 */
1916
- declare const Upload: typeof UploadRoot & {
1917
- /** 支持拖入文件上传的区域组件。 */
1918
- Dragger: typeof UploadDragger;
1919
- /** beforeUpload 返回此标记时忽略该文件,不加入上传列表。 */
1969
+
1970
+ /** 上传组件,支持图片列表、照片墙、目录、粘贴与完全受控请求;未配置请求时仅选择文件。 */
1971
+ declare const Upload: react.ForwardRefExoticComponent<UploadProps & react.RefAttributes<UploadRef>> & {
1972
+ /** 可点击、键盘操作和拖拽的上传区域,ref 支持手动上传、取消及移除。 */
1973
+ Dragger: react.ForwardRefExoticComponent<UploadDraggerProps & react.RefAttributes<UploadRef>>;
1974
+ /** beforeUpload 返回时移除该文件,不进行上传。 */
1920
1975
  LIST_IGNORE: symbol;
1921
1976
  };
1922
1977
 
@@ -2169,4 +2224,4 @@ declare const FloatButton: react.ForwardRefExoticComponent<FloatButtonProps & re
2169
2224
  BackTop: typeof FloatButtonBackTop;
2170
2225
  };
2171
2226
 
2172
- export { type MenuTheme as $, type FloatButtonGroupProps as A, type BadgeProps as B, Calendar as C, Dropdown as D, type FloatButtonProps as E, FILLED_ICON_NAMES as F, type FloatButtonShape as G, type FloatingPlacement as H, type FloatingTrigger as I, ICON_NAMES as J, Icon as K, type IconName as L, type IconProps as M, type IconVariant as N, Image as O, ImagePreview as P, type ImagePreviewConfig as Q, type ImagePreviewProps as R, type ImageProps as S, type TagStatus as T, Input as U, type InputProps as V, Menu as W, type MenuClickInfo as X, type MenuItem as Y, type MenuMode as Z, type MenuProps as _, Badge as a, type UploadRequestOptions as a$, type MessageConfig as a0, type MessageHandle as a1, type MessageKey as a2, type MessageType as a3, type NotificationConfig as a4, type NotificationPlacement as a5, type NotificationType as a6, Popconfirm as a7, type PopconfirmProps as a8, Popover as a9, Timeline as aA, type TimelineItem as aB, type TimelineProps as aC, Toolbar as aD, type ToolbarItem as aE, type ToolbarProps as aF, Tooltip as aG, type TooltipProps as aH, Tour as aI, type TourProps as aJ, type TourStep as aK, Tree as aL, type TreeDropPosition as aM, type TreeKey as aN, type TreeNode as aO, type TreeProps as aP, Typography as aQ, type TypographyLinkProps as aR, type TypographyProps as aS, type TypographyTitleProps as aT, type TypographyType as aU, Upload as aV, type UploadChangeInfo as aW, type UploadDraggerProps as aX, type UploadFile as aY, type UploadFileStatus as aZ, type UploadProps as a_, type PopoverProps as aa, Progress as ab, type ProgressProps as ac, type ProgressStatus as ad, Rate as ae, type RateProps as af, Segmented as ag, type SegmentedOption as ah, type SegmentedProps as ai, type SegmentedValue as aj, Spin as ak, type SpinProps as al, type StepItem as am, type StepStatus as an, Steps as ao, type StepsProps as ap, type TabItem as aq, Tabs as ar, type TabsContextMenuClickInfo as as, type TabsOrientation as at, type TabsPosition as au, type TabsProps as av, type TabsType as aw, Tag as ax, type TagProps as ay, type TagVariant as az, type BadgeRibbonProps as b, Watermark as b0, type WatermarkFont as b1, type WatermarkProps as b2, message as b3, notification as b4, type BadgeStatus as c, Breadcrumb as d, type BreadcrumbItem as e, type BreadcrumbProps as f, type CalendarProps as g, Card as h, type CardAccent as i, type CardProps as j, Carousel as k, type CarouselProps as l, type CarouselRef as m, Collapse as n, type CollapseItem as o, type CollapseKey as p, type CollapseProps as q, type DropdownButtonProps as r, type DropdownMenuProps as s, type DropdownOpenSource as t, type DropdownPlacement as u, type DropdownProps as v, type DropdownTrigger as w, type FilledIconName as x, FloatButton as y, type FloatButtonBackTopProps as z };
2227
+ export { type MenuTheme as $, type FloatButtonGroupProps as A, type BadgeProps as B, Calendar as C, Dropdown as D, type FloatButtonProps as E, FILLED_ICON_NAMES as F, type FloatButtonShape as G, type FloatingPlacement as H, type FloatingTrigger as I, ICON_NAMES as J, Icon as K, type IconName as L, type IconProps as M, type IconVariant as N, Image as O, ImagePreview as P, type ImagePreviewConfig as Q, type ImagePreviewProps as R, type ImageProps as S, type TagStatus as T, Input as U, type InputProps as V, Menu as W, type MenuClickInfo as X, type MenuItem as Y, type MenuMode as Z, type MenuProps as _, Badge as a, type UploadItemActions as a$, type MessageConfig as a0, type MessageHandle as a1, type MessageKey as a2, type MessageType as a3, type NotificationConfig as a4, type NotificationPlacement as a5, type NotificationType as a6, Popconfirm as a7, type PopconfirmProps as a8, Popover as a9, Timeline as aA, type TimelineItem as aB, type TimelineProps as aC, Toolbar as aD, type ToolbarItem as aE, type ToolbarProps as aF, Tooltip as aG, type TooltipProps as aH, Tour as aI, type TourProps as aJ, type TourStep as aK, Tree as aL, type TreeDropPosition as aM, type TreeKey as aN, type TreeNode as aO, type TreeProps as aP, Typography as aQ, type TypographyLinkProps as aR, type TypographyProps as aS, type TypographyTitleProps as aT, type TypographyType as aU, Upload as aV, type UploadChangeInfo as aW, type UploadDraggerProps as aX, type UploadFile as aY, type UploadFileStatus as aZ, type UploadHttpRequest as a_, type PopoverProps as aa, Progress as ab, type ProgressProps as ac, type ProgressStatus as ad, Rate as ae, type RateProps as af, Segmented as ag, type SegmentedOption as ah, type SegmentedProps as ai, type SegmentedValue as aj, Spin as ak, type SpinProps as al, type StepItem as am, type StepStatus as an, Steps as ao, type StepsProps as ap, type TabItem as aq, Tabs as ar, type TabsContextMenuClickInfo as as, type TabsOrientation as at, type TabsPosition as au, type TabsProps as av, type TabsType as aw, Tag as ax, type TagProps as ay, type TagVariant as az, type BadgeRibbonProps as b, type UploadProps as b0, type UploadRef as b1, type UploadRejectInfo as b2, type UploadRequestHandle as b3, type UploadRequestOptions as b4, Watermark as b5, type WatermarkFont as b6, type WatermarkProps as b7, message as b8, notification as b9, type BadgeStatus as c, Breadcrumb as d, type BreadcrumbItem as e, type BreadcrumbProps as f, type CalendarProps as g, Card as h, type CardAccent as i, type CardProps as j, Carousel as k, type CarouselProps as l, type CarouselRef as m, Collapse as n, type CollapseItem as o, type CollapseKey as p, type CollapseProps as q, type DropdownButtonProps as r, type DropdownMenuProps as s, type DropdownOpenSource as t, type DropdownPlacement as u, type DropdownProps as v, type DropdownTrigger as w, type FilledIconName as x, FloatButton as y, type FloatButtonBackTopProps as z };
@@ -1804,119 +1804,174 @@ interface InputProps extends Omit<InputHTMLAttributes<HTMLInputElement>, "prefix
1804
1804
  /** 输入框组件。 */
1805
1805
  declare const Input: react.ForwardRefExoticComponent<InputProps & react.RefAttributes<HTMLInputElement>>;
1806
1806
 
1807
- declare const LIST_IGNORE: unique symbol;
1808
- /** UploadFile的状态类型。 */
1807
+ /** ready 为待上传,uploading 为进行中,done 为成功,error 为校验或网络失败。 */
1809
1808
  type UploadFileStatus = "ready" | "uploading" | "done" | "error";
1810
- /** 上传文件的状态记录,包含唯一标识、文件名、原始文件和服务端响应。 */
1809
+ /** 文件记录;受控更新时应保持 uid 不变。 */
1811
1810
  interface UploadFile {
1812
- /** 文件的唯一标识。 */
1811
+ /** 列表中唯一的文件标识。 */
1813
1812
  uid: string;
1814
- /** 名称或字段标识。 */
1813
+ /** 显示文件名,不含目录。 */
1815
1814
  name: string;
1816
- /** 组件尺寸;用于调整控件高度、字号和间距。 */
1815
+ /** 文件大小,单位字节。 */
1817
1816
  size?: number;
1818
- /** 类型标识,用于选择对应的表现形式。 */
1817
+ /** MIME 类型,例如 image/png。 */
1819
1818
  type?: string;
1820
- /** 当前状态,用于选择对应的状态样式。 */
1819
+ /** 当前状态,缺省按 ready 展示。 */
1821
1820
  status?: UploadFileStatus;
1822
- /** 进度百分比。 */
1821
+ /** 上传百分比,范围 0–100。 */
1823
1822
  percent?: number;
1824
- /** 文件或资源的访问地址。 */
1823
+ /** 远程访问地址,用于预览和文件链接。 */
1825
1824
  url?: string;
1826
- /** 上传服务返回的响应数据。 */
1825
+ /** 缩略图地址,优先于本地缩略图;预览优先使用 url。 */
1826
+ thumbUrl?: string;
1827
+ /** 包含所选根目录的相对路径,例如 photos/trip/a.png;普通文件为文件名。 */
1828
+ relativePath?: string;
1829
+ /** 服务端成功响应;内置请求优先解析 JSON,否则保留文本。 */
1827
1830
  response?: unknown;
1828
- /** 错误信息或错误对象。 */
1831
+ /** 最近一次校验或上传错误。 */
1829
1832
  error?: unknown;
1830
- /** 上传前的原始 File 对象。 */
1833
+ /** 原始 File,用于本地预览与重试;beforeUpload 转换只影响当次请求。 */
1831
1834
  originFileObj?: File;
1832
1835
  }
1833
- /** UploadRequest的配置选项。 */
1836
+ /** 自定义上传参数,可用于 SDK、分片、断点续传或业务请求。 */
1834
1837
  interface UploadRequestOptions {
1835
- /** 当前操作涉及的文件。 */
1838
+ /** 已经 beforeUpload 转换的实际上传文件。 */
1836
1839
  file: File;
1837
- /** 文件名。 */
1840
+ /** 文件名,不是 multipart 字段名。 */
1838
1841
  filename: string;
1839
- /** 上传进度更新时调用。 */
1842
+ /** 本次上传的列表记录快照,uid 可关联业务任务。 */
1843
+ uploadFile: UploadFile;
1844
+ /** 相对路径;普通文件为文件名。 */
1845
+ relativePath: string;
1846
+ /** 取消、移除或卸载时中止;获取签名及分片请求也应监听此信号。 */
1847
+ signal: AbortSignal;
1848
+ /** 更新百分比 0–100;任务结束或取消后的回调会被忽略。 */
1840
1849
  onProgress: (percent: number) => void;
1841
- /** 上传成功时调用,接收响应数据。 */
1842
- onSuccess: (response?: unknown) => void;
1843
- /** 操作发生错误时调用,可用于显示业务错误提示。 */
1850
+ /** 上传完成时调用一次,保存 response;url 可指定访问地址。 */
1851
+ onSuccess: (response?: unknown, url?: string) => void;
1852
+ /** 失败时调用一次,保存错误并通知 onChange。 */
1844
1853
  onError: (error: unknown) => void;
1845
1854
  }
1846
- /** 文件上传的变更事件上下文。 */
1855
+ /** 上传取消句柄,与 signal 一起用于中止底层任务。 */
1856
+ interface UploadRequestHandle {
1857
+ /** 取消、移除或卸载时调用;应终止 SDK 或分片上传。 */
1858
+ abort?: () => void;
1859
+ }
1860
+ /** 通用 HTTP 上传配置,支持业务接口、OSS 签名表单和预签名 PUT。 */
1861
+ interface UploadHttpRequest {
1862
+ /** 上传地址;签名应由业务服务端生成。 */
1863
+ action: string;
1864
+ /** 请求方法,预签名二进制直传通常使用 PUT。 @defaultValue "POST" */
1865
+ method?: "POST" | "PUT" | "PATCH";
1866
+ /** form-data 为 multipart 表单,file 为 File 二进制。 @defaultValue "form-data" */
1867
+ body?: "form-data" | "file";
1868
+ /** multipart 文件字段名。 @defaultValue "file" */
1869
+ name?: string;
1870
+ /** multipart 额外字段,在文件之前添加,例如 key、policy、签名和令牌。 */
1871
+ data?: Readonly<Record<string, string | Blob>>;
1872
+ /** 自定义请求头,需与签名一致;multipart 不要手动设置 Content-Type。 */
1873
+ headers?: Readonly<Record<string, string>>;
1874
+ /** 是否携带跨域 Cookie。 @defaultValue false */
1875
+ withCredentials?: boolean;
1876
+ /** 超时毫秒数,0 为不设超时。 @defaultValue 0 */
1877
+ timeout?: number;
1878
+ /** 成功后写入文件记录的访问地址。 */
1879
+ url?: string;
1880
+ }
1881
+ /** 文件列表变化的上下文。 */
1847
1882
  interface UploadChangeInfo {
1848
- /** 当前操作涉及的文件。 */
1883
+ /** 本次变化的文件;移除时仍提供被移除的记录。 */
1849
1884
  file: UploadFile;
1850
- /** 受控的文件列表。 */
1885
+ /** 最新完整列表,受控模式需回填给 fileList。 */
1851
1886
  fileList: readonly UploadFile[];
1887
+ /** 触发原因:添加、开始、进度、成功、失败、移除或取消。 */
1888
+ event: "add" | "start" | "progress" | "success" | "error" | "remove" | "cancel";
1889
+ }
1890
+ /** 类型或数量限制拒绝的文件。 */
1891
+ interface UploadRejectInfo {
1892
+ /** 未加入列表的原始文件。 */
1893
+ file: File;
1894
+ /** accept 为类型不匹配,max-count 为达到数量上限。 */
1895
+ reason: "accept" | "max-count";
1852
1896
  }
1853
- /** 文件上传的属性配置。 */
1897
+ /** 自定义列表项可调用的操作,仍遵循禁用、取消和 onRemove 规则。 */
1898
+ interface UploadItemActions {
1899
+ /** 开始或重试当前文件;已上传成功或正在上传时不重复启动。 */
1900
+ upload: () => Promise<void>;
1901
+ /** 取消当前任务并回到 ready,保留文件。 */
1902
+ abort: () => void;
1903
+ /** 请求移除,等待 onRemove 允许后取消并删除。 */
1904
+ remove: () => Promise<void>;
1905
+ /** 触发自定义 onPreview,未提供时打开框架图片预览。 */
1906
+ preview: () => void;
1907
+ }
1908
+ /** Upload 的命令式句柄,适用于手动上传及业务工具栏。 */
1909
+ interface UploadRef {
1910
+ /** 开始 ready/error 文件;省略 uid 开始所有待上传项。Promise 在这些任务成功、失败或取消后完成,结果通过 onChange 通知。 */
1911
+ upload: (uid?: string) => Promise<void>;
1912
+ /** 取消指定文件,省略 uid 取消全部;保留记录为 ready,可再次 upload。 */
1913
+ abort: (uid?: string) => void;
1914
+ /** 请求移除指定文件;onRemove 拒绝时保留记录。 */
1915
+ remove: (uid: string) => Promise<void>;
1916
+ }
1917
+ /** 文件上传属性;未配置 request/customRequest 时仅选择文件,不模拟上传成功。 */
1854
1918
  interface UploadProps extends Omit<HTMLAttributes<HTMLDivElement>, "defaultValue" | "onChange"> {
1855
- /** 允许的文件类型,格式同原生 input accept。 */
1919
+ /** 扩展名或 MIME 类型,逗号分隔;点击、拖拽和粘贴均校验。 */
1856
1920
  accept?: string;
1857
- /**
1858
- 是否允许同时选择多个项目。
1859
- * @defaultValue false
1860
- */
1921
+ /** 每批是否允许多个文件;false 仅取首个,directory 模式不受此限制。 @defaultValue false */
1861
1922
  multiple?: boolean;
1862
- /**
1863
- * 是否允许选择文件夹。
1864
- * @defaultValue false
1865
- */
1923
+ /** 选择或拖入文件夹,文件路径保存在 relativePath;不会上传空目录。 @defaultValue false */
1866
1924
  directory?: boolean;
1867
- /**
1868
- * 是否禁用交互。
1869
- * @defaultValue false
1870
- */
1925
+ /** 是否包括子文件夹中的文件;false 仅处理根目录直接包含的文件。 @defaultValue true */
1926
+ recursive?: boolean;
1927
+ /** 聚焦本区域后允许粘贴文件或截图,不监听整个页面也不处理普通文本。 @defaultValue false */
1928
+ pastable?: boolean;
1929
+ /** 禁止添加、移除和启动上传;已在进行的请求不会自动取消。 @defaultValue false */
1871
1930
  disabled?: boolean;
1872
- /** 允许的最大文件数量。 */
1931
+ /** 添加后自动上传;false 为手动模式,调用 ref.upload 或自定义列表操作启动。 @defaultValue true */
1932
+ autoUpload?: boolean;
1933
+ /** 最大文件数量,包含等待及失败项;超出部分拒绝,不替换已有文件。默认不限。 */
1873
1934
  maxCount?: number;
1874
- /** 受控的文件列表。 */
1935
+ /** 受控列表,onChange 中回填;外部移除记录会取消关联请求。 */
1875
1936
  fileList?: readonly UploadFile[];
1876
- /**
1877
- * 非受控模式下的初始文件列表。
1878
- * @defaultValue []
1879
- */
1937
+ /** 非受控初始列表,后续修改不重置列表。 @defaultValue [] */
1880
1938
  defaultFileList?: readonly UploadFile[];
1881
- /**
1882
- * 上传文件列表的展示形式。
1883
- * @defaultValue "text"
1884
- */
1939
+ /** text 为文件列表,picture 为图片行,picture-card 为照片墙;照片墙满额隐藏添加入口。 @defaultValue "text" */
1885
1940
  listType?: "text" | "picture" | "picture-card";
1886
- /**
1887
- * 是否显示上传文件列表。
1888
- * @defaultValue true
1889
- */
1941
+ /** 是否显示列表;隐藏时仍执行数量限制和变更通知。 @defaultValue true */
1890
1942
  showUploadList?: boolean;
1891
- /** 上传前校验或转换文件 */
1892
- beforeUpload?: (file: File, fileList: readonly File[]) => boolean | File | typeof LIST_IGNORE | Promise<boolean | File | typeof LIST_IGNORE>;
1893
- /** 自定义上传实现 */
1894
- customRequest?: (options: UploadRequestOptions) => void | {
1895
- /** 取消当前上传请求。 */
1896
- abort?: () => void;
1897
- };
1898
- /** 值发生变化时调用;参数为新值及类型声明中列出的关联信息。 */
1943
+ /** 启动前校验,可异步;false 保留 ready,Upload.LIST_IGNORE 移除,File 转换本次上传内容;拒绝或抛错进入 error。手动上传时在调用 upload 后执行。 */
1944
+ beforeUpload?: (file: File, fileList: readonly File[]) => boolean | File | symbol | Promise<boolean | File | symbol>;
1945
+ /** HTTP 配置或逐文件异步签名函数,拒绝时进入 error;接收记录和取消信号。customRequest 优先。 */
1946
+ request?: UploadHttpRequest | ((file: UploadFile, signal: AbortSignal) => UploadHttpRequest | Promise<UploadHttpRequest>);
1947
+ /** 自定义上传,负责调用状态回调,可异步返回取消句柄;函数异常或 Promise 拒绝按失败处理。优先于 request。 */
1948
+ customRequest?: (options: UploadRequestOptions) => void | UploadRequestHandle | Promise<void | UploadRequestHandle>;
1949
+ /** 添加、开始、进度、完成、失败、取消和移除时调用;取消任务的迟到回调被忽略。 */
1899
1950
  onChange?: (info: UploadChangeInfo) => void;
1900
- /** 请求移除文件时调用;返回值控制是否允许移除。 */
1901
- onRemove?: (file: UploadFile) => boolean | Promise<boolean>;
1902
- /** 子内容;组件嵌套内容或当前节点的子项。 */
1951
+ /** 移除前调用;false 或 Promise 拒绝阻止移除,否则取消任务并删除。 */
1952
+ onRemove?: (file: UploadFile) => boolean | void | Promise<boolean | void>;
1953
+ /** 文件类型不匹配或数量超限时调用,该文件不进入列表。 */
1954
+ onReject?: (info: UploadRejectInfo) => void;
1955
+ /** 拖拽目录读取失败时调用,本次批次不上传。 */
1956
+ onReadError?: (error: unknown) => void;
1957
+ /** 点击预览时调用,提供后完全接管预览,可实现 PDF、视频或业务弹窗。 */
1958
+ onPreview?: (file: UploadFile) => void;
1959
+ /** 完全自定义列表项;接收默认节点、记录、最新列表及操作句柄,应自行提供可访问的按钮。 */
1960
+ itemRender?: (node: ReactNode, file: UploadFile, fileList: readonly UploadFile[], actions: UploadItemActions) => ReactNode;
1961
+ /** 上传按钮内容,不应嵌套其他交互控件;外层负责点击和键盘操作。 */
1903
1962
  children?: ReactNode;
1904
1963
  }
1905
- /** UploadDragger的属性配置。 */
1964
+ /** 拖拽区域继承全部 Upload 能力,ref 同样支持手动控制。 */
1906
1965
  interface UploadDraggerProps extends UploadProps {
1907
- /**
1908
- * 帮助或校验信息
1909
- * @defaultValue "支持单个或批量上传"
1910
- */
1966
+ /** 辅助说明文字。 @defaultValue "支持单个或批量上传" */
1911
1967
  hint?: ReactNode;
1912
1968
  }
1913
- declare function UploadRoot({ accept, multiple, directory, disabled, maxCount, fileList, defaultFileList, listType, showUploadList, beforeUpload, customRequest, onChange, onRemove, children, className, onDragOver, onDrop, ...props }: UploadProps): react.JSX.Element;
1914
- declare function UploadDragger({ hint, children, className, ...props }: UploadDraggerProps): react.JSX.Element;
1915
- /** 文件上传组件。 */
1916
- declare const Upload: typeof UploadRoot & {
1917
- /** 支持拖入文件上传的区域组件。 */
1918
- Dragger: typeof UploadDragger;
1919
- /** beforeUpload 返回此标记时忽略该文件,不加入上传列表。 */
1969
+
1970
+ /** 上传组件,支持图片列表、照片墙、目录、粘贴与完全受控请求;未配置请求时仅选择文件。 */
1971
+ declare const Upload: react.ForwardRefExoticComponent<UploadProps & react.RefAttributes<UploadRef>> & {
1972
+ /** 可点击、键盘操作和拖拽的上传区域,ref 支持手动上传、取消及移除。 */
1973
+ Dragger: react.ForwardRefExoticComponent<UploadDraggerProps & react.RefAttributes<UploadRef>>;
1974
+ /** beforeUpload 返回时移除该文件,不进行上传。 */
1920
1975
  LIST_IGNORE: symbol;
1921
1976
  };
1922
1977
 
@@ -2169,4 +2224,4 @@ declare const FloatButton: react.ForwardRefExoticComponent<FloatButtonProps & re
2169
2224
  BackTop: typeof FloatButtonBackTop;
2170
2225
  };
2171
2226
 
2172
- export { type MenuTheme as $, type FloatButtonGroupProps as A, type BadgeProps as B, Calendar as C, Dropdown as D, type FloatButtonProps as E, FILLED_ICON_NAMES as F, type FloatButtonShape as G, type FloatingPlacement as H, type FloatingTrigger as I, ICON_NAMES as J, Icon as K, type IconName as L, type IconProps as M, type IconVariant as N, Image as O, ImagePreview as P, type ImagePreviewConfig as Q, type ImagePreviewProps as R, type ImageProps as S, type TagStatus as T, Input as U, type InputProps as V, Menu as W, type MenuClickInfo as X, type MenuItem as Y, type MenuMode as Z, type MenuProps as _, Badge as a, type UploadRequestOptions as a$, type MessageConfig as a0, type MessageHandle as a1, type MessageKey as a2, type MessageType as a3, type NotificationConfig as a4, type NotificationPlacement as a5, type NotificationType as a6, Popconfirm as a7, type PopconfirmProps as a8, Popover as a9, Timeline as aA, type TimelineItem as aB, type TimelineProps as aC, Toolbar as aD, type ToolbarItem as aE, type ToolbarProps as aF, Tooltip as aG, type TooltipProps as aH, Tour as aI, type TourProps as aJ, type TourStep as aK, Tree as aL, type TreeDropPosition as aM, type TreeKey as aN, type TreeNode as aO, type TreeProps as aP, Typography as aQ, type TypographyLinkProps as aR, type TypographyProps as aS, type TypographyTitleProps as aT, type TypographyType as aU, Upload as aV, type UploadChangeInfo as aW, type UploadDraggerProps as aX, type UploadFile as aY, type UploadFileStatus as aZ, type UploadProps as a_, type PopoverProps as aa, Progress as ab, type ProgressProps as ac, type ProgressStatus as ad, Rate as ae, type RateProps as af, Segmented as ag, type SegmentedOption as ah, type SegmentedProps as ai, type SegmentedValue as aj, Spin as ak, type SpinProps as al, type StepItem as am, type StepStatus as an, Steps as ao, type StepsProps as ap, type TabItem as aq, Tabs as ar, type TabsContextMenuClickInfo as as, type TabsOrientation as at, type TabsPosition as au, type TabsProps as av, type TabsType as aw, Tag as ax, type TagProps as ay, type TagVariant as az, type BadgeRibbonProps as b, Watermark as b0, type WatermarkFont as b1, type WatermarkProps as b2, message as b3, notification as b4, type BadgeStatus as c, Breadcrumb as d, type BreadcrumbItem as e, type BreadcrumbProps as f, type CalendarProps as g, Card as h, type CardAccent as i, type CardProps as j, Carousel as k, type CarouselProps as l, type CarouselRef as m, Collapse as n, type CollapseItem as o, type CollapseKey as p, type CollapseProps as q, type DropdownButtonProps as r, type DropdownMenuProps as s, type DropdownOpenSource as t, type DropdownPlacement as u, type DropdownProps as v, type DropdownTrigger as w, type FilledIconName as x, FloatButton as y, type FloatButtonBackTopProps as z };
2227
+ export { type MenuTheme as $, type FloatButtonGroupProps as A, type BadgeProps as B, Calendar as C, Dropdown as D, type FloatButtonProps as E, FILLED_ICON_NAMES as F, type FloatButtonShape as G, type FloatingPlacement as H, type FloatingTrigger as I, ICON_NAMES as J, Icon as K, type IconName as L, type IconProps as M, type IconVariant as N, Image as O, ImagePreview as P, type ImagePreviewConfig as Q, type ImagePreviewProps as R, type ImageProps as S, type TagStatus as T, Input as U, type InputProps as V, Menu as W, type MenuClickInfo as X, type MenuItem as Y, type MenuMode as Z, type MenuProps as _, Badge as a, type UploadItemActions as a$, type MessageConfig as a0, type MessageHandle as a1, type MessageKey as a2, type MessageType as a3, type NotificationConfig as a4, type NotificationPlacement as a5, type NotificationType as a6, Popconfirm as a7, type PopconfirmProps as a8, Popover as a9, Timeline as aA, type TimelineItem as aB, type TimelineProps as aC, Toolbar as aD, type ToolbarItem as aE, type ToolbarProps as aF, Tooltip as aG, type TooltipProps as aH, Tour as aI, type TourProps as aJ, type TourStep as aK, Tree as aL, type TreeDropPosition as aM, type TreeKey as aN, type TreeNode as aO, type TreeProps as aP, Typography as aQ, type TypographyLinkProps as aR, type TypographyProps as aS, type TypographyTitleProps as aT, type TypographyType as aU, Upload as aV, type UploadChangeInfo as aW, type UploadDraggerProps as aX, type UploadFile as aY, type UploadFileStatus as aZ, type UploadHttpRequest as a_, type PopoverProps as aa, Progress as ab, type ProgressProps as ac, type ProgressStatus as ad, Rate as ae, type RateProps as af, Segmented as ag, type SegmentedOption as ah, type SegmentedProps as ai, type SegmentedValue as aj, Spin as ak, type SpinProps as al, type StepItem as am, type StepStatus as an, Steps as ao, type StepsProps as ap, type TabItem as aq, Tabs as ar, type TabsContextMenuClickInfo as as, type TabsOrientation as at, type TabsPosition as au, type TabsProps as av, type TabsType as aw, Tag as ax, type TagProps as ay, type TagVariant as az, type BadgeRibbonProps as b, type UploadProps as b0, type UploadRef as b1, type UploadRejectInfo as b2, type UploadRequestHandle as b3, type UploadRequestOptions as b4, Watermark as b5, type WatermarkFont as b6, type WatermarkProps as b7, message as b8, notification as b9, type BadgeStatus as c, Breadcrumb as d, type BreadcrumbItem as e, type BreadcrumbProps as f, type CalendarProps as g, Card as h, type CardAccent as i, type CardProps as j, Carousel as k, type CarouselProps as l, type CarouselRef as m, Collapse as n, type CollapseItem as o, type CollapseKey as p, type CollapseProps as q, type DropdownButtonProps as r, type DropdownMenuProps as s, type DropdownOpenSource as t, type DropdownPlacement as u, type DropdownProps as v, type DropdownTrigger as w, type FilledIconName as x, FloatButton as y, type FloatButtonBackTopProps as z };