@gm-pc/keyboard 1.16.0 → 1.17.0-beta.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 +4 -4
- package/src/cell/more_select.tsx +18 -4
- package/src/types.ts +6 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gm-pc/keyboard",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0-beta.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.
|
|
31
|
-
"@gm-pc/table-x": "^1.
|
|
30
|
+
"@gm-pc/react": "^1.17.0-beta.0",
|
|
31
|
+
"@gm-pc/table-x": "^1.17.0-beta.0",
|
|
32
32
|
"classnames": "^2.2.5",
|
|
33
33
|
"lodash": "^4.17.19"
|
|
34
34
|
},
|
|
35
|
-
"gitHead": "
|
|
35
|
+
"gitHead": "4ded82c728d9153ce0f837ad39777ac461a57d1f"
|
|
36
36
|
}
|
package/src/cell/more_select.tsx
CHANGED
|
@@ -1,16 +1,25 @@
|
|
|
1
|
-
import React, { useRef, KeyboardEvent } from 'react'
|
|
1
|
+
import React, { useRef, KeyboardEvent, forwardRef, useImperativeHandle } from 'react'
|
|
2
2
|
import { MoreSelect, MoreSelectProps } from '@gm-pc/react'
|
|
3
3
|
import { findDOMNode } from 'react-dom'
|
|
4
4
|
|
|
5
5
|
import KeyboardCell from '../core/cell'
|
|
6
6
|
import { isInputUnBoundary, scrollIntoViewFixedWidth, useContextData } from '../utils'
|
|
7
|
-
import { KeyboardWrapData } from '../types'
|
|
7
|
+
import { KeyboardWrapData, MoreSelectRef } from '../types'
|
|
8
8
|
|
|
9
|
-
function KCMoreSelect<V>(
|
|
9
|
+
function KCMoreSelect<V>(
|
|
10
|
+
{ disabled, onKeyDown, ...rest }: MoreSelectProps<V>,
|
|
11
|
+
ref: React.ForwardedRef<MoreSelectRef>
|
|
12
|
+
) {
|
|
10
13
|
const cellRef = useRef<KeyboardCell>(null)
|
|
11
14
|
const targetRef = useRef<MoreSelect>(null)
|
|
12
15
|
const { wrapData, cellKey } = useContextData()
|
|
13
16
|
|
|
17
|
+
useImperativeHandle(ref, () => {
|
|
18
|
+
return {
|
|
19
|
+
handleInitSearch,
|
|
20
|
+
}
|
|
21
|
+
})
|
|
22
|
+
|
|
14
23
|
const handleFocus = () => {
|
|
15
24
|
// eslint-disable-next-line
|
|
16
25
|
targetRef.current?.apiDoFocus()
|
|
@@ -45,6 +54,11 @@ function KCMoreSelect<V>({ disabled, onKeyDown, ...rest }: MoreSelectProps<V>) {
|
|
|
45
54
|
}
|
|
46
55
|
}
|
|
47
56
|
|
|
57
|
+
const handleInitSearch = (q?: string) => {
|
|
58
|
+
// eslint-disable-next-line no-unused-expressions
|
|
59
|
+
targetRef.current?._handleInitSearch(q)
|
|
60
|
+
}
|
|
61
|
+
|
|
48
62
|
return (
|
|
49
63
|
<KeyboardCell
|
|
50
64
|
ref={cellRef}
|
|
@@ -66,4 +80,4 @@ function KCMoreSelect<V>({ disabled, onKeyDown, ...rest }: MoreSelectProps<V>) {
|
|
|
66
80
|
)
|
|
67
81
|
}
|
|
68
82
|
|
|
69
|
-
export default KCMoreSelect
|
|
83
|
+
export default forwardRef(KCMoreSelect)
|
package/src/types.ts
CHANGED
|
@@ -65,6 +65,11 @@ interface WrapProps {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
+
type MoreSelectRef = {
|
|
69
|
+
/** 默认搜索 */
|
|
70
|
+
handleInitSearch: (q?: string) => void
|
|
71
|
+
}
|
|
72
|
+
|
|
68
73
|
export type {
|
|
69
74
|
KeyboardCellProps,
|
|
70
75
|
WrapProps,
|
|
@@ -73,4 +78,5 @@ export type {
|
|
|
73
78
|
KeyboardCustomEvent,
|
|
74
79
|
KeyboardDirection,
|
|
75
80
|
KeyboardWrapData,
|
|
81
|
+
MoreSelectRef,
|
|
76
82
|
}
|