@gm-pc/react 1.28.0-beta.9 → 1.28.1-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.28.0-beta.9",
3
+ "version": "1.28.1-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.28.0-beta.9",
27
+ "@gm-pc/locales": "^1.28.1-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": "7fc1c5f55a36184f94825f800a6759d925bcf1ab"
51
+ "gitHead": "21e6355e34d987a7243fbdb16d3d3c4981a59344"
52
52
  }
@@ -23,6 +23,7 @@ import { ConfigConsumer, ConfigProvider, ConfigProviderProps } from '../config_p
23
23
  import { Checkbox } from '../checkbox'
24
24
  import { Switch } from '../switch'
25
25
  interface MoreSelectBaseState {
26
+ canClear?: boolean
26
27
  searchValue: string
27
28
  loading: boolean
28
29
  /* keyboard 默认第一个位置 */
@@ -212,6 +213,12 @@ class MoreSelectBase<V extends string | number = string> extends Component<
212
213
  onSelect(willSelected)
213
214
  }
214
215
 
216
+ private _handleClearAll = (event: MouseEvent): void => {
217
+ event.stopPropagation()
218
+ const { onSelect = _.noop } = this.props
219
+ onSelect([])
220
+ }
221
+
215
222
  private _handlePopupKeyDown = (event: KeyboardEvent<HTMLDivElement>): void => {
216
223
  const { onKeyDown } = this.props
217
224
  let willActiveIndex = this.state.willActiveIndex as number
@@ -401,19 +408,75 @@ class MoreSelectBase<V extends string | number = string> extends Component<
401
408
  renderListItem,
402
409
  listHeight,
403
410
  } = this.props
411
+
412
+ const selectedValues = new Set(selected?.map((v) => v.value))
413
+
414
+ // 分离已勾选和未勾选的数据
415
+ const availableGroups: MoreSelectGroupDataItem<V>[] = []
416
+ // 已选中区域直接使用 selected 构建,不受筛选影响
417
+ const selectedGroups: MoreSelectGroupDataItem<V>[] = []
418
+
419
+ if (multiple) {
420
+ filterData.forEach((group) => {
421
+ const availableChildren = group.children.filter(
422
+ (item) => !selectedValues.has(item.value)
423
+ )
424
+
425
+ if (availableChildren.length > 0) {
426
+ availableGroups.push({
427
+ ...group,
428
+ children: availableChildren,
429
+ })
430
+ }
431
+ })
432
+
433
+ if (selected.length > 0) {
434
+ selectedGroups.push({
435
+ label: '',
436
+ children: selected,
437
+ })
438
+ }
439
+ }
440
+
404
441
  return (
405
- <ListBase
406
- selected={selected.map((v) => v.value)}
407
- data={filterData}
408
- multiple={multiple}
409
- isGroupList={isGroupList}
410
- className='gm-border-0'
411
- renderItem={renderListItem}
412
- onSelect={this._handleSelect}
413
- isScrollTo
414
- willActiveIndex={willActiveIndex!}
415
- style={{ height: listHeight }}
416
- />
442
+ <div style={{ height: listHeight, overflow: 'auto' }}>
443
+ {selected.length > 0 && multiple && (
444
+ <>
445
+ <div className='gm-more-select-section-title gm-padding-5 gm-text-desc gm-text-12'>
446
+ 已选中
447
+ </div>
448
+ <ListBase
449
+ selected={selected.map((v) => v.value)}
450
+ data={selectedGroups}
451
+ multiple={multiple}
452
+ isGroupList={false}
453
+ className='gm-border-0'
454
+ renderItem={renderListItem}
455
+ onSelect={this._handleSelect}
456
+ isScrollTo={false}
457
+ />
458
+ </>
459
+ )}
460
+ <>
461
+ {multiple && (
462
+ <div className='gm-more-select-section-title gm-padding-5 gm-text-desc gm-text-12'>
463
+ 未选中
464
+ </div>
465
+ )}
466
+
467
+ <ListBase
468
+ selected={selected?.map((v) => v.value)}
469
+ data={multiple ? availableGroups : filterData}
470
+ multiple={multiple}
471
+ isGroupList={isGroupList}
472
+ className='gm-border-0'
473
+ renderItem={renderListItem}
474
+ onSelect={this._handleSelect}
475
+ isScrollTo
476
+ willActiveIndex={willActiveIndex!}
477
+ />
478
+ </>
479
+ </div>
417
480
  )
418
481
  }
419
482
  }
@@ -581,6 +644,10 @@ class MoreSelectBase<V extends string | number = string> extends Component<
581
644
  )}
582
645
  </Flex>
583
646
  )}
647
+ <SVGRemove
648
+ className='gm-cursor gm-more-select-clear-btn'
649
+ onClick={disabled ? _.noop : this._handleClearAll}
650
+ />
584
651
  </>
585
652
  )
586
653
  }
@@ -8,7 +8,7 @@ class MoreSelect<V = any> extends Component<MoreSelectProps<V>> {
8
8
  renderSelected: (item: MoreSelectDataItem<any>) => item.text,
9
9
  renderListItem: (item: MoreSelectDataItem<any>) => item.text,
10
10
  delay: 500,
11
- listHeight: '180px',
11
+ listHeight: '280px',
12
12
  renderListFilterType: 'default',
13
13
  popoverType: 'focus',
14
14
  onKeyDown: _.noop,