2025-12-08 12:04:01 +00:00
|
|
|
import * as interfaces from '../../interfaces/index.js';
|
2024-01-24 12:18:37 +01:00
|
|
|
|
|
|
|
|
import {
|
|
|
|
|
DeesElement,
|
|
|
|
|
type TemplateResult,
|
|
|
|
|
property,
|
|
|
|
|
customElement,
|
|
|
|
|
html,
|
|
|
|
|
css,
|
|
|
|
|
cssManager,
|
|
|
|
|
} from '@design.estate/dees-element';
|
|
|
|
|
|
|
|
|
|
import * as domtools from '@design.estate/dees-domtools';
|
2025-12-06 13:54:17 +00:00
|
|
|
import '../dees-appui-tabs/dees-appui-tabs.js';
|
Refactor import paths for consistency and clarity across multiple components
- Updated import paths in dees-panel, dees-pdf, dees-progressbar, dees-searchbar, dees-shopping-productcard, dees-simple-appdash, dees-speechbubble, dees-statsgrid, dees-table, dees-toast, dees-updater, and dees-windowlayer to use consistent directory structure.
- Created index.ts files for various components to streamline imports and improve modularity.
- Ensured all imports point to the correct subdirectory structure, enhancing maintainability and readability of the codebase.
2025-12-05 10:19:37 +00:00
|
|
|
import type { DeesAppuiTabs } from '../dees-appui-tabs/dees-appui-tabs.js';
|
2025-12-29 01:20:24 +00:00
|
|
|
import { themeDefaultStyles } from '../../00theme.js';
|
2024-01-24 12:18:37 +01:00
|
|
|
|
|
|
|
|
@customElement('dees-appui-maincontent')
|
|
|
|
|
export class DeesAppuiMaincontent extends DeesElement {
|
2025-06-17 08:41:36 +00:00
|
|
|
public static demo = () => html`
|
|
|
|
|
<dees-appui-maincontent
|
|
|
|
|
.tabs=${[
|
2025-06-27 22:55:20 +00:00
|
|
|
{ key: 'Overview', iconName: 'lucide:home', action: () => console.log('Overview') },
|
|
|
|
|
{ key: 'Details', iconName: 'lucide:file', action: () => console.log('Details') },
|
|
|
|
|
{ key: 'Settings', iconName: 'lucide:settings', action: () => console.log('Settings') },
|
2025-06-17 08:41:36 +00:00
|
|
|
]}
|
|
|
|
|
>
|
|
|
|
|
<div slot="content" style="padding: 40px; color: #ccc;">
|
|
|
|
|
<h1>Main Content Area</h1>
|
|
|
|
|
<p>This is where your application content goes.</p>
|
|
|
|
|
</div>
|
|
|
|
|
</dees-appui-maincontent>
|
|
|
|
|
`;
|
2026-01-04 17:09:18 +00:00
|
|
|
public static demoGroup = 'App UI';
|
2024-01-24 12:18:37 +01:00
|
|
|
|
|
|
|
|
// INSTANCE
|
|
|
|
|
@property({
|
|
|
|
|
type: Array,
|
|
|
|
|
})
|
2025-12-29 01:20:24 +00:00
|
|
|
accessor tabs: interfaces.IMenuItem[] = [
|
2025-06-17 08:41:36 +00:00
|
|
|
{ key: '⚠️ Please set tabs', action: () => console.warn('No tabs configured for maincontent') },
|
2024-01-24 12:18:37 +01:00
|
|
|
];
|
|
|
|
|
|
2025-06-17 08:41:36 +00:00
|
|
|
@property({ type: Object })
|
2025-12-29 01:20:24 +00:00
|
|
|
accessor selectedTab: interfaces.IMenuItem | null = null;
|
2024-01-24 12:18:37 +01:00
|
|
|
|
2025-12-29 02:55:03 +00:00
|
|
|
@property({ type: Boolean })
|
|
|
|
|
accessor showTabs: boolean = true;
|
|
|
|
|
|
2025-12-29 23:33:38 +00:00
|
|
|
@property({ type: Boolean })
|
|
|
|
|
accessor tabsAutoHide: boolean = false;
|
|
|
|
|
|
|
|
|
|
@property({ type: Number })
|
|
|
|
|
accessor tabsAutoHideThreshold: number = 0;
|
|
|
|
|
|
2024-01-24 12:18:37 +01:00
|
|
|
public static styles = [
|
2025-12-29 01:20:24 +00:00
|
|
|
themeDefaultStyles,
|
2024-01-24 12:18:37 +01:00
|
|
|
cssManager.defaultStyles,
|
|
|
|
|
css`
|
2025-12-29 01:20:24 +00:00
|
|
|
/* TODO: Migrate hardcoded values to --dees-* CSS variables */
|
2024-01-24 12:18:37 +01:00
|
|
|
:host {
|
2025-06-17 08:58:47 +00:00
|
|
|
color: ${cssManager.bdTheme('#333', '#fff')};
|
2025-12-29 11:44:16 +00:00
|
|
|
display: grid;
|
|
|
|
|
grid-template-rows: auto 1fr;
|
2024-01-24 12:18:37 +01:00
|
|
|
width: 100%;
|
|
|
|
|
height: 100%;
|
2025-06-17 08:58:47 +00:00
|
|
|
background: ${cssManager.bdTheme('#ffffff', '#161616')};
|
2024-01-24 12:18:37 +01:00
|
|
|
}
|
2025-12-29 11:44:16 +00:00
|
|
|
|
2024-01-24 12:18:37 +01:00
|
|
|
.maincontainer {
|
2025-12-29 11:44:16 +00:00
|
|
|
display: contents;
|
2024-01-24 12:18:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.topbar {
|
2025-12-29 11:44:16 +00:00
|
|
|
display: grid;
|
|
|
|
|
grid-template-rows: 1fr;
|
|
|
|
|
overflow: hidden;
|
2024-01-24 12:18:37 +01:00
|
|
|
user-select: none;
|
2025-12-29 11:44:16 +00:00
|
|
|
transition: grid-template-rows 0.3s ease;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.topbar > * {
|
|
|
|
|
min-height: 0;
|
2024-01-24 12:18:37 +01:00
|
|
|
}
|
|
|
|
|
|
2025-06-17 08:41:36 +00:00
|
|
|
.content-area {
|
|
|
|
|
overflow: auto;
|
2025-12-29 11:44:16 +00:00
|
|
|
min-height: 0;
|
2026-01-03 01:58:19 +00:00
|
|
|
overscroll-behavior: contain;
|
2024-01-24 12:18:37 +01:00
|
|
|
}
|
2025-12-29 02:55:03 +00:00
|
|
|
|
|
|
|
|
:host([notabs]) .topbar {
|
2025-12-29 11:44:16 +00:00
|
|
|
grid-template-rows: 0fr;
|
2025-12-29 02:55:03 +00:00
|
|
|
}
|
2024-01-24 12:18:37 +01:00
|
|
|
`,
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
public render(): TemplateResult {
|
|
|
|
|
return html`
|
|
|
|
|
<div class="maincontainer">
|
|
|
|
|
<div class="topbar">
|
2025-06-17 08:41:36 +00:00
|
|
|
<dees-appui-tabs
|
|
|
|
|
.tabs=${this.tabs}
|
|
|
|
|
.selectedTab=${this.selectedTab}
|
|
|
|
|
.showTabIndicator=${true}
|
|
|
|
|
.tabStyle=${'horizontal'}
|
2025-12-29 23:33:38 +00:00
|
|
|
.autoHide=${this.tabsAutoHide}
|
|
|
|
|
.autoHideThreshold=${this.tabsAutoHideThreshold}
|
2025-06-17 08:41:36 +00:00
|
|
|
@tab-select=${(e: CustomEvent) => this.handleTabSelect(e)}
|
2025-12-29 23:33:38 +00:00
|
|
|
@tab-close=${(e: CustomEvent) => this.handleTabClose(e)}
|
2025-06-17 08:41:36 +00:00
|
|
|
></dees-appui-tabs>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="content-area">
|
|
|
|
|
<slot></slot>
|
|
|
|
|
<slot name="content"></slot>
|
2024-01-24 12:18:37 +01:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
`;
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-17 08:41:36 +00:00
|
|
|
private handleTabSelect(e: CustomEvent) {
|
|
|
|
|
this.selectedTab = e.detail.tab;
|
2025-12-29 23:33:38 +00:00
|
|
|
|
2025-06-17 08:41:36 +00:00
|
|
|
// Re-emit the event
|
|
|
|
|
this.dispatchEvent(new CustomEvent('tab-select', {
|
|
|
|
|
detail: e.detail,
|
|
|
|
|
bubbles: true,
|
|
|
|
|
composed: true
|
|
|
|
|
}));
|
2024-01-24 12:18:37 +01:00
|
|
|
}
|
|
|
|
|
|
2025-12-29 23:33:38 +00:00
|
|
|
private handleTabClose(e: CustomEvent) {
|
|
|
|
|
// Re-emit the event
|
|
|
|
|
this.dispatchEvent(new CustomEvent('tab-close', {
|
|
|
|
|
detail: e.detail,
|
|
|
|
|
bubbles: true,
|
|
|
|
|
composed: true
|
|
|
|
|
}));
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-29 02:55:03 +00:00
|
|
|
updated(changedProperties: Map<string | number | symbol, unknown>) {
|
|
|
|
|
super.updated(changedProperties);
|
|
|
|
|
if (changedProperties.has('showTabs')) {
|
|
|
|
|
if (this.showTabs) {
|
|
|
|
|
this.removeAttribute('notabs');
|
|
|
|
|
} else {
|
|
|
|
|
this.setAttribute('notabs', '');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2025-06-17 08:41:36 +00:00
|
|
|
async firstUpdated(_changedProperties: Map<string | number | symbol, unknown>) {
|
|
|
|
|
await super.firstUpdated(_changedProperties);
|
2025-12-29 02:55:03 +00:00
|
|
|
// Apply initial notabs state
|
|
|
|
|
if (!this.showTabs) {
|
|
|
|
|
this.setAttribute('notabs', '');
|
|
|
|
|
}
|
2025-06-17 08:41:36 +00:00
|
|
|
// Tab selection is now handled by the dees-appui-tabs component
|
|
|
|
|
// But we need to ensure the tabs component is ready
|
|
|
|
|
const tabsComponent = this.shadowRoot.querySelector('dees-appui-tabs') as DeesAppuiTabs;
|
|
|
|
|
if (tabsComponent) {
|
|
|
|
|
await tabsComponent.updateComplete;
|
|
|
|
|
}
|
2024-01-24 12:18:37 +01:00
|
|
|
}
|
|
|
|
|
}
|