@gm-pc/react 1.17.0-beta.8 → 1.18.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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gm-pc/react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.18.0-beta.0",
|
|
4
4
|
"description": "观麦前端基础组件库",
|
|
5
5
|
"author": "liyatang <liyatang@qq.com>",
|
|
6
6
|
"homepage": "https://github.com/gmfe/gm-pc#readme",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"dependencies": {
|
|
25
25
|
"@gm-common/hooks": "^2.10.0",
|
|
26
26
|
"@gm-common/tool": "^2.10.0",
|
|
27
|
-
"@gm-pc/locales": "^1.
|
|
27
|
+
"@gm-pc/locales": "^1.18.0-beta.0",
|
|
28
28
|
"big.js": "^6.0.1",
|
|
29
29
|
"classnames": "^2.2.5",
|
|
30
30
|
"lodash": "^4.17.19",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"react-router-dom": "^5.2.0",
|
|
49
49
|
"react-window": "^1.8.5"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "558b652c8c55d7d2955d85fb509fb6a7202a0b74"
|
|
52
52
|
}
|
|
@@ -99,11 +99,15 @@ const AutoComplete = forwardRef<AutoCompleteRef, AutoCompleteProps>((props, ref)
|
|
|
99
99
|
|
|
100
100
|
const handleKeyDown = (event: React.KeyboardEvent<HTMLInputElement>) => {
|
|
101
101
|
if (event.key === 'Enter') {
|
|
102
|
-
triggerPopover(false)
|
|
103
102
|
if (willActiveIndex >= 0) {
|
|
104
103
|
const val = options[willActiveIndex]?.value
|
|
105
104
|
if (!_.isNil(val) && value !== val) {
|
|
106
105
|
onChange && onChange(val)
|
|
106
|
+
triggerPopover(false)
|
|
107
|
+
return
|
|
108
|
+
}
|
|
109
|
+
if (popoverVisible.current) {
|
|
110
|
+
triggerPopover(false)
|
|
107
111
|
return
|
|
108
112
|
}
|
|
109
113
|
}
|
|
@@ -136,20 +140,16 @@ const AutoComplete = forwardRef<AutoCompleteRef, AutoCompleteProps>((props, ref)
|
|
|
136
140
|
}
|
|
137
141
|
|
|
138
142
|
const renderItem = useMemo(() => {
|
|
139
|
-
if (renderOption)
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
}
|
|
143
|
+
if (!renderOption) return
|
|
144
|
+
return (value: ListDataItem<string>, index: number) => {
|
|
145
|
+
return renderOption({ value: value.value }, index)
|
|
143
146
|
}
|
|
144
|
-
return undefined
|
|
145
147
|
}, [renderOption])
|
|
146
148
|
|
|
147
|
-
useImperativeHandle(ref, () => {
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
}
|
|
152
|
-
})
|
|
149
|
+
useImperativeHandle(ref, () => ({
|
|
150
|
+
input: inputNode.current,
|
|
151
|
+
triggerPopover,
|
|
152
|
+
}))
|
|
153
153
|
|
|
154
154
|
return (
|
|
155
155
|
<Popover
|
|
@@ -46,6 +46,8 @@ class MoreSelectBase<V extends string | number = string> extends Component<
|
|
|
46
46
|
private _baseRef = createRef<HTMLDivElement>()
|
|
47
47
|
private _selectionRef = createRef<HTMLDivElement>()
|
|
48
48
|
private _popoverRef = createRef<Popover>()
|
|
49
|
+
private _inputRef = createRef<HTMLInputElement>()
|
|
50
|
+
|
|
49
51
|
private _filterData: MoreSelectGroupDataItem<V>[] | undefined
|
|
50
52
|
|
|
51
53
|
constructor(props: MoreSelectBaseProps<V>) {
|
|
@@ -123,10 +125,20 @@ class MoreSelectBase<V extends string | number = string> extends Component<
|
|
|
123
125
|
}
|
|
124
126
|
}
|
|
125
127
|
|
|
126
|
-
public _handleChange = (
|
|
128
|
+
public _handleChange = (
|
|
129
|
+
event: ChangeEvent<HTMLInputElement>,
|
|
130
|
+
isInitSearch?: boolean
|
|
131
|
+
): void => {
|
|
127
132
|
const searchValue = event.target.value
|
|
128
133
|
this.setState({ searchValue })
|
|
129
134
|
this._debounceDoSearch(searchValue)
|
|
135
|
+
setTimeout(() => {
|
|
136
|
+
// eslint-disable-next-line no-unused-expressions
|
|
137
|
+
isInitSearch && this._inputRef.current?.select()
|
|
138
|
+
if (this.props.searchWhenActive) {
|
|
139
|
+
localStorage.setItem('_GM-PC_MORESELECT_SEARCHVALUE', this.state.searchValue)
|
|
140
|
+
}
|
|
141
|
+
}, 100)
|
|
130
142
|
}
|
|
131
143
|
|
|
132
144
|
private _doSearch = (query: string): void => {
|
|
@@ -239,6 +251,7 @@ class MoreSelectBase<V extends string | number = string> extends Component<
|
|
|
239
251
|
>
|
|
240
252
|
<div className='gm-more-select-popup-input'>
|
|
241
253
|
<Input
|
|
254
|
+
ref={this._inputRef}
|
|
242
255
|
autoFocus
|
|
243
256
|
value={searchValue}
|
|
244
257
|
onChange={this._handleChange}
|
|
@@ -276,6 +289,17 @@ class MoreSelectBase<V extends string | number = string> extends Component<
|
|
|
276
289
|
}
|
|
277
290
|
|
|
278
291
|
private _handleMoreSelectClick = () => {
|
|
292
|
+
if (this.props.searchWhenActive) {
|
|
293
|
+
const searchValue = localStorage.getItem('_GM-PC_MORESELECT_SEARCHVALUE')
|
|
294
|
+
if (searchValue) {
|
|
295
|
+
this.setState({ searchValue })
|
|
296
|
+
setTimeout(() => {
|
|
297
|
+
// eslint-disable-next-line no-unused-expressions
|
|
298
|
+
this._inputRef.current?.select()
|
|
299
|
+
this._debounceDoSearch(searchValue)
|
|
300
|
+
}, 0)
|
|
301
|
+
}
|
|
302
|
+
}
|
|
279
303
|
const { onClick, selected } = this.props
|
|
280
304
|
if (typeof onClick === 'function') {
|
|
281
305
|
return onClick(selected)
|
|
@@ -53,9 +53,12 @@ class MoreSelect<V = any> extends Component<MoreSelectProps<V>> {
|
|
|
53
53
|
|
|
54
54
|
public _handleInitSearch = (q?: string) => {
|
|
55
55
|
// eslint-disable-next-line no-unused-expressions
|
|
56
|
-
this._moreSelectBaseRef?.current?._handleChange(
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
this._moreSelectBaseRef?.current?._handleChange(
|
|
57
|
+
{
|
|
58
|
+
target: { value: q },
|
|
59
|
+
} as ChangeEvent<HTMLInputElement>,
|
|
60
|
+
true
|
|
61
|
+
)
|
|
59
62
|
}
|
|
60
63
|
|
|
61
64
|
_renderListFilter = (data: MoreSelectGroupDataItem<V>[], searchValue: string) => {
|
|
@@ -78,6 +78,8 @@ interface MoreSelectBaseProps<V extends string | number = string>
|
|
|
78
78
|
data: MoreSelectGroupDataItem<V>[],
|
|
79
79
|
searchValue: string
|
|
80
80
|
): MoreSelectGroupDataItem<V>[]
|
|
81
|
+
/** 是否在active的时候搜索,订单业务相关,searchValue放在localstorage */
|
|
82
|
+
searchWhenActive?: boolean
|
|
81
83
|
}
|
|
82
84
|
|
|
83
85
|
type MoreSelectData<V extends string | number = string> =
|
|
@@ -88,7 +90,8 @@ type MoreSelectSelected<V extends string | number = string> =
|
|
|
88
90
|
| MoreSelectDataItem<V>
|
|
89
91
|
|
|
90
92
|
interface MoreSelectProps<V extends string | number = string>
|
|
91
|
-
extends MoreSelectCommonProps<V
|
|
93
|
+
extends MoreSelectCommonProps<V>,
|
|
94
|
+
Pick<MoreSelectBaseProps, 'searchWhenActive'> {
|
|
92
95
|
data?: MoreSelectData<V>
|
|
93
96
|
selected?: MoreSelectSelected<V>
|
|
94
97
|
value?: V | V[]
|