Skip to content

Commit b17720d

Browse files
committed
feat: add allow clear in select and add showSize changer support change size options
1 parent d46c701 commit b17720d

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

packages/tushan/client/components/fields/select.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ export interface SelectFieldOptionItem {
2222

2323
export interface SelectFieldOptions {
2424
items: SelectFieldOptionItem[];
25+
allowClear?: boolean;
2526
}
2627

2728
export const SelectFieldDetail: FieldDetailComponent<
@@ -49,10 +50,12 @@ export const SelectFieldEdit: FieldEditComponent<
4950
SelectFieldOptions
5051
> = React.memo((props) => {
5152
const items = props.options.items ?? [];
53+
const allowClear = props.options.allowClear ?? false;
5254

5355
return (
5456
<Select
5557
placeholder={props.options.edit?.placeholder ?? props.options.label}
58+
allowClear={allowClear}
5659
value={props.value}
5760
onChange={(val) => props.onChange(val)}
5861
>

packages/tushan/client/components/list/ListTable.tsx

+9-3
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,11 @@ export interface ListTableProps {
6666
defaultSort?: SortPayload;
6767
defaultFilter?: FilterPayload;
6868
showTotal?: boolean;
69-
showSizeChanger?: boolean;
69+
/**
70+
* If pass number array, you can change size options,
71+
* default is [10, 20, 50, 100]
72+
*/
73+
showSizeChanger?: boolean | number[];
7074
drawerWidth?: number;
7175
/**
7276
* Allow pass table props into table element
@@ -202,8 +206,10 @@ export const ListTable: React.FC<ListTableProps> = React.memo((props) => {
202206
current: pageNum,
203207
pageSize,
204208
showTotal: props.showTotal ?? true,
205-
sizeCanChange: props.showSizeChanger ?? false,
206-
sizeOptions: [10, 20, 50, 100],
209+
sizeCanChange: props.showSizeChanger ? true : false,
210+
sizeOptions: Array.isArray(props.showSizeChanger)
211+
? props.showSizeChanger
212+
: [10, 20, 50, 100],
207213
onChange: (pageNum, pageSize) => {
208214
setPageNum(pageNum);
209215
setPageSize(pageSize);

packages/tushan/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "tushan",
3-
"version": "0.3.10",
3+
"version": "0.3.11",
44
"description": "",
55
"main": "./index.ts",
66
"scripts": {

0 commit comments

Comments
 (0)