@a11d/lit-application 0.9.0 → 0.11.1

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 (79) hide show
  1. package/CHANGELOG.md +184 -0
  2. package/README.md +99 -0
  3. package/dist/Application.d.ts +50 -0
  4. package/dist/Application.d.ts.map +1 -1
  5. package/dist/Application.js +93 -45
  6. package/dist/ApplicationTopLayer.d.ts +6 -0
  7. package/dist/ApplicationTopLayer.d.ts.map +1 -1
  8. package/dist/ApplicationTopLayer.js +15 -9
  9. package/dist/Dialog/Dialog.d.ts +13 -0
  10. package/dist/Dialog/Dialog.d.ts.map +1 -1
  11. package/dist/Dialog/Dialog.js +1 -0
  12. package/dist/Dialog/DialogCancelledError.d.ts +1 -0
  13. package/dist/Dialog/DialogCancelledError.d.ts.map +1 -1
  14. package/dist/Dialog/DialogCancelledError.js +1 -0
  15. package/dist/Dialog/DialogComponent.d.ts +36 -0
  16. package/dist/Dialog/DialogComponent.d.ts.map +1 -1
  17. package/dist/Dialog/DialogComponent.js +32 -1
  18. package/dist/Dialog/ErrorHandlers/DialogComponentNoOpErrorHandler.d.ts +1 -0
  19. package/dist/Dialog/ErrorHandlers/DialogComponentNoOpErrorHandler.d.ts.map +1 -1
  20. package/dist/Dialog/ErrorHandlers/DialogComponentNoOpErrorHandler.js +1 -0
  21. package/dist/Dialog/ErrorHandlers/DialogComponentNotificationErrorHandler.d.ts +1 -0
  22. package/dist/Dialog/ErrorHandlers/DialogComponentNotificationErrorHandler.d.ts.map +1 -1
  23. package/dist/Dialog/ErrorHandlers/DialogComponentNotificationErrorHandler.js +1 -0
  24. package/dist/Notification/NotificationComponent.d.ts +14 -0
  25. package/dist/Notification/NotificationComponent.d.ts.map +1 -1
  26. package/dist/Notification/NotificationComponent.js +10 -0
  27. package/dist/Page/Page.d.ts +3 -1
  28. package/dist/Page/Page.d.ts.map +1 -1
  29. package/dist/Page/PageComponent.d.ts +11 -0
  30. package/dist/Page/PageComponent.d.ts.map +1 -1
  31. package/dist/Page/PageComponent.js +10 -1
  32. package/dist/Page/PageError.d.ts +1 -0
  33. package/dist/Page/PageError.d.ts.map +1 -1
  34. package/dist/Page/PageError.js +25 -24
  35. package/dist/Page/PageHost.d.ts +1 -0
  36. package/dist/Page/PageHost.d.ts.map +1 -1
  37. package/dist/Page/PageHost.js +7 -6
  38. package/dist/PwaHelper/Manifest.d.ts +2 -0
  39. package/dist/PwaHelper/Manifest.d.ts.map +1 -1
  40. package/dist/PwaHelper/ManifestProvider.d.ts +1 -0
  41. package/dist/PwaHelper/ManifestProvider.d.ts.map +1 -1
  42. package/dist/PwaHelper/PwaHelper.d.ts +4 -0
  43. package/dist/PwaHelper/PwaHelper.d.ts.map +1 -1
  44. package/dist/PwaHelper/PwaHelper.js +3 -0
  45. package/dist/Router/RoutableComponent.d.ts.map +1 -1
  46. package/dist/Router/RouterController.d.ts +6 -0
  47. package/dist/Router/RouterController.d.ts.map +1 -1
  48. package/dist/Router/RouterController.js +6 -0
  49. package/dist/Router/path.d.ts +1 -3
  50. package/dist/Router/path.d.ts.map +1 -1
  51. package/dist/Router/route.d.ts +5 -0
  52. package/dist/Router/route.d.ts.map +1 -1
  53. package/dist/Router/route.js +5 -0
  54. package/dist/Router/routerLink.d.ts +12 -0
  55. package/dist/Router/routerLink.d.ts.map +1 -1
  56. package/dist/Router/routerLink.js +6 -0
  57. package/dist/utilities/HookSet.d.ts +2 -0
  58. package/dist/utilities/HookSet.d.ts.map +1 -1
  59. package/dist/utilities/HookSet.js +2 -0
  60. package/dist/utilities/HttpError.d.ts +1 -0
  61. package/dist/utilities/HttpError.d.ts.map +1 -1
  62. package/dist/utilities/HttpError.js +1 -0
  63. package/dist/utilities/HttpErrorCode.d.ts +1 -0
  64. package/dist/utilities/HttpErrorCode.d.ts.map +1 -1
  65. package/dist/utilities/HttpErrorCode.js +1 -0
  66. package/dist/utilities/Key.d.ts +3 -4
  67. package/dist/utilities/Key.d.ts.map +1 -1
  68. package/dist/utilities/Key.js +3 -4
  69. package/dist/utilities/WindowHelper.d.ts +3 -0
  70. package/dist/utilities/WindowHelper.d.ts.map +1 -1
  71. package/dist/utilities/WindowHelper.js +3 -0
  72. package/dist/utilities/queryInstanceElement.d.ts +1 -0
  73. package/dist/utilities/queryInstanceElement.d.ts.map +1 -1
  74. package/dist/utilities/queryInstanceElement.js +1 -0
  75. package/dist/utilities/querySymbolizedElement.d.ts +5 -0
  76. package/dist/utilities/querySymbolizedElement.d.ts.map +1 -1
  77. package/dist/utilities/querySymbolizedElement.js +5 -0
  78. package/package.json +47 -43
  79. package/dist/tsconfig.tsbuildinfo +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Dialog.d.ts","sourceRoot":"","sources":["../../Dialog/Dialog.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAA;AACpE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAA;AAE3C,oBAAY,eAAe;IAC1B,OAAO,YAAY;IACnB,SAAS,cAAc;IACvB,YAAY,iBAAiB;CAC7B;AAED,MAAM,MAAM,kBAAkB,GAC3B,MAAM,4BAA4B,GAClC,CAAC,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;AAE3C,MAAM,WAAW,MAAO,SAAQ,IAAI;IACnC,IAAI,EAAE,OAAO,CAAA;IAEb,QAAQ,CAAC,eAAe,EAAE,mBAAmB,CAAA;IAE7C,QAAQ,CAAC,oBAAoB,EAAE,WAAW,GAAG,SAAS,CAAA;IACtD,QAAQ,CAAC,sBAAsB,EAAE,WAAW,GAAG,SAAS,CAAA;IACxD,QAAQ,CAAC,yBAAyB,EAAE,WAAW,GAAG,SAAS,CAAA;IAC3D,YAAY,EAAE,CAAC,GAAG,EAAE,eAAe,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC5D,eAAe,CAAC,EA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AC,EAAE,eAAe,CAAA;IAEjC,2BAA2B,CAAC,EAAE,OAAO,CAAA;IACrC,6DAA6D;IAC7D,cAAc,CAAC,EAAE,OAAO,CAAA;IAExB,wFAAwF;IACxF,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,sHAAsH;IACtH,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,uDAAuD;IACvD,QAAQ,CAAC,YAAY,CAAC,EAAE,eAAe,CAAC,IAAI,CAAC,CAAA;IAE7C,uHAAuH;IACvH,WAAW,CAAC,EAAE,OAAO,CAAA;IAErB,2FAA2F;IAC3F,YAAY,CAAC,EAAE,kBAAkB,CAAA;CACjC"}
@@ -1,3 +1,4 @@
1
+ /** The keys of the actions of a dialog. */
1
2
  export var DialogActionKey;
2
3
  (function (DialogActionKey) {
3
4
  DialogActionKey["Primary"] = "primary";
@@ -1,4 +1,5 @@
1
1
  import type { DialogComponent } from './DialogComponent.js';
2
+ /** The error the confirmation of a dialog rejects with when the dialog is cancelled. */
2
3
  export declare class DialogCancelledError extends Error {
3
4
  constructor(dialogComponent: DialogComponent<any, any>);
4
5
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DialogCancelledError.d.ts","sourceRoot":"","sources":["../../Dialog/DialogCancelledError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAE3D,qBAAa,oBAAqB,SAAQ,KAAK;gBAClC,eAAe,EAAE,eAAe,CAAC,GAAG,EAAE,GAAG,CAAC;CAGtD"}
1
+ {"version":3,"file":"DialogCancelledError.d.ts","sourceRoot":"","sources":["../../Dialog/DialogCancelledError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA;AAE3D,wFAAwF;AACxF,qBAAa,oBAAqB,SAAQ,KAAK;IAC9C,YAAY,eAAe,EAAE,eAAe,CAAC,GAAG,EAAE,GAAG,CAAC,EAErD;CACD"}
@@ -1,3 +1,4 @@
1
+ /** The error the confirmation of a dialog rejects with when the dialog is cancelled. */
1
2
  export class DialogCancelledError extends Error {
2
3
  constructor(dialogComponent) {
3
4
  super(`Dialog "${dialogComponent.tagName.toLowerCase()}" was cancelled.`);
@@ -2,52 +2,88 @@ import { type PropertyValues } from '@a11d/lit';
2
2
  import { LocalStorage } from '@a11d/local-storage';
3
3
  import { HookSet, RoutableComponent, NavigationStrategy } from '../index.js';
4
4
  import { type Dialog, DialogActionKey } from './index.js';
5
+ /** The parameters of a dialog, passed to its constructor and mapped to its URL if it has a route. */
5
6
  export type DialogParameters = void | Record<string, any>;
7
+ /** The outcome of a dialog action: the result resolving the confirmation, or an `Error` rejecting it. */
6
8
  export type DialogResult<TResult> = TResult | Error;
9
+ /** What a dialog action returns: a `DialogResult`, or a promise of one. */
7
10
  export type DialogAction<TResult> = DialogResult<TResult> | PromiseLike<DialogResult<TResult>>;
11
+ /** Where a dialog opens: in place, or popped out into a new tab or window. */
8
12
  export declare enum DialogConfirmationStrategy {
9
13
  Dialog = 0,
10
14
  Tab = 1,
11
15
  Window = 2
12
16
  }
17
+ /** The confirmation strategies that pop a dialog out into a new tab or window. */
13
18
  export type PopupConfirmationStrategy = Exclude<DialogConfirmationStrategy, DialogConfirmationStrategy.Dialog>;
19
+ /**
20
+ * The base class of a handler for the errors thrown by dialog actions, registered with `DialogComponent.errorHandler()`.
21
+ *
22
+ * Declare its key in the global `DialogComponentErrorHandlers` interface for dialog elements to refer to it by `errorHandler`.
23
+ */
14
24
  export declare abstract class DialogComponentErrorHandler {
15
25
  protected readonly dialogComponent: DialogComponent<any, any>;
16
26
  constructor(dialogComponent: DialogComponent<any, any>);
17
27
  abstract handle(error: Error): void | Promise<void>;
18
28
  }
29
+ /**
30
+ * The base class of a dialog, opened by `confirm`, which resolves with the dialog's result once it closes.
31
+ *
32
+ * Its template renders a dialog element, such as `lit-dialog`, whose heading defaults to the component's `label` metadata.
33
+ * An action resolves `confirm` with the value it returns or rejects it with the `Error` it returns, and cancelling rejects it
34
+ * with a `DialogCancelledError`. An error thrown by an action keeps the dialog open and goes to the dialog element's `errorHandler`.
35
+ * A dialog with a `@route` can also pop out into a tab or window.
36
+ */
19
37
  export declare abstract class DialogComponent<T extends DialogParameters = void, TResult = void> extends RoutableComponent<T> {
38
+ /** Hooks awaited with each dialog before it connects. */
20
39
  static readonly connectingHooks: HookSet<DialogComponent<any, any>>;
21
40
  private static readonly errorHandlers;
22
41
  private static defaultErrorHandler;
42
+ /** Marks the decorated element class as a dialog element, which `dialogElement` finds in a dialog component's render root. */
23
43
  static dialogElement(): (constructor: Constructor<Dialog>) => void;
44
+ /** Registers the decorated class as the error handler of the key, and as the default one if `isDefault` is set. */
24
45
  static errorHandler(key: string, isDefault?: boolean): (ErrorHandlerConstructor: Constructor<DialogComponentErrorHandler>) => void;
46
+ /** The strategy poppable dialogs open with unless `confirm` is given one, persisted in local storage. */
25
47
  static readonly poppableConfirmationStrategy: LocalStorage<DialogConfirmationStrategy>;
48
+ /** Resolves the element dialogs are appended to, the application's top layer by default. */
26
49
  static getHost(): Promise<HTMLElement>;
50
+ /** The dialog element in the render root; accessing it throws when there is none. */
27
51
  readonly dialogElement: Dialog & HTMLElement;
28
52
  get primaryActionElement(): HTMLElement | undefined;
29
53
  get secondaryActionElement(): HTMLElement | undefined;
30
54
  get cancellationActionElement(): HTMLElement | undefined;
55
+ /** The window that opened the window the dialog popped out into, or the current window otherwise. */
31
56
  get opener(): Window & typeof globalThis;
32
57
  protected handleBeforeUnload(): Promise<void>;
33
58
  protected handleKeyDown(e: KeyboardEvent): Promise<void>;
34
59
  connectedCallback(): Promise<void>;
60
+ /** Opens the dialog like `confirm`, taking the navigation strategy as the confirmation strategy. */
35
61
  navigate(strategy?: NavigationStrategy, force?: boolean): Promise<TResult>;
62
+ /** Opens the dialog and resolves with its result once it closes; poppable dialogs open with `poppableConfirmationStrategy` by default. */
36
63
  confirm(strategy?: DialogConfirmationStrategy): Promise<TResult>;
37
64
  private _confirmationPromiseExecutor?;
38
65
  private confirmAsDialog;
39
66
  private confirmAsPopup;
67
+ /** Copies the reactive properties of this dialog to its counterpart in the window it pops out into; override it to copy more. */
40
68
  protected cloned(other: DialogComponent<T, TResult>): void;
69
+ /** Closes the dialog and reopens it in a new tab or window, whose result then settles the original confirmation. */
41
70
  protected pop(strategy?: Exclude<DialogConfirmationStrategy, DialogConfirmationStrategy.Dialog>): Promise<void>;
71
+ /** Closes the dialog, resolving its confirmation with the result, or rejecting it if the result is an `Error`. */
42
72
  protected close(result: TResult | Error): void;
43
73
  private get open();
44
74
  private set open(value);
75
+ /** Whether the dialog can pop out into a tab or window, which requires a route that the current URL does not match. */
45
76
  get poppable(): boolean;
46
77
  protected firstUpdated(props: PropertyValues): void;
78
+ /** Returns the result to close the dialog with when its primary action is invoked; throws unless overridden. */
47
79
  protected primaryAction(): DialogAction<TResult>;
80
+ /** Returns the result to close the dialog with when its secondary action is invoked; cancels the dialog by default. */
48
81
  protected secondaryAction(): DialogAction<TResult>;
82
+ /** Returns the result to close the dialog with when it is cancelled, a `DialogCancelledError` by default. */
49
83
  protected cancellationAction(): DialogAction<TResult>;
84
+ /** Runs the action of the key and closes the dialog with its result, unless `manualClose` keeps it open. */
50
85
  protected readonly handleAction: (actionKey: DialogActionKey) => Promise<void>;
86
+ /** Passes an error thrown by an action to the dialog element's `errorHandler`, or to the default error handler without one. */
51
87
  protected handleError(error: Error): void | Promise<void>;
52
88
  }
53
89
  //# sourceMappingURL=DialogComponent.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"DialogComponent.d.ts","sourceRoot":"","sources":["../../Dialog/DialogComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,KAAK,cAAc,EAAE,MAAM,WAAW,CAAA;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,EAAe,OAAO,EAA0B,iBAAiB,EAAqC,kBAAkB,EAAE,MAAM,aAAa,CAAA;AACpJ,OAAO,EAAE,KAAK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H,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,GAAG,KAAK,QAetC;IAED,OAAO,KAAK,IAAI,GAA8C;IAC9D,OAAO,KAAK,IAAI,QAIf;IAED,uHAAuH;IACvH,IAAI,QAAQ,YAEX;IAED,UAAmB,YAAY,CAAC,KAAK,EAAE,cAAc,QASpD;IAED,gHAAgH;IAChH,SAAS,CAAC,aAAa,IAAI,YAAY,CAAC,OAAO,CAAC,CAE/C;IAED,uHAAuH;IACvH,SAAS,CAAC,eAAe,IAAI,YAAY,CAAC,OAAO,CAAC,CAEjD;IAED,6GAA6G;IAC7G,SAAS,CAAC,kBAAkB,IAAI,YAAY,CAAC,OAAO,CAAC,CAEpD;IAED,4GAA4G;IAC5G,SAAS,CAAC,QAAQ,CAAC,YAAY,cAAqB,eAAe,mBAyBlE;IAED,+HAA+H;IAC/H,SAAS,CAAC,WAAW,CAAC,KAAK,EAAE,KAAK,wBAoBjC;CACD"}
@@ -3,21 +3,36 @@ import { eventListener } from '@a11d/lit';
3
3
  import { LocalStorage } from '@a11d/local-storage';
4
4
  import { Application, HookSet, querySymbolizedElement, RoutableComponent, WindowHelper, WindowOpenMode, Key, NavigationStrategy } from '../index.js';
5
5
  import { DialogActionKey, DialogCancelledError } from './index.js';
6
+ /** Where a dialog opens: in place, or popped out into a new tab or window. */
6
7
  export var DialogConfirmationStrategy;
7
8
  (function (DialogConfirmationStrategy) {
8
9
  DialogConfirmationStrategy[DialogConfirmationStrategy["Dialog"] = 0] = "Dialog";
9
10
  DialogConfirmationStrategy[DialogConfirmationStrategy["Tab"] = 1] = "Tab";
10
11
  DialogConfirmationStrategy[DialogConfirmationStrategy["Window"] = 2] = "Window";
11
12
  })(DialogConfirmationStrategy || (DialogConfirmationStrategy = {}));
13
+ /**
14
+ * The base class of a handler for the errors thrown by dialog actions, registered with `DialogComponent.errorHandler()`.
15
+ *
16
+ * Declare its key in the global `DialogComponentErrorHandlers` interface for dialog elements to refer to it by `errorHandler`.
17
+ */
12
18
  export class DialogComponentErrorHandler {
13
19
  constructor(dialogComponent) {
14
20
  this.dialogComponent = dialogComponent;
15
21
  }
16
22
  }
17
23
  const dialogElementConstructorSymbol = Symbol('DialogComponent.DialogElementConstructor');
24
+ /**
25
+ * The base class of a dialog, opened by `confirm`, which resolves with the dialog's result once it closes.
26
+ *
27
+ * Its template renders a dialog element, such as `lit-dialog`, whose heading defaults to the component's `label` metadata.
28
+ * An action resolves `confirm` with the value it returns or rejects it with the `Error` it returns, and cancelling rejects it
29
+ * with a `DialogCancelledError`. An error thrown by an action keeps the dialog open and goes to the dialog element's `errorHandler`.
30
+ * A dialog with a `@route` can also pop out into a tab or window.
31
+ */
18
32
  export class DialogComponent extends RoutableComponent {
19
33
  constructor() {
20
34
  super(...arguments);
35
+ /** Runs the action of the key and closes the dialog with its result, unless `manualClose` keeps it open. */
21
36
  this.handleAction = async (actionKey) => {
22
37
  const actionByKey = new Map([
23
38
  [DialogActionKey.Primary, this.primaryAction],
@@ -44,13 +59,16 @@ export class DialogComponent extends RoutableComponent {
44
59
  }
45
60
  };
46
61
  }
62
+ /** Hooks awaited with each dialog before it connects. */
47
63
  static { this.connectingHooks = new HookSet(); }
48
64
  static { this.errorHandlers = new Map(); }
65
+ /** Marks the decorated element class as a dialog element, which `dialogElement` finds in a dialog component's render root. */
49
66
  static dialogElement() {
50
67
  return (constructor) => {
51
68
  constructor[dialogElementConstructorSymbol] = true;
52
69
  };
53
70
  }
71
+ /** Registers the decorated class as the error handler of the key, and as the default one if `isDefault` is set. */
54
72
  static errorHandler(key, isDefault = false) {
55
73
  return (ErrorHandlerConstructor) => {
56
74
  DialogComponent.errorHandlers.set(key, ErrorHandlerConstructor);
@@ -59,7 +77,9 @@ export class DialogComponent extends RoutableComponent {
59
77
  }
60
78
  };
61
79
  }
80
+ /** The strategy poppable dialogs open with unless `confirm` is given one, persisted in local storage. */
62
81
  static { this.poppableConfirmationStrategy = new LocalStorage('DialogComponent.PoppableConfirmationStrategy', DialogConfirmationStrategy.Dialog); }
82
+ /** Resolves the element dialogs are appended to, the application's top layer by default. */
63
83
  static getHost() {
64
84
  return Promise.resolve(Application.topLayer);
65
85
  }
@@ -72,6 +92,7 @@ export class DialogComponent extends RoutableComponent {
72
92
  get cancellationActionElement() {
73
93
  return this.dialogElement.cancellationActionElement;
74
94
  }
95
+ /** The window that opened the window the dialog popped out into, or the current window otherwise. */
75
96
  get opener() {
76
97
  return !this.dialogElement.boundToWindow
77
98
  ? window
@@ -97,10 +118,12 @@ export class DialogComponent extends RoutableComponent {
97
118
  await DialogComponent.connectingHooks.execute(this);
98
119
  super.connectedCallback();
99
120
  }
121
+ /** Opens the dialog like `confirm`, taking the navigation strategy as the confirmation strategy. */
100
122
  navigate(strategy, force) {
101
123
  force;
102
124
  return this.confirm(strategy);
103
125
  }
126
+ /** Opens the dialog and resolves with its result once it closes; poppable dialogs open with `poppableConfirmationStrategy` by default. */
104
127
  confirm(strategy) {
105
128
  strategy ??= !this.poppable
106
129
  ? DialogConfirmationStrategy.Dialog
@@ -134,6 +157,7 @@ export class DialogComponent extends RoutableComponent {
134
157
  this.cloned(other);
135
158
  return other.confirmAsDialog();
136
159
  }
160
+ /** Copies the reactive properties of this dialog to its counterpart in the window it pops out into; override it to copy more. */
137
161
  cloned(other) {
138
162
  if (this.isConnected) {
139
163
  // Copy the dialog's properties to the dialog in the new window
@@ -143,6 +167,7 @@ export class DialogComponent extends RoutableComponent {
143
167
  other.requestUpdate();
144
168
  }
145
169
  }
170
+ /** Closes the dialog and reopens it in a new tab or window, whose result then settles the original confirmation. */
146
171
  async pop(strategy = DialogConfirmationStrategy.Tab) {
147
172
  this.open = false;
148
173
  const [resolve, reject] = this._confirmationPromiseExecutor ?? [];
@@ -154,6 +179,7 @@ export class DialogComponent extends RoutableComponent {
154
179
  reject?.(error);
155
180
  }
156
181
  }
182
+ /** Closes the dialog, resolving its confirmation with the result, or rejecting it if the result is an `Error`. */
157
183
  close(result) {
158
184
  this.open = false;
159
185
  const [resolve, reject] = this._confirmationPromiseExecutor ?? [];
@@ -174,6 +200,7 @@ export class DialogComponent extends RoutableComponent {
174
200
  this.dialogElement.open = value;
175
201
  }
176
202
  }
203
+ /** Whether the dialog can pop out into a tab or window, which requires a route that the current URL does not match. */
177
204
  get poppable() {
178
205
  return !!this.route && !this.urlMatches();
179
206
  }
@@ -182,19 +209,23 @@ export class DialogComponent extends RoutableComponent {
182
209
  this.dialogElement.requestPopup?.subscribe(() => this.pop());
183
210
  this.dialogElement.poppable = this.poppable;
184
211
  this.dialogElement.boundToWindow = this.boundToWindow;
185
- this.dialogElement.heading ||= label.get(this.constructor)?.toString();
212
+ this.dialogElement.heading ||= label.resolve(this)?.toString();
186
213
  this.open = true;
187
214
  super.firstUpdated(props);
188
215
  }
216
+ /** Returns the result to close the dialog with when its primary action is invoked; throws unless overridden. */
189
217
  primaryAction() {
190
218
  throw new Error('Not implemented.');
191
219
  }
220
+ /** Returns the result to close the dialog with when its secondary action is invoked; cancels the dialog by default. */
192
221
  secondaryAction() {
193
222
  return this.cancellationAction();
194
223
  }
224
+ /** Returns the result to close the dialog with when it is cancelled, a `DialogCancelledError` by default. */
195
225
  cancellationAction() {
196
226
  return new DialogCancelledError(this);
197
227
  }
228
+ /** Passes an error thrown by an action to the dialog element's `errorHandler`, or to the default error handler without one. */
198
229
  handleError(error) {
199
230
  if (error instanceof DialogCancelledError) {
200
231
  return;
@@ -1,4 +1,5 @@
1
1
  import { DialogComponentErrorHandler } from '../DialogComponent.js';
2
+ /** The `no-op` dialog error handler, which ignores errors. */
2
3
  export declare class DialogComponentNoOpErrorHandler extends DialogComponentErrorHandler {
3
4
  handle(): void;
4
5
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DialogComponentNoOpErrorHandler.d.ts","sourceRoot":"","sources":["../../../Dialog/ErrorHandlers/DialogComponentNoOpErrorHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,2BAA2B,EAAE,MAAM,uBAAuB,CAAA;AAEpF,qBACa,+BAAgC,SAAQ,2BAA2B;IACtE,MAAM;CACf;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,4BAA4B;QACrC,OAAO,EAAE,+BAA+B,CAAA;KACxC;CACD"}
1
+ {"version":3,"file":"DialogComponentNoOpErrorHandler.d.ts","sourceRoot":"","sources":["../../../Dialog/ErrorHandlers/DialogComponentNoOpErrorHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,2BAA2B,EAAE,MAAM,uBAAuB,CAAA;AAEpF,8DAA8D;AAC9D,qBACa,+BAAgC,SAAQ,2BAA2B;IACtE,MAAM,SAAM;CACrB;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,4BAA4B;QACrC,OAAO,EAAE,+BAA+B,CAAA;KACxC;CACD"}
@@ -1,5 +1,6 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { DialogComponent, DialogComponentErrorHandler } from '../DialogComponent.js';
3
+ /** The `no-op` dialog error handler, which ignores errors. */
3
4
  let DialogComponentNoOpErrorHandler = class DialogComponentNoOpErrorHandler extends DialogComponentErrorHandler {
4
5
  handle() { }
5
6
  };
@@ -1,4 +1,5 @@
1
1
  import { DialogComponentErrorHandler } from '../DialogComponent.js';
2
+ /** The default `notification` dialog error handler, which shows errors as error notifications. */
2
3
  export declare class DialogComponentNotificationErrorHandler extends DialogComponentErrorHandler {
3
4
  handle(error: Error): Promise<void>;
4
5
  }
@@ -1 +1 @@
1
- {"version":3,"file":"DialogComponentNotificationErrorHandler.d.ts","sourceRoot":"","sources":["../../../Dialog/ErrorHandlers/DialogComponentNotificationErrorHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,2BAA2B,EAAE,MAAM,uBAAuB,CAAA;AAGpF,qBACa,uCAAwC,SAAQ,2BAA2B;IAC9E,MAAM,CAAC,KAAK,EAAE,KAAK;CAG5B;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,4BAA4B;QACrC,cAAc,EAAE,uCAAuC,CAAA;KACvD;CACD"}
1
+ {"version":3,"file":"DialogComponentNotificationErrorHandler.d.ts","sourceRoot":"","sources":["../../../Dialog/ErrorHandlers/DialogComponentNotificationErrorHandler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,2BAA2B,EAAE,MAAM,uBAAuB,CAAA;AAGpF,kGAAkG;AAClG,qBACa,uCAAwC,SAAQ,2BAA2B;IAC9E,MAAM,CAAC,KAAK,EAAE,KAAK,iBAE3B;CACD;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,4BAA4B;QACrC,cAAc,EAAE,uCAAuC,CAAA;KACvD;CACD"}
@@ -1,6 +1,7 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { DialogComponent, DialogComponentErrorHandler } from '../DialogComponent.js';
3
3
  import { NotificationComponent } from '../../Notification/NotificationComponent.js';
4
+ /** The default `notification` dialog error handler, which shows errors as error notifications. */
4
5
  let DialogComponentNotificationErrorHandler = class DialogComponentNotificationErrorHandler extends DialogComponentErrorHandler {
5
6
  handle(error) {
6
7
  return NotificationComponent.notifyError(error.message);
@@ -1,15 +1,18 @@
1
1
  import { NonInertableComponent } from '@a11d/non-inertable-component';
2
+ /** The kinds of notifications. */
2
3
  export declare enum NotificationType {
3
4
  Info = "info",
4
5
  Success = "success",
5
6
  Warning = "warning",
6
7
  Error = "error"
7
8
  }
9
+ /** A notification to show: its message, with an optional type and actions. */
8
10
  export type Notification = {
9
11
  type?: NotificationType;
10
12
  message: string;
11
13
  actions?: Array<NotificationAction>;
12
14
  };
15
+ /** An action of a notification, with the title of its button and what clicking it does. */
13
16
  type NotificationAction = {
14
17
  title: string;
15
18
  handleClick: () => void | PromiseLike<void>;
@@ -17,17 +20,28 @@ type NotificationAction = {
17
20
  type NonTypedNotification = Omit<Notification, 'type'>;
18
21
  type NonTypedNotificationParameters = [notification: NonTypedNotification] | [message: string, ...actions: Array<NotificationAction>];
19
22
  type NonTypedNotificationWithErrorParameters = [notification: NonTypedNotification] | [errorMessage: string, ...actions: Array<NotificationAction>] | [error: Error, ...actions: Array<NotificationAction>];
23
+ /**
24
+ * The base class of the element showing notifications, whose static `notify` methods send them.
25
+ *
26
+ * Implement `show` to show the `notification`, and register the implementation with `@NotificationComponent.defaultComponent()`.
27
+ * Each notification gets its own instance, appended to the application's top layer while it is shown.
28
+ */
20
29
  export declare abstract class NotificationComponent extends NonInertableComponent {
21
30
  static readonly shownNotifications: Set<Notification>;
22
31
  private static DefaultComponentConstructor?;
32
+ /** Registers the decorated class as the component that notifications sent through `NotificationComponent` are shown with. */
23
33
  static defaultComponent: () => <T extends NotificationComponent>(Constructor: Constructor<T>) => void;
24
34
  static notifyInfo(...parameters: NonTypedNotificationParameters): Promise<void>;
25
35
  static notifySuccess(...parameters: NonTypedNotificationParameters): Promise<void>;
26
36
  static notifyWarning(...parameters: NonTypedNotificationParameters): Promise<void>;
27
37
  static notifyError(...parameters: NonTypedNotificationParameters): Promise<void>;
38
+ /** Shows an error notification, then throws the given error, or an `Error` with the given message. */
28
39
  static notifyAndThrowError(...parameters: NonTypedNotificationWithErrorParameters): void;
40
+ /** Shows the notification with this class, or with the default component if called on `NotificationComponent` itself. */
29
41
  static notify(notification: Notification): Promise<void>;
42
+ /** The notification to show, set before `show` is called. */
30
43
  abstract notification: Notification;
44
+ /** Shows the `notification`, resolving once it is done showing. */
31
45
  abstract show(): Promise<void>;
32
46
  }
33
47
  export {};
@@ -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,kBAAk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AAC,2BAA2B,CAAC,CAAoC;IAE/E,6HAA6H;IAC7H,MAAM,CAAC,gBAAgB,SACd,CAAC,SAAS,qBAAqB,eAAe,WAAW,CAAC,CAAC,CAAC,UAGpE;IAED,MAAM,CAAC,UAAU,CAAC,GAAG,UAAU,EAAE,8BAA8B,iBAE9D;IAED,MAAM,CAAC,aAAa,CAAC,GAAG,UAAU,EAAE,8BAA8B,iBAEjE;IAED,MAAM,CAAC,aAAa,CAAC,GAAG,UAAU,EAAE,8BAA8B,iBAEjE;IAED,MAAM,CAAC,WAAW,CAAC,GAAG,UAAU,EAAE,8BAA8B,iBAE/D;IAED,sGAAsG;IACtG,MAAM,CAAC,mBAAmB,CAAC,GAAG,UAAU,EAAE,uCAAuC,QAchF;IAED,yHAAyH;IACzH,OAAa,MAAM,CAAC,YAAY,EAAE,YAAY,iBAwB7C;IAED,6DAA6D;IAC7D,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAA;IACnC,mEAAmE;IACnE,QAAQ,CAAC,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAA;CAC9B"}
@@ -1,6 +1,7 @@
1
1
  import { LitElement } from '@a11d/lit';
2
2
  import { Application } from '../Application.js';
3
3
  import { NonInertableComponent } from '@a11d/non-inertable-component';
4
+ /** The kinds of notifications. */
4
5
  export var NotificationType;
5
6
  (function (NotificationType) {
6
7
  NotificationType["Info"] = "info";
@@ -14,8 +15,15 @@ function normalizeNonTypedNotificationParameters(...parameters) {
14
15
  actions: parameters.slice(1),
15
16
  };
16
17
  }
18
+ /**
19
+ * The base class of the element showing notifications, whose static `notify` methods send them.
20
+ *
21
+ * Implement `show` to show the `notification`, and register the implementation with `@NotificationComponent.defaultComponent()`.
22
+ * Each notification gets its own instance, appended to the application's top layer while it is shown.
23
+ */
17
24
  export class NotificationComponent extends NonInertableComponent {
18
25
  static { this.shownNotifications = new Set(); }
26
+ /** Registers the decorated class as the component that notifications sent through `NotificationComponent` are shown with. */
19
27
  static { this.defaultComponent = () => {
20
28
  return (Constructor) => {
21
29
  NotificationComponent.DefaultComponentConstructor = Constructor;
@@ -33,6 +41,7 @@ export class NotificationComponent extends NonInertableComponent {
33
41
  static notifyError(...parameters) {
34
42
  return this.notify({ type: NotificationType.Error, ...normalizeNonTypedNotificationParameters(...parameters) });
35
43
  }
44
+ /** Shows an error notification, then throws the given error, or an `Error` with the given message. */
36
45
  static notifyAndThrowError(...parameters) {
37
46
  let error;
38
47
  if (parameters[0] instanceof Error) {
@@ -50,6 +59,7 @@ export class NotificationComponent extends NonInertableComponent {
50
59
  }
51
60
  throw error;
52
61
  }
62
+ /** Shows the notification with this class, or with the default component if called on `NotificationComponent` itself. */
53
63
  static async notify(notification) {
54
64
  const notificationComponent = this !== NotificationComponent
55
65
  ? new this()
@@ -1,7 +1,9 @@
1
1
  import { type LitElement } from '@a11d/lit';
2
+ /** The element a page component renders its content into, such as `lit-page`, marked with `PageComponent.pageElement()`. */
2
3
  export interface Page extends LitElement {
3
- /** The event must be "composed", "bubbles" and "cancellable" */
4
+ /** Dispatches the heading whenever it changes, as a `composed`, bubbling and `cancelable` event. */
4
5
  readonly pageHeadingChange: EventDispatcher<string>;
6
+ /** The heading of the page, which the application shows in the document title. */
5
7
  heading: string;
6
8
  }
7
9
  //# sourceMappingURL=Page.d.ts.map
@@ -1 +1 @@
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
+ {"version":3,"file":"Page.d.ts","sourceRoot":"","sources":["../../Page/Page.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,UAAU,EAAE,MAAM,WAAW,CAAA;AAE3C,4HAA4H;AAC5H,MAAM,WAAW,IAAK,SAAQ,UAAU;IACvC,oGAAoG;IACpG,QAAQ,CAAC,iBAAiB,EAAE,eAAe,CAAC,MAAM,CAAC,CAAA;IACnD,kFAAkF;IAClF,OAAO,EAAE,MAAM,CAAA;CACf"}
@@ -1,12 +1,23 @@
1
1
  import { type PropertyValues } from '@a11d/lit';
2
2
  import { RoutableComponent, HookSet, type RoutableParameters } from '../index.js';
3
3
  import { type Page } from './index.js';
4
+ /** The parameters of a page, mapped to the path and query string of its URL. */
4
5
  export type PageParameters = RoutableParameters;
6
+ /**
7
+ * The base class of a page, rendered by the application when its route matches.
8
+ *
9
+ * Its template renders a page element, such as `lit-page`, whose heading defaults to the component's `label` metadata.
10
+ * Navigate to a page with `new PageUser({ id: 1 }).navigate()`, or link to it with `routerLink`.
11
+ */
5
12
  export declare abstract class PageComponent<T extends PageParameters = void> extends RoutableComponent<T> {
13
+ /** Hooks awaited with each page before it connects, such as to check permissions. */
6
14
  static readonly connectingHooks: HookSet<PageComponent<any>>;
15
+ /** The tag of the page element that built-in pages such as `PageError` render, `lit-page` by default. */
7
16
  static defaultPageElementTag: import("lit-html/static.js").StaticValue;
17
+ /** Marks the decorated element class as a page element, which `pageElement` finds in a page component's render root. */
8
18
  static pageElement(): (constructor: Constructor<Page>) => void;
9
19
  navigate(...args: Parameters<RoutableComponent['navigate']>): Promise<void>;
20
+ /** The page element in the render root; accessing it throws when there is none. */
10
21
  readonly pageElement: Page & HTMLElement;
11
22
  connectedCallback(): Promise<void>;
12
23
  protected firstUpdated(props: PropertyValues): void;
@@ -1 +1 @@
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,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AED,mFAAmF;IAC7B,QAAQ,CAAC,WAAW,EAAG,IAAI,GAAG,WAAW,CAAA;IAEhF,iBAAiB,kBAG/B;IAED,UAAmB,YAAY,CAAC,KAAK,EAAE,cAAc,QAGpD;CACD"}
@@ -3,9 +3,18 @@ import { literal } from '@a11d/lit';
3
3
  import { label } from '@a11d/metadata';
4
4
  import { querySymbolizedElement, RoutableComponent, HookSet } from '../index.js';
5
5
  const pageElementConstructorSymbol = Symbol('PageComponent.PageElementConstructor');
6
+ /**
7
+ * The base class of a page, rendered by the application when its route matches.
8
+ *
9
+ * Its template renders a page element, such as `lit-page`, whose heading defaults to the component's `label` metadata.
10
+ * Navigate to a page with `new PageUser({ id: 1 }).navigate()`, or link to it with `routerLink`.
11
+ */
6
12
  export class PageComponent extends RoutableComponent {
13
+ /** Hooks awaited with each page before it connects, such as to check permissions. */
7
14
  static { this.connectingHooks = new HookSet(); }
15
+ /** The tag of the page element that built-in pages such as `PageError` render, `lit-page` by default. */
8
16
  static { this.defaultPageElementTag = literal `lit-page`; }
17
+ /** Marks the decorated element class as a page element, which `pageElement` finds in a page component's render root. */
9
18
  static pageElement() {
10
19
  return (constructor) => {
11
20
  constructor[pageElementConstructorSymbol] = true;
@@ -19,7 +28,7 @@ export class PageComponent extends RoutableComponent {
19
28
  super.connectedCallback();
20
29
  }
21
30
  firstUpdated(props) {
22
- this.pageElement.heading ||= label.get(this.constructor)?.toString();
31
+ this.pageElement.heading ||= label.resolve(this)?.toString();
23
32
  super.firstUpdated(props);
24
33
  }
25
34
  }
@@ -1,6 +1,7 @@
1
1
  import { type HTMLTemplateResult } from '@a11d/lit';
2
2
  import { HttpErrorCode } from '../index.js';
3
3
  import { PageComponent } from './PageComponent.js';
4
+ /** The page showing an HTTP error, routed at `/error/:error` and rendered by the application when no route matches. */
4
5
  export declare class PageError extends PageComponent<{
5
6
  readonly error: HttpErrorCode;
6
7
  readonly message?: string;
@@ -1 +1 @@
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"}
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,uHAAuH;AACvH,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"}
@@ -4,6 +4,7 @@ import { component, css, html, staticHtml, style } from '@a11d/lit';
4
4
  import { HttpError, HttpErrorCode } from '../index.js';
5
5
  import { route } from '../Router/route.js';
6
6
  import { PageComponent } from './PageComponent.js';
7
+ /** The page showing an HTTP error, routed at `/error/:error` and rendered by the application when no route matches. */
7
8
  let PageError = class PageError extends PageComponent {
8
9
  static { PageError_1 = this; }
9
10
  static { this.emojisByErrorCodes = new Map([
@@ -28,38 +29,38 @@ let PageError = class PageError extends PageComponent {
28
29
  [HttpErrorCode.LoopDetected, '➰'],
29
30
  ]); }
30
31
  static get styles() {
31
- return css `
32
- .code {
33
- font-size: 60px;
34
- font-weight: 400;
35
- text-align: center;
36
- }
37
-
38
- h1, h2 {
39
- text-align: center;
40
- margin: 0;
41
- }
32
+ return css `
33
+ .code {
34
+ font-size: 60px;
35
+ font-weight: 400;
36
+ text-align: center;
37
+ }
38
+
39
+ h1, h2 {
40
+ text-align: center;
41
+ margin: 0;
42
+ }
42
43
  `;
43
44
  }
44
45
  get template() {
45
- return staticHtml `
46
- <${PageComponent.defaultPageElementTag} heading=${`Error ${this.parameters.error}`} fullHeight>
47
- <div ${style({ display: 'flex', gap: '8px', flexDirection: 'column', alignItems: 'center', justifyContent: 'center' })}>
48
- <div class='code'>${this.errorTemplate}</div>
49
- <div ${style({ display: 'flex', gap: '4px', flexDirection: 'column' })}>
50
- <h1>${this.parameters.message ?? HttpError.defaultMessageByErrorCode.get(this.parameters.error) ?? 'Unknown Error'}</h1>
51
- </div>
52
- </div>
53
- </${PageComponent.defaultPageElementTag}>
46
+ return staticHtml `
47
+ <${PageComponent.defaultPageElementTag} heading=${`Error ${this.parameters.error}`} fullHeight>
48
+ <div ${style({ display: 'flex', gap: '8px', flexDirection: 'column', alignItems: 'center', justifyContent: 'center' })}>
49
+ <div class='code'>${this.errorTemplate}</div>
50
+ <div ${style({ display: 'flex', gap: '4px', flexDirection: 'column' })}>
51
+ <h1>${this.parameters.message ?? HttpError.defaultMessageByErrorCode.get(this.parameters.error) ?? 'Unknown Error'}</h1>
52
+ </div>
53
+ </div>
54
+ </${PageComponent.defaultPageElementTag}>
54
55
  `;
55
56
  }
56
57
  get errorTemplate() {
57
58
  const errorCode = String(this.parameters.error);
58
59
  const emoji = PageError_1.emojisByErrorCodes.get(this.parameters.error);
59
- return !emoji ? html `
60
- <span>${errorCode}</span>
61
- ` : html `
62
- <span>${errorCode.charAt(0)}</span>${emoji}<span>${errorCode.charAt(2)}</span>
60
+ return !emoji ? html `
61
+ <span>${errorCode}</span>
62
+ ` : html `
63
+ <span>${errorCode.charAt(0)}</span>${emoji}<span>${errorCode.charAt(2)}</span>
63
64
  `;
64
65
  }
65
66
  };
@@ -1,4 +1,5 @@
1
1
  import { Component } from '@a11d/lit';
2
+ /** The element hosting the current page, rendered by the application. */
2
3
  export declare class PageHost extends Component {
3
4
  static get styles(): import("@a11d/lit").CSSResult;
4
5
  protected get template(): import("lit-html").HTMLTemplateResult;
@@ -1 +1 @@
1
- {"version":3,"file":"PageHost.d.ts","sourceRoot":"","sources":["../../Page/PageHost.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAwB,MAAM,WAAW,CAAA;AAE3D,qBACa,QAAS,SAAQ,SAAS;IACtC,WAAoB,MAAM,kCAQzB;IAED,cAAuB,QAAQ,0CAE9B;CACD;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,eAAe,EAAE,QAAQ,CAAA;KACzB;CACD"}
1
+ {"version":3,"file":"PageHost.d.ts","sourceRoot":"","sources":["../../Page/PageHost.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAwB,MAAM,WAAW,CAAA;AAE3D,yEAAyE;AACzE,qBACa,QAAS,SAAQ,SAAS;IACtC,WAAoB,MAAM,kCAQzB;IAED,cAAuB,QAAQ,0CAE9B;CACD;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,eAAe,EAAE,QAAQ,CAAA;KACzB;CACD"}
@@ -1,13 +1,14 @@
1
1
  import { __decorate } from "tslib";
2
2
  import { Component, component, css, html } from '@a11d/lit';
3
+ /** The element hosting the current page, rendered by the application. */
3
4
  let PageHost = class PageHost extends Component {
4
5
  static get styles() {
5
- return css `
6
- :host {
7
- display: grid;
8
- grid-template-rows: 1fr;
9
- width: 100%;
10
- }
6
+ return css `
7
+ :host {
8
+ display: grid;
9
+ grid-template-rows: 1fr;
10
+ width: 100%;
11
+ }
11
12
  `;
12
13
  }
13
14
  get template() {