Skip to content

Commit

Permalink
feat: add allow clear in select and add showSize changer support chan…
Browse files Browse the repository at this point in the history
…ge size options
  • Loading branch information
moonrailgun committed Jan 24, 2025
1 parent d46c701 commit b17720d
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
3 changes: 3 additions & 0 deletions packages/tushan/client/components/fields/select.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export interface SelectFieldOptionItem {

export interface SelectFieldOptions {
items: SelectFieldOptionItem[];
allowClear?: boolean;
}

export const SelectFieldDetail: FieldDetailComponent<
Expand Down Expand Up @@ -49,10 +50,12 @@ export const SelectFieldEdit: FieldEditComponent<
SelectFieldOptions
> = React.memo((props) => {
const items = props.options.items ?? [];
const allowClear = props.options.allowClear ?? false;

return (
<Select
placeholder={props.options.edit?.placeholder ?? props.options.label}
allowClear={allowClear}
value={props.value}
onChange={(val) => props.onChange(val)}
>
Expand Down
12 changes: 9 additions & 3 deletions packages/tushan/client/components/list/ListTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,11 @@ export interface ListTableProps {
defaultSort?: SortPayload;
defaultFilter?: FilterPayload;
showTotal?: boolean;
showSizeChanger?: boolean;
/**
* If pass number array, you can change size options,
* default is [10, 20, 50, 100]
*/
showSizeChanger?: boolean | number[];
drawerWidth?: number;
/**
* Allow pass table props into table element
Expand Down Expand Up @@ -202,8 +206,10 @@ export const ListTable: React.FC<ListTableProps> = React.memo((props) => {
current: pageNum,
pageSize,
showTotal: props.showTotal ?? true,
sizeCanChange: props.showSizeChanger ?? false,
sizeOptions: [10, 20, 50, 100],
sizeCanChange: props.showSizeChanger ? true : false,
sizeOptions: Array.isArray(props.showSizeChanger)
? props.showSizeChanger
: [10, 20, 50, 100],
onChange: (pageNum, pageSize) => {
setPageNum(pageNum);
setPageSize(pageSize);
Expand Down
2 changes: 1 addition & 1 deletion packages/tushan/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tushan",
"version": "0.3.10",
"version": "0.3.11",
"description": "",
"main": "./index.ts",
"scripts": {
Expand Down

0 comments on commit b17720d

Please sign in to comment.