Skip to content

Commit daaedab

Browse files
nmetulevbeth-panx
andauthored
Removed deprecated properties (#781)
* removed deprecated properties * Removed show-name and show-email from samples * fixed build Co-authored-by: Beth Pan <[email protected]>
1 parent b3a50b9 commit daaedab

File tree

13 files changed

+103
-198
lines changed

13 files changed

+103
-198
lines changed

packages/mgt-components/src/components/mgt-person-card/mgt-person-card.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,6 @@ export class MgtPersonCard extends MgtTemplatedComponent {
289289

290290
constructor() {
291291
super();
292-
this.handleLocalizationChanged();
293292
this._chatInput = '';
294293
this._currentSection = null;
295294
this._history = [];

packages/mgt-components/src/components/mgt-person-card/sections/BasePersonCardSection.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@ export abstract class BasePersonCardSection extends MgtTemplatedComponent {
7070
super();
7171
this._isCompact = false;
7272
this._personDetails = null;
73-
this.handleLocalizationChanged();
7473
}
7574

7675
/**

packages/mgt-components/src/components/mgt-person-card/sections/mgt-person-card-organization/mgt-person-card-organization.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ export class MgtPersonCardOrganization extends BasePersonCardSection {
3232
return styles;
3333
}
3434

35+
/**
36+
* returns component strings
37+
*
38+
* @readonly
39+
* @protected
40+
* @memberof MgtBaseComponent
41+
*/
3542
protected get strings() {
3643
return strings;
3744
}

packages/mgt-components/src/components/mgt-person/mgt-person.ts

Lines changed: 53 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -770,10 +770,7 @@ export class MgtPerson extends MgtTemplatedComponent {
770770
const graph = provider.graph.forComponent(this);
771771

772772
if (this.personDetails) {
773-
if (
774-
!this.personDetails.personImage &&
775-
((this.fetchImage && !this.personImage && !this._fetchedImage) || this.personImage === '@')
776-
) {
773+
if (!this.personDetails.personImage && (this.fetchImage && !this.personImage && !this._fetchedImage)) {
777774
const image = await getPersonImage(graph, this.personDetails, MgtPerson.config.useContactApis);
778775
if (image) {
779776
this.personDetails.personImage = image;
@@ -823,19 +820,6 @@ export class MgtPerson extends MgtTemplatedComponent {
823820
}
824821
}
825822

826-
private getImage(): string {
827-
if (this.personImage && this.personImage !== '@') {
828-
return this.personImage;
829-
}
830-
831-
if (this._fetchedImage) {
832-
return this._fetchedImage;
833-
}
834-
835-
const person = this.personDetails;
836-
return person && person.personImage ? person.personImage : null;
837-
}
838-
839823
/**
840824
* Gets the user initials
841825
*
@@ -872,6 +856,58 @@ export class MgtPerson extends MgtTemplatedComponent {
872856
return initials;
873857
}
874858

859+
/**
860+
* Gets color from name
861+
*
862+
* @protected
863+
* @param {string} name
864+
* @returns {string}
865+
* @memberof MgtPerson
866+
*/
867+
protected getColorFromName(name: string): string {
868+
const charCodes = name
869+
.split('')
870+
.map(char => char.charCodeAt(0))
871+
.join('');
872+
const nameInt = parseInt(charCodes, 10);
873+
const colors = [
874+
'pinkRed10',
875+
'red20',
876+
'red10',
877+
'orange20',
878+
'orangeYellow20',
879+
'green10',
880+
'green20',
881+
'cyan20',
882+
'cyan30',
883+
'cyanBlue10',
884+
'cyanBlue20',
885+
'blue10',
886+
'blueMagenta30',
887+
'blueMagenta20',
888+
'magenta20',
889+
'magenta10',
890+
'magentaPink10',
891+
'orange30',
892+
'gray30',
893+
'gray20'
894+
];
895+
return colors[nameInt % colors.length];
896+
}
897+
898+
private getImage(): string {
899+
if (this.personImage) {
900+
return this.personImage;
901+
}
902+
903+
if (this._fetchedImage) {
904+
return this._fetchedImage;
905+
}
906+
907+
const person = this.personDetails;
908+
return person && person.personImage ? person.personImage : null;
909+
}
910+
875911
private isLetter(char: string) {
876912
try {
877913
return char.match(new RegExp('\\p{L}', 'u'));
@@ -954,43 +990,4 @@ export class MgtPerson extends MgtTemplatedComponent {
954990
flyout.isOpen = true;
955991
}
956992
}
957-
958-
/**
959-
* Gets color from name
960-
*
961-
* @protected
962-
* @param {string} name
963-
* @returns {string}
964-
* @memberof MgtPerson
965-
*/
966-
protected getColorFromName(name: string): string {
967-
const charCodes = name
968-
.split('')
969-
.map(char => char.charCodeAt(0))
970-
.join('');
971-
const nameInt = parseInt(charCodes, 10);
972-
const colors = [
973-
'pinkRed10',
974-
'red20',
975-
'red10',
976-
'orange20',
977-
'orangeYellow20',
978-
'green10',
979-
'green20',
980-
'cyan20',
981-
'cyan30',
982-
'cyanBlue10',
983-
'cyanBlue20',
984-
'blue10',
985-
'blueMagenta30',
986-
'blueMagenta20',
987-
'magenta20',
988-
'magenta10',
989-
'magentaPink10',
990-
'orange30',
991-
'gray30',
992-
'gray20'
993-
];
994-
return colors[nameInt % colors.length];
995-
}
996993
}

packages/mgt-element/src/components/baseComponent.ts

Lines changed: 14 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export enum ComponentMediaQuery {
2222
mobile = '',
2323

2424
/**
25-
* devies with width < 1200
25+
* devices with width < 1200
2626
*/
2727
tablet = 'tablet',
2828

@@ -33,7 +33,7 @@ export enum ComponentMediaQuery {
3333
}
3434

3535
/**
36-
* BaseComponent extends LitElement including ShadowRoot toggle and fireCustomEvent features
36+
* BaseComponent extends LitElement adding mgt specific features to all components
3737
*
3838
* @export MgtBaseComponent
3939
* @abstract
@@ -49,26 +49,6 @@ export abstract class MgtBaseComponent extends LitElement {
4949
*/
5050
@internalProperty() protected direction = 'ltr';
5151

52-
/**
53-
* Get ShadowRoot toggle, returns value of _useShadowRoot
54-
*
55-
* @static _useShadowRoot
56-
* @memberof MgtBaseComponent
57-
*/
58-
public static get useShadowRoot() {
59-
return this._useShadowRoot;
60-
}
61-
62-
/**
63-
* Set ShadowRoot toggle value
64-
*
65-
* @static _useShadowRoot
66-
* @memberof MgtBaseComponent
67-
*/
68-
public static set useShadowRoot(value: boolean) {
69-
this._useShadowRoot = value;
70-
}
71-
7252
/**
7353
* Gets the ComponentMediaQuery of the component
7454
*
@@ -108,8 +88,6 @@ export abstract class MgtBaseComponent extends LitElement {
10888
return this._isFirstUpdated;
10989
}
11090

111-
private static _useShadowRoot: boolean = true;
112-
11391
/**
11492
* returns component strings
11593
*
@@ -132,12 +110,10 @@ export abstract class MgtBaseComponent extends LitElement {
132110

133111
constructor() {
134112
super();
135-
if (this.isShadowRootDisabled()) {
136-
(this as any)._needsShimAdoptedStyleSheets = true;
137-
}
138113
this.handleLocalizationChanged = this.handleLocalizationChanged.bind(this);
139-
this.updateDirection = this.updateDirection.bind(this);
140-
this.updateDirection();
114+
this.handleDirectionChanged = this.handleDirectionChanged.bind(this);
115+
this.handleDirectionChanged();
116+
this.handleLocalizationChanged();
141117
}
142118

143119
/**
@@ -148,39 +124,18 @@ export abstract class MgtBaseComponent extends LitElement {
148124
public connectedCallback() {
149125
super.connectedCallback();
150126
LocalizationHelper.onStringsUpdated(this.handleLocalizationChanged);
151-
LocalizationHelper.onDirectionUpdated(this.updateDirection);
127+
LocalizationHelper.onDirectionUpdated(this.handleDirectionChanged);
152128
}
153129

154130
/**
155-
* Invoked each time the custom element is removed from the document
131+
* Invoked each time the custom element is removed from a document-connected element
156132
*
157133
* @memberof MgtBaseComponent
158134
*/
159135
public disconnectedCallback() {
160136
super.disconnectedCallback();
161137
LocalizationHelper.removeOnStringsUpdated(this.handleLocalizationChanged);
162-
LocalizationHelper.removeOnDirectionUpdated(this.updateDirection);
163-
}
164-
165-
/**
166-
* Request localization changes when the 'strings' event is detected
167-
*
168-
* @protected
169-
* @memberof MgtBaseComponent
170-
*/
171-
protected handleLocalizationChanged() {
172-
this.requestUpdate();
173-
LocalizationHelper.updateStringsForTag(this.tagName, this.strings);
174-
}
175-
176-
/**
177-
* Receive ShadowRoot Disabled value
178-
*
179-
* @returns boolean _useShadowRoot value
180-
* @memberof MgtBaseComponent
181-
*/
182-
public isShadowRootDisabled() {
183-
return !MgtBaseComponent._useShadowRoot || !(this.constructor as typeof MgtBaseComponent)._useShadowRoot;
138+
LocalizationHelper.removeOnDirectionUpdated(this.handleDirectionChanged);
184139
}
185140

186141
/**
@@ -232,17 +187,6 @@ export abstract class MgtBaseComponent extends LitElement {
232187
return this.dispatchEvent(event);
233188
}
234189

235-
/**
236-
* method to create ShadowRoot if disabled flag isn't present
237-
*
238-
* @protected
239-
* @returns boolean
240-
* @memberof MgtBaseComponent
241-
*/
242-
protected createRenderRoot() {
243-
return this.isShadowRootDisabled() ? this : super.createRenderRoot();
244-
}
245-
246190
/**
247191
* Invoked whenever the element is updated. Implement to perform
248192
* post-updating tasks via DOM APIs, for example, focusing an element.
@@ -313,13 +257,12 @@ export abstract class MgtBaseComponent extends LitElement {
313257
this.requestUpdate('isLoadingState');
314258
}
315259

316-
/**
317-
* Adds rtl attribute to component if direction is returned rtl
318-
*
319-
* @private
320-
* @memberof MgtBaseComponent
321-
*/
322-
protected updateDirection() {
260+
private handleLocalizationChanged() {
261+
LocalizationHelper.updateStringsForTag(this.tagName, this.strings);
262+
this.requestUpdate();
263+
}
264+
265+
private handleDirectionChanged() {
323266
this.direction = LocalizationHelper.getDocumentDirection();
324267
}
325268
}

packages/mgt-element/src/components/templatedComponent.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66
*/
77

88
import { html, PropertyValues } from 'lit-element';
9-
import { TemplateContext } from '../utils/TemplateContext';
9+
1010
import { equals } from '../utils/equals';
1111
import { MgtBaseComponent } from './baseComponent';
12+
import { TemplateContext } from '../utils/TemplateContext';
1213
import { TemplateHelper } from '../utils/TemplateHelper';
1314

1415
/**
@@ -36,15 +37,6 @@ interface RenderedTemplates {
3637
* @extends {MgtBaseComponent}
3738
*/
3839
export abstract class MgtTemplatedComponent extends MgtBaseComponent {
39-
/**
40-
* Collection of functions to be used in template binding
41-
*
42-
* @type {MgtElement.TemplateContext}
43-
* @memberof MgtTemplatedComponent
44-
* @deprecated since 1.2 - use templateContext instead
45-
*/
46-
public templateConverters: TemplateContext;
47-
4840
/**
4941
* Additional data context to be used in template binding
5042
* Use this to add event listeners or value converters
@@ -70,10 +62,6 @@ export abstract class MgtTemplatedComponent extends MgtBaseComponent {
7062
super();
7163

7264
this.templateContext = this.templateContext || {};
73-
this.templateConverters = this.templateConverters || {};
74-
75-
this.templateContext.lower = (str: string) => str.toLowerCase();
76-
this.templateContext.upper = (str: string) => str.toUpperCase();
7765
}
7866

7967
/**
@@ -137,7 +125,6 @@ export abstract class MgtTemplatedComponent extends MgtBaseComponent {
137125
div.dataset.generated = 'template';
138126

139127
TemplateHelper.renderTemplate(div, this.templates[templateType], context, {
140-
...this.templateConverters,
141128
...this.templateContext
142129
});
143130

0 commit comments

Comments
 (0)