@a11d/lit-application 0.6.1 → 0.7.0-preview.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/dist/Application.d.ts.map +1 -1
- package/dist/Application.js +45 -45
- package/dist/Dialog/DialogComponent.d.ts +5 -7
- package/dist/Dialog/DialogComponent.d.ts.map +1 -1
- package/dist/Dialog/DialogComponent.js +35 -39
- package/dist/Notification/NotificationComponent.d.ts.map +1 -1
- package/dist/Page/Page.d.ts +1 -1
- package/dist/Page/Page.d.ts.map +1 -1
- package/dist/Page/PageComponent.d.ts +4 -8
- package/dist/Page/PageComponent.d.ts.map +1 -1
- package/dist/Page/PageComponent.js +3 -22
- package/dist/Page/PageError.d.ts +1 -1
- package/dist/Page/PageError.d.ts.map +1 -1
- package/dist/Page/PageError.js +24 -24
- package/dist/Page/PageHost.js +6 -6
- package/dist/Router/RoutableComponent.d.ts +44 -0
- package/dist/Router/RoutableComponent.d.ts.map +1 -0
- package/dist/Router/RoutableComponent.js +127 -0
- package/dist/Router/RoutableComponent.test.d.ts +2 -0
- package/dist/Router/RoutableComponent.test.d.ts.map +1 -0
- package/dist/Router/RoutableComponent.test.js +102 -0
- package/dist/Router/RouterController.d.ts +2 -3
- package/dist/Router/RouterController.d.ts.map +1 -1
- package/dist/Router/RouterController.js +15 -18
- package/dist/Router/index.d.ts +2 -2
- package/dist/Router/index.d.ts.map +1 -1
- package/dist/Router/index.js +2 -2
- package/dist/Router/path.d.ts +10 -0
- package/dist/Router/path.d.ts.map +1 -0
- package/dist/Router/path.js +8 -0
- package/dist/Router/path.test.d.ts +2 -0
- package/dist/Router/path.test.d.ts.map +1 -0
- package/dist/Router/path.test.js +17 -0
- package/dist/Router/route.d.ts +4 -4
- package/dist/Router/route.d.ts.map +1 -1
- package/dist/Router/route.js +10 -16
- package/dist/Router/routerLink.d.ts +5 -5
- package/dist/Router/routerLink.d.ts.map +1 -1
- package/dist/Router/routerLink.js +4 -5
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/utilities/HookSet.d.ts +1 -1
- package/dist/utilities/HookSet.d.ts.map +1 -1
- package/dist/utilities/WindowHelper.d.ts +1 -1
- package/dist/utilities/WindowHelper.d.ts.map +1 -1
- package/dist/utilities/WindowHelper.js +2 -2
- package/dist/utilities/queryInstanceElement.d.ts +1 -1
- package/dist/utilities/queryInstanceElement.d.ts.map +1 -1
- package/dist/utilities/querySymbolizedElement.d.ts +1 -1
- package/dist/utilities/querySymbolizedElement.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/Router/Routable.d.ts +0 -12
- package/dist/Router/Routable.d.ts.map +0 -1
- package/dist/Router/Routable.js +0 -6
- package/dist/Router/Router.d.ts +0 -27
- package/dist/Router/Router.d.ts.map +0 -1
- package/dist/Router/Router.js +0 -73
- package/dist/Router/Router.test.d.ts +0 -2
- package/dist/Router/Router.test.d.ts.map +0 -1
- package/dist/Router/Router.test.js +0 -52
- package/dist/Router/RoutesContainer.d.ts +0 -23
- package/dist/Router/RoutesContainer.d.ts.map +0 -1
- package/dist/Router/RoutesContainer.js +0 -37
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RoutableComponent.test.d.ts","sourceRoot":"","sources":["../../Router/RoutableComponent.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { RoutableComponent, UrlMatchMode } from './RoutableComponent.js';
|
|
3
|
+
import { route } from './route.js';
|
|
4
|
+
import { component } from '@a11d/lit';
|
|
5
|
+
let WithNumericId = class WithNumericId extends RoutableComponent {
|
|
6
|
+
};
|
|
7
|
+
WithNumericId = __decorate([
|
|
8
|
+
route('/routable-with-numeric-id/:id'),
|
|
9
|
+
component('test-routable-with-numeric-id')
|
|
10
|
+
], WithNumericId);
|
|
11
|
+
let WithSubRoute = class WithSubRoute extends RoutableComponent {
|
|
12
|
+
};
|
|
13
|
+
WithSubRoute = __decorate([
|
|
14
|
+
route('/routable-with-sub-route{/:subRoute}?'),
|
|
15
|
+
component('test-routable-with-sub-route')
|
|
16
|
+
], WithSubRoute);
|
|
17
|
+
let WithNonRouteParameter = class WithNonRouteParameter extends RoutableComponent {
|
|
18
|
+
};
|
|
19
|
+
WithNonRouteParameter = __decorate([
|
|
20
|
+
route('/routable-with-non-route-parameter'),
|
|
21
|
+
component('test-routable-with-non-route-parameter')
|
|
22
|
+
], WithNonRouteParameter);
|
|
23
|
+
let WithoutRoute = class WithoutRoute extends RoutableComponent {
|
|
24
|
+
};
|
|
25
|
+
WithoutRoute = __decorate([
|
|
26
|
+
component('test-routable-without-route')
|
|
27
|
+
], WithoutRoute);
|
|
28
|
+
describe('RoutableComponent', () => {
|
|
29
|
+
describe('routes', () => {
|
|
30
|
+
it('should return the routes of the component', () => {
|
|
31
|
+
expect(WithNumericId.routes).toEqual(['/routable-with-numeric-id/:id']);
|
|
32
|
+
expect(WithSubRoute.routes).toEqual(['/routable-with-sub-route{/:subRoute}?']);
|
|
33
|
+
expect(WithNonRouteParameter.routes).toEqual(['/routable-with-non-route-parameter']);
|
|
34
|
+
});
|
|
35
|
+
it('should return the routes of the component with base path', () => {
|
|
36
|
+
RoutableComponent.basePath = '/base-path';
|
|
37
|
+
expect(WithNumericId.routes).toEqual(['/base-path/routable-with-numeric-id/:id']);
|
|
38
|
+
expect(WithSubRoute.routes).toEqual(['/base-path/routable-with-sub-route{/:subRoute}?']);
|
|
39
|
+
expect(WithNonRouteParameter.routes).toEqual(['/base-path/routable-with-non-route-parameter']);
|
|
40
|
+
RoutableComponent.basePath = '';
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
describe('url', () => {
|
|
44
|
+
it('should return undefined if the given routable does not match any route', () => {
|
|
45
|
+
expect(new WithoutRoute().url).toBeUndefined();
|
|
46
|
+
});
|
|
47
|
+
it('should return the path that matches the given routable - PageWithNumericId', () => {
|
|
48
|
+
expect(new WithNumericId({ id: '1' }).url.path).toBe('/routable-with-numeric-id/1');
|
|
49
|
+
expect(new WithSubRoute({ subRoute: 'sub-route' }).url.path).toBe('/routable-with-sub-route/sub-route');
|
|
50
|
+
expect(new WithSubRoute({}).url.path).toBe('/routable-with-sub-route');
|
|
51
|
+
});
|
|
52
|
+
it('should put the parameters not part of the route in the query string', () => {
|
|
53
|
+
expect(new WithNonRouteParameter({ keyword: 'test' }).url.path).toBe('/routable-with-non-route-parameter?keyword=test');
|
|
54
|
+
expect(new WithNumericId({ id: 1, view: 'details' }).url.path).toBe('/routable-with-numeric-id/1?view=details');
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
describe('urlMatches', () => {
|
|
58
|
+
const url = (path) => new URL(path, globalThis.location.toString());
|
|
59
|
+
describe('mode: all', () => {
|
|
60
|
+
it('should return true when parameters absent', () => {
|
|
61
|
+
expect(new WithSubRoute({}).urlMatches({ url: url('/routable-with-sub-route') })).toBe(true);
|
|
62
|
+
});
|
|
63
|
+
it('should return true when parameters match', () => {
|
|
64
|
+
expect(new WithNumericId({ id: '1' }).urlMatches({ url: url('/routable-with-numeric-id/1') })).toBe(true);
|
|
65
|
+
expect(new WithSubRoute({ subRoute: 'sub-route' }).urlMatches({ url: url('/routable-with-sub-route/sub-route') })).toBe(true);
|
|
66
|
+
expect(new WithNonRouteParameter({ keyword: 'test' }).urlMatches({ url: url('/routable-with-non-route-parameter?keyword=test') })).toBe(true);
|
|
67
|
+
expect(new WithNumericId({ id: '1', view: 'details' }).urlMatches({ url: url('/routable-with-numeric-id/1?view=details') })).toBe(true);
|
|
68
|
+
});
|
|
69
|
+
it('should return false if the given routable does not match the route', () => {
|
|
70
|
+
expect(new WithNumericId({ id: 1 }).urlMatches({ url: url('/routable-with-numeric-id/2') })).toBe(false);
|
|
71
|
+
expect(new WithSubRoute({ subRoute: 'sub-route' }).urlMatches({ url: url('/routable-with-sub-route') })).toBe(false);
|
|
72
|
+
expect(new WithSubRoute({}).urlMatches({ url: url('/routable-with-sub-route/sub-route') })).toBe(false);
|
|
73
|
+
expect(new WithNonRouteParameter({ keyword: 'test' }).urlMatches({ url: url('/routable-with-non-route-parameter?keyword=other') })).toBe(false);
|
|
74
|
+
expect(new WithNumericId({ id: 1, view: 'details' }).urlMatches({ url: url('/routable-with-numeric-id/1?view=other') })).toBe(false);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
describe('mode: ignore-parameters', () => {
|
|
78
|
+
const mode = UrlMatchMode.IgnoreParameters;
|
|
79
|
+
it('should return true if the given routable matches the route', () => {
|
|
80
|
+
expect(new WithNumericId({ id: 1 }).urlMatches({ mode, url: url('/routable-with-numeric-id/1') })).toBe(true);
|
|
81
|
+
expect(new WithNumericId({ id: 1 }).urlMatches({ mode, url: url('/routable-with-numeric-id/2') })).toBe(true);
|
|
82
|
+
expect(new WithSubRoute({ subRoute: 'sub-route' }).urlMatches({ mode, url: url('/routable-with-sub-route/sub-route') })).toBe(true);
|
|
83
|
+
expect(new WithSubRoute({ subRoute: 'sub-route' }).urlMatches({ mode, url: url('/routable-with-sub-route') })).toBe(true);
|
|
84
|
+
expect(new WithSubRoute({}).urlMatches({ mode, url: url('/routable-with-sub-route') })).toBe(true);
|
|
85
|
+
expect(new WithSubRoute({}).urlMatches({ mode, url: url('/routable-with-sub-route/sub-route') })).toBe(true);
|
|
86
|
+
expect(new WithNonRouteParameter({ keyword: 'test' }).urlMatches({ mode, url: url('/routable-with-non-route-parameter?keyword=test') })).toBe(true);
|
|
87
|
+
expect(new WithNonRouteParameter({ keyword: 'test' }).urlMatches({ mode, url: url('/routable-with-non-route-parameter?keyword=other') })).toBe(true);
|
|
88
|
+
expect(new WithNumericId({ id: 1, view: 'details' }).urlMatches({ mode, url: url('/routable-with-numeric-id/1?view=details') })).toBe(true);
|
|
89
|
+
expect(new WithNumericId({ id: 1, view: 'details' }).urlMatches({ mode, url: url('/routable-with-numeric-id/1?view=other') })).toBe(true);
|
|
90
|
+
});
|
|
91
|
+
it('should return false if the given routable does not match the route', () => {
|
|
92
|
+
expect(new WithNumericId({ id: 1 }).urlMatches({ mode, url: url('/xx-routable-with-numeric-id') })).toBe(false);
|
|
93
|
+
expect(new WithSubRoute({ subRoute: 'sub-route' }).urlMatches({ mode, url: url('/xx-routable-with-sub-route/sub-route') })).toBe(false);
|
|
94
|
+
expect(new WithSubRoute({}).urlMatches({ mode, url: url('/xx-routable-with-sub-route') })).toBe(false);
|
|
95
|
+
expect(new WithSubRoute({}).urlMatches({ mode, url: url('/xx-routable-with-sub-route/sub-route') })).toBe(false);
|
|
96
|
+
expect(new WithNonRouteParameter({ keyword: 'test' }).urlMatches({ mode, url: url('/xx-routable-with-non-route-parameter?keyword=test') })).toBe(false);
|
|
97
|
+
expect(new WithNonRouteParameter({ keyword: 'test' }).urlMatches({ mode, url: url('/xx-routable-with-non-route-parameter?keyword=other') })).toBe(false);
|
|
98
|
+
expect(new WithNumericId({ id: 1, view: 'details' }).urlMatches({ mode, url: url('/xx-routable-with-numeric-id/1?view=details') })).toBe(false);
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
});
|
|
102
|
+
});
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
+
import { type ReactiveControllerHost } from '@a11d/lit';
|
|
1
2
|
import { Router as RouterControllerBase } from '@lit-labs/router';
|
|
2
|
-
import { ReactiveControllerHost } from '@a11d/lit';
|
|
3
3
|
export declare class RouterController extends RouterControllerBase {
|
|
4
4
|
protected readonly host: ReactiveControllerHost & HTMLElement;
|
|
5
5
|
hostConnected(): void;
|
|
6
6
|
constructor(...args: ConstructorParameters<typeof RouterControllerBase>);
|
|
7
|
-
private
|
|
8
|
-
private importDecoratorRoutesIfAvailable;
|
|
7
|
+
private importRoutableComponents;
|
|
9
8
|
}
|
|
10
9
|
//# sourceMappingURL=RouterController.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RouterController.d.ts","sourceRoot":"","sources":["../../Router/RouterController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"RouterController.d.ts","sourceRoot":"","sources":["../../Router/RouterController.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,sBAAsB,EAA4B,MAAM,WAAW,CAAA;AACjF,OAAO,EAAE,MAAM,IAAI,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AAGjE,qBAAa,gBAAiB,SAAQ,oBAAoB;IACzD,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,sBAAsB,GAAG,WAAW,CAAA;IAEpD,aAAa;gBAKV,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,oBAAoB,CAAC;IAKvE,OAAO,CAAC,wBAAwB;CAehC"}
|
|
@@ -1,29 +1,26 @@
|
|
|
1
|
+
import { staticHtml, unsafeStatic } from '@a11d/lit';
|
|
1
2
|
import { Router as RouterControllerBase } from '@lit-labs/router';
|
|
2
|
-
import {
|
|
3
|
-
import { equals } from '@a11d/equals';
|
|
3
|
+
import { RoutableComponent } from './RoutableComponent.js';
|
|
4
4
|
export class RouterController extends RouterControllerBase {
|
|
5
5
|
hostConnected() {
|
|
6
|
-
this.
|
|
6
|
+
this.importRoutableComponents();
|
|
7
7
|
super.hostConnected();
|
|
8
8
|
}
|
|
9
9
|
constructor(...args) {
|
|
10
10
|
super(...args);
|
|
11
11
|
this.host = args[0];
|
|
12
12
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
.filter(
|
|
16
|
-
.map(
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
}
|
|
13
|
+
importRoutableComponents() {
|
|
14
|
+
this.routes.push(...[...RoutableComponent.container]
|
|
15
|
+
.filter(Constructor => this.host.constructor === Constructor.host || this.host.constructor.prototype instanceof Constructor.host)
|
|
16
|
+
.flatMap(Constructor => Constructor.routes.map(route => ({
|
|
17
|
+
path: route,
|
|
18
|
+
render: (p) => {
|
|
19
|
+
const tagName = customElements.getName(Constructor);
|
|
20
|
+
const tag = unsafeStatic(tagName);
|
|
21
|
+
const query = Object.fromEntries(RoutableComponent.url.searchParams);
|
|
22
|
+
return staticHtml `<${tag} .parameters=${{ ...p, ...query }}></${tag}>`;
|
|
23
|
+
}
|
|
24
|
+
}))));
|
|
28
25
|
}
|
|
29
26
|
}
|
package/dist/Router/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../Router/index.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAA;AAC5B,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../Router/index.ts"],"names":[],"mappings":"AAAA,OAAO,qBAAqB,CAAA;AAC5B,OAAO,WAAW,CAAA;AAClB,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,YAAY,CAAA"}
|
package/dist/Router/index.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.d.ts","sourceRoot":"","sources":["../../Router/path.ts"],"names":[],"mappings":"AAQA,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,GAAG;QACZ;;WAEG;QACH,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KACrB;CACD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"path.test.d.ts","sourceRoot":"","sources":["../../Router/path.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
describe('URL', () => {
|
|
2
|
+
describe('path', () => {
|
|
3
|
+
it('should return the path of the URL', () => {
|
|
4
|
+
const url = new URL('https://example.com/path/to/resource?query=param');
|
|
5
|
+
expect(url.path).toBe('/path/to/resource?query=param');
|
|
6
|
+
});
|
|
7
|
+
it('should return the path of the URL without query parameters', () => {
|
|
8
|
+
const url = new URL('https://example.com/path/to/resource');
|
|
9
|
+
expect(url.path).toBe('/path/to/resource');
|
|
10
|
+
});
|
|
11
|
+
it('should return an empty string for a URL with no path', () => {
|
|
12
|
+
const url = new URL('https://example.com');
|
|
13
|
+
expect(url.path).toBe('/');
|
|
14
|
+
});
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
export {};
|
package/dist/Router/route.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { Component } from '@a11d/lit';
|
|
2
|
-
import { type
|
|
3
|
-
type RouteParameters = [...routes: Array<string>] | [
|
|
4
|
-
export declare const route: (...parameters: RouteParameters) => (
|
|
1
|
+
import { type Component } from '@a11d/lit';
|
|
2
|
+
import { type RoutableComponentConstructor } from './RoutableComponent.js';
|
|
3
|
+
type RouteParameters = [...routes: Array<string>] | [host: Constructor<Component>, ...routes: Array<string>];
|
|
4
|
+
export declare const route: (...parameters: RouteParameters) => (RoutableComponentConstructor: RoutableComponentConstructor) => void;
|
|
5
5
|
export {};
|
|
6
6
|
//# sourceMappingURL=route.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../Router/route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../Router/route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,EAAqB,KAAK,4BAA4B,EAAE,MAAM,wBAAwB,CAAA;AAE7F,KAAK,eAAe,GACjB,CAAC,GAAG,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,GAC1B,CAAC,IAAI,EAAE,WAAW,CAAC,SAAS,CAAC,EAAE,GAAG,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,CAAA;AAE3D,eAAO,MAAM,KAAK,GAAI,GAAG,YAAY,eAAe,MAC3C,8BAA8B,4BAA4B,SAUlE,CAAA"}
|
package/dist/Router/route.js
CHANGED
|
@@ -1,20 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Application } from '../Application.js';
|
|
3
|
-
function getParameters(...parameters) {
|
|
4
|
-
return typeof parameters[0] === 'string'
|
|
5
|
-
? {
|
|
6
|
-
routerHostConstructor: Application,
|
|
7
|
-
routes: parameters,
|
|
8
|
-
} : {
|
|
9
|
-
routerHostConstructor: parameters[0],
|
|
10
|
-
routes: parameters.slice(1),
|
|
11
|
-
};
|
|
12
|
-
}
|
|
1
|
+
import { RoutableComponent } from './RoutableComponent.js';
|
|
13
2
|
export const route = (...parameters) => {
|
|
14
|
-
return (
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
3
|
+
return (RoutableComponentConstructor) => {
|
|
4
|
+
if (typeof parameters[0] === 'string') {
|
|
5
|
+
RoutableComponentConstructor.routes = parameters;
|
|
6
|
+
}
|
|
7
|
+
else {
|
|
8
|
+
const [host, ...routes] = parameters;
|
|
9
|
+
RoutableComponentConstructor.host = host;
|
|
10
|
+
RoutableComponentConstructor.routes = routes;
|
|
18
11
|
}
|
|
12
|
+
RoutableComponent.container.add(RoutableComponentConstructor);
|
|
19
13
|
};
|
|
20
14
|
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { AsyncDirective, ElementPart, PartInfo } from '@a11d/lit';
|
|
2
|
-
import {
|
|
1
|
+
import { AsyncDirective, type ElementPart, type PartInfo } from '@a11d/lit';
|
|
2
|
+
import { UrlMatchMode, NavigationStrategy, type RoutableComponent } from './index.js';
|
|
3
3
|
type Parameters = {
|
|
4
|
-
component:
|
|
4
|
+
component: RoutableComponent<any>;
|
|
5
5
|
navigationStrategy?: NavigationStrategy;
|
|
6
|
-
matchMode?:
|
|
6
|
+
matchMode?: UrlMatchMode;
|
|
7
7
|
selectionChangeHandler?(this: Element, selected: boolean): void;
|
|
8
8
|
invocationHandler?(): void;
|
|
9
9
|
};
|
|
10
|
-
type ShorthandParametersOrParameters = [component:
|
|
10
|
+
type ShorthandParametersOrParameters = [component: RoutableComponent<any>] | [parameters: Parameters];
|
|
11
11
|
declare class RouterLinkDirective extends AsyncDirective {
|
|
12
12
|
readonly element: Element;
|
|
13
13
|
readonly parameters: Parameters;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routerLink.d.ts","sourceRoot":"","sources":["../../Router/routerLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAa,WAAW,EAAY,QAAQ,EAAY,MAAM,WAAW,CAAA;
|
|
1
|
+
{"version":3,"file":"routerLink.d.ts","sourceRoot":"","sources":["../../Router/routerLink.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAa,KAAK,WAAW,EAAY,KAAK,QAAQ,EAAY,MAAM,WAAW,CAAA;AAC1G,OAAO,EAAE,YAAY,EAAE,kBAAkB,EAAE,KAAK,iBAAiB,EAAqC,MAAM,YAAY,CAAA;AAExH,KAAK,UAAU,GAAG;IACjB,SAAS,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAA;IACjC,kBAAkB,CAAC,EAAE,kBAAkB,CAAA;IACvC,SAAS,CAAC,EAAE,YAAY,CAAA;IACxB,sBAAsB,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAA;IAC/D,iBAAiB,CAAC,IAAI,IAAI,CAAA;CAC1B,CAAA;AAED,KAAK,+BAA+B,GACjC,CAAC,SAAS,EAAE,iBAAiB,CAAC,GAAG,CAAC,CAAC,GACnC,CAAC,UAAU,EAAE,UAAU,CAAC,CAAA;AAY3B,cAAM,mBAAoB,SAAQ,cAAc;IAC/C,QAAQ,CAAC,OAAO,EAAG,OAAO,CAAA;IAC1B,QAAQ,CAAC,UAAU,EAAG,UAAU,CAAA;gBAEpB,QAAQ,EAAE,QAAQ;IAQrB,MAAM,CAAC,IAAI,EAAE,WAAW,EAAE,UAAU,EAAE,+BAA+B;IAqB9E,MAAM,CAAC,GAAG,UAAU,EAAE,+BAA+B;cAKlC,YAAY;IAI/B,WAAW,CAAC,KAAK,EAAE,KAAK;IAaxB,OAAO,CAAC,iBAAiB;IAMzB,OAAO,CAAC,oBAAoB;IAM5B,OAAO,CAAC,MAAM;IAqBd,OAAO,CAAC,sBAAsB;CAQ9B;AAED,eAAO,MAAM,UAAU,6HAAiC,CAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { AsyncDirective, directive, noChange, PartType } from '@a11d/lit';
|
|
2
|
-
import {
|
|
2
|
+
import { UrlMatchMode, NavigationStrategy } from './index.js';
|
|
3
3
|
function getParameters(...parameters) {
|
|
4
4
|
return !(parameters[0] instanceof HTMLElement) ? parameters[0] : {
|
|
5
5
|
component: parameters[0],
|
|
6
|
-
matchMode:
|
|
6
|
+
matchMode: UrlMatchMode.All,
|
|
7
7
|
navigationStrategy: undefined,
|
|
8
8
|
selectionChangeHandler: undefined,
|
|
9
9
|
invocationHandler: undefined,
|
|
@@ -28,8 +28,7 @@ class RouterLinkDirective extends AsyncDirective {
|
|
|
28
28
|
if (firstRender) {
|
|
29
29
|
this.executeSelectionChange();
|
|
30
30
|
}
|
|
31
|
-
|
|
32
|
-
this.element.setAttribute('href', path ?? '#');
|
|
31
|
+
this.element.setAttribute('href', this.parameters.component.url?.path ?? '#');
|
|
33
32
|
return super.update(part, parameters);
|
|
34
33
|
}
|
|
35
34
|
render(...parameters) {
|
|
@@ -80,7 +79,7 @@ class RouterLinkDirective extends AsyncDirective {
|
|
|
80
79
|
this.parameters.invocationHandler?.();
|
|
81
80
|
}
|
|
82
81
|
executeSelectionChange() {
|
|
83
|
-
const selected =
|
|
82
|
+
const selected = this.parameters.component.urlMatches({ mode: this.parameters.matchMode });
|
|
84
83
|
this.element.toggleAttribute('data-router-selected', selected);
|
|
85
84
|
if (this.parameters.selectionChangeHandler) {
|
|
86
85
|
this.parameters.selectionChangeHandler.call(this.element, selected);
|
package/dist/index.d.ts
CHANGED
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,0BAA0B,CAAA;AACxC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,yBAAyB,CAAA;AACvC,cAAc,sBAAsB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,CAAA;AACrB,cAAc,sBAAsB,CAAA;AACpC,cAAc,mBAAmB,CAAA;AACjC,cAAc,kBAAkB,CAAA;AAChC,cAAc,0BAA0B,CAAA;AACxC,cAAc,iBAAiB,CAAA;AAC/B,cAAc,mBAAmB,CAAA;AACjC,cAAc,yBAAyB,CAAA;AACvC,cAAc,sBAAsB,CAAA"}
|
package/dist/index.js
CHANGED