Skip to content

Commit

Permalink
feat: input-table、colunmn-toggler组件增加泛型 (#11318)
Browse files Browse the repository at this point in the history
  • Loading branch information
hzh11012 authored Dec 5, 2024
1 parent 680eba9 commit 7d91c20
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
6 changes: 4 additions & 2 deletions packages/amis/src/renderers/Form/InputTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,9 @@ export type FormTableRendererEvent =

export type FormTableRendererAction = 'add' | 'delete' | 'reset' | 'clear';

export default class FormTable extends React.Component<TableProps, TableState> {
export default class FormTable<
T extends TableProps = TableProps
> extends React.Component<T, TableState> {
static defaultProps = {
placeholder: 'placeholder.empty',
scaffold: {},
Expand Down Expand Up @@ -358,7 +360,7 @@ export default class FormTable extends React.Component<TableProps, TableState> {
leading: false
});

constructor(props: TableProps) {
constructor(props: T) {
super(props);
const {addHook} = props;
const items = Array.isArray(props.value) ? props.value.concat() : [];
Expand Down
9 changes: 4 additions & 5 deletions packages/amis/src/renderers/Table/ColumnToggler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,9 @@ export interface ColumnTogglerState {
tempColumns: any[];
}

export default class ColumnToggler extends React.Component<
ColumnTogglerProps,
ColumnTogglerState
> {
export default class ColumnToggler<
T extends ColumnTogglerProps = ColumnTogglerProps
> extends React.Component<T, ColumnTogglerState> {
state: ColumnTogglerState = {
isOpened: false,
enableSorting: false,
Expand All @@ -156,7 +155,7 @@ export default class ColumnToggler extends React.Component<
sortable?: Sortable;
dragRefDOM: HTMLElement;

constructor(props: ColumnTogglerProps) {
constructor(props: T) {
super(props);

this.open = this.open.bind(this);
Expand Down

0 comments on commit 7d91c20

Please sign in to comment.