@skyux/router 5.0.0 → 5.5.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -4
- package/bundles/skyux-router.umd.js +63 -63
- package/esm2015/index.js +13 -0
- package/esm2015/index.js.map +1 -0
- package/esm2015/lib/modules/href/href-query-params.js +2 -0
- package/esm2015/lib/modules/href/href-query-params.js.map +1 -0
- package/esm2015/lib/modules/href/href-resolver.js +2 -0
- package/esm2015/lib/modules/href/href-resolver.js.map +1 -0
- package/esm2015/lib/modules/href/href-resolver.service.js +19 -0
- package/esm2015/lib/modules/href/href-resolver.service.js.map +1 -0
- package/esm2015/lib/modules/href/href.directive.js +186 -0
- package/esm2015/lib/modules/href/href.directive.js.map +1 -0
- package/esm2015/lib/modules/href/href.module.js +18 -0
- package/esm2015/lib/modules/href/href.module.js.map +1 -0
- package/esm2015/lib/modules/href/types/href-resolver.args.js +2 -0
- package/esm2015/lib/modules/href/types/href-resolver.args.js.map +1 -0
- package/esm2015/lib/modules/href/types/href.js +2 -0
- package/esm2015/lib/modules/href/types/href.js.map +1 -0
- package/esm2015/lib/modules/link/link-external.directive.js +59 -0
- package/esm2015/lib/modules/link/link-external.directive.js.map +1 -0
- package/esm2015/lib/modules/link/link-query-params.js +2 -0
- package/esm2015/lib/modules/link/link-query-params.js.map +1 -0
- package/esm2015/lib/modules/link/link.directive.js +44 -0
- package/esm2015/lib/modules/link/link.directive.js.map +1 -0
- package/esm2015/lib/modules/link/link.module.js +18 -0
- package/esm2015/lib/modules/link/link.module.js.map +1 -0
- package/esm2015/skyux-router.js +2 -2
- package/esm2015/skyux-router.js.map +1 -0
- package/fesm2015/skyux-router.js +58 -56
- package/fesm2015/skyux-router.js.map +1 -1
- package/index.d.ts +10 -0
- package/{modules → lib/modules}/href/href-query-params.d.ts +0 -0
- package/{modules → lib/modules}/href/href-resolver.d.ts +0 -0
- package/{modules → lib/modules}/href/href-resolver.service.d.ts +0 -0
- package/{modules → lib/modules}/href/href.directive.d.ts +0 -0
- package/{modules → lib/modules}/href/href.module.d.ts +0 -0
- package/{modules → lib/modules}/href/types/href-resolver.args.d.ts +0 -0
- package/{modules → lib/modules}/href/types/href.d.ts +0 -0
- package/{modules → lib/modules}/link/link-external.directive.d.ts +3 -0
- package/{modules → lib/modules}/link/link-query-params.d.ts +0 -0
- package/{modules → lib/modules}/link/link.directive.d.ts +0 -0
- package/{modules → lib/modules}/link/link.module.d.ts +0 -0
- package/package.json +6 -6
- package/skyux-router.d.ts +1 -1
- package/LICENSE +0 -21
- package/bundles/skyux-router.umd.js.map +0 -1
- package/documentation.json +0 -1720
- package/esm2015/modules/href/href-query-params.js +0 -2
- package/esm2015/modules/href/href-resolver.js +0 -2
- package/esm2015/modules/href/href-resolver.service.js +0 -19
- package/esm2015/modules/href/href.directive.js +0 -175
- package/esm2015/modules/href/href.module.js +0 -18
- package/esm2015/modules/href/types/href-resolver.args.js +0 -2
- package/esm2015/modules/href/types/href.js +0 -2
- package/esm2015/modules/link/link-external.directive.js +0 -55
- package/esm2015/modules/link/link-query-params.js +0 -2
- package/esm2015/modules/link/link.directive.js +0 -42
- package/esm2015/modules/link/link.module.js +0 -26
- package/esm2015/public-api.js +0 -13
- package/public-api.d.ts +0 -10
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
#
|
|
1
|
+
# router
|
|
2
2
|
|
|
3
|
-
[
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
This library was generated with [Nx](https://nx.dev).
|
|
4
|
+
|
|
5
|
+
## Running unit tests
|
|
6
|
+
|
|
7
|
+
Run `nx test router` to execute the unit tests.
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/router'), require('@angular/common'), require('@skyux/config'), require('@skyux/core'), require('@angular/common/http')) :
|
|
3
3
|
typeof define === 'function' && define.amd ? define('@skyux/router', ['exports', '@angular/core', '@angular/router', '@angular/common', '@skyux/config', '@skyux/core', '@angular/common/http'], factory) :
|
|
4
4
|
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.skyux = global.skyux || {}, global.skyux.router = {}), global.ng.core, global.ng.router, global.ng.common, global.i4, global.i3, global.ng.common.http));
|
|
5
|
-
}(this, (function (exports, i0, i1, i2, i4, i3, http) { 'use strict';
|
|
5
|
+
})(this, (function (exports, i0, i1, i2, i4, i3, http) { 'use strict';
|
|
6
6
|
|
|
7
7
|
function _interopNamespace(e) {
|
|
8
8
|
if (e && e.__esModule) return e;
|
|
@@ -13,14 +13,12 @@
|
|
|
13
13
|
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
14
|
Object.defineProperty(n, k, d.get ? d : {
|
|
15
15
|
enumerable: true,
|
|
16
|
-
get: function () {
|
|
17
|
-
return e[k];
|
|
18
|
-
}
|
|
16
|
+
get: function () { return e[k]; }
|
|
19
17
|
});
|
|
20
18
|
}
|
|
21
19
|
});
|
|
22
20
|
}
|
|
23
|
-
n[
|
|
21
|
+
n["default"] = e;
|
|
24
22
|
return Object.freeze(n);
|
|
25
23
|
}
|
|
26
24
|
|
|
@@ -369,19 +367,19 @@
|
|
|
369
367
|
_super.prototype.ngOnChanges.call(this, changes);
|
|
370
368
|
};
|
|
371
369
|
SkyAppLinkDirective.prototype.mergeQueryParams = function (queryParams) {
|
|
372
|
-
var skyuxParams =
|
|
370
|
+
var skyuxParams = this.skyAppConfig
|
|
373
371
|
? this.skyAppConfig.runtime.params.getAll(true)
|
|
374
372
|
: this.paramsProvider.params.getAll(true);
|
|
375
373
|
return Object.assign({}, this.queryParams, queryParams, skyuxParams);
|
|
376
374
|
};
|
|
377
375
|
return SkyAppLinkDirective;
|
|
378
376
|
}(i1.RouterLinkWithHref));
|
|
379
|
-
SkyAppLinkDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
|
380
|
-
SkyAppLinkDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.
|
|
381
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
|
377
|
+
SkyAppLinkDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyAppLinkDirective, deps: [{ token: i1__namespace.Router }, { token: i1__namespace.ActivatedRoute }, { token: i2__namespace.LocationStrategy }, { token: i4__namespace.SkyAppConfig, optional: true }, { token: i4__namespace.SkyAppRuntimeConfigParamsProvider, optional: true }], target: i0__namespace.ɵɵFactoryTarget.Directive });
|
|
378
|
+
SkyAppLinkDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: SkyAppLinkDirective, selector: "[skyAppLink]", inputs: { skyAppLink: "skyAppLink" }, usesInheritance: true, usesOnChanges: true, ngImport: i0__namespace });
|
|
379
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyAppLinkDirective, decorators: [{
|
|
382
380
|
type: i0.Directive,
|
|
383
381
|
args: [{
|
|
384
|
-
selector: '[skyAppLink]'
|
|
382
|
+
selector: '[skyAppLink]',
|
|
385
383
|
}]
|
|
386
384
|
}], ctorParameters: function () {
|
|
387
385
|
return [{ type: i1__namespace.Router }, { type: i1__namespace.ActivatedRoute }, { type: i2__namespace.LocationStrategy }, { type: i4__namespace.SkyAppConfig, decorators: [{
|
|
@@ -393,16 +391,18 @@
|
|
|
393
391
|
type: i0.Input
|
|
394
392
|
}] } });
|
|
395
393
|
|
|
394
|
+
/**
|
|
395
|
+
* @deprecated Use `skyHref` directive instead.
|
|
396
|
+
*/
|
|
396
397
|
var SkyAppLinkExternalDirective = /** @class */ (function (_super) {
|
|
397
398
|
__extends(SkyAppLinkExternalDirective, _super);
|
|
398
399
|
function SkyAppLinkExternalDirective(router, route, platformLocation, window, skyAppConfig, paramsProvider, hostConfig) {
|
|
399
|
-
var _this = _super.call(this, router, route, new i2.PathLocationStrategy(platformLocation,
|
|
400
|
-
? hostConfig.host.url
|
|
401
|
-
: skyAppConfig.skyux.host.url)) || this;
|
|
400
|
+
var _this = _super.call(this, router, route, new i2.PathLocationStrategy(platformLocation, hostConfig ? hostConfig.host.url : skyAppConfig.skyux.host.url)) || this;
|
|
402
401
|
_this.window = window;
|
|
403
402
|
_this.skyAppConfig = skyAppConfig;
|
|
404
403
|
_this.paramsProvider = paramsProvider;
|
|
405
|
-
if (_this.window.nativeWindow.window.name &&
|
|
404
|
+
if (_this.window.nativeWindow.window.name &&
|
|
405
|
+
_this.window.nativeWindow.window.name !== '') {
|
|
406
406
|
_this.target = _this.window.nativeWindow.window.name;
|
|
407
407
|
}
|
|
408
408
|
else {
|
|
@@ -423,19 +423,19 @@
|
|
|
423
423
|
_super.prototype.ngOnChanges.call(this, changes);
|
|
424
424
|
};
|
|
425
425
|
SkyAppLinkExternalDirective.prototype.mergeQueryParams = function (queryParams) {
|
|
426
|
-
var skyuxParams =
|
|
426
|
+
var skyuxParams = this.skyAppConfig
|
|
427
427
|
? this.skyAppConfig.runtime.params.getAll()
|
|
428
428
|
: this.paramsProvider.params.getAll();
|
|
429
429
|
return Object.assign({}, this.queryParams, queryParams, skyuxParams);
|
|
430
430
|
};
|
|
431
431
|
return SkyAppLinkExternalDirective;
|
|
432
432
|
}(i1.RouterLinkWithHref));
|
|
433
|
-
SkyAppLinkExternalDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
|
434
|
-
SkyAppLinkExternalDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.
|
|
435
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
|
433
|
+
SkyAppLinkExternalDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyAppLinkExternalDirective, deps: [{ token: i1__namespace.Router }, { token: i1__namespace.ActivatedRoute }, { token: i2__namespace.PlatformLocation }, { token: i3__namespace.SkyAppWindowRef }, { token: i4__namespace.SkyAppConfig, optional: true }, { token: i4__namespace.SkyAppRuntimeConfigParamsProvider, optional: true }, { token: i4__namespace.SkyAppConfigHost, optional: true }], target: i0__namespace.ɵɵFactoryTarget.Directive });
|
|
434
|
+
SkyAppLinkExternalDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: SkyAppLinkExternalDirective, selector: "[skyAppLinkExternal]", inputs: { skyAppLinkExternal: "skyAppLinkExternal" }, usesInheritance: true, usesOnChanges: true, ngImport: i0__namespace });
|
|
435
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyAppLinkExternalDirective, decorators: [{
|
|
436
436
|
type: i0.Directive,
|
|
437
437
|
args: [{
|
|
438
|
-
selector: '[skyAppLinkExternal]'
|
|
438
|
+
selector: '[skyAppLinkExternal]',
|
|
439
439
|
}]
|
|
440
440
|
}], ctorParameters: function () {
|
|
441
441
|
return [{ type: i1__namespace.Router }, { type: i1__namespace.ActivatedRoute }, { type: i2__namespace.PlatformLocation }, { type: i3__namespace.SkyAppWindowRef }, { type: i4__namespace.SkyAppConfig, decorators: [{
|
|
@@ -455,22 +455,14 @@
|
|
|
455
455
|
}
|
|
456
456
|
return SkyAppLinkModule;
|
|
457
457
|
}());
|
|
458
|
-
SkyAppLinkModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
|
459
|
-
SkyAppLinkModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
SkyAppLinkModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: SkyAppLinkModule });
|
|
463
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0__namespace, type: SkyAppLinkModule, decorators: [{
|
|
458
|
+
SkyAppLinkModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyAppLinkModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
|
459
|
+
SkyAppLinkModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyAppLinkModule, declarations: [SkyAppLinkDirective, SkyAppLinkExternalDirective], exports: [SkyAppLinkDirective, SkyAppLinkExternalDirective] });
|
|
460
|
+
SkyAppLinkModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyAppLinkModule });
|
|
461
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyAppLinkModule, decorators: [{
|
|
464
462
|
type: i0.NgModule,
|
|
465
463
|
args: [{
|
|
466
|
-
declarations: [
|
|
467
|
-
|
|
468
|
-
SkyAppLinkExternalDirective
|
|
469
|
-
],
|
|
470
|
-
exports: [
|
|
471
|
-
SkyAppLinkDirective,
|
|
472
|
-
SkyAppLinkExternalDirective
|
|
473
|
-
]
|
|
464
|
+
declarations: [SkyAppLinkDirective, SkyAppLinkExternalDirective],
|
|
465
|
+
exports: [SkyAppLinkDirective, SkyAppLinkExternalDirective],
|
|
474
466
|
}]
|
|
475
467
|
}] });
|
|
476
468
|
|
|
@@ -483,14 +475,14 @@
|
|
|
483
475
|
SkyHrefResolverService.prototype.resolveHref = function (args) {
|
|
484
476
|
return Promise.resolve({
|
|
485
477
|
url: args.url,
|
|
486
|
-
userHasAccess: true
|
|
478
|
+
userHasAccess: true,
|
|
487
479
|
});
|
|
488
480
|
};
|
|
489
481
|
return SkyHrefResolverService;
|
|
490
482
|
}());
|
|
491
|
-
SkyHrefResolverService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
|
492
|
-
SkyHrefResolverService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.
|
|
493
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
|
483
|
+
SkyHrefResolverService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyHrefResolverService, deps: [], target: i0__namespace.ɵɵFactoryTarget.Injectable });
|
|
484
|
+
SkyHrefResolverService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyHrefResolverService });
|
|
485
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyHrefResolverService, decorators: [{
|
|
494
486
|
type: i0.Injectable
|
|
495
487
|
}] });
|
|
496
488
|
|
|
@@ -571,15 +563,13 @@
|
|
|
571
563
|
var _this = this;
|
|
572
564
|
this._route = {
|
|
573
565
|
url: this._skyHref,
|
|
574
|
-
userHasAccess: false
|
|
566
|
+
userHasAccess: false,
|
|
575
567
|
};
|
|
576
568
|
/* istanbul ignore else */
|
|
577
569
|
if (this.hrefResolver && this._skyHref) {
|
|
578
570
|
this.applyChanges(this.getChanges());
|
|
579
571
|
try {
|
|
580
|
-
this.hrefResolver
|
|
581
|
-
.resolveHref({ url: this._skyHref })
|
|
582
|
-
.then(function (route) {
|
|
572
|
+
this.hrefResolver.resolveHref({ url: this._skyHref }).then(function (route) {
|
|
583
573
|
_this._route = Object.assign({}, route);
|
|
584
574
|
_this.applyChanges(_this.getChanges());
|
|
585
575
|
});
|
|
@@ -599,7 +589,7 @@
|
|
|
599
589
|
if (!this._route || !this._route.userHasAccess) {
|
|
600
590
|
return {
|
|
601
591
|
href: '',
|
|
602
|
-
hidden: this._skyHrefElse === 'hide'
|
|
592
|
+
hidden: this._skyHrefElse === 'hide',
|
|
603
593
|
};
|
|
604
594
|
}
|
|
605
595
|
else {
|
|
@@ -612,14 +602,17 @@
|
|
|
612
602
|
});
|
|
613
603
|
}
|
|
614
604
|
var queryParamsMerged = new http.HttpParams({
|
|
615
|
-
fromObject: Object.assign({}, this.getSkyuxParams(), queryParams)
|
|
605
|
+
fromObject: Object.assign({}, this.getSkyuxParams(), queryParams),
|
|
616
606
|
});
|
|
617
|
-
this._href =
|
|
618
|
-
|
|
619
|
-
|
|
607
|
+
this._href =
|
|
608
|
+
baseUrl +
|
|
609
|
+
(queryParamsMerged.keys().length > 0
|
|
610
|
+
? '?' + queryParamsMerged.toString()
|
|
611
|
+
: '') +
|
|
612
|
+
(fragment ? "#" + fragment : '');
|
|
620
613
|
return {
|
|
621
614
|
href: this._href,
|
|
622
|
-
hidden: false
|
|
615
|
+
hidden: false,
|
|
623
616
|
};
|
|
624
617
|
}
|
|
625
618
|
};
|
|
@@ -633,7 +626,9 @@
|
|
|
633
626
|
SkyHrefDirective.prototype.getUrlTree = function () {
|
|
634
627
|
var _a, _b, _c, _d, _e;
|
|
635
628
|
var href = this._href.toLowerCase();
|
|
636
|
-
if (!href ||
|
|
629
|
+
if (!href ||
|
|
630
|
+
!((_b = (_a = this.skyAppConfig) === null || _a === void 0 ? void 0 : _a.skyux.host) === null || _b === void 0 ? void 0 : _b.url) ||
|
|
631
|
+
!((_e = (_d = (_c = this.skyAppConfig) === null || _c === void 0 ? void 0 : _c.runtime) === null || _d === void 0 ? void 0 : _d.app) === null || _e === void 0 ? void 0 : _e.base)) {
|
|
637
632
|
return false;
|
|
638
633
|
}
|
|
639
634
|
var baseUrl = (this.skyAppConfig.skyux.host.url +
|
|
@@ -650,12 +645,12 @@
|
|
|
650
645
|
};
|
|
651
646
|
return SkyHrefDirective;
|
|
652
647
|
}());
|
|
653
|
-
SkyHrefDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
|
654
|
-
SkyHrefDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.
|
|
655
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
|
648
|
+
SkyHrefDirective.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyHrefDirective, deps: [{ token: i1__namespace.Router }, { token: i0__namespace.Renderer2 }, { token: i0__namespace.ElementRef }, { token: i4__namespace.SkyAppConfig, optional: true }, { token: i4__namespace.SkyAppRuntimeConfigParamsProvider, optional: true }, { token: SkyHrefResolverService, optional: true }], target: i0__namespace.ɵɵFactoryTarget.Directive });
|
|
649
|
+
SkyHrefDirective.ɵdir = i0__namespace.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: SkyHrefDirective, selector: "[skyHref]", inputs: { skyHref: "skyHref", skyHrefElse: "skyHrefElse" }, host: { listeners: { "click": "onClick($event.button,$event.ctrlKey,$event.shiftKey,$event.altKey,$event.metaKey)" } }, ngImport: i0__namespace });
|
|
650
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyHrefDirective, decorators: [{
|
|
656
651
|
type: i0.Directive,
|
|
657
652
|
args: [{
|
|
658
|
-
selector: '[skyHref]'
|
|
653
|
+
selector: '[skyHref]',
|
|
659
654
|
}]
|
|
660
655
|
}], ctorParameters: function () {
|
|
661
656
|
return [{ type: i1__namespace.Router }, { type: i0__namespace.Renderer2 }, { type: i0__namespace.ElementRef }, { type: i4__namespace.SkyAppConfig, decorators: [{
|
|
@@ -671,8 +666,13 @@
|
|
|
671
666
|
type: i0.Input
|
|
672
667
|
}], onClick: [{
|
|
673
668
|
type: i0.HostListener,
|
|
674
|
-
args: ['click',
|
|
675
|
-
|
|
669
|
+
args: ['click', [
|
|
670
|
+
'$event.button',
|
|
671
|
+
'$event.ctrlKey',
|
|
672
|
+
'$event.shiftKey',
|
|
673
|
+
'$event.altKey',
|
|
674
|
+
'$event.metaKey',
|
|
675
|
+
]]
|
|
676
676
|
}] } });
|
|
677
677
|
|
|
678
678
|
var SkyHrefModule = /** @class */ (function () {
|
|
@@ -680,15 +680,15 @@
|
|
|
680
680
|
}
|
|
681
681
|
return SkyHrefModule;
|
|
682
682
|
}());
|
|
683
|
-
SkyHrefModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.
|
|
684
|
-
SkyHrefModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.
|
|
685
|
-
SkyHrefModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.
|
|
686
|
-
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.
|
|
683
|
+
SkyHrefModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyHrefModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
|
|
684
|
+
SkyHrefModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyHrefModule, declarations: [SkyHrefDirective], imports: [i2.CommonModule], exports: [SkyHrefDirective] });
|
|
685
|
+
SkyHrefModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyHrefModule, imports: [[i2.CommonModule]] });
|
|
686
|
+
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0__namespace, type: SkyHrefModule, decorators: [{
|
|
687
687
|
type: i0.NgModule,
|
|
688
688
|
args: [{
|
|
689
689
|
declarations: [SkyHrefDirective],
|
|
690
690
|
exports: [SkyHrefDirective],
|
|
691
|
-
imports: [i2.CommonModule]
|
|
691
|
+
imports: [i2.CommonModule],
|
|
692
692
|
}]
|
|
693
693
|
}] });
|
|
694
694
|
|
|
@@ -699,11 +699,11 @@
|
|
|
699
699
|
exports.SkyAppLinkModule = SkyAppLinkModule;
|
|
700
700
|
exports.SkyHrefModule = SkyHrefModule;
|
|
701
701
|
exports.SkyHrefResolverService = SkyHrefResolverService;
|
|
702
|
-
exports
|
|
703
|
-
exports
|
|
704
|
-
exports
|
|
702
|
+
exports["λ1"] = SkyHrefDirective;
|
|
703
|
+
exports["λ2"] = SkyAppLinkExternalDirective;
|
|
704
|
+
exports["λ3"] = SkyAppLinkDirective;
|
|
705
705
|
|
|
706
706
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
707
707
|
|
|
708
|
-
}))
|
|
708
|
+
}));
|
|
709
709
|
//# sourceMappingURL=skyux-router.umd.js.map
|
package/esm2015/index.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './lib/modules/link/link-query-params';
|
|
2
|
+
export * from './lib/modules/link/link.module';
|
|
3
|
+
export * from './lib/modules/href/href.module';
|
|
4
|
+
export * from './lib/modules/href/href-resolver';
|
|
5
|
+
export * from './lib/modules/href/href-resolver.service';
|
|
6
|
+
export * from './lib/modules/href/types/href';
|
|
7
|
+
export * from './lib/modules/href/types/href-resolver.args';
|
|
8
|
+
// Components and directives must be exported to support Angular's "partial" Ivy compiler.
|
|
9
|
+
// Obscure names are used to indicate types are not part of public API.
|
|
10
|
+
export { SkyHrefDirective as λ1 } from './lib/modules/href/href.directive';
|
|
11
|
+
export { SkyAppLinkExternalDirective as λ2 } from './lib/modules/link/link-external.directive';
|
|
12
|
+
export { SkyAppLinkDirective as λ3 } from './lib/modules/link/link.directive';
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../libs/components/router/src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sCAAsC,CAAC;AACrD,cAAc,gCAAgC,CAAC;AAC/C,cAAc,gCAAgC,CAAC;AAC/C,cAAc,kCAAkC,CAAC;AACjD,cAAc,0CAA0C,CAAC;AACzD,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6CAA6C,CAAC;AAE5D,0FAA0F;AAC1F,uEAAuE;AACvE,OAAO,EAAE,gBAAgB,IAAI,EAAE,EAAE,MAAM,mCAAmC,CAAC;AAC3E,OAAO,EAAE,2BAA2B,IAAI,EAAE,EAAE,MAAM,4CAA4C,CAAC;AAC/F,OAAO,EAAE,mBAAmB,IAAI,EAAE,EAAE,MAAM,mCAAmC,CAAC","sourcesContent":["export * from './lib/modules/link/link-query-params';\nexport * from './lib/modules/link/link.module';\nexport * from './lib/modules/href/href.module';\nexport * from './lib/modules/href/href-resolver';\nexport * from './lib/modules/href/href-resolver.service';\nexport * from './lib/modules/href/types/href';\nexport * from './lib/modules/href/types/href-resolver.args';\n\n// Components and directives must be exported to support Angular's \"partial\" Ivy compiler.\n// Obscure names are used to indicate types are not part of public API.\nexport { SkyHrefDirective as λ1 } from './lib/modules/href/href.directive';\nexport { SkyAppLinkExternalDirective as λ2 } from './lib/modules/link/link-external.directive';\nexport { SkyAppLinkDirective as λ3 } from './lib/modules/link/link.directive';\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"href-query-params.js","sourceRoot":"","sources":["../../../../../../../../libs/components/router/src/lib/modules/href/href-query-params.ts"],"names":[],"mappings":"","sourcesContent":["export type SkyHrefQueryParams = { [k: string]: any };\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"href-resolver.js","sourceRoot":"","sources":["../../../../../../../../libs/components/router/src/lib/modules/href/href-resolver.ts"],"names":[],"mappings":"","sourcesContent":["import { SkyHref } from './types/href';\n\nexport interface SkyHrefResolver {\n resolveHref(param: { url: string }): Promise<SkyHref>;\n}\n"]}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Injectable } from '@angular/core';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
/**
|
|
4
|
+
* Return the link as-is.
|
|
5
|
+
*/
|
|
6
|
+
export class SkyHrefResolverService {
|
|
7
|
+
resolveHref(args) {
|
|
8
|
+
return Promise.resolve({
|
|
9
|
+
url: args.url,
|
|
10
|
+
userHasAccess: true,
|
|
11
|
+
});
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
SkyHrefResolverService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyHrefResolverService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
|
|
15
|
+
SkyHrefResolverService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyHrefResolverService });
|
|
16
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyHrefResolverService, decorators: [{
|
|
17
|
+
type: Injectable
|
|
18
|
+
}] });
|
|
19
|
+
//# sourceMappingURL=href-resolver.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"href-resolver.service.js","sourceRoot":"","sources":["../../../../../../../../libs/components/router/src/lib/modules/href/href-resolver.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;;AAM3C;;GAEG;AAEH,MAAM,OAAO,sBAAsB;IAC1B,WAAW,CAAC,IAAyB;QAC1C,OAAO,OAAO,CAAC,OAAO,CAAU;YAC9B,GAAG,EAAE,IAAI,CAAC,GAAG;YACb,aAAa,EAAE,IAAI;SACpB,CAAC,CAAC;IACL,CAAC;;oHANU,sBAAsB;wHAAtB,sBAAsB;4FAAtB,sBAAsB;kBADlC,UAAU","sourcesContent":["import { Injectable } from '@angular/core';\n\nimport { SkyHrefResolver } from './href-resolver';\nimport { SkyHref } from './types/href';\nimport { SkyHrefResolverArgs } from './types/href-resolver.args';\n\n/**\n * Return the link as-is.\n */\n@Injectable()\nexport class SkyHrefResolverService implements SkyHrefResolver {\n public resolveHref(args: SkyHrefResolverArgs): Promise<SkyHref> {\n return Promise.resolve<SkyHref>({\n url: args.url,\n userHasAccess: true,\n });\n }\n}\n"]}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
import { HttpParams } from '@angular/common/http';
|
|
2
|
+
import { Directive, ElementRef, HostListener, Input, Optional, Renderer2, } from '@angular/core';
|
|
3
|
+
import { Router } from '@angular/router';
|
|
4
|
+
import { SkyAppConfig, SkyAppRuntimeConfigParamsProvider } from '@skyux/config';
|
|
5
|
+
import { SkyHrefResolverService } from './href-resolver.service';
|
|
6
|
+
import * as i0 from "@angular/core";
|
|
7
|
+
import * as i1 from "@angular/router";
|
|
8
|
+
import * as i2 from "@skyux/config";
|
|
9
|
+
import * as i3 from "./href-resolver.service";
|
|
10
|
+
export class SkyHrefDirective {
|
|
11
|
+
constructor(router, renderer, element, skyAppConfig, paramsProvider, hrefResolver) {
|
|
12
|
+
this.router = router;
|
|
13
|
+
this.renderer = renderer;
|
|
14
|
+
this.element = element;
|
|
15
|
+
this.skyAppConfig = skyAppConfig;
|
|
16
|
+
this.paramsProvider = paramsProvider;
|
|
17
|
+
this.hrefResolver = hrefResolver;
|
|
18
|
+
this._route = false;
|
|
19
|
+
this._skyHref = '';
|
|
20
|
+
this._skyHrefElse = 'hide';
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Provide a link as a string or as an array of strings to be joined by a slash to form a complete
|
|
24
|
+
* URL.
|
|
25
|
+
*
|
|
26
|
+
* @param skyHref
|
|
27
|
+
*/
|
|
28
|
+
set skyHref(skyHref) {
|
|
29
|
+
if (typeof skyHref === 'string') {
|
|
30
|
+
this._skyHref = skyHref;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
this._skyHref = skyHref.join('/');
|
|
34
|
+
}
|
|
35
|
+
this.checkRouteAccess();
|
|
36
|
+
}
|
|
37
|
+
set skyHrefElse(value) {
|
|
38
|
+
this._skyHrefElse = value;
|
|
39
|
+
this.applyChanges(this.getChanges());
|
|
40
|
+
}
|
|
41
|
+
/* istanbul ignore next */
|
|
42
|
+
onClick(button, ctrlKey, shiftKey, altKey, metaKey) {
|
|
43
|
+
if (!this._route || !this._route.userHasAccess) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
if (button !== 0 || ctrlKey || shiftKey || altKey || metaKey) {
|
|
47
|
+
return true;
|
|
48
|
+
}
|
|
49
|
+
const target = this.element.nativeElement.getAttribute('target');
|
|
50
|
+
if (typeof target === 'string' && target !== '_self') {
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
const urlTree = this.getUrlTree();
|
|
54
|
+
if (urlTree) {
|
|
55
|
+
this.router.navigateByUrl(urlTree);
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
return true;
|
|
59
|
+
}
|
|
60
|
+
applyChanges(change) {
|
|
61
|
+
this.renderer.addClass(this.element.nativeElement, 'sky-href');
|
|
62
|
+
if (change.hidden) {
|
|
63
|
+
this.renderer.setAttribute(this.element.nativeElement, 'hidden', 'hidden');
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
this.renderer.removeAttribute(this.element.nativeElement, 'hidden');
|
|
67
|
+
}
|
|
68
|
+
if (change.href) {
|
|
69
|
+
this.renderer.setAttribute(this.element.nativeElement, 'href', change.href);
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
this.renderer.removeAttribute(this.element.nativeElement, 'href');
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
checkRouteAccess() {
|
|
76
|
+
this._route = {
|
|
77
|
+
url: this._skyHref,
|
|
78
|
+
userHasAccess: false,
|
|
79
|
+
};
|
|
80
|
+
/* istanbul ignore else */
|
|
81
|
+
if (this.hrefResolver && this._skyHref) {
|
|
82
|
+
this.applyChanges(this.getChanges());
|
|
83
|
+
try {
|
|
84
|
+
this.hrefResolver.resolveHref({ url: this._skyHref }).then((route) => {
|
|
85
|
+
this._route = Object.assign({}, route);
|
|
86
|
+
this.applyChanges(this.getChanges());
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
catch (error) {
|
|
90
|
+
this.applyChanges(this.getChanges());
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
// no resolver or skyHref is falsy
|
|
95
|
+
this._route.userHasAccess = !!this._skyHref;
|
|
96
|
+
this.applyChanges(this.getChanges());
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
getChanges() {
|
|
100
|
+
let queryParams = {};
|
|
101
|
+
if (!this._route || !this._route.userHasAccess) {
|
|
102
|
+
return {
|
|
103
|
+
href: '',
|
|
104
|
+
hidden: this._skyHrefElse === 'hide',
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
else {
|
|
108
|
+
const [beforeFragment, fragment] = this._route.url.split('#', 2);
|
|
109
|
+
const [baseUrl, search] = beforeFragment.split('?', 2);
|
|
110
|
+
if (search) {
|
|
111
|
+
const searchParams = new HttpParams({ fromString: search });
|
|
112
|
+
searchParams.keys().forEach((key) => {
|
|
113
|
+
queryParams[key] = searchParams.get(key);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
const queryParamsMerged = new HttpParams({
|
|
117
|
+
fromObject: Object.assign({}, this.getSkyuxParams(), queryParams),
|
|
118
|
+
});
|
|
119
|
+
this._href =
|
|
120
|
+
baseUrl +
|
|
121
|
+
(queryParamsMerged.keys().length > 0
|
|
122
|
+
? '?' + queryParamsMerged.toString()
|
|
123
|
+
: '') +
|
|
124
|
+
(fragment ? `#${fragment}` : '');
|
|
125
|
+
return {
|
|
126
|
+
href: this._href,
|
|
127
|
+
hidden: false,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
getSkyuxParams() {
|
|
132
|
+
var _a, _b;
|
|
133
|
+
return typeof ((_b = (_a = this.skyAppConfig) === null || _a === void 0 ? void 0 : _a.runtime.params) === null || _b === void 0 ? void 0 : _b.getAll) === 'function'
|
|
134
|
+
? this.skyAppConfig.runtime.params.getAll(true)
|
|
135
|
+
: this.paramsProvider.params.getAll(true);
|
|
136
|
+
}
|
|
137
|
+
/* istanbul ignore next */
|
|
138
|
+
getUrlTree() {
|
|
139
|
+
var _a, _b, _c, _d, _e;
|
|
140
|
+
const href = this._href.toLowerCase();
|
|
141
|
+
if (!href ||
|
|
142
|
+
!((_b = (_a = this.skyAppConfig) === null || _a === void 0 ? void 0 : _a.skyux.host) === null || _b === void 0 ? void 0 : _b.url) ||
|
|
143
|
+
!((_e = (_d = (_c = this.skyAppConfig) === null || _c === void 0 ? void 0 : _c.runtime) === null || _d === void 0 ? void 0 : _d.app) === null || _e === void 0 ? void 0 : _e.base)) {
|
|
144
|
+
return false;
|
|
145
|
+
}
|
|
146
|
+
const baseUrl = (this.skyAppConfig.skyux.host.url +
|
|
147
|
+
this.skyAppConfig.runtime.app.base.substr(0, this.skyAppConfig.runtime.app.base.length - 1)).toLowerCase();
|
|
148
|
+
if (href === baseUrl ||
|
|
149
|
+
// Make sure the base URL is not simply a partial match of the base URL plus additional
|
|
150
|
+
// characters after the base URL that are not "terminating" characters
|
|
151
|
+
href.indexOf(baseUrl + '/') === 0 ||
|
|
152
|
+
href.indexOf(baseUrl + '?') === 0) {
|
|
153
|
+
const routePath = this._href.substring(baseUrl.length);
|
|
154
|
+
return this.router.parseUrl(routePath);
|
|
155
|
+
}
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
SkyHrefDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyHrefDirective, deps: [{ token: i1.Router }, { token: i0.Renderer2 }, { token: i0.ElementRef }, { token: i2.SkyAppConfig, optional: true }, { token: i2.SkyAppRuntimeConfigParamsProvider, optional: true }, { token: i3.SkyHrefResolverService, optional: true }], target: i0.ɵɵFactoryTarget.Directive });
|
|
160
|
+
SkyHrefDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "12.2.16", type: SkyHrefDirective, selector: "[skyHref]", inputs: { skyHref: "skyHref", skyHrefElse: "skyHrefElse" }, host: { listeners: { "click": "onClick($event.button,$event.ctrlKey,$event.shiftKey,$event.altKey,$event.metaKey)" } }, ngImport: i0 });
|
|
161
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyHrefDirective, decorators: [{
|
|
162
|
+
type: Directive,
|
|
163
|
+
args: [{
|
|
164
|
+
selector: '[skyHref]',
|
|
165
|
+
}]
|
|
166
|
+
}], ctorParameters: function () { return [{ type: i1.Router }, { type: i0.Renderer2 }, { type: i0.ElementRef }, { type: i2.SkyAppConfig, decorators: [{
|
|
167
|
+
type: Optional
|
|
168
|
+
}] }, { type: i2.SkyAppRuntimeConfigParamsProvider, decorators: [{
|
|
169
|
+
type: Optional
|
|
170
|
+
}] }, { type: i3.SkyHrefResolverService, decorators: [{
|
|
171
|
+
type: Optional
|
|
172
|
+
}] }]; }, propDecorators: { skyHref: [{
|
|
173
|
+
type: Input
|
|
174
|
+
}], skyHrefElse: [{
|
|
175
|
+
type: Input
|
|
176
|
+
}], onClick: [{
|
|
177
|
+
type: HostListener,
|
|
178
|
+
args: ['click', [
|
|
179
|
+
'$event.button',
|
|
180
|
+
'$event.ctrlKey',
|
|
181
|
+
'$event.shiftKey',
|
|
182
|
+
'$event.altKey',
|
|
183
|
+
'$event.metaKey',
|
|
184
|
+
]]
|
|
185
|
+
}] } });
|
|
186
|
+
//# sourceMappingURL=href.directive.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"href.directive.js","sourceRoot":"","sources":["../../../../../../../../libs/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ACtB;;0BAqCI,QAAQ;;0BACR,QAAQ;;0BACR,QAAQ;4CA9BA,OAAO;sBADjB,KAAK;gBAYK,WAAW;sBADrB,KAAK;gBA+BC,OAAO;sBAPb,YAAY;uBAAC,OAAO,EAAE;wBACrB,eAAe;wBACf,gBAAgB;wBAChB,iBAAiB;wBACjB,eAAe;wBACf,gBAAgB;qBACjB","sourcesContent":["import { HttpParams } from '@angular/common/http';\nimport {\n Directive,\n ElementRef,\n HostListener,\n Input,\n Optional,\n Renderer2,\n} from '@angular/core';\nimport { Router, UrlTree } from '@angular/router';\nimport { SkyAppConfig, SkyAppRuntimeConfigParamsProvider } from '@skyux/config';\n\nimport { SkyHrefQueryParams } from './href-query-params';\nimport { SkyHrefResolverService } from './href-resolver.service';\n\nimport { SkyHref } from './types/href';\n\ntype HrefChanges = { href: string; hidden: boolean };\n\n@Directive({\n selector: '[skyHref]',\n})\nexport class SkyHrefDirective {\n /**\n * Provide a link as a string or as an array of strings to be joined by a slash to form a complete\n * URL.\n *\n * @param skyHref\n */\n @Input()\n public set skyHref(skyHref: string | string[]) {\n if (typeof skyHref === 'string') {\n this._skyHref = skyHref;\n } else {\n this._skyHref = skyHref.join('/');\n }\n\n this.checkRouteAccess();\n }\n\n @Input()\n public set skyHrefElse(value: 'hide' | 'unlink') {\n this._skyHrefElse = value;\n this.applyChanges(this.getChanges());\n }\n\n private _route: SkyHref | false = false;\n\n private _href: string;\n\n private _skyHref = '';\n\n private _skyHrefElse: 'hide' | 'unlink' = 'hide';\n\n constructor(\n private router: Router,\n private renderer: Renderer2,\n private element: ElementRef,\n @Optional() private skyAppConfig?: SkyAppConfig,\n @Optional() private paramsProvider?: SkyAppRuntimeConfigParamsProvider,\n @Optional() private hrefResolver?: SkyHrefResolverService\n ) {}\n\n /* istanbul ignore next */\n @HostListener('click', [\n '$event.button',\n '$event.ctrlKey',\n '$event.shiftKey',\n '$event.altKey',\n '$event.metaKey',\n ])\n public onClick(\n button: number,\n ctrlKey: boolean,\n shiftKey: boolean,\n altKey: boolean,\n metaKey: boolean\n ): boolean {\n if (!this._route || !this._route.userHasAccess) {\n return false;\n }\n\n if (button !== 0 || ctrlKey || shiftKey || altKey || metaKey) {\n return true;\n }\n\n const target = this.element.nativeElement.getAttribute('target');\n if (typeof target === 'string' && target !== '_self') {\n return true;\n }\n\n const urlTree = this.getUrlTree();\n if (urlTree) {\n this.router.navigateByUrl(urlTree);\n return false;\n }\n return true;\n }\n\n private applyChanges(change: HrefChanges) {\n this.renderer.addClass(this.element.nativeElement, 'sky-href');\n if (change.hidden) {\n this.renderer.setAttribute(\n this.element.nativeElement,\n 'hidden',\n 'hidden'\n );\n } else {\n this.renderer.removeAttribute(this.element.nativeElement, 'hidden');\n }\n if (change.href) {\n this.renderer.setAttribute(\n this.element.nativeElement,\n 'href',\n change.href\n );\n } else {\n this.renderer.removeAttribute(this.element.nativeElement, 'href');\n }\n }\n\n private checkRouteAccess() {\n this._route = {\n url: this._skyHref,\n userHasAccess: false,\n };\n /* istanbul ignore else */\n if (this.hrefResolver && this._skyHref) {\n this.applyChanges(this.getChanges());\n try {\n this.hrefResolver.resolveHref({ url: this._skyHref }).then((route) => {\n this._route = { ...route };\n this.applyChanges(this.getChanges());\n });\n } catch (error) {\n this.applyChanges(this.getChanges());\n }\n } else {\n // no resolver or skyHref is falsy\n this._route.userHasAccess = !!this._skyHref;\n this.applyChanges(this.getChanges());\n }\n }\n\n private getChanges(): HrefChanges {\n let queryParams: SkyHrefQueryParams = {};\n\n if (!this._route || !this._route.userHasAccess) {\n return {\n href: '',\n hidden: this._skyHrefElse === 'hide',\n };\n } else {\n const [beforeFragment, fragment] = this._route.url.split('#', 2);\n const [baseUrl, search] = beforeFragment.split('?', 2);\n\n if (search) {\n const searchParams = new HttpParams({ fromString: search });\n searchParams.keys().forEach((key) => {\n queryParams[key] = searchParams.get(key);\n });\n }\n\n const queryParamsMerged = new HttpParams({\n fromObject: Object.assign({}, this.getSkyuxParams(), queryParams),\n });\n\n this._href =\n baseUrl +\n (queryParamsMerged.keys().length > 0\n ? '?' + queryParamsMerged.toString()\n : '') +\n (fragment ? `#${fragment}` : '');\n return {\n href: this._href,\n hidden: false,\n };\n }\n }\n\n private getSkyuxParams(): SkyHrefQueryParams {\n return typeof this.skyAppConfig?.runtime.params?.getAll === 'function'\n ? this.skyAppConfig.runtime.params.getAll(true)\n : this.paramsProvider.params.getAll(true);\n }\n\n /* istanbul ignore next */\n private getUrlTree(): UrlTree | false {\n const href = this._href.toLowerCase();\n\n if (\n !href ||\n !this.skyAppConfig?.skyux.host?.url ||\n !this.skyAppConfig?.runtime?.app?.base\n ) {\n return false;\n }\n\n const baseUrl = (\n this.skyAppConfig.skyux.host.url +\n this.skyAppConfig.runtime.app.base.substr(\n 0,\n this.skyAppConfig.runtime.app.base.length - 1\n )\n ).toLowerCase();\n\n if (\n href === baseUrl ||\n // Make sure the base URL is not simply a partial match of the base URL plus additional\n // characters after the base URL that are not \"terminating\" characters\n href.indexOf(baseUrl + '/') === 0 ||\n href.indexOf(baseUrl + '?') === 0\n ) {\n const routePath = this._href.substring(baseUrl.length);\n return this.router.parseUrl(routePath);\n }\n\n return false;\n }\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CommonModule } from '@angular/common';
|
|
2
|
+
import { NgModule } from '@angular/core';
|
|
3
|
+
import { SkyHrefDirective } from './href.directive';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
export class SkyHrefModule {
|
|
6
|
+
}
|
|
7
|
+
SkyHrefModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyHrefModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
|
|
8
|
+
SkyHrefModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyHrefModule, declarations: [SkyHrefDirective], imports: [CommonModule], exports: [SkyHrefDirective] });
|
|
9
|
+
SkyHrefModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyHrefModule, imports: [[CommonModule]] });
|
|
10
|
+
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.16", ngImport: i0, type: SkyHrefModule, decorators: [{
|
|
11
|
+
type: NgModule,
|
|
12
|
+
args: [{
|
|
13
|
+
declarations: [SkyHrefDirective],
|
|
14
|
+
exports: [SkyHrefDirective],
|
|
15
|
+
imports: [CommonModule],
|
|
16
|
+
}]
|
|
17
|
+
}] });
|
|
18
|
+
//# sourceMappingURL=href.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"href.module.js","sourceRoot":"","sources":["../../../../../../../../libs/components/router/src/lib/modules/href/href.module.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;;AAOpD,MAAM,OAAO,aAAa;;2GAAb,aAAa;4GAAb,aAAa,iBAJT,gBAAgB,aAErB,YAAY,aADZ,gBAAgB;4GAGf,aAAa,YAFf,CAAC,YAAY,CAAC;4FAEZ,aAAa;kBALzB,QAAQ;mBAAC;oBACR,YAAY,EAAE,CAAC,gBAAgB,CAAC;oBAChC,OAAO,EAAE,CAAC,gBAAgB,CAAC;oBAC3B,OAAO,EAAE,CAAC,YAAY,CAAC;iBACxB","sourcesContent":["import { CommonModule } from '@angular/common';\nimport { NgModule } from '@angular/core';\n\nimport { SkyHrefDirective } from './href.directive';\n\n@NgModule({\n declarations: [SkyHrefDirective],\n exports: [SkyHrefDirective],\n imports: [CommonModule],\n})\nexport class SkyHrefModule {}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"href-resolver.args.js","sourceRoot":"","sources":["../../../../../../../../../libs/components/router/src/lib/modules/href/types/href-resolver.args.ts"],"names":[],"mappings":"","sourcesContent":["export type SkyHrefResolverArgs = { url: string };\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"href.js","sourceRoot":"","sources":["../../../../../../../../../libs/components/router/src/lib/modules/href/types/href.ts"],"names":[],"mappings":"","sourcesContent":["export interface SkyHref {\n app?: string;\n route?: string;\n url: string;\n userHasAccess?: boolean;\n aliases?: string[];\n}\n"]}
|