Skip to content

Commit 2b6020f

Browse files
committed
migration guide draft
1 parent 96f51c3 commit 2b6020f

File tree

3 files changed

+84
-6
lines changed

3 files changed

+84
-6
lines changed

docs/documentation/docs/guides/index.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ Following is an overview of guides for this project. If you're considering contr
55
- [Contributing](./contributing.md) - how you can contribute to the project
66
- [Minimal Path to Awesome](./mpa.md) - setup your development environment
77
- [Submitting a PR](./submitting-pr.md) - how to submit a PR
8+
- [Migrating from V1](./migrate-from-v1.md) - how to migrate from v1
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
# Migrating from v1 to v2
2+
Most of the controls have no breaking changes when moving from v1 to v2. However, some APIs were changed to make the libary more stable and controls behavior more even.
3+
Also, we've bumped up React and Fluent UI versions used in the library. It means you will need to update `package.json` file in your SPFx projects.
4+
The below guide is an overview of what it takes to migrate from v1 to v2. If we missed something, please let us know in the issues list so we can update the guide. Thanks!
5+
6+
## v2 Supports SharePoint Online Only
7+
v2 of Reusable Controls is based on SharePoint Framework 1.11 and, as a result, does not support SharePoint On-Premise. **Please, use v1 if you plan to deploy your soluition on-prem.**
8+
9+
## React and Fluent UI versions
10+
v2 of Reusable Controls uses React.js v16.8.5 and Fluent UI (Office UI Fabric React) v6.189.2.
11+
Please, update the `package.json` accordingly:
12+
```json
13+
"dependencies": {
14+
// other dependencies
15+
"@types/react": "16.8.8",
16+
"@types/react-dom": "16.8.3",
17+
"office-ui-fabric-react": "6.189.2",
18+
"react": "16.8.5",
19+
"react-dom": "16.8.5"
20+
},
21+
"resolutions": {
22+
"@types/react": "16.8.8"
23+
},
24+
```
25+
26+
## APIs Changes
27+
### PeoplePicker
28+
`isRequred` is renamed to `required`.<br/>
29+
The property has been renamed to use the common approach for mandatory field naming.
30+
31+
`errorMessage` represents static error message to be displayed in the control. <br />
32+
In v1 `errorMessage` is used to provide the text that will be displayed if the field is set as `required` and no value is selected.
33+
In v2 you can use this property to statically display error message for whatever reason.
34+
```typescript
35+
/**
36+
* Static error message displayed below the text field. Use onGetErrorMessage to dynamically change the error message displayed (if any) based on the current value. errorMessage and onGetErrorMessage are mutually exclusive (errorMessage takes precedence).
37+
*/
38+
errorMessage?: string;
39+
```
40+
41+
`onGetErrorMessage` to get error message dynamically.<br />
42+
The method is used to get the validation error message and determine whether the input value is valid or not. Mutually exclusive with the static string errorMessage (it will take precedence over this).
43+
```typescript
44+
/**
45+
* The method is used to get the validation error message and determine whether the picker value is valid or not.
46+
* Mutually exclusive with the static string errorMessage (it will take precedence over this).
47+
*
48+
* When it returns string:
49+
* - If valid, it returns empty string.
50+
* - If invalid, it returns the error message string and the picker will
51+
* show an error message below the picker.
52+
*
53+
* When it returns Promise<string>:
54+
* - The resolved value is display as error message.
55+
* - The rejected, the value is thrown away.
56+
*
57+
*/
58+
onGetErrorMessage?: (items: IPersonaProps[]) => string | Promise<string>;
59+
```
60+
61+
`showRequiredError` has been deleted.<br />
62+
Use `errorMessage` or `onGetErrorMessage` to provide the error message.
63+
64+
`selectedItems` is renamed to `onChange`<br />
65+
`onChange` better describes the purpose of the property.
66+

src/controls/peoplepicker/IPeoplePicker.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,19 +48,30 @@ export interface IPeoplePickerProps {
4848
/**
4949
* People Field is mandatory
5050
*/
51-
isRequired?: boolean;
51+
required?: boolean;
5252
/**
53-
* Mandatory field error message
53+
* Static error message displayed below the text field. Use onGetErrorMessage to dynamically change the error message displayed (if any) based on the current value. errorMessage and onGetErrorMessage are mutually exclusive (errorMessage takes precedence).
5454
*/
5555
errorMessage?: string;
5656
/**
57-
* Specifies if the component should show mandatory field error message because of some changes occured in parent
58-
*/
59-
showRequiredError?: boolean;
57+
* The method is used to get the validation error message and determine whether the input value is valid or not.
58+
* Mutually exclusive with the static string errorMessage (it will take precedence over this).
59+
*
60+
* When it returns string:
61+
* - If valid, it returns empty string.
62+
* - If invalid, it returns the error message string and the text field will
63+
* show a red border and show an error message below the text field.
64+
*
65+
* When it returns Promise<string>:
66+
* - The resolved value is display as error message.
67+
* - The rejected, the value is thrown away.
68+
*
69+
*/
70+
onGetErrorMessage?: (items: IPersonaProps[]) => string | Promise<string>;
6071
/**
6172
* Method to check value of People Picker text
6273
*/
63-
selectedItems?: (items: IPersonaProps[]) => void;
74+
onChange?: (items: IPersonaProps[]) => void;
6475
/**
6576
* Tooltip Message
6677
*/

0 commit comments

Comments
 (0)