import { html, css } from '@design.estate/dees-element'; import '@design.estate/dees-wcctools/demotools'; import './dees-panel.js'; import './dees-form.js'; import './dees-form-submit.js'; export const demoFunc = () => html`
{ // Demonstrate programmatic interaction with basic dropdowns const countryDropdown = elementArg.querySelector('dees-input-dropdown[label="Select Country"]'); const roleDropdown = elementArg.querySelector('dees-input-dropdown[label="Select Role"]'); // Log when country changes if (countryDropdown) { countryDropdown.addEventListener('selectedOption', (event: CustomEvent) => { console.log('Country selected:', event.detail); }); } // Log when role changes if (roleDropdown) { roleDropdown.addEventListener('selectedOption', (event: CustomEvent) => { console.log('Role selected:', event.detail); }); } }}> { // Demonstrate simpler dropdown without search const priorityDropdown = elementArg.querySelector('dees-input-dropdown'); if (priorityDropdown) { priorityDropdown.addEventListener('selectedOption', (event: CustomEvent) => { console.log(`Priority changed to: ${event.detail.option}`); }); } }}> { // Demonstrate horizontal layout with multiple dropdowns const dropdowns = elementArg.querySelectorAll('dees-input-dropdown'); // Log all changes from horizontal dropdowns dropdowns.forEach((dropdown) => { dropdown.addEventListener('selectedOption', (event: CustomEvent) => { const label = dropdown.getAttribute('label'); console.log(`${label}: ${event.detail.option}`); }); }); }}>
{ // Demonstrate state handling const requiredDropdown = elementArg.querySelector('dees-input-dropdown[required]'); if (requiredDropdown) { // Show validation state changes requiredDropdown.addEventListener('blur', () => { console.log('Required dropdown lost focus'); }); } }}>
(Spacer to test dropdown positioning)
{ // This dropdown demonstrates automatic positioning const dropdown = elementArg.querySelector('dees-input-dropdown'); if (dropdown) { dropdown.addEventListener('selectedOption', (event: CustomEvent) => { console.log('Bottom dropdown selected:', event.detail); }); // Note: The dropdown automatically detects available space // and opens upward when near the bottom of the viewport } }}> { // Setup the interactive payload display const dropdown = elementArg.querySelector('dees-input-dropdown'); const output = elementArg.querySelector('#selection-output'); if (dropdown && output) { // Initialize output output.innerHTML = 'Select a product to see details...'; // Handle dropdown changes dropdown.addEventListener('change', (event: CustomEvent) => { if (event.detail.value) { output.innerHTML = ` Selected: ${event.detail.value.option}
Key: ${event.detail.value.key}
Price: $${event.detail.value.payload?.price || 'N/A'}
Features: ${event.detail.value.payload?.features?.join(', ') || 'N/A'} `; } }); } }}>
{ // Demonstrate form integration and validation const form = elementArg.querySelector('dees-form'); const projectTypeDropdown = elementArg.querySelector('dees-input-dropdown[key="projectType"]'); const frameworkDropdown = elementArg.querySelector('dees-input-dropdown[key="framework"]'); if (form) { form.addEventListener('formData', (event: CustomEvent) => { console.log('Form submitted with data:', event.detail.data); }); } if (projectTypeDropdown && frameworkDropdown) { // Filter frameworks based on project type projectTypeDropdown.addEventListener('selectedOption', (event: CustomEvent) => { const selectedType = event.detail.key; console.log(`Project type changed to: ${selectedType}`); // In a real app, you could filter the framework options based on project type // For demo purposes, we just log the change }); } }}>
`