Skip to content

Commit 3c71397

Browse files
committed
Merge branch 'SherpasGroup-modern-taxonomy-picker-2' into dev
2 parents 666e0af + a81f14d commit 3c71397

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1792
-69
lines changed
1.91 KB
Loading
7.45 KB
Loading
3.61 KB
Loading
16.2 KB
Loading
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Modern Taxonomy Picker
2+
3+
This control allows you to select one or more Terms from a TermSet via its TermSet ID. You can also configure the control to select the child terms from a specific term in the TermSet by setting the anchorTermId. This is the modern version of the taxonomy picker that uses the REST API and makes use of some load on demand features which makes it well suited for large term sets.
4+
5+
!!! note "Disclaimer"
6+
Since this control is meant to look as and work in the same way as the out-of-the-box control it lacks some of the features from the legacy ```TaxonomyPicker``` control. If you need some of those features please continue using the legacy version.
7+
8+
**Empty term picker**
9+
10+
![Empty term picker](../assets/modernTaxonomyPicker-empty.png)
11+
12+
**Selecting terms**
13+
14+
![Selecting terms](../assets/modernTaxonomyPicker-tree-selection.png)
15+
16+
**Selected terms in picker**
17+
18+
![Selected terms in the input](../assets/modernTaxonomyPicker-selected-terms.png)
19+
20+
**Term picker: Auto Complete**
21+
22+
![Selected terms in the input](../assets/modernTaxonomyPicker-input-autocomplete.png)
23+
24+
25+
## How to use this control in your solutions
26+
27+
- Check that you installed the `@pnp/spfx-controls-react` dependency. Check out the [getting started](../../#getting-started) page for more information about installing the dependency.
28+
- Import the following modules to your component:
29+
30+
```TypeScript
31+
import { ModernTaxonomyPicker } from "@pnp/spfx-controls-react/lib/ModernTaxonomyPicker";
32+
```
33+
34+
- Use the `ModernTaxonomyPicker` control in your code as follows:
35+
36+
```TypeScript
37+
<ModernTaxonomyPicker allowMultipleSelections={true}
38+
termSetId="f233d4b7-68fb-41ef-8b58-2af0bafc0d38"
39+
panelTitle="Select Term"
40+
label="Taxonomy Picker"
41+
context={this.props.context}
42+
onChange={this.onTaxPickerChange} />
43+
```
44+
45+
- With the `onChange` property you can capture the event of when the terms in the picker has changed:
46+
47+
```typescript
48+
private onTaxPickerChange(terms : ITermInfo[]) {
49+
console.log("Terms", terms);
50+
}
51+
```
52+
53+
## Implementation
54+
55+
The ModernTaxonomyPicker control can be configured with the following properties:
56+
57+
| Property | Type | Required | Description |
58+
| ---- | ---- | ---- | ---- |
59+
| panelTitle | string | yes | TermSet Picker Panel title. |
60+
| label | string | yes | Text displayed above the Taxonomy Picker. |
61+
| disabled | boolean | no | Specify if the control should be disabled. Default value is false. |
62+
| context | BaseComponentContext | yes | Context of the current web part or extension. |
63+
| initialValues | ITermInfo[] | no | Defines the terms selected by default. ITermInfo comes from PnP/PnPjs and can be imported with <br/>```import { ITermInfo } from '@pnp/sp/taxonomy';``` |
64+
| allowMultipleSelections | boolean | no | Defines if the user can select only one or multiple terms. Default value is false. |
65+
| termSetId | string | yes | The Id of the TermSet that you would like the Taxonomy Picker to select terms from. |
66+
| onChange | function | no | Captures the event of when the terms in the picker has changed. |
67+
| anchorTermId | string | no | Set the id of a child term in the TermSet to be able to select terms from that level and below. |
68+
| placeHolder | string | no | Short text hint to display in picker. |
69+
| required | boolean | no | Specifies if to display an asterisk near the label. Default value is false. |
70+
| customPanelWidth | number | no | Custom panel width in pixels. |
71+
| termPickerProps | IModernTermPickerProps | no | Custom properties for the term picker (More info: [IBasePickerProps interface](https://developer.microsoft.com/en-us/fluentui#/controls/web/pickers#IBasePickerProps)). |
72+
| themeVariant | IReadonlyTheme | no | The current loaded SharePoint theme/section background (More info: [Supporting section backgrounds](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/guidance/supporting-section-backgrounds)). |
73+
74+
![](https://telemetry.sharepointpnp.com/sp-dev-fx-controls-react/wiki/controls/TaxonomyPicker)

docs/documentation/docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ The following controls are currently available:
8484
- [LivePersona](./controls/LivePersona) (Live Persona control)
8585
- [LocationPicker](./controls/LocationPicker) (Location Picker control)
8686
- [Map](./controls/Map) (renders a map in a web part)
87+
- [ModernTaxonomyPicker](./controls/ModernTaxonomyPicker) (Modern Taxonomy Picker)
8788
- [MyTeams](./controls/MyTeams) (My Teams)
8889
- [PeoplePicker](./controls/PeoplePicker) (People Picker)
8990
- [Placeholder](./controls/Placeholder) (shows an initial placeholder if the web part has to be configured)

docs/documentation/mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ nav:
4646
- LivePersona: 'controls/LivePersona.md'
4747
- LocationPicker: 'controls/LocationPicker.md'
4848
- Map: 'controls/Map.md'
49+
- ModernTaxonomyPicker: 'controls/ModernTaxonomyPicker.md'
4950
- MyTeams: 'controls/MyTeams.md'
5051
- Pagination: 'controls/Pagination.md'
5152
- PeoplePicker: 'controls/PeoplePicker.md'

src/ModernTaxonomyPicker.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './controls/modernTaxonomyPicker';
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
.modernTaxonomyPicker {
2+
3+
.termField {
4+
align-items: center;
5+
border-spacing: 0;
6+
display: flex;
7+
width: 100%;
8+
9+
.termFieldInput {
10+
flex-grow: 1;
11+
}
12+
13+
.termFieldButton {
14+
text-align: center;
15+
width: 42px;
16+
}
17+
18+
input[type="text"] {
19+
cursor: pointer;
20+
opacity: 0.8;
21+
width: 100%;
22+
}
23+
}
24+
25+
}

0 commit comments

Comments
 (0)