2022-03-24 15:39:17 +01:00
|
|
|
import * as plugins from '../wcctools.plugins.js';
|
2025-12-11 15:49:04 +00:00
|
|
|
import { DeesElement, property, html, customElement, type TemplateResult, state } from '@design.estate/dees-element';
|
2025-12-28 12:51:55 +00:00
|
|
|
import { WccDashboard, getSectionItems } from './wcc-dashboard.js';
|
2025-09-19 13:02:16 +00:00
|
|
|
import type { TTemplateFactory } from './wcctools.helpers.js';
|
2025-12-11 15:49:04 +00:00
|
|
|
import { getDemoCount, hasMultipleDemos } from './wcctools.helpers.js';
|
2025-12-28 12:51:55 +00:00
|
|
|
import type { IWccSection, TElementType } from '../wcctools.interfaces.js';
|
2020-11-26 02:28:17 +00:00
|
|
|
|
2020-05-11 00:36:58 +00:00
|
|
|
@customElement('wcc-sidebar')
|
2022-03-24 15:39:17 +01:00
|
|
|
export class WccSidebar extends DeesElement {
|
2020-05-11 00:36:58 +00:00
|
|
|
@property({ attribute: false })
|
2025-12-11 11:14:37 +00:00
|
|
|
accessor selectedItem: DeesElement | TTemplateFactory;
|
2020-05-11 00:36:58 +00:00
|
|
|
|
2020-11-26 02:28:17 +00:00
|
|
|
@property({ attribute: false })
|
2025-12-11 11:14:37 +00:00
|
|
|
accessor selectedType: TElementType;
|
2020-11-26 02:28:17 +00:00
|
|
|
|
2020-07-15 19:55:35 +00:00
|
|
|
@property()
|
2025-12-11 11:14:37 +00:00
|
|
|
accessor dashboardRef: WccDashboard;
|
2020-07-15 19:55:35 +00:00
|
|
|
|
2025-07-07 08:48:09 +00:00
|
|
|
@property()
|
2025-12-19 09:08:08 +00:00
|
|
|
accessor isNative: boolean = false;
|
2025-07-07 08:48:09 +00:00
|
|
|
|
2025-12-11 15:49:04 +00:00
|
|
|
// Track which elements are expanded (for multi-demo elements)
|
|
|
|
|
@state()
|
|
|
|
|
accessor expandedElements: Set<string> = new Set();
|
|
|
|
|
|
2025-12-28 12:51:55 +00:00
|
|
|
// Track which sections are collapsed
|
|
|
|
|
@state()
|
|
|
|
|
accessor collapsedSections: Set<string> = new Set();
|
|
|
|
|
|
2025-12-30 12:30:45 +00:00
|
|
|
// Search query for filtering sidebar items
|
|
|
|
|
@property()
|
|
|
|
|
accessor searchQuery: string = '';
|
|
|
|
|
|
2025-12-28 12:51:55 +00:00
|
|
|
private sectionsInitialized = false;
|
|
|
|
|
|
2020-05-11 00:36:58 +00:00
|
|
|
public render(): TemplateResult {
|
|
|
|
|
return html`
|
2025-06-27 20:28:47 +00:00
|
|
|
<link href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined:opsz,wght,FILL,GRAD@20..48,100..700,0..1,-50..200" rel="stylesheet" />
|
2020-05-11 00:36:58 +00:00
|
|
|
<style>
|
|
|
|
|
:host {
|
2025-06-27 20:28:47 +00:00
|
|
|
/* CSS Variables - Always dark theme to match wcc-properties */
|
|
|
|
|
--background: #0a0a0a;
|
|
|
|
|
--foreground: #e5e5e5;
|
|
|
|
|
--card: #0f0f0f;
|
|
|
|
|
--card-foreground: #f0f0f0;
|
|
|
|
|
--muted: #1a1a1a;
|
|
|
|
|
--muted-foreground: #666;
|
|
|
|
|
--accent: #222;
|
|
|
|
|
--accent-foreground: #fff;
|
|
|
|
|
--border: rgba(255, 255, 255, 0.06);
|
|
|
|
|
--input: #141414;
|
|
|
|
|
--primary: #3b82f6;
|
|
|
|
|
--primary-foreground: #fff;
|
|
|
|
|
--ring: #3b82f6;
|
|
|
|
|
--radius: 4px;
|
2025-06-27 20:03:54 +00:00
|
|
|
|
2025-12-19 09:08:08 +00:00
|
|
|
display: ${this.isNative ? 'none' : 'block'};
|
2025-06-27 20:28:47 +00:00
|
|
|
border-right: 1px solid rgba(255, 255, 255, 0.08);
|
|
|
|
|
font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
|
2025-06-27 20:03:54 +00:00
|
|
|
font-size: 14px;
|
2020-05-11 00:36:58 +00:00
|
|
|
box-sizing: border-box;
|
|
|
|
|
position: absolute;
|
|
|
|
|
left: 0px;
|
|
|
|
|
width: 200px;
|
|
|
|
|
top: 0px;
|
|
|
|
|
bottom: 0px;
|
2025-06-27 20:03:54 +00:00
|
|
|
overflow-y: auto;
|
2020-05-11 00:36:58 +00:00
|
|
|
overflow-x: hidden;
|
2025-06-27 20:28:47 +00:00
|
|
|
background: var(--background);
|
2025-06-27 20:03:54 +00:00
|
|
|
color: var(--foreground);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.menu {
|
2025-06-27 20:28:47 +00:00
|
|
|
padding: 0.5rem 0;
|
2025-06-27 20:03:54 +00:00
|
|
|
}
|
|
|
|
|
|
2025-12-28 12:51:55 +00:00
|
|
|
.section-header {
|
2025-06-27 20:28:47 +00:00
|
|
|
padding: 0.3rem 0.75rem;
|
|
|
|
|
font-size: 0.65rem;
|
|
|
|
|
font-weight: 500;
|
2025-06-27 20:03:54 +00:00
|
|
|
text-transform: uppercase;
|
2025-06-27 20:28:47 +00:00
|
|
|
letter-spacing: 0.08em;
|
|
|
|
|
color: #888;
|
2025-06-27 20:03:54 +00:00
|
|
|
margin: 0;
|
2025-06-27 20:28:47 +00:00
|
|
|
margin-top: 0.5rem;
|
|
|
|
|
background: rgba(59, 130, 246, 0.03);
|
|
|
|
|
border-bottom: 1px solid var(--border);
|
|
|
|
|
border-top: 1px solid var(--border);
|
2025-12-28 12:51:55 +00:00
|
|
|
display: flex;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 0.5rem;
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
user-select: none;
|
|
|
|
|
transition: all 0.15s ease;
|
2025-06-27 20:03:54 +00:00
|
|
|
}
|
|
|
|
|
|
2025-12-28 12:51:55 +00:00
|
|
|
.section-header:first-child {
|
2025-06-27 20:03:54 +00:00
|
|
|
margin-top: 0;
|
2020-05-11 00:36:58 +00:00
|
|
|
}
|
|
|
|
|
|
2025-12-28 12:51:55 +00:00
|
|
|
.section-header:hover {
|
|
|
|
|
background: rgba(59, 130, 246, 0.08);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.section-header .expand-icon {
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
opacity: 0.5;
|
|
|
|
|
transition: transform 0.2s ease;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.section-header.collapsed .expand-icon {
|
|
|
|
|
transform: rotate(-90deg);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.section-header .section-icon {
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
opacity: 0.6;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.section-content {
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.section-content.collapsed {
|
|
|
|
|
display: none;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-07 14:05:25 +01:00
|
|
|
.material-symbols-outlined {
|
|
|
|
|
font-family: 'Material Symbols Outlined';
|
|
|
|
|
font-weight: normal;
|
|
|
|
|
font-style: normal;
|
2025-06-27 20:28:47 +00:00
|
|
|
font-size: 16px;
|
2023-01-07 14:05:25 +01:00
|
|
|
display: inline-block;
|
|
|
|
|
line-height: 1;
|
|
|
|
|
text-transform: none;
|
|
|
|
|
letter-spacing: normal;
|
|
|
|
|
word-wrap: normal;
|
|
|
|
|
white-space: nowrap;
|
|
|
|
|
direction: ltr;
|
2025-06-27 20:03:54 +00:00
|
|
|
font-variation-settings: 'FILL' 0, 'wght' 300, 'GRAD' 0, 'opsz' 24;
|
2025-06-27 20:28:47 +00:00
|
|
|
opacity: 0.5;
|
2023-01-07 14:05:25 +01:00
|
|
|
}
|
|
|
|
|
|
2020-05-11 00:36:58 +00:00
|
|
|
.selectOption {
|
2023-12-10 16:20:31 +01:00
|
|
|
user-select: none;
|
2020-05-11 00:36:58 +00:00
|
|
|
position: relative;
|
2025-06-27 20:28:47 +00:00
|
|
|
margin: 0.125rem 0.5rem;
|
|
|
|
|
padding: 0.5rem 0.75rem;
|
2025-06-27 20:03:54 +00:00
|
|
|
transition: all 0.15s ease;
|
2020-05-11 00:36:58 +00:00
|
|
|
display: grid;
|
2025-06-27 20:28:47 +00:00
|
|
|
grid-template-columns: 20px 1fr;
|
2025-06-27 20:03:54 +00:00
|
|
|
align-items: center;
|
2025-06-27 20:28:47 +00:00
|
|
|
gap: 0.5rem;
|
|
|
|
|
border-radius: var(--radius);
|
2025-06-27 20:03:54 +00:00
|
|
|
cursor: pointer;
|
2025-06-27 20:28:47 +00:00
|
|
|
font-size: 0.75rem;
|
|
|
|
|
color: #999;
|
|
|
|
|
background: transparent;
|
2020-05-11 00:36:58 +00:00
|
|
|
}
|
2025-12-11 15:49:04 +00:00
|
|
|
|
|
|
|
|
.selectOption.folder {
|
|
|
|
|
grid-template-columns: 16px 20px 1fr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.selectOption .expand-icon {
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
opacity: 0.5;
|
|
|
|
|
transition: transform 0.2s ease;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.selectOption.expanded .expand-icon {
|
|
|
|
|
transform: rotate(90deg);
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-11 00:36:58 +00:00
|
|
|
.selectOption:hover {
|
2025-06-27 20:28:47 +00:00
|
|
|
background: rgba(59, 130, 246, 0.05);
|
|
|
|
|
color: #bbb;
|
2025-06-27 20:03:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.selectOption:hover .material-symbols-outlined {
|
2025-06-27 20:28:47 +00:00
|
|
|
opacity: 0.7;
|
2020-05-11 00:36:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.selectOption.selected {
|
2025-06-27 20:28:47 +00:00
|
|
|
background: rgba(59, 130, 246, 0.15);
|
|
|
|
|
color: var(--primary);
|
2025-06-27 20:03:54 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.selectOption.selected .material-symbols-outlined {
|
|
|
|
|
opacity: 1;
|
|
|
|
|
font-variation-settings: 'FILL' 1, 'wght' 400, 'GRAD' 0, 'opsz' 24;
|
2020-05-11 00:36:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.selectOption.selected:hover {
|
2025-06-27 20:28:47 +00:00
|
|
|
background: rgba(59, 130, 246, 0.2);
|
|
|
|
|
color: var(--primary);
|
2020-05-11 00:36:58 +00:00
|
|
|
}
|
|
|
|
|
|
2025-06-27 20:03:54 +00:00
|
|
|
.selectOption .text {
|
2020-05-11 00:36:58 +00:00
|
|
|
display: block;
|
2025-06-27 20:03:54 +00:00
|
|
|
overflow: hidden;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
white-space: nowrap;
|
2025-06-27 20:28:47 +00:00
|
|
|
font-weight: 400;
|
2020-05-11 00:36:58 +00:00
|
|
|
}
|
|
|
|
|
|
2025-12-11 15:49:04 +00:00
|
|
|
.demo-children {
|
|
|
|
|
margin-left: 1rem;
|
|
|
|
|
overflow: hidden;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.demo-child {
|
|
|
|
|
user-select: none;
|
|
|
|
|
position: relative;
|
|
|
|
|
margin: 0.125rem 0.5rem;
|
|
|
|
|
padding: 0.35rem 0.75rem;
|
|
|
|
|
transition: all 0.15s ease;
|
|
|
|
|
display: grid;
|
|
|
|
|
grid-template-columns: 16px 1fr;
|
|
|
|
|
align-items: center;
|
|
|
|
|
gap: 0.5rem;
|
|
|
|
|
border-radius: var(--radius);
|
|
|
|
|
cursor: pointer;
|
|
|
|
|
font-size: 0.7rem;
|
|
|
|
|
color: #777;
|
|
|
|
|
background: transparent;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.demo-child:hover {
|
|
|
|
|
background: rgba(59, 130, 246, 0.05);
|
|
|
|
|
color: #bbb;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.demo-child.selected {
|
|
|
|
|
background: rgba(59, 130, 246, 0.15);
|
|
|
|
|
color: var(--primary);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.demo-child .material-symbols-outlined {
|
|
|
|
|
font-size: 14px;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-27 20:03:54 +00:00
|
|
|
::-webkit-scrollbar {
|
|
|
|
|
width: 8px;
|
2020-05-11 00:36:58 +00:00
|
|
|
}
|
|
|
|
|
|
2025-06-27 20:03:54 +00:00
|
|
|
::-webkit-scrollbar-track {
|
|
|
|
|
background: transparent;
|
2020-05-11 00:36:58 +00:00
|
|
|
}
|
|
|
|
|
|
2025-06-27 20:03:54 +00:00
|
|
|
::-webkit-scrollbar-thumb {
|
2025-06-27 20:28:47 +00:00
|
|
|
background: rgba(255, 255, 255, 0.1);
|
2025-06-27 20:03:54 +00:00
|
|
|
border-radius: 4px;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
::-webkit-scrollbar-thumb:hover {
|
2025-06-27 20:28:47 +00:00
|
|
|
background: rgba(255, 255, 255, 0.2);
|
2025-06-27 20:03:54 +00:00
|
|
|
}
|
2025-12-30 12:30:45 +00:00
|
|
|
|
|
|
|
|
.search-container {
|
|
|
|
|
padding: 0.5rem;
|
|
|
|
|
border-bottom: 1px solid var(--border);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.search-input {
|
|
|
|
|
width: 100%;
|
|
|
|
|
box-sizing: border-box;
|
|
|
|
|
background: var(--input);
|
|
|
|
|
border: 1px solid var(--border);
|
|
|
|
|
border-radius: var(--radius);
|
|
|
|
|
padding: 0.5rem 0.75rem;
|
|
|
|
|
color: var(--foreground);
|
|
|
|
|
font-size: 0.75rem;
|
|
|
|
|
font-family: inherit;
|
|
|
|
|
outline: none;
|
|
|
|
|
transition: border-color 0.15s ease;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.search-input:focus {
|
|
|
|
|
border-color: var(--primary);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.search-input::placeholder {
|
|
|
|
|
color: var(--muted-foreground);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.highlight {
|
|
|
|
|
background: rgba(59, 130, 246, 0.3);
|
|
|
|
|
border-radius: 2px;
|
|
|
|
|
}
|
2020-05-11 00:36:58 +00:00
|
|
|
</style>
|
2025-12-30 12:30:45 +00:00
|
|
|
<div class="search-container">
|
|
|
|
|
<input
|
|
|
|
|
type="text"
|
|
|
|
|
class="search-input"
|
|
|
|
|
placeholder="Search..."
|
|
|
|
|
.value=${this.searchQuery}
|
|
|
|
|
@input=${this.handleSearchInput}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2020-05-11 00:36:58 +00:00
|
|
|
<div class="menu">
|
2025-12-28 12:51:55 +00:00
|
|
|
${this.renderSections()}
|
2023-10-08 13:11:00 +02:00
|
|
|
</div>
|
2020-05-11 00:36:58 +00:00
|
|
|
`;
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-28 12:51:55 +00:00
|
|
|
/**
|
|
|
|
|
* Initialize collapsed sections from section config
|
|
|
|
|
*/
|
|
|
|
|
private initCollapsedSections() {
|
|
|
|
|
if (this.sectionsInitialized) return;
|
|
|
|
|
|
|
|
|
|
const collapsed = new Set<string>();
|
|
|
|
|
for (const section of this.dashboardRef.sections) {
|
|
|
|
|
if (section.collapsed) {
|
|
|
|
|
collapsed.add(section.name);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
this.collapsedSections = collapsed;
|
|
|
|
|
this.sectionsInitialized = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Render all sections
|
|
|
|
|
*/
|
|
|
|
|
private renderSections() {
|
|
|
|
|
this.initCollapsedSections();
|
|
|
|
|
|
|
|
|
|
return this.dashboardRef.sections.map((section, index) => {
|
2025-12-30 12:30:45 +00:00
|
|
|
// Check if section has any matching items
|
|
|
|
|
const entries = getSectionItems(section);
|
|
|
|
|
const filteredEntries = entries.filter(([name]) => this.matchesSearch(name));
|
|
|
|
|
|
|
|
|
|
// Hide section if no items match the search
|
|
|
|
|
if (filteredEntries.length === 0 && this.searchQuery) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-28 12:51:55 +00:00
|
|
|
const isCollapsed = this.collapsedSections.has(section.name);
|
|
|
|
|
const sectionIcon = section.icon || (section.type === 'pages' ? 'insert_drive_file' : 'widgets');
|
|
|
|
|
|
|
|
|
|
return html`
|
|
|
|
|
<div
|
|
|
|
|
class="section-header ${isCollapsed ? 'collapsed' : ''}"
|
|
|
|
|
@click=${() => this.toggleSectionCollapsed(section.name)}
|
|
|
|
|
>
|
|
|
|
|
<i class="material-symbols-outlined expand-icon">expand_more</i>
|
|
|
|
|
${section.icon ? html`<i class="material-symbols-outlined section-icon">${section.icon}</i>` : null}
|
|
|
|
|
<span>${section.name}</span>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="section-content ${isCollapsed ? 'collapsed' : ''}">
|
|
|
|
|
${this.renderSectionItems(section)}
|
|
|
|
|
</div>
|
|
|
|
|
`;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Render items for a section
|
|
|
|
|
*/
|
|
|
|
|
private renderSectionItems(section: IWccSection) {
|
|
|
|
|
const entries = getSectionItems(section);
|
2025-12-30 12:30:45 +00:00
|
|
|
// Filter entries by search query
|
|
|
|
|
const filteredEntries = entries.filter(([name]) => this.matchesSearch(name));
|
2025-12-28 12:51:55 +00:00
|
|
|
|
|
|
|
|
if (section.type === 'pages') {
|
2025-12-30 12:30:45 +00:00
|
|
|
return filteredEntries.map(([pageName, item]) => {
|
2025-12-28 12:51:55 +00:00
|
|
|
return html`
|
|
|
|
|
<div
|
|
|
|
|
class="selectOption ${this.selectedItem === item ? 'selected' : ''}"
|
|
|
|
|
@click=${async () => {
|
|
|
|
|
await plugins.deesDomtools.DomTools.setupDomTools();
|
|
|
|
|
this.selectItem('page', pageName, item, 0, section);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<i class="material-symbols-outlined">insert_drive_file</i>
|
2025-12-30 12:30:45 +00:00
|
|
|
<div class="text">${this.highlightMatch(pageName)}</div>
|
2025-12-28 12:51:55 +00:00
|
|
|
</div>
|
|
|
|
|
`;
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
// type === 'elements'
|
2025-12-30 12:30:45 +00:00
|
|
|
return filteredEntries.map(([elementName, item]) => {
|
2025-12-28 12:51:55 +00:00
|
|
|
const anonItem = item as any;
|
|
|
|
|
const demoCount = anonItem.demo ? getDemoCount(anonItem.demo) : 0;
|
|
|
|
|
const isMultiDemo = anonItem.demo && hasMultipleDemos(anonItem.demo);
|
|
|
|
|
const isExpanded = this.expandedElements.has(elementName);
|
|
|
|
|
const isSelected = this.selectedItem === item;
|
|
|
|
|
|
|
|
|
|
if (isMultiDemo) {
|
|
|
|
|
// Multi-demo element - render as expandable folder
|
|
|
|
|
return html`
|
|
|
|
|
<div
|
|
|
|
|
class="selectOption folder ${isExpanded ? 'expanded' : ''} ${isSelected ? 'selected' : ''}"
|
|
|
|
|
@click=${() => this.toggleExpanded(elementName)}
|
|
|
|
|
>
|
|
|
|
|
<i class="material-symbols-outlined expand-icon">chevron_right</i>
|
|
|
|
|
<i class="material-symbols-outlined">folder</i>
|
2025-12-30 12:30:45 +00:00
|
|
|
<div class="text">${this.highlightMatch(elementName)}</div>
|
2025-12-28 12:51:55 +00:00
|
|
|
</div>
|
|
|
|
|
${isExpanded ? html`
|
|
|
|
|
<div class="demo-children">
|
|
|
|
|
${Array.from({ length: demoCount }, (_, i) => {
|
|
|
|
|
const demoIndex = i;
|
|
|
|
|
const isThisDemoSelected = isSelected && this.dashboardRef.selectedDemoIndex === demoIndex;
|
|
|
|
|
return html`
|
|
|
|
|
<div
|
|
|
|
|
class="demo-child ${isThisDemoSelected ? 'selected' : ''}"
|
|
|
|
|
@click=${async () => {
|
|
|
|
|
await plugins.deesDomtools.DomTools.setupDomTools();
|
|
|
|
|
this.selectItem('element', elementName, item, demoIndex, section);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<i class="material-symbols-outlined">play_circle</i>
|
|
|
|
|
<div class="text">demo${demoIndex + 1}</div>
|
|
|
|
|
</div>
|
|
|
|
|
`;
|
|
|
|
|
})}
|
|
|
|
|
</div>
|
|
|
|
|
` : null}
|
|
|
|
|
`;
|
|
|
|
|
} else {
|
|
|
|
|
// Single demo element
|
|
|
|
|
return html`
|
|
|
|
|
<div
|
|
|
|
|
class="selectOption ${isSelected ? 'selected' : ''}"
|
|
|
|
|
@click=${async () => {
|
|
|
|
|
await plugins.deesDomtools.DomTools.setupDomTools();
|
|
|
|
|
this.selectItem('element', elementName, item, 0, section);
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<i class="material-symbols-outlined">featured_video</i>
|
2025-12-30 12:30:45 +00:00
|
|
|
<div class="text">${this.highlightMatch(elementName)}</div>
|
2025-12-28 12:51:55 +00:00
|
|
|
</div>
|
|
|
|
|
`;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private toggleSectionCollapsed(sectionName: string) {
|
|
|
|
|
const newSet = new Set(this.collapsedSections);
|
|
|
|
|
if (newSet.has(sectionName)) {
|
|
|
|
|
newSet.delete(sectionName);
|
|
|
|
|
} else {
|
|
|
|
|
newSet.add(sectionName);
|
|
|
|
|
}
|
|
|
|
|
this.collapsedSections = newSet;
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-11 15:49:04 +00:00
|
|
|
private toggleExpanded(elementName: string) {
|
|
|
|
|
const newSet = new Set(this.expandedElements);
|
|
|
|
|
if (newSet.has(elementName)) {
|
|
|
|
|
newSet.delete(elementName);
|
|
|
|
|
} else {
|
|
|
|
|
newSet.add(elementName);
|
|
|
|
|
}
|
|
|
|
|
this.expandedElements = newSet;
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-30 12:30:45 +00:00
|
|
|
private handleSearchInput(e: Event) {
|
|
|
|
|
const input = e.target as HTMLInputElement;
|
|
|
|
|
this.searchQuery = input.value;
|
|
|
|
|
this.dispatchEvent(new CustomEvent('searchChanged', { detail: this.searchQuery }));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private matchesSearch(name: string): boolean {
|
|
|
|
|
if (!this.searchQuery) return true;
|
|
|
|
|
return name.toLowerCase().includes(this.searchQuery.toLowerCase());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private highlightMatch(text: string): TemplateResult {
|
|
|
|
|
if (!this.searchQuery) return html`${text}`;
|
|
|
|
|
const lowerText = text.toLowerCase();
|
|
|
|
|
const lowerQuery = this.searchQuery.toLowerCase();
|
|
|
|
|
const index = lowerText.indexOf(lowerQuery);
|
|
|
|
|
if (index === -1) return html`${text}`;
|
|
|
|
|
const before = text.slice(0, index);
|
|
|
|
|
const match = text.slice(index, index + this.searchQuery.length);
|
|
|
|
|
const after = text.slice(index + this.searchQuery.length);
|
|
|
|
|
return html`${before}<span class="highlight">${match}</span>${after}`;
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-22 10:49:02 +00:00
|
|
|
protected updated(changedProperties: Map<string, unknown>) {
|
|
|
|
|
super.updated(changedProperties);
|
|
|
|
|
|
|
|
|
|
// Auto-expand folder when a multi-demo element is selected
|
|
|
|
|
if (changedProperties.has('selectedItem') && this.selectedItem) {
|
2025-12-28 12:51:55 +00:00
|
|
|
// Find the element in any section
|
|
|
|
|
for (const section of this.dashboardRef.sections) {
|
|
|
|
|
if (section.type !== 'elements') continue;
|
|
|
|
|
|
|
|
|
|
const entries = getSectionItems(section);
|
|
|
|
|
const found = entries.find(([_, item]) => item === this.selectedItem);
|
|
|
|
|
if (found) {
|
|
|
|
|
const [elementName, item] = found;
|
|
|
|
|
const anonItem = item as any;
|
|
|
|
|
if (anonItem.demo && hasMultipleDemos(anonItem.demo)) {
|
|
|
|
|
if (!this.expandedElements.has(elementName)) {
|
|
|
|
|
const newSet = new Set(this.expandedElements);
|
|
|
|
|
newSet.add(elementName);
|
|
|
|
|
this.expandedElements = newSet;
|
|
|
|
|
}
|
2025-12-22 10:49:02 +00:00
|
|
|
}
|
2025-12-28 12:51:55 +00:00
|
|
|
break;
|
2025-12-22 10:49:02 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-28 12:51:55 +00:00
|
|
|
public selectItem(
|
|
|
|
|
typeArg: TElementType,
|
|
|
|
|
itemNameArg: string,
|
|
|
|
|
itemArg: TTemplateFactory | DeesElement,
|
|
|
|
|
demoIndex: number = 0,
|
|
|
|
|
section?: IWccSection
|
|
|
|
|
) {
|
2020-05-11 00:36:58 +00:00
|
|
|
console.log('selected item');
|
2020-11-27 16:40:38 +00:00
|
|
|
console.log(itemNameArg);
|
|
|
|
|
console.log(itemArg);
|
2025-12-11 15:49:04 +00:00
|
|
|
console.log('demo index:', demoIndex);
|
2025-12-28 12:51:55 +00:00
|
|
|
console.log('section:', section?.name);
|
|
|
|
|
|
2020-11-26 02:28:17 +00:00
|
|
|
this.selectedItem = itemArg;
|
|
|
|
|
this.selectedType = typeArg;
|
2025-12-11 15:49:04 +00:00
|
|
|
this.dashboardRef.selectedDemoIndex = demoIndex;
|
2025-12-28 12:51:55 +00:00
|
|
|
|
|
|
|
|
// Set the selected section on dashboard
|
|
|
|
|
if (section) {
|
|
|
|
|
this.dashboardRef.selectedSection = section;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-11 00:36:58 +00:00
|
|
|
this.dispatchEvent(
|
2020-11-27 15:59:18 +00:00
|
|
|
new CustomEvent('selectedType', {
|
|
|
|
|
detail: typeArg
|
2020-11-26 02:28:17 +00:00
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
this.dispatchEvent(
|
2020-11-27 15:59:18 +00:00
|
|
|
new CustomEvent('selectedItemName', {
|
|
|
|
|
detail: itemNameArg
|
|
|
|
|
})
|
|
|
|
|
);
|
|
|
|
|
this.dispatchEvent(
|
|
|
|
|
new CustomEvent('selectedItem', {
|
|
|
|
|
detail: itemArg
|
2020-05-11 00:36:58 +00:00
|
|
|
})
|
|
|
|
|
);
|
2025-12-11 15:49:04 +00:00
|
|
|
|
2020-11-26 02:28:17 +00:00
|
|
|
this.dashboardRef.buildUrl();
|
2025-12-11 19:02:02 +00:00
|
|
|
|
|
|
|
|
// Force re-render to update demo child selection indicator
|
|
|
|
|
this.requestUpdate();
|
2020-05-11 00:36:58 +00:00
|
|
|
}
|
|
|
|
|
}
|