Skip to content

Commit 16ddb57

Browse files
Add missing documentation for FolderPicker control
1 parent 2501ead commit 16ddb57

File tree

8 files changed

+73
-3
lines changed

8 files changed

+73
-3
lines changed
2.31 KB
Loading
2.26 KB
Loading
17.9 KB
Loading
56.9 KB
Loading
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# FolderPicker control
2+
3+
This control allows you to explore and select a folder.
4+
It also allows the user to create a new folder at the current level being explored.
5+
6+
Here is an example of the control:
7+
8+
![FolderPicker](../assets/FolderPicker.png)
9+
10+
`FolderPicker` no selection:
11+
12+
![FolderPicker no selection](../assets/FolderPicker-no-selection.png)
13+
14+
`FolderPicker` selection:
15+
16+
![FolderPicker selection](../assets/FolderPicker-selection.png)
17+
18+
`FolderPicker` selected:
19+
20+
![FolderPicker selected](../assets/FolderPicker-selected.png)
21+
22+
## How to use this control in your solutions
23+
24+
- 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.
25+
- Import the control into your component:
26+
27+
```TypeScript
28+
import { FolderPicker, IFolder } from "@pnp/spfx-controls-react/lib/FolderPicker";
29+
```
30+
31+
- Use the `FolderPicker` control in your code as follows:
32+
33+
```TypeScript
34+
<FolderPicker context={this.props.context}
35+
label='Folder Picker'
36+
required={true}
37+
rootFolder={{
38+
Name: 'Documents',
39+
ServerRelativeUrl: `/sites/TestSite/Shared Documents`
40+
}}
41+
onSelect={this._onFolderSelect}
42+
canCreateFolders={true} />
43+
```
44+
45+
- The `onSelect` change event returns the selected folder and can be implemented as follows:
46+
47+
```TypeScript
48+
private _onFolderSelect = (folder: IFolder): void => {
49+
console.log('selected folder', folder);
50+
}
51+
```
52+
53+
## Implementation
54+
55+
The `FolderPicker` control can be configured with the following properties:
56+
57+
| Property | Type | Required | Description |
58+
| ---- | ---- | ---- | ---- |
59+
| context | WebPartContext \| ExtensionContext | yes | The context object of the SPFx loaded webpart or customizer. |
60+
| label | string | yes | The label for the control. |
61+
| rootFolder | IFolder | yes | The lowest level folder that can be explored. This can be the root folder of a library. |
62+
| defaultFolder | IFolder | no | The default folder to be selected or explored. |
63+
| required | boolean | no | Is selection required. |
64+
| disabled | boolean | no | Is the control disabled. |
65+
| canCreateFolders | boolean | no | Allow current user to create folders on the target location. If enabled, you need to ensure that the user has the required permissions. |
66+
| onSelect | (folder: IFolder): void | no | Callback function called after a folder is selected. |
67+
68+
![](https://telemetry.sharepointpnp.com/sp-dev-fx-controls-react/wiki/controls/FolderPicker)

docs/documentation/docs/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ The following controls are currently available:
5454
- [FilePicker](./controls/FilePicker) (control that allows to browse and select a file from various places)
5555
- [FileTypeIcon](./controls/FileTypeIcon) (Control that shows the icon of a specified file path or application)
5656
- [FolderExplorer](./controls/FolderExplorer) (Control that allows to browse the folders and sub-folders from a root folder)
57+
- [FolderPicker](./controls/FolderPicker) (Control that allows to browse and select a folder)
5758
- [GridLayout](./controls/GridLayout) (control that renders a responsive grid layout for your web parts)
5859
- [IconPicker](./controls/IconPicker) (control that allows to search and select an icon from office-ui-fabric icons)
5960
- [IFrameDialog](./controls/IFrameDialog) (renders a Dialog with an iframe as a content)

docs/documentation/mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ nav:
1818
- FilePicker: 'controls/FilePicker.md'
1919
- FileTypeIcon: 'controls/FileTypeIcon.md'
2020
- FolderExplorer: 'controls/FolderExplorer.md'
21+
- FolderPicker: 'controls/FolderPicker.md'
2122
- GridLayout: 'controls/GridLayout.md'
2223
- IconPicker: 'controls/IconPicker.md'
2324
- IFrameDialog: 'controls/IFrameDialog.md'

src/controls/folderPicker/IFolderPickerProps.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ export interface IFolderPickerProps {
99
context: WebPartContext | ExtensionContext;
1010

1111
/**
12-
* The field label
12+
* The label for the control
1313
*/
1414
label: string;
1515

@@ -24,12 +24,12 @@ export interface IFolderPickerProps {
2424
defaultFolder?: IFolder;
2525

2626
/**
27-
* Is the field required
27+
* Is selection required
2828
*/
2929
required?: boolean;
3030

3131
/**
32-
* Is the field disabled
32+
* Is the control disabled
3333
*/
3434
disabled?: boolean;
3535

0 commit comments

Comments
 (0)