@gm-pc/keyboard 1.24.0-beta.4 → 1.24.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gm-pc/keyboard",
3
- "version": "1.24.0-beta.4",
3
+ "version": "1.24.0-beta.7",
4
4
  "description": "",
5
5
  "author": "liyatang <liyatang@qq.com>",
6
6
  "homepage": "https://github.com/gmfe/gm-pc#readme",
@@ -27,10 +27,10 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@gm-common/tool": "^2.10.0",
30
- "@gm-pc/react": "^1.24.0-beta.4",
31
- "@gm-pc/table-x": "^1.24.0-beta.4",
30
+ "@gm-pc/react": "^1.24.0-beta.7",
31
+ "@gm-pc/table-x": "^1.24.0-beta.7",
32
32
  "classnames": "^2.2.5",
33
33
  "lodash": "^4.17.19"
34
34
  },
35
- "gitHead": "16d604e61e7c49eb1ae7bb47fbb7a01097c849f7"
35
+ "gitHead": "898eed0942e41d2d13de02dfcac0986d493285b5"
36
36
  }
package/src/core/wrap.tsx CHANGED
@@ -23,6 +23,7 @@ const Wrap: FC<WrapProps> = ({
23
23
  id,
24
24
  children,
25
25
  onAddRow,
26
+ allowAddRow,
26
27
  columnKeys,
27
28
  dataLength,
28
29
  fixedWidths,
@@ -87,7 +88,9 @@ const Wrap: FC<WrapProps> = ({
87
88
  }
88
89
  // 最后一行
89
90
  else if (rowKey === dataLength - 1) {
90
- onAddRow()
91
+ if (allowAddRow) {
92
+ onAddRow()
93
+ }
91
94
  timer.current = window.setTimeout(() => {
92
95
  // 去到第一列
93
96
  doFocusWithColumnRowKey(
@@ -21,6 +21,7 @@ function keyboardTableXHOC<Props extends TableXProps = TableXProps>(
21
21
  id,
22
22
  onAddRow,
23
23
  onBeforeDispatch,
24
+ allowAddRow = true,
24
25
  ...tableProps
25
26
  }) => {
26
27
  const { data, columns } = tableProps
@@ -106,6 +107,7 @@ function keyboardTableXHOC<Props extends TableXProps = TableXProps>(
106
107
  fixedWidths={{ leftFixedWidth, rightFixedWidth }}
107
108
  dataLength={data.length}
108
109
  onAddRow={onAddRow}
110
+ allowAddRow={allowAddRow}
109
111
  onBeforeDispatch={onBeforeDispatch}
110
112
  >
111
113
  <Table {...(tableProps as Props)} id={id} columns={newColumns} />
package/src/types.ts CHANGED
@@ -8,6 +8,8 @@ interface KeyboardTableXProps {
8
8
  /* 通过 id 来确定本单元格内通信,避免多表格时混了。请确保 id 唯一 */
9
9
  id: string
10
10
  columns: KeyboardTableXColumn[]
11
+ /** 按下键是否允许增加一行数据 */
12
+ allowAddRow?: boolean
11
13
  /* 增加一行数据 */
12
14
  onAddRow(): void
13
15
  onBeforeDispatch?(options: {
@@ -55,6 +57,9 @@ interface WrapProps {
55
57
  from: { rowKey: number; columnKey: string }
56
58
  }): boolean
57
59
 
60
+ /** 按下键是否允许增加一行数据 */
61
+ allowAddRow?: boolean
62
+
58
63
  /** Wrap 需要知道字段集合,以便能找到相应的单元格,请确保表格的顺序一致 */
59
64
  columnKeys: string[]
60
65
  /** Wrap 需要知道有多少行,以便能找到相应的单元格,同时必要时会触发 onAddRow,告知调用方需要增加一行数据 */