Skip to content

Commit 56d4f03

Browse files
author
Ben Grynhaus
committed
prettier formatting
1 parent d60a1c3 commit 56d4f03

File tree

75 files changed

+632
-354
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

75 files changed

+632
-354
lines changed

.prettierrc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"singleQuote": true,
3-
"printWidth": 120
4-
}
3+
"printWidth": 120,
4+
"trailingComma": "es5"
5+
}

libs/core/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/core/public-api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ export * from './src/components/wrapper-component';
33
export { ReactContent } from './src/renderer/react-content';
44
export { registerElement } from './src/renderer/registry';
55
export { passProp, getPassProps, PassProp } from './src/renderer/pass-prop-decorator';
6-
export * from './src/renderer/components/Disguise'
6+
export * from './src/renderer/components/Disguise';

libs/core/src/components/wrapper-component.ts

Lines changed: 50 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1-
import { AfterViewInit, ComponentFactoryResolver, ComponentRef, ElementRef, Injector, TemplateRef, Type, ChangeDetectorRef, OnChanges, SimpleChanges, HostBinding, Input } from "@angular/core";
2-
import { isReactNode } from "../renderer/react-node";
3-
import { renderComponent, renderFunc, renderTemplate } from "../renderer/renderprop-helpers";
4-
import { unreachable } from "../utils/types/unreachable";
1+
import {
2+
AfterViewInit,
3+
ComponentFactoryResolver,
4+
ComponentRef,
5+
ElementRef,
6+
Injector,
7+
TemplateRef,
8+
Type,
9+
ChangeDetectorRef,
10+
OnChanges,
11+
SimpleChanges,
12+
HostBinding,
13+
Input
14+
} from '@angular/core';
15+
import { isReactNode } from '../renderer/react-node';
16+
import { renderComponent, renderFunc, renderTemplate } from '../renderer/renderprop-helpers';
17+
import { unreachable } from '../utils/types/unreachable';
518
import toStyle from 'css-to-style';
619

720
type PropMapper = (value: any) => [string, any];
@@ -14,9 +27,7 @@ const forbiddenAttributesAsProps: ReadonlyArray<AttributeNameAlternative> = [
1427
['style', 'rStyle'],
1528
];
1629

17-
const ignoredAttributeMatchers = [
18-
/^_?ng-?.*/
19-
];
30+
const ignoredAttributeMatchers = [/^_?ng-?.*/];
2031

2132
const ngClassRegExp = /^ng-/;
2233

@@ -27,7 +38,7 @@ export interface RenderComponentOptions<TContext extends object> {
2738
}
2839

2940
export type InputRendererOptions<TContext extends object> =
30-
TemplateRef<TContext>
41+
| TemplateRef<TContext>
3142
| ((context: TContext) => HTMLElement)
3243
| ComponentRef<TContext>
3344
| RenderComponentOptions<TContext>;
@@ -40,17 +51,18 @@ export type JsxRenderFunc<TContext> = (context: TContext) => JSX.Element;
4051
*/
4152
// NOTE: TProps is not used at the moment, but a preparation for a potential future change.
4253
export abstract class ReactWrapperComponent<TProps extends {}> implements AfterViewInit, OnChanges {
43-
4454
protected abstract reactNodeRef: ElementRef;
4555

46-
@Input() set rClass(value: string) {
56+
@Input()
57+
set rClass(value: string) {
4758
if (isReactNode(this.reactNodeRef.nativeElement)) {
4859
this.reactNodeRef.nativeElement.setProperty('className', value);
4960
this.changeDetectorRef.detectChanges();
5061
}
5162
}
5263

53-
@Input() set rStyle(value: string) {
64+
@Input()
65+
set rStyle(value: string) {
5466
if (isReactNode(this.reactNodeRef.nativeElement)) {
5567
this.reactNodeRef.nativeElement.setProperty('style', toStyle(value));
5668
this.changeDetectorRef.detectChanges();
@@ -62,7 +74,11 @@ export abstract class ReactWrapperComponent<TProps extends {}> implements AfterV
6274
* @param elementRef The host element.
6375
* @param setHostDisplay Whether the host's `display` should be set to the root child node's `display`. defaults to `false`
6476
*/
65-
constructor(public readonly elementRef: ElementRef, private readonly changeDetectorRef: ChangeDetectorRef, private readonly setHostDisplay: boolean = false) { }
77+
constructor(
78+
public readonly elementRef: ElementRef,
79+
private readonly changeDetectorRef: ChangeDetectorRef,
80+
private readonly setHostDisplay: boolean = false
81+
) { }
6682

6783
ngAfterViewInit() {
6884
this._passAttributesAsProps();
@@ -90,7 +106,9 @@ export abstract class ReactWrapperComponent<TProps extends {}> implements AfterV
90106
* Create an JSX renderer for an `@Input` property.
91107
* @param input The input property
92108
*/
93-
protected createInputJsxRenderer<TContext extends object>(input: InputRendererOptions<TContext>): JsxRenderFunc<TContext> | undefined {
109+
protected createInputJsxRenderer<TContext extends object>(
110+
input: InputRendererOptions<TContext>
111+
): JsxRenderFunc<TContext> | undefined {
94112
if (input === undefined) {
95113
return undefined;
96114
}
@@ -107,7 +125,7 @@ export abstract class ReactWrapperComponent<TProps extends {}> implements AfterV
107125
return (context: TContext) => renderFunc(input, context);
108126
}
109127

110-
if (typeof input === "object") {
128+
if (typeof input === 'object') {
111129
const { componentType, factoryResolver, injector } = input;
112130
const componentFactory = factoryResolver.resolveComponentFactory(componentType);
113131
const componentRef = componentFactory.create(injector);
@@ -123,7 +141,10 @@ export abstract class ReactWrapperComponent<TProps extends {}> implements AfterV
123141
* @param renderInputValue the value of the render `@Input` property.
124142
* @param jsxRenderer an optional renderer to use.
125143
*/
126-
protected createRenderPropHandler<TProps extends object>(renderInputValue: InputRendererOptions<TProps>, jsxRenderer?: JsxRenderFunc<TProps>): (props?: TProps, defaultRender?: JsxRenderFunc<TProps>) => JSX.Element | null {
144+
protected createRenderPropHandler<TProps extends object>(
145+
renderInputValue: InputRendererOptions<TProps>,
146+
jsxRenderer?: JsxRenderFunc<TProps>
147+
): (props?: TProps, defaultRender?: JsxRenderFunc<TProps>) => JSX.Element | null {
127148
const renderer = jsxRenderer || this.createInputJsxRenderer(renderInputValue);
128149

129150
return (props?: TProps, defaultRender?: JsxRenderFunc<TProps>) => {
@@ -136,9 +157,7 @@ export abstract class ReactWrapperComponent<TProps extends {}> implements AfterV
136157
}
137158

138159
private _passAttributesAsProps() {
139-
const hostAttributes = Array.from(
140-
(this.elementRef.nativeElement as HTMLElement).attributes
141-
);
160+
const hostAttributes = Array.from((this.elementRef.nativeElement as HTMLElement).attributes);
142161

143162
if (!this.reactNodeRef || !isReactNode(this.reactNodeRef.nativeElement)) {
144163
throw new Error('reactNodeRef must hold a reference to a ReactNode');
@@ -148,15 +167,23 @@ export abstract class ReactWrapperComponent<TProps extends {}> implements AfterV
148167
hostAttributes.forEach(attr => {
149168
const [forbidden, alternativeAttrName] = this._isForbiddenAttribute(attr);
150169
if (forbidden) {
151-
throw new Error(`[${(this.elementRef.nativeElement as HTMLElement).tagName.toLowerCase()}] React wrapper components cannot have the '${attr.name}' attribute set. Use the following alternative: ${alternativeAttrName || ''}`);
170+
throw new Error(
171+
`[${(this.elementRef
172+
.nativeElement as HTMLElement).tagName.toLowerCase()}] React wrapper components cannot have the '${
173+
attr.name
174+
}' attribute set. Use the following alternative: ${alternativeAttrName || ''}`
175+
);
152176
}
153177
});
154178

155179
const whitelistedHostAttributes = hostAttributes.filter(attr => !this._isIgnoredAttribute(attr));
156-
const props = whitelistedHostAttributes.reduce((acc, attr) => ({
157-
...acc,
158-
[attr.name]: attr.value,
159-
}), {});
180+
const props = whitelistedHostAttributes.reduce(
181+
(acc, attr) => ({
182+
...acc,
183+
[attr.name]: attr.value,
184+
}),
185+
{}
186+
);
160187

161188
this.reactNodeRef.nativeElement.setProperties(props);
162189
}

libs/core/src/utils/object/remove-undefined-properties.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const clearUndefinedProperties = <T extends object>(obj: T): Partial<T> => {
33
const _acc = acc;
44
if (obj[key] !== undefined) _acc[key] = obj[key];
55
return _acc;
6-
}, {})
7-
}
6+
}, {});
7+
};
88

99
export default clearUndefinedProperties;

libs/fabric/package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

libs/fabric/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
],
6363
"private": false,
6464
"peerDependencies": {
65-
"@angular-react/core": "^0.2.0",
65+
"@angular-react/core": "^0.2.1",
6666
"@angular/common": "^5.2.7",
6767
"@angular/core": "^5.2.7",
6868
"@angular/platform-browser-dynamic": "^5.2.7",

libs/fabric/src/components/breadcrumb/breadcrumb.component.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
import { InputRendererOptions, JsxRenderFunc, ReactWrapperComponent } from '@angular-react/core';
2-
import { ChangeDetectionStrategy, Component, ElementRef, Input, OnInit, ViewChild, ChangeDetectorRef } from '@angular/core';
2+
import {
3+
ChangeDetectionStrategy,
4+
Component,
5+
ElementRef,
6+
Input,
7+
OnInit,
8+
ViewChild,
9+
ChangeDetectorRef,
10+
} from '@angular/core';
311
import { IBreadcrumbItem, IBreadcrumbProps } from 'office-ui-fabric-react/lib/Breadcrumb';
412

513
@Component({
@@ -24,7 +32,7 @@ import { IBreadcrumbItem, IBreadcrumbProps } from 'office-ui-fabric-react/lib/Br
2432
</Breadcrumb>
2533
`,
2634
styles: ['react-renderer'],
27-
changeDetection: ChangeDetectionStrategy.OnPush
35+
changeDetection: ChangeDetectionStrategy.OnPush,
2836
})
2937
export class FabBreadcrumbComponent extends ReactWrapperComponent<IBreadcrumbProps> implements OnInit {
3038
@ViewChild('reactNode') protected reactNodeRef: ElementRef;

libs/fabric/src/components/breadcrumb/breadcrumb.module.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,17 @@ import { NgModule, NO_ERRORS_SCHEMA } from '@angular/core';
44
import { Breadcrumb } from 'office-ui-fabric-react/lib/Breadcrumb';
55
import { FabBreadcrumbComponent } from './breadcrumb.component';
66

7-
const components = [
8-
FabBreadcrumbComponent,
9-
];
7+
const components = [FabBreadcrumbComponent];
108

119
@NgModule({
1210
imports: [CommonModule],
1311
declarations: components,
1412
exports: components,
15-
schemas: [NO_ERRORS_SCHEMA]
13+
schemas: [NO_ERRORS_SCHEMA],
1614
})
1715
export class FabBreadcrumbModule {
18-
1916
constructor() {
2017
// Add any React elements to the registry (used by the renderer).
2118
registerElement('Breadcrumb', () => Breadcrumb);
2219
}
23-
2420
}

libs/fabric/src/components/button/action-button.component.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,9 @@ import { FabBaseButtonComponent } from './base-button.component';
5151
changeDetection: ChangeDetectionStrategy.OnPush,
5252
})
5353
export class FabActionButtonComponent extends FabBaseButtonComponent {
54-
5554
@ViewChild('reactNode') reactNodeRef: ElementRef;
5655

5756
constructor(elementRef: ElementRef, changeDetectorRef: ChangeDetectorRef) {
5857
super(elementRef, changeDetectorRef);
5958
}
60-
6159
}

0 commit comments

Comments
 (0)