Skip to content

Commit dfe3c29

Browse files
Added icons and exports
1 parent d8265f3 commit dfe3c29

File tree

10 files changed

+50
-19
lines changed

10 files changed

+50
-19
lines changed

docs/documentation/docs/controls/ModernTaxonomyPicker.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ You can also use the `TaxonomyTree` control separately to just render a stand-al
156156

157157
```TypeScript
158158
const taxonomyService = new SPTaxonomyService(props.context);
159-
const [terms, setTerms] = React.useState<ITermInfo[]>();
159+
const [terms, setTerms] = React.useState<ITermInfo[]>([]);
160160
const [currentTermStoreInfo, setCurrentTermStoreInfo] = React.useState<ITermStoreInfo>();
161161
const [currentTermSetInfo, setCurrentTermSetInfo] = React.useState<ITermSetInfo>();
162162
const [currentLanguageTag, setCurrentLanguageTag] = React.useState<string>("");
@@ -176,16 +176,21 @@ You can also use the `TaxonomyTree` control separately to just render a stand-al
176176
});
177177
}, []);
178178

179-
<TaxonomyTree
180-
languageTag={currentLanguageTag}
181-
onLoadMoreData={taxonomyService.getTerms}
182-
pageSize={50}
183-
setTerms={setTerms}
184-
termSetInfo={currentTermSetInfo}
185-
termStoreInfo={currentTermStoreInfo}
186-
terms={terms}
187-
onRenderActionButton={onRenderActionButton}
188-
/>
179+
return (
180+
{currentTermSetInfo && (
181+
<TaxonomyTree
182+
languageTag={currentLanguageTag}
183+
onLoadMoreData={taxonomyService.getTerms}
184+
pageSize={50}
185+
setTerms={setTerms}
186+
termSetInfo={currentTermSetInfo}
187+
termStoreInfo={currentTermStoreInfo}
188+
terms={terms}
189+
onRenderActionButton={onRenderActionButton}
190+
hideDeprecatedTerms={false}
191+
showIcons={true}
192+
/>
193+
)}
189194
```
190195
191196
![](https://telemetry.sharepointpnp.com/sp-dev-fx-controls-react/wiki/controls/ModernTaxonomyPicker)

src/controls/modernTaxonomyPicker/ModernTaxonomyPicker.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export interface IModernTaxonomyPickerProps {
5050
panelTitle: string;
5151
label: string;
5252
context: BaseComponentContext;
53-
initialValues?: ITermInfo[];
53+
initialValues?: Optional<ITermInfo, "childrenCount" | "createdDateTime" | "lastModifiedDateTime" | "descriptions" | "customSortOrder" | "properties" | "localProperties" | "isDeprecated" | "isAvailableForTagging" | "topicRequested">[];
5454
disabled?: boolean;
5555
required?: boolean;
5656
onChange?: (newValue?: ITermInfo[]) => void;
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,6 @@
11
export * from './ModernTaxonomyPicker';
2-
export * from './termItem/TermItem';
2+
export * from './modernTermPicker/index';
3+
export * from './taxonomyPanelContents/index';
4+
export * from './taxonomyTree/index';
5+
export * from './termItem/index';
6+
export * from '../../services/SPTaxonomyService';

src/controls/modernTaxonomyPicker/modernTermPicker/ModernTermPicker.types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export interface ITermItemStyles {
3838
close: IStyle;
3939
}
4040

41-
export interface ITermItemSuggestionProps extends React.AllHTMLAttributes<HTMLElement> {
41+
export interface ITermItemSuggestionElementProps extends React.AllHTMLAttributes<HTMLElement> {
4242
/** Additional CSS class(es) to apply to the TermItemSuggestion div element */
4343
className?: string;
4444

@@ -49,8 +49,8 @@ export interface ITermItemSuggestionProps extends React.AllHTMLAttributes<HTMLEl
4949
theme?: ITheme;
5050
}
5151

52-
export type ITermItemSuggestionStyleProps = Required<Pick<ITermItemSuggestionProps, 'theme'>> &
53-
Pick<ITermItemSuggestionProps, 'className'> & {};
52+
export type ITermItemSuggestionStyleProps = Required<Pick<ITermItemSuggestionElementProps, 'theme'>> &
53+
Pick<ITermItemSuggestionElementProps, 'className'> & {};
5454

5555
export interface ITermItemSuggestionStyles {
5656
/** Refers to the text element of the TermItemSuggestion */
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './ModernTermPicker';
2+
export * from './ModernTermPicker.types';

src/controls/modernTaxonomyPicker/taxonomyPanelContents/TaxonomyPanelContents.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ export function TaxonomyPanelContents(props: ITaxonomyPanelContentsProps): React
112112
terms={terms}
113113
allowMultipleSelections={props.allowMultipleSelections}
114114
onRenderActionButton={props.onRenderActionButton}
115+
hideDeprecatedTerms={true}
116+
showIcons={false}
115117
/>
116118
</div>
117119
);

src/controls/modernTaxonomyPicker/taxonomyTree/TaxonomyTree.module.scss

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,3 +60,8 @@
6060
.taxonomyItemHeader:hover .actionButtonContainer > *, .taxonomyItemHeader:focus .actionButtonContainer > *, .taxonomyItemHeader .actionButtonContainer:focus-within > * {
6161
opacity: 1;
6262
}
63+
64+
.taxonomyItemIcon {
65+
margin-inline-start: 8px;
66+
margin-inline-end: 8px;
67+
}

src/controls/modernTaxonomyPicker/taxonomyTree/TaxonomyTree.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { Checkbox,
44
css,
55
FocusZone,
66
FocusZoneDirection,
7+
FontIcon,
78
getRTLSafeKeyCode,
89
GroupedList,
910
GroupHeader,
@@ -55,6 +56,8 @@ export interface ITaxonomyTreeProps {
5556
terms: ITermInfo[];
5657
setTerms: React.Dispatch<React.SetStateAction<ITermInfo[]>>;
5758
selection?: Selection<any>;
59+
hideDeprecatedTerms?: boolean;
60+
showIcons?: boolean;
5861
}
5962

6063
export function TaxonomyTree(props: ITaxonomyTreeProps): React.ReactElement<ITaxonomyTreeProps> {
@@ -90,7 +93,7 @@ export function TaxonomyTree(props: ITaxonomyTreeProps): React.ReactElement<ITax
9093
setGroups([rootGroup]);
9194
setGroupsLoading((prevGroupsLoading) => [...prevGroupsLoading, props.termSetInfo.id]);
9295
if (props.termSetInfo.childrenCount > 0) {
93-
props.onLoadMoreData(Guid.parse(props.termSetInfo.id), props.anchorTermInfo ? Guid.parse(props.anchorTermInfo.id) : Guid.empty, '', true)
96+
props.onLoadMoreData(Guid.parse(props.termSetInfo.id), props.anchorTermInfo ? Guid.parse(props.anchorTermInfo.id) : Guid.empty, '', props.hideDeprecatedTerms)
9497
.then((loadedTerms) => {
9598
const grps: IGroup[] = loadedTerms.value.map(term => {
9699
let termNames = term.labels.filter((termLabel) => (termLabel.languageTag === props.languageTag && termLabel.isDefault === true));
@@ -151,7 +154,7 @@ export function TaxonomyTree(props: ITaxonomyTreeProps): React.ReactElement<ITax
151154
setGroupsLoading((prevGroupsLoading) => [...prevGroupsLoading, group.key]);
152155
group.data.isLoading = true;
153156

154-
props.onLoadMoreData(Guid.parse(props.termSetInfo.id), Guid.parse(group.key), '', true)
157+
props.onLoadMoreData(Guid.parse(props.termSetInfo.id), Guid.parse(group.key), '', props.hideDeprecatedTerms)
155158
.then((loadedTerms) => {
156159
const grps: IGroup[] = loadedTerms.value.map(term => {
157160
let termNames = term.labels.filter((termLabel) => (termLabel.languageTag === props.languageTag && termLabel.isDefault === true));
@@ -225,6 +228,9 @@ export function TaxonomyTree(props: ITaxonomyTreeProps): React.ReactElement<ITax
225228
direction={FocusZoneDirection.horizontal}
226229
className={styles.taxonomyItemFocusZone}
227230
>
231+
{props.showIcons && (
232+
<FontIcon iconName="Tag" className={styles.taxonomyItemIcon} />
233+
)}
228234
<Label styles={labelStyles}>{groupHeaderProps.group.name}</Label>
229235
<div className={styles.actionButtonContainer}>
230236
{props.onRenderActionButton && props.onRenderActionButton(props.termStoreInfo, props.termSetInfo, props.anchorTermInfo)}
@@ -235,11 +241,15 @@ export function TaxonomyTree(props: ITaxonomyTreeProps): React.ReactElement<ITax
235241

236242
if (!props.selection) {
237243
const labelStyles: IStyleFunctionOrObject<ILabelStyleProps, ILabelStyles> = {root: {width: "100%", fontWeight: childIsSelected ? "bold" : "normal"}};
244+
let taxonomyItemIconName: string = groupHeaderProps.group.data.term.isDeprecated ? "Blocked" : "Tag";
238245
return (
239246
<FocusZone
240247
direction={FocusZoneDirection.horizontal}
241248
className={styles.taxonomyItemFocusZone}
242249
>
250+
{props.showIcons && (
251+
<FontIcon iconName={taxonomyItemIconName} className={styles.taxonomyItemIcon} />
252+
)}
243253
<Label styles={labelStyles}>{groupHeaderProps.group.name}</Label>
244254
<div className={styles.actionButtonContainer}>
245255
{props.onRenderActionButton && props.onRenderActionButton(props.termStoreInfo, props.termSetInfo, groupHeaderProps.group.data.term)}
@@ -373,7 +383,7 @@ export function TaxonomyTree(props: ITaxonomyTreeProps): React.ReactElement<ITax
373383
<div className={styles.loadMoreContainer}>
374384
<Link onClick={() => {
375385
setGroupsLoading((prevGroupsLoading) => [...prevGroupsLoading, footerProps.group.key]);
376-
props.onLoadMoreData(Guid.parse(props.termSetInfo.id), footerProps.group.key === props.termSetInfo.id ? Guid.empty : Guid.parse(footerProps.group.key), footerProps.group.data.skiptoken, true)
386+
props.onLoadMoreData(Guid.parse(props.termSetInfo.id), footerProps.group.key === props.termSetInfo.id ? Guid.empty : Guid.parse(footerProps.group.key), footerProps.group.data.skiptoken, props.hideDeprecatedTerms)
377387
.then((loadedTerms) => {
378388
const grps: IGroup[] = loadedTerms.value.map(term => {
379389
let termNames = term.labels.filter((termLabel) => (termLabel.languageTag === props.languageTag && termLabel.isDefault === true));
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './TaxonomyTree';
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './TermItem';
2+
export * from './TermItemSuggestion';

0 commit comments

Comments
 (0)