From 7d91c203669d276751167b45167d7f40a992bdee Mon Sep 17 00:00:00 2001 From: Qnets <43038692+hzh11012@users.noreply.github.com> Date: Thu, 5 Dec 2024 14:11:44 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20input-table=E3=80=81colunmn-toggler?= =?UTF-8?q?=E7=BB=84=E4=BB=B6=E5=A2=9E=E5=8A=A0=E6=B3=9B=E5=9E=8B=20(#1131?= =?UTF-8?q?8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/amis/src/renderers/Form/InputTable.tsx | 6 ++++-- packages/amis/src/renderers/Table/ColumnToggler.tsx | 9 ++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/amis/src/renderers/Form/InputTable.tsx b/packages/amis/src/renderers/Form/InputTable.tsx index 7671aea6e46..6987a889578 100644 --- a/packages/amis/src/renderers/Form/InputTable.tsx +++ b/packages/amis/src/renderers/Form/InputTable.tsx @@ -305,7 +305,9 @@ export type FormTableRendererEvent = export type FormTableRendererAction = 'add' | 'delete' | 'reset' | 'clear'; -export default class FormTable extends React.Component { +export default class FormTable< + T extends TableProps = TableProps +> extends React.Component { static defaultProps = { placeholder: 'placeholder.empty', scaffold: {}, @@ -358,7 +360,7 @@ export default class FormTable extends React.Component { leading: false }); - constructor(props: TableProps) { + constructor(props: T) { super(props); const {addHook} = props; const items = Array.isArray(props.value) ? props.value.concat() : []; diff --git a/packages/amis/src/renderers/Table/ColumnToggler.tsx b/packages/amis/src/renderers/Table/ColumnToggler.tsx index d63776f6af1..a036657fcc5 100644 --- a/packages/amis/src/renderers/Table/ColumnToggler.tsx +++ b/packages/amis/src/renderers/Table/ColumnToggler.tsx @@ -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 { state: ColumnTogglerState = { isOpened: false, enableSorting: false, @@ -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);