@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.
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 +35 -39
  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 +3 -22
  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 +1 @@
1
- {"version":3,"file":"Application.d.ts","sourceRoot":"","sources":["../Application.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,yBAAyB,CAAA;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AACrE,OAAO,EAAE,OAAO,EAAa,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAIjE,eAAO,MAAM,WAAW,SACf,CAAC,SAAS,WAAW,0BAA0B,WAAW,CAA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W,CAAA;IAE9D,WAAoB,MAAM,kCAsCzB;IAEiF,WAAW,CAAC,EAAE,MAAM,CAAA;IAEtG,QAAQ,CAAC,MAAM,mBAMd;IAED,SAAS,CAAC,QAAQ,CAAC,eAAe,4BAAwE;IAEjG,OAAO,CAAC,iBAAiB,CAAQ;cAEvB,gBAAgB;IAIpB,iBAAiB;cAOP,WAAW;IAQpC,SAAS,KAAK,aAAa,WAE1B;IAED,cAAuB,QAAQ,0CAI9B;IAED,SAAS,KAAK,YAAY,0CAKzB;IAED,SAAS,KAAK,gBAAgB,0CAM7B;IAED,SAAS,KAAK,mBAAmB,0CAEhC;IAED,SAAS,KAAK,gBAAgB,0CAE7B;CACD"}
@@ -25,42 +25,42 @@ export class Application extends NonInertableComponent {
25
25
  }
26
26
  static get topLayer() { return ApplicationTopLayer.instance; }
27
27
  static get styles() {
28
- return css `
29
- :root { color-scheme: light dark; }
30
-
31
- html, body, [application] {
32
- margin: 0;
33
- padding: 0;
34
- scrollbar-width: thin;
35
- display: block;
36
- min-height: 100vh;
37
- min-height: 100dvh;
38
- }
39
-
40
- [application] {
41
- display: flex;
42
- flex-direction: column;
43
- }
44
-
45
- ::-webkit-scrollbar {
46
- width: 5px;
47
- height: 5px;
48
- }
49
-
50
- ::-webkit-scrollbar-thumb {
51
- background: rgba(128, 128, 128, 0.75);
52
- }
53
-
54
- lit-page-host {
55
- flex: 1;
56
- margin: auto;
57
- width: 100%;
58
- max-width: var(--lit-application-page-host-max-width, 2560px);
59
- }
60
-
61
- lit-page-host > * {
62
- padding: max(min(1rem, 1vw), min(1rem, 1vh));
63
- }
28
+ return css `
29
+ :root { color-scheme: light dark; }
30
+
31
+ html, body, [application] {
32
+ margin: 0;
33
+ padding: 0;
34
+ scrollbar-width: thin;
35
+ display: block;
36
+ min-height: 100vh;
37
+ min-height: 100dvh;
38
+ }
39
+
40
+ [application] {
41
+ display: flex;
42
+ flex-direction: column;
43
+ }
44
+
45
+ ::-webkit-scrollbar {
46
+ width: 5px;
47
+ height: 5px;
48
+ }
49
+
50
+ ::-webkit-scrollbar-thumb {
51
+ background: rgba(128, 128, 128, 0.75);
52
+ }
53
+
54
+ lit-page-host {
55
+ flex: 1;
56
+ margin: auto;
57
+ width: 100%;
58
+ max-width: var(--lit-application-page-host-max-width, 2560px);
59
+ }
60
+
61
+ lit-page-host > * {
62
+ padding: max(min(1rem, 1vw), min(1rem, 1vh));
63
+ }
64
64
  `;
65
65
  }
66
66
  createRenderRoot() {
@@ -83,21 +83,21 @@ export class Application extends NonInertableComponent {
83
83
  return [this.pageHeading, manifest?.short_name].filter(Boolean).join(' | ');
84
84
  }
85
85
  get template() {
86
- return html `
87
- ${this.bodyTemplate}
86
+ return html `
87
+ ${this.bodyTemplate}
88
88
  `;
89
89
  }
90
90
  get bodyTemplate() {
91
- return html `
92
- ${this.pageHostTemplate}
93
- ${this.topLayerTemplate}
91
+ return html `
92
+ ${this.pageHostTemplate}
93
+ ${this.topLayerTemplate}
94
94
  `;
95
95
  }
96
96
  get pageHostTemplate() {
97
- return html `
98
- <lit-page-host @pageHeadingChange=${(e) => this.pageHeading = e.detail}>
99
- ${!this.shallRenderRouter ? this.pageLoadingTemplate : this.router.outlet()}
100
- </lit-page-host>
97
+ return html `
98
+ <lit-page-host @pageHeadingChange=${(e) => this.pageHeading = e.detail}>
99
+ ${!this.shallRenderRouter ? this.pageLoadingTemplate : this.router.outlet()}
100
+ </lit-page-host>
101
101
  `;
102
102
  }
103
103
  get pageLoadingTemplate() {
@@ -1,7 +1,7 @@
1
- import { Component, PropertyValues } from '@a11d/lit';
1
+ import { type PropertyValues } from '@a11d/lit';
2
2
  import { LocalStorage } from '@a11d/local-storage';
3
- import { HookSet, type Routable, NavigationStrategy } from '../index.js';
4
- import { Dialog, DialogActionKey } from './index.js';
3
+ import { HookSet, RoutableComponent, NavigationStrategy } from '../index.js';
4
+ import { type Dialog, DialogActionKey } from './index.js';
5
5
  export type DialogParameters = void | Record<string, any>;
6
6
  export type DialogResult<TResult> = TResult | Error;
7
7
  export type DialogAction<TResult> = DialogResult<TResult> | PromiseLike<DialogResult<TResult>>;
@@ -16,8 +16,7 @@ export declare abstract class DialogComponentErrorHandler {
16
16
  constructor(dialogComponent: DialogComponent<any, any>);
17
17
  abstract handle(error: Error): void | Promise<void>;
18
18
  }
19
- export declare abstract class DialogComponent<T extends DialogParameters = void, TResult = void> extends Component implements Routable {
20
- readonly parameters: T;
19
+ export declare abstract class DialogComponent<T extends DialogParameters = void, TResult = void> extends RoutableComponent<T> {
21
20
  static readonly connectingHooks: HookSet<DialogComponent<any, any>>;
22
21
  private static readonly errorHandlers;
23
22
  private static defaultErrorHandler;
@@ -30,7 +29,6 @@ export declare abstract class DialogComponent<T extends DialogParameters = void,
30
29
  get secondaryActionElement(): HTMLElement | undefined;
31
30
  get cancellationActionElement(): HTMLElement | undefined;
32
31
  get opener(): Window & typeof globalThis;
33
- constructor(parameters: T);
34
32
  protected handleBeforeUnload(): Promise<void>;
35
33
  protected handleKeyDown(e: KeyboardEvent): Promise<void>;
36
34
  connectedCallback(): Promise<void>;
@@ -44,7 +42,7 @@ export declare abstract class DialogComponent<T extends DialogParameters = void,
44
42
  protected close(result: TResult | Error): void;
45
43
  private get open();
46
44
  private set open(value);
47
- protected firstUpdated(props: PropertyValues): void;
45
+ protected firstUpdated(props: PropertyValues<this>): void;
48
46
  protected primaryAction(): DialogAction<TResult>;
49
47
  protected secondaryAction(): DialogAction<TResult>;
50
48
  protected cancellationAction(): DialogAction<TResult>;
@@ -1 +1 @@
1
- {"version":3,"file":"DialogComponent.d.ts","sourceRoot":"","sources":["../../Dialog/DialogComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAiB,cAAc,EAAE,MAAM,WAAW,CAAA;AACpE,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAe,OAAO,EAA6D,KAAK,QAAQ,EAAE,kBAAkB,EAAU,MAAM,aAAa,CAAA;AACxJ,OAAO,E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BlE;IAED,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,KAAK;CAqBlC"}
@@ -1,7 +1,7 @@
1
1
  import { __decorate } from "tslib";
2
- import { Component, eventListener } from '@a11d/lit';
2
+ import { eventListener } from '@a11d/lit';
3
3
  import { LocalStorage } from '@a11d/local-storage';
4
- import { Application, HookSet, querySymbolizedElement, WindowHelper, WindowOpenMode, Key, NavigationStrategy, Router } from '../index.js';
4
+ import { Application, HookSet, querySymbolizedElement, RoutableComponent, WindowHelper, WindowOpenMode, Key, NavigationStrategy } from '../index.js';
5
5
  import { DialogActionKey, DialogCancelledError } from './index.js';
6
6
  export var DialogConfirmationStrategy;
7
7
  (function (DialogConfirmationStrategy) {
@@ -15,7 +15,35 @@ export class DialogComponentErrorHandler {
15
15
  }
16
16
  }
17
17
  const dialogElementConstructorSymbol = Symbol('DialogComponent.DialogElementConstructor');
18
- export class DialogComponent extends Component {
18
+ export class DialogComponent extends RoutableComponent {
19
+ constructor() {
20
+ super(...arguments);
21
+ this.handleAction = async (actionKey) => {
22
+ const actionByKey = new Map([
23
+ [DialogActionKey.Primary, this.primaryAction],
24
+ [DialogActionKey.Secondary, this.secondaryAction],
25
+ [DialogActionKey.Cancellation, this.cancellationAction],
26
+ ]);
27
+ const action = actionByKey.get(actionKey)?.bind(this);
28
+ if (!action) {
29
+ throw new Error(`No action for key ${actionKey}`);
30
+ }
31
+ try {
32
+ this.dialogElement.executingAction = actionKey;
33
+ const result = await action();
34
+ if (!this.dialogElement.manualClose || actionKey === DialogActionKey.Cancellation) {
35
+ this.close(result);
36
+ }
37
+ }
38
+ catch (e) {
39
+ this.handleError(e);
40
+ throw e;
41
+ }
42
+ finally {
43
+ this.dialogElement.executingAction = undefined;
44
+ }
45
+ };
46
+ }
19
47
  static dialogElement() {
20
48
  return (constructor) => {
21
49
  constructor[dialogElementConstructorSymbol] = true;
@@ -46,35 +74,6 @@ export class DialogComponent extends Component {
46
74
  ? window
47
75
  : window.opener ?? window;
48
76
  }
49
- constructor(parameters) {
50
- super();
51
- this.parameters = parameters;
52
- this.handleAction = async (actionKey) => {
53
- const actionByKey = new Map([
54
- [DialogActionKey.Primary, this.primaryAction],
55
- [DialogActionKey.Secondary, this.secondaryAction],
56
- [DialogActionKey.Cancellation, this.cancellationAction],
57
- ]);
58
- const action = actionByKey.get(actionKey)?.bind(this);
59
- if (!action) {
60
- throw new Error(`No action for key ${actionKey}`);
61
- }
62
- try {
63
- this.dialogElement.executingAction = actionKey;
64
- const result = await action();
65
- if (!this.dialogElement.manualClose || actionKey === DialogActionKey.Cancellation) {
66
- this.close(result);
67
- }
68
- }
69
- catch (e) {
70
- this.handleError(e);
71
- throw e;
72
- }
73
- finally {
74
- this.dialogElement.executingAction = undefined;
75
- }
76
- };
77
- }
78
77
  async handleBeforeUnload() {
79
78
  if (this.dialogElement.boundToWindow) {
80
79
  await this.handleAction(DialogActionKey.Cancellation);
@@ -114,12 +113,11 @@ export class DialogComponent extends Component {
114
113
  });
115
114
  }
116
115
  async confirmAsPopup(strategy) {
117
- const path = Router.getPathOf(this);
118
- if (!path) {
116
+ if (!this.url) {
119
117
  throw new Error('No @route decorator found on dialog component.');
120
118
  }
121
119
  // Open a new window at the dialog's path
122
- const popup = await WindowHelper.open(path, strategy === DialogConfirmationStrategy.Window ? WindowOpenMode.Window : WindowOpenMode.Tab);
120
+ const popup = await WindowHelper.open(this.url, strategy === DialogConfirmationStrategy.Window ? WindowOpenMode.Window : WindowOpenMode.Tab);
123
121
  // Wait for the router to navigate to the dialog
124
122
  await new Promise(r => popup?.addEventListener('Application.routed', r));
125
123
  // Find the dialog in the new window
@@ -171,11 +169,9 @@ export class DialogComponent extends Component {
171
169
  var _a;
172
170
  this.dialogElement.handleAction = this.handleAction;
173
171
  this.dialogElement.requestPopup?.subscribe(() => this.pop());
174
- if (Router.path === Router.getPathOf(this)) {
175
- this.dialogElement.boundToWindow = true;
176
- }
172
+ this.dialogElement.boundToWindow = this.boundToWindow;
177
173
  if (this.dialogElement.poppable &&
178
- Router.path !== Router.getPathOf(this) &&
174
+ this.urlMatches() === false &&
179
175
  DialogComponent.poppableConfirmationStrategy.value !== DialogConfirmationStrategy.Dialog) {
180
176
  this.pop(DialogComponent.poppableConfirmationStrategy.value);
181
177
  return;
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationComponent.d.ts","sourceRoot":"","sources":["../../Notification/NotificationComponent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAA;AAErE,oBAAY,gBAAgB;IAC3B,IAAI,SAAS;IACb,OAAO,YAAY;IACnB,OAAO,YAAY;IACnB,KAAK,UAAU;CACf;AAED,MAAM,MAAM,YAAY,GAAG;IAC1B,IAAI,CAAC,EAAE,gBAAgB,CAAA;IACvB,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,CAAC,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAA;CACnC,CAAA;AAED,KAAK,kBAAkB,GAAG;IACzB,KAAK,EAAE,MAAM,CAAA;IACb,WAAW,EAAE,MAAM,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,CAAA;CAC3C,CAAA;AAED,KAAK,oBAAoB,GAAG,IAAI,CAAC,YAAY,EAAE,MAAM,CAAC,CAAA;AAEtD,KAAK,8BAA8B,GAChC,CAAC,YAAY,EAAE,oBAAoB,CAAC,GACpC,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAA;AAE3D,KAAK,uCAAuC,GACzC,CAAC,YAAY,EAAE,oBAAoB,CAAC,GACpC,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC,GAC7D,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAA;AASxD,8BAAsB,qBAAsB,SAAQ,qBAAqB;IACxE,MAAM,CAAC,QAAQ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C,CAAC,YAAY,EAAE,oBAAoB,CAAC,GACpC,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAA;AAE3D,KAAK,uCAAuC,GACzC,CAAC,YAAY,EAAE,oBAAoB,CAAC,GACpC,CAAC,YAAY,EAAE,MAAM,EAAE,GAAG,OAAO,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC,GAC7D,CAAC,KAAK,EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,KAAK,CAAC,kBAAkB,CAAC,CAAC,CAAA;AASxD,8BAAsB,qBAAsB,SAAQ,qBAAqB;IACxE,MAAM,CAAC,QAAQ,CAAC,kBAAkB,oBAA0B;IAE5D,OAAO,CAAC,MAAM,CAAC,2BAA2B,CAAC,CAAoC;IAE/E,MAAM,CAAC,gBAAgB,SACd,CAAC,SAAS,qBAAqB,EAAE,aAAa,WAAW,CAAC,CAAC,CAAC,UAGpE;IAED,MAAM,CAAC,UAAU,CAAC,GAAG,UAAU,EAAE,8BAA8B;IAI/D,MAAM,CAAC,aAAa,CAAC,GAAG,UAAU,EAAE,8BAA8B;IAIlE,MAAM,CAAC,aAAa,CAAC,GAAG,UAAU,EAAE,8BAA8B;IAIlE,MAAM,CAAC,WAAW,CAAC,GAAG,UAAU,EAAE,8BAA8B;IAIhE,MAAM,CAAC,mBAAmB,CAAC,GAAG,UAAU,EAAE,uCAAuC;WAgBpE,MAAM,CAAC,YAAY,EAAE,YAAY;IA0B9C,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAA;IACnC,QAAQ,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAC9B"}
@@ -1,4 +1,4 @@
1
- import { LitElement } from '@a11d/lit';
1
+ import { type LitElement } from '@a11d/lit';
2
2
  export interface Page extends LitElement {
3
3
  /** The event must be "composed", "bubbles" and "cancellable" */
4
4
  readonly pageHeadingChange: EventDispatcher<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"Page.d.ts","sourceRoot":"","sources":["../../Page/Page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAA;AAEtC,MAAM,WAAW,IAAK,SAAQ,UAAU;IACvC,gEAAgE;IAChE,QAAQ,CAAC,iBAAiB,EAAE,eAAe,CAAC,MAAM,CAAC,CAAA;IACnD,OAAO,EAAE,MAAM,CAAA;CACf"}
1
+ {"version":3,"file":"Page.d.ts","sourceRoot":"","sources":["../../Page/Page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAA;AAE3C,MAAM,WAAW,IAAK,SAAQ,UAAU;IACvC,gEAAgE;IAChE,QAAQ,CAAC,iBAAiB,EAAE,eAAe,CAAC,MAAM,CAAC,CAAA;IACnD,OAAO,EAAE,MAAM,CAAA;CACf"}
@@ -1,17 +1,13 @@
1
- import { Component, type PropertyValues } from '@a11d/lit';
2
- import { HookSet, NavigationStrategy, type Routable, type RoutableParameters } from '../index.js';
3
- import { Page } from './index.js';
1
+ import { type PropertyValues } from '@a11d/lit';
2
+ import { RoutableComponent, HookSet, type RoutableParameters } from '../index.js';
3
+ import { type Page } from './index.js';
4
4
  export type PageParameters = RoutableParameters;
5
- export declare abstract class PageComponent<T extends PageParameters = void> extends Component implements Routable {
6
- readonly parameters: T;
5
+ export declare abstract class PageComponent<T extends PageParameters = void> extends RoutableComponent<T> {
7
6
  static readonly connectingHooks: HookSet<PageComponent<any>>;
8
7
  static defaultPageElementTag: import("lit-html/static.js").StaticValue;
9
8
  static pageElement(): (constructor: Constructor<Page>) => void;
10
- navigate(strategy?: NavigationStrategy, force?: boolean): Promise<void>;
11
9
  readonly pageElement: Page & HTMLElement;
12
- constructor(parameters: T);
13
10
  connectedCallback(): Promise<void>;
14
11
  protected firstUpdated(props: PropertyValues<this>): void;
15
- protected refresh(parameters?: T): any;
16
12
  }
17
13
  //# sourceMappingURL=PageComponent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PageComponent.d.ts","sourceRoot":"","sources":["../../Page/PageComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAW,KAAK,cAAc,EAAE,MAAM,WAAW,CAAA;AAEnE,OAAO,EAAwD,OAAO,EAA0B,kBAAkB,EAAE,KAAK,QAAQ,EAAE,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAC/K,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAA;AAEjC,MAAM,MAAM,cAAc,GAAG,kBAAkB,CAAA;AAI/C,8BAAsB,aAAa,CAAC,CAAC,SAAS,cAAc,GAAG,IAAI,CAAE,SAAQ,SAAU,YAAW,QAAQ;IA0B7F,QAAQ,CAAC,UAAU,EAAE,CAAC;IAzBlC,MAAM,CAAC,QAAQ,CAAC,eAAe,8BAAoC;IAEnE,MAAM,CAAC,qBAAqB,2CAAoB;IAEhD,MAAM,CAAC,WAAW,kBACI,WAAW,CAAC,IAAI,CAAC;IAKjC,QAAQ,CAAC,QAAQ,qBAA0B,EAAE,KAAK,UAAQ;IAaV,QAAQ,CAAC,WAAW,EAAG,IAAI,GAAG,WAAW,CAAA;gBAE1E,UAAU,EAAE,CAAC;IAInB,iBAAiB;cAKb,YAAY,CAAC,KAAK,EAAE,cAAc,CAAC,IAAI,CAAC;IAK3D,SAAS,CAAC,OAAO,CAAC,UAAU,IAAkB;CAG9C"}
1
+ {"version":3,"file":"PageComponent.d.ts","sourceRoot":"","sources":["../../Page/PageComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAW,KAAK,cAAc,EAAE,MAAM,WAAW,CAAA;AAExD,OAAO,EAA0B,iBAAiB,EAAE,OAAO,EAAE,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAA;AACzG,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,YAAY,CAAA;AAEtC,MAAM,MAAM,cAAc,GAAG,kBAAkB,CAAA;AAI/C,8BAAsB,aAAa,CAAC,CAAC,SAAS,cAAc,GAAG,IAAI,CAAE,SAAQ,iBAAiB,CAAC,CAAC,CAAC;IAChG,MAAM,CAAC,QAAQ,CAAC,eAAe,8BAAoC;IAEnE,MAAM,CAAC,qBAAqB,2CAAoB;IAEhD,MAAM,CAAC,WAAW,KACT,aAAa,WAAW,CAAC,IAAI,CAAC;IAKe,QAAQ,CAAC,WAAW,EAAG,IAAI,GAAG,WAAW,CAAA;IAEhF,iBAAiB;cAKb,YAAY,CAAC,KAAK,EAAE,cAAc,CAAC,IAAI,CAAC;CAI3D"}
@@ -1,30 +1,14 @@
1
1
  import { __decorate } from "tslib";
2
- import { Component, literal } from '@a11d/lit';
2
+ import { literal } from '@a11d/lit';
3
3
  import { label } from '@a11d/metadata';
4
- import { querySymbolizedElement, WindowHelper, WindowOpenMode, HookSet, Router, RouteMatchMode, NavigationStrategy } from '../index.js';
4
+ import { querySymbolizedElement, RoutableComponent, HookSet } from '../index.js';
5
5
  const pageElementConstructorSymbol = Symbol('PageComponent.PageElementConstructor');
6
- export class PageComponent extends Component {
6
+ export class PageComponent extends RoutableComponent {
7
7
  static pageElement() {
8
8
  return (constructor) => {
9
9
  constructor[pageElementConstructorSymbol] = true;
10
10
  };
11
11
  }
12
- async navigate(strategy = NavigationStrategy.Page, force = false) {
13
- if (force === false && Router.match(this, RouteMatchMode.All)) {
14
- return;
15
- }
16
- if (strategy === NavigationStrategy.Page) {
17
- Router.setPathBy(this);
18
- }
19
- else {
20
- const url = window.location.origin + Router.getPathOf(this);
21
- await WindowHelper.openAndFocus(url, strategy === NavigationStrategy.Window ? WindowOpenMode.Window : WindowOpenMode.Tab);
22
- }
23
- }
24
- constructor(parameters) {
25
- super();
26
- this.parameters = parameters;
27
- }
28
12
  async connectedCallback() {
29
13
  await PageComponent.connectingHooks.execute(this);
30
14
  super.connectedCallback();
@@ -34,9 +18,6 @@ export class PageComponent extends Component {
34
18
  (_a = this.pageElement).heading || (_a.heading = label.get(this.constructor)?.toString());
35
19
  super.firstUpdated(props);
36
20
  }
37
- refresh(parameters = this.parameters) {
38
- return new this.constructor(parameters).navigate(NavigationStrategy.Page, true);
39
- }
40
21
  }
41
22
  PageComponent.connectingHooks = new HookSet();
42
23
  PageComponent.defaultPageElementTag = literal `lit-page`;
@@ -1,4 +1,4 @@
1
- import { HTMLTemplateResult } from '@a11d/lit';
1
+ import { type HTMLTemplateResult } from '@a11d/lit';
2
2
  import { HttpErrorCode } from '../index.js';
3
3
  import { PageComponent } from './PageComponent.js';
4
4
  export declare class PageError extends PageComponent<{
@@ -1 +1 @@
1
- {"version":3,"file":"PageError.d.ts","sourceRoot":"","sources":["../../Page/PageError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,kBAAkB,EAAqB,MAAM,WAAW,CAAA;AACvF,OAAO,EAAa,aAAa,EAAE,MAAM,aAAa,CAAA;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,qBAEa,SAAU,SAAQ,aAAa,CAAC;IAAE,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;IACzG,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAoBxC;IAEF,WAAoB,MAAM,kCAazB;IAED,cAAuB,QAAQ,IAUzB,kBAAkB,CACvB;IAED,OAAO,KAAK,aAAa,GAQxB;CACD;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,gBAAgB,EAAE,SAAS,CAAA;KAC3B;CACD"}
1
+ {"version":3,"file":"PageError.d.ts","sourceRoot":"","sources":["../../Page/PageError.ts"],"names":[],"mappings":"AAAA,OAAO,EAAwB,KAAK,kBAAkB,EAAqB,MAAM,WAAW,CAAA;AAC5F,OAAO,EAAa,aAAa,EAAE,MAAM,aAAa,CAAA;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAElD,qBAEa,SAAU,SAAQ,aAAa,CAAC;IAAE,QAAQ,CAAC,KAAK,EAAE,aAAa,CAAC;IAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;IACzG,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAoBxC;IAEF,WAAoB,MAAM,kCAazB;IAED,cAAuB,QAAQ,IAUzB,kBAAkB,CACvB;IAED,OAAO,KAAK,aAAa,GAQxB;CACD;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,gBAAgB,EAAE,SAAS,CAAA;KAC3B;CACD"}
@@ -6,38 +6,38 @@ import { route } from '../Router/route.js';
6
6
  import { PageComponent } from './PageComponent.js';
7
7
  let PageError = PageError_1 = class PageError extends PageComponent {
8
8
  static get styles() {
9
- return css `
10
- .code {
11
- font-size: 60px;
12
- font-weight: 400;
13
- text-align: center;
14
- }
15
-
16
- h1, h2 {
17
- text-align: center;
18
- margin: 0;
19
- }
9
+ return css `
10
+ .code {
11
+ font-size: 60px;
12
+ font-weight: 400;
13
+ text-align: center;
14
+ }
15
+
16
+ h1, h2 {
17
+ text-align: center;
18
+ margin: 0;
19
+ }
20
20
  `;
21
21
  }
22
22
  get template() {
23
- return staticHtml `
24
- <${PageComponent.defaultPageElementTag} heading=${`Error ${this.parameters.error}`} fullHeight>
25
- <div ${style({ display: 'flex', gap: '8px', flexDirection: 'column', alignItems: 'center', justifyContent: 'center' })}>
26
- <div class='code'>${this.errorTemplate}</div>
27
- <div ${style({ display: 'flex', gap: '4px', flexDirection: 'column' })}>
28
- <h1>${this.parameters.message ?? HttpError.defaultMessageByErrorCode.get(this.parameters.error) ?? 'Unknown Error'}</h1>
29
- </div>
30
- </div>
31
- </${PageComponent.defaultPageElementTag}>
23
+ return staticHtml `
24
+ <${PageComponent.defaultPageElementTag} heading=${`Error ${this.parameters.error}`} fullHeight>
25
+ <div ${style({ display: 'flex', gap: '8px', flexDirection: 'column', alignItems: 'center', justifyContent: 'center' })}>
26
+ <div class='code'>${this.errorTemplate}</div>
27
+ <div ${style({ display: 'flex', gap: '4px', flexDirection: 'column' })}>
28
+ <h1>${this.parameters.message ?? HttpError.defaultMessageByErrorCode.get(this.parameters.error) ?? 'Unknown Error'}</h1>
29
+ </div>
30
+ </div>
31
+ </${PageComponent.defaultPageElementTag}>
32
32
  `;
33
33
  }
34
34
  get errorTemplate() {
35
35
  const errorCode = String(this.parameters.error);
36
36
  const emoji = PageError_1.emojisByErrorCodes.get(this.parameters.error);
37
- return !emoji ? html `
38
- <span>${errorCode}</span>
39
- ` : html `
40
- <span>${errorCode.charAt(0)}</span>${emoji}<span>${errorCode.charAt(2)}</span>
37
+ return !emoji ? html `
38
+ <span>${errorCode}</span>
39
+ ` : html `
40
+ <span>${errorCode.charAt(0)}</span>${emoji}<span>${errorCode.charAt(2)}</span>
41
41
  `;
42
42
  }
43
43
  };
@@ -2,12 +2,12 @@ import { __decorate } from "tslib";
2
2
  import { Component, component, css, html } from '@a11d/lit';
3
3
  let PageHost = class PageHost extends Component {
4
4
  static get styles() {
5
- return css `
6
- :host {
7
- display: grid;
8
- grid-template-rows: 1fr;
9
- width: 100%;
10
- }
5
+ return css `
6
+ :host {
7
+ display: grid;
8
+ grid-template-rows: 1fr;
9
+ width: 100%;
10
+ }
11
11
  `;
12
12
  }
13
13
  get template() {
@@ -0,0 +1,44 @@
1
+ import { Component } from '@a11d/lit';
2
+ export type RoutableParameters = void | Record<string, string | number | undefined>;
3
+ export declare enum UrlMatchMode {
4
+ All = "all",
5
+ IgnoreParameters = "ignore-parameters"
6
+ }
7
+ export declare enum NavigationStrategy {
8
+ Page = 0,
9
+ Tab = 1,
10
+ Window = 2
11
+ }
12
+ export declare abstract class RoutableComponent<T extends RoutableParameters = void> extends Component {
13
+ static basePath: string;
14
+ static readonly container: Set<RoutableComponentConstructor>;
15
+ static host: AbstractConstructor<HTMLElement> | Constructor<HTMLElement>;
16
+ private static _routes;
17
+ static get routes(): string[];
18
+ static set routes(value: string[]);
19
+ private static readonly connectedInstances;
20
+ private static get boundComponent();
21
+ static get url(): URL;
22
+ private static setUrl;
23
+ parameters: T;
24
+ constructor(parameters: T);
25
+ get route(): string | undefined;
26
+ get boundToWindow(): boolean;
27
+ navigate(strategy?: NavigationStrategy, force?: boolean): Promise<unknown>;
28
+ get url(): URL | undefined;
29
+ /**
30
+ * Determines if the current URL matches the route of this component.
31
+ * @param mode The matching mode. 'all' matches the path and parameters, 'ignore-parameters' matches only the path. Defaults to 'all'.
32
+ */
33
+ urlMatches(options?: {
34
+ mode?: UrlMatchMode;
35
+ url?: URL;
36
+ }): boolean;
37
+ protected updateUrl(force?: boolean): void;
38
+ protected refresh(parameters?: T): Promise<unknown>;
39
+ }
40
+ export type RoutableComponentConstructor = Constructor<RoutableComponent<any>> & {
41
+ host: AbstractConstructor<HTMLElement> | Constructor<HTMLElement>;
42
+ routes: Array<string>;
43
+ };
44
+ //# sourceMappingURL=RoutableComponent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RoutableComponent.d.ts","sourceRoot":"","sources":["../../Router/RoutableComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAkC,MAAM,WAAW,CAAA;AAMrE,MAAM,MAAM,kBAAkB,GAAG,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,CAAA;AAEnF,oBAAY,YAAY;IACvB,GAAG,QAAQ;IACX,gBAAgB,sBAAsB;CACtC;AAED,oBAAY,kBAAkB;IAAG,IAAI,IAAA;IAAE,GAAG,IAAA;IAAE,MAAM,IAAA;CAAE;AAEpD,8BAAsB,iBAAiB,CAAC,CAAC,SAAS,kBAAkB,GAAG,IAAI,CAAE,SAAQ,SAAS;IAC7F,MAAM,CAAC,QAAQ,SAAK;IACpB,MAAM,CAAC,QAAQ,CAAC,SAAS,oCAA0C;IAEnE,MAAM,CAAC,IAAI,EAAE,mBAAmB,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC,WAAW,CAAC,CAAc;IAEtF,OAAO,CAAC,MAAM,CAAC,OAAO,CAAsB;IAC5C,MAAM,KAAK,MAAM,aAA2E;IAC5F,MAAM,KAAK,MAAM,CAAC,KAAK,UAAA,EAA0B;IAEtB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,kBAAkB,CAA6B;IAElG,OAAO,CAAC,MAAM,KAAK,cAAc,GAEhC;IAED,MAAM,KAAK,GAAG,QAAqD;IAEnE,OAAO,CAAC,MAAM,CAAC,MAAM;IA0BlB,UAAU,EAAE,CAAC,CAAA;gBAEJ,UAAU,EAAE,CAAC;IAKzB,IAAI,KAAK,uBAER;IAED,IAAI,aAAa,IAAI,OAAO,CAE3B;IAEK,QAAQ,CAAC,QAAQ,CAAC,EAAE,kBAAkB,EAAE,KAAK,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IAiBhF,IAAI,GAAG,oBAoBN;IAED;;;OAGG;IACH,UAAU,CAAC,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,YAAY,CAAC;QAAC,GAAG,CAAC,EAAE,GAAG,CAAA;KAAE;IAwBvD,SAAS,CAAC,SAAS,CAAC,KAAK,UAAQ;IAMjC,SAAS,CAAC,OAAO,CAAC,UAAU,IAAyB;CAGrD;AAED,MAAM,MAAM,4BAA4B,GAAG,WAAW,CAAC,iBAAiB,CAAC,GAAG,CAAC,CAAC,GAAG;IAChF,IAAI,EAAE,mBAAmB,CAAC,WAAW,CAAC,GAAG,WAAW,CAAC,WAAW,CAAC,CAAA;IACjE,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;CACrB,CAAA"}
@@ -0,0 +1,127 @@
1
+ import { __decorate } from "tslib";
2
+ import { Component, queryConnectedInstances, state } from '@a11d/lit';
3
+ import { equals } from '@a11d/equals';
4
+ import { compile, match, parse } from 'path-to-regexp';
5
+ import { WindowHelper, WindowOpenMode } from '../utilities/WindowHelper.js';
6
+ import { Application } from '../Application.js';
7
+ export var UrlMatchMode;
8
+ (function (UrlMatchMode) {
9
+ UrlMatchMode["All"] = "all";
10
+ UrlMatchMode["IgnoreParameters"] = "ignore-parameters";
11
+ })(UrlMatchMode || (UrlMatchMode = {}));
12
+ export var NavigationStrategy;
13
+ (function (NavigationStrategy) {
14
+ NavigationStrategy[NavigationStrategy["Page"] = 0] = "Page";
15
+ NavigationStrategy[NavigationStrategy["Tab"] = 1] = "Tab";
16
+ NavigationStrategy[NavigationStrategy["Window"] = 2] = "Window";
17
+ })(NavigationStrategy || (NavigationStrategy = {}));
18
+ export class RoutableComponent extends Component {
19
+ static get routes() { return this._routes.map(route => RoutableComponent.basePath + route); }
20
+ static set routes(value) { this._routes = value; }
21
+ static get boundComponent() {
22
+ return [...RoutableComponent.connectedInstances].at(0);
23
+ }
24
+ static get url() { return new URL(globalThis.location.toString()); }
25
+ static setUrl(value, force = false) {
26
+ if (value === undefined) {
27
+ return;
28
+ }
29
+ if (!force && value.toString() === this.url.toString()) {
30
+ return;
31
+ }
32
+ const navigate = () => {
33
+ window.history.pushState(null, '', value);
34
+ window.dispatchEvent(new PopStateEvent('popstate'));
35
+ };
36
+ if ('startViewTransition' in document) {
37
+ document.startViewTransition(() => navigate());
38
+ }
39
+ else {
40
+ navigate();
41
+ }
42
+ }
43
+ constructor(parameters) {
44
+ super();
45
+ this.parameters = parameters;
46
+ }
47
+ get route() {
48
+ return this.constructor.routes?.at(0);
49
+ }
50
+ get boundToWindow() {
51
+ return RoutableComponent.boundComponent === this;
52
+ }
53
+ async navigate(strategy, force) {
54
+ if (!force && this.urlMatches()) {
55
+ return;
56
+ }
57
+ strategy ?? (strategy = NavigationStrategy.Page);
58
+ if (strategy !== NavigationStrategy.Page) {
59
+ await WindowHelper.openAndFocus(this.url, strategy === NavigationStrategy.Window ? WindowOpenMode.Window : WindowOpenMode.Tab);
60
+ return;
61
+ }
62
+ this.updateUrl(force);
63
+ return;
64
+ }
65
+ get url() {
66
+ const route = this.route;
67
+ if (route === undefined) {
68
+ return undefined;
69
+ }
70
+ const url = new URL(compile(route)(this.parameters ?? undefined), RoutableComponent.url);
71
+ const routeKeys = !route ? [] : parse(route)
72
+ .map(x => typeof x === 'object' ? x.name : undefined)
73
+ .filter(name => typeof name === 'string')
74
+ .filter(Boolean);
75
+ const parametersKeys = Object.keys(this.parameters ?? {});
76
+ for (const queryString of parametersKeys.filter(key => !routeKeys.includes(key))) {
77
+ url.searchParams.set(queryString, encodeURIComponent(this.parameters[queryString]));
78
+ }
79
+ return url;
80
+ }
81
+ /**
82
+ * Determines if the current URL matches the route of this component.
83
+ * @param mode The matching mode. 'all' matches the path and parameters, 'ignore-parameters' matches only the path. Defaults to 'all'.
84
+ */
85
+ urlMatches(options) {
86
+ options ?? (options = {});
87
+ options.url ?? (options.url = RoutableComponent.url);
88
+ options.mode ?? (options.mode = UrlMatchMode.All);
89
+ const route = this.route;
90
+ const m = route === undefined ? false : match(route)(options.url.pathname);
91
+ if (m === false) {
92
+ return false;
93
+ }
94
+ if (options.mode === UrlMatchMode.IgnoreParameters) {
95
+ return true;
96
+ }
97
+ const parameters = {
98
+ ...m.params,
99
+ ...Object.fromEntries(options.url.searchParams)
100
+ };
101
+ return Object[equals](this.parameters, parameters);
102
+ }
103
+ updateUrl(force = false) {
104
+ if (this.url) {
105
+ RoutableComponent.setUrl(this.url, force);
106
+ }
107
+ }
108
+ refresh(parameters = { ...this.parameters }) {
109
+ return new this.constructor(parameters).navigate(NavigationStrategy.Page, true);
110
+ }
111
+ }
112
+ RoutableComponent.basePath = '';
113
+ RoutableComponent.container = new Set();
114
+ RoutableComponent.host = Application;
115
+ RoutableComponent._routes = new Array();
116
+ __decorate([
117
+ state({
118
+ updated() {
119
+ if (this.boundToWindow) {
120
+ this.updateUrl();
121
+ }
122
+ }
123
+ })
124
+ ], RoutableComponent.prototype, "parameters", void 0);
125
+ __decorate([
126
+ queryConnectedInstances()
127
+ ], RoutableComponent, "connectedInstances", void 0);