Skip to content

Commit 96740ab

Browse files
authored
Merge pull request #2064 from microsoftgraph/merge/main-to-next
chore: merge main to next
2 parents 840b6b6 + ebee230 commit 96740ab

File tree

9 files changed

+222
-66
lines changed

9 files changed

+222
-66
lines changed

.devcontainer/devcontainer.json

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"image": "mcr.microsoft.com/devcontainers/javascript-node:0-16",
3+
"customizations": {
4+
"vscode": {
5+
"extensions": [
6+
"streetsidesoftware.code-spell-checker",
7+
"nicolasparada.innerhtml",
8+
"runem.lit-plugin",
9+
"esbenp.prettier-vscode",
10+
"rebornix.project-snippets",
11+
"ms-vscode.vscode-typescript-tslint-plugin",
12+
"mutantdino.resourcemonitor"
13+
]
14+
}
15+
},
16+
"forwardPorts": [3000, 6006]
17+
}

.github/workflows/push-release.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,14 @@ jobs:
7575
- name: Attach mgt-spfx solution to GitHub release
7676
run: node scripts/uploadSpfxSolution.js ${{secrets.GITHUB_TOKEN}} ${{needs.version.outputs.package-version}}
7777

78+
- name: Notify TeamsFx Repo
79+
uses: peter-evans/repository-dispatch@v2
80+
with:
81+
token: ${{ secrets.TEAMSFX_REPO_ACCESS_TOKEN }}
82+
repository: OfficeDev/TeamsFx
83+
event-type: graph-toolkit-released
84+
client-payload: '{"version": "${{ needs.version.outputs.package-version }}"}'
85+
7886
storybook:
7987
runs-on: ubuntu-latest
8088

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,6 @@
160160
},
161161
"resolutions": {
162162
"@microsoft/microsoft-graph-client": "3.0.2",
163-
"react": "16.13.1",
164-
"react-dom": "16.13.1",
165163
"responselike": "2.0.0"
166164
}
167165
}

packages/mgt-components/src/components/mgt-people-picker/mgt-people-picker.scss

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,9 +226,16 @@ mgt-people-picker .root {
226226
top: 0px;
227227
border-radius: 12px;
228228
line-height: 24px;
229+
229230
&:hover {
230231
color: $commblue_primary;
231232
}
233+
&:focus,
234+
&:focus-visible {
235+
outline-offset: -4px;
236+
outline-width: 1px;
237+
outline-style: solid;
238+
}
232239
}
233240
}
234241
}

packages/mgt-components/src/components/mgt-people-picker/mgt-people-picker.ts

Lines changed: 94 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
103103
return styles;
104104
}
105105

106+
/**
107+
* The strings to be used for localizing the component.
108+
*
109+
* @readonly
110+
* @protected
111+
* @memberof MgtPeoplePicker
112+
*/
106113
protected get strings() {
107114
return strings;
108115
}
@@ -241,7 +248,7 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
241248
}
242249

243250
/**
244-
* User type to search for.
251+
* The type of user to search for. Default is any.
245252
*
246253
* @readonly
247254
* @type {UserType}
@@ -275,7 +282,15 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
275282
attribute: 'transitive-search',
276283
type: Boolean
277284
})
278-
public transitiveSearch: boolean;
285+
public get transitiveSearch(): boolean {
286+
return this._transitiveSearch;
287+
}
288+
public set transitiveSearch(value: boolean) {
289+
if (this.transitiveSearch !== value) {
290+
this._transitiveSearch = value;
291+
this.requestStateUpdate(true);
292+
}
293+
}
279294

280295
/**
281296
* containing object of IDynamicPerson.
@@ -285,7 +300,15 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
285300
attribute: 'people',
286301
type: Object
287302
})
288-
public people: IDynamicPerson[];
303+
public get people(): IDynamicPerson[] {
304+
return this._people;
305+
}
306+
public set people(value: IDynamicPerson[]) {
307+
if (!arraysAreEqual(this._people, value)) {
308+
this._people = value;
309+
this.requestStateUpdate(true);
310+
}
311+
}
289312

290313
/**
291314
* determining how many people to show in list.
@@ -295,7 +318,15 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
295318
attribute: 'show-max',
296319
type: Number
297320
})
298-
public showMax: number;
321+
public get showMax(): number {
322+
return this._showMax;
323+
}
324+
public set showMax(value: number) {
325+
if (value !== this._showMax) {
326+
this._showMax = value;
327+
this.requestStateUpdate(true);
328+
}
329+
}
299330

300331
/**
301332
* Sets whether the person image should be fetched
@@ -311,17 +342,25 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
311342
public disableImages: boolean;
312343

313344
/**
314-
* array of user picked people.
345+
* array of user picked people.
315346
* @type {IDynamicPerson[]}
316347
*/
317348
@property({
318349
attribute: 'selected-people',
319350
type: Array
320351
})
321-
public selectedPeople: IDynamicPerson[];
352+
public get selectedPeople(): IDynamicPerson[] {
353+
return this._selectedPeople;
354+
}
355+
public set selectedPeople(value: IDynamicPerson[]) {
356+
if (!value) value = [];
357+
if (!arraysAreEqual(this._selectedPeople, value)) {
358+
this._selectedPeople = value;
359+
}
360+
}
322361

323362
/**
324-
* array of people to be selected upon intialization
363+
* array of people to be selected upon initialization
325364
*
326365
* @type {string[]}
327366
* @memberof MgtPeoplePicker
@@ -333,10 +372,18 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
333372
},
334373
type: String
335374
})
336-
public defaultSelectedUserIds: string[];
375+
public get defaultSelectedUserIds(): string[] {
376+
return this._defaultSelectedUserIds;
377+
}
378+
public set defaultSelectedUserIds(value) {
379+
if (!arraysAreEqual(this._defaultSelectedUserIds, value)) {
380+
this._defaultSelectedUserIds = value;
381+
this.requestStateUpdate(true);
382+
}
383+
}
337384

338385
/**
339-
* array of groups to be selected upon intialization
386+
* array of groups to be selected upon initialization
340387
*
341388
* @type {string[]}
342389
* @memberof MgtPeoplePicker
@@ -348,7 +395,15 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
348395
},
349396
type: String
350397
})
351-
public defaultSelectedGroupIds: string[];
398+
public get defaultSelectedGroupIds(): string[] {
399+
return this._defaultSelectedGroupIds;
400+
}
401+
public set defaultSelectedGroupIds(value) {
402+
if (!arraysAreEqual(this._defaultSelectedGroupIds, value)) {
403+
this._defaultSelectedGroupIds = value;
404+
this.requestStateUpdate(true);
405+
}
406+
}
352407

353408
/**
354409
* Placeholder text.
@@ -398,7 +453,6 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
398453
})
399454
public selectionMode: string;
400455

401-
private _userIds: string[];
402456
/**
403457
* Array of the only users to be searched.
404458
*
@@ -495,8 +549,9 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
495549
protected userInput: string;
496550

497551
// if search is still loading don't load "people not found" state
498-
@property({ attribute: false }) private _showLoading: boolean;
552+
@state() private _showLoading: boolean;
499553

554+
private _userIds: string[];
500555
private _groupId: string;
501556
private _groupIds: string[];
502557
private _type: PersonType = PersonType.person;
@@ -505,6 +560,13 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
505560
private _userFilters: string;
506561
private _groupFilters: string;
507562
private _peopleFilters: string;
563+
private _defaultSelectedGroupIds: string[];
564+
private _defaultSelectedUserIds: string[];
565+
private _selectedPeople: IDynamicPerson[] = [];
566+
private _showMax: number;
567+
private _people: IDynamicPerson[];
568+
private _transitiveSearch: boolean;
569+
508570
private defaultPeople: IDynamicPerson[];
509571

510572
// tracking of user arrow key input for selection
@@ -688,7 +750,7 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
688750
* @memberof MgtPeoplePicker
689751
*/
690752
protected renderInput(): TemplateResult {
691-
const hasSelectedPeople = !!this.selectedPeople.length;
753+
const hasSelectedPeople = this.selectedPeople?.length > 0;
692754

693755
const placeholder = !this.disabled
694756
? this.placeholder
@@ -729,6 +791,7 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
729791
@focus="${this.gainedFocus}"
730792
@keydown="${this.onUserKeyDown}"
731793
@keyup="${this.onUserKeyUp}"
794+
@input="${this.onUserInput}"
732795
@blur=${this.lostFocus}
733796
?disabled=${this.disabled}
734797
/>
@@ -1071,7 +1134,7 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
10711134
}
10721135

10731136
if (
1074-
(this.defaultSelectedUserIds || this.defaultSelectedGroupIds) &&
1137+
(this.defaultSelectedUserIds?.length > 0 || this.defaultSelectedGroupIds?.length > 0) &&
10751138
!this.selectedPeople.length &&
10761139
!this.defaultSelectedUsers
10771140
) {
@@ -1168,7 +1231,7 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
11681231
}
11691232
}
11701233
} catch (e) {
1171-
// nop
1234+
// no-op
11721235
}
11731236
}
11741237
}
@@ -1184,7 +1247,9 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
11841247
this.groupType,
11851248
this.userFilters
11861249
);
1187-
} catch (_) {}
1250+
} catch (_) {
1251+
// no-op
1252+
}
11881253
} else {
11891254
let groups = [];
11901255
try {
@@ -1269,7 +1334,7 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
12691334
this.fireCustomEvent('selectionChanged', this.selectedPeople);
12701335
if (this.selectedPeople.length <= 0) this.showSearchIcon();
12711336

1272-
this.input.focus();
1337+
this.input?.focus();
12731338
}
12741339

12751340
/**
@@ -1365,7 +1430,6 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
13651430
const isPaste = (event.ctrlKey || event.metaKey) && event.key === 'v';
13661431
const isCmdOrCtrlKey = ['ControlLeft', 'ControlRight'].includes(event.code) || event.ctrlKey || event.metaKey;
13671432
const isArrowKey = ['ArrowDown', 'ArrowRight', 'ArrowUp', 'ArrowLeft'].includes(event.code);
1368-
const input = event.target as HTMLInputElement;
13691433

13701434
if ((!isPaste && isCmdOrCtrlKey) || isArrowKey) {
13711435
if (isCmdOrCtrlKey || ['ArrowLeft', 'ArrowRight'].includes(event.code)) {
@@ -1426,17 +1490,22 @@ export class MgtPeoplePicker extends MgtTemplatedComponent {
14261490
}
14271491
return;
14281492
}
1493+
}
14291494

1495+
private onUserInput(event: InputEvent) {
1496+
const input = event.target as HTMLInputElement;
14301497
this.userInput = input.value;
1431-
const validEmail = isValidEmail(this.userInput);
1432-
if (validEmail && this.allowAnyEmail) {
1433-
if (this._setAnyEmail) {
1434-
this.handleAnyEmail();
1498+
if (this.userInput) {
1499+
const validEmail = isValidEmail(this.userInput);
1500+
if (validEmail && this.allowAnyEmail) {
1501+
if (this._setAnyEmail) {
1502+
this.handleAnyEmail();
1503+
}
1504+
} else {
1505+
this.handleUserSearch();
14351506
}
1436-
} else {
1437-
this.handleUserSearch();
1507+
this._setAnyEmail = false;
14381508
}
1439-
this._setAnyEmail = false;
14401509
}
14411510

14421511
private handleAnyEmail() {

packages/mgt/src/bundle/mgt-loader.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@
88
(function () {
99
'use strict';
1010

11+
var loaderScript = document.querySelector('script[src*="mgt-loader.js"]');
12+
if (
13+
loaderScript &&
14+
loaderScript.src.indexOf('unpkg.com/@microsoft/mgt') > 0 &&
15+
loaderScript.src.indexOf('/mgt@') === -1
16+
) {
17+
console.warn(
18+
'You have loaded the mgt-loader script from unpkg without using a semver range or tag.\n',
19+
'This could break your application when new major versions are released\n',
20+
'Please update your application to use a mgt-loader with a semver range tag e.g. https://unpkg.com/@microsoft/mgt@2/dist/bundle/mgt-loader.js'
21+
);
22+
}
23+
1124
var rootPath = getScriptPath();
1225

1326
// decide es5 or es6

samples/angular-app/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ npm-debug.log
4141
yarn-error.log
4242
testem.log
4343
/typings
44+
package-lock.json
4445

4546
# System Files
4647
.DS_Store

0 commit comments

Comments
 (0)