export function featureRequest(form: FormTs) {
// Feature Request Form - Product feedback and suggestion collector
// Demonstrates: Slider, CheckboxList, Textarea, RadioButton, dynamic labels, conditional sections
// ============================================
// HEADER
// ============================================
form.addRow(row => {
row.addTextPanel('header', {
label: 'Feature Request',
computedValue: () => 'Help us build the product you need',
customStyles: {
backgroundColor: '#8b5cf6',
color: 'white',
padding: '24px',
borderRadius: '12px',
textAlign: 'center'
}
});
});
// ============================================
// SECTION 1: Request Type
// ============================================
const typeSection = form.addSubform('typeSection', {
title: 'What type of request is this?',
customStyles: { backgroundColor: '#f5f3ff', padding: '16px', borderRadius: '8px' }
});
typeSection.addRow(row => {
row.addRadioButton('requestType', {
label: 'Request Category',
options: [
{ id: 'new_feature', name: 'New Feature - Something that doesn\'t exist' },
{ id: 'enhancement', name: 'Enhancement - Improve existing feature' },
{ id: 'integration', name: 'Integration - Connect with another tool' },
{ id: 'performance', name: 'Performance - Make something faster' },
{ id: 'usability', name: 'Usability - Make something easier to use' }
],
orientation: 'vertical',
isRequired: true
});
});
typeSection.addRow(row => {
row.addDropdown('productArea', {
label: 'Product Area',
options: [
{ id: 'dashboard', name: 'Dashboard & Analytics' },
{ id: 'reports', name: 'Reports & Exports' },
{ id: 'settings', name: 'Settings & Configuration' },
{ id: 'user_management', name: 'User Management' },
{ id: 'notifications', name: 'Notifications & Alerts' },
{ id: 'api', name: 'API & Integrations' },
{ id: 'mobile', name: 'Mobile App' },
{ id: 'other', name: 'Other' }
],
placeholder: 'Select product area'
}, '1fr');
row.addDropdown('userRole', {
label: 'Your Role',
options: [
{ id: 'admin', name: 'Admin/Manager' },
{ id: 'power_user', name: 'Power User' },
{ id: 'regular', name: 'Regular User' },
{ id: 'developer', name: 'Developer' },
{ id: 'other', name: 'Other' }
],
placeholder: 'Select your role'
}, '1fr');
});
// ============================================
// SECTION 2: Problem Statement
// ============================================
const problemSection = form.addSubform('problemSection', {
title: 'What problem are you trying to solve?',
customStyles: { padding: '16px', borderRadius: '8px', border: '1px solid #e2e8f0' }
});
problemSection.addRow(row => {
row.addTextbox('featureTitle', {
label: 'Feature Title (short summary)',
placeholder: 'e.g., "Bulk export to Excel"',
maxLength: 100,
isRequired: true
});
});
problemSection.addRow(row => {
row.addTextarea('problemDescription', {
label: () => {
const type = typeSection.radioButton('requestType')?.value();
if (type === 'enhancement') return 'What\'s frustrating about the current feature?';
if (type === 'integration') return 'What tool do you want to integrate with and why?';
if (type === 'performance') return 'What\'s slow and how does it affect you?';
if (type === 'usability') return 'What\'s difficult to use and how could it be better?';
return 'What problem are you trying to solve?';
},
placeholder: 'Describe the problem or need in detail...',
rows: 4,
autoExpand: true,
isRequired: true
});
});
problemSection.addRow(row => {
row.addTextarea('currentWorkaround', {
label: 'How do you currently work around this?',
placeholder: 'Describe any workarounds or manual processes you use...',
rows: 2,
autoExpand: true
});
});
// ============================================
// SECTION 3: Use Case Details
// ============================================
const useCaseSection = form.addSubform('useCaseSection', {
title: 'Use Case Details',
customStyles: { padding: '16px', borderRadius: '8px', backgroundColor: '#f0fdf4' }
});
useCaseSection.addRow(row => {
row.addTextarea('useCase', {
label: 'Describe a specific scenario where you need this',
placeholder: 'As a [role], I want to [action] so that [benefit]...',
rows: 3,
autoExpand: true
});
});
useCaseSection.addRow(row => {
row.addRadioButton('frequency', {
label: 'How often would you use this feature?',
options: [
{ id: 'daily', name: 'Multiple times daily' },
{ id: 'weekly', name: 'Several times per week' },
{ id: 'monthly', name: 'A few times per month' },
{ id: 'occasionally', name: 'Occasionally' },
{ id: 'once', name: 'One-time need' }
],
orientation: 'horizontal'
});
});
useCaseSection.addRow(row => {
row.addSlider('teamImpact', {
label: 'How many people on your team would benefit?',
min: 1,
max: 100,
step: 1,
showValue: true,
unit: 'people',
defaultValue: 5
});
});
// ============================================
// SECTION 4: Business Impact
// ============================================
const impactSection = form.addSubform('impactSection', {
title: 'Business Impact',
customStyles: { padding: '16px', borderRadius: '8px', border: '1px solid #e2e8f0' }
});
impactSection.addRow(row => {
row.addCheckboxList('impactAreas', {
label: 'How would this feature impact your work?',
options: [
{ id: 'save_time', name: 'Save time on repetitive tasks' },
{ id: 'reduce_errors', name: 'Reduce errors/mistakes' },
{ id: 'improve_collaboration', name: 'Improve team collaboration' },
{ id: 'better_insights', name: 'Provide better insights/data' },
{ id: 'customer_satisfaction', name: 'Improve customer satisfaction' },
{ id: 'cost_savings', name: 'Reduce costs' },
{ id: 'revenue', name: 'Increase revenue' },
{ id: 'compliance', name: 'Meet compliance requirements' }
],
orientation: 'vertical'
});
});
impactSection.addRow(row => {
row.addSlider('timeSavings', {
label: 'Estimated time saved per week (hours)',
min: 0,
max: 40,
step: 1,
showValue: true,
unit: 'hrs/week',
isVisible: () => {
const impacts = impactSection.checkboxList('impactAreas')?.value() || [];
return impacts.includes('save_time');
}
});
});
impactSection.addRow(row => {
row.addTextarea('businessValue', {
label: 'Describe the business value in your own words',
placeholder: 'How would this help your business goals?',
rows: 2,
autoExpand: true
});
});
// ============================================
// SECTION 5: Priority & Urgency
// ============================================
const prioritySection = form.addSubform('prioritySection', {
title: 'Priority & Urgency',
customStyles: () => {
const urgency = prioritySection.slider('urgency')?.value();
if (urgency && urgency >= 8) {
return { backgroundColor: '#fee2e2', padding: '16px', borderRadius: '8px', borderLeft: '4px solid #ef4444' };
} else if (urgency && urgency >= 5) {
return { backgroundColor: '#fef3c7', padding: '16px', borderRadius: '8px', borderLeft: '4px solid #f59e0b' };
}
return { backgroundColor: '#ecfdf5', padding: '16px', borderRadius: '8px', borderLeft: '4px solid #10b981' };
}
});
prioritySection.addRow(row => {
row.addSlider('urgency', {
label: () => {
const urgency = prioritySection.slider('urgency')?.value();
if (urgency && urgency >= 8) return 'How urgent is this for you? (Critical)';
if (urgency && urgency >= 5) return 'How urgent is this for you? (Important)';
return 'How urgent is this for you? (Nice to have)';
},
min: 1,
max: 10,
step: 1,
showValue: true,
defaultValue: 5
});
});
prioritySection.addRow(row => {
row.addRadioButton('blocker', {
label: 'Is this blocking you from achieving a goal?',
options: [
{ id: 'yes_major', name: 'Yes, major blocker' },
{ id: 'yes_minor', name: 'Yes, minor blocker' },
{ id: 'no', name: 'No, it\'s an improvement' }
],
orientation: 'horizontal'
});
});
prioritySection.addRow(row => {
row.addTextarea('deadline', {
label: 'Do you have a specific deadline or timeline?',
placeholder: 'e.g., "Need for Q2 reporting" or "Annual audit in March"',
rows: 2,
autoExpand: true,
isVisible: () => {
const blocker = prioritySection.radioButton('blocker')?.value();
return blocker === 'yes_major' || blocker === 'yes_minor';
}
});
});
// ============================================
// SECTION 6: Alternative Solutions
// ============================================
const alternativesSection = form.addSubform('alternativesSection', {
title: 'Alternatives & Competition',
customStyles: { padding: '16px', borderRadius: '8px', border: '1px solid #e2e8f0' }
});
alternativesSection.addRow(row => {
row.addThumbRating('seenElsewhere', {
label: 'Have you seen this feature in other products?',
showLabels: true,
upLabel: 'Yes',
downLabel: 'No',
alignment: 'left'
});
});
alternativesSection.addRow(row => {
row.addTextarea('competitorExamples', {
label: 'Which products have this feature?',
placeholder: 'List any competitors or tools with similar functionality...',
rows: 2,
autoExpand: true,
isVisible: () => alternativesSection.thumbRating('seenElsewhere')?.value() === 'up'
});
});
alternativesSection.addRow(row => {
row.addRadioButton('switchRisk', {
label: 'Would lack of this feature make you consider switching products?',
options: [
{ id: 'yes', name: 'Yes, it\'s critical' },
{ id: 'maybe', name: 'Maybe, depends on alternatives' },
{ id: 'no', name: 'No, I\'d stay anyway' }
],
orientation: 'horizontal'
});
});
// ============================================
// SECTION 7: Implementation Preference
// ============================================
const implementationSection = form.addSubform('implementationSection', {
title: 'Implementation Preference',
customStyles: { padding: '16px', borderRadius: '8px', backgroundColor: '#f0f9ff' }
});
implementationSection.addRow(row => {
row.addRadioButton('solutionPreference', {
label: 'Would you prefer...',
options: [
{ id: 'full', name: 'Full solution (even if it takes longer)' },
{ id: 'mvp', name: 'Basic version quickly, then iterate' },
{ id: 'any', name: 'Whatever works best for the team' }
],
orientation: 'vertical'
});
});
implementationSection.addRow(row => {
row.addCheckbox('betaTester', {
label: 'I\'d like to be a beta tester for this feature'
});
});
implementationSection.addRow(row => {
row.addCheckbox('provideFeedback', {
label: 'I\'m willing to provide feedback during development'
});
});
// ============================================
// SECTION 8: Attachments & Examples
// ============================================
const examplesSection = form.addSubform('examplesSection', {
title: 'Examples & References',
customStyles: { padding: '16px', borderRadius: '8px', border: '1px solid #e2e8f0' }
});
examplesSection.addRow(row => {
row.addTextarea('mockupIdea', {
label: 'Describe how you envision the feature (optional)',
placeholder: 'Describe the UI/UX, workflow, or share a link to a mockup...',
rows: 3,
autoExpand: true
});
});
examplesSection.addRow(row => {
row.addTextbox('referenceUrl', {
label: 'Link to reference/example (optional)',
placeholder: 'https://...'
});
});
// ============================================
// SECTION 9: Contact
// ============================================
const contactSection = form.addSubform('contactSection', {
title: 'Contact Information'
});
contactSection.addRow(row => {
row.addCheckbox('allowContact', {
label: 'You may contact me about this request'
});
});
contactSection.addRow(row => {
row.addEmail('contactEmail', {
label: 'Email Address',
placeholder: 'your@email.com',
isVisible: () => contactSection.checkbox('allowContact')?.value() === true,
isRequired: () => contactSection.checkbox('allowContact')?.value() === true
});
});
contactSection.addRow(row => {
row.addCheckbox('notifyUpdates', {
label: 'Notify me when this feature is released',
isVisible: () => contactSection.checkbox('allowContact')?.value() === true
});
});
// ============================================
// SUMMARY SECTION
// ============================================
const summarySection = form.addSubform('summarySection', {
title: 'Request Summary',
isVisible: () => problemSection.textbox('featureTitle')?.value() !== null && problemSection.textbox('featureTitle')?.value() !== ''
});
summarySection.addRow(row => {
row.addTextPanel('summaryContent', {
computedValue: () => {
const title = problemSection.textbox('featureTitle')?.value();
const type = typeSection.radioButton('requestType')?.value();
const area = typeSection.dropdown('productArea')?.value();
const urgency = prioritySection.slider('urgency')?.value();
const frequency = useCaseSection.radioButton('frequency')?.value();
const teamSize = useCaseSection.slider('teamImpact')?.value();
const impacts = impactSection.checkboxList('impactAreas')?.value() || [];
const blocker = prioritySection.radioButton('blocker')?.value();
const betaTester = implementationSection.checkbox('betaTester')?.value();
if (!title) return '';
let emoji = '💡';
if (blocker === 'yes_major') emoji = '🚨';
else if (urgency && urgency >= 8) emoji = '⚡';
const typeLabels: Record<string, string> = {
'new_feature': 'New Feature',
'enhancement': 'Enhancement',
'integration': 'Integration',
'performance': 'Performance',
'usability': 'Usability'
};
const frequencyLabels: Record<string, string> = {
'daily': 'Daily use',
'weekly': 'Weekly use',
'monthly': 'Monthly use',
'occasionally': 'Occasional use',
'once': 'One-time'
};
let summary = `${emoji} Feature Request Summary\n`;
summary += `${'═'.repeat(28)}\n\n`;
summary += `📝 ${title}\n\n`;
if (type) {
summary += `📋 Type: ${typeLabels[type] || type}\n`;
}
if (area) {
summary += `🎯 Area: ${area.replace('_', ' ')}\n`;
}
if (urgency) {
const urgencyLabel = urgency >= 8 ? 'Critical' : urgency >= 5 ? 'Important' : 'Nice to have';
summary += `⏰ Urgency: ${urgency}/10 (${urgencyLabel})\n`;
}
if (frequency) {
summary += `🔄 Frequency: ${frequencyLabels[frequency] || frequency}\n`;
}
if (teamSize) {
summary += `👥 Team Impact: ${teamSize} people\n`;
}
if (impacts.length > 0) {
summary += `\n💼 Business Impact: ${impacts.length} areas`;
}
if (betaTester) {
summary += `\n✅ Willing to beta test`;
}
return summary;
},
customStyles: () => {
const urgency = prioritySection.slider('urgency')?.value();
const baseStyles = {
padding: '16px',
borderRadius: '8px',
whiteSpace: 'pre-wrap',
fontFamily: 'monospace',
fontSize: '14px'
};
if (urgency && urgency >= 8) {
return { ...baseStyles, backgroundColor: '#fee2e2', borderLeft: '4px solid #ef4444' };
} else if (urgency && urgency >= 5) {
return { ...baseStyles, backgroundColor: '#fef3c7', borderLeft: '4px solid #f59e0b' };
}
return { ...baseStyles, backgroundColor: '#ecfdf5', borderLeft: '4px solid #10b981' };
}
});
});
// ============================================
// FORM CONFIGURATION
// ============================================
form.configureSubmitButton({
label: 'Submit Request',
isVisible: () => {
const title = problemSection.textbox('featureTitle')?.value();
return title !== null && title !== undefined && title.length > 0;
}
});
form.configureCompletionScreen({
type: 'text',
title: 'Thank You for Your Input!',
message: 'Your feature request has been submitted. Our product team reviews all suggestions and will keep you updated if you opted in for notifications.'
});
}