| 
									
										
										
										
											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'; | 
					
						
							| 
									
										
										
										
											2025-06-17 10:00:50 +00:00
										 |  |  | import './dees-icon.js'; | 
					
						
							| 
									
										
										
										
											2024-01-24 12:18:37 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  | 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=${[ | 
					
						
							| 
									
										
										
										
											2025-06-17 10:00:50 +00:00
										 |  |  |         { key: 'Overview', iconName: 'home', action: () => console.log('Overview') }, | 
					
						
							|  |  |  |         { key: 'Components', iconName: 'package', action: () => console.log('Components') }, | 
					
						
							|  |  |  |         { key: 'Services', iconName: 'server', action: () => console.log('Services') }, | 
					
						
							|  |  |  |         { key: 'Database', iconName: 'database', action: () => console.log('Database') }, | 
					
						
							|  |  |  |         { key: 'Settings', iconName: 'settings', action: () => console.log('Settings') }, | 
					
						
							| 
									
										
										
										
											2025-06-17 08:41:36 +00:00
										 |  |  |       ]} | 
					
						
							|  |  |  |     ></dees-appui-mainselector> | 
					
						
							|  |  |  |   `;
 | 
					
						
							| 
									
										
										
										
											2024-01-24 12:18:37 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |   // INSTANCE
 | 
					
						
							| 
									
										
										
										
											2025-06-17 08:41:36 +00:00
										 |  |  |   @property({ type: Array }) | 
					
						
							| 
									
										
										
										
											2025-06-17 10:00:50 +00:00
										 |  |  |   public selectionOptions: (interfaces.ISelectionOption | { divider: true })[] = [ | 
					
						
							| 
									
										
										
										
											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')}; | 
					
						
							| 
									
										
										
										
											2025-06-17 10:00:50 +00:00
										 |  |  |         border-right: 1px solid ${cssManager.bdTheme('#e0e0e0', '#202020')}; | 
					
						
							| 
									
										
										
										
											2024-01-24 12:18:37 +01:00
										 |  |  |       } | 
					
						
							|  |  |  |       .maincontainer { | 
					
						
							|  |  |  |         position: absolute; | 
					
						
							|  |  |  |         top: 0px; | 
					
						
							|  |  |  |         left: 0px; | 
					
						
							|  |  |  |         height: 100%; | 
					
						
							|  |  |  |         width: 100%; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       .topbar { | 
					
						
							|  |  |  |         position: absolute; | 
					
						
							| 
									
										
										
										
											2025-06-17 10:00:50 +00:00
										 |  |  |         height: 40px; | 
					
						
							| 
									
										
										
										
											2024-01-24 12:18:37 +01:00
										 |  |  |         width: 100%; | 
					
						
							| 
									
										
										
										
											2025-06-17 10:00:50 +00:00
										 |  |  |         display: flex; | 
					
						
							|  |  |  |         align-items: center; | 
					
						
							|  |  |  |         border-bottom: 1px solid ${cssManager.bdTheme('#e0e0e0', '#202020')}; | 
					
						
							| 
									
										
										
										
											2024-01-24 12:18:37 +01:00
										 |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       .topbar .heading { | 
					
						
							| 
									
										
										
										
											2025-06-17 10:00:50 +00:00
										 |  |  |         padding-left: 12px; | 
					
						
							| 
									
										
										
										
											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; | 
					
						
							| 
									
										
										
										
											2025-06-17 10:00:50 +00:00
										 |  |  |         font-size: 12px; | 
					
						
							|  |  |  |         color: ${cssManager.bdTheme('#666', '#999')}; | 
					
						
							|  |  |  |         text-transform: uppercase; | 
					
						
							|  |  |  |         letter-spacing: 0.5px; | 
					
						
							| 
									
										
										
										
											2024-01-24 12:18:37 +01:00
										 |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       .selectionOptions { | 
					
						
							|  |  |  |         position: absolute; | 
					
						
							| 
									
										
										
										
											2025-06-17 10:00:50 +00:00
										 |  |  |         top: 40px; | 
					
						
							| 
									
										
										
										
											2024-01-24 12:18:37 +01:00
										 |  |  |         left: 0px; | 
					
						
							| 
									
										
										
										
											2025-06-17 10:00:50 +00:00
										 |  |  |         right: 0px; | 
					
						
							|  |  |  |         bottom: 0px; | 
					
						
							|  |  |  |         overflow-y: auto; | 
					
						
							| 
									
										
										
										
											2024-06-30 10:37:12 +02:00
										 |  |  |         font-family: 'Geist Sans', sans-serif; | 
					
						
							| 
									
										
										
										
											2025-06-17 10:00:50 +00:00
										 |  |  |         font-size: 12px; | 
					
						
							|  |  |  |         padding: 4px 0; | 
					
						
							| 
									
										
										
										
											2024-01-24 12:18:37 +01:00
										 |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       .selectionOptions .selectionOption { | 
					
						
							|  |  |  |         cursor: default; | 
					
						
							| 
									
										
										
										
											2025-06-17 10:00:50 +00:00
										 |  |  |         padding: 8px 12px; | 
					
						
							|  |  |  |         margin: 0; | 
					
						
							|  |  |  |         transition: background 0.1s; | 
					
						
							|  |  |  |         display: flex; | 
					
						
							|  |  |  |         align-items: center; | 
					
						
							|  |  |  |         gap: 8px; | 
					
						
							|  |  |  |         color: ${cssManager.bdTheme('#333', '#ccc')}; | 
					
						
							|  |  |  |         user-select: none; | 
					
						
							| 
									
										
										
										
											2024-01-24 12:18:37 +01:00
										 |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       .selectionOptions .selectionOption:hover { | 
					
						
							| 
									
										
										
										
											2025-06-17 10:00:50 +00:00
										 |  |  |         background: ${cssManager.bdTheme('rgba(0, 0, 0, 0.04)', 'rgba(255, 255, 255, 0.08)')}; | 
					
						
							| 
									
										
										
										
											2024-01-24 12:18:37 +01:00
										 |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2025-06-17 10:00:50 +00:00
										 |  |  |       .selectionOptions .selectionOption:active { | 
					
						
							|  |  |  |         background: ${cssManager.bdTheme('rgba(0, 0, 0, 0.08)', 'rgba(255, 255, 255, 0.12)')}; | 
					
						
							| 
									
										
										
										
											2024-01-24 12:18:37 +01:00
										 |  |  |       } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       .selectionOptions .selectionOption.selectedOption { | 
					
						
							| 
									
										
										
										
											2025-06-17 10:00:50 +00:00
										 |  |  |         background: ${cssManager.bdTheme('rgba(0, 0, 0, 0.08)', 'rgba(255, 255, 255, 0.12)')}; | 
					
						
							|  |  |  |         color: ${cssManager.bdTheme('#000', '#fff')}; | 
					
						
							|  |  |  |         font-weight: 500; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |        | 
					
						
							|  |  |  |       .selectionOptions .selectionOption.selectedOption::before { | 
					
						
							|  |  |  |         content: ''; | 
					
						
							|  |  |  |         position: absolute; | 
					
						
							|  |  |  |         left: 0; | 
					
						
							|  |  |  |         top: 0; | 
					
						
							|  |  |  |         bottom: 0; | 
					
						
							|  |  |  |         width: 3px; | 
					
						
							|  |  |  |         background: ${cssManager.bdTheme('#26a69a', '#26a69a')}; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |        | 
					
						
							|  |  |  |       .selectionOption { | 
					
						
							|  |  |  |         position: relative; | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |        | 
					
						
							|  |  |  |       .selection-divider { | 
					
						
							|  |  |  |         height: 1px; | 
					
						
							|  |  |  |         background: ${cssManager.bdTheme('#e0e0e0', '#202020')}; | 
					
						
							|  |  |  |         margin: 4px 0; | 
					
						
							| 
									
										
										
										
											2024-01-24 12:18:37 +01:00
										 |  |  |       } | 
					
						
							|  |  |  |     `,
 | 
					
						
							|  |  |  |   ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   public render(): TemplateResult { | 
					
						
							|  |  |  |     return html`
 | 
					
						
							|  |  |  |       <style></style> | 
					
						
							|  |  |  |       <div class="maincontainer"> | 
					
						
							|  |  |  |         <div class="topbar"> | 
					
						
							| 
									
										
										
										
											2025-06-17 10:00:50 +00:00
										 |  |  |           <div class="heading">Selector</div> | 
					
						
							| 
									
										
										
										
											2024-01-24 12:18:37 +01:00
										 |  |  |         </div> | 
					
						
							|  |  |  |         <div class="selectionOptions"> | 
					
						
							|  |  |  |           ${this.selectionOptions.map((selectionOptionArg) => { | 
					
						
							| 
									
										
										
										
											2025-06-17 10:00:50 +00:00
										 |  |  |             if ('divider' in selectionOptionArg && selectionOptionArg.divider) { | 
					
						
							|  |  |  |               return html`<div class="selection-divider"></div>`; | 
					
						
							|  |  |  |             } | 
					
						
							|  |  |  |              | 
					
						
							|  |  |  |             const option = selectionOptionArg as interfaces.ISelectionOption; | 
					
						
							| 
									
										
										
										
											2024-01-24 12:18:37 +01:00
										 |  |  |             return html`
 | 
					
						
							|  |  |  |               <div | 
					
						
							| 
									
										
										
										
											2025-06-17 10:00:50 +00:00
										 |  |  |                 class="selectionOption ${this.selectedOption === option | 
					
						
							| 
									
										
										
										
											2024-01-24 12:18:37 +01:00
										 |  |  |                   ? 'selectedOption' | 
					
						
							|  |  |  |                   : null}" | 
					
						
							|  |  |  |                 @click="${() => { | 
					
						
							| 
									
										
										
										
											2025-06-17 10:00:50 +00:00
										 |  |  |                   this.selectOption(option); | 
					
						
							| 
									
										
										
										
											2024-01-24 12:18:37 +01:00
										 |  |  |                 }}" | 
					
						
							|  |  |  |                 @contextmenu="${(eventArg: MouseEvent) => { | 
					
						
							|  |  |  |                   DeesContextmenu.openContextMenuWithOptions(eventArg, [ | 
					
						
							|  |  |  |                     { | 
					
						
							|  |  |  |                       name: 'property settings', | 
					
						
							|  |  |  |                       action: async () => {}, | 
					
						
							|  |  |  |                       iconName: 'gear', | 
					
						
							|  |  |  |                     }, | 
					
						
							|  |  |  |                   ]); | 
					
						
							|  |  |  |                 }}" | 
					
						
							|  |  |  |               > | 
					
						
							| 
									
										
										
										
											2025-06-17 10:00:50 +00:00
										 |  |  |                 ${option.iconName ? html`
 | 
					
						
							|  |  |  |                   <dees-icon .icon="${`lucide:${option.iconName}`}" style="font-size: 14px; opacity: 0.7;"></dees-icon> | 
					
						
							|  |  |  |                 ` : ''}
 | 
					
						
							|  |  |  |                 <span style="flex: 1;">${option.key}</span> | 
					
						
							| 
									
										
										
										
											2024-01-24 12:18:37 +01:00
										 |  |  |               </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; | 
					
						
							| 
									
										
										
										
											2025-06-17 10:00:50 +00:00
										 |  |  |       // Find first non-divider option
 | 
					
						
							|  |  |  |       const firstOption = this.selectionOptions.find(option => !('divider' in option)) as interfaces.ISelectionOption; | 
					
						
							|  |  |  |       if (firstOption) { | 
					
						
							|  |  |  |         this.selectOption(firstOption); | 
					
						
							|  |  |  |       } | 
					
						
							| 
									
										
										
										
											2025-06-17 08:41:36 +00:00
										 |  |  |     } | 
					
						
							| 
									
										
										
										
											2024-01-24 12:18:37 +01:00
										 |  |  |   } | 
					
						
							|  |  |  | } |