@@ -46,39 +46,38 @@ import { css } from '@uifabric/utilities/lib/css';
46
46
import * as strings from 'ControlStrings' ;
47
47
import { useForceUpdate } from '@uifabric/react-hooks' ;
48
48
import { ModernTermPicker } from '../modernTermPicker/ModernTermPicker' ;
49
- import { ITermInfoExt } from '../modernTermPicker/ModernTermPicker.types' ;
50
49
51
50
export interface ITaxonomyFormProps {
52
51
context : BaseComponentContext ;
53
52
allowMultipleSelections ?: boolean ;
54
53
termSetId : Guid ;
55
54
pageSize : number ;
56
- selectedPanelOptions : ITermInfoExt [ ] ;
57
- setSelectedPanelOptions : React . Dispatch < React . SetStateAction < ITermInfoExt [ ] > > ;
58
- onResolveSuggestions : ( filter : string , selectedItems ?: ITermInfoExt [ ] ) => ITermInfoExt [ ] | PromiseLike < ITermInfoExt [ ] > ;
55
+ selectedPanelOptions : ITermInfo [ ] ;
56
+ setSelectedPanelOptions : React . Dispatch < React . SetStateAction < ITermInfo [ ] > > ;
57
+ onResolveSuggestions : ( filter : string , selectedItems ?: ITermInfo [ ] ) => ITermInfo [ ] | PromiseLike < ITermInfo [ ] > ;
59
58
onLoadMoreData : ( termSetId : Guid , parentTermId ?: Guid , skiptoken ?: string , hideDeprecatedTerms ?: boolean , pageSize ?: number ) => Promise < { value : ITermInfo [ ] , skiptoken : string } > ;
60
59
anchorTermInfo : ITermInfo ;
61
60
termSetInfo : ITermSetInfo ;
62
61
termStoreInfo : ITermStoreInfo ;
63
62
placeHolder : string ;
64
- onRenderSuggestionsItem ?: ( props : ITermInfoExt , itemProps : ISuggestionItemProps < ITermInfoExt > ) => JSX . Element ;
65
- onRenderItem ?: ( props : IPickerItemProps < ITermInfoExt > ) => JSX . Element ;
66
- getTextFromItem : ( item : ITermInfoExt , currentValue ?: string ) => string ;
63
+ onRenderSuggestionsItem ?: ( props : ITermInfo , itemProps : ISuggestionItemProps < ITermInfo > ) => JSX . Element ;
64
+ onRenderItem ?: ( props : IPickerItemProps < ITermInfo > ) => JSX . Element ;
65
+ getTextFromItem : ( item : ITermInfo , currentValue ?: string ) => string ;
67
66
languageTag : string ;
68
67
}
69
68
70
69
export function TaxonomyPanelContents ( props : ITaxonomyFormProps ) : React . ReactElement < ITaxonomyFormProps > {
71
70
const [ groupsLoading , setGroupsLoading ] = React . useState < string [ ] > ( [ ] ) ;
72
71
const [ groups , setGroups ] = React . useState < IGroup [ ] > ( [ ] ) ;
73
- const [ terms , setTerms ] = React . useState < ITermInfoExt [ ] > ( props . selectedPanelOptions ?. length > 0 ? [ ...props . selectedPanelOptions ] : [ ] ) ;
72
+ const [ terms , setTerms ] = React . useState < ITermInfo [ ] > ( props . selectedPanelOptions ?. length > 0 ? [ ...props . selectedPanelOptions ] : [ ] ) ;
74
73
75
74
const forceUpdate = useForceUpdate ( ) ;
76
75
77
76
const selection = React . useMemo ( ( ) => {
78
77
const s = new Selection ( { onSelectionChanged : ( ) => {
79
78
props . setSelectedPanelOptions ( ( prevOptions ) => [ ...selection . getSelection ( ) ] ) ;
80
79
forceUpdate ( ) ;
81
- } , getKey : ( term : ITermInfoExt ) => term . id } ) ;
80
+ } , getKey : ( term : any ) => term . id } ) ;
82
81
s . setItems ( terms ) ;
83
82
for ( const selectedOption of props . selectedPanelOptions ) {
84
83
if ( s . canSelectItem ) {
@@ -141,8 +140,7 @@ export function TaxonomyPanelContents(props: ITaxonomyFormProps): React.ReactEle
141
140
} ) ;
142
141
setTerms ( ( prevTerms ) => {
143
142
const nonExistingTerms = loadedTerms . value . filter ( ( term ) => prevTerms . every ( ( prevTerm ) => prevTerm . id !== term . id ) ) ;
144
- const nonExistingTermsAsExt = nonExistingTerms . map ( term => { return { ...term , languageTag : props . languageTag , termStoreInfo : props . termStoreInfo } as ITermInfoExt ; } ) ;
145
- return [ ...prevTerms , ...nonExistingTermsAsExt ] ;
143
+ return [ ...prevTerms , ...nonExistingTerms ] ;
146
144
} ) ;
147
145
rootGroup . children = grps ;
148
146
rootGroup . data . skiptoken = loadedTerms . skiptoken ;
@@ -204,8 +202,7 @@ export function TaxonomyPanelContents(props: ITaxonomyFormProps): React.ReactEle
204
202
205
203
setTerms ( ( prevTerms ) => {
206
204
const nonExistingTerms = loadedTerms . value . filter ( ( term ) => prevTerms . every ( ( prevTerm ) => prevTerm . id !== term . id ) ) ;
207
- const nonExistingTermsAsExt = nonExistingTerms . map ( term => { return { ...term , languageTag : props . languageTag , termStoreInfo : props . termStoreInfo } as ITermInfoExt ; } ) ;
208
- return [ ...prevTerms , ...nonExistingTermsAsExt ] ;
205
+ return [ ...prevTerms , ...nonExistingTerms ] ;
209
206
} ) ;
210
207
211
208
group . children = grps ;
@@ -384,8 +381,7 @@ export function TaxonomyPanelContents(props: ITaxonomyFormProps): React.ReactEle
384
381
} ) ;
385
382
setTerms ( ( prevTerms ) => {
386
383
const nonExistingTerms = loadedTerms . value . filter ( ( term ) => prevTerms . every ( ( prevTerm ) => prevTerm . id !== term . id ) ) ;
387
- const nonExistingTermsAsExt = nonExistingTerms . map ( term => { return { ...term , languageTag : props . languageTag , termStoreInfo : props . termStoreInfo } as ITermInfoExt ; } ) ;
388
- return [ ...prevTerms , ...nonExistingTermsAsExt ] ;
384
+ return [ ...prevTerms , ...nonExistingTerms ] ;
389
385
} ) ;
390
386
footerProps . group . children = [ ...footerProps . group . children , ...grps ] ;
391
387
footerProps . group . data . skiptoken = loadedTerms . skiptoken ;
@@ -413,7 +409,7 @@ export function TaxonomyPanelContents(props: ITaxonomyFormProps): React.ReactEle
413
409
onRenderShowAll : onRenderShowAll ,
414
410
} ;
415
411
416
- const onPickerChange = ( items ?: ITermInfoExt [ ] ) : void => {
412
+ const onPickerChange = ( items ?: ITermInfo [ ] ) : void => {
417
413
const itemsToAdd = items . filter ( ( item ) => terms . every ( ( term ) => term . id !== item . id ) ) ;
418
414
setTerms ( ( prevTerms ) => [ ...prevTerms , ...itemsToAdd ] ) ;
419
415
selection . setItems ( [ ...selection . getItems ( ) , ...itemsToAdd ] , true ) ;
0 commit comments