@api-client/ui 0.5.31 → 0.5.33
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/build/src/core/renderer/ApplicationRenderer.d.ts +3 -2
- package/build/src/core/renderer/ApplicationRenderer.d.ts.map +1 -1
- package/build/src/core/renderer/ApplicationRenderer.js +24 -33
- package/build/src/core/renderer/ApplicationRenderer.js.map +1 -1
- package/build/src/core/renderer/FragmentRenderer.d.ts +2 -2
- package/build/src/core/renderer/FragmentRenderer.d.ts.map +1 -1
- package/build/src/core/renderer/FragmentRenderer.js +6 -16
- package/build/src/core/renderer/FragmentRenderer.js.map +1 -1
- package/build/src/core/renderer/Renderer.d.ts +38 -9
- package/build/src/core/renderer/Renderer.d.ts.map +1 -1
- package/build/src/core/renderer/Renderer.js +51 -8
- package/build/src/core/renderer/Renderer.js.map +1 -1
- package/build/src/elements/navigation/internals/Navigation.d.ts +68 -0
- package/build/src/elements/navigation/internals/Navigation.d.ts.map +1 -0
- package/build/src/elements/navigation/internals/Navigation.js +205 -0
- package/build/src/elements/navigation/internals/Navigation.js.map +1 -0
- package/build/src/elements/navigation/internals/Navigation.styles.d.ts +3 -0
- package/build/src/elements/navigation/internals/Navigation.styles.d.ts.map +1 -0
- package/build/src/elements/navigation/internals/Navigation.styles.js +24 -0
- package/build/src/elements/navigation/internals/Navigation.styles.js.map +1 -0
- package/build/src/elements/navigation/internals/NavigationItem.d.ts +57 -2
- package/build/src/elements/navigation/internals/NavigationItem.d.ts.map +1 -1
- package/build/src/elements/navigation/internals/NavigationItem.js +73 -18
- package/build/src/elements/navigation/internals/NavigationItem.js.map +1 -1
- package/build/src/elements/navigation/ui-navigation.d.ts +11 -0
- package/build/src/elements/navigation/ui-navigation.d.ts.map +1 -0
- package/build/src/elements/navigation/ui-navigation.js +27 -0
- package/build/src/elements/navigation/ui-navigation.js.map +1 -0
- package/build/src/md/input/Input.d.ts +2 -0
- package/build/src/md/input/Input.d.ts.map +1 -1
- package/build/src/types/aria.d.ts +28 -0
- package/build/src/types/aria.d.ts.map +1 -0
- package/build/src/types/aria.js +2 -0
- package/build/src/types/aria.js.map +1 -0
- package/build/src/types/role.d.ts +1 -16
- package/build/src/types/role.d.ts.map +1 -1
- package/build/src/types/role.js.map +1 -1
- package/build/test/elements/navigation/Navigation.test.d.ts +3 -0
- package/build/test/elements/navigation/Navigation.test.d.ts.map +1 -0
- package/build/test/elements/navigation/Navigation.test.js +113 -0
- package/build/test/elements/navigation/Navigation.test.js.map +1 -0
- package/demo/elements/index.html +2 -0
- package/demo/elements/navigation/navigation.html +20 -0
- package/demo/elements/navigation/navigation.ts +45 -0
- package/package.json +1 -1
- package/src/core/renderer/ApplicationRenderer.ts +28 -32
- package/src/core/renderer/FragmentRenderer.ts +6 -15
- package/src/core/renderer/Renderer.ts +60 -12
- package/src/elements/navigation/internals/Navigation.styles.ts +24 -0
- package/src/elements/navigation/internals/Navigation.ts +181 -0
- package/src/elements/navigation/internals/NavigationItem.ts +74 -5
- package/src/elements/navigation/ui-navigation.ts +15 -0
- package/src/types/aria.ts +141 -0
- package/src/types/role.ts +1 -129
- package/test/core/renderer.spec.ts +113 -0
- package/test/elements/navigation/Navigation.test.ts +120 -0
- package/tsconfig.json +1 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { Application } from '../Application.js';
|
|
2
2
|
import type { Activity } from '../Activity.js';
|
|
3
|
-
import { Renderer
|
|
3
|
+
import { Renderer } from './Renderer.js';
|
|
4
4
|
export declare class ApplicationRenderer extends Renderer {
|
|
5
5
|
protected app: Application;
|
|
6
6
|
renderedFirst: WeakMap<Application | Activity, boolean>;
|
|
7
7
|
constructor(app: Application);
|
|
8
|
-
|
|
8
|
+
private _handleFirstRender;
|
|
9
|
+
protected renderer(): void;
|
|
9
10
|
}
|
|
10
11
|
//# sourceMappingURL=ApplicationRenderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApplicationRenderer.d.ts","sourceRoot":"","sources":["../../../../src/core/renderer/ApplicationRenderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"ApplicationRenderer.d.ts","sourceRoot":"","sources":["../../../../src/core/renderer/ApplicationRenderer.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AACpD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAGxC,qBAAa,mBAAoB,SAAQ,QAAQ;IAGnC,SAAS,CAAC,GAAG,EAAE,WAAW;IAFtC,aAAa,EAAE,OAAO,CAAC,WAAW,GAAG,QAAQ,EAAE,OAAO,CAAC,CAAA;gBAEjC,GAAG,EAAE,WAAW;IAKtC,OAAO,CAAC,kBAAkB;IAU1B,SAAS,CAAC,QAAQ,IAAI,IAAI;CA4B3B"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Renderer, renderFn } from './Renderer.js';
|
|
1
|
+
import { Renderer } from './Renderer.js';
|
|
3
2
|
import { ModalActivity } from '../ModalActivity.js';
|
|
4
3
|
export class ApplicationRenderer extends Renderer {
|
|
5
4
|
app;
|
|
@@ -9,48 +8,40 @@ export class ApplicationRenderer extends Renderer {
|
|
|
9
8
|
this.app = app;
|
|
10
9
|
this.renderedFirst = new WeakMap();
|
|
11
10
|
}
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
const activity = app.manager.getTopActivity();
|
|
18
|
-
if (activity) {
|
|
19
|
-
host = activity;
|
|
20
|
-
if (activity.renderRoot) {
|
|
21
|
-
root = activity.renderRoot;
|
|
22
|
-
}
|
|
23
|
-
if (activity instanceof ModalActivity) {
|
|
24
|
-
content = activity.renderDialog();
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
content = activity.render();
|
|
11
|
+
_handleFirstRender(target, clearRoot, root) {
|
|
12
|
+
if (!this.renderedFirst.has(target)) {
|
|
13
|
+
this.renderedFirst.set(target, true);
|
|
14
|
+
if (clearRoot) {
|
|
15
|
+
this._clearRoot(root);
|
|
28
16
|
}
|
|
17
|
+
queueMicrotask(() => target.onFirstRender());
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
renderer() {
|
|
21
|
+
const { app, renderRoot: defaultRenderRoot } = this;
|
|
22
|
+
const activity = app.manager.getTopActivity();
|
|
23
|
+
const host = activity || app;
|
|
24
|
+
const root = activity?.renderRoot || defaultRenderRoot;
|
|
25
|
+
let content;
|
|
26
|
+
if (activity instanceof ModalActivity) {
|
|
27
|
+
content = activity.renderDialog();
|
|
29
28
|
}
|
|
30
29
|
else {
|
|
31
|
-
|
|
32
|
-
content = app.render();
|
|
30
|
+
content = host.render();
|
|
33
31
|
}
|
|
34
32
|
if (!root) {
|
|
35
33
|
// eslint-disable-next-line no-console
|
|
36
34
|
console.warn(`The "renderRoot" is not set up.`);
|
|
37
35
|
return;
|
|
38
36
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
setTimeout(() => app.onFirstRender());
|
|
43
|
-
}
|
|
44
|
-
// host might !== app
|
|
45
|
-
if (!this.renderedFirst.has(host)) {
|
|
46
|
-
setTimeout(() => host.onFirstRender());
|
|
37
|
+
this._handleFirstRender(app, true, root);
|
|
38
|
+
if (!this.firstRendered) {
|
|
39
|
+
this.firstRenderedFlag = true;
|
|
47
40
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
litPart._$litPart$.options.host = host;
|
|
41
|
+
if (host !== app) {
|
|
42
|
+
this._handleFirstRender(host, false, root);
|
|
51
43
|
}
|
|
52
|
-
|
|
53
|
-
this.resolveUpdatePromise();
|
|
44
|
+
this._render(content, root, host);
|
|
54
45
|
this.app.onRendered();
|
|
55
46
|
}
|
|
56
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApplicationRenderer.js","sourceRoot":"","sources":["../../../../src/core/renderer/ApplicationRenderer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ApplicationRenderer.js","sourceRoot":"","sources":["../../../../src/core/renderer/ApplicationRenderer.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAA;AAEnD,MAAM,OAAO,mBAAoB,SAAQ,QAAQ;IAGzB;IAFtB,aAAa,CAA0C;IAEvD,YAAsB,GAAgB;QACpC,KAAK,EAAE,CAAA;QADa,QAAG,GAAH,GAAG,CAAa;QAEpC,IAAI,CAAC,aAAa,GAAG,IAAI,OAAO,EAAE,CAAA;IACpC,CAAC;IAEO,kBAAkB,CAAC,MAA8B,EAAE,SAAkB,EAAE,IAAiB;QAC9F,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE,CAAC;YACpC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,CAAC,CAAA;YACpC,IAAI,SAAS,EAAE,CAAC;gBACd,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;YACvB,CAAC;YACD,cAAc,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,aAAa,EAAE,CAAC,CAAA;QAC9C,CAAC;IACH,CAAC;IAES,QAAQ;QAChB,MAAM,EAAE,GAAG,EAAE,UAAU,EAAE,iBAAiB,EAAE,GAAG,IAAI,CAAA;QACnD,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,cAAc,EAAE,CAAA;QAE7C,MAAM,IAAI,GAA2B,QAAQ,IAAI,GAAG,CAAA;QACpD,MAAM,IAAI,GAAuB,QAAQ,EAAE,UAAU,IAAI,iBAAiB,CAAA;QAE1E,IAAI,OAAwC,CAAA;QAC5C,IAAI,QAAQ,YAAY,aAAa,EAAE,CAAC;YACtC,OAAO,GAAG,QAAQ,CAAC,YAAY,EAAE,CAAA;QACnC,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,IAAI,CAAC,MAAM,EAAE,CAAA;QACzB,CAAC;QACD,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,sCAAsC;YACtC,OAAO,CAAC,IAAI,CAAC,iCAAiC,CAAC,CAAA;YAC/C,OAAM;QACR,CAAC;QACD,IAAI,CAAC,kBAAkB,CAAC,GAAG,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;QACxC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACxB,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAA;QAC/B,CAAC;QACD,IAAI,IAAI,KAAK,GAAG,EAAE,CAAC;YACjB,IAAI,CAAC,kBAAkB,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,CAAA;QAC5C,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;QACjC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,CAAA;IACvB,CAAC;CACF","sourcesContent":["import { nothing, type TemplateResult } from 'lit'\nimport type { Application } from '../Application.js'\nimport type { Activity } from '../Activity.js'\nimport { Renderer } from './Renderer.js'\nimport { ModalActivity } from '../ModalActivity.js'\n\nexport class ApplicationRenderer extends Renderer {\n renderedFirst: WeakMap<Application | Activity, boolean>\n\n constructor(protected app: Application) {\n super()\n this.renderedFirst = new WeakMap()\n }\n\n private _handleFirstRender(target: Application | Activity, clearRoot: boolean, root: HTMLElement): void {\n if (!this.renderedFirst.has(target)) {\n this.renderedFirst.set(target, true)\n if (clearRoot) {\n this._clearRoot(root)\n }\n queueMicrotask(() => target.onFirstRender())\n }\n }\n\n protected renderer(): void {\n const { app, renderRoot: defaultRenderRoot } = this\n const activity = app.manager.getTopActivity()\n\n const host: Application | Activity = activity || app\n const root: HTMLElement | null = activity?.renderRoot || defaultRenderRoot\n\n let content: TemplateResult | typeof nothing\n if (activity instanceof ModalActivity) {\n content = activity.renderDialog()\n } else {\n content = host.render()\n }\n if (!root) {\n // eslint-disable-next-line no-console\n console.warn(`The \"renderRoot\" is not set up.`)\n return\n }\n this._handleFirstRender(app, true, root)\n if (!this.firstRendered) {\n this.firstRenderedFlag = true\n }\n if (host !== app) {\n this._handleFirstRender(host, false, root)\n }\n this._render(content, root, host)\n this.app.onRendered()\n }\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { Fragment } from '../Fragment.js';
|
|
2
|
-
import { Renderer
|
|
2
|
+
import { Renderer } from './Renderer.js';
|
|
3
3
|
export declare class FragmentRenderer extends Renderer {
|
|
4
4
|
protected fragment: Fragment;
|
|
5
5
|
constructor(fragment: Fragment);
|
|
6
|
-
|
|
6
|
+
protected renderer(): void;
|
|
7
7
|
}
|
|
8
8
|
//# sourceMappingURL=FragmentRenderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FragmentRenderer.d.ts","sourceRoot":"","sources":["../../../../src/core/renderer/FragmentRenderer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FragmentRenderer.d.ts","sourceRoot":"","sources":["../../../../src/core/renderer/FragmentRenderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAC9C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,qBAAa,gBAAiB,SAAQ,QAAQ;IAChC,SAAS,CAAC,QAAQ,EAAE,QAAQ;gBAAlB,QAAQ,EAAE,QAAQ;IAIxC,SAAS,CAAC,QAAQ,IAAI,IAAI;CAe3B"}
|
|
@@ -1,34 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Renderer, renderFn } from './Renderer.js';
|
|
1
|
+
import { Renderer } from './Renderer.js';
|
|
3
2
|
export class FragmentRenderer extends Renderer {
|
|
4
3
|
fragment;
|
|
5
4
|
constructor(fragment) {
|
|
6
5
|
super();
|
|
7
6
|
this.fragment = fragment;
|
|
8
7
|
}
|
|
9
|
-
|
|
8
|
+
renderer() {
|
|
10
9
|
const root = this.renderRoot;
|
|
11
10
|
if (!root) {
|
|
12
11
|
// return quietly. Fragments can be rendered directly.
|
|
13
12
|
return;
|
|
14
13
|
}
|
|
15
|
-
const
|
|
16
|
-
const host = fragment.getSingleVisibleFragment() || fragment;
|
|
14
|
+
const host = this.fragment.getSingleVisibleFragment() ?? this.fragment;
|
|
17
15
|
if (!this.firstRendered) {
|
|
18
16
|
this.firstRenderedFlag = true;
|
|
19
17
|
// cleanup any pre-existing content.
|
|
20
|
-
|
|
21
|
-
|
|
18
|
+
this._clearRoot(root);
|
|
19
|
+
queueMicrotask(() => host.onFirstRender());
|
|
22
20
|
}
|
|
23
|
-
|
|
24
|
-
if (litPart._$litPart$) {
|
|
25
|
-
;
|
|
26
|
-
litPart._$litPart$.options.host = host;
|
|
27
|
-
}
|
|
28
|
-
// console.log(host, root)
|
|
29
|
-
render(host.render(), root, { host });
|
|
30
|
-
this.resolveUpdatePromise();
|
|
31
|
-
// this.app.onRendered()
|
|
21
|
+
this._render(host.render(), root, host);
|
|
32
22
|
}
|
|
33
23
|
}
|
|
34
24
|
//# sourceMappingURL=FragmentRenderer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FragmentRenderer.js","sourceRoot":"","sources":["../../../../src/core/renderer/FragmentRenderer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FragmentRenderer.js","sourceRoot":"","sources":["../../../../src/core/renderer/FragmentRenderer.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAExC,MAAM,OAAO,gBAAiB,SAAQ,QAAQ;IACtB;IAAtB,YAAsB,QAAkB;QACtC,KAAK,EAAE,CAAA;QADa,aAAQ,GAAR,QAAQ,CAAU;IAExC,CAAC;IAES,QAAQ;QAChB,MAAM,IAAI,GAAG,IAAI,CAAC,UAAU,CAAA;QAC5B,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,sDAAsD;YACtD,OAAM;QACR,CAAC;QACD,MAAM,IAAI,GAAG,IAAI,CAAC,QAAQ,CAAC,wBAAwB,EAAE,IAAI,IAAI,CAAC,QAAQ,CAAA;QACtE,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC;YACxB,IAAI,CAAC,iBAAiB,GAAG,IAAI,CAAA;YAC7B,oCAAoC;YACpC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAA;YACrB,cAAc,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE,CAAC,CAAA;QAC5C,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;IACzC,CAAC;CACF","sourcesContent":["import type { Fragment } from '../Fragment.js'\nimport { Renderer } from './Renderer.js'\n\nexport class FragmentRenderer extends Renderer {\n constructor(protected fragment: Fragment) {\n super()\n }\n\n protected renderer(): void {\n const root = this.renderRoot\n if (!root) {\n // return quietly. Fragments can be rendered directly.\n return\n }\n const host = this.fragment.getSingleVisibleFragment() ?? this.fragment\n if (!this.firstRendered) {\n this.firstRenderedFlag = true\n // cleanup any pre-existing content.\n this._clearRoot(root)\n queueMicrotask(() => host.onFirstRender())\n }\n this._render(host.render(), root, host)\n }\n}\n"]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { type TemplateResult, type nothing } from 'lit';
|
|
1
2
|
export declare enum RenderingState {
|
|
2
3
|
Idle = 0,
|
|
3
4
|
Rendering = 1
|
|
4
5
|
}
|
|
5
|
-
export declare const renderFn: unique symbol;
|
|
6
6
|
/**
|
|
7
7
|
* A class that manages rendering of the application screen.
|
|
8
8
|
*/
|
|
@@ -17,25 +17,54 @@ export declare abstract class Renderer {
|
|
|
17
17
|
*/
|
|
18
18
|
get updateComplete(): Promise<void> | undefined;
|
|
19
19
|
/**
|
|
20
|
-
* Sets the root element where the application will be rendered.
|
|
21
|
-
*
|
|
20
|
+
* Sets the root element where the application or activity will be rendered.
|
|
21
|
+
*
|
|
22
|
+
* @param renderRoot - The root element or a CSS selector string for the element.
|
|
23
|
+
* If a string is provided, it will be queried from the document.
|
|
22
24
|
*/
|
|
23
25
|
setRenderRoot(renderRoot: HTMLElement | string): void;
|
|
24
26
|
/**
|
|
25
|
-
* Requests an update of the
|
|
26
|
-
*
|
|
27
|
+
* Requests an update of the UI. Schedules a render if one is not already pending.
|
|
28
|
+
*
|
|
29
|
+
* This will call the `renderer()` method and update the DOM in the next animation frame.
|
|
30
|
+
* Ensures only one render is scheduled at a time.
|
|
27
31
|
*/
|
|
28
32
|
requestUpdate(): void;
|
|
29
33
|
protected firstRenderedFlag: boolean;
|
|
30
34
|
/**
|
|
31
|
-
*
|
|
32
|
-
* function was called.
|
|
35
|
+
* Indicates whether the initial render has occurred and `onFirstRender()` was called.
|
|
33
36
|
*/
|
|
34
37
|
get firstRendered(): boolean;
|
|
35
38
|
/**
|
|
36
|
-
*
|
|
39
|
+
* Returns the current rendering state.
|
|
40
|
+
*
|
|
41
|
+
* @returns The current rendering state.
|
|
42
|
+
*/
|
|
43
|
+
get state(): RenderingState;
|
|
44
|
+
/**
|
|
45
|
+
* Abstract method that must be implemented by subclasses to perform the actual rendering logic.
|
|
46
|
+
*
|
|
47
|
+
* Called by `requestUpdate()` when a render is scheduled.
|
|
48
|
+
*/
|
|
49
|
+
protected abstract renderer(): void;
|
|
50
|
+
/**
|
|
51
|
+
* Resolves the update promise if one is pending, indicating that rendering has finished.
|
|
37
52
|
*/
|
|
38
|
-
abstract [renderFn](): void;
|
|
39
53
|
protected resolveUpdatePromise(): void;
|
|
54
|
+
/**
|
|
55
|
+
* Renders the given Lit template into the specified root element, setting the host context.
|
|
56
|
+
*
|
|
57
|
+
* @param content - The Lit template or `nothing` to render.
|
|
58
|
+
* @param root - The root HTMLElement to render into.
|
|
59
|
+
* @param host - The host object for Lit's context (usually the Application or Activity).
|
|
60
|
+
*/
|
|
61
|
+
protected _render(content: TemplateResult | typeof nothing, root: HTMLElement, host: object): void;
|
|
62
|
+
/**
|
|
63
|
+
* Removes all child nodes from the given root element.
|
|
64
|
+
*
|
|
65
|
+
* Uses `replaceChildren()` for efficient DOM cleanup.
|
|
66
|
+
* @param root - The root HTMLElement to clear.
|
|
67
|
+
*/
|
|
68
|
+
protected _clearRoot(root: HTMLElement): void;
|
|
40
69
|
}
|
|
41
70
|
//# sourceMappingURL=Renderer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Renderer.d.ts","sourceRoot":"","sources":["../../../../src/core/renderer/Renderer.ts"],"names":[],"mappings":"AAAA,oBAAY,cAAc;IACxB,IAAI,IAAA;IACJ,SAAS,IAAA;CACV;AAED
|
|
1
|
+
{"version":3,"file":"Renderer.d.ts","sourceRoot":"","sources":["../../../../src/core/renderer/Renderer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAyB,KAAK,cAAc,EAAE,KAAK,OAAO,EAAE,MAAM,KAAK,CAAA;AAE9E,oBAAY,cAAc;IACxB,IAAI,IAAA;IACJ,SAAS,IAAA;CACV;AAED;;GAEG;AACH,8BAAsB,QAAQ;;IAC5B;;OAEG;IACH,UAAU,EAAE,WAAW,GAAG,IAAI,CAAO;IAErC;;OAEG;IACH,IAAI,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CAE9C;IAED;;;;;OAKG;IACH,aAAa,CAAC,UAAU,EAAE,WAAW,GAAG,MAAM,GAAG,IAAI;IAQrD;;;;;OAKG;IACH,aAAa,IAAI,IAAI;IAerB,SAAS,CAAC,iBAAiB,UAAQ;IAEnC;;OAEG;IACH,IAAI,aAAa,IAAI,OAAO,CAE3B;IAOD;;;;OAIG;IACH,IAAI,KAAK,IAAI,cAAc,CAE1B;IAiBD;;;;OAIG;IACH,SAAS,CAAC,QAAQ,CAAC,QAAQ,IAAI,IAAI;IAanC;;OAEG;IACH,SAAS,CAAC,oBAAoB,IAAI,IAAI;IAWtC;;;;;;OAMG;IACH,SAAS,CAAC,OAAO,CAAC,OAAO,EAAE,cAAc,GAAG,OAAO,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI;IASlG;;;;;OAKG;IACH,SAAS,CAAC,UAAU,CAAC,IAAI,EAAE,WAAW,GAAG,IAAI;CAI9C"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
+
import { render } from 'lit';
|
|
1
2
|
export var RenderingState;
|
|
2
3
|
(function (RenderingState) {
|
|
3
4
|
RenderingState[RenderingState["Idle"] = 0] = "Idle";
|
|
4
5
|
RenderingState[RenderingState["Rendering"] = 1] = "Rendering";
|
|
5
6
|
})(RenderingState || (RenderingState = {}));
|
|
6
|
-
export const renderFn = Symbol('renderFn');
|
|
7
7
|
/**
|
|
8
8
|
* A class that manages rendering of the application screen.
|
|
9
9
|
*/
|
|
@@ -19,8 +19,10 @@ export class Renderer {
|
|
|
19
19
|
return this.#updateComplete;
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
|
-
* Sets the root element where the application will be rendered.
|
|
23
|
-
*
|
|
22
|
+
* Sets the root element where the application or activity will be rendered.
|
|
23
|
+
*
|
|
24
|
+
* @param renderRoot - The root element or a CSS selector string for the element.
|
|
25
|
+
* If a string is provided, it will be queried from the document.
|
|
24
26
|
*/
|
|
25
27
|
setRenderRoot(renderRoot) {
|
|
26
28
|
if (typeof renderRoot === 'string') {
|
|
@@ -31,8 +33,10 @@ export class Renderer {
|
|
|
31
33
|
}
|
|
32
34
|
}
|
|
33
35
|
/**
|
|
34
|
-
* Requests an update of the
|
|
35
|
-
*
|
|
36
|
+
* Requests an update of the UI. Schedules a render if one is not already pending.
|
|
37
|
+
*
|
|
38
|
+
* This will call the `renderer()` method and update the DOM in the next animation frame.
|
|
39
|
+
* Ensures only one render is scheduled at a time.
|
|
36
40
|
*/
|
|
37
41
|
requestUpdate() {
|
|
38
42
|
if (this.#renderingState !== RenderingState.Idle) {
|
|
@@ -44,14 +48,13 @@ export class Renderer {
|
|
|
44
48
|
this.#setUpdatePromise();
|
|
45
49
|
}
|
|
46
50
|
requestAnimationFrame(() => {
|
|
47
|
-
this
|
|
51
|
+
this.renderer();
|
|
48
52
|
this.#renderingState = RenderingState.Idle;
|
|
49
53
|
});
|
|
50
54
|
}
|
|
51
55
|
firstRenderedFlag = false;
|
|
52
56
|
/**
|
|
53
|
-
*
|
|
54
|
-
* function was called.
|
|
57
|
+
* Indicates whether the initial render has occurred and `onFirstRender()` was called.
|
|
55
58
|
*/
|
|
56
59
|
get firstRendered() {
|
|
57
60
|
return this.firstRenderedFlag;
|
|
@@ -60,6 +63,14 @@ export class Renderer {
|
|
|
60
63
|
* A flag used to determine in which rendering state the UI is.
|
|
61
64
|
*/
|
|
62
65
|
#renderingState = RenderingState.Idle;
|
|
66
|
+
/**
|
|
67
|
+
* Returns the current rendering state.
|
|
68
|
+
*
|
|
69
|
+
* @returns The current rendering state.
|
|
70
|
+
*/
|
|
71
|
+
get state() {
|
|
72
|
+
return this.#renderingState;
|
|
73
|
+
}
|
|
63
74
|
/**
|
|
64
75
|
* A flag that helps to determine whether the `updateComplete` is setup.
|
|
65
76
|
*/
|
|
@@ -72,12 +83,19 @@ export class Renderer {
|
|
|
72
83
|
* The resolver to call when the update completes.
|
|
73
84
|
*/
|
|
74
85
|
#updateResolver;
|
|
86
|
+
/**
|
|
87
|
+
* Sets up the promise that will be resolved when the next render completes.
|
|
88
|
+
* Used for tracking asynchronous rendering.
|
|
89
|
+
*/
|
|
75
90
|
#setUpdatePromise() {
|
|
76
91
|
this.#updateComplete = new Promise((resolve) => {
|
|
77
92
|
this.#updateResolver = resolve;
|
|
78
93
|
this.#hasPendingUpdatePromise = true;
|
|
79
94
|
});
|
|
80
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Resolves the update promise if one is pending, indicating that rendering has finished.
|
|
98
|
+
*/
|
|
81
99
|
resolveUpdatePromise() {
|
|
82
100
|
if (!this.#hasPendingUpdatePromise) {
|
|
83
101
|
return;
|
|
@@ -88,5 +106,30 @@ export class Renderer {
|
|
|
88
106
|
resolver();
|
|
89
107
|
}
|
|
90
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* Renders the given Lit template into the specified root element, setting the host context.
|
|
111
|
+
*
|
|
112
|
+
* @param content - The Lit template or `nothing` to render.
|
|
113
|
+
* @param root - The root HTMLElement to render into.
|
|
114
|
+
* @param host - The host object for Lit's context (usually the Application or Activity).
|
|
115
|
+
*/
|
|
116
|
+
_render(content, root, host) {
|
|
117
|
+
const litPart = root;
|
|
118
|
+
if (litPart._$litPart$ && litPart._$litPart$.options) {
|
|
119
|
+
litPart._$litPart$.options.host = host;
|
|
120
|
+
}
|
|
121
|
+
render(content, root, { host });
|
|
122
|
+
this.resolveUpdatePromise();
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Removes all child nodes from the given root element.
|
|
126
|
+
*
|
|
127
|
+
* Uses `replaceChildren()` for efficient DOM cleanup.
|
|
128
|
+
* @param root - The root HTMLElement to clear.
|
|
129
|
+
*/
|
|
130
|
+
_clearRoot(root) {
|
|
131
|
+
// Using replaceChildren() is a modern and clean way to clear a node's children.
|
|
132
|
+
root.replaceChildren();
|
|
133
|
+
}
|
|
91
134
|
}
|
|
92
135
|
//# sourceMappingURL=Renderer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Renderer.js","sourceRoot":"","sources":["../../../../src/core/renderer/Renderer.ts"],"names":[],"mappings":"AAAA,MAAM,CAAN,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,mDAAI,CAAA;IACJ,6DAAS,CAAA;A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AAI,CAAC,eAAe,EAAE,CAAA;IACxB,CAAC;CACF","sourcesContent":["import { render, type RootPart, type TemplateResult, type nothing } from 'lit'\n\nexport enum RenderingState {\n Idle,\n Rendering,\n}\n\n/**\n * A class that manages rendering of the application screen.\n */\nexport abstract class Renderer {\n /**\n * The root element where the activity or fragment will be rendered.\n */\n renderRoot: HTMLElement | null = null\n\n /**\n * @type A promise resolved when the render finished.\n */\n get updateComplete(): Promise<void> | undefined {\n return this.#updateComplete\n }\n\n /**\n * Sets the root element where the application or activity will be rendered.\n *\n * @param renderRoot - The root element or a CSS selector string for the element.\n * If a string is provided, it will be queried from the document.\n */\n setRenderRoot(renderRoot: HTMLElement | string): void {\n if (typeof renderRoot === 'string') {\n this.renderRoot = document.querySelector<HTMLElement>(renderRoot)\n } else {\n this.renderRoot = renderRoot\n }\n }\n\n /**\n * Requests an update of the UI. Schedules a render if one is not already pending.\n *\n * This will call the `renderer()` method and update the DOM in the next animation frame.\n * Ensures only one render is scheduled at a time.\n */\n requestUpdate(): void {\n if (this.#renderingState !== RenderingState.Idle) {\n // An update is already scheduled.\n return\n }\n this.#renderingState = RenderingState.Rendering\n if (!this.#hasPendingUpdatePromise) {\n this.#setUpdatePromise()\n }\n requestAnimationFrame(() => {\n this.renderer()\n this.#renderingState = RenderingState.Idle\n })\n }\n\n protected firstRenderedFlag = false\n\n /**\n * Indicates whether the initial render has occurred and `onFirstRender()` was called.\n */\n get firstRendered(): boolean {\n return this.firstRenderedFlag\n }\n\n /**\n * A flag used to determine in which rendering state the UI is.\n */\n #renderingState = RenderingState.Idle\n\n /**\n * Returns the current rendering state.\n *\n * @returns The current rendering state.\n */\n get state(): RenderingState {\n return this.#renderingState\n }\n\n /**\n * A flag that helps to determine whether the `updateComplete` is setup.\n */\n #hasPendingUpdatePromise = false\n\n /**\n * A hidden value for the `updateComplete` getter.\n */\n #updateComplete?: Promise<void>\n\n /**\n * The resolver to call when the update completes.\n */\n #updateResolver?: () => void\n\n /**\n * Abstract method that must be implemented by subclasses to perform the actual rendering logic.\n *\n * Called by `requestUpdate()` when a render is scheduled.\n */\n protected abstract renderer(): void\n\n /**\n * Sets up the promise that will be resolved when the next render completes.\n * Used for tracking asynchronous rendering.\n */\n #setUpdatePromise(): void {\n this.#updateComplete = new Promise<void>((resolve) => {\n this.#updateResolver = resolve\n this.#hasPendingUpdatePromise = true\n })\n }\n\n /**\n * Resolves the update promise if one is pending, indicating that rendering has finished.\n */\n protected resolveUpdatePromise(): void {\n if (!this.#hasPendingUpdatePromise) {\n return\n }\n this.#hasPendingUpdatePromise = false\n const resolver = this.#updateResolver\n if (resolver) {\n resolver()\n }\n }\n\n /**\n * Renders the given Lit template into the specified root element, setting the host context.\n *\n * @param content - The Lit template or `nothing` to render.\n * @param root - The root HTMLElement to render into.\n * @param host - The host object for Lit's context (usually the Application or Activity).\n */\n protected _render(content: TemplateResult | typeof nothing, root: HTMLElement, host: object): void {\n const litPart = root as HTMLElement & { _$litPart$?: RootPart }\n if (litPart._$litPart$ && litPart._$litPart$.options) {\n litPart._$litPart$.options.host = host\n }\n render(content, root, { host })\n this.resolveUpdatePromise()\n }\n\n /**\n * Removes all child nodes from the given root element.\n *\n * Uses `replaceChildren()` for efficient DOM cleanup.\n * @param root - The root HTMLElement to clear.\n */\n protected _clearRoot(root: HTMLElement): void {\n // Using replaceChildren() is a modern and clean way to clear a node's children.\n root.replaceChildren()\n }\n}\n"]}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { LitElement, type TemplateResult } from 'lit';
|
|
2
|
+
import type NavigationItem from './NavigationItem.js';
|
|
3
|
+
import { AriaCurrent } from '../../../types/aria.js';
|
|
4
|
+
/**
|
|
5
|
+
* NavigationList
|
|
6
|
+
*
|
|
7
|
+
* A semantic, accessible navigation container for `ui-navigation-item` elements.
|
|
8
|
+
* Handles keyboard navigation (roving tabindex), focus management, and ARIA roles.
|
|
9
|
+
*
|
|
10
|
+
* ## Usage Example
|
|
11
|
+
*
|
|
12
|
+
* ```html
|
|
13
|
+
* <ui-navigation aria-label="Main navigation" current="page">
|
|
14
|
+
* <ui-navigation-item selected>
|
|
15
|
+
* <span slot="icon" aria-hidden="true">🏠</span>
|
|
16
|
+
* Home
|
|
17
|
+
* </ui-navigation-item>
|
|
18
|
+
* <ui-navigation-item>
|
|
19
|
+
* <span slot="icon" aria-hidden="true">🔍</span>
|
|
20
|
+
* Search
|
|
21
|
+
* </ui-navigation-item>
|
|
22
|
+
* <ui-navigation-item>
|
|
23
|
+
* <span slot="icon" aria-hidden="true">📁</span>
|
|
24
|
+
* Files
|
|
25
|
+
* </ui-navigation-item>
|
|
26
|
+
* <ui-navigation-item iconOnly disabled aria-disabled="true" tabindex="-1">
|
|
27
|
+
* <span slot="icon" aria-hidden="true">⚙️</span>
|
|
28
|
+
* </ui-navigation-item>
|
|
29
|
+
* </ui-navigation>
|
|
30
|
+
* ```
|
|
31
|
+
*
|
|
32
|
+
* @slot - Place `ui-navigation-item` elements as direct children.
|
|
33
|
+
* @fires select - Dispatched when an item is selected via click or keyboard.
|
|
34
|
+
* The `detail` object contains the selected `item`.
|
|
35
|
+
*/
|
|
36
|
+
export default class Navigation extends LitElement {
|
|
37
|
+
/**
|
|
38
|
+
* Orientation of the navigation: 'horizontal' or 'vertical'.
|
|
39
|
+
* @attribute
|
|
40
|
+
*/
|
|
41
|
+
accessor orientation: 'horizontal' | 'vertical';
|
|
42
|
+
/**
|
|
43
|
+
* The current item in the navigation, used for ARIA attributes.
|
|
44
|
+
* Can be 'page', 'step', 'location', 'date', 'time', 'true', 'false', or ''.
|
|
45
|
+
* @attribute
|
|
46
|
+
*/
|
|
47
|
+
accessor current: AriaCurrent;
|
|
48
|
+
/**
|
|
49
|
+
* Query all ui-navigation-item children
|
|
50
|
+
*/
|
|
51
|
+
accessor _items: NavigationItem[];
|
|
52
|
+
render(): TemplateResult;
|
|
53
|
+
constructor();
|
|
54
|
+
firstUpdated(): void;
|
|
55
|
+
private _onSlotChange;
|
|
56
|
+
/**
|
|
57
|
+
* Sets the initial `tabindex` for the items. The first selected item,
|
|
58
|
+
* or the first item if none are selected, receives `tabindex="0"`.
|
|
59
|
+
* All other items receive `tabindex="-1"`.
|
|
60
|
+
*/
|
|
61
|
+
private _setTabIndexes;
|
|
62
|
+
private _getEnabledItems;
|
|
63
|
+
private _onClick;
|
|
64
|
+
private _selectItem;
|
|
65
|
+
private _updateFocus;
|
|
66
|
+
private _onKeyDown;
|
|
67
|
+
}
|
|
68
|
+
//# sourceMappingURL=Navigation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Navigation.d.ts","sourceRoot":"","sources":["../../../../../src/elements/navigation/internals/Navigation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAQ,UAAU,EAAE,KAAK,cAAc,EAAE,MAAM,KAAK,CAAA;AAE3D,OAAO,KAAK,cAAc,MAAM,qBAAqB,CAAA;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAA;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,UAAU;IAChD;;;OAGG;IACwC,QAAQ,CAAC,WAAW,EAAE,YAAY,GAAG,UAAU,CAAa;IAEvG;;;;OAIG;IACwC,QAAQ,CAAC,OAAO,EAAE,WAAW,CAAK;IAE7E;;OAEG;IACuC,QAAQ,CAAC,MAAM,EAAG,cAAc,EAAE,CAAA;IAEnE,MAAM,IAAI,cAAc;;IAcxB,YAAY;IAIrB,OAAO,CAAC,aAAa,CAEpB;IAED;;;;OAIG;IACH,OAAO,CAAC,cAAc;IAatB,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,QAAQ,CAMf;IAED,OAAO,CAAC,WAAW;IA0BnB,OAAO,CAAC,YAAY;IAKpB,OAAO,CAAC,UAAU;CAyCnB"}
|