@@ -12,11 +12,13 @@ import { useState, useRef, useEffect, useMemo } from 'react';
12
12
import KeyCode from 'rc-util/lib/KeyCode' ;
13
13
import classNames from 'classnames' ;
14
14
import useMergedState from 'rc-util/lib/hooks/useMergedState' ;
15
- import { ScrollTo } from 'rc-virtual-list/lib/List' ;
16
- import Selector , { RefSelectorProps } from './Selector' ;
17
- import SelectTrigger , { RefTriggerProps } from './SelectTrigger' ;
18
- import { RenderNode , Mode , RenderDOMFunc , OnActiveValue } from './interface' ;
19
- import {
15
+ import type { ScrollTo } from 'rc-virtual-list/lib/List' ;
16
+ import type { RefSelectorProps } from './Selector' ;
17
+ import Selector from './Selector' ;
18
+ import type { RefTriggerProps } from './SelectTrigger' ;
19
+ import SelectTrigger from './SelectTrigger' ;
20
+ import type { RenderNode , Mode , RenderDOMFunc , OnActiveValue } from './interface' ;
21
+ import type {
20
22
GetLabeledValue ,
21
23
FilterOptions ,
22
24
FilterFunc ,
@@ -29,11 +31,12 @@ import {
29
31
FlattenOptionsType ,
30
32
SingleType ,
31
33
OnClear ,
32
- INTERNAL_PROPS_MARK ,
33
34
SelectSource ,
34
- CustomTagProps ,
35
+ CustomTagProps } from './interface/generator' ;
36
+ import {
37
+ INTERNAL_PROPS_MARK
35
38
} from './interface/generator' ;
36
- import { OptionListProps , RefOptionListProps } from './OptionList' ;
39
+ import type { OptionListProps , RefOptionListProps } from './OptionList' ;
37
40
import { toInnerValue , toOuterValues , removeLastEnabledValue , getUUID } from './utils/commonUtil' ;
38
41
import TransBtn from './TransBtn' ;
39
42
import useLock from './hooks/useLock' ;
@@ -59,7 +62,7 @@ const DEFAULT_OMIT_PROPS = [
59
62
export interface RefSelectProps {
60
63
focus : ( ) => void ;
61
64
blur : ( ) => void ;
62
- scrollTo ?: ScrollTo ,
65
+ scrollTo ?: ScrollTo ;
63
66
}
64
67
65
68
export interface SelectProps < OptionsType extends object [ ] , ValueType > extends React . AriaAttributes {
@@ -194,7 +197,7 @@ export interface GenerateConfig<OptionsType extends object[]> {
194
197
getLabeledValue : GetLabeledValue < FlattenOptionsType < OptionsType > > ;
195
198
filterOptions : FilterOptions < OptionsType > ;
196
199
findValueOption : // Need still support legacy ts api
197
- | ( ( values : RawValueType [ ] , options : FlattenOptionsType < OptionsType > ) => OptionsType )
200
+ | ( ( values : RawValueType [ ] , options : FlattenOptionsType < OptionsType > ) => OptionsType )
198
201
// New API add prevValueOptions support
199
202
| ( (
200
203
values : RawValueType [ ] ,
@@ -327,7 +330,7 @@ export default function generateSelector<
327
330
const useInternalProps = internalProps . mark === INTERNAL_PROPS_MARK ;
328
331
329
332
const domProps = omitDOMProps ? omitDOMProps ( restProps ) : restProps ;
330
- DEFAULT_OMIT_PROPS . forEach ( prop => {
333
+ DEFAULT_OMIT_PROPS . forEach ( ( prop ) => {
331
334
delete domProps [ prop ] ;
332
335
} ) ;
333
336
@@ -337,7 +340,8 @@ export default function generateSelector<
337
340
const listRef = useRef < RefOptionListProps > ( null ) ;
338
341
339
342
const tokenWithEnter = useMemo (
340
- ( ) => ( tokenSeparators || [ ] ) . some ( tokenSeparator => [ '\n' , '\r\n' ] . includes ( tokenSeparator ) ) ,
343
+ ( ) =>
344
+ ( tokenSeparators || [ ] ) . some ( ( tokenSeparator ) => [ '\n' , '\r\n' ] . includes ( tokenSeparator ) ) ,
341
345
[ tokenSeparators ] ,
342
346
) ;
343
347
@@ -446,7 +450,7 @@ export default function generateSelector<
446
450
} ) ;
447
451
if (
448
452
mode === 'tags' &&
449
- filteredOptions . every ( opt => opt [ optionFilterProp ] !== mergedSearchValue )
453
+ filteredOptions . every ( ( opt ) => opt [ optionFilterProp ] !== mergedSearchValue )
450
454
) {
451
455
filteredOptions . unshift ( {
452
456
value : mergedSearchValue ,
@@ -682,7 +686,7 @@ export default function generateSelector<
682
686
683
687
if ( mode !== 'tags' ) {
684
688
patchRawValues = patchLabels
685
- . map ( label => {
689
+ . map ( ( label ) => {
686
690
const item = mergedFlattenOptions . find (
687
691
( { data } ) => data [ mergedOptionLabelProp ] === label ,
688
692
) ;
@@ -695,7 +699,7 @@ export default function generateSelector<
695
699
new Set < RawValueType > ( [ ...mergedRawValue , ...patchRawValues ] ) ,
696
700
) ;
697
701
triggerChange ( newRawValues ) ;
698
- newRawValues . forEach ( newRawValue => {
702
+ newRawValues . forEach ( ( newRawValue ) => {
699
703
triggerSelect ( newRawValue , true , 'input' ) ;
700
704
} ) ;
701
705
@@ -719,9 +723,11 @@ export default function generateSelector<
719
723
// If menu is open, OptionList will take charge
720
724
// If mode isn't tags, press enter is not meaningful when you can't see any option
721
725
const onSearchSubmit = ( searchText : string ) => {
722
- const newRawValues = Array . from ( new Set < RawValueType > ( [ ...mergedRawValue , searchText ] ) ) ;
726
+ const newRawValues = Array . from (
727
+ new Set < RawValueType > ( [ ...mergedRawValue , searchText ] ) ,
728
+ ) ;
723
729
triggerChange ( newRawValues ) ;
724
- newRawValues . forEach ( newRawValue => {
730
+ newRawValues . forEach ( ( newRawValue ) => {
725
731
triggerSelect ( newRawValue , true , 'input' ) ;
726
732
} ) ;
727
733
setInnerSearchValue ( '' ) ;
@@ -845,10 +851,10 @@ export default function generateSelector<
845
851
}
846
852
} ;
847
853
848
- const activeTimeoutIds : number [ ] = [ ] ;
854
+ const activeTimeoutIds : any [ ] = [ ] ;
849
855
useEffect (
850
856
( ) => ( ) => {
851
- activeTimeoutIds . forEach ( timeoutId => clearTimeout ( timeoutId ) ) ;
857
+ activeTimeoutIds . forEach ( ( timeoutId ) => clearTimeout ( timeoutId ) ) ;
852
858
activeTimeoutIds . splice ( 0 , activeTimeoutIds . length ) ;
853
859
} ,
854
860
[ ] ,
0 commit comments