export function stayInterviewSurvey(form: FormTs) {
// Stay Interview Survey - Employee Retention Tool
// Demonstrates: Slider, MatrixQuestion, StarRating, EmojiRating, RatingScale (Likert), multi-page wizard
// ============================================
// HEADER
// ============================================
form.addRow(row => {
row.addTextPanel('header', {
label: 'Stay Interview',
computedValue: () => 'Your honest feedback helps us create a better workplace. All responses are confidential.',
customStyles: {
backgroundColor: '#8b5cf6',
color: 'white',
padding: '24px',
borderRadius: '12px',
textAlign: 'center'
}
});
});
// ============================================
// MULTI-PAGE WIZARD
// ============================================
const pages = form.addPages('stayInterviewPages');
// ============================================
// PAGE 1: Engagement & Satisfaction
// ============================================
const page1 = pages.addPage('engagement');
page1.addRow(row => {
row.addTextPanel('page1Title', {
label: '',
computedValue: () => 'Part 1: Current Engagement',
customStyles: { fontWeight: 'bold', fontSize: '18px', marginBottom: '8px' }
});
});
// Engagement Slider
const engagementSection = page1.addSubform('engagementSection', {
title: 'How Engaged Do You Feel?',
customStyles: () => {
const level = engagementSection.slider('engagementLevel')?.value();
if (level && level >= 8) return { backgroundColor: '#d1fae5', padding: '16px', borderRadius: '8px' };
if (level && level <= 4) return { backgroundColor: '#fee2e2', padding: '16px', borderRadius: '8px' };
return { padding: '16px', borderRadius: '8px', border: '1px dashed #cbd5e1' };
}
});
engagementSection.addRow(row => {
row.addSlider('engagementLevel', {
label: 'On a scale of 1-10, how engaged do you feel at work right now?',
min: 1,
max: 10,
step: 1,
showValue: true,
defaultValue: 5
});
});
engagementSection.addRow(row => {
row.addTextPanel('engagementFeedback', {
computedValue: () => {
const level = engagementSection.slider('engagementLevel')?.value();
if (level && level >= 8) return '💚 Great to hear you feel highly engaged!';
if (level && level >= 5) return '💛 Thank you for sharing. Let\'s explore how we can increase your engagement.';
if (level) return '🔴 We appreciate your honesty. Let\'s discuss what might help.';
return '';
},
customStyles: { fontStyle: 'italic', textAlign: 'center', padding: '8px' }
});
});
// Work-Life Balance with Emoji Rating
const balanceSection = page1.addSubform('balanceSection', {
title: 'Work-Life Balance'
});
balanceSection.addRow(row => {
row.addEmojiRating('workLifeBalance', {
label: 'How would you rate your current work-life balance?',
preset: 'satisfaction',
size: 'lg',
showLabels: true,
alignment: 'center'
});
});
// ============================================
// PAGE 2: Job Satisfaction Factors
// ============================================
const page2 = pages.addPage('satisfaction');
page2.addRow(row => {
row.addTextPanel('page2Title', {
label: '',
computedValue: () => 'Part 2: What Matters to You',
customStyles: { fontWeight: 'bold', fontSize: '18px', marginBottom: '8px' }
});
});
// What keeps you here - SuggestionChips
const stayReasonsSection = page2.addSubform('stayReasonsSection', {
title: 'Why You Stay',
customStyles: { backgroundColor: '#f8fafc', padding: '16px', borderRadius: '8px' }
});
stayReasonsSection.addRow(row => {
row.addSuggestionChips('stayReasons', {
label: 'What keeps you working here? (select your top 3)',
suggestions: [
{ id: 'team', name: 'Great team/colleagues' },
{ id: 'manager', name: 'Supportive manager' },
{ id: 'growth', name: 'Career growth opportunities' },
{ id: 'compensation', name: 'Compensation & benefits' },
{ id: 'mission', name: 'Company mission/values' },
{ id: 'flexibility', name: 'Work flexibility' },
{ id: 'learning', name: 'Learning opportunities' },
{ id: 'recognition', name: 'Recognition & appreciation' },
{ id: 'challenge', name: 'Challenging work' },
{ id: 'stability', name: 'Job stability' }
],
max: 3,
alignment: 'center'
});
});
// Satisfaction Matrix
const satisfactionSection = page2.addSubform('satisfactionSection', {
title: 'Satisfaction Levels'
});
satisfactionSection.addRow(row => {
row.addMatrixQuestion('satisfactionMatrix', {
label: 'How satisfied are you with the following aspects of your job?',
rows: [
{ id: 'role', label: 'Your current role & responsibilities', isRequired: true },
{ id: 'growth', label: 'Career development opportunities', isRequired: true },
{ id: 'compensation', label: 'Compensation & benefits', isRequired: false },
{ id: 'recognition', label: 'Recognition for your work', isRequired: false },
{ id: 'tools', label: 'Tools & resources provided', isRequired: false },
{ id: 'culture', label: 'Team culture & dynamics', isRequired: false }
],
columns: [
{ id: 'very-unsatisfied', label: 'Very Unsatisfied' },
{ id: 'unsatisfied', label: 'Unsatisfied' },
{ id: 'neutral', label: 'Neutral' },
{ id: 'satisfied', label: 'Satisfied' },
{ id: 'very-satisfied', label: 'Very Satisfied' }
],
striped: true,
fullWidth: true
});
});
// ============================================
// PAGE 3: Manager Relationship
// ============================================
const page3 = pages.addPage('manager');
page3.addRow(row => {
row.addTextPanel('page3Title', {
label: '',
computedValue: () => 'Part 3: Manager Relationship',
customStyles: { fontWeight: 'bold', fontSize: '18px', marginBottom: '8px' }
});
});
const managerSection = page3.addSubform('managerSection', {
title: 'Your Manager',
customStyles: () => {
const rating = managerSection.starRating('managerRating')?.value();
if (rating && rating >= 4) return { backgroundColor: '#d1fae5', padding: '16px', borderRadius: '8px' };
if (rating && rating <= 2) return { backgroundColor: '#fee2e2', padding: '16px', borderRadius: '8px' };
return { padding: '16px', borderRadius: '8px', border: '1px dashed #cbd5e1' };
}
});
managerSection.addRow(row => {
row.addStarRating('managerRating', {
label: 'Overall, how would you rate your relationship with your direct manager?',
maxStars: 5,
size: 'xl',
alignment: 'center',
showConfettiOnMax: true
});
});
managerSection.addRow(row => {
row.addRatingScale('managerSupport', {
label: 'My manager provides the support I need to succeed',
preset: 'likert-5',
size: 'md',
alignment: 'center',
isVisible: () => managerSection.starRating('managerRating')?.value() !== null
});
});
managerSection.addSpacer();
managerSection.addRow(row => {
row.addTextarea('managerFeedback', {
label: () => {
const rating = managerSection.starRating('managerRating')?.value();
if (rating && rating >= 4) return 'What does your manager do well?';
if (rating && rating <= 2) return 'What could your manager do differently?';
return 'Any feedback about your manager relationship?';
},
placeholder: 'Share specific examples if possible...',
rows: 3,
isVisible: () => managerSection.starRating('managerRating')?.value() !== null
});
});
// ============================================
// PAGE 4: Growth & Future
// ============================================
const page4 = pages.addPage('growth');
page4.addRow(row => {
row.addTextPanel('page4Title', {
label: '',
computedValue: () => 'Part 4: Growth & Future',
customStyles: { fontWeight: 'bold', fontSize: '18px', marginBottom: '8px' }
});
});
// Career Growth Rating Scale
const growthSection = page4.addSubform('growthSection', {
title: 'Career Development'
});
growthSection.addRow(row => {
row.addRatingScale('careerProgress', {
label: 'I feel I am making progress toward my career goals',
preset: 'likert-7',
size: 'md',
alignment: 'center'
});
});
growthSection.addSpacer();
growthSection.addRow(row => {
row.addTextarea('careerGoals', {
label: 'What are your career goals for the next 1-2 years?',
placeholder: 'Where do you see yourself? What skills do you want to develop?',
rows: 3
});
});
growthSection.addSpacer();
growthSection.addRow(row => {
row.addTextarea('growthSupport', {
label: 'What could the company do to better support your career growth?',
placeholder: 'Training, mentorship, projects, promotions, etc.',
rows: 3
});
});
// Flight Risk Assessment
const riskSection = page4.addSubform('riskSection', {
title: 'Looking Ahead',
customStyles: { backgroundColor: '#fef3c7', padding: '16px', borderRadius: '8px' }
});
riskSection.addRow(row => {
row.addRadioButton('stayLikelihood', {
label: 'Do you see yourself still working here in 12 months?',
options: [
{ id: 'definitely', name: 'Definitely yes' },
{ id: 'probably', name: 'Probably yes' },
{ id: 'unsure', name: 'Unsure' },
{ id: 'probably-no', name: 'Probably not' },
{ id: 'no', name: 'Definitely not' }
],
orientation: 'vertical'
});
});
riskSection.addRow(row => {
row.addTextarea('leaveReasons', {
label: 'What might cause you to consider leaving?',
placeholder: 'Be honest - this helps us address issues before they become problems...',
rows: 3,
isVisible: () => {
const likelihood = riskSection.radioButton('stayLikelihood')?.value();
return likelihood === 'unsure' || likelihood === 'probably-no' || likelihood === 'no';
}
});
});
riskSection.addRow(row => {
row.addTextarea('keepFactors', {
label: 'What would make you more likely to stay long-term?',
placeholder: 'Changes, opportunities, or improvements you\'d like to see...',
rows: 3
});
});
// ============================================
// SUMMARY SECTION (after pages)
// ============================================
const summarySection = form.addSubform('summary', {
title: 'Interview Summary',
isVisible: () => engagementSection.slider('engagementLevel')?.value() !== null
});
summarySection.addRow(row => {
row.addTextPanel('summaryContent', {
computedValue: () => {
const engagement = engagementSection.slider('engagementLevel')?.value();
const balance = balanceSection.emojiRating('workLifeBalance')?.value();
const stayReasons = stayReasonsSection.suggestionChips('stayReasons')?.value() || [];
const managerRating = managerSection.starRating('managerRating')?.value();
const stayLikelihood = riskSection.radioButton('stayLikelihood')?.value();
let summary = '📋 Stay Interview Summary\n';
summary += '━'.repeat(28) + '\n\n';
// Engagement
if (engagement) {
const engEmoji = engagement >= 8 ? '🟢' : engagement >= 5 ? '🟡' : '🔴';
summary += `${engEmoji} Engagement Level: ${engagement}/10\n`;
}
// Work-Life Balance
if (balance) {
const balanceLabels: Record<string, string> = {
'very-bad': '😢 Poor',
'bad': '😕 Below Average',
'neutral': '😐 Moderate',
'good': '🙂 Good',
'excellent': '😊 Excellent'
};
summary += `⚖️ Work-Life Balance: ${balanceLabels[balance] || balance}\n`;
}
// Manager Rating
if (managerRating) {
summary += `👔 Manager Relationship: ${'⭐'.repeat(managerRating)}${managerRating}/5\n`;
}
// Stay Reasons
if (stayReasons.length > 0) {
summary += `\n💚 Top Reasons to Stay: ${stayReasons.length} selected\n`;
}
// Retention Risk
if (stayLikelihood) {
const riskLabels: Record<string, string> = {
'definitely': '🟢 Low Risk',
'probably': '🟢 Low Risk',
'unsure': '🟡 Medium Risk',
'probably-no': '🟠 High Risk',
'no': '🔴 Critical Risk'
};
summary += `\n📊 Retention Outlook: ${riskLabels[stayLikelihood] || stayLikelihood}`;
}
return summary;
},
customStyles: () => {
const stayLikelihood = riskSection.radioButton('stayLikelihood')?.value();
const baseStyles = {
padding: '16px',
borderRadius: '8px',
whiteSpace: 'pre-wrap',
fontFamily: 'monospace',
fontSize: '14px'
};
if (stayLikelihood === 'definitely' || stayLikelihood === 'probably') {
return { ...baseStyles, backgroundColor: '#d1fae5', borderLeft: '4px solid #10b981' };
} else if (stayLikelihood === 'probably-no' || stayLikelihood === 'no') {
return { ...baseStyles, backgroundColor: '#fee2e2', borderLeft: '4px solid #ef4444' };
}
return { ...baseStyles, backgroundColor: '#fef3c7', borderLeft: '4px solid #f59e0b' };
}
});
});
// ============================================
// FORM CONFIGURATION
// ============================================
form.configureSubmitButton({
label: 'Complete Stay Interview'
});
form.configureCompletionScreen({
type: 'text',
title: 'Thank You for Your Openness',
message: 'Your feedback is incredibly valuable. Your manager or HR will follow up to discuss action items based on your responses. Together, we can make this a great place to work.'
});
}