@a11d/lit-application 0.6.0 → 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.
Files changed (65) hide show
  1. package/dist/Application.d.ts.map +1 -1
  2. package/dist/Application.js +45 -45
  3. package/dist/Dialog/DialogComponent.d.ts +5 -7
  4. package/dist/Dialog/DialogComponent.d.ts.map +1 -1
  5. package/dist/Dialog/DialogComponent.js +36 -40
  6. package/dist/Notification/NotificationComponent.d.ts.map +1 -1
  7. package/dist/Page/Page.d.ts +1 -1
  8. package/dist/Page/Page.d.ts.map +1 -1
  9. package/dist/Page/PageComponent.d.ts +4 -8
  10. package/dist/Page/PageComponent.d.ts.map +1 -1
  11. package/dist/Page/PageComponent.js +4 -23
  12. package/dist/Page/PageError.d.ts +1 -1
  13. package/dist/Page/PageError.d.ts.map +1 -1
  14. package/dist/Page/PageError.js +24 -24
  15. package/dist/Page/PageHost.js +6 -6
  16. package/dist/Router/RoutableComponent.d.ts +44 -0
  17. package/dist/Router/RoutableComponent.d.ts.map +1 -0
  18. package/dist/Router/RoutableComponent.js +127 -0
  19. package/dist/Router/RoutableComponent.test.d.ts +2 -0
  20. package/dist/Router/RoutableComponent.test.d.ts.map +1 -0
  21. package/dist/Router/RoutableComponent.test.js +102 -0
  22. package/dist/Router/RouterController.d.ts +2 -3
  23. package/dist/Router/RouterController.d.ts.map +1 -1
  24. package/dist/Router/RouterController.js +15 -18
  25. package/dist/Router/index.d.ts +2 -2
  26. package/dist/Router/index.d.ts.map +1 -1
  27. package/dist/Router/index.js +2 -2
  28. package/dist/Router/path.d.ts +10 -0
  29. package/dist/Router/path.d.ts.map +1 -0
  30. package/dist/Router/path.js +8 -0
  31. package/dist/Router/path.test.d.ts +2 -0
  32. package/dist/Router/path.test.d.ts.map +1 -0
  33. package/dist/Router/path.test.js +17 -0
  34. package/dist/Router/route.d.ts +4 -4
  35. package/dist/Router/route.d.ts.map +1 -1
  36. package/dist/Router/route.js +10 -16
  37. package/dist/Router/routerLink.d.ts +5 -5
  38. package/dist/Router/routerLink.d.ts.map +1 -1
  39. package/dist/Router/routerLink.js +4 -5
  40. package/dist/index.d.ts +1 -0
  41. package/dist/index.d.ts.map +1 -1
  42. package/dist/index.js +1 -0
  43. package/dist/tsconfig.tsbuildinfo +1 -1
  44. package/dist/utilities/HookSet.d.ts +1 -1
  45. package/dist/utilities/HookSet.d.ts.map +1 -1
  46. package/dist/utilities/WindowHelper.d.ts +1 -1
  47. package/dist/utilities/WindowHelper.d.ts.map +1 -1
  48. package/dist/utilities/WindowHelper.js +2 -2
  49. package/dist/utilities/queryInstanceElement.d.ts +1 -1
  50. package/dist/utilities/queryInstanceElement.d.ts.map +1 -1
  51. package/dist/utilities/querySymbolizedElement.d.ts +1 -1
  52. package/dist/utilities/querySymbolizedElement.d.ts.map +1 -1
  53. package/package.json +1 -1
  54. package/dist/Router/Routable.d.ts +0 -12
  55. package/dist/Router/Routable.d.ts.map +0 -1
  56. package/dist/Router/Routable.js +0 -6
  57. package/dist/Router/Router.d.ts +0 -27
  58. package/dist/Router/Router.d.ts.map +0 -1
  59. package/dist/Router/Router.js +0 -73
  60. package/dist/Router/Router.test.d.ts +0 -2
  61. package/dist/Router/Router.test.d.ts.map +0 -1
  62. package/dist/Router/Router.test.js +0 -52
  63. package/dist/Router/RoutesContainer.d.ts +0 -23
  64. package/dist/Router/RoutesContainer.d.ts.map +0 -1
  65. package/dist/Router/RoutesContainer.js +0 -37
@@ -1,52 +0,0 @@
1
- import { __decorate } from "tslib";
2
- import { Router } from './Router.js';
3
- import { PageComponent } from '../Page/PageComponent.js';
4
- import { route } from './route.js';
5
- import { component } from '@a11d/lit';
6
- let PageWithNumericId = class PageWithNumericId extends PageComponent {
7
- };
8
- PageWithNumericId = __decorate([
9
- route('/page-with-numeric-id/:id'),
10
- component('test-page-with-numeric-id')
11
- ], PageWithNumericId);
12
- let PageWithSubRoute = class PageWithSubRoute extends PageComponent {
13
- };
14
- PageWithSubRoute = __decorate([
15
- route('/page-with-sub-route{/:subRoute}?'),
16
- component('test-page-with-sub-route')
17
- ], PageWithSubRoute);
18
- let PageWithNonRouteParameter = class PageWithNonRouteParameter extends PageComponent {
19
- };
20
- PageWithNonRouteParameter = __decorate([
21
- route('/page-with-non-route-parameter'),
22
- component('test-page-with-non-route-parameter')
23
- ], PageWithNonRouteParameter);
24
- let PageWithoutRoute = class PageWithoutRoute extends PageComponent {
25
- };
26
- PageWithoutRoute = __decorate([
27
- component('test-page-without-route')
28
- ], PageWithoutRoute);
29
- describe('Router', () => {
30
- describe('getPathOf', () => {
31
- it('should return the path that matches the given routable - PageWithNumericId', () => {
32
- const path = Router.getPathOf(new PageWithNumericId({ id: 1 }));
33
- expect(path).toBe('/page-with-numeric-id/1');
34
- });
35
- it('should return the path that matches the given routable - PageWithSubRoute', () => {
36
- const path = Router.getPathOf(new PageWithSubRoute({ subRoute: 'sub-route' }));
37
- expect(path).toBe('/page-with-sub-route/sub-route');
38
- const pathWithoutSubRoute = Router.getPathOf(new PageWithSubRoute({}));
39
- expect(pathWithoutSubRoute).toBe('/page-with-sub-route');
40
- });
41
- it('should put the parameters not part of the route in the query string', () => {
42
- expect(Router.getPathOf(new PageWithNonRouteParameter({ keyword: 'test' })))
43
- .toBe('/page-with-non-route-parameter?keyword=test');
44
- expect(Router.getPathOf(new PageWithNumericId({ id: 1, view: 'details' })))
45
- .toBe('/page-with-numeric-id/1?view=details');
46
- });
47
- it('should return undefined if the given routable does not match any route', () => {
48
- const path = Router.getPathOf(new PageWithoutRoute);
49
- expect(path).toBeUndefined();
50
- });
51
- });
52
- });
@@ -1,23 +0,0 @@
1
- import type { Component } from '@a11d/lit';
2
- import type { Routable, RoutableConstructor } from './Routable.js';
3
- type RouterHost = Component;
4
- type RouterHostConstructor = Constructor<RouterHost>;
5
- type RouteMetadata = {
6
- routerHostConstructor: RouterHostConstructor;
7
- routableConstructor: RoutableConstructor;
8
- };
9
- /**
10
- * A container to persist routes and their metadata.
11
- * A route is a string that represents the URL template of a path e.g. '/users/:id'.
12
- * The metadata consists of the routable that the router matches
13
- * as well as the constructor of the router host that the route is associated with.
14
- */
15
- export declare class RoutesContainer extends Map<string, RouteMetadata> {
16
- basePath: string;
17
- get(key: string): RouteMetadata | undefined;
18
- getByRoutable(routable: Routable): string | undefined;
19
- entries(): IterableIterator<[string, RouteMetadata]>;
20
- [Symbol.iterator](): IterableIterator<[string, RouteMetadata]>;
21
- }
22
- export {};
23
- //# sourceMappingURL=RoutesContainer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"RoutesContainer.d.ts","sourceRoot":"","sources":["../../Router/RoutesContainer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAC1C,OAAO,KAAK,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAA;AAElE,KAAK,UAAU,GAAG,SAAS,CAAA;AAC3B,KAAK,qBAAqB,GAAG,WAAW,CAAC,UAAU,CAAC,CAAA;AAEpD,KAAK,aAAa,GAAG;IACpB,qBAAqB,EAAE,qBAAqB,CAAA;IAC5C,mBAAmB,EAAE,mBAAmB,CAAA;CACxC,CAAA;AAED;;;;;GAKG;AACH,qBAAa,eAAgB,SAAQ,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC;IAC9D,QAAQ,SAAK;IAEJ,GAAG,CAAC,GAAG,EAAE,MAAM;IAKxB,aAAa,CAAC,QAAQ,EAAE,QAAQ;IAKvB,OAAO,IAAI,gBAAgB,CAAC,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAgBrD,CAAC,MAAM,CAAC,QAAQ,CAAC;CAGzB"}
@@ -1,37 +0,0 @@
1
- /**
2
- * A container to persist routes and their metadata.
3
- * A route is a string that represents the URL template of a path e.g. '/users/:id'.
4
- * The metadata consists of the routable that the router matches
5
- * as well as the constructor of the router host that the route is associated with.
6
- */
7
- export class RoutesContainer extends Map {
8
- constructor() {
9
- super(...arguments);
10
- this.basePath = '';
11
- }
12
- get(key) {
13
- key = key.split(this.basePath)[1];
14
- return super.get(key);
15
- }
16
- getByRoutable(routable) {
17
- const [route] = [...this].find(([, { routableConstructor }]) => routableConstructor === routable.constructor) ?? [];
18
- return route;
19
- }
20
- entries() {
21
- const entries = super.entries();
22
- const basePath = this.basePath;
23
- return {
24
- *[Symbol.iterator]() {
25
- for (const [key, value] of entries) {
26
- yield [basePath + key, value];
27
- }
28
- },
29
- next() {
30
- return this[Symbol.iterator]().next();
31
- }
32
- };
33
- }
34
- [Symbol.iterator]() {
35
- return this.entries();
36
- }
37
- }