@@ -2,41 +2,44 @@ import * as React from 'react';
2
2
import { BaseComponentContext } from '@microsoft/sp-component-base' ;
3
3
import { Guid } from '@microsoft/sp-core-library' ;
4
4
import { IIconProps } from 'office-ui-fabric-react/lib/components/Icon' ;
5
- import { PrimaryButton ,
6
- DefaultButton ,
7
- IconButton ,
8
- IButtonStyles
9
- } from 'office-ui-fabric-react/lib/Button' ;
5
+ import {
6
+ PrimaryButton ,
7
+ DefaultButton ,
8
+ IconButton ,
9
+ IButtonStyles
10
+ } from 'office-ui-fabric-react/lib/Button' ;
10
11
import { Label } from 'office-ui-fabric-react/lib/Label' ;
11
- import { Panel ,
12
- PanelType
13
- } from 'office-ui-fabric-react/lib/Panel' ;
14
- import { IBasePickerStyleProps ,
15
- IBasePickerStyles ,
16
- ISuggestionItemProps
17
- } from 'office-ui-fabric-react/lib/Pickers' ;
18
- import { IStackTokens ,
19
- Stack
20
- } from 'office-ui-fabric-react/lib/Stack' ;
12
+ import {
13
+ Panel ,
14
+ PanelType
15
+ } from 'office-ui-fabric-react/lib/Panel' ;
16
+ import {
17
+ IBasePickerStyleProps ,
18
+ IBasePickerStyles ,
19
+ ISuggestionItemProps
20
+ } from 'office-ui-fabric-react/lib/Pickers' ;
21
+ import {
22
+ IStackTokens ,
23
+ Stack
24
+ } from 'office-ui-fabric-react/lib/Stack' ;
21
25
import { IStyleFunctionOrObject } from 'office-ui-fabric-react/lib/Utilities' ;
22
26
import { sp } from '@pnp/sp' ;
23
27
import { SPTaxonomyService } from '../../services/SPTaxonomyService' ;
24
28
import { TaxonomyPanelContents } from './taxonomyPanelContents' ;
25
29
import styles from './ModernTaxonomyPicker.module.scss' ;
26
30
import * as strings from 'ControlStrings' ;
27
- import { TooltipHost } from '@microsoft/ office-ui-fabric-react-bundle ' ;
31
+ import { TooltipHost , ITooltipHostStyles } from 'office-ui-fabric-react/lib/Tooltip ' ;
28
32
import { useId } from '@uifabric/react-hooks' ;
29
- import { ITooltipHostStyles } from 'office-ui-fabric-react' ;
30
- import { ITermInfo ,
31
- ITermSetInfo ,
32
- ITermStoreInfo
33
- } from '@pnp/sp/taxonomy' ;
33
+ import {
34
+ ITermInfo ,
35
+ ITermSetInfo ,
36
+ ITermStoreInfo
37
+ } from '@pnp/sp/taxonomy' ;
34
38
import { TermItemSuggestion } from './termItem/TermItemSuggestion' ;
35
39
import { ModernTermPicker } from './modernTermPicker/ModernTermPicker' ;
36
40
import { IModernTermPickerProps , ITermItemProps } from './modernTermPicker/ModernTermPicker.types' ;
37
41
import { TermItem } from './termItem/TermItem' ;
38
- import { IReadonlyTheme } from "@microsoft/sp-component-base" ;
39
- import { isUndefined } from 'lodash' ;
42
+ import { IReadonlyTheme } from '@microsoft/sp-component-base' ;
40
43
41
44
export type Optional < T , K extends keyof T > = Pick < Partial < T > , K > & Omit < T , K > ;
42
45
@@ -75,21 +78,21 @@ export function ModernTaxonomyPicker(props: IModernTaxonomyPickerProps) {
75
78
. then ( ( termStoreInfo ) => {
76
79
setCurrentTermStoreInfo ( termStoreInfo ) ;
77
80
setCurrentLanguageTag ( props . context . pageContext . cultureInfo . currentUICultureName !== '' ?
78
- props . context . pageContext . cultureInfo . currentUICultureName :
79
- currentTermStoreInfo . defaultLanguageTag ) ;
80
- setSelectedOptions ( Object . prototype . toString . call ( props . initialValues ) === '[object Array]' ?
81
- props . initialValues . map ( term => { return { ...term , languageTag : currentLanguageTag , termStoreInfo : currentTermStoreInfo } as ITermInfo ; } ) :
82
- [ ] ) ;
81
+ props . context . pageContext . cultureInfo . currentUICultureName :
82
+ currentTermStoreInfo . defaultLanguageTag ) ;
83
+ setSelectedOptions ( Array . isArray ( props . initialValues ) ?
84
+ props . initialValues . map ( term => { return { ...term , languageTag : currentLanguageTag , termStoreInfo : currentTermStoreInfo } as ITermInfo ; } ) :
85
+ [ ] ) ;
83
86
} ) ;
84
87
taxonomyService . getTermSetInfo ( Guid . parse ( props . termSetId ) )
85
88
. then ( ( termSetInfo ) => {
86
89
setCurrentTermSetInfo ( termSetInfo ) ;
87
90
} ) ;
88
91
if ( props . anchorTermId && props . anchorTermId !== Guid . empty . toString ( ) ) {
89
92
taxonomyService . getTermById ( Guid . parse ( props . termSetId ) , props . anchorTermId ? Guid . parse ( props . anchorTermId ) : Guid . empty )
90
- . then ( ( anchorTermInfo ) => {
91
- setCurrentAnchorTermInfo ( anchorTermInfo ) ;
92
- } ) ;
93
+ . then ( ( anchorTermInfo ) => {
94
+ setCurrentAnchorTermInfo ( anchorTermInfo ) ;
95
+ } ) ;
93
96
}
94
97
} , [ ] ) ;
95
98
@@ -184,8 +187,8 @@ export function ModernTaxonomyPicker(props: IModernTaxonomyPickerProps) {
184
187
const calloutProps = { gapSpace : 0 } ;
185
188
const tooltipId = useId ( 'tooltip' ) ;
186
189
const hostStyles : Partial < ITooltipHostStyles > = { root : { display : 'inline-block' } } ;
187
- const addTermButtonStyles : IButtonStyles = { rootHovered : { backgroundColor : " inherit" } , rootPressed : { backgroundColor : " inherit" } } ;
188
- const termPickerStyles : IStyleFunctionOrObject < IBasePickerStyleProps , IBasePickerStyles > = { input : { minheight : 34 } , text : { minheight : 34 } } ;
190
+ const addTermButtonStyles : IButtonStyles = { rootHovered : { backgroundColor : ' inherit' } , rootPressed : { backgroundColor : ' inherit' } } ;
191
+ const termPickerStyles : IStyleFunctionOrObject < IBasePickerStyleProps , IBasePickerStyles > = { input : { minheight : 34 } , text : { minheight : 34 } } ;
189
192
190
193
return (
191
194
< div className = { styles . modernTaxonomyPicker } >
@@ -205,7 +208,7 @@ export function ModernTaxonomyPicker(props: IModernTaxonomyPickerProps) {
205
208
setSelectedPanelOptions ( itms || [ ] ) ;
206
209
} }
207
210
getTextFromItem = { getTextFromItem }
208
- pickerSuggestionsProps = { props . termPickerProps ?. pickerSuggestionsProps ?? { noResultsFoundText : strings . ModernTaxonomyPickerNoResultsFound } }
211
+ pickerSuggestionsProps = { props . termPickerProps ?. pickerSuggestionsProps ?? { noResultsFoundText : strings . ModernTaxonomyPickerNoResultsFound } }
209
212
inputProps = { props . termPickerProps ?. inputProps ?? {
210
213
'aria-label' : props . placeHolder || strings . ModernTaxonomyPickerDefaultPlaceHolder ,
211
214
placeholder : props . placeHolder || strings . ModernTaxonomyPickerDefaultPlaceHolder
@@ -242,8 +245,8 @@ export function ModernTaxonomyPicker(props: IModernTaxonomyPickerProps) {
242
245
} ;
243
246
return (
244
247
< Stack horizontal disableShrink tokens = { horizontalGapStackTokens } >
245
- < PrimaryButton text = { strings . ModernTaxonomyPickerApplyButtonText } value = " Apply" onClick = { onApply } />
246
- < DefaultButton text = { strings . ModernTaxonomyPickerCancelButtonText } value = " Cancel" onClick = { onClosePanel } />
248
+ < PrimaryButton text = { strings . ModernTaxonomyPickerApplyButtonText } value = ' Apply' onClick = { onApply } />
249
+ < DefaultButton text = { strings . ModernTaxonomyPickerCancelButtonText } value = ' Cancel' onClick = { onClosePanel } />
247
250
</ Stack >
248
251
) ;
249
252
} } >
0 commit comments