@3mo/navigation 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/INavigation.d.ts +35 -0
- package/dist/INavigation.d.ts.map +1 -0
- package/dist/INavigation.js +2 -0
- package/dist/Navigation.d.ts +75 -0
- package/dist/Navigation.d.ts.map +1 -0
- package/dist/Navigation.js +304 -0
- package/dist/NavigationBar.d.ts +32 -0
- package/dist/NavigationBar.d.ts.map +1 -0
- package/dist/NavigationBar.js +90 -0
- package/dist/NavigationBarItem.d.ts +30 -0
- package/dist/NavigationBarItem.d.ts.map +1 -0
- package/dist/NavigationBarItem.js +108 -0
- package/dist/NavigationDrawer.d.ts +38 -0
- package/dist/NavigationDrawer.d.ts.map +1 -0
- package/dist/NavigationDrawer.js +89 -0
- package/dist/NavigationGroup.d.ts +22 -0
- package/dist/NavigationGroup.d.ts.map +1 -0
- package/dist/NavigationGroup.js +17 -0
- package/dist/NavigationLink.d.ts +24 -0
- package/dist/NavigationLink.d.ts.map +1 -0
- package/dist/NavigationLink.js +33 -0
- package/dist/NavigationPresentation.d.ts +8 -0
- package/dist/NavigationPresentation.d.ts.map +1 -0
- package/dist/NavigationPresentation.js +1 -0
- package/dist/NavigationRail.d.ts +52 -0
- package/dist/NavigationRail.d.ts.map +1 -0
- package/dist/NavigationRail.js +213 -0
- package/dist/NavigationRailItem.d.ts +28 -0
- package/dist/NavigationRailItem.d.ts.map +1 -0
- package/dist/NavigationRailItem.js +103 -0
- package/dist/NavigationTree.d.ts +33 -0
- package/dist/NavigationTree.d.ts.map +1 -0
- package/dist/NavigationTree.js +87 -0
- package/dist/NavigationTreeItem.d.ts +19 -0
- package/dist/NavigationTreeItem.d.ts.map +1 -0
- package/dist/NavigationTreeItem.js +115 -0
- package/dist/custom-elements.json +1208 -0
- package/dist/index.d.ts +21 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +20 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +49 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { Component, component, css, html, property } from '@a11d/lit';
|
|
3
|
+
/**
|
|
4
|
+
* A navigation of a navigation rail: an icon with its label beneath it.
|
|
5
|
+
*
|
|
6
|
+
* @element mo-navigation-rail-item
|
|
7
|
+
*
|
|
8
|
+
* @attr navigation - The navigation this item stands for.
|
|
9
|
+
* @attr data-current - Whether this navigation, or one nested in it, is the page being shown.
|
|
10
|
+
* @attr selected - Whether the rail is showing this navigation's destinations.
|
|
11
|
+
*
|
|
12
|
+
* @csspart indicator - The shape behind the icon, which marks the navigation the page belongs to.
|
|
13
|
+
* @csspart label - The label beneath the icon.
|
|
14
|
+
*/
|
|
15
|
+
let NavigationRailItem = class NavigationRailItem extends Component {
|
|
16
|
+
constructor() {
|
|
17
|
+
super(...arguments);
|
|
18
|
+
this.current = false;
|
|
19
|
+
this.selected = false;
|
|
20
|
+
this.tabIndex = 0;
|
|
21
|
+
}
|
|
22
|
+
static get styles() {
|
|
23
|
+
return css `
|
|
24
|
+
:host {
|
|
25
|
+
position: relative;
|
|
26
|
+
display: flex;
|
|
27
|
+
flex-direction: column;
|
|
28
|
+
align-items: center;
|
|
29
|
+
gap: 4px;
|
|
30
|
+
padding-block: 8px;
|
|
31
|
+
border-radius: var(--mo-border-radius);
|
|
32
|
+
color: var(--mo-color-foreground-transparent);
|
|
33
|
+
cursor: pointer;
|
|
34
|
+
outline: none;
|
|
35
|
+
-webkit-tap-highlight-color: transparent;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
:host([selected]) {
|
|
39
|
+
background: var(--mo-color-transparent-gray-1);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
:host([data-current]), :host([data-router-selected]) {
|
|
43
|
+
color: var(--mo-color-on-selected);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
[part=indicator] {
|
|
47
|
+
display: grid;
|
|
48
|
+
place-items: center;
|
|
49
|
+
inline-size: 56px;
|
|
50
|
+
block-size: 32px;
|
|
51
|
+
border-radius: 16px;
|
|
52
|
+
transition: background-color 0.2s ease;
|
|
53
|
+
|
|
54
|
+
mo-icon {
|
|
55
|
+
font-size: 24px;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
:host([data-current]) [part=indicator], :host([data-router-selected]) [part=indicator] {
|
|
60
|
+
background: var(--mo-color-selected);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
:host(:hover:not([data-current])) [part=indicator] {
|
|
64
|
+
background: var(--mo-color-transparent-gray-2);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
[part=label] {
|
|
68
|
+
font-size: 0.75rem;
|
|
69
|
+
line-height: 1.2;
|
|
70
|
+
font-weight: 500;
|
|
71
|
+
text-align: center;
|
|
72
|
+
max-inline-size: 100%;
|
|
73
|
+
padding-inline: 4px;
|
|
74
|
+
overflow: hidden;
|
|
75
|
+
display: -webkit-box;
|
|
76
|
+
-webkit-box-orient: vertical;
|
|
77
|
+
-webkit-line-clamp: 2;
|
|
78
|
+
}
|
|
79
|
+
`;
|
|
80
|
+
}
|
|
81
|
+
get template() {
|
|
82
|
+
return html `
|
|
83
|
+
<mo-focus-ring .control=${this} inward></mo-focus-ring>
|
|
84
|
+
<span part='indicator'>
|
|
85
|
+
${!this.navigation?.icon ? html.nothing : html `<mo-icon icon=${this.navigation.icon}></mo-icon>`}
|
|
86
|
+
</span>
|
|
87
|
+
<span part='label'>${this.navigation?.label}</span>
|
|
88
|
+
`;
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
__decorate([
|
|
92
|
+
property({ type: Object })
|
|
93
|
+
], NavigationRailItem.prototype, "navigation", void 0);
|
|
94
|
+
__decorate([
|
|
95
|
+
property({ type: Boolean, reflect: true, attribute: 'data-current' })
|
|
96
|
+
], NavigationRailItem.prototype, "current", void 0);
|
|
97
|
+
__decorate([
|
|
98
|
+
property({ type: Boolean, reflect: true })
|
|
99
|
+
], NavigationRailItem.prototype, "selected", void 0);
|
|
100
|
+
NavigationRailItem = __decorate([
|
|
101
|
+
component('mo-navigation-rail-item')
|
|
102
|
+
], NavigationRailItem);
|
|
103
|
+
export { NavigationRailItem };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Component, type HTMLTemplateResult } from '@a11d/lit';
|
|
2
|
+
import { type INavigation } from './INavigation.js';
|
|
3
|
+
import './NavigationTreeItem.js';
|
|
4
|
+
/**
|
|
5
|
+
* The navigations as a tree of rows: a group is a row which opens, a destination is a row which navigates.
|
|
6
|
+
* The row of the page being shown is revealed, so that a deep destination is on screen right away.
|
|
7
|
+
*
|
|
8
|
+
* @element mo-navigation-tree
|
|
9
|
+
*
|
|
10
|
+
* @attr navigations - The navigations to present.
|
|
11
|
+
* @fires invoke - Dispatched with the destination which was invoked.
|
|
12
|
+
*
|
|
13
|
+
* @csspart tree - The tree holding the rows.
|
|
14
|
+
* @csspart item - Every row of the tree.
|
|
15
|
+
*/
|
|
16
|
+
export declare class NavigationTree extends Component {
|
|
17
|
+
readonly invoke: EventDispatcher<INavigation>;
|
|
18
|
+
navigations: INavigation[];
|
|
19
|
+
private readonly treeElement?;
|
|
20
|
+
protected handleLocationChange(): void;
|
|
21
|
+
focus(options?: FocusOptions): void;
|
|
22
|
+
private revealedItem?;
|
|
23
|
+
protected updated(...parameters: Parameters<Component['updated']>): void;
|
|
24
|
+
static get styles(): import("@a11d/lit").CSSResult;
|
|
25
|
+
protected get template(): HTMLTemplateResult;
|
|
26
|
+
private itemTemplate;
|
|
27
|
+
}
|
|
28
|
+
declare global {
|
|
29
|
+
interface HTMLElementTagNameMap {
|
|
30
|
+
'mo-navigation-tree': NavigationTree;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=NavigationTree.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavigationTree.d.ts","sourceRoot":"","sources":["../NavigationTree.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAkF,KAAK,kBAAkB,EAAE,MAAM,WAAW,CAAA;AAE9I,OAAO,EAAsB,KAAK,WAAW,EAAE,MAAM,kBAAkB,CAAA;AACvE,OAAO,yBAAyB,CAAA;AAEhC;;;;;;;;;;;GAWG;AACH,qBACa,cAAe,SAAQ,SAAS;IACF,QAAQ,CAAC,MAAM,EAAG,eAAe,CAAC,WAAW,CAAC,CAAA;IAE7D,WAAW,gBAA2B;IAE/C,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAM;IAGrD,SAAS,CAAC,oBAAoB;IAIrB,KAAK,CAAC,OAAO,CAAC,EAAE,YAAY;IAQrC,OAAO,CAAC,YAAY,CAAC,CAAS;cAEX,OAAO,CAAC,GAAG,UAAU,EAAE,UAAU,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAS1E,WAAoB,MAAM,kCAUzB;IAED,cAAuB,QAAQ,uBAM9B;IAED,OAAO,CAAC,YAAY;CAYpB;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,oBAAoB,EAAE,cAAc,CAAA;KACpC;CACD"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { Component, component, css, event, eventListener, html, ifDefined, property, query, repeat } from '@a11d/lit';
|
|
3
|
+
import { visibleNavigations } from './INavigation.js';
|
|
4
|
+
import './NavigationTreeItem.js';
|
|
5
|
+
/**
|
|
6
|
+
* The navigations as a tree of rows: a group is a row which opens, a destination is a row which navigates.
|
|
7
|
+
* The row of the page being shown is revealed, so that a deep destination is on screen right away.
|
|
8
|
+
*
|
|
9
|
+
* @element mo-navigation-tree
|
|
10
|
+
*
|
|
11
|
+
* @attr navigations - The navigations to present.
|
|
12
|
+
* @fires invoke - Dispatched with the destination which was invoked.
|
|
13
|
+
*
|
|
14
|
+
* @csspart tree - The tree holding the rows.
|
|
15
|
+
* @csspart item - Every row of the tree.
|
|
16
|
+
*/
|
|
17
|
+
let NavigationTree = class NavigationTree extends Component {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this.navigations = new Array();
|
|
21
|
+
}
|
|
22
|
+
handleLocationChange() {
|
|
23
|
+
this.requestUpdate();
|
|
24
|
+
}
|
|
25
|
+
focus(options) {
|
|
26
|
+
if (this.treeElement) {
|
|
27
|
+
this.treeElement.focus(options);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
super.focus(options);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
updated(...parameters) {
|
|
34
|
+
super.updated(...parameters);
|
|
35
|
+
const current = this.treeElement?.querySelector('mo-navigation-tree-item[aria-current]') ?? undefined;
|
|
36
|
+
if (current && current !== this.revealedItem) {
|
|
37
|
+
this.revealedItem = current;
|
|
38
|
+
this.treeElement?.reveal(current);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
static get styles() {
|
|
42
|
+
return css `
|
|
43
|
+
:host {
|
|
44
|
+
display: block;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
mo-tree {
|
|
48
|
+
padding-block: 8px;
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
51
|
+
}
|
|
52
|
+
get template() {
|
|
53
|
+
return html `
|
|
54
|
+
<mo-tree part='tree'>
|
|
55
|
+
${repeat(visibleNavigations(this.navigations), navigation => navigation, navigation => this.itemTemplate(navigation))}
|
|
56
|
+
</mo-tree>
|
|
57
|
+
`;
|
|
58
|
+
}
|
|
59
|
+
itemTemplate(navigation, level = 0) {
|
|
60
|
+
const children = visibleNavigations(navigation.children);
|
|
61
|
+
return html `
|
|
62
|
+
<mo-navigation-tree-item part='item'
|
|
63
|
+
icon=${ifDefined(level === 0 ? navigation.icon : undefined)}
|
|
64
|
+
.current=${navigation.current === true}
|
|
65
|
+
aria-current=${ifDefined(navigation.current === true && children.length === 0 ? 'page' : undefined)}
|
|
66
|
+
?data-separator=${navigation.hasSeparator === true}
|
|
67
|
+
${navigation.link?.({ invocationHandler: () => this.invoke.dispatch(navigation) }) ?? html.nothing}
|
|
68
|
+
>${navigation.label}${children.map(child => this.itemTemplate(child, level + 1))}</mo-navigation-tree-item>
|
|
69
|
+
`;
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
__decorate([
|
|
73
|
+
event({ bubbles: true, composed: true })
|
|
74
|
+
], NavigationTree.prototype, "invoke", void 0);
|
|
75
|
+
__decorate([
|
|
76
|
+
property({ type: Array })
|
|
77
|
+
], NavigationTree.prototype, "navigations", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
query('mo-tree')
|
|
80
|
+
], NavigationTree.prototype, "treeElement", void 0);
|
|
81
|
+
__decorate([
|
|
82
|
+
eventListener({ target: window, type: 'popstate' })
|
|
83
|
+
], NavigationTree.prototype, "handleLocationChange", null);
|
|
84
|
+
NavigationTree = __decorate([
|
|
85
|
+
component('mo-navigation-tree')
|
|
86
|
+
], NavigationTree);
|
|
87
|
+
export { NavigationTree };
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { TreeItem } from '@3mo/tree';
|
|
2
|
+
/**
|
|
3
|
+
* A row of a navigation tree: a destination, or a group of them which opens.
|
|
4
|
+
*
|
|
5
|
+
* @element mo-navigation-tree-item
|
|
6
|
+
*
|
|
7
|
+
* @attr data-current - Whether this row, or a row nested in it, is the page being shown.
|
|
8
|
+
* @attr data-separator - Whether a divider parts this row from the one before it.
|
|
9
|
+
*/
|
|
10
|
+
export declare class NavigationTreeItem extends TreeItem {
|
|
11
|
+
current: boolean;
|
|
12
|
+
static get styles(): import("@a11d/lit").CSSResult;
|
|
13
|
+
}
|
|
14
|
+
declare global {
|
|
15
|
+
interface HTMLElementTagNameMap {
|
|
16
|
+
'mo-navigation-tree-item': NavigationTreeItem;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=NavigationTreeItem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NavigationTreeItem.d.ts","sourceRoot":"","sources":["../NavigationTreeItem.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAA;AAEpC;;;;;;;GAOG;AACH,qBACa,kBAAmB,SAAQ,QAAQ;IACwB,OAAO,UAAQ;IAEtF,WAAoB,MAAM,kCA0FzB;CACD;AAED,OAAO,CAAC,MAAM,CAAC;IACd,UAAU,qBAAqB;QAC9B,yBAAyB,EAAE,kBAAkB,CAAA;KAC7C;CACD"}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { __decorate } from "tslib";
|
|
2
|
+
import { component, css, property } from '@a11d/lit';
|
|
3
|
+
import { TreeItem } from '@3mo/tree';
|
|
4
|
+
/**
|
|
5
|
+
* A row of a navigation tree: a destination, or a group of them which opens.
|
|
6
|
+
*
|
|
7
|
+
* @element mo-navigation-tree-item
|
|
8
|
+
*
|
|
9
|
+
* @attr data-current - Whether this row, or a row nested in it, is the page being shown.
|
|
10
|
+
* @attr data-separator - Whether a divider parts this row from the one before it.
|
|
11
|
+
*/
|
|
12
|
+
let NavigationTreeItem = class NavigationTreeItem extends TreeItem {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(...arguments);
|
|
15
|
+
this.current = false;
|
|
16
|
+
}
|
|
17
|
+
static get styles() {
|
|
18
|
+
return css `
|
|
19
|
+
${super.styles}
|
|
20
|
+
|
|
21
|
+
[part=row] {
|
|
22
|
+
/* A child's label lines up under its parent's, the first step clearing the parent's icon. */
|
|
23
|
+
padding-inline: calc(12px + var(--mo-tree-level, 0) * 16px + min(var(--mo-tree-level, 0), 1) * 14px) 8px;
|
|
24
|
+
min-block-size: 28px;
|
|
25
|
+
margin: 1px 8px;
|
|
26
|
+
border-radius: var(--mo-border-radius);
|
|
27
|
+
font-size: 0.875rem;
|
|
28
|
+
line-height: 1.25;
|
|
29
|
+
/* The group draws one line for the whole nested block; the tree's own guides would be one per level. */
|
|
30
|
+
background-image: none;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
:host(:not([slot=children])) [part=row] {
|
|
34
|
+
min-block-size: 34px;
|
|
35
|
+
font-weight: 500;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
slot[name=start] mo-icon {
|
|
39
|
+
font-size: 20px;
|
|
40
|
+
opacity: 0.7;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@media not (any-pointer: fine) {
|
|
44
|
+
[part=row] {
|
|
45
|
+
min-block-size: 36px;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
:host(:not([slot=children])) [part=row] {
|
|
49
|
+
min-block-size: 40px;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/* A separator parts two sections, so it is a line with air around it rather than a border drawn
|
|
54
|
+
on the rounded block of the row below it — and it starts where the guide line of a nested
|
|
55
|
+
block runs, so that the two meet at a corner instead of crossing. */
|
|
56
|
+
:host([data-separator]) {
|
|
57
|
+
margin-block-start: 5px;
|
|
58
|
+
padding-block-start: 5px;
|
|
59
|
+
background-image: linear-gradient(var(--mo-color-transparent-gray-3) 0 0);
|
|
60
|
+
background-size: calc(100% - 30px) 1px;
|
|
61
|
+
background-position: 30px 0;
|
|
62
|
+
background-repeat: no-repeat;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
:host([data-separator]) [part=row] {
|
|
66
|
+
border-block-start: none;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
:host([data-current]) [part=row] {
|
|
70
|
+
color: var(--mo-color-on-selected);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
:host([aria-current]) [part=row] {
|
|
74
|
+
background-color: var(--mo-color-selected);
|
|
75
|
+
color: var(--mo-color-on-selected);
|
|
76
|
+
|
|
77
|
+
slot[name=start] mo-icon {
|
|
78
|
+
opacity: 1;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
[part=indicator] {
|
|
83
|
+
order: 1;
|
|
84
|
+
margin-inline-start: auto;
|
|
85
|
+
inline-size: 1.5rem;
|
|
86
|
+
block-size: 1.5rem;
|
|
87
|
+
|
|
88
|
+
mo-icon {
|
|
89
|
+
font-size: 18px;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/* A row with nothing to open keeps no room for the chevron it does not draw. */
|
|
94
|
+
:host(:not([aria-expanded])) [part=indicator] {
|
|
95
|
+
display: none;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/* One line for the whole nested block, drawn by the outermost group alone: a deeper one would lay
|
|
99
|
+
a second over it, and two of the same translucent grey read as a brighter stripe. */
|
|
100
|
+
:host(:not([slot=children])) [part=group] > div {
|
|
101
|
+
background-image: linear-gradient(var(--mo-color-transparent-gray-3) 0 0);
|
|
102
|
+
background-size: 1px 100%;
|
|
103
|
+
background-position: 30px 0;
|
|
104
|
+
background-repeat: no-repeat;
|
|
105
|
+
}
|
|
106
|
+
`;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
__decorate([
|
|
110
|
+
property({ type: Boolean, reflect: true, attribute: 'data-current' })
|
|
111
|
+
], NavigationTreeItem.prototype, "current", void 0);
|
|
112
|
+
NavigationTreeItem = __decorate([
|
|
113
|
+
component('mo-navigation-tree-item')
|
|
114
|
+
], NavigationTreeItem);
|
|
115
|
+
export { NavigationTreeItem };
|