tango-ui-cw 1.1.0 → 1.2.0

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/README.md CHANGED
@@ -12,12 +12,18 @@ A lightweight React UI library for Next.js, powered by Tailwind CSS. Pre-compile
12
12
 
13
13
  ---
14
14
 
15
+ ![npm-rate](./npm-rate.png)
16
+
15
17
  ## Installation
16
18
 
17
19
  ```bash
18
20
  npm install tango-ui-cw
19
21
  ```
20
22
 
23
+ ```bash
24
+ pnpm install tango-ui-cw
25
+ ```
26
+
21
27
  ### Peer Dependencies
22
28
 
23
29
  ```bash
@@ -53,3 +53,9 @@ export declare const createSlotProps: (options?: {
53
53
  className: string;
54
54
  style: SxStyleObject;
55
55
  };
56
+
57
+ export declare const resolveSupportedValue: <T>(
58
+ value: T,
59
+ fallback: T,
60
+ map: Record<string, unknown>
61
+ ) => T;
@@ -1,6 +1,7 @@
1
1
  import type { CSSProperties, ReactNode } from "react";
2
2
  import type { SxValue } from "../CSSFab";
3
3
 
4
+ export type BannerSlotNames = readonly ["root", "icon", "content", "actions", "closeIcon"];
4
5
  export type BannerLevel = "info" | "success" | "warning" | "error";
5
6
  export type BannerSize = "small" | "normal" | "large";
6
7
 
@@ -6,6 +6,7 @@ import type {
6
6
  } from "react";
7
7
  import type { SxValue } from "../CSSFab";
8
8
 
9
+ export type ButtonSlotNames = readonly ["root", "content", "icon", "loading"];
9
10
  export type ButtonVariant = "default" | "transparent" | "danger" | "success";
10
11
  export type ButtonSize = "small" | "medium" | "large" | "huge";
11
12
  export type LoadingMode = boolean | "light" | "dark" | [boolean | "light" | "dark", "light" | "dark"];
@@ -64,6 +65,7 @@ export interface ButtonProps
64
65
  declare function Button(props: ButtonProps): JSX.Element;
65
66
 
66
67
  // MaterialButton 类型
68
+ export type MaterialButtonSlotNames = readonly ["root", "content", "icon", "loading"];
67
69
  export type MaterialButtonVariant = "default" | "transparent" | "danger" | "success";
68
70
  export type MaterialButtonSize = "small" | "medium" | "large" | "huge";
69
71
 
@@ -0,0 +1,40 @@
1
+ import type {
2
+ CSSProperties,
3
+ HTMLAttributes,
4
+ ReactNode,
5
+ Ref,
6
+ } from "react";
7
+
8
+ /** Card sx slot 名列表 */
9
+ export type CardSlotNames = readonly ["root", "header", "body"];
10
+
11
+ /** sx 值类型 */
12
+ export type SxValue =
13
+ | string
14
+ | { tw?: string; className?: string; css?: CSSProperties; style?: CSSProperties }
15
+ | Record<string, unknown>;
16
+
17
+ /** Card Props */
18
+ export interface CardProps extends Omit<HTMLAttributes<HTMLDivElement>, "style" | "title"> {
19
+ /** 卡片标题 */
20
+ title?: ReactNode;
21
+ /** 卡片标题右侧额外内容(如操作按钮) */
22
+ extra?: ReactNode;
23
+ /** 是否显示边框 */
24
+ bordered?: boolean;
25
+ /** 样式扩展 */
26
+ sx?: SxValue;
27
+ /** 行内样式 */
28
+ style?: CSSProperties;
29
+ /** 额外 CSS 类名 */
30
+ className?: string;
31
+ /** 卡片内容 */
32
+ children?: ReactNode;
33
+ /** ref 转发 */
34
+ ref?: Ref<HTMLDivElement>;
35
+ }
36
+
37
+ declare const Card: React.ForwardRefExoticComponent<
38
+ CardProps & React.RefAttributes<HTMLDivElement>
39
+ >;
40
+ export default Card;
@@ -1,6 +1,7 @@
1
1
  import type { CSSProperties, InputHTMLAttributes } from "react";
2
2
  import type { SxValue } from "../CSSFab";
3
3
 
4
+ export type ColorPickerSlotNames = readonly ["root", "input", "text"];
4
5
  export type ColorPickerSize = "small" | "medium" | "large";
5
6
  export type ColorPickerFormat = "hex" | "rgb" | "hsl";
6
7
  export type ColorPickerShowText = boolean | ColorPickerFormat;
@@ -1,6 +1,7 @@
1
1
  import type { CSSProperties, HTMLAttributes } from "react";
2
2
  import type { SxValue } from "../CSSFab";
3
3
 
4
+ export type DateSlotNames = readonly ["root", "date", "weekday", "time"];
4
5
  export type DateType =
5
6
  | "default"
6
7
  | "line"
@@ -3,7 +3,9 @@ import type { SxValue } from "../CSSFab";
3
3
 
4
4
  export type DatePickerSize = "small" | "medium" | "large";
5
5
 
6
- export type DatePickerI18nKey = "placeholder" | "placeholderTime" | "timeLabel" | "confirm" | "cancel" | "prevMonth" | "nextMonth" | (string & {});
6
+ export type DatePickerSlotNames = readonly ["root", "input", "panel", "header", "body", "footer"];
7
+
8
+ export type DatePickerI18nKey = "placeholder" | "placeholderTime" | "timeLabel" | "confirm" | "cancel" | "prevMonth" | "nextMonth" | "hourLabel" | "minuteLabel" | "panelAriaLabel" | (string & {});
7
9
 
8
10
  export type DatePickerLocaleText = Partial<{
9
11
  placeholder: string;
@@ -15,6 +17,9 @@ export type DatePickerLocaleText = Partial<{
15
17
  nextMonth: string;
16
18
  weekDays: string[];
17
19
  monthFormat: string;
20
+ hourLabel: string;
21
+ minuteLabel: string;
22
+ panelAriaLabel: string;
18
23
  }>;
19
24
 
20
25
  export interface DatePickerProps
@@ -1,6 +1,7 @@
1
1
  import type { CSSProperties, HTMLAttributes, ReactNode } from "react";
2
2
  import type { SxValue } from "../CSSFab";
3
3
 
4
+ export type DrawerSlotNames = readonly ["overlay", "container", "header", "title", "closeBtn", "content", "footer"];
4
5
  export type DrawerType = "top" | "bottom" | "left" | "right";
5
6
 
6
7
  export type DrawerI18nKey = "title" | "okText" | "cancelText" | "closeAriaLabel" | (string & {});
@@ -1,10 +1,17 @@
1
- import type { CSSProperties, InputHTMLAttributes, TextareaHTMLAttributes } from "react";
1
+ import type { CSSProperties, InputHTMLAttributes, ReactNode, TextareaHTMLAttributes } from "react";
2
2
  import type { SxValue } from "../CSSFab";
3
3
 
4
+ export type InputSlotNames = readonly ["root", "input", "prefix", "suffix", "clearIcon"];
4
5
  export type InputType = "default" | "textarea" | "password";
5
6
  export type InputSize = "small" | "medium" | "large" | "huge";
6
7
  export type InputStatus = "default" | "error";
7
8
 
9
+ // added by clayw on 20260624: Input localeText 类型
10
+ export type InputLocaleText = Partial<{
11
+ clearAriaLabel: string;
12
+ countTemplate: string;
13
+ }>;
14
+
8
15
  export interface InputProps
9
16
  extends Omit<InputHTMLAttributes<HTMLInputElement> & TextareaHTMLAttributes<HTMLTextAreaElement>, "style" | "className" | "size" | "type" | "onChange"> {
10
17
  /** 输入类型 */
@@ -30,7 +37,17 @@ export interface InputProps
30
37
  /** 占位文案 */
31
38
  placeholder?: string;
32
39
  /** 最大字符数 */
33
- maxlength?: number;
40
+ maxLength?: number;
41
+ /** 前缀图标/文字,位于输入框内左侧 added by clayw on 20260624 */
42
+ prefix?: ReactNode;
43
+ /** 后缀图标/文字,位于输入框内右侧 added by clayw on 20260624 */
44
+ suffix?: ReactNode;
45
+ /** 是否显示清除按钮,默认 true,值为空时隐藏图标 added by clayw on 20260624 */
46
+ allowClear?: boolean;
47
+ /** 是否显示字数统计,默认 false,支持 i18n added by clayw on 20260624 */
48
+ showCount?: boolean;
49
+ /** 覆盖内置文案 added by clayw on 20260624 */
50
+ localeText?: InputLocaleText;
34
51
  }
35
52
 
36
53
  declare function Input(props: InputProps): JSX.Element;
@@ -46,11 +63,14 @@ export { InputWithType as Input };
46
63
  export default Input;
47
64
 
48
65
  // MaterialInput 类型
66
+ export type MaterialInputSlotNames = readonly ["root", "input", "label", "prefix", "suffix", "clearIcon"];
49
67
  export type MaterialInputSize = "small" | "medium" | "large" | "huge";
50
68
 
51
- export interface MaterialInputLocaleText {
69
+ export type MaterialInputLocaleText = Partial<{
52
70
  label?: string;
53
- }
71
+ clearAriaLabel?: string;
72
+ countTemplate?: string;
73
+ }>;
54
74
 
55
75
  export interface MaterialInputProps
56
76
  extends Omit<InputHTMLAttributes<HTMLInputElement>, "style" | "className" | "size" | "onChange" | "type"> {
@@ -74,6 +94,16 @@ export interface MaterialInputProps
74
94
  disabled?: boolean;
75
95
  /** 覆盖标签文案 */
76
96
  localeText?: MaterialInputLocaleText;
97
+ /** 前缀图标/文字 added by clayw on 20260624 */
98
+ prefix?: ReactNode;
99
+ /** 后缀图标/文字 added by clayw on 20260624 */
100
+ suffix?: ReactNode;
101
+ /** 是否显示清除按钮,默认 true added by clayw on 20260624 */
102
+ allowClear?: boolean;
103
+ /** 是否显示字数统计,默认 false added by clayw on 20260624 */
104
+ showCount?: boolean;
105
+ /** 最大字符数 added by clayw on 20260624 */
106
+ maxLength?: number;
77
107
  }
78
108
 
79
109
  declare function MaterialInput(props: MaterialInputProps): JSX.Element;
@@ -5,6 +5,9 @@ import type {
5
5
  Ref,
6
6
  } from "react";
7
7
 
8
+ /** Layout sx slot 名列表 */
9
+ export type LayoutSlotNames = readonly ["root"];
10
+
8
11
  /** sx 值类型(引用自 CSSFab) */
9
12
  export type SxValue =
10
13
  | string
@@ -5,6 +5,9 @@ import type {
5
5
  Ref,
6
6
  } from "react";
7
7
 
8
+ /** Line sx slot 名列表 */
9
+ export type LineSlotNames = readonly ["root", "text"];
10
+
8
11
  /** sx 值类型 */
9
12
  export type SxValue =
10
13
  | string
@@ -5,6 +5,9 @@ import type {
5
5
  Ref,
6
6
  } from "react";
7
7
 
8
+ /** Mark sx slot 名列表 */
9
+ export type MarkSlotNames = readonly ["root"];
10
+
8
11
  /** sx 值类型 */
9
12
  export type SxValue =
10
13
  | string
@@ -1,13 +1,19 @@
1
1
  import type { CSSProperties, HTMLAttributes, ReactNode } from "react";
2
2
  import type { SxValue } from "../CSSFab";
3
3
 
4
- export type ModalI18nKey = "title" | "okText" | "cancelText" | "closeAriaLabel" | (string & {});
4
+ export type ModalSlotNames = readonly ["overlay", "container", "header", "title", "closeBtn", "content", "footer"];
5
+ export type ModalI18nKey = "title" | "okText" | "cancelText" | "closeAriaLabel" | "confirmTitle" | "successTitle" | "errorTitle" | "warningTitle" | (string & {});
5
6
 
6
7
  export type ModalLocaleText = Partial<{
7
8
  title: string;
8
9
  okText: string;
9
10
  cancelText: string;
10
11
  closeAriaLabel: string;
12
+ // added by clayw on 20260624: 静态方法默认标题
13
+ confirmTitle: string;
14
+ successTitle: string;
15
+ errorTitle: string;
16
+ warningTitle: string;
11
17
  }>;
12
18
 
13
19
  export type ModalFooterButton = {
@@ -30,8 +36,8 @@ export interface ModalProps
30
36
  open?: boolean;
31
37
  /** 关闭回调 */
32
38
  onClose?: () => void;
33
- /** 确定回调,若未传则默认调用 onClose */
34
- onOk?: () => void;
39
+ /** 确定回调,若未传则默认调用 onClose;支持返回 Promise,自动 loading */
40
+ onOk?: () => void | Promise<void>;
35
41
  /** 容器宽度 */
36
42
  width?: string | number;
37
43
  /** Style extension via CSSFab sx */
@@ -42,11 +48,60 @@ export interface ModalProps
42
48
  maskClosable?: boolean;
43
49
  /** 自定义底部按钮,传入后替代默认的取消/确定 */
44
50
  footerButtons?: ModalFooterButton[];
51
+ /**
52
+ * 底部区域控制:
53
+ * - `undefined`:使用 footerButtons 或默认取消/确定按钮
54
+ * - `null`:不渲染底部区域
55
+ * - `ReactNode`:自定义底部内容
56
+ * added by clayw on 20260624
57
+ */
58
+ footer?: ReactNode | null;
59
+ /**
60
+ * 关闭时是否卸载 children DOM,适用于需要重置内部状态的场景
61
+ * added by clayw on 20260624
62
+ */
63
+ destroyOnClose?: boolean;
45
64
  /** 覆盖 locale 文案 */
46
65
  localeText?: ModalLocaleText;
47
66
  }
48
67
 
49
- declare function Modal(props: ModalProps): JSX.Element;
68
+ /** 静态方法配置 */
69
+ export interface ModalStaticConfig {
70
+ title?: string;
71
+ content?: ReactNode;
72
+ okText?: string;
73
+ cancelText?: string;
74
+ onOk?: () => void | Promise<void>;
75
+ onCancel?: () => void;
76
+ width?: string | number;
77
+ sx?: SxValue;
78
+ style?: CSSProperties;
79
+ className?: string;
80
+ maskClosable?: boolean;
81
+ footerButtons?: ModalFooterButton[];
82
+ localeText?: ModalLocaleText;
83
+ }
84
+
85
+ /** 静态方法返回值 */
86
+ export interface ModalStaticResult {
87
+ close: () => void;
88
+ update: (config: Partial<ModalStaticConfig>) => void;
89
+ }
90
+
91
+ // added by clayw on 20260624: 静态方法类型声明
92
+ interface ModalStaticMethods {
93
+ confirm: (config: ModalStaticConfig) => ModalStaticResult;
94
+ success: (config: ModalStaticConfig) => ModalStaticResult;
95
+ error: (config: ModalStaticConfig) => ModalStaticResult;
96
+ warning: (config: ModalStaticConfig) => ModalStaticResult;
97
+ }
98
+
99
+ // Modal 组件类型 = 函数签名 + 静态方法
100
+ interface ModalComponent extends ModalStaticMethods {
101
+ (props: ModalProps): JSX.Element;
102
+ }
103
+
104
+ declare const Modal: ModalComponent;
50
105
 
51
106
  export { Modal };
52
107
  export default Modal;
@@ -1,18 +1,26 @@
1
1
  import type { CSSProperties, ReactNode } from "react";
2
2
  import type { SxValue } from "../CSSFab";
3
3
 
4
+ export type NoticeSlotNames = readonly ["root", "icon", "content"];
4
5
  export type NoticeType = "success" | "fail" | "caution";
5
6
  export type NoticeVariant = "default" | "md";
7
+ // added by clayw on 20260624: placement 四角位置类型(大小写均可)
8
+ export type NoticePlacement = "TL" | "TR" | "BL" | "BR" | "tl" | "tr" | "bl" | "br";
6
9
 
7
10
  export interface NoticeProps extends React.HTMLAttributes<HTMLDivElement> {
8
11
  /** 通知类型 */
9
12
  type?: NoticeType;
10
- /** 图标(default 模式显示,md 模式隐藏) */
13
+ /** 图标(default 模式和 placement 模式显示,md 模式隐藏) */
11
14
  icon?: ReactNode;
12
15
  /** 通知内容 */
13
16
  message?: ReactNode;
14
17
  /** 变体:default 顶部居中,md 左下角 */
15
18
  variant?: NoticeVariant;
19
+ /**
20
+ * 四角位置,优先级高于 variant
21
+ * added by clayw on 20260624
22
+ */
23
+ placement?: NoticePlacement;
16
24
  /** 自动关闭时间(ms),0 或不传则不自动关闭 */
17
25
  duration?: number;
18
26
  /** 关闭回调 */
@@ -23,6 +31,15 @@ export interface NoticeProps extends React.HTMLAttributes<HTMLDivElement> {
23
31
  className?: string;
24
32
  }
25
33
 
34
+ /** useNotice 调用的 options 参数 */
35
+ // added by clayw on 20260624
36
+ export interface NoticeCallOptions {
37
+ variant?: NoticeVariant;
38
+ duration?: number;
39
+ placement?: NoticePlacement;
40
+ key?: string;
41
+ }
42
+
26
43
  declare const Notice: React.ForwardRefExoticComponent<
27
44
  NoticeProps & React.RefAttributes<HTMLDivElement>
28
45
  >;
@@ -1,6 +1,7 @@
1
- import type { CSSProperties, HTMLAttributes } from "react";
1
+ import type { CSSProperties, HTMLAttributes, ReactNode } from "react";
2
2
  import type { SxValue } from "../CSSFab";
3
3
 
4
+ export type SearchSlotNames = readonly ["root", "input", "button", "prefix", "clearIcon"];
4
5
  export type SearchSize = "small" | "medium" | "large" | "huge";
5
6
 
6
7
  export type SearchI18nKey = "placeholder" | "btnText" | (string & {});
@@ -8,6 +9,9 @@ export type SearchI18nKey = "placeholder" | "btnText" | (string & {});
8
9
  export type SearchLocaleText = Partial<{
9
10
  placeholder: string;
10
11
  btnText: string;
12
+ // added by clayw on 20260624
13
+ clearAriaLabel: string;
14
+ countTemplate: string;
11
15
  }>;
12
16
 
13
17
  export interface SearchProps
@@ -20,6 +24,8 @@ export interface SearchProps
20
24
  className?: string;
21
25
  /** 搜索回调,参数为输入框当前值 */
22
26
  onSearch?: (value: string) => void;
27
+ /** 输入值变化回调,参数为当前输入值 */
28
+ onChange?: (value: string) => void;
23
29
  /** 受控值 */
24
30
  value?: string;
25
31
  /** 非受控默认值 */
@@ -34,6 +40,14 @@ export interface SearchProps
34
40
  path?: string;
35
41
  /** 覆盖 locale 文案 */
36
42
  localeText?: SearchLocaleText;
43
+ /** 前缀图标/文字,位于输入框内左侧 added by clayw on 20260624 */
44
+ prefix?: ReactNode;
45
+ /** 是否显示清除按钮,默认 true,值为空时隐藏图标 added by clayw on 20260624 */
46
+ allowClear?: boolean;
47
+ /** 是否显示字数统计,默认 false,支持 i18n added by clayw on 20260624 */
48
+ showCount?: boolean;
49
+ /** 最大字符数,默认 524288 added by clayw on 20260624 */
50
+ maxLength?: number;
37
51
  }
38
52
 
39
53
  declare function Search(props: SearchProps): JSX.Element;
@@ -5,6 +5,9 @@ import type {
5
5
  Ref,
6
6
  } from "react";
7
7
 
8
+ /** Space sx slot 名列表 */
9
+ export type SpaceSlotNames = readonly ["root"];
10
+
8
11
  /** Space 布局变体 */
9
12
  export type SpaceType =
10
13
  | "default"
@@ -1,3 +1,6 @@
1
+ /** Table sx slot 名列表 */
2
+ export type TableSlotNames = readonly ["root", "wrapper", "thead", "headerCell", "body", "row", "cell", "empty", "pagination", "loading", "footer"];
3
+
1
4
  import type { CSSProperties, ReactNode } from "react";
2
5
  import type { SxValue } from "../CSSFab";
3
6
 
@@ -8,6 +11,12 @@ export interface TableColumn<T = Record<string, unknown>> {
8
11
  key?: string | number;
9
12
  width?: string | number;
10
13
  hide?: boolean;
14
+ // added by clayw on 20260623
15
+ /** 是否开启数字排序,默认 false */
16
+ sortable?: boolean;
17
+ // added by clayw on 20260623
18
+ /** 是否固定列,最后一列 fixed=true 固定右侧,其余固定左侧,默认 false */
19
+ fixed?: boolean;
11
20
  render?: (value: unknown, row: T, rowIndex: number) => ReactNode;
12
21
  }
13
22
 
@@ -25,6 +34,21 @@ export interface TablePagination {
25
34
  showSizeChanger?: boolean;
26
35
  }
27
36
 
37
+ // added by clayw on 20260624
38
+ /** 行选择配置 */
39
+ export interface TableRowSelection<T = Record<string, unknown>> {
40
+ /** 选择类型,仅支持 checkbox */
41
+ type?: "checkbox";
42
+ /** 受控选中的行 key 列表 */
43
+ selectedRowKeys?: (string | number)[];
44
+ /** 选择变化回调 */
45
+ onChange?: (selectedRowKeys: (string | number)[], selectedRows: T[]) => void;
46
+ /** 是否固定选择列,默认 true(横向滚动时选择列始终可见);设为 false 取消固定 */
47
+ fixed?: boolean;
48
+ /** 选择列宽度,默认 50 */
49
+ width?: string | number;
50
+ }
51
+
28
52
  /** i18n 覆盖字段 */
29
53
  export interface TableLocaleText {
30
54
  empty?: string;
@@ -33,6 +57,13 @@ export interface TableLocaleText {
33
57
  page?: string;
34
58
  total?: string;
35
59
  perPage?: string;
60
+ // added by clayw on 20260624
61
+ /** 行选择 footer 计数模板,支持 {total} 和 {selected} 占位 */
62
+ selectedSummary?: string;
63
+ /** 全选复选框 aria-label */
64
+ selectAll?: string;
65
+ /** 行选择复选框 aria-label */
66
+ selectRow?: string;
36
67
  [key: string]: string | undefined;
37
68
  }
38
69
 
@@ -65,6 +96,15 @@ export interface TableProps {
65
96
  | CSSProperties;
66
97
  /** 自定义 hover 颜色(覆盖默认主题 hover) */
67
98
  hoverColor?: string;
99
+ // added by clayw on 20260624
100
+ /** 加载状态,默认自动模式:dataSource 为空时显示骨架屏;传 true 强制骨架屏;传 false 关闭骨架屏 */
101
+ loading?: boolean;
102
+ // added by clayw on 20260624
103
+ /** 行选择配置 */
104
+ rowSelection?: TableRowSelection;
105
+ // added by clayw on 20260624
106
+ /** 行事件,参考 AntD 写法:(record, rowIndex) => ({ onClick: event => {}, onDoubleClick: event => {} }) */
107
+ onRow?: (record: Record<string, unknown>, rowIndex: number) => React.HTMLAttributes<HTMLTableRowElement>;
68
108
  /** i18n key */
69
109
  i18nKey?: string;
70
110
  /** 覆盖内置文案 */
@@ -74,3 +114,4 @@ export interface TableProps {
74
114
  declare function Table(props: TableProps): JSX.Element;
75
115
 
76
116
  export default Table;
117
+
@@ -1,6 +1,7 @@
1
1
  import type { CSSProperties, ReactNode } from "react";
2
2
  import type { SxValue } from "../CSSFab";
3
3
 
4
+ export type TooltipSlotNames = readonly ["root", "tooltip"];
4
5
  export type TooltipPlacement = "top" | "bottom" | "left" | "right";
5
6
 
6
7
  export interface TooltipProps extends Omit<React.HTMLAttributes<HTMLDivElement>, "title"> {
@@ -18,6 +19,8 @@ export interface TooltipProps extends Omit<React.HTMLAttributes<HTMLDivElement>,
18
19
  onOpenChange?: (open: boolean) => void;
19
20
  /** 是否禁用提示 */
20
21
  disabled?: boolean;
22
+ /** z-index 层叠顺序,默认 50 */
23
+ zIndex?: number;
21
24
  /** 样式扩展 */
22
25
  sx?: SxValue;
23
26
  style?: CSSProperties;
@@ -1,4 +1,17 @@
1
- import type { CSSProperties, ReactNode } from "react";
1
+ import type { CSSProperties } from "react";
2
+
3
+ /** Upload sx slot 名列表 */
4
+ export type UploadSlotNames = readonly ["root", "button", "list", "item", "dragger", "preview"];
5
+
6
+ // added by clayw on 20260624: Upload i18n 文案类型
7
+ export interface UploadLocaleText {
8
+ /** 选择按钮文字 */
9
+ btnText?: string;
10
+ /** 拖拽区域提示文字 */
11
+ dragPlaceholder?: string;
12
+ /** 拖拽悬停时提示文字 */
13
+ dragActivePlaceholder?: string;
14
+ }
2
15
 
3
16
  export interface UploadProps {
4
17
  /** 样式扩展(字符串/对象/slot) */
@@ -23,7 +36,7 @@ export interface UploadProps {
23
36
  maxCount?: number;
24
37
  /** 单文件最大体积(MB) */
25
38
  maxSize?: number;
26
- /** 选择按钮文字 */
39
+ /** 选择按钮文字(覆盖 i18n 默认) */
27
40
  btnText?: string;
28
41
  /** 选择按钮样式 */
29
42
  btnStyle?: CSSProperties;
@@ -31,13 +44,29 @@ export interface UploadProps {
31
44
  showSize?: boolean;
32
45
  /** 是否禁用 */
33
46
  disabled?: boolean;
34
- /** 子元素 */
35
- children?: ReactNode;
47
+ // added by clayw on 20260624: 拖拽上传新增 props
48
+ /** 是否启用拖拽上传(启用后渲染拖拽区域代替按钮) */
49
+ draggable?: boolean;
50
+ /** 拖拽区域提示文字(覆盖 i18n 默认) */
51
+ dragPlaceholder?: string;
52
+ /** 拖拽文件悬停时提示文字(覆盖 i18n 默认) */
53
+ dragActivePlaceholder?: string;
54
+ // added by clayw on 20260624: i18n 文案覆盖
55
+ /** i18n 文案覆盖,优先级高于 prop 和 i18n Provider */
56
+ localeText?: UploadLocaleText;
57
+ // added by clayw on 20260624: 预览 + loading 新增 props
58
+ /** 是否显示图片缩略图预览(原生 img 实现,后续可用 Image 组件替换) */
59
+ preview?: boolean;
60
+ /** 是否显示上传中状态(按钮模式传 Button loading,拖拽模式显示 spinner overlay) */
61
+ loading?: boolean;
36
62
  }
37
63
 
38
64
  /** beforeUpload 返回此值时,文件不展示在列表中 */
39
65
  export const LIST_IGNORE: unique symbol;
40
66
 
67
+ // added by clayw on 20260624: Upload i18n key 类型
68
+ export type UploadI18nKey = "upload.btnText" | "upload.dragPlaceholder" | "upload.dragActivePlaceholder";
69
+
41
70
  declare const Upload: ((props: UploadProps) => JSX.Element) & {
42
71
  LIST_IGNORE: typeof LIST_IGNORE;
43
72
  };