symbiote-ui 0.3.0-alpha.4
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/CHANGELOG.md +46 -0
- package/LICENSE +21 -0
- package/README.md +76 -0
- package/canvas/AutoLayout.js +731 -0
- package/canvas/Breadcrumb/Breadcrumb.css.js +75 -0
- package/canvas/Breadcrumb/Breadcrumb.js +96 -0
- package/canvas/Breadcrumb/Breadcrumb.tpl.js +7 -0
- package/canvas/CanvasConnectionRenderer.js +971 -0
- package/canvas/CanvasGraph/CanvasGraph.css.js +29 -0
- package/canvas/CanvasGraph/CanvasGraph.js +1697 -0
- package/canvas/CanvasGraph/CanvasGraphDrawState.js +280 -0
- package/canvas/CanvasGraph/CanvasGraphGeometry.js +194 -0
- package/canvas/CanvasViewport.js +550 -0
- package/canvas/ConnectionRenderer.js +1283 -0
- package/canvas/FlowSimulator.js +326 -0
- package/canvas/ForceLayout.js +226 -0
- package/canvas/ForceWorker.js +1303 -0
- package/canvas/FrameManager.js +223 -0
- package/canvas/GraphExplorerShell/GraphExplorerShell.css.js +136 -0
- package/canvas/GraphExplorerShell/GraphExplorerShell.js +129 -0
- package/canvas/GraphExplorerShell/GraphExplorerShell.tpl.js +12 -0
- package/canvas/GraphTabs/GraphTabs.css.js +101 -0
- package/canvas/GraphTabs/GraphTabs.js +189 -0
- package/canvas/GraphTabs/GraphTabs.tpl.js +12 -0
- package/canvas/LODManager.js +88 -0
- package/canvas/Minimap/Minimap.css.js +73 -0
- package/canvas/Minimap/Minimap.js +210 -0
- package/canvas/Minimap/Minimap.tpl.js +7 -0
- package/canvas/NodeCanvas/NodeCanvas.css.js +398 -0
- package/canvas/NodeCanvas/NodeCanvas.js +1499 -0
- package/canvas/NodeCanvas/NodeCanvas.tpl.js +22 -0
- package/canvas/NodeSearch/NodeSearch.css.js +97 -0
- package/canvas/NodeSearch/NodeSearch.js +140 -0
- package/canvas/NodeSearch/NodeSearch.tpl.js +25 -0
- package/canvas/NodeViewManager.js +748 -0
- package/canvas/PcbRouteDiagnostics.js +463 -0
- package/canvas/PcbRouter.js +1127 -0
- package/canvas/PinExpansion.js +134 -0
- package/canvas/PseudoConnection.js +84 -0
- package/canvas/SelectionSync.js +163 -0
- package/canvas/SubgraphManager.js +203 -0
- package/canvas/SubgraphRouter.js +452 -0
- package/canvas/ViewportActions.js +473 -0
- package/canvas/graph-explorer.js +339 -0
- package/canvas/graph-layout.js +148 -0
- package/canvas/graph-model.js +68 -0
- package/canvas/html-in-canvas.js +202 -0
- package/canvas/project-graph-builder.js +440 -0
- package/canvas/project-graph-model.js +183 -0
- package/chat/ChatComposer/ChatComposer.css.js +652 -0
- package/chat/ChatComposer/ChatComposer.js +304 -0
- package/chat/ChatList/ChatList.css.js +102 -0
- package/chat/ChatList/ChatList.js +99 -0
- package/chat/ChatList/ChatList.tpl.js +20 -0
- package/chat/ChatListItem/ChatListItem.css.js +117 -0
- package/chat/ChatListItem/ChatListItem.js +32 -0
- package/chat/ChatListItem/ChatListItem.tpl.js +17 -0
- package/chat/ChatMessageItem/ChatMessageItem.css.js +628 -0
- package/chat/ChatMessageItem/ChatMessageItem.js +156 -0
- package/chat/ChatSidebar/ChatSidebar.css.js +150 -0
- package/chat/ChatSidebar/ChatSidebar.js +230 -0
- package/chat/ChatSidebar/ChatSidebar.tpl.js +18 -0
- package/chat/ChatSidebar/constants.js +11 -0
- package/chat/ChatSidebarItem/ChatSidebarItem.css.js +445 -0
- package/chat/ChatSidebarItem/ChatSidebarItem.js +304 -0
- package/chat/ChatTranscript/ChatTranscript.css.js +90 -0
- package/chat/ChatTranscript/ChatTranscript.js +244 -0
- package/chat/chat-context.js +123 -0
- package/chat/message-model.js +156 -0
- package/cli.js +20 -0
- package/control/Button/Button.css.js +93 -0
- package/control/Button/Button.js +78 -0
- package/control/Button/Button.tpl.js +3 -0
- package/control/Field/Field.css.js +91 -0
- package/control/Field/Field.js +17 -0
- package/control/Field/Field.tpl.js +3 -0
- package/core/Connection.js +47 -0
- package/core/Editor.js +449 -0
- package/core/Frame.js +33 -0
- package/core/GraphMermaid.js +348 -0
- package/core/GraphText.js +228 -0
- package/core/Node.js +145 -0
- package/core/Portal.js +106 -0
- package/core/Socket.js +187 -0
- package/core/SubgraphNode.js +121 -0
- package/core/base-path.js +55 -0
- package/core/dom-utils.js +14 -0
- package/core/index.js +18 -0
- package/core/local-cache.js +26 -0
- package/core/state-sync.js +227 -0
- package/custom-elements.json +6380 -0
- package/discover.js +240 -0
- package/display/Badge/Badge.css.js +44 -0
- package/display/Badge/Badge.js +17 -0
- package/display/Badge/Badge.tpl.js +3 -0
- package/display/Banner/Banner.css.js +61 -0
- package/display/Banner/Banner.js +17 -0
- package/display/Banner/Banner.tpl.js +3 -0
- package/display/CodeBlock/CodeBlock.css.js +194 -0
- package/display/CodeBlock/CodeBlock.js +220 -0
- package/display/CodeBlock/CodeBlock.tpl.js +11 -0
- package/display/DataTable/DataTable.css.js +101 -0
- package/display/DataTable/DataTable.js +136 -0
- package/display/DataTable/DataTable.tpl.js +13 -0
- package/display/EmptyState/EmptyState.css.js +33 -0
- package/display/EmptyState/EmptyState.js +17 -0
- package/display/EmptyState/EmptyState.tpl.js +3 -0
- package/display/EventFeed/EventFeed.css.js +145 -0
- package/display/EventFeed/EventFeed.js +64 -0
- package/display/EventFeed/EventFeed.tpl.js +14 -0
- package/display/EventFeed/EventFeedItem.js +116 -0
- package/display/EventFeed/EventFeedItem.tpl.js +22 -0
- package/display/LoadingOverlay/LoadingOverlay.css.js +91 -0
- package/display/LoadingOverlay/LoadingOverlay.js +48 -0
- package/display/LoadingOverlay/LoadingOverlay.tpl.js +12 -0
- package/display/Metric/Metric.css.js +60 -0
- package/display/Metric/Metric.js +17 -0
- package/display/Metric/Metric.tpl.js +6 -0
- package/display/OutputGraphPreview/OutputGraphPreview.css.js +122 -0
- package/display/OutputGraphPreview/OutputGraphPreview.js +89 -0
- package/display/OutputGraphPreview/OutputGraphPreview.tpl.js +13 -0
- package/display/OutputListPreview/OutputListPreview.css.js +109 -0
- package/display/OutputListPreview/OutputListPreview.js +77 -0
- package/display/OutputListPreview/OutputListPreview.tpl.js +13 -0
- package/display/SourceEditor/SourceEditor.css.js +39 -0
- package/display/SourceEditor/SourceEditor.js +129 -0
- package/display/SourceEditor/SourceEditor.tpl.js +10 -0
- package/display/SourceViewer/SourceViewer.css.js +80 -0
- package/display/SourceViewer/SourceViewer.js +418 -0
- package/display/SourceViewer/SourceViewer.tpl.js +17 -0
- package/display/StatusRibbon/StatusRibbon.css.js +73 -0
- package/display/StatusRibbon/StatusRibbon.js +87 -0
- package/display/StatusRibbon/StatusRibbon.tpl.js +7 -0
- package/display/event-feed-adapter.js +72 -0
- package/display/format-utils.js +29 -0
- package/display/highlight.js +659 -0
- package/display/icons.js +37 -0
- package/display/markdown-formatter.js +60 -0
- package/display/network-approval-page.js +487 -0
- package/display/output-preview.js +261 -0
- package/effects/CellBg/CellBg.css.js +33 -0
- package/effects/CellBg/CellBg.js +410 -0
- package/effects/CellBg/CellBg.tpl.js +5 -0
- package/graph/canvas-adapter.js +223 -0
- package/graph/graph-algorithms.js +31 -0
- package/graph/index.js +46 -0
- package/graph/model.js +176 -0
- package/graph/project-graph-build.js +66 -0
- package/graph/project-graph-metadata.js +253 -0
- package/graph/project-package.js +128 -0
- package/graph/project-runtime.js +116 -0
- package/graph/project-transaction.js +284 -0
- package/graph/skeleton-utils.js +84 -0
- package/graph/theme-contract.js +36 -0
- package/graph/transaction-parser.js +56 -0
- package/icons/MaterialSymbols.js +69 -0
- package/icons/material-symbols-outlined-400.ttf +0 -0
- package/icons/material-symbols.css +24 -0
- package/index.js +95 -0
- package/inspector/InspectorPanel/InspectorPanel.css.js +375 -0
- package/inspector/InspectorPanel/InspectorPanel.js +368 -0
- package/inspector/InspectorPanel/InspectorPanel.tpl.js +96 -0
- package/inspector/TemplatePreview/TemplatePreview.css.js +104 -0
- package/inspector/TemplatePreview/TemplatePreview.js +145 -0
- package/inspector/TemplatePreview/TemplatePreview.tpl.js +33 -0
- package/interactions/ConnectFlow.js +304 -0
- package/interactions/Drag.js +104 -0
- package/interactions/Selector.js +133 -0
- package/interactions/SnapGrid.js +66 -0
- package/interactions/Zoom.js +139 -0
- package/layout/ActionZone/ActionZone.css.js +88 -0
- package/layout/ActionZone/ActionZone.js +261 -0
- package/layout/ActionZone/ActionZone.tpl.js +11 -0
- package/layout/CrossLayoutPortalBridge/CrossLayoutPortalBridge.js +255 -0
- package/layout/Layout/Layout.css.js +91 -0
- package/layout/Layout/Layout.js +637 -0
- package/layout/Layout/Layout.tpl.js +27 -0
- package/layout/LayoutNode/LayoutNode.css.js +302 -0
- package/layout/LayoutNode/LayoutNode.js +509 -0
- package/layout/LayoutNode/LayoutNode.tpl.js +39 -0
- package/layout/LayoutPreview/LayoutPreview.css.js +46 -0
- package/layout/LayoutPreview/LayoutPreview.js +102 -0
- package/layout/LayoutPreview/LayoutPreview.tpl.js +6 -0
- package/layout/LayoutRouter/LayoutRouter.js +274 -0
- package/layout/LayoutRouter/SectionRegistry.js +135 -0
- package/layout/LayoutRouter/routerSync.js +250 -0
- package/layout/LayoutSidebar/LayoutSidebar.css.js +411 -0
- package/layout/LayoutSidebar/LayoutSidebar.js +368 -0
- package/layout/LayoutSidebar/LayoutSidebar.tpl.js +26 -0
- package/layout/LayoutSidebar/SidebarSection.css.js +20 -0
- package/layout/LayoutSidebar/SidebarSection.js +184 -0
- package/layout/LayoutSidebar/SidebarSection.tpl.js +22 -0
- package/layout/LayoutTree.js +373 -0
- package/layout/PanelMenu/PanelMenu.css.js +43 -0
- package/layout/PanelMenu/PanelMenu.js +95 -0
- package/layout/PanelMenu/PanelMenu.tpl.js +17 -0
- package/layout/ProjectTabs/ProjectTabs.css.js +188 -0
- package/layout/ProjectTabs/ProjectTabs.js +77 -0
- package/layout/ProjectTabs/ProjectTabs.tpl.js +15 -0
- package/layout/index.js +40 -0
- package/list/ListDetailShell/ListDetailShell.css.js +128 -0
- package/list/ListDetailShell/ListDetailShell.js +72 -0
- package/list/ListDetailShell/ListDetailShell.tpl.js +36 -0
- package/list/ListItem/ListItem.css.js +111 -0
- package/list/ListItem/ListItem.js +66 -0
- package/list/ListItem/ListItem.tpl.js +18 -0
- package/locale/index.js +503 -0
- package/manifest/component-registry.js +2446 -0
- package/manifest/graph-schema.js +285 -0
- package/manifest/index.js +6 -0
- package/manifest/project-schema-catalog.js +246 -0
- package/manifest/rule-catalog.js +201 -0
- package/manifest/theme-catalog.js +2149 -0
- package/manifest/ui-schema-catalog.js +334 -0
- package/menu/ContextMenu/ContextMenu.css.js +61 -0
- package/menu/ContextMenu/ContextMenu.js +82 -0
- package/menu/ContextMenu/ContextMenu.tpl.js +19 -0
- package/navigation/QuickOpen/QuickOpen.css.js +92 -0
- package/navigation/QuickOpen/QuickOpen.js +185 -0
- package/navigation/QuickOpen/QuickOpen.tpl.js +15 -0
- package/navigation/quick-open-utils.js +101 -0
- package/node/CtrlItem/CtrlItem.css.js +41 -0
- package/node/CtrlItem/CtrlItem.js +24 -0
- package/node/CtrlItem/CtrlItem.tpl.js +17 -0
- package/node/GraphFrame/GraphFrame.css.js +66 -0
- package/node/GraphFrame/GraphFrame.js +32 -0
- package/node/GraphFrame/GraphFrame.tpl.js +13 -0
- package/node/GraphNode/GraphNode.css.js +815 -0
- package/node/GraphNode/GraphNode.js +173 -0
- package/node/GraphNode/GraphNode.tpl.js +33 -0
- package/node/NodeCallout/NodeCallout.css.js +91 -0
- package/node/NodeCallout/NodeCallout.js +281 -0
- package/node/NodeCallout/NodeCallout.tpl.js +8 -0
- package/node/NodeSocket/NodeSocket.css.js +68 -0
- package/node/NodeSocket/NodeSocket.js +26 -0
- package/node/NodeSocket/NodeSocket.tpl.js +7 -0
- package/node/PortItem/PortItem.css.js +93 -0
- package/node/PortItem/PortItem.js +87 -0
- package/node/PortItem/PortItem.tpl.js +10 -0
- package/package.json +165 -0
- package/palette/PaletteBrowser/PaletteBrowser.css.js +143 -0
- package/palette/PaletteBrowser/PaletteBrowser.js +152 -0
- package/palette/PaletteBrowser/PaletteBrowser.tpl.js +23 -0
- package/plugins/History.js +408 -0
- package/plugins/Readonly.js +60 -0
- package/rules/symbiote-3x.json +170 -0
- package/schemas/component-descriptor-v1.json +91 -0
- package/schemas/component-descriptor-v2.json +145 -0
- package/schemas/graph-model-v1.json +179 -0
- package/schemas/graph-v1.json +91 -0
- package/schemas/project-package-v1.json +102 -0
- package/schemas/project-transaction-v1.json +114 -0
- package/schemas/runtime-ui-v1.json +80 -0
- package/schemas/theme-rule-block-v1.json +73 -0
- package/shapes/CircleShape.js +79 -0
- package/shapes/CommentShape.js +35 -0
- package/shapes/DiamondShape.js +130 -0
- package/shapes/NodeShape.js +79 -0
- package/shapes/PillShape.js +91 -0
- package/shapes/RectShape.js +84 -0
- package/shapes/SVGShape.js +525 -0
- package/shapes/index.js +63 -0
- package/surface/Card/Card.css.js +57 -0
- package/surface/Card/Card.js +17 -0
- package/surface/Card/Card.tpl.js +3 -0
- package/themes/Palette.js +30 -0
- package/themes/Skin.js +113 -0
- package/themes/Theme.js +82 -0
- package/themes/carbon.js +135 -0
- package/themes/dark.js +140 -0
- package/themes/default-dark.js +714 -0
- package/themes/default-provider.css +635 -0
- package/themes/default-provider.js +718 -0
- package/themes/ebook.js +136 -0
- package/themes/grey.js +137 -0
- package/themes/light.js +139 -0
- package/themes/neon.js +138 -0
- package/themes/pcb.js +273 -0
- package/themes/synthwave.js +138 -0
- package/tokens/base.json +29 -0
- package/tokens/themes/carbon.json +11 -0
- package/tokens/themes/dark.json +12 -0
- package/tokens/themes/default-dark.json +1543 -0
- package/tokens/themes/default-provider.json +1543 -0
- package/tokens/themes/ebook.json +11 -0
- package/tokens/themes/grey.json +11 -0
- package/tokens/themes/light.json +12 -0
- package/tokens/themes/neon.json +11 -0
- package/tokens/themes/pcb.json +11 -0
- package/tokens/themes/synthwave.json +11 -0
- package/toolbar/QuickToolbar/QuickToolbar.css.js +152 -0
- package/toolbar/QuickToolbar/QuickToolbar.js +529 -0
- package/toolbar/QuickToolbar/QuickToolbar.tpl.js +34 -0
- package/tree/TreePanel/TreePanel.css.js +112 -0
- package/tree/TreePanel/TreePanel.js +147 -0
- package/tree/TreePanel/TreePanel.tpl.js +18 -0
- package/tree/TreeView/TreeView.css.js +122 -0
- package/tree/TreeView/TreeView.js +365 -0
- package/tree/TreeView/TreeView.tpl.js +10 -0
- package/ui/dialogs.js +221 -0
- package/ui/host-adapters.js +114 -0
- package/ui/index.js +660 -0
- package/ui/locale.js +50 -0
- package/ui/overlay-stack.js +89 -0
- package/ui/shared-styles.js +26 -0
- package/webmcp.js +37 -0
- package/xr/deep-graph.js +646 -0
- package/xr/emulation.js +198 -0
- package/xr/gesture.js +228 -0
- package/xr/html-canvas-renderer.js +472 -0
- package/xr/index.js +15 -0
- package/xr/layout-projection.js +1046 -0
- package/xr/panel-frame.js +128 -0
- package/xr/panel-host.js +267 -0
- package/xr/pointer.js +258 -0
- package/xr/scene-controller.js +242 -0
- package/xr/spatial-scene.js +212 -0
- package/xr/theme-bridge.js +105 -0
- package/xr/three-webxr-adapter.js +3439 -0
- package/xr/webgl-layer-renderer.js +419 -0
- package/xr/webxr.js +679 -0
- package/xr/workbench.js +516 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import Symbiote from '@symbiotejs/symbiote';
|
|
2
|
+
import '../TreeView/TreeView.js';
|
|
3
|
+
import '../../control/Button/Button.js';
|
|
4
|
+
import template from './TreePanel.tpl.js';
|
|
5
|
+
import css from './TreePanel.css.js';
|
|
6
|
+
import { translate } from '../../locale/index.js';
|
|
7
|
+
|
|
8
|
+
function emit(el, type, detail = {}) {
|
|
9
|
+
el.dispatchEvent(new CustomEvent(type, { bubbles: true, composed: true, detail }));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export class TreePanel extends Symbiote {
|
|
13
|
+
init$ = {
|
|
14
|
+
title: '',
|
|
15
|
+
titleIcon: '',
|
|
16
|
+
hideTitle: true,
|
|
17
|
+
placeholder: translate('tree.loading'),
|
|
18
|
+
filterText: '',
|
|
19
|
+
onFilterInput: (event) => {
|
|
20
|
+
this.filterText = event.target.value;
|
|
21
|
+
emit(this, 'sn-tree-panel-filter', { filterText: this.filterText });
|
|
22
|
+
},
|
|
23
|
+
onCollapseAll: () => {
|
|
24
|
+
this.collapseAll();
|
|
25
|
+
emit(this, 'sn-tree-panel-collapse');
|
|
26
|
+
},
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
initCallback() {
|
|
30
|
+
this.#syncAttributes();
|
|
31
|
+
this.#syncInputChrome();
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
get tree() {
|
|
35
|
+
return this.ref.tree;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
get items() {
|
|
39
|
+
return this.tree?.items || [];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
set items(items) {
|
|
43
|
+
this.setItems(items);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
get selectedId() {
|
|
47
|
+
return this.tree?.selectedId || '';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
set selectedId(value) {
|
|
51
|
+
if (this.tree) this.tree.selectedId = value;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
get expandedIds() {
|
|
55
|
+
return this.tree?.expandedIds || [];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
set expandedIds(value) {
|
|
59
|
+
if (this.tree) this.tree.expandedIds = value;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
get defaultExpandedIds() {
|
|
63
|
+
return this.tree?.defaultExpandedIds || [];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
set defaultExpandedIds(value) {
|
|
67
|
+
if (this.tree) this.tree.defaultExpandedIds = value;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
get filterText() {
|
|
71
|
+
return this.$.filterText || '';
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
set filterText(value) {
|
|
75
|
+
let next = String(value || '');
|
|
76
|
+
this.$.filterText = next;
|
|
77
|
+
if (this.ref.filter && this.ref.filter.value !== next) this.ref.filter.value = next;
|
|
78
|
+
if (this.tree) this.tree.filterText = next;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
get storageKey() {
|
|
82
|
+
return this.tree?.storageKey || '';
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
set storageKey(value) {
|
|
86
|
+
if (this.tree) this.tree.storageKey = value;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
get toggleBranchesOnSelect() {
|
|
90
|
+
return this.tree?.toggleBranchesOnSelect || false;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
set toggleBranchesOnSelect(value) {
|
|
94
|
+
if (this.tree) this.tree.toggleBranchesOnSelect = value;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
setItems(items = []) {
|
|
98
|
+
this.tree?.setItems?.(items);
|
|
99
|
+
this.filterText = this.filterText;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
collapseAll() {
|
|
103
|
+
this.tree?.collapseAll?.();
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
expandAncestors(path) {
|
|
107
|
+
return this.tree?.expandAncestors?.(path) || false;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
scrollSelectedIntoView() {
|
|
111
|
+
this.tree?.scrollSelectedIntoView?.();
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
showPlaceholder(message = '') {
|
|
115
|
+
if (message) this.$.placeholder = message;
|
|
116
|
+
if (this.ref.placeholder) this.ref.placeholder.hidden = false;
|
|
117
|
+
if (this.tree) this.tree.hidden = true;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
showTree() {
|
|
121
|
+
if (this.ref.placeholder) this.ref.placeholder.hidden = true;
|
|
122
|
+
if (this.tree) this.tree.hidden = false;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
#syncAttributes() {
|
|
126
|
+
this.$.title = this.getAttribute('title') || '';
|
|
127
|
+
this.$.titleIcon = this.getAttribute('title-icon') || '';
|
|
128
|
+
this.$.hideTitle = !this.$.title && !this.$.titleIcon;
|
|
129
|
+
this.$.placeholder = this.getAttribute('placeholder') || this.$.placeholder;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
#syncInputChrome() {
|
|
133
|
+
if (this.ref.filter) {
|
|
134
|
+
this.ref.filter.placeholder = this.getAttribute('filter-placeholder') || translate('tree.filterPlaceholder');
|
|
135
|
+
this.ref.filter.value = this.filterText;
|
|
136
|
+
}
|
|
137
|
+
if (this.ref.collapseButton) {
|
|
138
|
+
this.ref.collapseButton.title = this.getAttribute('collapse-title') || translate('tree.collapseAll');
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
TreePanel.template = template;
|
|
144
|
+
TreePanel.rootStyles = css;
|
|
145
|
+
TreePanel.reg('sn-tree-panel');
|
|
146
|
+
|
|
147
|
+
export default TreePanel;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { html } from '@symbiotejs/symbiote';
|
|
2
|
+
|
|
3
|
+
export default html`
|
|
4
|
+
<div class="sn-tree-panel-title" ${{ '@hidden': 'hideTitle' }}>
|
|
5
|
+
<span class="material-symbols-outlined sn-tree-panel-title-icon" ${{ textContent: 'titleIcon', '@hidden': '!titleIcon' }}></span>
|
|
6
|
+
<span ${{ textContent: 'title' }}></span>
|
|
7
|
+
</div>
|
|
8
|
+
<div class="sn-tree-panel-toolbar">
|
|
9
|
+
<input class="sn-tree-panel-filter" ref="filter" type="search" ${{ oninput: 'onFilterInput' }}>
|
|
10
|
+
<sn-button class="sn-tree-panel-collapse" ref="collapseButton" variant="icon" ${{ onclick: 'onCollapseAll' }}>
|
|
11
|
+
<span class="material-symbols-outlined sn-tree-panel-toolbar-icon">unfold_less</span>
|
|
12
|
+
</sn-button>
|
|
13
|
+
</div>
|
|
14
|
+
<div class="sn-tree-panel-content">
|
|
15
|
+
<div class="sn-tree-panel-placeholder" ref="placeholder" ${{ textContent: 'placeholder' }}></div>
|
|
16
|
+
<sn-tree-view ref="tree" hidden></sn-tree-view>
|
|
17
|
+
</div>
|
|
18
|
+
`;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
export default /*css*/ `
|
|
2
|
+
:host,
|
|
3
|
+
sn-tree-view {
|
|
4
|
+
display: block;
|
|
5
|
+
color: var(--sn-text);
|
|
6
|
+
font-family: var(--sn-font-family);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
:host([hidden]),
|
|
10
|
+
sn-tree-view[hidden] {
|
|
11
|
+
display: none !important;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.sn-tree-view {
|
|
15
|
+
box-sizing: border-box;
|
|
16
|
+
display: flex;
|
|
17
|
+
flex-direction: column;
|
|
18
|
+
min-width: 0;
|
|
19
|
+
width: 100%;
|
|
20
|
+
outline: none;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.sn-tree-row {
|
|
24
|
+
--sn-tree-depth-indent: 0px;
|
|
25
|
+
box-sizing: border-box;
|
|
26
|
+
display: grid;
|
|
27
|
+
grid-template-columns: var(--sn-tree-toggle-width) var(--sn-tree-icon-width) minmax(0, 1fr) auto auto;
|
|
28
|
+
align-items: center;
|
|
29
|
+
gap: var(--sn-tree-gap);
|
|
30
|
+
min-height: var(--sn-tree-row-min-height, var(--sn-tree-row-height));
|
|
31
|
+
padding-block: var(--sn-tree-row-padding-block);
|
|
32
|
+
padding-inline: var(--sn-tree-depth-indent) 8px;
|
|
33
|
+
border: 1px solid transparent;
|
|
34
|
+
border-radius: var(--sn-tree-row-radius);
|
|
35
|
+
background: var(--sn-tree-row-bg, transparent);
|
|
36
|
+
color: inherit;
|
|
37
|
+
cursor: pointer;
|
|
38
|
+
user-select: none;
|
|
39
|
+
outline: none;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.sn-tree-row:hover {
|
|
43
|
+
background: var(--sn-tree-row-hover-bg, var(--sn-node-hover));
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.sn-tree-row:focus-visible {
|
|
47
|
+
border-color: var(--sn-tree-row-focus-border, var(--sn-node-selected));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.sn-tree-row[aria-selected="true"] {
|
|
51
|
+
background: var(--sn-tree-row-selected-bg, var(--sn-node-bg));
|
|
52
|
+
border-color: var(--sn-tree-row-selected-border, var(--sn-node-selected));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.sn-tree-row[muted] {
|
|
56
|
+
color: var(--sn-tree-muted-color, var(--sn-text-dim));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.sn-tree-toggle,
|
|
60
|
+
.sn-tree-icon {
|
|
61
|
+
display: inline-flex;
|
|
62
|
+
align-items: center;
|
|
63
|
+
justify-content: center;
|
|
64
|
+
width: var(--sn-tree-icon-width);
|
|
65
|
+
height: var(--sn-tree-icon-width);
|
|
66
|
+
color: var(--sn-tree-icon-color, var(--sn-text-dim));
|
|
67
|
+
font-family: var(--sn-icon-font);
|
|
68
|
+
font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 20;
|
|
69
|
+
font-size: var(--sn-tree-icon-size);
|
|
70
|
+
line-height: 1;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
.sn-tree-toggle {
|
|
74
|
+
border: 0;
|
|
75
|
+
padding: 0;
|
|
76
|
+
background: transparent;
|
|
77
|
+
cursor: pointer;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.sn-tree-toggle[hidden] {
|
|
81
|
+
visibility: hidden;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.sn-tree-label {
|
|
85
|
+
min-width: 0;
|
|
86
|
+
overflow: hidden;
|
|
87
|
+
color: var(--sn-tree-label-color, var(--sn-text));
|
|
88
|
+
font-size: var(--sn-tree-label-size);
|
|
89
|
+
font-weight: var(--sn-tree-label-weight);
|
|
90
|
+
text-overflow: ellipsis;
|
|
91
|
+
white-space: nowrap;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
.sn-tree-kind {
|
|
95
|
+
overflow: hidden;
|
|
96
|
+
max-width: var(--sn-tree-kind-max-width);
|
|
97
|
+
color: var(--sn-tree-kind-color, var(--sn-text-dim));
|
|
98
|
+
font-size: var(--sn-tree-kind-size);
|
|
99
|
+
text-overflow: ellipsis;
|
|
100
|
+
white-space: nowrap;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
.sn-tree-badges {
|
|
104
|
+
display: inline-flex;
|
|
105
|
+
align-items: center;
|
|
106
|
+
gap: 4px;
|
|
107
|
+
min-width: 0;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.sn-tree-badge {
|
|
111
|
+
max-width: var(--sn-tree-badge-max-width);
|
|
112
|
+
overflow: hidden;
|
|
113
|
+
padding: 1px 5px;
|
|
114
|
+
border-radius: var(--sn-tree-badge-radius);
|
|
115
|
+
background: var(--sn-tree-badge-bg, var(--sn-node-hover));
|
|
116
|
+
color: var(--sn-tree-badge-color, var(--sn-text-dim));
|
|
117
|
+
font-size: var(--sn-tree-badge-size);
|
|
118
|
+
line-height: 1.35;
|
|
119
|
+
text-overflow: ellipsis;
|
|
120
|
+
white-space: nowrap;
|
|
121
|
+
}
|
|
122
|
+
`;
|
|
@@ -0,0 +1,365 @@
|
|
|
1
|
+
import Symbiote from '@symbiotejs/symbiote';
|
|
2
|
+
import template from './TreeView.tpl.js';
|
|
3
|
+
import css from './TreeView.css.js';
|
|
4
|
+
|
|
5
|
+
function emit(el, type, detail = {}) {
|
|
6
|
+
el.dispatchEvent(new CustomEvent(type, { bubbles: true, composed: true, detail }));
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function escapeCssValue(value = '') {
|
|
10
|
+
if (globalThis.CSS?.escape) return globalThis.CSS.escape(String(value));
|
|
11
|
+
return String(value).replaceAll('\\', '\\\\').replaceAll('"', '\\"');
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
function normalizeBadges(badges = []) {
|
|
15
|
+
if (!Array.isArray(badges)) return [];
|
|
16
|
+
return badges
|
|
17
|
+
.map((badge) => {
|
|
18
|
+
if (badge && typeof badge === 'object') return badge.label || badge.text || badge.value || '';
|
|
19
|
+
return badge;
|
|
20
|
+
})
|
|
21
|
+
.filter((badge) => badge !== null && badge !== undefined && badge !== '');
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function textMatches(item, needle) {
|
|
25
|
+
if (!needle) return true;
|
|
26
|
+
let fields = [item.label, item.kind, item.icon, item.path, item.id, ...normalizeBadges(item.badges)];
|
|
27
|
+
return fields.some((field) => String(field || '').toLowerCase().includes(needle));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function hasStorage() {
|
|
31
|
+
return typeof localStorage !== 'undefined' && localStorage;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function serializeDragPayload(payload) {
|
|
35
|
+
if (payload === null || payload === undefined) return '';
|
|
36
|
+
return typeof payload === 'string' ? payload : JSON.stringify(payload);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function getItemId(item) {
|
|
40
|
+
return String(item?.id || item?.path || '');
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export class TreeView extends Symbiote {
|
|
44
|
+
#items = [];
|
|
45
|
+
#selectedId = '';
|
|
46
|
+
#expandedIds = new Set();
|
|
47
|
+
#defaultExpandedIds = [];
|
|
48
|
+
#expandedIdsLoaded = false;
|
|
49
|
+
#filterText = '';
|
|
50
|
+
#storageKey = '';
|
|
51
|
+
#toggleBranchesOnSelect = false;
|
|
52
|
+
#visibleItems = [];
|
|
53
|
+
|
|
54
|
+
init$ = {
|
|
55
|
+
onTreeClick: (event) => {
|
|
56
|
+
let row = event.target?.closest?.('.sn-tree-row');
|
|
57
|
+
if (!row) return;
|
|
58
|
+
let item = this.#visibleItems[Number(row.dataset.index)];
|
|
59
|
+
if (!item) return;
|
|
60
|
+
|
|
61
|
+
if (event.target?.closest?.('.sn-tree-toggle')) {
|
|
62
|
+
this.#toggleItem(item);
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
this.selectedId = getItemId(item);
|
|
67
|
+
if (this.#toggleBranchesOnSelect && Array.isArray(item.children) && item.children.length > 0) {
|
|
68
|
+
this.#toggleItem(item);
|
|
69
|
+
}
|
|
70
|
+
emit(this, 'sn-tree-select', { item });
|
|
71
|
+
},
|
|
72
|
+
|
|
73
|
+
onTreeKeydown: (event) => {
|
|
74
|
+
if (event.key !== 'Enter' && event.key !== ' ') return;
|
|
75
|
+
let row = event.target?.closest?.('.sn-tree-row');
|
|
76
|
+
if (!row) return;
|
|
77
|
+
event.preventDefault();
|
|
78
|
+
row.click();
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
onTreeDragStart: (event) => {
|
|
82
|
+
let row = event.target?.closest?.('.sn-tree-row');
|
|
83
|
+
if (!row) return;
|
|
84
|
+
let item = this.#visibleItems[Number(row.dataset.index)];
|
|
85
|
+
if (!item?.draggable) {
|
|
86
|
+
event.preventDefault();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
let payload = item.payload ?? item.dragText ?? item.path ?? item.id ?? '';
|
|
90
|
+
if (payload && event.dataTransfer) {
|
|
91
|
+
event.dataTransfer.setData('text/plain', serializeDragPayload(payload));
|
|
92
|
+
event.dataTransfer.effectAllowed = item.dragEffect || 'copy';
|
|
93
|
+
}
|
|
94
|
+
emit(this, 'sn-tree-dragstart', { item, payload, nativeEvent: event });
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
get items() {
|
|
99
|
+
return this.#items;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
set items(items) {
|
|
103
|
+
this.setItems(items);
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
get selectedId() {
|
|
107
|
+
return this.#selectedId;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
set selectedId(value) {
|
|
111
|
+
this.#selectedId = value || '';
|
|
112
|
+
this.#renderTree();
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
get expandedIds() {
|
|
116
|
+
return [...this.#expandedIds];
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
set expandedIds(value) {
|
|
120
|
+
this.#expandedIds = new Set(Array.from(value || []).map(String));
|
|
121
|
+
this.#expandedIdsLoaded = true;
|
|
122
|
+
this.#persistExpandedIds();
|
|
123
|
+
this.#renderTree();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
get defaultExpandedIds() {
|
|
127
|
+
return [...this.#defaultExpandedIds];
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
set defaultExpandedIds(value) {
|
|
131
|
+
this.#defaultExpandedIds = Array.from(value || []).map(String);
|
|
132
|
+
this.#expandedIdsLoaded = false;
|
|
133
|
+
this.#loadExpandedIds();
|
|
134
|
+
this.#renderTree();
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
get filterText() {
|
|
138
|
+
return this.#filterText;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
set filterText(value) {
|
|
142
|
+
this.#filterText = String(value || '');
|
|
143
|
+
this.#renderTree();
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
get storageKey() {
|
|
147
|
+
return this.#storageKey;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
set storageKey(value) {
|
|
151
|
+
this.#storageKey = String(value || '');
|
|
152
|
+
this.#expandedIdsLoaded = false;
|
|
153
|
+
this.#loadExpandedIds();
|
|
154
|
+
this.#renderTree();
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
get toggleBranchesOnSelect() {
|
|
158
|
+
return this.#toggleBranchesOnSelect;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
set toggleBranchesOnSelect(value) {
|
|
162
|
+
this.#toggleBranchesOnSelect = Boolean(value);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
static filterItems(items = [], filterText = '') {
|
|
166
|
+
let needle = String(filterText || '').trim().toLowerCase();
|
|
167
|
+
return TreeView.#filterBranch(Array.isArray(items) ? items : [], needle);
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
static #filterBranch(items, needle) {
|
|
171
|
+
let result = [];
|
|
172
|
+
for (let item of items) {
|
|
173
|
+
if (!item || typeof item !== 'object') continue;
|
|
174
|
+
let children = Array.isArray(item.children) ? item.children : [];
|
|
175
|
+
let filteredChildren = TreeView.#filterBranch(children, needle);
|
|
176
|
+
if (!needle || textMatches(item, needle) || filteredChildren.length > 0) {
|
|
177
|
+
result.push({ item, children: filteredChildren });
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
return result;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
renderCallback() {
|
|
184
|
+
this.#loadExpandedIds();
|
|
185
|
+
this.#renderTree();
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
setItems(items = []) {
|
|
189
|
+
this.#items = Array.isArray(items) ? items : [];
|
|
190
|
+
this.#renderTree();
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
collapseAll() {
|
|
194
|
+
this.#expandedIds.clear();
|
|
195
|
+
this.#persistExpandedIds();
|
|
196
|
+
this.#renderTree();
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
toggleItem(item) {
|
|
200
|
+
if (!item) return;
|
|
201
|
+
this.#toggleItem(item);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
expandAncestors(idOrPath) {
|
|
205
|
+
let target = String(idOrPath || '');
|
|
206
|
+
if (!target) return false;
|
|
207
|
+
let ancestors = [];
|
|
208
|
+
let found = this.#collectAncestors(this.#items, target, ancestors);
|
|
209
|
+
if (!found) return false;
|
|
210
|
+
for (let item of ancestors) {
|
|
211
|
+
let id = getItemId(item);
|
|
212
|
+
if (id) this.#expandedIds.add(id);
|
|
213
|
+
}
|
|
214
|
+
this.#persistExpandedIds();
|
|
215
|
+
this.#renderTree();
|
|
216
|
+
return true;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
scrollSelectedIntoView() {
|
|
220
|
+
if (!this.#selectedId || !this.ref.tree?.querySelector) return;
|
|
221
|
+
let selector = `.sn-tree-row[data-tree-id="${escapeCssValue(this.#selectedId)}"]`;
|
|
222
|
+
this.ref.tree.querySelector(selector)?.scrollIntoView?.({ block: 'nearest' });
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
#toggleItem(item) {
|
|
226
|
+
let id = getItemId(item);
|
|
227
|
+
if (!id) return;
|
|
228
|
+
let expanded = !this.#expandedIds.has(id);
|
|
229
|
+
if (expanded) {
|
|
230
|
+
this.#expandedIds.add(id);
|
|
231
|
+
} else {
|
|
232
|
+
this.#expandedIds.delete(id);
|
|
233
|
+
}
|
|
234
|
+
this.#persistExpandedIds();
|
|
235
|
+
this.#renderTree();
|
|
236
|
+
emit(this, 'sn-tree-toggle', { item, expanded });
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
#collectAncestors(items, target, ancestors) {
|
|
240
|
+
for (let item of items) {
|
|
241
|
+
if (!item || typeof item !== 'object') continue;
|
|
242
|
+
let id = getItemId(item);
|
|
243
|
+
let path = String(item.path || '');
|
|
244
|
+
if (id === target || path === target) return true;
|
|
245
|
+
|
|
246
|
+
let children = Array.isArray(item.children) ? item.children : [];
|
|
247
|
+
ancestors.push(item);
|
|
248
|
+
if (this.#collectAncestors(children, target, ancestors)) return true;
|
|
249
|
+
ancestors.pop();
|
|
250
|
+
}
|
|
251
|
+
return false;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
#loadExpandedIds() {
|
|
255
|
+
if (this.#expandedIdsLoaded) return;
|
|
256
|
+
if (!this.#storageKey || !hasStorage()) {
|
|
257
|
+
this.#expandedIds = new Set(this.#defaultExpandedIds);
|
|
258
|
+
this.#expandedIdsLoaded = true;
|
|
259
|
+
return;
|
|
260
|
+
}
|
|
261
|
+
try {
|
|
262
|
+
let value = localStorage.getItem(this.#storageKey);
|
|
263
|
+
if (!value) {
|
|
264
|
+
this.#expandedIds = new Set(this.#defaultExpandedIds);
|
|
265
|
+
this.#expandedIdsLoaded = true;
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
let ids = JSON.parse(value);
|
|
269
|
+
if (Array.isArray(ids)) {
|
|
270
|
+
this.#expandedIds = new Set(ids.map(String));
|
|
271
|
+
}
|
|
272
|
+
} catch {
|
|
273
|
+
this.#expandedIds = new Set();
|
|
274
|
+
}
|
|
275
|
+
this.#expandedIdsLoaded = true;
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
#persistExpandedIds() {
|
|
279
|
+
if (!this.#storageKey || !hasStorage()) return;
|
|
280
|
+
localStorage.setItem(this.#storageKey, JSON.stringify(this.expandedIds));
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
#getIndentSize() {
|
|
284
|
+
if (typeof getComputedStyle !== 'function') return 16;
|
|
285
|
+
let rawValue = getComputedStyle(this).getPropertyValue('--sn-tree-indent').trim();
|
|
286
|
+
if (!rawValue.endsWith('px')) return 16;
|
|
287
|
+
let size = Number.parseFloat(rawValue);
|
|
288
|
+
return Number.isFinite(size) ? size : 16;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
#renderTree() {
|
|
292
|
+
if (!this.ref.tree) return;
|
|
293
|
+
this.#visibleItems = [];
|
|
294
|
+
let filtered = TreeView.filterItems(this.#items, this.#filterText);
|
|
295
|
+
let nodes = [];
|
|
296
|
+
let indentSize = this.#getIndentSize();
|
|
297
|
+
this.#appendBranches(nodes, filtered, 0, Boolean(this.#filterText.trim()), indentSize);
|
|
298
|
+
this.ref.tree.replaceChildren(...nodes);
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
#appendBranches(parent, branches, depth, forceExpanded, indentSize) {
|
|
302
|
+
for (let { item, children } of branches) {
|
|
303
|
+
let id = getItemId(item);
|
|
304
|
+
let hasChildren = children.length > 0;
|
|
305
|
+
let expanded = forceExpanded || this.#expandedIds.has(id);
|
|
306
|
+
let rowIndex = this.#visibleItems.push(item) - 1;
|
|
307
|
+
let row = document.createElement('div');
|
|
308
|
+
row.className = 'sn-tree-row';
|
|
309
|
+
row.setAttribute('role', 'treeitem');
|
|
310
|
+
row.tabIndex = 0;
|
|
311
|
+
row.dataset.index = String(rowIndex);
|
|
312
|
+
row.dataset.treeId = id;
|
|
313
|
+
row.style.setProperty('--sn-tree-depth', String(depth));
|
|
314
|
+
row.style.setProperty('--sn-tree-depth-indent', `${depth * indentSize}px`);
|
|
315
|
+
row.setAttribute('aria-selected', String(id === this.#selectedId));
|
|
316
|
+
row.setAttribute('aria-expanded', hasChildren ? String(expanded) : 'false');
|
|
317
|
+
row.toggleAttribute('muted', Boolean(item.muted));
|
|
318
|
+
row.draggable = Boolean(item.draggable);
|
|
319
|
+
|
|
320
|
+
let toggle = document.createElement('button');
|
|
321
|
+
toggle.className = 'sn-tree-toggle';
|
|
322
|
+
toggle.type = 'button';
|
|
323
|
+
toggle.hidden = !hasChildren;
|
|
324
|
+
toggle.textContent = expanded ? 'expand_more' : 'chevron_right';
|
|
325
|
+
|
|
326
|
+
let icon = document.createElement('span');
|
|
327
|
+
icon.className = 'sn-tree-icon';
|
|
328
|
+
icon.hidden = !item.icon;
|
|
329
|
+
icon.textContent = item.icon || '';
|
|
330
|
+
|
|
331
|
+
let label = document.createElement('span');
|
|
332
|
+
label.className = 'sn-tree-label';
|
|
333
|
+
label.textContent = item.label || id;
|
|
334
|
+
|
|
335
|
+
let kind = document.createElement('span');
|
|
336
|
+
kind.className = 'sn-tree-kind';
|
|
337
|
+
kind.hidden = !item.kind;
|
|
338
|
+
kind.textContent = item.kind || '';
|
|
339
|
+
|
|
340
|
+
let badges = document.createElement('span');
|
|
341
|
+
badges.className = 'sn-tree-badges';
|
|
342
|
+
let normalizedBadges = normalizeBadges(item.badges);
|
|
343
|
+
badges.hidden = normalizedBadges.length === 0;
|
|
344
|
+
for (let badge of normalizedBadges) {
|
|
345
|
+
let badgeEl = document.createElement('span');
|
|
346
|
+
badgeEl.className = 'sn-tree-badge';
|
|
347
|
+
badgeEl.textContent = badge;
|
|
348
|
+
badges.appendChild(badgeEl);
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
row.append(toggle, icon, label, kind, badges);
|
|
352
|
+
parent.push(row);
|
|
353
|
+
|
|
354
|
+
if (hasChildren && expanded) {
|
|
355
|
+
this.#appendBranches(parent, children, depth + 1, forceExpanded, indentSize);
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
TreeView.template = template;
|
|
362
|
+
TreeView.rootStyles = css;
|
|
363
|
+
TreeView.reg('sn-tree-view');
|
|
364
|
+
|
|
365
|
+
export default TreeView;
|