@sula-tech/webcomponents 0.25.0 → 0.27.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/cjs/loader.cjs.js +1 -1
- package/dist/cjs/sula-avatar_32.cjs.entry.js +83 -67
- package/dist/cjs/sula-avatar_32.cjs.entry.js.map +1 -1
- package/dist/cjs/sula-profile-menu.cjs.entry.js +1 -1
- package/dist/cjs/sula-profile-menu.cjs.entry.js.map +1 -1
- package/dist/cjs/sula-profile-menu.entry.cjs.js.map +1 -1
- package/dist/cjs/sula-toast-stack.cjs.entry.js +4 -4
- package/dist/cjs/sula-toast.cjs.entry.js +2 -2
- package/dist/cjs/sula-workbench-menu.cjs.entry.js +98 -59
- package/dist/cjs/sula-workbench-menu.cjs.entry.js.map +1 -1
- package/dist/cjs/sula-workbench-menu.entry.cjs.js.map +1 -1
- package/dist/cjs/webcomponents.cjs.js +1 -1
- package/dist/collection/components/sula-chip/sula-chip.css +1 -1
- package/dist/collection/components/sula-chip/sula-chip.js +50 -10
- package/dist/collection/components/sula-chip/sula-chip.js.map +1 -1
- package/dist/collection/components/sula-chip/sula-chip.stories.js +39 -0
- package/dist/collection/components/sula-chip/sula-chip.stories.js.map +1 -1
- package/dist/collection/components/sula-dropdown/sula-dropdown.js +3 -3
- package/dist/collection/components/sula-icon/sula-icon.css +1 -1
- package/dist/collection/components/sula-icon/sula-icon.js +1 -1
- package/dist/collection/components/sula-icon-picker/sula-icon-picker.js +2 -2
- package/dist/collection/components/sula-loader/sula-loader.css +1 -1
- package/dist/collection/components/sula-loader/sula-loader.js +1 -1
- package/dist/collection/components/sula-menu/sula-menu.js +8 -8
- package/dist/collection/components/sula-menu-select-list/sula-menu-select-list.css +1 -1
- package/dist/collection/components/sula-menu-select-list/sula-menu-select-list.js +1 -1
- package/dist/collection/components/sula-profile-menu/sula-profile-menu.css +1 -1
- package/dist/collection/components/sula-progress-bar/sula-progress-bar.js +2 -2
- package/dist/collection/components/sula-radio-button/sula-radio-button.js +2 -2
- package/dist/collection/components/sula-search-bar/sula-search-bar.js +2 -2
- package/dist/collection/components/sula-segmented-control/sula-segmented-control.js +1 -1
- package/dist/collection/components/sula-switch/sula-switch.css +1 -1
- package/dist/collection/components/sula-switch/sula-switch.js +4 -4
- package/dist/collection/components/sula-table/sula-table.js +3 -3
- package/dist/collection/components/sula-table-body/sula-table-body.js +1 -1
- package/dist/collection/components/sula-table-cell/sula-table-cell.js +2 -2
- package/dist/collection/components/sula-table-head-cell/sula-table-head-cell.js +2 -2
- package/dist/collection/components/sula-table-header/sula-table-header.js +1 -1
- package/dist/collection/components/sula-table-row/sula-table-row.js +1 -1
- package/dist/collection/components/sula-tag/sula-tag.js +3 -3
- package/dist/collection/components/sula-textarea/sula-textarea.js +6 -6
- package/dist/collection/components/sula-textfield/sula-textfield.js +2 -2
- package/dist/collection/components/sula-tiles/sula-tiles.js +1 -1
- package/dist/collection/components/sula-timeline-list/sula-timeline-list.js +1 -1
- package/dist/collection/components/sula-toast/sula-toast.js +2 -2
- package/dist/collection/components/sula-toast-stack/sula-toast-stack.js +4 -4
- package/dist/collection/components/sula-toggle/sula-toggle.js +1 -1
- package/dist/collection/components/sula-tooltip/sula-tooltip.js +1 -1
- package/dist/collection/components/sula-workbench-menu/sula-workbench-menu.css +1 -1
- package/dist/collection/components/sula-workbench-menu/sula-workbench-menu.js +104 -84
- package/dist/collection/components/sula-workbench-menu/sula-workbench-menu.js.map +1 -1
- package/dist/collection/components/sula-workbench-menu/sula-workbench-menu.stories.js +182 -103
- package/dist/collection/components/sula-workbench-menu/sula-workbench-menu.stories.js.map +1 -1
- package/dist/components/{p-Ckrg2kct.js → p-BNxL-ZjI.js} +5 -5
- package/dist/components/{p-Ckrg2kct.js.map → p-BNxL-ZjI.js.map} +1 -1
- package/dist/components/{p-BlRYoc3b.js → p-ByuiM_SX.js} +4 -4
- package/dist/components/{p-BlRYoc3b.js.map → p-ByuiM_SX.js.map} +1 -1
- package/dist/components/{p-DOhCUb27.js → p-CQQX0ZEo.js} +5 -5
- package/dist/components/{p-DOhCUb27.js.map → p-CQQX0ZEo.js.map} +1 -1
- package/dist/components/{p-DEhN6ZhJ.js → p-CTY6E4Qo.js} +7 -7
- package/dist/components/{p-DEhN6ZhJ.js.map → p-CTY6E4Qo.js.map} +1 -1
- package/dist/components/{p-CkBDMANF.js → p-CiJSp-1r.js} +5 -5
- package/dist/components/{p-CkBDMANF.js.map → p-CiJSp-1r.js.map} +1 -1
- package/dist/components/{p-ej3XWtzq.js → p-DImZWpEm.js} +4 -4
- package/dist/components/{p-ej3XWtzq.js.map → p-DImZWpEm.js.map} +1 -1
- package/dist/components/{p-CNJmyTBM.js → p-DQYdk1Hu.js} +4 -4
- package/dist/components/{p-CNJmyTBM.js.map → p-DQYdk1Hu.js.map} +1 -1
- package/dist/components/{p-Chv1iPo7.js → p-DcFem7BV.js} +7 -7
- package/dist/components/{p-Chv1iPo7.js.map → p-DcFem7BV.js.map} +1 -1
- package/dist/components/{p-BSlKsiiN.js → p-DotZeO3E.js} +5 -5
- package/dist/components/{p-BSlKsiiN.js.map → p-DotZeO3E.js.map} +1 -1
- package/dist/components/{p-CqrWuXvX.js → p-L_u-y6EK.js} +5 -5
- package/dist/components/{p-CqrWuXvX.js.map → p-L_u-y6EK.js.map} +1 -1
- package/dist/components/sula-avatar.js +1 -1
- package/dist/components/sula-badge.js +1 -1
- package/dist/components/sula-breadcrumb.js +1 -1
- package/dist/components/sula-button.js +1 -1
- package/dist/components/sula-calendar.js +2 -2
- package/dist/components/sula-checkbox.js +1 -1
- package/dist/components/sula-chip.js +40 -15
- package/dist/components/sula-chip.js.map +1 -1
- package/dist/components/sula-dropdown.js +1 -1
- package/dist/components/sula-icon-picker.js +6 -6
- package/dist/components/sula-icon.js +1 -1
- package/dist/components/sula-loader.js +1 -1
- package/dist/components/sula-menu-select-list.js +1 -1
- package/dist/components/sula-menu.js +9 -9
- package/dist/components/sula-modal.js +3 -3
- package/dist/components/sula-profile-menu.js +1 -1
- package/dist/components/sula-progress-bar.js +3 -3
- package/dist/components/sula-radio-button.js +2 -2
- package/dist/components/sula-search-bar.js +1 -1
- package/dist/components/sula-segmented-control.js +2 -2
- package/dist/components/sula-switch.js +1 -1
- package/dist/components/sula-table-body.js +1 -1
- package/dist/components/sula-table-cell.js +2 -2
- package/dist/components/sula-table-head-cell.js +2 -2
- package/dist/components/sula-table-header.js +1 -1
- package/dist/components/sula-table-row.js +1 -1
- package/dist/components/sula-table.js +3 -3
- package/dist/components/sula-tag.js +4 -4
- package/dist/components/sula-textarea.js +6 -6
- package/dist/components/sula-textfield.js +1 -1
- package/dist/components/sula-tiles.js +2 -2
- package/dist/components/sula-timeline-list.js +2 -2
- package/dist/components/sula-toast-stack.js +6 -6
- package/dist/components/sula-toast.js +1 -1
- package/dist/components/sula-toggle.js +2 -2
- package/dist/components/sula-tooltip.js +2 -2
- package/dist/components/sula-workbench-menu.js +102 -63
- package/dist/components/sula-workbench-menu.js.map +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/sula-avatar_32.entry.js +83 -67
- package/dist/esm/sula-avatar_32.entry.js.map +1 -1
- package/dist/esm/sula-profile-menu.entry.js +1 -1
- package/dist/esm/sula-profile-menu.entry.js.map +1 -1
- package/dist/esm/sula-toast-stack.entry.js +4 -4
- package/dist/esm/sula-toast.entry.js +2 -2
- package/dist/esm/sula-workbench-menu.entry.js +98 -59
- package/dist/esm/sula-workbench-menu.entry.js.map +1 -1
- package/dist/esm/webcomponents.js +1 -1
- package/dist/types/components/sula-chip/sula-chip.d.ts +5 -0
- package/dist/types/components/sula-chip/sula-chip.stories.d.ts +11 -0
- package/dist/types/components/sula-workbench-menu/sula-workbench-menu.d.ts +15 -13
- package/dist/types/components/sula-workbench-menu/sula-workbench-menu.stories.d.ts +14 -30
- package/dist/types/components.d.ts +29 -29
- package/dist/webcomponents/{p-18c84807.entry.js → p-4fa0213d.entry.js} +6 -6
- package/dist/webcomponents/{p-705e2424.entry.js → p-76884b75.entry.js} +16 -16
- package/dist/webcomponents/{p-88e5171a.entry.js → p-7e31b463.entry.js} +2 -2
- package/dist/webcomponents/p-86448fcf.entry.js +880 -0
- package/dist/webcomponents/p-86448fcf.entry.js.map +1 -0
- package/dist/webcomponents/{p-28e25fac.entry.js → p-d8d9b8e6.entry.js} +168 -143
- package/dist/webcomponents/p-d8d9b8e6.entry.js.map +1 -0
- package/dist/webcomponents/sula-profile-menu.entry.esm.js.map +1 -1
- package/dist/webcomponents/sula-workbench-menu.entry.esm.js.map +1 -1
- package/dist/webcomponents/webcomponents.esm.js +23 -20
- package/package.json +1 -1
- package/dist/webcomponents/p-28e25fac.entry.js.map +0 -1
- package/dist/webcomponents/p-50ad82d0.entry.js +0 -827
- package/dist/webcomponents/p-50ad82d0.entry.js.map +0 -1
- /package/dist/webcomponents/{p-18c84807.entry.js.map → p-4fa0213d.entry.js.map} +0 -0
- /package/dist/webcomponents/{p-705e2424.entry.js.map → p-76884b75.entry.js.map} +0 -0
- /package/dist/webcomponents/{p-88e5171a.entry.js.map → p-7e31b463.entry.js.map} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { Host, h } from "@stencil/core";
|
|
2
2
|
import { SulaMenuDensity, SulaMenuLabelOverflow } from "../sula-menu/model/sula-menu.model";
|
|
3
3
|
/**
|
|
4
|
-
* Navigation menu that
|
|
5
|
-
*
|
|
6
|
-
*
|
|
4
|
+
* Navigation menu that expands in place, as in `sula-menu`, while the tree has up to 3 levels.
|
|
5
|
+
* When any visible item reaches a 4th level, every item with children opens a single-level
|
|
6
|
+
* drill-down panel with a breadcrumb trail instead.
|
|
7
7
|
*
|
|
8
8
|
* @part shell - Main visual container of the menu.
|
|
9
9
|
* @part title - Menu title, or the current level title while drilled in.
|
|
@@ -12,7 +12,7 @@ import { SulaMenuDensity, SulaMenuLabelOverflow } from "../sula-menu/model/sula-
|
|
|
12
12
|
* @part toggle-label - Label of the collapse/expand control.
|
|
13
13
|
* @slot profile-content - Extra content rendered inside the profile popover.
|
|
14
14
|
* @part profile-popover - Popover opened from the user area.
|
|
15
|
-
* @cssprop --sula-menu-width - Width of the expanded menu. Defaults to
|
|
15
|
+
* @cssprop --sula-menu-width - Width of the expanded menu. Defaults to 300px.
|
|
16
16
|
* @cssprop --sula-menu-collapsed-width - Width of the collapsed menu. Defaults to 88px.
|
|
17
17
|
*/
|
|
18
18
|
export class SulaWorkbenchMenu {
|
|
@@ -38,11 +38,6 @@ export class SulaWorkbenchMenu {
|
|
|
38
38
|
* Overflow behavior for item labels.
|
|
39
39
|
*/
|
|
40
40
|
this.labelOverflow = SulaMenuLabelOverflow.Wrap;
|
|
41
|
-
/**
|
|
42
|
-
* Depth (1-based) from which items with children open a drill-down panel instead of expanding in place.
|
|
43
|
-
* With the default of 3, the first two levels expand inline and deeper branches drill down.
|
|
44
|
-
*/
|
|
45
|
-
this.drilldownLevel = 3;
|
|
46
41
|
/**
|
|
47
42
|
* Menu items. Each item may use `icon` (icon font class) or `image` (URL or data URI of an image or SVG).
|
|
48
43
|
*/
|
|
@@ -57,6 +52,7 @@ export class SulaWorkbenchMenu {
|
|
|
57
52
|
this.profileItems = [];
|
|
58
53
|
this.collapsed = false;
|
|
59
54
|
this.previewExpanded = false;
|
|
55
|
+
this.drillMode = false;
|
|
60
56
|
this.stack = [];
|
|
61
57
|
this.direction = 'forward';
|
|
62
58
|
this.selectedPath = [];
|
|
@@ -76,6 +72,7 @@ export class SulaWorkbenchMenu {
|
|
|
76
72
|
this.syncWithItems(this.items);
|
|
77
73
|
}
|
|
78
74
|
syncWithItems(items) {
|
|
75
|
+
this.drillMode = this.maxDepth(items) > 3;
|
|
79
76
|
const nextSelected = this.findSelectedIds(items);
|
|
80
77
|
if (nextSelected) {
|
|
81
78
|
this.selectedPath = nextSelected;
|
|
@@ -83,8 +80,8 @@ export class SulaWorkbenchMenu {
|
|
|
83
80
|
else if (!this.selectedPath.length || !this.isStillSelectable(items, this.selectedPath)) {
|
|
84
81
|
this.selectedPath = [];
|
|
85
82
|
}
|
|
86
|
-
this.stack = this.rebuildStack(items, this.stack);
|
|
87
|
-
if (this.drillPath)
|
|
83
|
+
this.stack = this.drillMode ? this.rebuildStack(items, this.stack) : [];
|
|
84
|
+
if (this.drillPath && (this.drillMode || this.drillPath !== this.expandedPath))
|
|
88
85
|
this.applyDrillPath(this.drillPath);
|
|
89
86
|
}
|
|
90
87
|
syncDrillPath(path) {
|
|
@@ -93,6 +90,10 @@ export class SulaWorkbenchMenu {
|
|
|
93
90
|
}
|
|
94
91
|
applyDrillPath(path) {
|
|
95
92
|
var _a;
|
|
93
|
+
if (!this.drillMode) {
|
|
94
|
+
this.expandInline(path);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
96
97
|
const next = [];
|
|
97
98
|
let level = this.items;
|
|
98
99
|
for (const id of path) {
|
|
@@ -108,6 +109,33 @@ export class SulaWorkbenchMenu {
|
|
|
108
109
|
this.direction = next.length < this.stack.length ? 'back' : 'forward';
|
|
109
110
|
this.stack = next;
|
|
110
111
|
}
|
|
112
|
+
expandInline(path) {
|
|
113
|
+
var _a;
|
|
114
|
+
if (!this.items.length)
|
|
115
|
+
return;
|
|
116
|
+
this.expandedPath = path;
|
|
117
|
+
const ids = [];
|
|
118
|
+
let level = this.items;
|
|
119
|
+
for (const id of path) {
|
|
120
|
+
const match = this.getVisibleItems(level).find(item => item.id === id);
|
|
121
|
+
if (!match)
|
|
122
|
+
break;
|
|
123
|
+
if (!match.expanded && this.hasVisibleChildren(match))
|
|
124
|
+
ids.push(id);
|
|
125
|
+
level = (_a = match.children) !== null && _a !== void 0 ? _a : [];
|
|
126
|
+
}
|
|
127
|
+
if (ids.length)
|
|
128
|
+
this.items = this.markExpanded(this.items, ids);
|
|
129
|
+
}
|
|
130
|
+
markExpanded(items, ids) {
|
|
131
|
+
return items.map(item => (Object.assign(Object.assign(Object.assign({}, item), (ids.includes(item.id) ? { expanded: true } : {})), (item.children ? { children: this.markExpanded(item.children, ids) } : {}))));
|
|
132
|
+
}
|
|
133
|
+
maxDepth(items) {
|
|
134
|
+
const visible = this.getVisibleItems(items);
|
|
135
|
+
if (!visible.length)
|
|
136
|
+
return 0;
|
|
137
|
+
return 1 + Math.max(...visible.map(item => this.maxDepth(item.children)));
|
|
138
|
+
}
|
|
111
139
|
componentDidRender() {
|
|
112
140
|
this.positionProfile();
|
|
113
141
|
}
|
|
@@ -142,7 +170,7 @@ export class SulaWorkbenchMenu {
|
|
|
142
170
|
return this.getVisibleItems(item.children).length > 0;
|
|
143
171
|
}
|
|
144
172
|
isDrilled() {
|
|
145
|
-
return this.stack.length
|
|
173
|
+
return this.drillMode && this.stack.length > 0;
|
|
146
174
|
}
|
|
147
175
|
findSelectedIds(items, trail = []) {
|
|
148
176
|
for (const item of this.getVisibleItems(items)) {
|
|
@@ -229,16 +257,16 @@ export class SulaWorkbenchMenu {
|
|
|
229
257
|
this.selectedPath = path.map(p => p.id);
|
|
230
258
|
this.itemSelected.emit(item);
|
|
231
259
|
}
|
|
232
|
-
handleRowClick(item
|
|
260
|
+
handleRowClick(item) {
|
|
233
261
|
if (item.disabled)
|
|
234
262
|
return;
|
|
235
263
|
this.itemClicked.emit(item);
|
|
236
264
|
if (this.hasVisibleChildren(item)) {
|
|
237
|
-
if (
|
|
238
|
-
this.
|
|
265
|
+
if (this.drillMode) {
|
|
266
|
+
this.enterDrill(item);
|
|
239
267
|
}
|
|
240
268
|
else {
|
|
241
|
-
this.
|
|
269
|
+
this.toggleInline(item.id);
|
|
242
270
|
}
|
|
243
271
|
return;
|
|
244
272
|
}
|
|
@@ -258,7 +286,7 @@ export class SulaWorkbenchMenu {
|
|
|
258
286
|
const button = event.currentTarget;
|
|
259
287
|
this.crumbMenu = {
|
|
260
288
|
open: true,
|
|
261
|
-
left:
|
|
289
|
+
left: 0,
|
|
262
290
|
top: button.offsetTop + button.offsetHeight + 6,
|
|
263
291
|
};
|
|
264
292
|
}
|
|
@@ -306,24 +334,26 @@ export class SulaWorkbenchMenu {
|
|
|
306
334
|
if (this.collapsed && !this.hovering)
|
|
307
335
|
this.previewExpanded = false;
|
|
308
336
|
}
|
|
309
|
-
// Fixed position, so ancestors with overflow hidden do not clip the popover.
|
|
337
|
+
// Fixed position, so ancestors with overflow hidden do not clip the popover. A transformed ancestor
|
|
338
|
+
// (e.g. the Storybook docs canvas) becomes the containing block, so coordinates are made relative to its origin.
|
|
310
339
|
positionProfile() {
|
|
340
|
+
var _a, _b;
|
|
311
341
|
if (!this.profileOpen || !this.profileEl || !this.userInfoEl || !this.shellEl)
|
|
312
342
|
return;
|
|
313
343
|
const gap = 8;
|
|
314
344
|
const inset = 12;
|
|
315
345
|
const anchor = this.userInfoEl.getBoundingClientRect();
|
|
316
346
|
const shell = this.shellEl.getBoundingClientRect();
|
|
347
|
+
const origin = (_b = (_a = this.profileOriginEl) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect()) !== null && _b !== void 0 ? _b : { left: 0, top: 0 };
|
|
317
348
|
const style = this.profileEl.style;
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
style.left = `${
|
|
325
|
-
style.
|
|
326
|
-
style.bottom = `${window.innerHeight - anchor.bottom}px`;
|
|
349
|
+
const expandedView = !this.collapsed || this.previewExpanded;
|
|
350
|
+
style.width = expandedView ? `${shell.width - inset * 2}px` : '';
|
|
351
|
+
const height = this.profileEl.offsetHeight;
|
|
352
|
+
const left = expandedView ? shell.left + inset : shell.right + gap;
|
|
353
|
+
const bottom = expandedView ? anchor.top - gap : anchor.bottom;
|
|
354
|
+
style.bottom = 'auto';
|
|
355
|
+
style.left = `${left - origin.left}px`;
|
|
356
|
+
style.top = `${bottom - height - origin.top}px`;
|
|
327
357
|
}
|
|
328
358
|
// Inner events are composed; stopping them avoids clashing with this menu's own itemClicked.
|
|
329
359
|
handleProfileItemClicked(event) {
|
|
@@ -379,12 +409,14 @@ export class SulaWorkbenchMenu {
|
|
|
379
409
|
renderUserInfo(expandedView) {
|
|
380
410
|
const user = this.user;
|
|
381
411
|
return (h("button", { type: "button", class: {
|
|
382
|
-
'user-info flex min-w-0 cursor-pointer items-center
|
|
383
|
-
'user-info--
|
|
384
|
-
'
|
|
412
|
+
'user-info flex min-w-0 cursor-pointer items-center text-left': true,
|
|
413
|
+
'user-info--card w-full gap-16 rounded-md bg-surface-on-body p-16': expandedView,
|
|
414
|
+
'rounded-xs p-8 hover:bg-states-empty-bg-hover': !expandedView,
|
|
415
|
+
'user-info--active bg-states-empty-bg-hover': this.profileOpen && !expandedView,
|
|
385
416
|
}, title: `Ver perfil de ${user.name}`, "aria-label": `Ver perfil de ${user.name}`, "aria-haspopup": "dialog", "aria-expanded": String(this.profileOpen), ref: el => (this.userInfoEl = el), onClick: () => this.toggleProfile() }, h("span", { class: "user-avatar flex h-9 w-9 flex-none items-center justify-center overflow-hidden rounded-full bg-brand-primary text-sm font-semibold text-negative-negative-1" }, user.photo ? h("img", { src: user.photo, alt: user.name }) : this.getInitials(user.name)), h("span", { "aria-hidden": !expandedView, class: {
|
|
386
417
|
'user-copy': true,
|
|
387
|
-
'ml-8':
|
|
418
|
+
'ml-8': !expandedView,
|
|
419
|
+
'flex-1': expandedView,
|
|
388
420
|
'user-copy--visible': expandedView,
|
|
389
421
|
'user-copy--hidden': !expandedView,
|
|
390
422
|
} }, h("span", { part: "user-name", class: "user-name truncate text-sm font-semibold text-text-primary" }, user.name), user.email && h("span", { part: "user-email", class: "user-email truncate text-xs text-text-secondary" }, user.email))));
|
|
@@ -398,7 +430,7 @@ export class SulaWorkbenchMenu {
|
|
|
398
430
|
}
|
|
399
431
|
renderCollapseButton() {
|
|
400
432
|
const label = this.collapsed ? 'Expandir menu' : 'Recolher menu';
|
|
401
|
-
return (h("button", { type: "button", class: "menu-toggle flex flex-none items-center justify-center", title: label, "aria-label": label, "aria-expanded": String(!this.collapsed), onClick: () => this.toggleMenu() }, h("sula-icon", { icon:
|
|
433
|
+
return (h("button", { type: "button", class: "menu-toggle flex flex-none items-center justify-center", title: label, "aria-label": label, "aria-expanded": String(!this.collapsed), onClick: () => this.toggleMenu() }, h("sula-icon", { icon: "ph-bold ph-sidebar", customClass: "text-lg" })));
|
|
402
434
|
}
|
|
403
435
|
renderRootHeader(expandedView) {
|
|
404
436
|
return (h("div", { class: {
|
|
@@ -414,7 +446,9 @@ export class SulaWorkbenchMenu {
|
|
|
414
446
|
renderTrail(ancestors) {
|
|
415
447
|
const hasHidden = ancestors.length > 2;
|
|
416
448
|
const visible = hasHidden ? ancestors.slice(-2) : ancestors;
|
|
417
|
-
const crumbs = [
|
|
449
|
+
const crumbs = [
|
|
450
|
+
h("button", { key: "root", type: "button", class: "crumb-btn", title: `Ir para o início de ${this.menuTitle}`, onClick: () => this.goToDepth(-1) }, this.menuTitle || 'Início'),
|
|
451
|
+
];
|
|
418
452
|
if (hasHidden) {
|
|
419
453
|
crumbs.push(h("button", { key: "ellipsis", type: "button", class: "crumb-btn crumb-btn--ellipsis", "aria-haspopup": "true", "aria-expanded": String(this.crumbMenu.open), title: `${ancestors.length - 2} nível(is) anterior(es)`, ref: el => (this.crumbEllipsisEl = el), onClick: event => this.toggleCrumbMenu(event) }, h("sula-icon", { icon: "ph-bold ph-dots-three", customClass: "text-base text-text-secondary" })));
|
|
420
454
|
}
|
|
@@ -433,24 +467,27 @@ export class SulaWorkbenchMenu {
|
|
|
433
467
|
if (!this.crumbMenu.open || ancestors.length <= 2)
|
|
434
468
|
return null;
|
|
435
469
|
const hidden = ancestors.slice(0, -2);
|
|
436
|
-
return (h("div", { class: "crumb-dropdown", role: "menu", ref: el => (this.crumbDropdownEl = el), style: { left: `${this.crumbMenu.left}px`, top: `${this.crumbMenu.top}px` } }, hidden.map(ancestor => (h("button", { key: ancestor.id, type: "button", role: "menuitem", class: "crumb-dropdown-item", onClick: () => this.goToDepth(this.stack.indexOf(ancestor)) }, h("span", { class: "item-icon flex flex-none items-center justify-center" }, this.renderItemIcon(ancestor, 'text-sm text-icon-primary', 'sm')), h("span", { class: "truncate" }, ancestor.label))))));
|
|
470
|
+
return (h("div", { class: "crumb-dropdown", role: "menu", ref: el => (this.crumbDropdownEl = el), style: { left: `${this.crumbMenu.left}px`, top: `${this.crumbMenu.top}px` } }, hidden.map(ancestor => (h("button", { key: ancestor.id, type: "button", role: "menuitem", class: "crumb-dropdown-item", onClick: () => this.goToDepth(this.stack.indexOf(ancestor)) }, h("span", { class: "item-icon flex flex-none items-center justify-center" }, this.renderItemIcon(ancestor, 'text-sm text-icon-primary', 'sm')), h("span", { class: "min-w-0 truncate" }, ancestor.label))))));
|
|
437
471
|
}
|
|
438
472
|
renderDrillHeader(activeParent) {
|
|
439
473
|
const ancestors = this.stack.slice(0, -1);
|
|
440
474
|
const backLabel = ancestors.length ? ancestors[ancestors.length - 1].label : this.menuTitle || 'Início';
|
|
441
|
-
const backButton = (h("button", { type: "button", class: "back-btn", title: `Voltar para ${backLabel}`, "aria-label": `Voltar para ${backLabel}`, onClick: () => this.goToDepth(this.stack.length - 2) }, h("sula-icon", { icon: "ph ph-arrow-left", customClass: "text-
|
|
442
|
-
return (h("div", {
|
|
475
|
+
const backButton = (h("button", { type: "button", class: "back-btn", title: `Voltar para ${backLabel}`, "aria-label": `Voltar para ${backLabel}`, onClick: () => this.goToDepth(this.stack.length - 2) }, h("sula-icon", { icon: "ph ph-arrow-left", customClass: "text-xl text-icon-primary" })));
|
|
476
|
+
return (h("div", { key: this.stack.map(item => item.id).join('/'), class: {
|
|
477
|
+
'menu-header menu-header--drilldown flex flex-col': true,
|
|
478
|
+
'menu-header--back': this.direction === 'back',
|
|
479
|
+
} }, h("div", { class: "drill-toolbar flex items-center justify-between" }, backButton, this.renderCollapseButton()), ancestors.length > 0 && (h("div", { class: "breadcrumb-row" }, this.renderTrail(ancestors), this.renderCrumbDropdown(ancestors))), h("div", { class: "context-row flex items-center min-w-0" }, this.hasIcon(activeParent) && (h("span", { class: "context-icon flex flex-none items-center justify-center" }, this.renderItemIcon(activeParent, 'text-xl text-brand-primary', 'md'))), h("h1", { part: "title", class: "context-title text-text-primary", title: activeParent.label }, activeParent.label))));
|
|
443
480
|
}
|
|
444
|
-
renderDrillRow(item, reserve) {
|
|
481
|
+
renderDrillRow(item, reserve, index) {
|
|
445
482
|
const branch = this.hasVisibleChildren(item);
|
|
446
483
|
const active = this.isActive(item, branch);
|
|
447
484
|
const faded = this.isFaded(item, active);
|
|
448
|
-
return (h("li", { class: "list-none", key: item.id }, h("div", { class: {
|
|
449
|
-
'menu-item flex items-center justify-between rounded-
|
|
450
|
-
'cursor-pointer hover:bg-states-empty-bg-hover': !item.disabled && !active,
|
|
485
|
+
return (h("li", { class: "list-none", key: item.id, style: { '--row-index': String(Math.min(index, 8)) } }, h("div", { class: {
|
|
486
|
+
'menu-item flex items-center justify-between rounded-md px-8': true,
|
|
487
|
+
'cursor-pointer hover:bg-states-empty-bg-hover active:bg-states-empty-bg-pressed': !item.disabled && !active,
|
|
451
488
|
'cursor-pointer': !item.disabled && active,
|
|
452
489
|
'cursor-not-allowed': !!item.disabled,
|
|
453
|
-
}, "aria-disabled": !!item.disabled, onClick: () => this.handleRowClick(item
|
|
490
|
+
}, "aria-disabled": !!item.disabled, onClick: () => this.handleRowClick(item) }, h("span", { class: "flex min-w-0 flex-1 items-center gap-8" }, this.renderIconSlot(item, this.getIconClass(active, faded, 'text-base'), faded, reserve), h("span", { part: "item-label", class: {
|
|
454
491
|
'menu-item-label truncate': this.labelOverflow !== SulaMenuLabelOverflow.Wrap,
|
|
455
492
|
'menu-item-label menu-item-label--wrap': this.labelOverflow === SulaMenuLabelOverflow.Wrap,
|
|
456
493
|
'font-bold text-text-primary': active,
|
|
@@ -458,6 +495,11 @@ export class SulaWorkbenchMenu {
|
|
|
458
495
|
'text-text-secondary': !active && !faded,
|
|
459
496
|
} }, item.label)), branch && h("sula-icon", { icon: "ph ph-caret-right", customClass: faded ? 'text-text-disabled text-xs' : 'text-text-secondary text-xs' }))));
|
|
460
497
|
}
|
|
498
|
+
// Strips on the left edge suggest the levels already navigated; the prototype shows at most two.
|
|
499
|
+
renderDrillLayers() {
|
|
500
|
+
const count = Math.min(this.stack.length, 2);
|
|
501
|
+
return (h("div", { class: "drill-layers", "aria-hidden": "true" }, Array.from({ length: count }, (_, index) => (h("span", { key: index, class: "drill-layer", style: { width: `${12 * (index + 1)}px`, zIndex: String(count - index) } })))));
|
|
502
|
+
}
|
|
461
503
|
renderDrillPanel() {
|
|
462
504
|
const activeParent = this.stack[this.stack.length - 1];
|
|
463
505
|
const panelKey = this.stack.map(item => item.id).join('/');
|
|
@@ -465,7 +507,7 @@ export class SulaWorkbenchMenu {
|
|
|
465
507
|
'menu-panel flex flex-col': true,
|
|
466
508
|
'menu-panel--forward': this.direction === 'forward',
|
|
467
509
|
'menu-panel--back': this.direction === 'back',
|
|
468
|
-
} }, this.getVisibleItems(activeParent.children).map(item => this.renderDrillRow(item, this.siblingsHaveIcon(activeParent.children)))));
|
|
510
|
+
} }, this.getVisibleItems(activeParent.children).map((item, index) => this.renderDrillRow(item, this.siblingsHaveIcon(activeParent.children), index))));
|
|
469
511
|
}
|
|
470
512
|
getMainIconClass(active, faded) {
|
|
471
513
|
if (faded)
|
|
@@ -499,15 +541,15 @@ export class SulaWorkbenchMenu {
|
|
|
499
541
|
return null;
|
|
500
542
|
return h("span", { class: "item-icon flex flex-none items-center justify-center" }, this.renderItemIcon(item, customClass, 'lg', faded));
|
|
501
543
|
}
|
|
502
|
-
renderMainRow(item, expandedView, branch, expanded, active, faded, reserve) {
|
|
544
|
+
renderMainRow(item, expandedView, branch, expanded, active, faded, drill, reserve) {
|
|
503
545
|
const labelOverflowTruncate = this.labelOverflow === SulaMenuLabelOverflow.Truncate;
|
|
504
546
|
return (h("div", { class: {
|
|
505
|
-
'menu-item flex items-center rounded-
|
|
506
|
-
'cursor-pointer hover:bg-states-empty-bg-hover': !item.disabled,
|
|
547
|
+
'menu-item flex items-center rounded-md px-8': true,
|
|
548
|
+
'cursor-pointer hover:bg-states-empty-bg-hover active:bg-states-empty-bg-pressed': !item.disabled,
|
|
507
549
|
'cursor-not-allowed': !!item.disabled,
|
|
508
550
|
'justify-between': expandedView,
|
|
509
551
|
'justify-center': !expandedView,
|
|
510
|
-
}, title: !expandedView ? item.label : undefined, "aria-disabled": !!item.disabled, onClick: () => this.handleRowClick(item
|
|
552
|
+
}, title: !expandedView ? item.label : undefined, "aria-disabled": !!item.disabled, onClick: () => this.handleRowClick(item) }, h("div", { class: { 'flex items-center': true, 'flex-1 min-w-0 gap-8': expandedView, 'justify-center': !expandedView } }, this.renderIconSlot(item, this.getMainIconClass(active, faded), faded, reserve), h("span", { part: "main-item-label", title: expandedView ? item.label : undefined, "aria-hidden": !expandedView, class: {
|
|
511
553
|
'menu-item-label menu-copy': true,
|
|
512
554
|
'menu-item-label--truncate': labelOverflowTruncate,
|
|
513
555
|
'menu-item-label--wrap': !labelOverflowTruncate,
|
|
@@ -521,15 +563,15 @@ export class SulaWorkbenchMenu {
|
|
|
521
563
|
'menu-item-caret--expanded': expanded,
|
|
522
564
|
'menu-item-caret--visible': expandedView,
|
|
523
565
|
'menu-item-caret--hidden': !expandedView,
|
|
524
|
-
}, icon:
|
|
566
|
+
}, icon: drill ? 'ph ph-caret-right' : 'ph ph-caret-down', customClass: this.getMainCaretClass(active, faded) }))));
|
|
525
567
|
}
|
|
526
568
|
renderSubRow(item, expandedView, branch, expanded, active, faded, drill, reserve) {
|
|
527
569
|
const caretIcon = drill ? 'ph-bold ph-caret-right' : `ph-bold ph-caret-${expanded && expandedView ? 'up' : 'down'}`;
|
|
528
|
-
const onClick = () => this.handleRowClick(item
|
|
570
|
+
const onClick = () => this.handleRowClick(item);
|
|
529
571
|
const rowClass = {
|
|
530
|
-
'submenu-item flex min-w-0 items-center rounded-
|
|
572
|
+
'submenu-item flex min-w-0 items-center rounded-md py-8 pr-8 select-none': true,
|
|
531
573
|
'submenu-item--branch w-full': branch,
|
|
532
|
-
'cursor-pointer hover:bg-states-empty-bg-hover': !item.disabled,
|
|
574
|
+
'cursor-pointer hover:bg-states-empty-bg-hover active:bg-states-empty-bg-pressed': !item.disabled,
|
|
533
575
|
'cursor-not-allowed': !!item.disabled,
|
|
534
576
|
'font-bold': active && branch,
|
|
535
577
|
};
|
|
@@ -547,27 +589,23 @@ export class SulaWorkbenchMenu {
|
|
|
547
589
|
}
|
|
548
590
|
return (h("a", { class: rowClass, style: { paddingLeft: '8px' }, title: item.label, "aria-disabled": !!item.disabled, onClick: onClick }, h("div", { class: "submenu-item-branch-content flex min-w-0 flex-1 items-center" }, this.renderIconSlot(item, this.getSubIconClass(faded, active && !branch), faded, reserve), label), h("div", { class: "submenu-item-branch-caret flex flex-none items-center justify-end pl-8" }, h("sula-icon", { icon: caretIcon, customClass: this.getSubCaretClass(faded) }))));
|
|
549
591
|
}
|
|
550
|
-
depthOf(item) {
|
|
551
|
-
const path = this.findPath(this.items, item.id);
|
|
552
|
-
return path ? path.length : 1;
|
|
553
|
-
}
|
|
554
592
|
renderInlineList(items, depth, expandedView) {
|
|
555
593
|
const reserve = this.siblingsHaveIcon(items);
|
|
556
594
|
return this.getVisibleItems(items).map(item => {
|
|
557
595
|
const branch = this.hasVisibleChildren(item);
|
|
558
|
-
const drill = branch &&
|
|
596
|
+
const drill = branch && this.drillMode;
|
|
559
597
|
const inline = branch && !drill;
|
|
560
598
|
const expanded = inline && !!item.expanded;
|
|
561
599
|
const active = this.isActive(item, branch) || expanded;
|
|
562
600
|
const faded = this.isFaded(item, active);
|
|
563
601
|
const row = depth === 1
|
|
564
|
-
? this.renderMainRow(item, expandedView, branch, expanded, active, faded, reserve)
|
|
602
|
+
? this.renderMainRow(item, expandedView, branch, expanded, active, faded, drill, reserve)
|
|
565
603
|
: this.renderSubRow(item, expandedView, branch, expanded, active, faded, drill, reserve);
|
|
566
604
|
return (h("li", { class: { 'decoration-none list-none': true, 'menu-group': depth === 1, 'is-selected': depth > 1 && active && !branch }, key: item.id }, row, inline && (h("ul", { "aria-hidden": !expandedView || !expanded, class: {
|
|
567
605
|
submenu: true,
|
|
568
606
|
'submenu--expanded': expandedView && expanded,
|
|
569
|
-
'ml-[8px] border-l border-line-general pl-
|
|
570
|
-
'submenu-branch ml-[
|
|
607
|
+
'ml-[8px] border-l border-line-general pl-12': depth === 1,
|
|
608
|
+
'submenu-branch ml-[20px]': depth > 1,
|
|
571
609
|
} }, this.renderInlineList(item.children, depth + 1, expandedView)))));
|
|
572
610
|
});
|
|
573
611
|
}
|
|
@@ -575,20 +613,21 @@ export class SulaWorkbenchMenu {
|
|
|
575
613
|
const expandedView = !this.collapsed || this.previewExpanded;
|
|
576
614
|
const drilled = expandedView && this.isDrilled();
|
|
577
615
|
const activeParent = this.stack[this.stack.length - 1];
|
|
578
|
-
return (h(Host, { key: '
|
|
616
|
+
return (h(Host, { key: 'ab2f6194a30ca48695e5861b4fd34c1c8f926bec', class: {
|
|
579
617
|
'menu-host--collapsed': this.collapsed,
|
|
580
618
|
'menu-host--preview': this.collapsed && this.previewExpanded,
|
|
581
619
|
'menu-host--density-compact': this.density === SulaMenuDensity.Compact,
|
|
582
620
|
'menu-host--density-comfortable': this.density === SulaMenuDensity.Comfortable,
|
|
583
|
-
}, style: this.hostStyleVariables, onMouseEnter: () => this.handleMenuMouseEnter(), onMouseLeave: () => this.handleMenuMouseLeave() }, h("aside", { key: '
|
|
621
|
+
}, style: this.hostStyleVariables, onMouseEnter: () => this.handleMenuMouseEnter(), onMouseLeave: () => this.handleMenuMouseLeave() }, h("aside", { key: '8019d8e64ab613cd56a5f7a43c7524515738bd47', part: "shell", ref: el => (this.shellEl = el), class: {
|
|
584
622
|
'menu-shell flex h-full flex-col bg-surface-body shadow-md z-50': true,
|
|
585
623
|
'menu-shell--collapsed': this.collapsed && !this.previewExpanded,
|
|
586
624
|
'menu-shell--expanded': expandedView,
|
|
587
625
|
'menu-shell--preview': this.collapsed && this.previewExpanded,
|
|
588
|
-
|
|
626
|
+
'menu-shell--drilled': drilled,
|
|
627
|
+
} }, drilled && this.renderDrillLayers(), drilled ? this.renderDrillHeader(activeParent) : this.renderRootHeader(expandedView), h("nav", { key: 'c49e5bbbcad96f97a78c937cc9881c04bd1a614a', class: {
|
|
589
628
|
'menu-nav flex h-full flex-col overflow-y-auto overflow-x-hidden': true,
|
|
590
629
|
'px-12': !expandedView,
|
|
591
|
-
} }, drilled ? (this.renderDrillPanel()) : (h("ul", { class: "flex flex-col" }, this.renderInlineList(this.items, 1, expandedView)))), this.user && (h("div", { key: '
|
|
630
|
+
} }, drilled ? (this.renderDrillPanel()) : (h("ul", { class: "flex flex-col" }, this.renderInlineList(this.items, 1, expandedView)))), this.user && (h("div", { key: '9ac5a2f21cdacd18dc8f127905293b54bb3ef592', class: "menu-footer pt-12" }, this.renderUserInfo(expandedView)))), this.user && h("span", { key: '58b2452d40614cd366bcefb186fbafc7930a2ebe', class: "profile-origin", "aria-hidden": "true", ref: el => (this.profileOriginEl = el) }), this.user && this.renderProfilePopover(expandedView)));
|
|
592
631
|
}
|
|
593
632
|
static get is() { return "sula-workbench-menu"; }
|
|
594
633
|
static get encapsulation() { return "shadow"; }
|
|
@@ -716,26 +755,6 @@ export class SulaWorkbenchMenu {
|
|
|
716
755
|
"reflect": false,
|
|
717
756
|
"defaultValue": "SulaMenuLabelOverflow.Wrap"
|
|
718
757
|
},
|
|
719
|
-
"drilldownLevel": {
|
|
720
|
-
"type": "number",
|
|
721
|
-
"attribute": "drilldown-level",
|
|
722
|
-
"mutable": false,
|
|
723
|
-
"complexType": {
|
|
724
|
-
"original": "number",
|
|
725
|
-
"resolved": "number",
|
|
726
|
-
"references": {}
|
|
727
|
-
},
|
|
728
|
-
"required": false,
|
|
729
|
-
"optional": false,
|
|
730
|
-
"docs": {
|
|
731
|
-
"tags": [],
|
|
732
|
-
"text": "Depth (1-based) from which items with children open a drill-down panel instead of expanding in place.\nWith the default of 3, the first two levels expand inline and deeper branches drill down."
|
|
733
|
-
},
|
|
734
|
-
"getter": false,
|
|
735
|
-
"setter": false,
|
|
736
|
-
"reflect": false,
|
|
737
|
-
"defaultValue": "3"
|
|
738
|
-
},
|
|
739
758
|
"drillPath": {
|
|
740
759
|
"type": "unknown",
|
|
741
760
|
"attribute": "drill-path",
|
|
@@ -749,7 +768,7 @@ export class SulaWorkbenchMenu {
|
|
|
749
768
|
"optional": true,
|
|
750
769
|
"docs": {
|
|
751
770
|
"tags": [],
|
|
752
|
-
"text": "Controls the
|
|
771
|
+
"text": "Controls the navigation from the host: ids from the root to the item whose children are shown.\nIn drill-down mode an empty array goes back to the root; in inline mode the items on the path are expanded.\nLeave it undefined to let only user clicks navigate."
|
|
753
772
|
},
|
|
754
773
|
"getter": false,
|
|
755
774
|
"setter": false
|
|
@@ -854,6 +873,7 @@ export class SulaWorkbenchMenu {
|
|
|
854
873
|
return {
|
|
855
874
|
"collapsed": {},
|
|
856
875
|
"previewExpanded": {},
|
|
876
|
+
"drillMode": {},
|
|
857
877
|
"stack": {},
|
|
858
878
|
"direction": {},
|
|
859
879
|
"selectedPath": {},
|
|
@@ -891,7 +911,7 @@ export class SulaWorkbenchMenu {
|
|
|
891
911
|
"composed": true,
|
|
892
912
|
"docs": {
|
|
893
913
|
"tags": [],
|
|
894
|
-
"text": "Emitted when any item is
|
|
914
|
+
"text": "Emitted when any item is clickede"
|
|
895
915
|
},
|
|
896
916
|
"complexType": {
|
|
897
917
|
"original": "SulaWorkbenchMenuItem",
|