Skip to content

Commit

Permalink
feat: 增加 table Keyboard 点击向下新增行功能的配置
Browse files Browse the repository at this point in the history
  • Loading branch information
Yiiu committed Aug 14, 2024
1 parent 4e6a2c0 commit 969554b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions packages/keyboard/src/core/wrap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const Wrap: FC<WrapProps> = ({
id,
children,
onAddRow,
allowAddRow,
allowAddRowOnDownKey,
columnKeys,
dataLength,
fixedWidths,
Expand Down Expand Up @@ -88,7 +88,7 @@ const Wrap: FC<WrapProps> = ({
}
// 最后一行
else if (rowKey === dataLength - 1) {
if (allowAddRow) {
if (allowAddRowOnDownKey) {
onAddRow()
}
timer.current = window.setTimeout(() => {
Expand Down
4 changes: 2 additions & 2 deletions packages/keyboard/src/hoc/keyboard_table_x.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function keyboardTableXHOC<Props extends TableXProps = TableXProps>(
id,
onAddRow,
onBeforeDispatch,
allowAddRow = true,
allowAddRowOnDownKey = false,
...tableProps
}) => {
const { data, columns } = tableProps
Expand Down Expand Up @@ -107,7 +107,7 @@ function keyboardTableXHOC<Props extends TableXProps = TableXProps>(
fixedWidths={{ leftFixedWidth, rightFixedWidth }}
dataLength={data.length}
onAddRow={onAddRow}
allowAddRow={allowAddRow}
allowAddRowOnDownKey={allowAddRowOnDownKey}
onBeforeDispatch={onBeforeDispatch}
>
<Table {...(tableProps as Props)} id={id} columns={newColumns} />
Expand Down
4 changes: 2 additions & 2 deletions packages/keyboard/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ interface KeyboardTableXProps {
id: string
columns: KeyboardTableXColumn[]
/** 按下键是否允许增加一行数据 */
allowAddRow?: boolean
allowAddRowOnDownKey?: boolean
/* 增加一行数据 */
onAddRow(): void
onBeforeDispatch?(options: {
Expand Down Expand Up @@ -58,7 +58,7 @@ interface WrapProps {
}): boolean

/** 按下键是否允许增加一行数据 */
allowAddRow?: boolean
allowAddRowOnDownKey?: boolean

/** Wrap 需要知道字段集合,以便能找到相应的单元格,请确保表格的顺序一致 */
columnKeys: string[]
Expand Down

0 comments on commit 969554b

Please sign in to comment.