Skip to content

Commit 2a70957

Browse files
committed
docs, correct export, telemetry
1 parent 64ba21b commit 2a70957

File tree

8 files changed

+85
-2
lines changed

8 files changed

+85
-2
lines changed
1.76 MB
Loading
1.71 MB
Loading
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# SitePicker control
2+
3+
This control allows you to select one or multiple available sites, site collections or hub sites.
4+
5+
Here is an example of the control.
6+
7+
`SitePicker` single selection mode:
8+
9+
![SitePicker Single Select](../assets/site-picker-single-select.gif)
10+
11+
`SitePicker` multi-selection mode
12+
13+
![SitePicker Multi Select](../assets/site-picker-multi-select.gif)
14+
15+
## How to use this control in your solutions
16+
17+
- 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.
18+
- Import the control into your component:
19+
20+
```TypeScript
21+
import { SitePicker } from "@pnp/spfx-controls-react/lib/SitePicker";
22+
```
23+
24+
- Use the `SitePicker` control in your code as follows:
25+
26+
```TypeScript
27+
<SitePicker
28+
context={this.props.context}
29+
label={'Select sites'}
30+
mode={'site'}
31+
allowSearch={true}
32+
multiSelect={false}
33+
onChange={(sites) => { console.log(sites); }}
34+
placeholder={'Select sites'}
35+
searchPlaceholder={'Filter sites'} />
36+
```
37+
38+
- The `onChange` change event returns the selected site(s).
39+
40+
## Implementation
41+
42+
The `SitePicker` control can be configured with the following properties:
43+
44+
| Property | Type | Required | Description |
45+
| ---- | ---- | ---- | ---- |
46+
| allowSearch | boolean | no | Specifies if search box is displayed for the component. Default: `true`. |
47+
| context | BaseComponentContext | yes | The context object of the SPFx loaded webpart or customizer. |
48+
| deferredSearchTime | number | no | The list will be filtered after users stop typing for `deferredSearchTime` milliseconds. Default: 200. |
49+
| className | string | no | If provided, additional class name to provide on the dropdown element. |
50+
| disabled | boolean | no | Whether or not the control is disabled. |
51+
| initialSites | ISite[] | no | Intial data to load in the 'Selected sites' area (optional). |
52+
| isDesc | boolean | no | Specifies if the list is sorted in descending order. Default: `false`. |
53+
| label | string | no | Label to use for the control. |
54+
| limitToCurrentSiteCollection | boolean | no | Specifies if the options should be limited by the current site collections. Taken into consideration if selectionMode is set to `web`. |
55+
| mode | `'site' \| 'web' \| 'hub'` | no | Defines what entities are available for selection: site collections, sites, hub sites. Default: `web`. |
56+
| multiSelect | boolean | no | Optional mode indicates if multi-choice selections is allowed. Default: `true`. |
57+
| onChange | `(selectedSites: ISite[]) => void` | yes | Selection change handler. |
58+
| orderBy | `'title' \| 'url'` | no | Specifices if the list is sorted by title or url. Default: `title`. |
59+
| placeholder | string | no | Placeholder label to show in the dropdown. |
60+
| searchPlaceholder | string | no | Search input placeholder text. Displayed until search text is entered. |
61+
62+
Interface `ISite`
63+
64+
| Property | Type | Required | Description |
65+
| ---- | ---- | ---- | ---- |
66+
| id | string | no | ID of the site collection. |
67+
| title | string | no | Title of the site. |
68+
| url | string | no | URL of the site. |
69+
| webId | string | no | ID of the site. **Note: the value is not populated if the `mode` is set to `hub`. |
70+
| hubSiteId | string | no | ID of the hub site. |
71+
72+
![](https://telemetry.sharepointpnp.com/sp-dev-fx-controls-react/wiki/controls/SitePicker)

docs/documentation/docs/index.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,9 @@ The following controls are currently available:
7777
- [PeoplePicker](./controls/PeoplePicker) (People Picker)
7878
- [Placeholder](./controls/Placeholder) (shows an initial placeholder if the web part has to be configured)
7979
- [Progress](./controls/Progress) (shows progress of multiple SEQUENTIALLY executed actions)
80-
- [SiteBreadcrumb](./controls/SiteBreadcrumb) (Breadcrumb control)
8180
- [SecurityTrimmedControl](./controls/SecurityTrimmedControl) (intended to be used when you want to show or hide components based on the user permissions)
81+
- [SiteBreadcrumb](./controls/SiteBreadcrumb) (Breadcrumb control)
82+
- [SitePicker](./controls/SitePicker) (Site Picker control)
8283
- [TaxonomyPicker](./controls/TaxonomyPicker) (Taxonomy Picker)
8384
- [Toolbar](./controls/Toolbar) (Control to render Toolbar in Microsoft Teams)
8485
- [TreeView](./controls/TreeView) (Tree View)

docs/documentation/mkdocs.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ nav:
4747
- Placeholder: 'controls/Placeholder.md'
4848
- Progress: 'controls/Progress.md'
4949
- RichText: 'controls/RichText.md'
50-
- SiteBreadcrumb: 'controls/SiteBreadcrumb.md'
5150
- SecurityTrimmedControl: 'controls/SecurityTrimmedControl.md'
51+
- SiteBreadcrumb: 'controls/SiteBreadcrumb.md'
52+
- SitePicker: 'controls/SitePicker.md'
5253
- TaxonomyPicker: 'controls/TaxonomyPicker.md'
5354
- Toolbar: 'controls/Toolbar.md'
5455
- TreeView: 'controls/TreeView.md'

src/SitePicker.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './controls/sitePicker/index';

src/controls/sitePicker/SitePicker.tsx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import findIndex from 'lodash/findIndex';
1010
import { SearchBox } from 'office-ui-fabric-react/lib/SearchBox';
1111
import { toRelativeUrl } from '../../common/utilities/GeneralHelper';
1212
import { Async } from '@uifabric/utilities/lib/Async';
13+
import * as telemetry from '../../common/telemetry';
1314

1415
const styles = mergeStyleSets({
1516
loadingSpinnerContainer: {
@@ -189,6 +190,11 @@ export const SitePicker: React.FunctionComponent<ISitePickerProps> = (props: Rea
189190
</div>;
190191
};
191192

193+
React.useEffect(() => {
194+
telemetry.track('ReactSitePicker');
195+
}, []);
196+
197+
192198
React.useEffect(() => {
193199
if (!initialSites) {
194200
return;

src/controls/sitePicker/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export * from './ISitePicker';
2+
export * from './SitePicker';

0 commit comments

Comments
 (0)