@gm-pc/react 1.28.0-beta.12 → 1.28.0-beta.13

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.28.0-beta.12",
3
+ "version": "1.28.0-beta.13",
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.28.0-beta.12",
27
+ "@gm-pc/locales": "^1.28.0-beta.13",
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": "b6c0b797d887b71f3e15bafa84dda40ea1ef78f7"
51
+ "gitHead": "c8234f419681aca5321788b5e0cf39a36716e30d"
52
52
  }
@@ -402,36 +402,38 @@ class MoreSelectBase<V extends string | number = string> extends Component<
402
402
  listHeight,
403
403
  } = this.props
404
404
 
405
- const selectedValues = new Set(selected.map((v) => v.value))
405
+ const selectedValues = new Set(selected?.map((v) => v.value))
406
406
 
407
407
  // 分离已勾选和未勾选的数据
408
408
  const availableGroups: MoreSelectGroupDataItem<V>[] = []
409
+ // 已选中区域直接使用 selected 构建,不受筛选影响
410
+ const selectedGroups: MoreSelectGroupDataItem<V>[] = []
409
411
 
410
- filterData.forEach((group) => {
411
- const availableChildren = group.children.filter(
412
- (item) => !selectedValues.has(item.value)
413
- )
412
+ if (multiple) {
413
+ filterData.forEach((group) => {
414
+ const availableChildren = group.children.filter(
415
+ (item) => !selectedValues.has(item.value)
416
+ )
417
+
418
+ if (availableChildren.length > 0) {
419
+ availableGroups.push({
420
+ ...group,
421
+ children: availableChildren,
422
+ })
423
+ }
424
+ })
414
425
 
415
- if (availableChildren.length > 0) {
416
- availableGroups.push({
417
- ...group,
418
- children: availableChildren,
426
+ if (selected.length > 0) {
427
+ selectedGroups.push({
428
+ label: '',
429
+ children: selected,
419
430
  })
420
431
  }
421
- })
422
-
423
- // 已选中区域直接使用 selected 构建,不受筛选影响
424
- const selectedGroups: MoreSelectGroupDataItem<V>[] = []
425
- if (selected.length > 0) {
426
- selectedGroups.push({
427
- label: '',
428
- children: selected,
429
- })
430
432
  }
431
433
 
432
434
  return (
433
435
  <div style={{ height: listHeight, overflow: 'auto' }}>
434
- {selectedGroups.length > 0 && (
436
+ {selected.length > 0 && multiple && (
435
437
  <>
436
438
  <div className='gm-more-select-section-title gm-padding-5 gm-text-desc gm-text-12'>
437
439
  已选中
@@ -449,24 +451,25 @@ class MoreSelectBase<V extends string | number = string> extends Component<
449
451
  />
450
452
  </>
451
453
  )}
452
- {availableGroups.length > 0 && (
453
- <>
454
+ <>
455
+ {multiple && (
454
456
  <div className='gm-more-select-section-title gm-padding-5 gm-text-desc gm-text-12'>
455
457
  未选中
456
458
  </div>
457
- <ListBase
458
- selected={selected.map((v) => v.value)}
459
- data={availableGroups}
460
- multiple={multiple}
461
- isGroupList={isGroupList}
462
- className='gm-border-0'
463
- renderItem={renderListItem}
464
- onSelect={this._handleSelect}
465
- isScrollTo={false}
466
- willActiveIndex={willActiveIndex!}
467
- />
468
- </>
469
- )}
459
+ )}
460
+
461
+ <ListBase
462
+ selected={selected.map((v) => v.value)}
463
+ data={multiple ? availableGroups : filterData}
464
+ multiple={multiple}
465
+ isGroupList={isGroupList}
466
+ className='gm-border-0'
467
+ renderItem={renderListItem}
468
+ onSelect={this._handleSelect}
469
+ isScrollTo
470
+ willActiveIndex={willActiveIndex!}
471
+ />
472
+ </>
470
473
  </div>
471
474
  )
472
475
  }