Skip to content

Commit cd70db1

Browse files
docs: remove packageDocumentation and switch internalapi to internal
1 parent 1d48b48 commit cd70db1

17 files changed

+70
-128
lines changed

src/directives/directives.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
/**
2-
* The UI-Router for Angular directives:
3-
*
4-
* - [[UIView]]: A viewport for routed components
5-
* - [[UISref]]: A state ref to a target state; navigates when clicked
6-
* - [[UISrefActive]]: (and `UISrefActiveEq`) Adds a css class when a UISref's target state (or a child state) is active
7-
*
8-
* @ng2api
9-
* @preferred
10-
* @module directives
11-
*/ /** */
121
import { UISref, AnchorUISref } from './uiSref';
132
import { UISrefActive } from './uiSrefActive';
143
import { UIView } from './uiView';
@@ -19,12 +8,12 @@ export * from './uiSref';
198
export * from './uiSrefStatus';
209
export * from './uiSrefActive';
2110

22-
/** @internalapi */
11+
/** @internal */
2312
export const _UIROUTER_DIRECTIVES = [UISref, AnchorUISref, UIView, UISrefActive, UISrefStatus];
2413

2514
/**
2615
* References to the UI-Router directive classes, for use within a @Component's `directives:` property
2716
* @deprecated use [[UIRouterModule]]
28-
* @internalapi
17+
* @internal
2918
*/
3019
export const UIROUTER_DIRECTIVES = _UIROUTER_DIRECTIVES;

src/directives/uiSref.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/** @ng2api @module directives */
2-
/** */
31
import { UIRouter, extend, Obj, TransitionOptions, TargetState, isNumber } from '@uirouter/core';
42
import {
53
Directive,
@@ -16,7 +14,7 @@ import { UIView, ParentUIViewInject } from './uiView';
1614
import { ReplaySubject, Subscription } from 'rxjs';
1715

1816
/**
19-
* @internalapi
17+
* @internal
2018
* # blah blah blah
2119
*/
2220
@Directive({ selector: 'a[uiSref]' })
@@ -113,11 +111,11 @@ export class UISref implements OnChanges {
113111
*/
114112
public targetState$ = new ReplaySubject<TargetState>(1);
115113

116-
/** @internalapi */ private _emit = false;
117-
/** @internalapi */ private _statesSub: Subscription;
118-
/** @internalapi */ private _router: UIRouter;
119-
/** @internalapi */ private _anchorUISref: AnchorUISref;
120-
/** @internalapi */ private _parent: ParentUIViewInject;
114+
/** @internal */ private _emit = false;
115+
/** @internal */ private _statesSub: Subscription;
116+
/** @internal */ private _router: UIRouter;
117+
/** @internal */ private _anchorUISref: AnchorUISref;
118+
/** @internal */ private _parent: ParentUIViewInject;
121119

122120
constructor(
123121
_router: UIRouter,
@@ -131,17 +129,17 @@ export class UISref implements OnChanges {
131129
this._statesSub = _router.globals.states$.subscribe(() => this.update());
132130
}
133131

134-
/** @internalapi */
132+
/** @internal */
135133
set uiSref(val: string) {
136134
this.state = val;
137135
this.update();
138136
}
139-
/** @internalapi */
137+
/** @internal */
140138
set uiParams(val: Obj) {
141139
this.params = val;
142140
this.update();
143141
}
144-
/** @internalapi */
142+
/** @internal */
145143
set uiOptions(val: TransitionOptions) {
146144
this.options = val;
147145
this.update();

src/directives/uiSrefActive.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
/** @ng2api @module directives */ /** */
21
import { Directive, Input, ElementRef, Host, Renderer2 } from '@angular/core';
32
import { UISrefStatus, SrefStatus } from './uiSrefStatus';
43
import { Subscription } from 'rxjs';
@@ -100,14 +99,14 @@ export class UISrefActive {
10099
private _subscription: Subscription;
101100
constructor(uiSrefStatus: UISrefStatus, rnd: Renderer2, @Host() host: ElementRef) {
102101
this._subscription = uiSrefStatus.uiSrefStatus.subscribe((next: SrefStatus) => {
103-
this._classes.forEach(cls => {
102+
this._classes.forEach((cls) => {
104103
if (next.active) {
105104
rnd.addClass(host.nativeElement, cls);
106105
} else {
107106
rnd.removeClass(host.nativeElement, cls);
108107
}
109108
});
110-
this._classesEq.forEach(cls => {
109+
this._classesEq.forEach((cls) => {
111110
if (next.exact) {
112111
rnd.addClass(host.nativeElement, cls);
113112
} else {

src/directives/uiSrefStatus.ts

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/** @ng2api @module directives */
2-
/** */
31
import { Directive, Output, EventEmitter, ContentChildren, QueryList, Host, Self, Optional } from '@angular/core';
42
import { UISref } from './uiSref';
53
import {
@@ -21,7 +19,7 @@ import {
2119
import { Subscription, Observable, BehaviorSubject, of, from, combineLatest, concat } from 'rxjs';
2220
import { switchMap, map, tap } from 'rxjs/operators';
2321

24-
/** @internalapi */
22+
/** @internal */
2523
interface TransEvt {
2624
evt: string;
2725
trans: Transition;
@@ -43,7 +41,7 @@ export interface SrefStatus {
4341
targetStates: TargetState[];
4442
}
4543

46-
/** @internalapi */
44+
/** @internal */
4745
const inactiveStatus: SrefStatus = {
4846
active: false,
4947
exact: false,
@@ -58,15 +56,15 @@ const inactiveStatus: SrefStatus = {
5856
* The predicate returns true when the target state (and param values)
5957
* match the (tail of) the path, and the path's param values
6058
*
61-
* @internalapi
59+
* @internal
6260
*/
6361
const pathMatches = (target: TargetState): Predicate<PathNode[]> => {
6462
if (!target.exists()) return () => false;
6563
const state: StateObject = target.$state();
6664
const targetParamVals = target.params();
6765
const targetPath: PathNode[] = PathUtils.buildPath(target);
6866
const paramSchema: Param[] = targetPath
69-
.map(node => node.paramSchema)
67+
.map((node) => node.paramSchema)
7068
.reduce(unnestR, [])
7169
.filter((param: Param) => targetParamVals.hasOwnProperty(param.id));
7270

@@ -83,10 +81,10 @@ const pathMatches = (target: TargetState): Predicate<PathNode[]> => {
8381
* Expands the path to [c], [c, d]
8482
* Then appends each to [a,b,] and returns: [a, b, c], [a, b, c, d]
8583
*
86-
* @internalapi
84+
* @internal
8785
*/
8886
function spreadToSubPaths(basePath: PathNode[], appendPath: PathNode[]): PathNode[][] {
89-
return appendPath.map(node => basePath.concat(PathUtils.subPath(appendPath, n => n.state === node.state)));
87+
return appendPath.map((node) => basePath.concat(PathUtils.subPath(appendPath, (n) => n.state === node.state)));
9088
}
9189

9290
/**
@@ -95,7 +93,7 @@ function spreadToSubPaths(basePath: PathNode[], appendPath: PathNode[]): PathNod
9593
* which represents the current status of that Sref:
9694
* active, activeEq (exact match), entering, exiting
9795
*
98-
* @internalapi
96+
* @internal
9997
*/
10098
function getSrefStatus(event: TransEvt, srefTarget: TargetState): SrefStatus {
10199
const pathMatchesTarget = pathMatches(srefTarget);
@@ -105,22 +103,13 @@ function getSrefStatus(event: TransEvt, srefTarget: TargetState): SrefStatus {
105103
const isSuccessEvent = event.evt === 'success';
106104
const activePath: PathNode[] = isSuccessEvent ? tc.to : tc.from;
107105

108-
const isActive = () =>
109-
spreadToSubPaths([], activePath)
110-
.map(pathMatchesTarget)
111-
.reduce(anyTrueR, false);
106+
const isActive = () => spreadToSubPaths([], activePath).map(pathMatchesTarget).reduce(anyTrueR, false);
112107

113108
const isExact = () => pathMatchesTarget(activePath);
114109

115-
const isEntering = () =>
116-
spreadToSubPaths(tc.retained, tc.entering)
117-
.map(pathMatchesTarget)
118-
.reduce(anyTrueR, false);
110+
const isEntering = () => spreadToSubPaths(tc.retained, tc.entering).map(pathMatchesTarget).reduce(anyTrueR, false);
119111

120-
const isExiting = () =>
121-
spreadToSubPaths(tc.retained, tc.exiting)
122-
.map(pathMatchesTarget)
123-
.reduce(anyTrueR, false);
112+
const isExiting = () => spreadToSubPaths(tc.retained, tc.exiting).map(pathMatchesTarget).reduce(anyTrueR, false);
124113

125114
return {
126115
active: isActive(),
@@ -131,7 +120,7 @@ function getSrefStatus(event: TransEvt, srefTarget: TargetState): SrefStatus {
131120
} as SrefStatus;
132121
}
133122

134-
/** @internalapi */
123+
/** @internal */
135124
function mergeSrefStatus(left: SrefStatus, right: SrefStatus): SrefStatus {
136125
return {
137126
active: left.active || right.active,
@@ -204,11 +193,11 @@ export class UISrefStatus {
204193
/** The current status */
205194
status: SrefStatus;
206195

207-
/** @internalapi */ private _subscription: Subscription;
208-
/** @internalapi */ private _srefChangesSub: Subscription;
209-
/** @internalapi */ private _srefs$: BehaviorSubject<UISref[]>;
210-
/** @internalapi */ private _globals: UIRouterGlobals;
211-
/** @internalapi */ private _hostUiSref: UISref;
196+
/** @internal */ private _subscription: Subscription;
197+
/** @internal */ private _srefChangesSub: Subscription;
198+
/** @internal */ private _srefs$: BehaviorSubject<UISref[]>;
199+
/** @internal */ private _globals: UIRouterGlobals;
200+
/** @internal */ private _hostUiSref: UISref;
212201
constructor(@Host() @Self() @Optional() _hostUiSref: UISref, _globals: UIRouterGlobals) {
213202
this._globals = _globals;
214203
this._hostUiSref = _hostUiSref;
@@ -223,25 +212,25 @@ export class UISrefStatus {
223212
const event = (evt: string) => ({ evt, trans } as TransEvt);
224213

225214
const transStart$ = of(event('start'));
226-
const transResult = trans.promise.then(() => event('success'), () => event('error'));
215+
const transResult = trans.promise.then(
216+
() => event('success'),
217+
() => event('error')
218+
);
227219
const transFinish$ = from(transResult);
228220

229221
return concat(transStart$, transFinish$);
230222
})
231223
);
232224

233225
const withHostSref = (childrenSrefs: UISref[]) =>
234-
childrenSrefs
235-
.concat(this._hostUiSref)
236-
.filter(identity)
237-
.reduce(uniqR, []);
226+
childrenSrefs.concat(this._hostUiSref).filter(identity).reduce(uniqR, []);
238227

239228
// Watch the @ContentChildren UISref[] components and get their target states
240229
this._srefs$ = new BehaviorSubject(withHostSref(this._srefs.toArray()));
241-
this._srefChangesSub = this._srefs.changes.subscribe(srefs => this._srefs$.next(withHostSref(srefs)));
230+
this._srefChangesSub = this._srefs.changes.subscribe((srefs) => this._srefs$.next(withHostSref(srefs)));
242231

243232
const targetStates$: Observable<TargetState[]> = this._srefs$.pipe(
244-
switchMap((srefs: UISref[]) => combineLatest<TargetState[]>(srefs.map(sref => sref.targetState$)))
233+
switchMap((srefs: UISref[]) => combineLatest<TargetState[]>(srefs.map((sref) => sref.targetState$)))
245234
);
246235

247236
// Calculate the status of each UISref based on the transition event.
@@ -251,7 +240,7 @@ export class UISrefStatus {
251240
switchMap((evt: TransEvt) => {
252241
return targetStates$.pipe(
253242
map((targets: TargetState[]) => {
254-
const statuses: SrefStatus[] = targets.map(target => getSrefStatus(evt, target));
243+
const statuses: SrefStatus[] = targets.map((target) => getSrefStatus(evt, target));
255244
return statuses.reduce(mergeSrefStatus);
256245
})
257246
);

src/directives/uiView.ts

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/** @ng2api @module directives */
2-
/** */
31
import {
42
Component,
53
ComponentFactory,
@@ -40,13 +38,13 @@ import { MergeInjector } from '../mergeInjector';
4038
/** @hidden */
4139
let id = 0;
4240

43-
/** @internalapi These are provide()d as the string UIView.PARENT_INJECT */
41+
/** @internal These are provide()d as the string UIView.PARENT_INJECT */
4442
export interface ParentUIViewInject {
4543
context: ViewContext;
4644
fqn: string;
4745
}
4846

49-
/** @internalapi */
47+
/** @internal */
5048
interface InputMapping {
5149
token: string;
5250
prop: string;
@@ -58,10 +56,10 @@ interface InputMapping {
5856
* - @Input('foo') _foo
5957
* - `inputs: ['foo']`
6058
*
61-
* @internalapi
59+
* @internal
6260
*/
6361
const ng2ComponentInputs = (factory: ComponentFactory<any>): InputMapping[] => {
64-
return factory.inputs.map(input => ({ prop: input.propName, token: input.templateName }));
62+
return factory.inputs.map((input) => ({ prop: input.propName, token: input.templateName }));
6563
};
6664

6765
/**
@@ -172,11 +170,11 @@ export class UIView implements OnInit, OnDestroy {
172170
config: undefined,
173171
};
174172

175-
this._deregisterUiCanExitHook = router.transitionService.onBefore({}, trans => {
173+
this._deregisterUiCanExitHook = router.transitionService.onBefore({}, (trans) => {
176174
return this._invokeUiCanExitHook(trans);
177175
});
178176

179-
this._deregisterUiOnParamsChangedHook = router.transitionService.onSuccess({}, trans =>
177+
this._deregisterUiOnParamsChangedHook = router.transitionService.onSuccess({}, (trans) =>
180178
this._invokeUiOnParamsChangedHook(trans)
181179
);
182180

@@ -199,7 +197,7 @@ export class UIView implements OnInit, OnDestroy {
199197
const state: StateDeclaration = this.state;
200198

201199
if (trans.exiting().indexOf(state) !== -1) {
202-
trans.onStart({}, function() {
200+
trans.onStart({}, function () {
203201
return uiCanExitFn.call(instance, trans);
204202
});
205203
}
@@ -226,14 +224,8 @@ export class UIView implements OnInit, OnDestroy {
226224
const toParams: { [paramName: string]: any } = $transition$.params('to');
227225
const fromParams: { [paramName: string]: any } = $transition$.params('from');
228226
const getNodeSchema = (node: PathNode) => node.paramSchema;
229-
const toSchema: Param[] = $transition$
230-
.treeChanges('to')
231-
.map(getNodeSchema)
232-
.reduce(unnestR, []);
233-
const fromSchema: Param[] = $transition$
234-
.treeChanges('from')
235-
.map(getNodeSchema)
236-
.reduce(unnestR, []);
227+
const toSchema: Param[] = $transition$.treeChanges('to').map(getNodeSchema).reduce(unnestR, []);
228+
const fromSchema: Param[] = $transition$.treeChanges('from').map(getNodeSchema).reduce(unnestR, []);
237229

238230
// Find the to params that have different values than the from params
239231
const changedToParams = toSchema.filter((param: Param) => {
@@ -243,7 +235,7 @@ export class UIView implements OnInit, OnDestroy {
243235

244236
// Only trigger callback if a to param has changed or is new
245237
if (changedToParams.length) {
246-
const changedKeys: string[] = changedToParams.map(x => x.id);
238+
const changedKeys: string[] = changedToParams.map((x) => x.id);
247239
// Filter the params to only changed/new to params. `$transition$.params()` may be used to get all params.
248240
const newValues = filter(toParams, (val, key) => changedKeys.indexOf(key) !== -1);
249241
instance.uiOnParamsChanged(newValues, $transition$);
@@ -321,10 +313,10 @@ export class UIView implements OnInit, OnDestroy {
321313
// Map resolves to "useValue: providers"
322314
const resolvables = context
323315
.getTokens()
324-
.map(token => context.getResolvable(token))
325-
.filter(r => r.resolved);
316+
.map((token) => context.getResolvable(token))
317+
.filter((r) => r.resolved);
326318

327-
const newProviders = resolvables.map(r => ({ provide: r.token, useValue: context.injector().get(r.token) }));
319+
const newProviders = resolvables.map((r) => ({ provide: r.token, useValue: context.injector().get(r.token) }));
328320

329321
const parentInject = { context: this._uiViewData.config.viewDecl.$context, fqn: this._uiViewData.fqn };
330322
newProviders.push({ provide: UIView.PARENT_INJECT, useValue: parentInject });
@@ -349,7 +341,7 @@ export class UIView implements OnInit, OnDestroy {
349341
// Returns the actual component property for a renamed an input renamed using `@Input('foo') _foo`.
350342
// return the `_foo` property
351343
const renamedInputProp = (prop: string) => {
352-
const input = factory.inputs.find(i => i.templateName === prop);
344+
const input = factory.inputs.find((i) => i.templateName === prop);
353345
return (input && input.propName) || prop;
354346
};
355347

@@ -360,7 +352,7 @@ export class UIView implements OnInit, OnDestroy {
360352
);
361353

362354
// Supply resolve data to matching @Input('prop') or inputs: ['prop']
363-
const implicitInputTuples = ng2ComponentInputs(factory).filter(tuple => !inArray(explicitBoundProps, tuple.prop));
355+
const implicitInputTuples = ng2ComponentInputs(factory).filter((tuple) => !inArray(explicitBoundProps, tuple.prop));
364356

365357
const addResolvable = (tuple: InputMapping) => ({
366358
prop: tuple.prop,
@@ -372,8 +364,8 @@ export class UIView implements OnInit, OnDestroy {
372364
explicitInputTuples
373365
.concat(implicitInputTuples)
374366
.map(addResolvable)
375-
.filter(tuple => tuple.resolvable && tuple.resolvable.resolved)
376-
.forEach(tuple => {
367+
.filter((tuple) => tuple.resolvable && tuple.resolvable.resolved)
368+
.forEach((tuple) => {
377369
component[tuple.prop] = injector.get(tuple.resolvable.token);
378370
});
379371
}

src/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
/** @ng2api @module ng2 */ /** for typedoc */
2-
31
export * from './interface';
42
export * from './providers';
53
export * from './uiRouterNgModule';

0 commit comments

Comments
 (0)