@para-ui/core 5.0.0-beta.4 → 5.0.0-beta.6
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 +31 -0
- package/es/CheckboxGroup/index.d.ts +6 -6
- package/es/CheckboxGroup/index.js +21 -21
- package/es/FormItem/compoments/formSelect/index.d.ts +2 -2
- package/es/FormItem/compoments/formSelect/index.js +13 -13
- package/es/Pagination/index.js +11 -10
- package/es/RadioGroup/index.d.ts +6 -7
- package/es/RadioGroup/index.js +2 -2
- package/es/Select/index.d.ts +39 -16
- package/es/Select/index.js +324 -317
- package/es/ToggleButton/ToggleButtonGroup.d.ts +8 -8
- package/es/ToggleButton/ToggleButtonGroup.js +27 -27
- package/es/ToggleButton/index.d.ts +5 -6
- package/es/ToggleButton/index.js +13 -13
- package/es/Utils/type.d.ts +3 -1
- package/lib/Argv/batchEdit/index.js +1 -1
- package/lib/CheckboxGroup/index.d.ts +6 -6
- package/lib/CheckboxGroup/index.js +1 -1
- package/lib/CodeEditor/index.js +1 -1
- package/lib/FormItem/compoments/formSelect/index.d.ts +2 -2
- package/lib/FormItem/compoments/formSelect/index.js +1 -1
- package/lib/InputCode/index.js +1 -1
- package/lib/Pagination/index.js +1 -1
- package/lib/RadioGroup/index.d.ts +6 -7
- package/lib/RadioGroup/index.js +1 -1
- package/lib/Select/index.d.ts +39 -16
- package/lib/Select/index.js +1 -1
- package/lib/ToggleButton/ToggleButtonGroup.d.ts +8 -8
- package/lib/ToggleButton/ToggleButtonGroup.js +1 -1
- package/lib/ToggleButton/index.d.ts +5 -6
- package/lib/ToggleButton/index.js +1 -1
- package/lib/Utils/type.d.ts +3 -1
- package/lib/node_modules/@para-snack/core/dist/index.js +1 -1
- package/lib/node_modules/classnames/index.js +1 -1
- package/package.json +1 -1
- /package/lib/{CodeEditor → InputCode}/index.css +0 -0
package/README.md
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
|
+
## 🎉 para-ui/core@5.0.0-beta.6 发布
|
|
2
|
+
|
|
3
|
+
🎁【Feature】
|
|
4
|
+
|
|
5
|
+
- 【下拉框-Select】泛型按 `multiple` 判别:`SelectProps` 拆分为 `SelectSingleProps | SelectMultipleProps`,单选 `value` / `onChange` 推导为 `T`,多选推导为 `T[]`,使用方无需再处理 `T | T[]` 联合
|
|
6
|
+
|
|
7
|
+
⚠️【Breaking Change】
|
|
8
|
+
|
|
9
|
+
- 【下拉框-Select】单选清空时 `onChange` 入参由 `''` 调整为 `undefined`。原有 `if (val === '')` 写法需改为 `if (val === undefined)`;受控模式下旧代码传 `value=""` 仍能被识别为清空(向后兼容保留)
|
|
10
|
+
|
|
11
|
+
🔧【Bugfix】
|
|
12
|
+
|
|
13
|
+
- 【下拉框-Select】修复受控模式下 `value` 被置为 `undefined` 时 UI 未同步清空的问题
|
|
14
|
+
|
|
15
|
+
## 🎉 para-ui/core@5.0.0-beta.5 发布
|
|
16
|
+
|
|
17
|
+
🎁【Feature】
|
|
18
|
+
|
|
19
|
+
- 【单选框组-RadioGroup】支持泛型,`value`/`onChange` 可指定精确类型,替代原 `unknown`
|
|
20
|
+
- 【切换按钮-ToggleButton / ToggleButtonGroup】支持泛型,值类型由调用方指定
|
|
21
|
+
- 【复选框组-CheckboxGroup】支持泛型,`value` 可窄化到 `'a' | 'b'` 等枚举
|
|
22
|
+
- 【下拉框-Select】支持泛型,`value`/`onChange` 可窄化;`SelectProps` 严格化(移除索引签名,禁止未声明字段透传);新增共享类型 `SelectOptionValue`
|
|
23
|
+
|
|
24
|
+
🔧【Bugfix】
|
|
25
|
+
|
|
26
|
+
- 【下拉框-Select】修复 `fetchSuggestions` 未走全局 `componentsProps.Select` 默认值合并
|
|
27
|
+
- 【下拉框-Select】`handleInitValue` 内 `multiple` 判断与其它位置保持一致
|
|
28
|
+
- 【下拉框-Select】`closest` 内部辅助函数去除 `any`,复用 `VendorPrefixedElement` 类型
|
|
29
|
+
- 【动态多值框-FormSelect】过滤自定义 `change` 回调,不再泄漏到 Select DOM
|
|
30
|
+
- 【切换按钮组-ToggleButtonGroup】`icon` 字段不再透传给 Button 造成无效属性
|
|
31
|
+
|
|
1
32
|
## 🎉 para-ui/core@5.0.0-beta.4 发布
|
|
2
33
|
|
|
3
34
|
🔧【Bugfix】
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { default as React,
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
2
|
import { CheckboxProps } from '../Checkbox';
|
|
3
3
|
import { LabelTooltipProps } from '../Label';
|
|
4
4
|
import { HelperTextDetailProps } from '../HelperText';
|
|
@@ -6,7 +6,7 @@ export interface CheckboxListProps extends CheckboxProps {
|
|
|
6
6
|
/** 唯一标识值 */
|
|
7
7
|
name?: string | number;
|
|
8
8
|
}
|
|
9
|
-
export interface CheckboxGroupProps extends HelperTextDetailProps {
|
|
9
|
+
export interface CheckboxGroupProps<T extends string | number = string | number> extends HelperTextDetailProps {
|
|
10
10
|
/** 样式class */
|
|
11
11
|
className?: string;
|
|
12
12
|
/** style */
|
|
@@ -28,15 +28,15 @@ export interface CheckboxGroupProps extends HelperTextDetailProps {
|
|
|
28
28
|
/** 是否禁用 */
|
|
29
29
|
disabled?: boolean;
|
|
30
30
|
/** 默认值 不受控 */
|
|
31
|
-
defaultValue?:
|
|
31
|
+
defaultValue?: T[];
|
|
32
32
|
/** 值 */
|
|
33
|
-
value?:
|
|
33
|
+
value?: T[];
|
|
34
34
|
/** 选中选值 */
|
|
35
35
|
id?: string;
|
|
36
36
|
/** 选项数据 */
|
|
37
37
|
list: CheckboxListProps[] | CheckboxListProps[][];
|
|
38
38
|
/** 改变值 */
|
|
39
|
-
onChange?: (val:
|
|
39
|
+
onChange?: (val: T[]) => void;
|
|
40
40
|
}
|
|
41
|
-
export declare
|
|
41
|
+
export declare function CheckboxGroup<T extends string | number = string | number>(props: CheckboxGroupProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
42
42
|
export default CheckboxGroup;
|
|
@@ -6,7 +6,7 @@ import R from "../HelperText/index.js";
|
|
|
6
6
|
import { DeepClone as S } from "@paraview/lib";
|
|
7
7
|
import { $prefixCls as t } from "../GlobalContext/constant.js";
|
|
8
8
|
import './index.css';/* empty css */
|
|
9
|
-
|
|
9
|
+
function K(l) {
|
|
10
10
|
const {
|
|
11
11
|
label: h = "",
|
|
12
12
|
labelTooltip: n,
|
|
@@ -30,9 +30,9 @@ const M = (l) => {
|
|
|
30
30
|
}, []), C(() => {
|
|
31
31
|
l.value !== void 0 && f(l.value);
|
|
32
32
|
}, [l.value]);
|
|
33
|
-
const N = (e) => (
|
|
33
|
+
const N = (e) => (a, s) => {
|
|
34
34
|
const o = e[m], r = S(d);
|
|
35
|
-
if (
|
|
35
|
+
if (s)
|
|
36
36
|
r.push(o);
|
|
37
37
|
else {
|
|
38
38
|
const B = r.indexOf(o);
|
|
@@ -42,8 +42,8 @@ const M = (l) => {
|
|
|
42
42
|
}, V = () => {
|
|
43
43
|
if (h || g) {
|
|
44
44
|
const e = () => {
|
|
45
|
-
let
|
|
46
|
-
return n && n.className && (
|
|
45
|
+
let a = "checkbox-group-label";
|
|
46
|
+
return n && n.className && (a += ` ${n.className}`), a;
|
|
47
47
|
};
|
|
48
48
|
return /* @__PURE__ */ c.jsx(
|
|
49
49
|
I,
|
|
@@ -55,12 +55,12 @@ const M = (l) => {
|
|
|
55
55
|
}
|
|
56
56
|
);
|
|
57
57
|
}
|
|
58
|
-
}, $ = (e,
|
|
58
|
+
}, $ = (e, a, s) => {
|
|
59
59
|
const o = {
|
|
60
60
|
display: "inline-block",
|
|
61
61
|
...e.style
|
|
62
62
|
};
|
|
63
|
-
return b && p &&
|
|
63
|
+
return b && p && s.length !== a + 1 && (o.marginRight = b), x && (o.width = x), o;
|
|
64
64
|
}, A = () => {
|
|
65
65
|
let e = `${t}-checkbox-group`;
|
|
66
66
|
return y && (e += ` ${y}`), i && (e += ` ${t}-checkbox-group-${i}`), k && (e += ` ${t}-checkbox-group-error`), u && (e += ` ${t}-checkbox-group-disabled`), p ? e += ` ${t}-checkbox-group-row` : e += ` ${t}-checkbox-group-column`, e;
|
|
@@ -72,7 +72,7 @@ const M = (l) => {
|
|
|
72
72
|
style: T,
|
|
73
73
|
children: [
|
|
74
74
|
V(),
|
|
75
|
-
/* @__PURE__ */ c.jsx("div", { className: "checkbox-group-content", children: v.map((e,
|
|
75
|
+
/* @__PURE__ */ c.jsx("div", { className: "checkbox-group-content", children: v.map((e, a) => {
|
|
76
76
|
if (Array.isArray(e))
|
|
77
77
|
return /* @__PURE__ */ c.jsx(
|
|
78
78
|
"div",
|
|
@@ -91,7 +91,7 @@ const M = (l) => {
|
|
|
91
91
|
checked: d.indexOf(o[m]) !== -1,
|
|
92
92
|
size: i,
|
|
93
93
|
disabled: !!(u || o.disabled),
|
|
94
|
-
key:
|
|
94
|
+
key: a,
|
|
95
95
|
onChange: N(o)
|
|
96
96
|
}
|
|
97
97
|
)
|
|
@@ -99,28 +99,28 @@ const M = (l) => {
|
|
|
99
99
|
r
|
|
100
100
|
))
|
|
101
101
|
},
|
|
102
|
-
|
|
102
|
+
a
|
|
103
103
|
);
|
|
104
|
-
const
|
|
104
|
+
const s = e;
|
|
105
105
|
return /* @__PURE__ */ c.jsx(
|
|
106
106
|
"span",
|
|
107
107
|
{
|
|
108
108
|
className: "checkbox-item-box",
|
|
109
|
-
style: $(
|
|
109
|
+
style: $(s, a, v),
|
|
110
110
|
children: /* @__PURE__ */ E(
|
|
111
111
|
w,
|
|
112
112
|
{
|
|
113
|
-
...
|
|
113
|
+
...s,
|
|
114
114
|
style: {},
|
|
115
|
-
checked: d.indexOf(
|
|
115
|
+
checked: d.indexOf(s[m]) !== -1,
|
|
116
116
|
size: i,
|
|
117
|
-
disabled: !!(u ||
|
|
118
|
-
key:
|
|
119
|
-
onChange: N(
|
|
117
|
+
disabled: !!(u || s.disabled),
|
|
118
|
+
key: a,
|
|
119
|
+
onChange: N(s)
|
|
120
120
|
}
|
|
121
121
|
)
|
|
122
122
|
},
|
|
123
|
-
|
|
123
|
+
a
|
|
124
124
|
);
|
|
125
125
|
}) }),
|
|
126
126
|
/* @__PURE__ */ c.jsx(
|
|
@@ -135,9 +135,9 @@ const M = (l) => {
|
|
|
135
135
|
]
|
|
136
136
|
}
|
|
137
137
|
);
|
|
138
|
-
}
|
|
138
|
+
}
|
|
139
139
|
export {
|
|
140
|
-
|
|
141
|
-
|
|
140
|
+
K as CheckboxGroup,
|
|
141
|
+
K as default
|
|
142
142
|
};
|
|
143
143
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FC } from 'react';
|
|
2
2
|
import { SelectProps } from '../../../Select';
|
|
3
|
-
export
|
|
3
|
+
export type FormSelectProps = Omit<SelectProps, 'value' | 'defaultValue' | 'onChange'> & {
|
|
4
4
|
/**
|
|
5
5
|
* 默认值
|
|
6
6
|
*/
|
|
@@ -13,6 +13,6 @@ export interface FormSelectProps extends SelectProps {
|
|
|
13
13
|
* 绑定值
|
|
14
14
|
*/
|
|
15
15
|
value?: string;
|
|
16
|
-
}
|
|
16
|
+
};
|
|
17
17
|
declare const FormSelect: FC<FormSelectProps>;
|
|
18
18
|
export default FormSelect;
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
import { j as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
const h = (
|
|
5
|
-
const { defaultValue: s = "", change:
|
|
6
|
-
a
|
|
1
|
+
import { j as m } from "../../../_virtual/jsx-runtime.js";
|
|
2
|
+
import l from "react";
|
|
3
|
+
import f from "../../../Select/index.js";
|
|
4
|
+
const h = (r) => {
|
|
5
|
+
const { defaultValue: s = "", change: t, value: e, ...u } = r, [c, o] = l.useState(e !== void 0 ? e : s), n = (a) => {
|
|
6
|
+
o(a), t && t(a);
|
|
7
7
|
};
|
|
8
|
-
return
|
|
9
|
-
|
|
10
|
-
}, [e]), /* @__PURE__ */
|
|
11
|
-
|
|
8
|
+
return l.useEffect(() => {
|
|
9
|
+
o(e);
|
|
10
|
+
}, [e]), /* @__PURE__ */ m.jsx(
|
|
11
|
+
f,
|
|
12
12
|
{
|
|
13
13
|
labelMode: "inside",
|
|
14
|
-
onChange:
|
|
14
|
+
onChange: n,
|
|
15
15
|
hideErrorDom: null,
|
|
16
|
-
...
|
|
17
|
-
value:
|
|
16
|
+
...u,
|
|
17
|
+
value: c
|
|
18
18
|
}
|
|
19
19
|
);
|
|
20
20
|
};
|
package/es/Pagination/index.js
CHANGED
|
@@ -2,8 +2,8 @@ import { j as r } from "../_virtual/jsx-runtime.js";
|
|
|
2
2
|
import de, { useState as g, useRef as q, useEffect as u, useMemo as w } from "react";
|
|
3
3
|
import xe from "../GlobalContext/index.js";
|
|
4
4
|
import { $prefixCls as z, $rcPrefixCls as he } from "../GlobalContext/constant.js";
|
|
5
|
-
import { TextField as
|
|
6
|
-
import
|
|
5
|
+
import { TextField as ve } from "../TextField/index.js";
|
|
6
|
+
import Pe from "../GlobalContext/useFormatMessage.js";
|
|
7
7
|
import je from "./lang/index.js";
|
|
8
8
|
import be from "../Select/index.js";
|
|
9
9
|
import { Button as G } from "../Button/index.js";
|
|
@@ -31,7 +31,7 @@ const Oe = (y) => {
|
|
|
31
31
|
changeRowsPerPage: F,
|
|
32
32
|
getPopupContainer: O,
|
|
33
33
|
resizeLine: W
|
|
34
|
-
} = y, p =
|
|
34
|
+
} = y, p = Pe("Pagination", je), { language: k, locale: f } = de.useContext(xe), [c, V] = g(L), [K, X] = g([]), [n, R] = g(S), [i, Y] = g(), [d, E] = g(), [o, U] = g(null), x = q(null), a = q({
|
|
35
35
|
layoutArr: ["jumper", "pageRow", "pager-btn", "sizes", "pager-num"]
|
|
36
36
|
});
|
|
37
37
|
a.current.type = l, a.current.autoType = M, u(() => () => {
|
|
@@ -87,7 +87,7 @@ const Oe = (y) => {
|
|
|
87
87
|
U(t), t > 3 ? _(t) : x.current.classList.remove(`${z}-pagination-over`);
|
|
88
88
|
} else
|
|
89
89
|
x.current.classList.remove(`${z}-pagination-over`);
|
|
90
|
-
},
|
|
90
|
+
}, v = (e) => a.current.type instanceof Array && a.current.type.indexOf(e) === -1, P = (e) => {
|
|
91
91
|
if (o === null) return !1;
|
|
92
92
|
switch (e) {
|
|
93
93
|
case "jumper":
|
|
@@ -128,6 +128,7 @@ const Oe = (y) => {
|
|
|
128
128
|
}
|
|
129
129
|
s !== void 0 && R(s), N && N(s);
|
|
130
130
|
}, ee = (e) => {
|
|
131
|
+
if (e === void 0) return;
|
|
131
132
|
const t = Number(e);
|
|
132
133
|
e !== c && (V(t), F && F(t));
|
|
133
134
|
}, te = (e) => {
|
|
@@ -143,11 +144,11 @@ const Oe = (y) => {
|
|
|
143
144
|
const t = /(?=(\B)(\d{3})+$)/g;
|
|
144
145
|
return e.toString().replace(t, ",");
|
|
145
146
|
}, oe = w(() => {
|
|
146
|
-
if (l === "simple" ||
|
|
147
|
+
if (l === "simple" || v("sizes") || P("sizes"))
|
|
147
148
|
return null;
|
|
148
149
|
const e = ae(m);
|
|
149
150
|
return /* @__PURE__ */ r.jsx("div", { className: "total-num pagination-space", children: p({ id: "total" }, { total: e }) });
|
|
150
|
-
}, [m, k, f, o]), ie = w(() =>
|
|
151
|
+
}, [m, k, f, o]), ie = w(() => v("pageRow") || P("pageRow") ? null : /* @__PURE__ */ r.jsx("div", { className: "page-line-memo pagination-space", children: /* @__PURE__ */ r.jsx(
|
|
151
152
|
be,
|
|
152
153
|
{
|
|
153
154
|
className: "page-line-select",
|
|
@@ -165,7 +166,7 @@ const Oe = (y) => {
|
|
|
165
166
|
] }), le = () => /* @__PURE__ */ r.jsxs("div", { className: "jump-next-icon", children: [
|
|
166
167
|
/* @__PURE__ */ r.jsx("span", { children: "..." }),
|
|
167
168
|
/* @__PURE__ */ r.jsx(Ce, {})
|
|
168
|
-
] }), ce = () => C !== "num" || l === "simple" ? !0 : l === "complex" ?
|
|
169
|
+
] }), ce = () => C !== "num" || l === "simple" ? !0 : l === "complex" ? P("pager-num") : v("pager"), ue = w(() => ce() ? null : /* @__PURE__ */ r.jsxs("div", { className: "pagination-content pagination-space", children: [
|
|
169
170
|
I.indexOf("prev") !== -1 && /* @__PURE__ */ r.jsx("div", { className: "left-page", children: /* @__PURE__ */ r.jsx(
|
|
170
171
|
"div",
|
|
171
172
|
{
|
|
@@ -195,7 +196,7 @@ const Oe = (y) => {
|
|
|
195
196
|
children: /* @__PURE__ */ r.jsx(H, {})
|
|
196
197
|
}
|
|
197
198
|
) })
|
|
198
|
-
] }), [m, n, i, c, y.flippingArrow, C, o]), me = () => C === "btn" || l === "simple" ? !1 : l === "complex" ?
|
|
199
|
+
] }), [m, n, i, c, y.flippingArrow, C, o]), me = () => C === "btn" || l === "simple" ? !1 : l === "complex" ? P("pager-btn") : v("pager"), pe = w(() => me() ? null : /* @__PURE__ */ r.jsxs("div", { className: "pagination-btn-content pagination-space", children: [
|
|
199
200
|
/* @__PURE__ */ r.jsx(
|
|
200
201
|
G,
|
|
201
202
|
{
|
|
@@ -218,10 +219,10 @@ const Oe = (y) => {
|
|
|
218
219
|
children: p({ id: "nextPage" })
|
|
219
220
|
}
|
|
220
221
|
)
|
|
221
|
-
] }), [n, i, C, f, o]), ge = w(() =>
|
|
222
|
+
] }), [n, i, C, f, o]), ge = w(() => v("jumper") || P("jumper") ? null : /* @__PURE__ */ r.jsxs("div", { className: "skip-page-memo pagination-space", children: [
|
|
222
223
|
/* @__PURE__ */ r.jsx("span", { children: p({ id: "jumpTo" }) }),
|
|
223
224
|
/* @__PURE__ */ r.jsx(
|
|
224
|
-
|
|
225
|
+
ve,
|
|
225
226
|
{
|
|
226
227
|
className: "skip-page-text-field",
|
|
227
228
|
size: "large",
|
package/es/RadioGroup/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { default as React,
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
2
|
import { RadioProps } from '../Radio';
|
|
3
3
|
import { LabelTooltipProps } from '../Label';
|
|
4
4
|
import { HelperTextDetailProps } from '../HelperText';
|
|
5
5
|
export interface RadioListProps extends RadioProps {
|
|
6
6
|
[name: string]: unknown;
|
|
7
7
|
}
|
|
8
|
-
export interface RadioGroupProps extends HelperTextDetailProps {
|
|
8
|
+
export interface RadioGroupProps<T = unknown> extends HelperTextDetailProps {
|
|
9
9
|
/** 样式class */
|
|
10
10
|
className?: string;
|
|
11
11
|
/** style */
|
|
@@ -27,16 +27,15 @@ export interface RadioGroupProps extends HelperTextDetailProps {
|
|
|
27
27
|
/** 是否禁用 */
|
|
28
28
|
disabled?: boolean;
|
|
29
29
|
/** 默认值 不受控 */
|
|
30
|
-
defaultValue?:
|
|
30
|
+
defaultValue?: T;
|
|
31
31
|
/** 默认值 */
|
|
32
|
-
value?:
|
|
32
|
+
value?: T;
|
|
33
33
|
/** 选中选值 */
|
|
34
34
|
id?: string;
|
|
35
35
|
/** 选项数据 */
|
|
36
36
|
list: RadioListProps[] | RadioListProps[][];
|
|
37
37
|
/** 改变值 */
|
|
38
|
-
onChange?: (val:
|
|
39
|
-
[name: string]: unknown;
|
|
38
|
+
onChange?: (val: T, item?: RadioListProps) => void;
|
|
40
39
|
}
|
|
41
|
-
export declare
|
|
40
|
+
export declare function RadioGroup<T = unknown>(props: RadioGroupProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
42
41
|
export default RadioGroup;
|
package/es/RadioGroup/index.js
CHANGED
|
@@ -5,7 +5,7 @@ import A from "../Label/index.js";
|
|
|
5
5
|
import B from "../HelperText/index.js";
|
|
6
6
|
import { $prefixCls as l } from "../GlobalContext/constant.js";
|
|
7
7
|
import './index.css';/* empty css */
|
|
8
|
-
|
|
8
|
+
function F(i) {
|
|
9
9
|
const {
|
|
10
10
|
className: m = "",
|
|
11
11
|
style: w,
|
|
@@ -122,7 +122,7 @@ const F = (i) => {
|
|
|
122
122
|
]
|
|
123
123
|
}
|
|
124
124
|
);
|
|
125
|
-
}
|
|
125
|
+
}
|
|
126
126
|
export {
|
|
127
127
|
F as RadioGroup,
|
|
128
128
|
F as default
|
package/es/Select/index.d.ts
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import { default as React,
|
|
1
|
+
import { default as React, ReactNode } from 'react';
|
|
2
2
|
import { EmptyProps } from '../Empty';
|
|
3
3
|
import { LabelTooltipProps } from '../Label';
|
|
4
4
|
import { TooltipProps } from '../Tooltip';
|
|
5
5
|
import { HelperTextDetailProps } from '../HelperText';
|
|
6
|
-
import { SelectOptionBase } from '../Utils/type';
|
|
6
|
+
import { SelectOptionBase, SelectOptionValue } from '../Utils/type';
|
|
7
7
|
/** Select 下拉选项类型 */
|
|
8
8
|
export interface SelectOption extends SelectOptionBase {
|
|
9
9
|
/** 子选项数组 */
|
|
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
14
|
/** 样式class */
|
|
14
15
|
className?: string;
|
|
15
16
|
/** style */
|
|
@@ -35,13 +36,11 @@ export interface SelectProps extends HelperTextDetailProps {
|
|
|
35
36
|
/** 搜索提示语 */
|
|
36
37
|
searchPlaceholder?: string;
|
|
37
38
|
/** 是否禁用,传入数组时表示禁用的选项值列表 */
|
|
38
|
-
disabled?: boolean |
|
|
39
|
+
disabled?: boolean | T[];
|
|
39
40
|
/**
|
|
40
41
|
* 禁用提示
|
|
41
42
|
*/
|
|
42
43
|
disabledTooltip?: TooltipProps;
|
|
43
|
-
/** 是否多选 */
|
|
44
|
-
multiple?: boolean;
|
|
45
44
|
/** 是否必填 */
|
|
46
45
|
required?: boolean;
|
|
47
46
|
/** 下拉选项数组 */
|
|
@@ -60,10 +59,6 @@ export interface SelectProps extends HelperTextDetailProps {
|
|
|
60
59
|
showValue?: string;
|
|
61
60
|
/** 下级字段 */
|
|
62
61
|
childrenName?: string;
|
|
63
|
-
/** 默认值,多选时为数组,单选时为单值 */
|
|
64
|
-
defaultValue?: string | number | boolean | Array<string | number | boolean>;
|
|
65
|
-
/** 选中值,多选时为数组,单选时为单值(受控) */
|
|
66
|
-
value?: string | number | boolean | Array<string | number | boolean>;
|
|
67
62
|
/** 超出换行 */
|
|
68
63
|
overLine?: boolean;
|
|
69
64
|
/** 是否有搜索 */
|
|
@@ -80,10 +75,6 @@ export interface SelectProps extends HelperTextDetailProps {
|
|
|
80
75
|
morePopoverClassName?: string;
|
|
81
76
|
/** 返回输入建议的方法 */
|
|
82
77
|
fetchSuggestions?: (val: string, cb: (data: SelectOption[]) => void) => void;
|
|
83
|
-
/** 改变值回调 */
|
|
84
|
-
onChange?: (val: string | number | boolean | Array<string | number | boolean>, e: React.SyntheticEvent) => void;
|
|
85
|
-
/** 全局回车事件 */
|
|
86
|
-
onEnter?: (val: string | number | boolean | Array<string | number | boolean>) => void;
|
|
87
78
|
/** 搜索框输入框回车事件 */
|
|
88
79
|
onEnterInput?: (val: string) => void;
|
|
89
80
|
/** 点击清空内容回调 */
|
|
@@ -92,7 +83,39 @@ export interface SelectProps extends HelperTextDetailProps {
|
|
|
92
83
|
getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
|
|
93
84
|
/** 失去焦点改变值 */
|
|
94
85
|
blurChangeValueBol?: boolean;
|
|
95
|
-
[name: string]: unknown;
|
|
96
86
|
}
|
|
97
|
-
|
|
87
|
+
/** 单选模式 */
|
|
88
|
+
export interface SelectSingleProps<T extends SelectOptionValue = SelectOptionValue> extends SelectBaseProps<T> {
|
|
89
|
+
/** 是否多选(未传或 false 为单选) */
|
|
90
|
+
multiple?: false;
|
|
91
|
+
/** 默认值(单选) */
|
|
92
|
+
defaultValue?: T;
|
|
93
|
+
/** 选中值(单选受控) */
|
|
94
|
+
value?: T;
|
|
95
|
+
/** 改变值回调;清空时 val 为空字符串 */
|
|
96
|
+
/** 改变值回调;清空时 val 为 undefined */
|
|
97
|
+
onChange?: (val: T | undefined, e: React.SyntheticEvent) => void;
|
|
98
|
+
/** 全局回车事件(单选) */
|
|
99
|
+
onEnter?: (val: T) => void;
|
|
100
|
+
}
|
|
101
|
+
/** 多选模式 */
|
|
102
|
+
export interface SelectMultipleProps<T extends SelectOptionValue = SelectOptionValue> extends SelectBaseProps<T> {
|
|
103
|
+
/** 是否多选 */
|
|
104
|
+
multiple: true;
|
|
105
|
+
/** 默认值(多选) */
|
|
106
|
+
defaultValue?: T[];
|
|
107
|
+
/** 选中值(多选受控) */
|
|
108
|
+
value?: T[];
|
|
109
|
+
/** 改变值回调(多选) */
|
|
110
|
+
onChange?: (val: T[], e: React.SyntheticEvent) => void;
|
|
111
|
+
/** 全局回车事件(多选) */
|
|
112
|
+
onEnter?: (val: T[]) => void;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Select 的 props
|
|
116
|
+
* - `multiple` 未传或为 `false`:value / defaultValue 为 `T`,onChange/onEnter 入参为 `T`(清空时 `undefined`)
|
|
117
|
+
* - `multiple` 为 `true`:value / defaultValue 为 `T[]`,onChange/onEnter 入参为 `T[]`(清空时 `[]`)
|
|
118
|
+
*/
|
|
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;
|
|
98
121
|
export default Select;
|