2024-01-24 12:18:37 +01:00
|
|
|
import * as plugins from './00plugins.js';
|
|
|
|
import * as interfaces from './interfaces/index.js';
|
|
|
|
|
|
|
|
import { DeesContextmenu } from './dees-contextmenu.js';
|
|
|
|
|
|
|
|
import {
|
|
|
|
DeesElement,
|
|
|
|
type TemplateResult,
|
|
|
|
property,
|
|
|
|
customElement,
|
|
|
|
html,
|
|
|
|
css,
|
|
|
|
cssManager,
|
|
|
|
} from '@design.estate/dees-element';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* the property selector menu
|
|
|
|
* mainly used to select assets within in an organization
|
|
|
|
*/
|
|
|
|
@customElement('dees-appui-mainselector')
|
|
|
|
export class DeesAppuiMainselector extends DeesElement {
|
2025-06-17 08:41:36 +00:00
|
|
|
public static demo = () => html`
|
|
|
|
<dees-appui-mainselector
|
|
|
|
.selectionOptions=${[
|
|
|
|
{ key: 'Overview', action: () => console.log('Overview') },
|
|
|
|
{ key: 'Components', action: () => console.log('Components') },
|
|
|
|
{ key: 'Services', action: () => console.log('Services') },
|
|
|
|
{ key: 'Database', action: () => console.log('Database') },
|
|
|
|
{ key: 'Settings', action: () => console.log('Settings') },
|
|
|
|
]}
|
|
|
|
></dees-appui-mainselector>
|
|
|
|
`;
|
2024-01-24 12:18:37 +01:00
|
|
|
|
|
|
|
// INSTANCE
|
2025-06-17 08:41:36 +00:00
|
|
|
@property({ type: Array })
|
2024-01-24 12:18:37 +01:00
|
|
|
public selectionOptions: interfaces.ISelectionOption[] = [
|
2025-06-17 08:41:36 +00:00
|
|
|
{ key: '⚠️ Please set selection options', action: () => console.warn('No selection options configured for mainselector') },
|
2024-01-24 12:18:37 +01:00
|
|
|
];
|
|
|
|
|
|
|
|
@property()
|
|
|
|
public selectedOption: interfaces.ISelectionOption = null;
|
|
|
|
|
|
|
|
public static styles = [
|
|
|
|
cssManager.defaultStyles,
|
|
|
|
css`
|
|
|
|
:host {
|
2025-06-17 08:58:47 +00:00
|
|
|
color: ${cssManager.bdTheme('#333', '#fff')};
|
2024-01-24 12:18:37 +01:00
|
|
|
position: relative;
|
|
|
|
display: block;
|
|
|
|
width: 100%;
|
|
|
|
max-width: 300px;
|
|
|
|
height: 100%;
|
2025-06-17 08:58:47 +00:00
|
|
|
background: ${cssManager.bdTheme('#fafafa', '#000000')};
|
|
|
|
border-right: 1px solid ${cssManager.bdTheme('#e0e0e0', '#222222')};
|
2024-01-24 12:18:37 +01:00
|
|
|
}
|
|
|
|
.maincontainer {
|
|
|
|
position: absolute;
|
|
|
|
top: 0px;
|
|
|
|
left: 0px;
|
|
|
|
height: 100%;
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.topbar {
|
|
|
|
position: absolute;
|
|
|
|
height: 32px;
|
|
|
|
width: 100%;
|
|
|
|
}
|
|
|
|
|
|
|
|
.topbar .heading {
|
|
|
|
padding-left: 16px;
|
|
|
|
padding-top: 8px;
|
|
|
|
line-height: 24px;
|
2024-06-30 10:37:12 +02:00
|
|
|
font-family: 'Geist Sans', sans-serif;
|
2024-01-24 12:18:37 +01:00
|
|
|
font-weight: 600;
|
|
|
|
font-size: 14px;
|
2025-06-17 08:58:47 +00:00
|
|
|
color: ${cssManager.bdTheme('#666', '#ccc')};
|
2024-01-24 12:18:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
.selectionOptions {
|
|
|
|
position: absolute;
|
|
|
|
top: 32px;
|
|
|
|
padding-top: 8px;
|
|
|
|
left: 0px;
|
|
|
|
width: 100%;
|
2024-06-30 10:37:12 +02:00
|
|
|
font-family: 'Geist Sans', sans-serif;
|
2024-01-24 12:18:37 +01:00
|
|
|
font-size: 14px;
|
|
|
|
}
|
|
|
|
|
|
|
|
.selectionOptions .selectionOption {
|
|
|
|
cursor: default;
|
|
|
|
margin-left: 16px;
|
|
|
|
margin-right: 16px;
|
|
|
|
padding-top: 8px;
|
|
|
|
padding-bottom: 8px;
|
2025-06-17 08:58:47 +00:00
|
|
|
border-top: 1px dotted ${cssManager.bdTheme('#e0e0e0', '#303030')};
|
2024-01-24 12:18:37 +01:00
|
|
|
border-left: 0px solid rgba(0, 0, 0, 0);
|
|
|
|
transition: all 0.1s;
|
|
|
|
}
|
|
|
|
|
|
|
|
.selectionOptions .selectionOption:hover {
|
|
|
|
border-left: 2px solid #26a69a50;
|
|
|
|
padding-left: 8px;
|
2025-06-17 08:58:47 +00:00
|
|
|
background: ${cssManager.bdTheme('rgba(0, 0, 0, 0.02)', 'rgba(255, 255, 255, 0.02)')};
|
2024-01-24 12:18:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
.selectionOptions .selectionOption:first-child {
|
|
|
|
border-top: 1px solid rgba(0, 0, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
.selectionOptions .selectionOption.selectedOption {
|
|
|
|
border-left: 4px solid #26a69a;
|
|
|
|
padding-left: 10px;
|
2025-06-17 08:58:47 +00:00
|
|
|
background: ${cssManager.bdTheme('rgba(38, 166, 154, 0.05)', 'rgba(38, 166, 154, 0.1)')};
|
2024-01-24 12:18:37 +01:00
|
|
|
}
|
|
|
|
`,
|
|
|
|
];
|
|
|
|
|
|
|
|
public render(): TemplateResult {
|
|
|
|
return html`
|
|
|
|
<style></style>
|
|
|
|
<div class="maincontainer">
|
|
|
|
<div class="topbar">
|
|
|
|
<div class="heading">Properties</div>
|
|
|
|
</div>
|
|
|
|
<div class="selectionOptions">
|
|
|
|
${this.selectionOptions.map((selectionOptionArg) => {
|
|
|
|
return html`
|
|
|
|
<div
|
|
|
|
class="selectionOption ${this.selectedOption === selectionOptionArg
|
|
|
|
? 'selectedOption'
|
|
|
|
: null}"
|
|
|
|
@click="${() => {
|
|
|
|
this.selectOption(selectionOptionArg);
|
|
|
|
}}"
|
|
|
|
@contextmenu="${(eventArg: MouseEvent) => {
|
|
|
|
DeesContextmenu.openContextMenuWithOptions(eventArg, [
|
|
|
|
{
|
|
|
|
name: 'property settings',
|
|
|
|
action: async () => {},
|
|
|
|
iconName: 'gear',
|
|
|
|
},
|
|
|
|
]);
|
|
|
|
}}"
|
|
|
|
>
|
|
|
|
${selectionOptionArg.key}
|
|
|
|
</div>
|
|
|
|
`;
|
|
|
|
})}
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
`;
|
|
|
|
}
|
|
|
|
|
|
|
|
private selectOption(optionArg: interfaces.ISelectionOption) {
|
|
|
|
this.selectedOption = optionArg;
|
|
|
|
this.selectedOption.action();
|
2025-06-17 08:41:36 +00:00
|
|
|
|
|
|
|
// Emit option-select event
|
|
|
|
this.dispatchEvent(new CustomEvent('option-select', {
|
|
|
|
detail: { option: optionArg },
|
|
|
|
bubbles: true,
|
|
|
|
composed: true
|
|
|
|
}));
|
2024-01-24 12:18:37 +01:00
|
|
|
}
|
|
|
|
|
2025-06-17 08:41:36 +00:00
|
|
|
async firstUpdated(_changedProperties: Map<string | number | symbol, unknown>) {
|
|
|
|
await super.firstUpdated(_changedProperties);
|
|
|
|
if (this.selectionOptions && this.selectionOptions.length > 0) {
|
|
|
|
await this.updateComplete;
|
|
|
|
this.selectOption(this.selectionOptions[0]);
|
|
|
|
}
|
2024-01-24 12:18:37 +01:00
|
|
|
}
|
|
|
|
}
|