@oicl/openbridge-webcomponents-full-bundle 2.0.0-next.59 → 2.0.0-next.60
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/bundle/openbridge-webcomponents.bundle.js +5557 -4305
- package/bundle/openbridge-webcomponents.bundle.js.map +1 -1
- package/custom-elements.json +1204 -25
- package/dist/components/navigation-item/navigation-item.css.js +5 -0
- package/dist/components/navigation-item/navigation-item.css.js.map +1 -1
- package/dist/components/navigation-item/navigation-item.d.ts +18 -0
- package/dist/components/navigation-item/navigation-item.d.ts.map +1 -1
- package/dist/components/navigation-item/navigation-item.js +49 -1
- package/dist/components/navigation-item/navigation-item.js.map +1 -1
- package/dist/components/navigation-item-group/navigation-item-group.css.js +8 -0
- package/dist/components/navigation-item-group/navigation-item-group.css.js.map +1 -1
- package/dist/components/navigation-item-group/navigation-item-group.d.ts +22 -0
- package/dist/components/navigation-item-group/navigation-item-group.d.ts.map +1 -1
- package/dist/components/navigation-item-group/navigation-item-group.js +63 -1
- package/dist/components/navigation-item-group/navigation-item-group.js.map +1 -1
- package/dist/components/navigation-menu/navigation-menu.d.ts +29 -1
- package/dist/components/navigation-menu/navigation-menu.d.ts.map +1 -1
- package/dist/components/navigation-menu/navigation-menu.js +105 -0
- package/dist/components/navigation-menu/navigation-menu.js.map +1 -1
- package/dist/components/tree-navigation/tree-navigation.css.js +18 -0
- package/dist/components/tree-navigation/tree-navigation.css.js.map +1 -0
- package/dist/components/tree-navigation/tree-navigation.d.ts +74 -0
- package/dist/components/tree-navigation/tree-navigation.d.ts.map +1 -0
- package/dist/components/tree-navigation/tree-navigation.js +120 -0
- package/dist/components/tree-navigation/tree-navigation.js.map +1 -0
- package/dist/components/tree-navigation-group/tree-navigation-group.css.js +22 -0
- package/dist/components/tree-navigation-group/tree-navigation-group.css.js.map +1 -0
- package/dist/components/tree-navigation-group/tree-navigation-group.d.ts +94 -0
- package/dist/components/tree-navigation-group/tree-navigation-group.d.ts.map +1 -0
- package/dist/components/tree-navigation-group/tree-navigation-group.js +116 -0
- package/dist/components/tree-navigation-group/tree-navigation-group.js.map +1 -0
- package/dist/components/tree-navigation-item/tree-navigation-item.css.js +429 -0
- package/dist/components/tree-navigation-item/tree-navigation-item.css.js.map +1 -0
- package/dist/components/tree-navigation-item/tree-navigation-item.d.ts +160 -0
- package/dist/components/tree-navigation-item/tree-navigation-item.d.ts.map +1 -0
- package/dist/components/tree-navigation-item/tree-navigation-item.js +208 -0
- package/dist/components/tree-navigation-item/tree-navigation-item.js.map +1 -0
- package/dist/internal/tree-roving-navigator.d.ts +71 -0
- package/dist/internal/tree-roving-navigator.d.ts.map +1 -0
- package/dist/internal/tree-roving-navigator.js +172 -0
- package/dist/internal/tree-roving-navigator.js.map +1 -0
- package/package.json +1 -1
- package/src/components/navigation-item/navigation-item.css +5 -0
- package/src/components/navigation-item/navigation-item.ts +56 -1
- package/src/components/navigation-item-group/navigation-item-group.css +8 -0
- package/src/components/navigation-item-group/navigation-item-group.ts +71 -1
- package/src/components/navigation-menu/navigation-menu.stories.ts +54 -0
- package/src/components/navigation-menu/navigation-menu.ts +151 -0
- package/src/components/tree-navigation/tree-navigation.css +7 -0
- package/src/components/tree-navigation/tree-navigation.stories.ts +162 -0
- package/src/components/tree-navigation/tree-navigation.ts +188 -0
- package/src/components/tree-navigation-group/tree-navigation-group.css +11 -0
- package/src/components/tree-navigation-group/tree-navigation-group.ts +157 -0
- package/src/components/tree-navigation-item/tree-navigation-item.css +258 -0
- package/src/components/tree-navigation-item/tree-navigation-item.stories.ts +119 -0
- package/src/components/tree-navigation-item/tree-navigation-item.ts +307 -0
- package/src/internal/tree-roving-navigator.ts +231 -0
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
* {
|
|
2
|
+
box-sizing: border-box;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
:host {
|
|
6
|
+
display: block;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.wrapper {
|
|
10
|
+
display: flex;
|
|
11
|
+
align-items: center;
|
|
12
|
+
width: 100%;
|
|
13
|
+
height: var(--menu-navigation-components-tree-navigation-item-touch-target);
|
|
14
|
+
user-select: none;
|
|
15
|
+
|
|
16
|
+
@mixin outline-inward;
|
|
17
|
+
@mixin style style=flat visibleWrapperClass=.visible-wrapper;
|
|
18
|
+
@mixin font-body;
|
|
19
|
+
color: var(--on-flat-active-color);
|
|
20
|
+
|
|
21
|
+
.visible-wrapper {
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
width: 100%;
|
|
25
|
+
height: 100%;
|
|
26
|
+
border-radius: var(--global-border-radius-border-radius-base);
|
|
27
|
+
padding: 0
|
|
28
|
+
var(--menu-navigation-components-tree-navigation-item-padding-horizontal);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/*
|
|
32
|
+
* A checked row is not re-selectable, so it stays on the amplified enabled
|
|
33
|
+
* style with no hover/pressed feedback.
|
|
34
|
+
*/
|
|
35
|
+
&.checked {
|
|
36
|
+
@mixin style style=amplified visibleWrapperClass=.visible-wrapper;
|
|
37
|
+
cursor: default;
|
|
38
|
+
|
|
39
|
+
& .visible-wrapper,
|
|
40
|
+
&:hover .visible-wrapper,
|
|
41
|
+
&:active .visible-wrapper {
|
|
42
|
+
background-color: var(--amplified-enabled-background-color);
|
|
43
|
+
border-color: var(--amplified-enabled-border-color);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
& .label {
|
|
47
|
+
@mixin font-body-active;
|
|
48
|
+
color: var(--on-flat-active-color);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
& .leading-icon {
|
|
52
|
+
color: var(--on-amplified-active-color);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/* Guide lines are tree structure, not row state, so they do not dim here. */
|
|
57
|
+
&.disabled {
|
|
58
|
+
color: var(--on-flat-disabled-color);
|
|
59
|
+
|
|
60
|
+
& .leading-icon {
|
|
61
|
+
color: var(--on-flat-disabled-color);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
.tree-node-row {
|
|
67
|
+
display: flex;
|
|
68
|
+
align-items: center;
|
|
69
|
+
height: 100%;
|
|
70
|
+
flex-shrink: 0;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.branch {
|
|
74
|
+
position: relative;
|
|
75
|
+
height: 100%;
|
|
76
|
+
width: var(--menu-navigation-components-branch-width);
|
|
77
|
+
flex-shrink: 0;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/*
|
|
81
|
+
* Guide lines all run on a rail at 75% of each 32px column and share the faint
|
|
82
|
+
* outline color. Verticals and the dropdown bleed 1px past the row edges so they
|
|
83
|
+
* cross the visible-wrapper's 1px transparent flat border and meet the adjacent
|
|
84
|
+
* row's line with no seam gap.
|
|
85
|
+
*/
|
|
86
|
+
.branch-vertical {
|
|
87
|
+
position: absolute;
|
|
88
|
+
top: -1px;
|
|
89
|
+
bottom: -1px;
|
|
90
|
+
left: 75%;
|
|
91
|
+
width: 1px;
|
|
92
|
+
transform: translateX(-0.5px);
|
|
93
|
+
background: var(--border-outline-color);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.branch-horizontal {
|
|
97
|
+
position: absolute;
|
|
98
|
+
top: 50%;
|
|
99
|
+
transform: translateY(-0.5px);
|
|
100
|
+
left: 75%;
|
|
101
|
+
right: 0;
|
|
102
|
+
height: 1px;
|
|
103
|
+
background: var(--border-outline-color);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/*
|
|
107
|
+
* Corner (└, last child): a single bordered box replaces the straight rects so
|
|
108
|
+
* the bend can be rounded. The box bleeds 1px past the column's right edge so its
|
|
109
|
+
* bottom border overlaps the terminal connector with no break, and translateY
|
|
110
|
+
* drops it 0.5px so that border lands on the connector's pixel row (else the join
|
|
111
|
+
* reads as a `---___` step). The radius stays tight — the stub is only 8px, so a
|
|
112
|
+
* larger fillet would consume the whole flat run.
|
|
113
|
+
*/
|
|
114
|
+
.branch-corner .branch-vertical,
|
|
115
|
+
.branch-corner .branch-horizontal {
|
|
116
|
+
display: none;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
.branch-corner .branch-elbow {
|
|
120
|
+
position: absolute;
|
|
121
|
+
top: -1px;
|
|
122
|
+
bottom: 50%;
|
|
123
|
+
left: 75%;
|
|
124
|
+
right: -1px;
|
|
125
|
+
transform: translate(-0.5px, 0.5px);
|
|
126
|
+
border-left: 1px solid var(--border-outline-color);
|
|
127
|
+
border-bottom: 1px solid var(--border-outline-color);
|
|
128
|
+
border-bottom-left-radius: var(
|
|
129
|
+
--menu-navigation-components-branch-corner-radius,
|
|
130
|
+
2px
|
|
131
|
+
);
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
.terminal {
|
|
135
|
+
position: relative;
|
|
136
|
+
height: 100%;
|
|
137
|
+
width: var(--global-size-spacing-touch-target-min);
|
|
138
|
+
flex-shrink: 0;
|
|
139
|
+
display: flex;
|
|
140
|
+
align-items: center;
|
|
141
|
+
justify-content: center;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/* Stub entering the terminal, continuing the guide line up to the chevron gap. */
|
|
145
|
+
.terminal-connector {
|
|
146
|
+
position: absolute;
|
|
147
|
+
top: 50%;
|
|
148
|
+
transform: translateY(-0.5px);
|
|
149
|
+
left: 0;
|
|
150
|
+
width: 25%;
|
|
151
|
+
height: 1px;
|
|
152
|
+
background: var(--border-outline-color);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/* On a leaf (no chevron) the stub runs further, stopping ~13px before the icon. */
|
|
156
|
+
.terminal:not(:has(.chevron)) .terminal-connector {
|
|
157
|
+
width: calc(100% - 13px);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/* Descends from below the chevron to connect an expanded node to its children. */
|
|
161
|
+
.terminal-dropdown {
|
|
162
|
+
position: absolute;
|
|
163
|
+
left: 50%;
|
|
164
|
+
transform: translateX(-0.5px);
|
|
165
|
+
top: 75%;
|
|
166
|
+
bottom: -1px;
|
|
167
|
+
width: 1px;
|
|
168
|
+
background: var(--border-outline-color);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/* Visual expand/collapse indicator only — not a separate control. */
|
|
172
|
+
.chevron {
|
|
173
|
+
position: relative;
|
|
174
|
+
display: flex;
|
|
175
|
+
align-items: center;
|
|
176
|
+
justify-content: center;
|
|
177
|
+
width: var(--menu-navigation-components-tree-navigation-item-icon-size);
|
|
178
|
+
height: var(--menu-navigation-components-tree-navigation-item-icon-size);
|
|
179
|
+
color: var(--element-neutral-color);
|
|
180
|
+
transition: transform 100ms ease-in-out;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
@media (prefers-reduced-motion: reduce) {
|
|
184
|
+
.chevron {
|
|
185
|
+
transition: none;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
.wrapper.disabled .chevron {
|
|
190
|
+
color: var(--on-flat-disabled-color);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
:host([expanded]) .chevron {
|
|
194
|
+
transform: rotate(90deg);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/* Alert-header marker for non-regular terminal types, at the terminal's top-right. */
|
|
198
|
+
.terminal-header {
|
|
199
|
+
position: absolute;
|
|
200
|
+
inset: 0;
|
|
201
|
+
display: flex;
|
|
202
|
+
justify-content: flex-end;
|
|
203
|
+
align-items: flex-start;
|
|
204
|
+
padding: var(--menu-navigation-components-terminal-padding-aggregated-icon);
|
|
205
|
+
color: var(--element-neutral-color);
|
|
206
|
+
pointer-events: none;
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
.terminal-header > * {
|
|
210
|
+
width: var(--menu-navigation-components-tree-navigation-item-icon-size);
|
|
211
|
+
height: var(--menu-navigation-components-tree-navigation-item-icon-size);
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.wrapper.disabled .terminal-header {
|
|
215
|
+
color: var(--on-flat-disabled-color);
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
.label-container {
|
|
219
|
+
display: flex;
|
|
220
|
+
flex: 1;
|
|
221
|
+
gap: var(
|
|
222
|
+
--menu-navigation-components-tree-navigation-item-padding-horizontal
|
|
223
|
+
);
|
|
224
|
+
align-items: center;
|
|
225
|
+
min-width: 0;
|
|
226
|
+
padding-right: var(
|
|
227
|
+
--menu-navigation-components-tree-navigation-item-padding-horizontal
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.leading-icon {
|
|
232
|
+
position: relative;
|
|
233
|
+
flex-shrink: 0;
|
|
234
|
+
display: flex;
|
|
235
|
+
align-items: center;
|
|
236
|
+
justify-content: center;
|
|
237
|
+
width: var(--menu-navigation-components-tree-navigation-item-icon-size);
|
|
238
|
+
height: var(--menu-navigation-components-tree-navigation-item-icon-size);
|
|
239
|
+
color: var(--on-flat-neutral-color);
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
::slotted([slot="icon"]) {
|
|
243
|
+
display: block;
|
|
244
|
+
width: var(--menu-navigation-components-tree-navigation-item-icon-size);
|
|
245
|
+
height: var(--menu-navigation-components-tree-navigation-item-icon-size);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.label {
|
|
249
|
+
flex: 1;
|
|
250
|
+
overflow: hidden;
|
|
251
|
+
text-overflow: ellipsis;
|
|
252
|
+
white-space: nowrap;
|
|
253
|
+
min-width: 0;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
.alert-badge {
|
|
257
|
+
flex-shrink: 0;
|
|
258
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type {Meta, StoryObj} from '@storybook/web-components-vite';
|
|
2
|
+
import {
|
|
3
|
+
ObcTreeNavigationItem,
|
|
4
|
+
TreeBranchType,
|
|
5
|
+
TreeTerminalType,
|
|
6
|
+
} from './tree-navigation-item.js';
|
|
7
|
+
import './tree-navigation-item.js';
|
|
8
|
+
import {iconIds, iconIdToIconHtml} from '../../storybook-util.js';
|
|
9
|
+
import {html} from 'lit';
|
|
10
|
+
import {BadgeType} from '../badge/badge.js';
|
|
11
|
+
|
|
12
|
+
const meta: Meta<typeof ObcTreeNavigationItem> = {
|
|
13
|
+
title: 'UI Components/Menus and Navigation/Tree Navigation Item',
|
|
14
|
+
tags: ['autodocs', '6.0'],
|
|
15
|
+
component: 'obc-tree-navigation-item',
|
|
16
|
+
args: {
|
|
17
|
+
label: 'List item',
|
|
18
|
+
icon: 'placeholder',
|
|
19
|
+
branches: [TreeBranchType.straight, TreeBranchType.intersection],
|
|
20
|
+
expandable: true,
|
|
21
|
+
expanded: false,
|
|
22
|
+
checked: false,
|
|
23
|
+
disabled: false,
|
|
24
|
+
hasLeadingIcon: true,
|
|
25
|
+
terminalType: TreeTerminalType.regular,
|
|
26
|
+
hasAlertBadge: false,
|
|
27
|
+
alertCount: 9,
|
|
28
|
+
alertType: BadgeType.alarm,
|
|
29
|
+
},
|
|
30
|
+
argTypes: {
|
|
31
|
+
icon: {
|
|
32
|
+
options: iconIds,
|
|
33
|
+
control: {type: 'select'},
|
|
34
|
+
},
|
|
35
|
+
label: {control: {type: 'text'}},
|
|
36
|
+
branches: {control: {type: 'object'}},
|
|
37
|
+
expandable: {control: {type: 'boolean'}},
|
|
38
|
+
expanded: {control: {type: 'boolean'}},
|
|
39
|
+
checked: {control: {type: 'boolean'}},
|
|
40
|
+
disabled: {control: {type: 'boolean'}},
|
|
41
|
+
hasLeadingIcon: {control: {type: 'boolean'}},
|
|
42
|
+
terminalType: {
|
|
43
|
+
control: {type: 'select'},
|
|
44
|
+
options: Object.values(TreeTerminalType),
|
|
45
|
+
},
|
|
46
|
+
hasAlertBadge: {control: {type: 'boolean'}},
|
|
47
|
+
alertCount: {control: {type: 'number'}},
|
|
48
|
+
alertType: {
|
|
49
|
+
control: {type: 'select'},
|
|
50
|
+
options: Object.values(BadgeType),
|
|
51
|
+
if: {arg: 'hasAlertBadge'},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
render: (args) => {
|
|
55
|
+
return html`<obc-tree-navigation-item
|
|
56
|
+
.label=${args.label}
|
|
57
|
+
.branches=${args.branches}
|
|
58
|
+
?expandable=${args.expandable}
|
|
59
|
+
?expanded=${args.expanded}
|
|
60
|
+
?checked=${args.checked}
|
|
61
|
+
?disabled=${args.disabled}
|
|
62
|
+
.hasLeadingIcon=${args.hasLeadingIcon}
|
|
63
|
+
.terminalType=${args.terminalType}
|
|
64
|
+
.hasAlertBadge=${args.hasAlertBadge}
|
|
65
|
+
.alertCount=${args.alertCount}
|
|
66
|
+
.alertType=${args.alertType}
|
|
67
|
+
@expand-toggle=${(e: CustomEvent<boolean>) => {
|
|
68
|
+
(e.currentTarget as ObcTreeNavigationItem).expanded = e.detail;
|
|
69
|
+
}}
|
|
70
|
+
>
|
|
71
|
+
${args.hasLeadingIcon && args.icon
|
|
72
|
+
? iconIdToIconHtml(args.icon as unknown as string, {slot: 'icon'})
|
|
73
|
+
: ''}
|
|
74
|
+
</obc-tree-navigation-item>`;
|
|
75
|
+
},
|
|
76
|
+
} satisfies Meta<ObcTreeNavigationItem>;
|
|
77
|
+
|
|
78
|
+
export default meta;
|
|
79
|
+
type Story = StoryObj<ObcTreeNavigationItem>;
|
|
80
|
+
|
|
81
|
+
export const Default: Story = {
|
|
82
|
+
args: {},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export const Checked: Story = {
|
|
86
|
+
args: {checked: true, expandable: false},
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
export const Expanded: Story = {
|
|
90
|
+
args: {expanded: true},
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export const Disabled: Story = {
|
|
94
|
+
args: {disabled: true},
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export const Leaf: Story = {
|
|
98
|
+
args: {expandable: false},
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const Root: Story = {
|
|
102
|
+
args: {branches: []},
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export const IndentedNoConnectors: Story = {
|
|
106
|
+
args: {branches: [TreeBranchType.blank, TreeBranchType.blank]},
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export const WithAlertBadge: Story = {
|
|
110
|
+
args: {hasAlertBadge: true, alertCount: 9},
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export const AggregatedHeader: Story = {
|
|
114
|
+
args: {terminalType: TreeTerminalType.aggregatedHeader},
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
export const GroupHeader: Story = {
|
|
118
|
+
args: {terminalType: TreeTerminalType.groupHeader},
|
|
119
|
+
};
|
|
@@ -0,0 +1,307 @@
|
|
|
1
|
+
import {LitElement, html, nothing, unsafeCSS} from 'lit';
|
|
2
|
+
import {property, query} from 'lit/decorators.js';
|
|
3
|
+
import componentStyle from './tree-navigation-item.css?inline';
|
|
4
|
+
import {classMap} from 'lit/directives/class-map.js';
|
|
5
|
+
import {ifDefined} from 'lit/directives/if-defined.js';
|
|
6
|
+
import {customElement} from '../../decorator.js';
|
|
7
|
+
import '../../icons/icon-chevron-right-google.js';
|
|
8
|
+
import '../../icons/icon-alert-header-aggregated-iec.js';
|
|
9
|
+
import '../../icons/icon-alert-header-group-iec.js';
|
|
10
|
+
import '../badge/badge.js';
|
|
11
|
+
import {BadgeType} from '../badge/badge.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Guide line drawn for one indentation column. Normally computed by
|
|
15
|
+
* `obc-tree-navigation`; rarely set by hand.
|
|
16
|
+
*
|
|
17
|
+
* - `straight`: vertical pass-through (`│`)
|
|
18
|
+
* - `intersection`: vertical + stub for a non-last child (`├`)
|
|
19
|
+
* - `corner`: half vertical + stub for the last child (`└`)
|
|
20
|
+
* - `blank`: empty spacer
|
|
21
|
+
*/
|
|
22
|
+
export enum TreeBranchType {
|
|
23
|
+
straight = 'straight',
|
|
24
|
+
intersection = 'intersection',
|
|
25
|
+
corner = 'corner',
|
|
26
|
+
blank = 'blank',
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Terminal type for a tree item, controlling the alert-header marker shown in
|
|
31
|
+
* the terminal (top-right, by the chevron).
|
|
32
|
+
*
|
|
33
|
+
* - `regular`: No marker — a plain expand/collapse terminal.
|
|
34
|
+
* - `aggregatedHeader`: Shows the aggregated alert-header marker, indicating the
|
|
35
|
+
* node aggregates alerts from its descendants.
|
|
36
|
+
* - `groupHeader`: Shows the group alert-header marker, indicating a grouped set
|
|
37
|
+
* of alerts beneath the node.
|
|
38
|
+
*/
|
|
39
|
+
export enum TreeTerminalType {
|
|
40
|
+
regular = 'regular',
|
|
41
|
+
aggregatedHeader = 'aggregated-header',
|
|
42
|
+
groupHeader = 'group-header',
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* `<obc-tree-navigation-item>` – A single row in a tree- or file-explorer-style
|
|
47
|
+
* navigation list, with indentation guide lines, an optional expand/collapse
|
|
48
|
+
* chevron, a leading icon, a label, and an optional alert badge.
|
|
49
|
+
*
|
|
50
|
+
* Each row represents one node in a hierarchy. Depth is expressed through the
|
|
51
|
+
* `branches` array: one entry per ancestor level, each describing the guide line
|
|
52
|
+
* to draw for that level. The expand chevron lets a node disclose its children,
|
|
53
|
+
* emitting `expand-toggle` so a parent can manage the open/closed state.
|
|
54
|
+
*
|
|
55
|
+
* ## Features
|
|
56
|
+
* - **Indentation guides:** Render one 32px guide column per `branches` entry —
|
|
57
|
+
* pass-through vertical lines for ancestors that continue, and an elbow
|
|
58
|
+
* (`intersection`) connecting the row to its parent.
|
|
59
|
+
* - **Expand/collapse:** Set `expandable` to show a chevron that rotates when
|
|
60
|
+
* `expanded`. The chevron is a visual indicator only — activating the row
|
|
61
|
+
* fires `expand-toggle` with the next state; manage `expanded` in response.
|
|
62
|
+
* When `expanded`, a vertical guide descends from the chevron to connect to
|
|
63
|
+
* the revealed child rows below.
|
|
64
|
+
* - **Terminal type:** `terminalType` adds an alert-header marker in the terminal
|
|
65
|
+
* (`aggregatedHeader` or `groupHeader`), indicating the node heads a set of
|
|
66
|
+
* aggregated or grouped alerts.
|
|
67
|
+
* - **Leading icon:** Provide an icon via the `icon` slot (shown when
|
|
68
|
+
* `hasLeadingIcon`).
|
|
69
|
+
* - **Alert badge:** A trailing counter badge (e.g. an alarm count), toggled with
|
|
70
|
+
* `hasAlertBadge` and configured via `alertCount` and `alertType`.
|
|
71
|
+
* - **Checked state:** `checked` highlights the current selection using the
|
|
72
|
+
* amplified elevation style. A checked row is the current item and is not
|
|
73
|
+
* re-selectable — it shows no hover/pressed feedback and fires no `click` or
|
|
74
|
+
* navigation. An expandable checked row still toggles (fires `expand-toggle`),
|
|
75
|
+
* so a group that is the current selection can be opened and closed. It stays
|
|
76
|
+
* keyboard-focusable.
|
|
77
|
+
* - **Link or button:** Set `href` to render the row as a link; otherwise it acts
|
|
78
|
+
* as a button.
|
|
79
|
+
*
|
|
80
|
+
* ## Usage Guidelines
|
|
81
|
+
* - Use for hierarchical navigation such as file trees, layer panels, or nested
|
|
82
|
+
* menus. For flat navigation lists, use `obc-navigation-item` instead.
|
|
83
|
+
* - Build `branches` from the row's ancestry: `intersection` for the level that
|
|
84
|
+
* owns this row, `straight` for ancestors with siblings still to come, and
|
|
85
|
+
* `blank` for ancestors whose subtrees have ended. When placed inside
|
|
86
|
+
* `obc-tree-navigation`, the container computes `branches` automatically.
|
|
87
|
+
* - Keep one row `checked` at a time within a tree to mark the current location.
|
|
88
|
+
* - Leaf nodes should leave `expandable` as `false` so no chevron is shown.
|
|
89
|
+
*
|
|
90
|
+
* ## Slots
|
|
91
|
+
*
|
|
92
|
+
* | Slot Name | Renders When... | Purpose |
|
|
93
|
+
* |----------------|---------------------------------|-------------------------------------------------------------------------|
|
|
94
|
+
* | icon | `hasLeadingIcon` is true | Leading icon for the row, e.g. `<obi-placeholder slot="icon">`. |
|
|
95
|
+
*
|
|
96
|
+
* @slot icon - Leading icon slot (shown when `hasLeadingIcon` is true).
|
|
97
|
+
* @fires expand-toggle {CustomEvent<boolean>} Fired when an expandable row is activated; detail is the next `expanded` value.
|
|
98
|
+
* @fires click {CustomEvent<void>} Fired when the row is activated.
|
|
99
|
+
*/
|
|
100
|
+
@customElement('obc-tree-navigation-item')
|
|
101
|
+
export class ObcTreeNavigationItem extends LitElement {
|
|
102
|
+
/** The text label displayed for the row. */
|
|
103
|
+
@property({type: String}) label = 'List item';
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Guide line for each ancestor level, outermost first; one 32px column per
|
|
107
|
+
* entry. Computed by `obc-tree-navigation` — rarely set by hand.
|
|
108
|
+
*/
|
|
109
|
+
@property({type: Array}) branches: TreeBranchType[] = [];
|
|
110
|
+
|
|
111
|
+
/** Whether the row shows an expand/collapse chevron. Leave false for leaf nodes. */
|
|
112
|
+
@property({type: Boolean}) expandable = false;
|
|
113
|
+
|
|
114
|
+
/** Whether the node is expanded. Rotates the chevron and sets `aria-expanded`. */
|
|
115
|
+
@property({type: Boolean, reflect: true}) expanded = false;
|
|
116
|
+
|
|
117
|
+
/**
|
|
118
|
+
* Whether the row is the current selection. Applies the amplified style and
|
|
119
|
+
* makes the row inert to re-selection (no hover/pressed feedback, no `click`
|
|
120
|
+
* or navigation); it remains keyboard-focusable. An expandable checked row
|
|
121
|
+
* still fires `expand-toggle` so a selected group can open and close.
|
|
122
|
+
*/
|
|
123
|
+
@property({type: Boolean, reflect: true}) checked = false;
|
|
124
|
+
|
|
125
|
+
/** Disables the row, removing it from the tab order and dimming its appearance. */
|
|
126
|
+
@property({type: Boolean, reflect: true}) disabled = false;
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Whether the row is in the tab order. A tree container manages this as a
|
|
130
|
+
* roving tabindex (one row focusable at a time); standalone rows stay tabbable.
|
|
131
|
+
*/
|
|
132
|
+
@property({type: Boolean, attribute: false}) focusable = true;
|
|
133
|
+
|
|
134
|
+
/**
|
|
135
|
+
* Whether the row shows a leading icon (provided via the `icon` slot).
|
|
136
|
+
*/
|
|
137
|
+
@property({type: Boolean, attribute: false}) hasLeadingIcon = true;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* Terminal type, controlling the alert-header marker shown in the terminal.
|
|
141
|
+
* One of `regular` (default), `aggregated-header`, or `group-header`.
|
|
142
|
+
*/
|
|
143
|
+
@property({type: String}) terminalType: string = TreeTerminalType.regular;
|
|
144
|
+
|
|
145
|
+
/** Whether a trailing alert counter badge is shown. */
|
|
146
|
+
@property({type: Boolean}) hasAlertBadge = false;
|
|
147
|
+
|
|
148
|
+
/** The number shown in the alert badge when `hasAlertBadge` is true. */
|
|
149
|
+
@property({type: Number}) alertCount = 0;
|
|
150
|
+
|
|
151
|
+
/** The severity/type of the alert badge. One of the `obc-badge` types (default `alarm`). */
|
|
152
|
+
@property({type: String}) alertType: string = BadgeType.alarm;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* The URL to navigate to when the row is activated. If set, the row renders as
|
|
156
|
+
* a link; otherwise it acts as a button.
|
|
157
|
+
*/
|
|
158
|
+
@property({type: String}) href: string | undefined;
|
|
159
|
+
|
|
160
|
+
@query('.wrapper') private wrapperElement?: HTMLElement;
|
|
161
|
+
|
|
162
|
+
/** Focuses the row's interactive wrapper (the host itself is not focusable). */
|
|
163
|
+
public override focus(options?: FocusOptions): void {
|
|
164
|
+
this.wrapperElement?.focus(options);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** A root-level row has no ancestor columns, so it draws no connector lines. */
|
|
168
|
+
private get isRoot(): boolean {
|
|
169
|
+
return this.branches.length === 0;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* All ancestor columns are blank spacers — the row is indented but draws no
|
|
174
|
+
* guide lines, so the terminal connector and dropdown are suppressed too.
|
|
175
|
+
*/
|
|
176
|
+
private get isBlankAncestry(): boolean {
|
|
177
|
+
return (
|
|
178
|
+
this.branches.length > 0 &&
|
|
179
|
+
this.branches.every((b) => b === TreeBranchType.blank)
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
private activate() {
|
|
184
|
+
if (this.disabled) return;
|
|
185
|
+
// An expandable row always toggles, even when checked — a group that is the
|
|
186
|
+
// current selection must still open and close. A checked leaf, however, is
|
|
187
|
+
// the current selection and is inert (no re-selection click or navigation).
|
|
188
|
+
if (this.expandable) {
|
|
189
|
+
this.dispatchEvent(
|
|
190
|
+
new CustomEvent<boolean>('expand-toggle', {detail: !this.expanded})
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
if (this.checked) return;
|
|
194
|
+
this.dispatchEvent(new CustomEvent('click'));
|
|
195
|
+
if (this.href !== undefined) {
|
|
196
|
+
window.location.href = this.href;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
private handleKeydown(event: KeyboardEvent) {
|
|
201
|
+
if (this.disabled) return;
|
|
202
|
+
if (event.key !== 'Enter' && event.key !== ' ') return;
|
|
203
|
+
event.preventDefault();
|
|
204
|
+
this.activate();
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
private renderBranch(type: TreeBranchType) {
|
|
208
|
+
const hasVertical =
|
|
209
|
+
type === TreeBranchType.straight ||
|
|
210
|
+
type === TreeBranchType.intersection ||
|
|
211
|
+
type === TreeBranchType.corner;
|
|
212
|
+
const hasHorizontal =
|
|
213
|
+
type === TreeBranchType.intersection || type === TreeBranchType.corner;
|
|
214
|
+
return html`<div
|
|
215
|
+
class=${classMap({branch: true, ['branch-' + type]: true})}
|
|
216
|
+
>
|
|
217
|
+
${hasVertical ? html`<div class="branch-vertical"></div>` : nothing}
|
|
218
|
+
${hasHorizontal ? html`<div class="branch-horizontal"></div>` : nothing}
|
|
219
|
+
${type === TreeBranchType.corner
|
|
220
|
+
? html`<div class="branch-elbow"></div>`
|
|
221
|
+
: nothing}
|
|
222
|
+
</div>`;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
private renderTerminalHeader() {
|
|
226
|
+
if (this.terminalType === TreeTerminalType.aggregatedHeader) {
|
|
227
|
+
return html`<div class="terminal-header" aria-hidden="true">
|
|
228
|
+
<obi-alert-header-aggregated-iec></obi-alert-header-aggregated-iec>
|
|
229
|
+
</div>`;
|
|
230
|
+
}
|
|
231
|
+
if (this.terminalType === TreeTerminalType.groupHeader) {
|
|
232
|
+
return html`<div class="terminal-header" aria-hidden="true">
|
|
233
|
+
<obi-alert-header-group-iec></obi-alert-header-group-iec>
|
|
234
|
+
</div>`;
|
|
235
|
+
}
|
|
236
|
+
return nothing;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
override render() {
|
|
240
|
+
return html`
|
|
241
|
+
<div
|
|
242
|
+
class=${classMap({
|
|
243
|
+
wrapper: true,
|
|
244
|
+
checked: this.checked,
|
|
245
|
+
disabled: this.disabled,
|
|
246
|
+
'has-icon': this.hasLeadingIcon,
|
|
247
|
+
})}
|
|
248
|
+
role="treeitem"
|
|
249
|
+
aria-expanded=${ifDefined(this.expandable ? this.expanded : undefined)}
|
|
250
|
+
aria-current=${ifDefined(this.checked ? 'page' : undefined)}
|
|
251
|
+
aria-selected=${ifDefined(this.checked ? 'true' : undefined)}
|
|
252
|
+
aria-disabled=${ifDefined(this.disabled ? 'true' : undefined)}
|
|
253
|
+
tabindex=${this.disabled ? -1 : this.focusable ? 0 : -1}
|
|
254
|
+
@click=${this.activate}
|
|
255
|
+
@keydown=${this.handleKeydown}
|
|
256
|
+
>
|
|
257
|
+
<div class="visible-wrapper">
|
|
258
|
+
<div class="tree-node-row">
|
|
259
|
+
${this.branches.map((branch) => this.renderBranch(branch))}
|
|
260
|
+
<div class="terminal">
|
|
261
|
+
${this.isRoot || this.isBlankAncestry
|
|
262
|
+
? nothing
|
|
263
|
+
: html`<div class="terminal-connector"></div>`}
|
|
264
|
+
${!this.isRoot &&
|
|
265
|
+
!this.isBlankAncestry &&
|
|
266
|
+
this.expandable &&
|
|
267
|
+
this.expanded
|
|
268
|
+
? html`<div class="terminal-dropdown"></div>`
|
|
269
|
+
: nothing}
|
|
270
|
+
${this.expandable
|
|
271
|
+
? html`<div class="chevron" aria-hidden="true">
|
|
272
|
+
<obi-chevron-right-google></obi-chevron-right-google>
|
|
273
|
+
</div>`
|
|
274
|
+
: nothing}
|
|
275
|
+
${this.renderTerminalHeader()}
|
|
276
|
+
</div>
|
|
277
|
+
</div>
|
|
278
|
+
<div class="label-container">
|
|
279
|
+
${this.hasLeadingIcon
|
|
280
|
+
? html`<div class="leading-icon">
|
|
281
|
+
<slot name="icon"></slot>
|
|
282
|
+
</div>`
|
|
283
|
+
: nothing}
|
|
284
|
+
<span part="label" class="label">${this.label}</span>
|
|
285
|
+
</div>
|
|
286
|
+
${this.hasAlertBadge
|
|
287
|
+
? html`<obc-badge
|
|
288
|
+
class="alert-badge"
|
|
289
|
+
.type=${this.alertType}
|
|
290
|
+
.number=${this.alertCount}
|
|
291
|
+
></obc-badge>`
|
|
292
|
+
: nothing}
|
|
293
|
+
</div>
|
|
294
|
+
</div>
|
|
295
|
+
`;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
static override styles = unsafeCSS(componentStyle);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
export type ObcTreeNavigationItemExpandToggleEvent = CustomEvent<boolean>;
|
|
302
|
+
|
|
303
|
+
declare global {
|
|
304
|
+
interface HTMLElementTagNameMap {
|
|
305
|
+
'obc-tree-navigation-item': ObcTreeNavigationItem;
|
|
306
|
+
}
|
|
307
|
+
}
|