@gm-pc/keyboard 1.8.8 → 1.9.0

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.8.8",
3
+ "version": "1.9.0",
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.8.8",
31
- "@gm-pc/table-x": "^1.8.8",
30
+ "@gm-pc/react": "^1.9.0",
31
+ "@gm-pc/table-x": "^1.9.0",
32
32
  "classnames": "^2.2.5",
33
33
  "lodash": "^4.17.19"
34
34
  },
35
- "gitHead": "5f590a574045fa5259a021b3aff181a4ab0a5d0f"
35
+ "gitHead": "5afa0f0207f38211482ae8a65e515e57741265de"
36
36
  }
@@ -1,4 +1,11 @@
1
- import React, { FC, useRef, FocusEvent, KeyboardEvent } from 'react'
1
+ import React, {
2
+ useRef,
3
+ FocusEvent,
4
+ KeyboardEvent,
5
+ useImperativeHandle,
6
+ forwardRef,
7
+ ForwardRefRenderFunction,
8
+ } from 'react'
2
9
  import { InputNumber, InputNumberProps } from '@gm-pc/react'
3
10
  import { findDOMNode } from 'react-dom'
4
11
 
@@ -6,12 +13,14 @@ import KeyboardCell from '../core/cell'
6
13
  import { isInputUnBoundary, scrollIntoViewFixedWidth, useContextData } from '../utils'
7
14
  import { KeyboardWrapData } from '../types'
8
15
 
9
- const KCInputNumber: FC<InputNumberProps> = ({
10
- disabled,
11
- onKeyDown,
12
- onFocus,
13
- ...rest
14
- }) => {
16
+ interface RefFunctionProps {
17
+ focus(): void
18
+ }
19
+
20
+ const KCInputNumber: ForwardRefRenderFunction<RefFunctionProps, InputNumberProps> = (
21
+ { disabled, onKeyDown, onFocus, ...rest },
22
+ ref
23
+ ) => {
15
24
  const cellRef = useRef<KeyboardCell>(null)
16
25
  const targetRef = useRef<InputNumber>(null)
17
26
  const { cellKey, wrapData } = useContextData()
@@ -56,6 +65,9 @@ const KCInputNumber: FC<InputNumberProps> = ({
56
65
  cellRef.current?.apiDoEnter()
57
66
  }
58
67
  }
68
+ useImperativeHandle(ref, () => ({
69
+ focus: handleFocus,
70
+ }))
59
71
 
60
72
  return (
61
73
  <KeyboardCell
@@ -77,4 +89,4 @@ const KCInputNumber: FC<InputNumberProps> = ({
77
89
  )
78
90
  }
79
91
 
80
- export default KCInputNumber
92
+ export default forwardRef(KCInputNumber)