Skip to content

Commit e3b2d7d

Browse files
chore(bump): add strict mode to demo application (#6217)
1 parent 51808da commit e3b2d7d

File tree

141 files changed

+493
-345
lines changed

Some content is hidden

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

141 files changed

+493
-345
lines changed

apps/ngx-bootstrap-docs/src/assets/css/bootstrap-3.3.7/css/bootstrap.min.css.map

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

libs/common-docs/src/lib/api-docs/analytics/analytics.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,15 @@ export class Analytics {
4949
/**
5050
* Sends an event.
5151
*/
52-
trackEvent(action: string, category: string): void {
52+
trackEvent(action: string, category?: string): void {
5353
if (!this.enabled) {
5454
return;
5555
}
56+
57+
if (!category) {
58+
return;
59+
}
60+
5661
if (typeof ga !== 'undefined') {
5762
ga('send', {
5863
hitType: 'event',

libs/common-docs/src/lib/api-docs/api-doc-class/api-doc-class.component.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<div class="api-doc-component" (click)="trackSourceClick()">
22
<h3 [attr.id]="headerAnchor">
3-
<a href="https://github.com/valor-software/ngx-bootstrap/tree/development/{{apiDocs.fileName}}"
4-
target="_blank" rel="noopener">{{apiDocs.className}}</a>
3+
<a href="https://github.com/valor-software/ngx-bootstrap/tree/development/{{apiDocs?.fileName}}"
4+
target="_blank" rel="noopener">{{apiDocs?.className}}</a>
55
</h3>
6-
<p [innerHTML]="apiDocs.description"></p>
6+
<p [innerHTML]="apiDocs?.description"></p>
77

8-
<ng-template [ngIf]="apiDocs.properties && apiDocs.properties.length">
8+
<ng-template [ngIf]="apiDocs?.properties && apiDocs?.properties?.length">
99
<section>
1010
<h3>Properties</h3>
1111
<table class="table table-bordered">
1212
<tbody>
13-
<tr *ngFor="let prop of apiDocs.properties">
13+
<tr *ngFor="let prop of apiDocs?.properties">
1414
<td class="col-xs-3"><code>{{prop.name}}</code></td>
1515
<td class="col-xs-9">
1616
<div><i>Type: </i><code>{{ prop.type }}</code></div>
@@ -25,12 +25,12 @@ <h3>Properties</h3>
2525
</section>
2626
</ng-template>
2727

28-
<ng-template [ngIf]="apiDocs.methods && apiDocs.methods.length">
28+
<ng-template [ngIf]="apiDocs?.methods && apiDocs?.methods?.length">
2929
<section>
3030
<h3 id="methods">Methods</h3>
3131
<table class="table table-bordered">
3232
<tbody>
33-
<tr *ngFor="let method of apiDocs.methods">
33+
<tr *ngFor="let method of apiDocs?.methods">
3434
<td class="col-xs-3"><code>{{method.name}}</code></td>
3535
<td class="col-xs-9">
3636
<div><i>Signature: </i><code>{{ methodSignature(method) }}</code>

libs/common-docs/src/lib/api-docs/api-doc-class/api-doc-class.component.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { ComponentApi } from '../../models/components-api.model';
2020
})
2121
export class NgApiDocClassComponent {
2222
headerAnchor?: string;
23-
apiDocs: ClassDesc;
23+
apiDocs?: ClassDesc;
2424

2525
private analytics: Analytics;
2626
private docs: NgApiDoc;
@@ -30,14 +30,16 @@ export class NgApiDocClassComponent {
3030
this.analytics = analytics;
3131

3232
this.headerAnchor = content.anchor;
33-
this.apiDocs = this.docs[content.title];
33+
if (content?.title) {
34+
this.apiDocs = this.docs[content.title];
35+
}
3436
}
3537

3638
methodSignature(method: MethodDesc): string {
3739
return signature(method);
3840
}
3941

4042
trackSourceClick(): void {
41-
this.analytics.trackEvent('Source File View', this.apiDocs.className);
43+
this.analytics.trackEvent('Source File View', this.apiDocs?.className);
4244
}
4345
}

libs/common-docs/src/lib/api-docs/api-doc-config/api-doc-config.component.html

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
<div (click)="trackSourceClick()" class="api-doc-component">
22
<h3 [attr.id]="headerAnchor">
3-
<a href="https://github.com/valor-software/ngx-bootstrap/tree/development/{{ apiDocs.fileName }}"
4-
target="_blank" rel="noopener">{{ apiDocs.className }}</a>
3+
<a href="https://github.com/valor-software/ngx-bootstrap/tree/development/{{ apiDocs?.fileName }}"
4+
target="_blank" rel="noopener">{{ apiDocs?.className }}</a>
55
</h3>
6-
<p [innerHTML]="apiDocs.description"></p>
6+
<p [innerHTML]="apiDocs?.description"></p>
77

8-
<ng-template [ngIf]="apiDocs.properties && apiDocs.properties.length">
8+
<ng-template [ngIf]="apiDocs?.properties && apiDocs?.properties?.length">
99
<section>
1010
<h3>Properties</h3>
1111
<table class="table table-bordered">
1212
<tbody>
13-
<tr *ngFor="let prop of apiDocs.properties">
13+
<tr *ngFor="let prop of apiDocs?.properties">
1414
<td class="col-xs-3"><code>{{ prop.name }}</code></td>
1515
<td class="col-xs-9">
1616
<div><i>Type: </i><code>{{ prop.type }}</code></div>
@@ -25,12 +25,12 @@ <h3>Properties</h3>
2525
</section>
2626
</ng-template>
2727

28-
<ng-template [ngIf]="apiDocs.methods && apiDocs.methods.length && this.isShowMethods">
28+
<ng-template [ngIf]="apiDocs?.methods && apiDocs?.methods?.length && this.isShowMethods">
2929
<section>
3030
<h3>Methods</h3>
3131
<table class="table table-bordered">
3232
<tbody>
33-
<tr *ngFor="let method of apiDocs.methods">
33+
<tr *ngFor="let method of apiDocs?.methods">
3434
<td class="col-xs-3"><code>{{ method.name }}</code></td>
3535
<td class="col-xs-9">
3636
<div>

libs/common-docs/src/lib/api-docs/api-doc-config/api-doc-config.component.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const CONFIG_SUFFIX_LENGTH = 'Config'.length;
2424
templateUrl: './api-doc-config.component.html'
2525
})
2626
export class NgApiDocConfigComponent {
27-
apiDocs: ClassDesc;
27+
apiDocs?: ClassDesc;
2828
directiveName?: string;
2929
headerAnchor?: string;
3030
isShowMethods = false;
@@ -37,12 +37,14 @@ export class NgApiDocConfigComponent {
3737
this.docs = docs;
3838

3939
this.headerAnchor = content.anchor;
40-
this.apiDocs = this.docs[content.title];
40+
if (content?.title) {
41+
this.apiDocs = this.docs[content.title];
42+
}
4143
this.isShowMethods = content.showMethods || this.isShowMethods;
4244
this.directiveName = content.title?.slice(0, -CONFIG_SUFFIX_LENGTH);
4345
}
4446

4547
trackSourceClick(): void {
46-
this.analytics.trackEvent('Source File View', this.apiDocs.className);
48+
this.analytics.trackEvent('Source File View', this.apiDocs?.className);
4749
}
4850
}

libs/common-docs/src/lib/api-docs/api-doc/api-doc.component.html

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
11
<div (click)="trackSourceClick()" class="api-doc-component">
22
<h3 [attr.id]="headerAnchor">
3-
<a href="https://github.com/valor-software/ngx-bootstrap/tree/development/{{ apiDocs.fileName }}"
4-
target="_blank" rel="noopener">{{ apiDocs.className }}</a>
3+
<a href="https://github.com/valor-software/ngx-bootstrap/tree/development/{{ apiDocs?.fileName }}"
4+
target="_blank" rel="noopener">{{ apiDocs?.className }}</a>
55
</h3>
6-
<p [innerHTML]="apiDocs.description"></p>
6+
<p [innerHTML]="apiDocs?.descriptionSafeHtML"></p>
77

88
<div class="table-responsive">
99
<table class="table table-bordered">
1010
<tbody>
1111
<tr>
1212
<td class="col-xs-3">Selector</td>
13-
<td class="col-xs-9"><code>{{ apiDocs.selector }}</code></td>
13+
<td class="col-xs-9"><code>{{ apiDocs?.selector }}</code></td>
1414
</tr>
15-
<tr *ngIf="apiDocs.exportAs">
15+
<tr *ngIf="apiDocs?.exportAs">
1616
<td class="col-xs-3">Exported as</td>
17-
<td class="col-xs-9"><code>{{ apiDocs.exportAs }}</code></td>
17+
<td class="col-xs-9"><code>{{ apiDocs?.exportAs }}</code></td>
1818
</tr>
1919
</tbody>
2020
</table>
2121
</div>
2222

23-
<ng-template [ngIf]="apiDocs.inputs.length">
23+
<ng-template [ngIf]="apiDocs?.inputs?.length">
2424
<section>
2525
<h3>Inputs</h3>
2626
<div class="table-responsive">
2727
<table class="table table-bordered">
2828
<tbody>
29-
<tr *ngFor="let input of apiDocs.inputs">
29+
<tr *ngFor="let input of apiDocs?.inputs">
3030
<td class="col-xs-3"><code>{{ input.name }}</code></td>
3131
<td class="col-xs-9">
3232
<div><i>Type: </i><code>{{ input.type }}</code></div>
@@ -36,7 +36,7 @@ <h3>Inputs</h3>
3636
<span *ngIf="hasConfigProperty(input)">&mdash; initialized from {{ configServiceName }} service</span>
3737
</div>
3838
</ng-template>
39-
<div [innerHTML]="input.description"></div>
39+
<div [innerHTML]="input.descriptionSafeHtml"></div>
4040
</td>
4141
</tr>
4242
</tbody>
@@ -45,34 +45,34 @@ <h3>Inputs</h3>
4545
</section>
4646
</ng-template>
4747

48-
<ng-template [ngIf]="apiDocs.outputs.length">
48+
<ng-template [ngIf]="apiDocs?.outputs?.length">
4949
<section>
5050
<h3 id="outputs">Outputs</h3>
5151
<div class="table-responsive">
5252
<table class="table table-bordered">
5353
<tbody>
54-
<tr *ngFor="let output of apiDocs.outputs">
54+
<tr *ngFor="let output of apiDocs?.outputs">
5555
<td class="col-xs-3"><code>{{ output.name }}</code></td>
56-
<td class="col-xs-9"><div [innerHTML]="output.description"></div></td>
56+
<td class="col-xs-9"><div [innerHTML]="output.descriptionSafeHtml"></div></td>
5757
</tr>
5858
</tbody>
5959
</table>
6060
</div>
6161
</section>
6262
</ng-template>
6363

64-
<ng-template [ngIf]="apiDocs.methods.length && apiDocs.exportAs">
64+
<ng-template [ngIf]="apiDocs?.methods?.length && apiDocs?.exportAs">
6565
<section>
6666
<h3 id="methods">Methods</h3>
6767
<div class="table-responsive">
6868
<table class="table table-bordered">
6969
<tbody>
70-
<tr *ngFor="let method of apiDocs.methods">
70+
<tr *ngFor="let method of apiDocs?.methods">
7171
<td class="col-xs-3"><code>{{ method.name }}</code></td>
7272
<td class="col-xs-9">
7373
<div><i>Signature: </i><code>{{ methodSignature(method) }}</code></div>
7474
<div><i>Return type: </i><code>{{ method.returnType }}</code></div>
75-
<div [innerHTML]="method.description"></div>
75+
<div [innerHTML]="method.descriptionSafeHtml"></div>
7676
</td>
7777
</tr>
7878
</tbody>

libs/common-docs/src/lib/api-docs/api-doc/api-doc.component.ts

Lines changed: 57 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { ChangeDetectionStrategy, Component } from '@angular/core';
77
import { ComponentApi } from '../../models/components-api.model';
88
import { Analytics } from '../analytics/analytics';
99
import { ClassDesc, DirectiveDesc, InputDesc, MethodDesc, NgApiDoc, PropertyDesc, signature } from '../api-docs.model';
10+
import { DomSanitizer } from '@angular/platform-browser';
1011

1112
/**
1213
* Displays the API docs of a directive.
@@ -23,33 +24,39 @@ import { ClassDesc, DirectiveDesc, InputDesc, MethodDesc, NgApiDoc, PropertyDesc
2324
templateUrl: './api-doc.component.html'
2425
})
2526
export class NgApiDocComponent {
26-
apiDocs: DirectiveDesc;
27-
configServiceName: string;
27+
apiDocs?: DirectiveDesc;
28+
configServiceName?: string;
2829
headerAnchor: string | undefined;
2930

3031
/**
3132
* Object which contains, for each input name of the directive, the corresponding property of the associated config
3233
* service (if any)
3334
*/
3435

35-
private configProperties: { [propertyName: string]: PropertyDesc };
36+
private configProperties?: { [propertyName: string]: PropertyDesc };
3637
private analytics: Analytics;
3738
private docs: NgApiDoc;
3839

39-
constructor(analytics: Analytics, docs: NgApiDoc, content: ComponentApi) {
40+
constructor(analytics: Analytics, docs: NgApiDoc, content: ComponentApi, private sanitizer: DomSanitizer) {
4041
this.analytics = analytics;
4142
// todo: inject docs
4243
this.docs = docs;
43-
4444
this.headerAnchor = content.anchor;
45-
this.apiDocs = this.docs[content.title];
46-
this.configServiceName = `${content.title}Config`;
47-
const configApiDocs = this.docs[this.configServiceName];
48-
this.configProperties = {};
49-
if (configApiDocs) {
50-
this.apiDocs.inputs.forEach(
51-
(input: InputDesc) => (this.configProperties[input.name] = this.findInputConfigProperty(configApiDocs, input))
52-
);
45+
if (content?.title) {
46+
this.apiDocs = this.docs[content.title];
47+
this.configServiceName = `${content.title}Config`;
48+
const configApiDocs = this.docs[this.configServiceName];
49+
this.configProperties = {};
50+
if (configApiDocs) {
51+
this.apiDocs?.inputs.forEach(
52+
(input: InputDesc) => {
53+
if (this.configProperties && this.configProperties[input.name]) {
54+
this.configProperties[input.name] = this.findInputConfigProperty(configApiDocs, input);
55+
}
56+
}
57+
);
58+
}
59+
this.checkSecurApiDocs();
5360
}
5461
}
5562

@@ -58,7 +65,7 @@ export class NgApiDocComponent {
5865
* property. If there is no matching config property, it reads it from the input.
5966
*/
6067
defaultInputValue(input: InputDesc): string | undefined {
61-
const configProperty = this.configProperties[input.name];
68+
const configProperty = this.configProperties?.[input.name];
6269

6370
return configProperty ? configProperty.defaultValue : input.defaultValue;
6471
}
@@ -67,18 +74,52 @@ export class NgApiDocComponent {
6774
* Returns true if there is a config service property matching with the given directive input
6875
*/
6976
hasConfigProperty(input: InputDesc): boolean {
70-
return !!this.configProperties[input.name];
77+
return !!this.configProperties?.[input.name];
7178
}
7279

7380
methodSignature(method: MethodDesc): string {
7481
return signature(method);
7582
}
7683

7784
trackSourceClick(): void {
78-
this.analytics.trackEvent('Source File View', this.apiDocs.className);
85+
this.analytics.trackEvent('Source File View', this.apiDocs?.className);
7986
}
8087

8188
private findInputConfigProperty(configApiDocs: ClassDesc, input: InputDesc): PropertyDesc {
8289
return configApiDocs.properties.filter((prop: PropertyDesc) => prop.name === input.name)[0];
8390
}
91+
92+
checkSecurApiDocs(): void {
93+
if (!this.apiDocs) {
94+
return;
95+
}
96+
97+
if (this.apiDocs?.description) {
98+
this.apiDocs.descriptionSafeHtML = this.sanitizer.bypassSecurityTrustHtml(this.apiDocs.description);
99+
}
100+
101+
if (this.apiDocs?.inputs?.length) {
102+
this.apiDocs.inputs.map(input => {
103+
if (input.description) {
104+
input.descriptionSafeHtml = this.sanitizer.bypassSecurityTrustHtml(input.description);
105+
}
106+
});
107+
}
108+
109+
if (this.apiDocs?.outputs?.length) {
110+
this.apiDocs.outputs.map(output => {
111+
if (output.description) {
112+
output.descriptionSafeHtml = this.sanitizer.bypassSecurityTrustHtml(output.description);
113+
}
114+
});
115+
}
116+
117+
if (this.apiDocs?.methods?.length) {
118+
this.apiDocs.methods.map(method => {
119+
if (method.description) {
120+
method.descriptionSafeHtml = this.sanitizer.bypassSecurityTrustHtml(method.description);
121+
}
122+
});
123+
}
124+
}
84125
}

libs/common-docs/src/lib/api-docs/api-docs.model.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
* @author ng-team
33
* @copyright ng-bootstrap
44
*/
5+
import { SafeHtml } from '@angular/platform-browser';
6+
57
export interface ClassDesc {
68
fileName: string;
79
className: string;
810
description: string;
11+
descriptionSafeHtML?: SafeHtml;
912
properties: PropertyDesc[];
1013
methods: MethodDesc[];
1114
}
@@ -22,11 +25,13 @@ export interface PropertyDesc {
2225
type: string;
2326
description: string;
2427
defaultValue?: string;
28+
descriptionSafeHtml?: SafeHtml;
2529
}
2630

2731
export interface MethodDesc {
2832
name: string;
2933
description: string;
34+
descriptionSafeHtml?: SafeHtml;
3035
args: ArgumentDesc[];
3136
returnType: string;
3237
}

libs/common-docs/src/lib/common/add-nav/add-nav.component.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
<ul *ngIf="componentContent" (click)="goToSection($event)">
2-
<li *ngFor="let item of componentContent">
1+
<ul *ngIf="_componentContent" (click)="goToSection($event)">
2+
<li *ngFor="let item of _componentContent">
33
<a routerLink="." [fragment]="item.anchor" [attr.data-anchor]="item.anchor">{{ item.name }}</a>
4-
<ul *ngIf="item.content && item.content.length">
4+
<ul *ngIf="item?.content && item.content?.length">
55
<li *ngFor="let subItem of item.content">
66
<a routerLink="." [fragment]="subItem.anchor" [attr.data-anchor]="subItem.anchor">{{ subItem.title }}</a>
77
</ul>

0 commit comments

Comments
 (0)