@gm-pc/react 1.27.5-beta.0 → 1.27.5-beta.1
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.27.5-beta.
|
|
3
|
+
"version": "1.27.5-beta.1",
|
|
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.5-beta.
|
|
27
|
+
"@gm-pc/locales": "^1.27.5-beta.1",
|
|
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": "ba7a645cc22f0b5f7271160bf327909c1c057388"
|
|
52
52
|
}
|
|
@@ -22,11 +22,10 @@ import { findDOMNode } from 'react-dom'
|
|
|
22
22
|
import { ConfigConsumer, ConfigProvider, ConfigProviderProps } from '../config_provider'
|
|
23
23
|
|
|
24
24
|
interface MoreSelectBaseState {
|
|
25
|
-
searchValue: string
|
|
25
|
+
searchValue: string
|
|
26
26
|
loading: boolean
|
|
27
27
|
/* keyboard 默认第一个位置 */
|
|
28
28
|
willActiveIndex: number | null
|
|
29
|
-
isOpen: boolean
|
|
30
29
|
}
|
|
31
30
|
|
|
32
31
|
// @todo keydown item disabled
|
|
@@ -39,10 +38,9 @@ class MoreSelectBase<V extends string | number = string> extends Component<
|
|
|
39
38
|
static renderListFilterPinYin = renderListFilterPinYin
|
|
40
39
|
|
|
41
40
|
readonly state: MoreSelectBaseState = {
|
|
42
|
-
searchValue:
|
|
41
|
+
searchValue: '',
|
|
43
42
|
loading: false,
|
|
44
43
|
willActiveIndex: this.props.isKeyboard ? 0 : null,
|
|
45
|
-
isOpen: false,
|
|
46
44
|
}
|
|
47
45
|
|
|
48
46
|
private _isUnmounted = false
|
|
@@ -135,10 +133,6 @@ class MoreSelectBase<V extends string | number = string> extends Component<
|
|
|
135
133
|
const searchValue = event.target.value
|
|
136
134
|
this.setState({ searchValue })
|
|
137
135
|
this._debounceDoSearch(searchValue)
|
|
138
|
-
if (this.props.isSameAntd) {
|
|
139
|
-
// eslint-disable-next-line no-unused-expressions
|
|
140
|
-
this._popoverRef.current?.apiDoSetActive(true)
|
|
141
|
-
}
|
|
142
136
|
setTimeout(() => {
|
|
143
137
|
// eslint-disable-next-line no-unused-expressions
|
|
144
138
|
isInitSearch && this._inputRef.current?.select()
|
|
@@ -238,34 +232,18 @@ class MoreSelectBase<V extends string | number = string> extends Component<
|
|
|
238
232
|
)
|
|
239
233
|
}
|
|
240
234
|
|
|
241
|
-
private _renderSearchInput = () => {
|
|
242
|
-
const { searchPlaceholder } = this.props
|
|
243
|
-
const { searchValue } = this.state
|
|
244
|
-
return (
|
|
245
|
-
<div className='gm-more-select-popup-input'>
|
|
246
|
-
<Input
|
|
247
|
-
ref={this._inputRef}
|
|
248
|
-
autoFocus
|
|
249
|
-
value={searchValue}
|
|
250
|
-
onChange={this._handleChange}
|
|
251
|
-
placeholder={searchPlaceholder}
|
|
252
|
-
/>
|
|
253
|
-
</div>
|
|
254
|
-
)
|
|
255
|
-
}
|
|
256
|
-
|
|
257
235
|
private _renderList = (config: ConfigProviderProps): ReactNode => {
|
|
258
236
|
const {
|
|
259
237
|
selected = [],
|
|
260
238
|
multiple,
|
|
261
239
|
isGroupList,
|
|
262
240
|
renderListItem,
|
|
241
|
+
searchPlaceholder,
|
|
263
242
|
listHeight,
|
|
264
243
|
popupClassName,
|
|
265
244
|
renderCustomizedBottom,
|
|
266
|
-
isSameAntd = false,
|
|
267
245
|
} = this.props
|
|
268
|
-
const { loading, willActiveIndex } = this.state
|
|
246
|
+
const { loading, searchValue, willActiveIndex } = this.state
|
|
269
247
|
const filterData = this._getFilterData()
|
|
270
248
|
return (
|
|
271
249
|
<ConfigProvider {...config}>
|
|
@@ -273,7 +251,15 @@ class MoreSelectBase<V extends string | number = string> extends Component<
|
|
|
273
251
|
className={classNames('gm-more-select-popup', popupClassName)}
|
|
274
252
|
onKeyDown={this._handlePopupKeyDown}
|
|
275
253
|
>
|
|
276
|
-
|
|
254
|
+
<div className='gm-more-select-popup-input'>
|
|
255
|
+
<Input
|
|
256
|
+
ref={this._inputRef}
|
|
257
|
+
autoFocus
|
|
258
|
+
value={searchValue}
|
|
259
|
+
onChange={this._handleChange}
|
|
260
|
+
placeholder={searchPlaceholder}
|
|
261
|
+
/>
|
|
262
|
+
</div>
|
|
277
263
|
<div style={{ height: listHeight }}>
|
|
278
264
|
{loading && (
|
|
279
265
|
<Flex alignCenter justifyCenter className='gm-bg gm-padding-5'>
|
|
@@ -313,16 +299,7 @@ class MoreSelectBase<V extends string | number = string> extends Component<
|
|
|
313
299
|
}
|
|
314
300
|
|
|
315
301
|
private _handlePopoverVisibleChange = (active: boolean) => {
|
|
316
|
-
if (this.props.
|
|
317
|
-
this.setState({
|
|
318
|
-
isOpen: active,
|
|
319
|
-
})
|
|
320
|
-
if (!this.props.multiple && !active) {
|
|
321
|
-
this.setState({ searchValue: undefined })
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
if (active && this.props.searchOnActive && !this.props.isSameAntd) {
|
|
302
|
+
if (active && this.props.searchOnActive) {
|
|
326
303
|
const searchValue = localStorage.getItem('_GM-PC_MORESELECT_SEARCHVALUE')
|
|
327
304
|
if (searchValue) {
|
|
328
305
|
this.setState({ searchValue })
|
|
@@ -348,11 +325,7 @@ class MoreSelectBase<V extends string | number = string> extends Component<
|
|
|
348
325
|
style,
|
|
349
326
|
popoverType,
|
|
350
327
|
children,
|
|
351
|
-
searchPlaceholder,
|
|
352
|
-
isSameAntd = false,
|
|
353
328
|
} = this.props
|
|
354
|
-
const { searchValue } = this.state
|
|
355
|
-
|
|
356
329
|
return (
|
|
357
330
|
<ConfigConsumer>
|
|
358
331
|
{(config) => (
|
|
@@ -373,9 +346,7 @@ class MoreSelectBase<V extends string | number = string> extends Component<
|
|
|
373
346
|
ref={this._popoverRef}
|
|
374
347
|
type={popoverType}
|
|
375
348
|
popup={() => this._renderList(config)}
|
|
376
|
-
disabled={
|
|
377
|
-
disabled || (!isSameAntd ? false : this.state.searchValue === undefined)
|
|
378
|
-
}
|
|
349
|
+
disabled={disabled}
|
|
379
350
|
isInPopup={isInPopup}
|
|
380
351
|
onVisibleChange={this._handlePopoverVisibleChange}
|
|
381
352
|
>
|
|
@@ -384,17 +355,13 @@ class MoreSelectBase<V extends string | number = string> extends Component<
|
|
|
384
355
|
ref={this._selectionRef}
|
|
385
356
|
tabIndex={0}
|
|
386
357
|
wrap
|
|
387
|
-
className=
|
|
388
|
-
'gm-more-select-selected': true,
|
|
389
|
-
'gm-more-select-selected-antd': isSameAntd,
|
|
390
|
-
})}
|
|
358
|
+
className='gm-more-select-selected'
|
|
391
359
|
>
|
|
392
360
|
{selected.length !== 0 ? (
|
|
393
361
|
selected.map((item) => (
|
|
394
362
|
<Flex
|
|
395
363
|
key={item.value as any}
|
|
396
364
|
className='gm-more-select-selected-item'
|
|
397
|
-
alignCenter
|
|
398
365
|
>
|
|
399
366
|
<Popover
|
|
400
367
|
disabled={!this.props.isKeyboard}
|
|
@@ -402,23 +369,7 @@ class MoreSelectBase<V extends string | number = string> extends Component<
|
|
|
402
369
|
popup={<div className='gm-padding-10'>{item.text}</div>}
|
|
403
370
|
>
|
|
404
371
|
<Flex flex column>
|
|
405
|
-
{
|
|
406
|
-
<div className='gm-more-select-popup-input'>
|
|
407
|
-
<Input
|
|
408
|
-
ref={this._inputRef}
|
|
409
|
-
value={
|
|
410
|
-
!this.state.isOpen
|
|
411
|
-
? renderSelected!(item)
|
|
412
|
-
: searchValue
|
|
413
|
-
}
|
|
414
|
-
onChange={this._handleChange}
|
|
415
|
-
placeholder={searchPlaceholder}
|
|
416
|
-
className='gm-more-select-popup-input-no-border'
|
|
417
|
-
/>
|
|
418
|
-
</div>
|
|
419
|
-
) : (
|
|
420
|
-
renderSelected!(item)
|
|
421
|
-
)}
|
|
372
|
+
{renderSelected!(item)}
|
|
422
373
|
</Flex>
|
|
423
374
|
</Popover>
|
|
424
375
|
{multiple ? (
|
|
@@ -442,20 +393,7 @@ class MoreSelectBase<V extends string | number = string> extends Component<
|
|
|
442
393
|
))
|
|
443
394
|
) : (
|
|
444
395
|
// 加多个 避免对齐问题,有文本才有对齐
|
|
445
|
-
|
|
446
|
-
{isSameAntd ? (
|
|
447
|
-
<Input
|
|
448
|
-
ref={this._inputRef}
|
|
449
|
-
value={searchValue}
|
|
450
|
-
onChange={this._handleChange}
|
|
451
|
-
placeholder={searchPlaceholder}
|
|
452
|
-
className='gm-more-select-popup-input-no-border'
|
|
453
|
-
/>
|
|
454
|
-
) : (
|
|
455
|
-
<div className='gm-text-placeholder'>{placeholder} </div>
|
|
456
|
-
)}
|
|
457
|
-
</>
|
|
458
|
-
//
|
|
396
|
+
<div className='gm-text-placeholder'>{placeholder} </div>
|
|
459
397
|
)}
|
|
460
398
|
</Flex>
|
|
461
399
|
)}
|
|
@@ -14,15 +14,10 @@
|
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
.gm-more-select-selected-antd {
|
|
18
|
-
padding: 0 12px;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
17
|
.gm-more-select-clear-btn {
|
|
22
18
|
position: absolute;
|
|
23
|
-
right:
|
|
24
|
-
top:
|
|
25
|
-
transform: translateY(-50%);
|
|
19
|
+
right: 5px;
|
|
20
|
+
top: 7px;
|
|
26
21
|
cursor: pointer;
|
|
27
22
|
color: var(--gm-color-desc);
|
|
28
23
|
}
|
|
@@ -75,10 +70,3 @@
|
|
|
75
70
|
}
|
|
76
71
|
}
|
|
77
72
|
}
|
|
78
|
-
|
|
79
|
-
.gm-more-select-popup-input-no-border {
|
|
80
|
-
border: none !important;
|
|
81
|
-
border-radius: 0 !important;
|
|
82
|
-
padding: 0 !important;
|
|
83
|
-
box-shadow: none !important;
|
|
84
|
-
}
|
|
@@ -80,8 +80,6 @@ interface MoreSelectBaseProps<V extends string | number = string>
|
|
|
80
80
|
): MoreSelectGroupDataItem<V>[]
|
|
81
81
|
/** 是否在active的时候搜索,订单业务相关,searchValue放在localstorage */
|
|
82
82
|
searchOnActive?: boolean
|
|
83
|
-
/** 是否用select */
|
|
84
|
-
isSameAntd?: boolean
|
|
85
83
|
}
|
|
86
84
|
|
|
87
85
|
type MoreSelectData<V extends string | number = string> =
|
|
@@ -6,13 +6,17 @@ import _ from 'lodash'
|
|
|
6
6
|
import { getLocale } from '@gm-pc/locales'
|
|
7
7
|
|
|
8
8
|
function getLimitData(limit: number, pageSizeOptions?: string[]) {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
{ value:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
let limitData = []
|
|
10
|
+
if (pageSizeOptions) {
|
|
11
|
+
limitData = pageSizeOptions.map((v) => ({ value: Number(v), text: v }))
|
|
12
|
+
} else {
|
|
13
|
+
limitData = [
|
|
14
|
+
{ value: limit, text: limit + '' },
|
|
15
|
+
{ value: 10, text: '10' },
|
|
16
|
+
{ value: 20, text: '20' },
|
|
17
|
+
{ value: 50, text: '50' },
|
|
18
|
+
]
|
|
19
|
+
}
|
|
16
20
|
|
|
17
21
|
return _.orderBy(
|
|
18
22
|
_.uniqBy(limitData, (v) => v.value),
|