@para-ui/core 5.0.0-beta.10 → 5.0.0-beta.11

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.
@@ -10,7 +10,7 @@ export interface SelectOption extends SelectOptionBase {
10
10
  children?: SelectOption[];
11
11
  }
12
12
  /** Select 共享 props —— 不含随 multiple 变化的 value/defaultValue/onChange/onEnter/multiple */
13
- export interface SelectBaseProps<T extends SelectOptionValue = SelectOptionValue> extends HelperTextDetailProps {
13
+ export interface SelectBaseProps<T extends SelectOptionValue = SelectOptionValue, Item extends SelectOptionBase = SelectOptionBase> extends HelperTextDetailProps {
14
14
  /** 样式class */
15
15
  className?: string;
16
16
  /** style */
@@ -44,13 +44,13 @@ export interface SelectBaseProps<T extends SelectOptionValue = SelectOptionValue
44
44
  /** 是否必填 */
45
45
  required?: boolean;
46
46
  /** 下拉选项数组 */
47
- list: SelectOption[];
47
+ list: Item[];
48
48
  /**
49
49
  * 自定义渲染
50
50
  * item: 当前想数据
51
51
  * type: true 下拉选项 false 已选项 more: 更多选项
52
52
  * */
53
- renderContent?: (item: SelectOption, type: boolean | 'more') => ReactNode;
53
+ renderContent?: (item: Item, type: boolean | 'more') => ReactNode;
54
54
  /** 下拉选中是否有图标, 默认有 */
55
55
  selectCheckIcon?: boolean;
56
56
  /** 显示名字段 */
@@ -74,7 +74,7 @@ export interface SelectBaseProps<T extends SelectOptionValue = SelectOptionValue
74
74
  /** 更多className */
75
75
  morePopoverClassName?: string;
76
76
  /** 返回输入建议的方法 */
77
- fetchSuggestions?: (val: string, cb: (data: SelectOption[]) => void) => void;
77
+ fetchSuggestions?: (val: string, cb: (data: Item[]) => void) => void;
78
78
  /** 搜索框输入框回车事件 */
79
79
  onEnterInput?: (val: string) => void;
80
80
  /** 点击清空内容回调 */
@@ -85,7 +85,7 @@ export interface SelectBaseProps<T extends SelectOptionValue = SelectOptionValue
85
85
  blurChangeValueBol?: boolean;
86
86
  }
87
87
  /** 单选模式 */
88
- export interface SelectSingleProps<T extends SelectOptionValue = SelectOptionValue> extends SelectBaseProps<T> {
88
+ export interface SelectSingleProps<T extends SelectOptionValue = SelectOptionValue, Item extends SelectOptionBase = SelectOptionBase> extends SelectBaseProps<T, Item> {
89
89
  /** 是否多选(未传或 false 为单选) */
90
90
  multiple?: false;
91
91
  /** 默认值(单选) */
@@ -99,7 +99,7 @@ export interface SelectSingleProps<T extends SelectOptionValue = SelectOptionVal
99
99
  onEnter?: (val: T) => void;
100
100
  }
101
101
  /** 多选模式 */
102
- export interface SelectMultipleProps<T extends SelectOptionValue = SelectOptionValue> extends SelectBaseProps<T> {
102
+ export interface SelectMultipleProps<T extends SelectOptionValue = SelectOptionValue, Item extends SelectOptionBase = SelectOptionBase> extends SelectBaseProps<T, Item> {
103
103
  /** 是否多选 */
104
104
  multiple: true;
105
105
  /** 默认值(多选) */
@@ -115,7 +115,10 @@ export interface SelectMultipleProps<T extends SelectOptionValue = SelectOptionV
115
115
  * Select 的 props
116
116
  * - `multiple` 未传或为 `false`:value / defaultValue 为 `T`,onChange/onEnter 入参为 `T`(清空时 `undefined`)
117
117
  * - `multiple` 为 `true`:value / defaultValue 为 `T[]`,onChange/onEnter 入参为 `T[]`(清空时 `[]`)
118
+ * - 第二个泛型参数 `Item` 描述 `list` 行项的具体类型,默认 `SelectOptionBase`,
119
+ * 可传业务侧 DTO 接口(如 `{ label, value, id, time }`)以承载 `renderContent` /
120
+ * `fetchSuggestions` 的端到端类型推导。
118
121
  */
119
- export type SelectProps<T extends SelectOptionValue = SelectOptionValue> = SelectSingleProps<T> | SelectMultipleProps<T>;
120
- declare function Select<T extends SelectOptionValue = SelectOptionValue>(outerProps: SelectProps<T>): import("react/jsx-runtime").JSX.Element;
122
+ export type SelectProps<T extends SelectOptionValue = SelectOptionValue, Item extends SelectOptionBase = SelectOptionBase> = SelectSingleProps<T, Item> | SelectMultipleProps<T, Item>;
123
+ declare function Select<T extends SelectOptionValue = SelectOptionValue, Item extends SelectOptionBase = SelectOptionBase>(outerProps: SelectProps<T, Item>): import("react/jsx-runtime").JSX.Element;
121
124
  export default Select;