export function mentalHealthCheckinSurvey(form: FormTs) {
// Mental Health Check-in - Mood and Wellness Tracking Form
// Demonstrates: EmojiRating (mood preset), Slider, conditional visibility, dynamic styling, supportive messaging
// ============================================
// HEADER
// ============================================
form.addRow(row => {
row.addTextPanel('header', {
label: 'Mental Health Check-in',
computedValue: () => 'Take a moment to reflect on how you\'re feeling. Your wellbeing matters.',
customStyles: {
backgroundColor: '#6366f1',
color: 'white',
padding: '24px',
borderRadius: '12px',
textAlign: 'center'
}
});
});
// ============================================
// SECTION 1: Current Mood
// ============================================
const moodSection = form.addSubform('moodSection', {
title: 'How Are You Feeling Right Now?',
customStyles: () => {
const mood = moodSection.emojiRating('currentMood')?.value();
if (mood === 'excited' || mood === 'happy') {
return { backgroundColor: '#d1fae5', padding: '16px', borderRadius: '8px' };
}
if (mood === 'sad' || mood === 'down') {
return { backgroundColor: '#ede9fe', padding: '16px', borderRadius: '8px' };
}
return { backgroundColor: '#f8fafc', padding: '16px', borderRadius: '8px' };
}
});
moodSection.addRow(row => {
row.addEmojiRating('currentMood', {
label: 'Select the emoji that best describes your mood:',
preset: 'mood',
size: 'lg',
showLabels: true,
alignment: 'center',
isRequired: true
});
});
// Dynamic supportive message based on mood
moodSection.addRow(row => {
row.addTextPanel('moodMessage', {
computedValue: () => {
const mood = moodSection.emojiRating('currentMood')?.value();
switch (mood) {
case 'excited':
return "That's wonderful! It's great to hear you're feeling excited and energized.";
case 'happy':
return "Nice! Feeling happy is something to appreciate. Let's capture what's going well.";
case 'neutral':
return "It's okay to feel neutral. Let's check in on a few more things.";
case 'down':
return "Thank you for sharing. It takes courage to acknowledge difficult feelings.";
case 'sad':
return "We're sorry you're feeling this way. Remember, it's okay to not be okay sometimes.";
default:
return '';
}
},
customStyles: () => {
const mood = moodSection.emojiRating('currentMood')?.value();
if (!mood) return { display: 'none' };
return {
padding: '12px',
borderRadius: '8px',
backgroundColor: mood === 'excited' || mood === 'happy' ? '#ecfdf5' :
mood === 'sad' || mood === 'down' ? '#f5f3ff' : '#f1f5f9',
fontStyle: 'italic',
textAlign: 'center',
marginTop: '8px'
};
},
isVisible: () => moodSection.emojiRating('currentMood')?.value() !== null
});
});
// ============================================
// SECTION 2: Energy & Stress Levels
// ============================================
const levelsSection = form.addSubform('levelsSection', {
title: 'Energy & Stress Levels',
isVisible: () => moodSection.emojiRating('currentMood')?.value() !== null
});
levelsSection.addRow(row => {
row.addSlider('energyLevel', {
label: 'How is your energy level today?',
min: 1,
max: 10,
step: 1,
defaultValue: 5,
showValue: true,
unit: '/10'
}, '1fr');
row.addSlider('stressLevel', {
label: 'How stressed are you feeling?',
min: 1,
max: 10,
step: 1,
defaultValue: 5,
showValue: true,
unit: '/10'
}, '1fr');
});
levelsSection.addRow(row => {
row.addSlider('sleepQuality', {
label: 'How well did you sleep last night?',
min: 1,
max: 10,
step: 1,
defaultValue: 5,
showValue: true,
unit: '/10'
}, '1fr');
row.addSlider('anxietyLevel', {
label: 'How anxious are you feeling?',
min: 1,
max: 10,
step: 1,
defaultValue: 5,
showValue: true,
unit: '/10'
}, '1fr');
});
// ============================================
// SECTION 3: Positive Factors (for positive moods)
// ============================================
const positiveSection = form.addSubform('positiveSection', {
title: 'What\'s Contributing to Your Good Mood?',
isVisible: () => {
const mood = moodSection.emojiRating('currentMood')?.value();
return mood === 'excited' || mood === 'happy';
},
customStyles: { backgroundColor: '#ecfdf5', padding: '16px', borderRadius: '8px' }
});
positiveSection.addRow(row => {
row.addSuggestionChips('positiveFactors', {
label: 'Select what\'s going well (choose all that apply):',
suggestions: [
{ id: 'accomplishment', name: 'Accomplished something' },
{ id: 'connection', name: 'Connected with others' },
{ id: 'exercise', name: 'Physical activity' },
{ id: 'outdoors', name: 'Time outdoors' },
{ id: 'hobby', name: 'Enjoyed a hobby' },
{ id: 'rest', name: 'Good rest/sleep' },
{ id: 'work', name: 'Work going well' },
{ id: 'mindfulness', name: 'Mindfulness/meditation' }
],
alignment: 'center'
});
});
positiveSection.addSpacer();
positiveSection.addRow(row => {
row.addTextarea('gratitude', {
label: 'What are you grateful for today?',
placeholder: 'Share one or more things you\'re thankful for...',
rows: 2,
autoExpand: true
});
});
// ============================================
// SECTION 4: Challenges (for difficult moods)
// ============================================
const challengesSection = form.addSubform('challengesSection', {
title: 'What\'s Affecting Your Mood?',
isVisible: () => {
const mood = moodSection.emojiRating('currentMood')?.value();
return mood === 'down' || mood === 'sad';
},
customStyles: { backgroundColor: '#f5f3ff', padding: '16px', borderRadius: '8px' }
});
challengesSection.addRow(row => {
row.addSuggestionChips('stressors', {
label: 'What factors are contributing? (Select all that apply):',
suggestions: [
{ id: 'work', name: 'Work stress' },
{ id: 'relationships', name: 'Relationship issues' },
{ id: 'health', name: 'Health concerns' },
{ id: 'finances', name: 'Financial worries' },
{ id: 'sleep', name: 'Poor sleep' },
{ id: 'isolation', name: 'Feeling isolated' },
{ id: 'uncertainty', name: 'Uncertainty/change' },
{ id: 'overwhelm', name: 'Feeling overwhelmed' }
],
alignment: 'center'
});
});
challengesSection.addSpacer();
challengesSection.addRow(row => {
row.addTextarea('challengeDetails', {
label: 'Would you like to share more about what\'s on your mind?',
placeholder: 'This is a safe space to express your thoughts...',
rows: 3,
autoExpand: true
});
});
// Support resources for low moods
challengesSection.addRow(row => {
row.addTextPanel('supportMessage', {
label: 'Support Resources',
computedValue: () => {
const mood = moodSection.emojiRating('currentMood')?.value();
if (mood !== 'sad') return '';
return 'Remember: It\'s okay to ask for help. Consider reaching out to a trusted friend, family member, or mental health professional. If you\'re in crisis, please contact a helpline in your area.';
},
customStyles: {
padding: '12px',
borderRadius: '8px',
backgroundColor: '#fef3c7',
borderLeft: '4px solid #f59e0b',
fontSize: '14px'
},
isVisible: () => moodSection.emojiRating('currentMood')?.value() === 'sad'
});
});
// ============================================
// SECTION 5: Coping & Self-Care
// ============================================
const copingSection = form.addSubform('copingSection', {
title: 'Self-Care Today',
isVisible: () => moodSection.emojiRating('currentMood')?.value() !== null
});
copingSection.addRow(row => {
row.addCheckboxList('selfCareActivities', {
label: 'Which self-care activities have you done today?',
options: [
{ id: 'exercise', name: 'Physical exercise' },
{ id: 'healthy-eating', name: 'Healthy eating' },
{ id: 'hydration', name: 'Stayed hydrated' },
{ id: 'social', name: 'Social connection' },
{ id: 'nature', name: 'Time in nature' },
{ id: 'rest', name: 'Rest/relaxation' },
{ id: 'mindfulness', name: 'Mindfulness/breathing' },
{ id: 'hobby', name: 'Enjoyed a hobby' },
{ id: 'none', name: 'None yet' }
],
orientation: 'vertical'
});
});
copingSection.addRow(row => {
row.addThumbRating('needsSupport', {
label: 'Would you like to speak with someone about how you\'re feeling?',
showLabels: true,
upLabel: 'Yes, please',
downLabel: 'Not right now',
alignment: 'left'
});
});
// Contact section if they need support
const contactSection = form.addSubform('contactSection', {
title: 'Contact Information',
isVisible: () => copingSection.thumbRating('needsSupport')?.value() === 'up',
customStyles: { backgroundColor: '#dbeafe', padding: '16px', borderRadius: '8px' }
});
contactSection.addRow(row => {
row.addTextPanel('contactNote', {
computedValue: () => 'A member of our wellness team will reach out to you. Your information is confidential.',
customStyles: {
fontSize: '14px',
color: '#1e40af',
marginBottom: '12px'
}
});
});
contactSection.addRow(row => {
row.addTextbox('preferredName', {
label: 'Preferred Name',
placeholder: 'How should we address you?',
isRequired: true
}, '1fr');
row.addEmail('contactEmail', {
label: 'Email Address',
placeholder: 'your@email.com',
isRequired: true
}, '1fr');
});
contactSection.addRow(row => {
row.addDropdown('contactPreference', {
label: 'Preferred contact method',
options: [
{ id: 'email', name: 'Email' },
{ id: 'phone', name: 'Phone call' },
{ id: 'video', name: 'Video call' },
{ id: 'in-person', name: 'In-person meeting' }
],
placeholder: 'Select your preference'
}, '1fr');
row.addDropdown('urgency', {
label: 'How soon would you like to connect?',
options: [
{ id: 'today', name: 'Today if possible' },
{ id: 'few-days', name: 'Within a few days' },
{ id: 'week', name: 'This week' },
{ id: 'flexible', name: 'Flexible' }
],
placeholder: 'Select'
}, '1fr');
});
// ============================================
// SECTION 6: Summary & Reflection
// ============================================
const summarySection = form.addSubform('summarySection', {
title: 'Check-in Summary',
isVisible: () => moodSection.emojiRating('currentMood')?.value() !== null
});
summarySection.addRow(row => {
row.addTextPanel('summaryContent', {
computedValue: () => {
const mood = moodSection.emojiRating('currentMood')?.value();
const energy = levelsSection.slider('energyLevel')?.value();
const stress = levelsSection.slider('stressLevel')?.value();
const sleep = levelsSection.slider('sleepQuality')?.value();
const anxiety = levelsSection.slider('anxietyLevel')?.value();
const selfCare = copingSection.checkboxList('selfCareActivities')?.value() || [];
if (!mood) return '';
const moodLabels: Record<string, string> = {
'excited': '🤩 Excited',
'happy': '😊 Happy',
'neutral': '😐 Neutral',
'down': '😔 Down',
'sad': '😢 Sad'
};
let summary = `Today's Check-in\n`;
summary += `${'═'.repeat(22)}\n\n`;
summary += `Mood: ${moodLabels[mood] || mood}\n\n`;
if (energy !== null && energy !== undefined) {
summary += `Energy: ${energy}/10 ${energy >= 7 ? '⚡' : energy <= 3 ? '🔋' : ''}\n`;
}
if (stress !== null && stress !== undefined) {
summary += `Stress: ${stress}/10 ${stress >= 7 ? '⚠️' : stress <= 3 ? '✨' : ''}\n`;
}
if (sleep !== null && sleep !== undefined) {
summary += `Sleep: ${sleep}/10 ${sleep >= 7 ? '😴' : sleep <= 3 ? '😫' : ''}\n`;
}
if (anxiety !== null && anxiety !== undefined) {
summary += `Anxiety: ${anxiety}/10 ${anxiety >= 7 ? '😰' : anxiety <= 3 ? '😌' : ''}\n`;
}
if (selfCare.length > 0 && !selfCare.includes('none')) {
summary += `\n✓ Self-care activities: ${selfCare.length}\n`;
}
// Add encouragement based on overall state
summary += `\n${'─'.repeat(22)}\n`;
if (mood === 'excited' || mood === 'happy') {
summary += `Keep nurturing what brings you joy!`;
} else if (mood === 'neutral') {
summary += `Small steps can shift your day.`;
} else {
summary += `Be gentle with yourself today.`;
}
return summary;
},
customStyles: () => {
const mood = moodSection.emojiRating('currentMood')?.value();
const baseStyles = {
padding: '16px',
borderRadius: '8px',
whiteSpace: 'pre-wrap',
fontFamily: 'monospace',
fontSize: '14px'
};
if (mood === 'excited' || mood === 'happy') {
return { ...baseStyles, backgroundColor: '#d1fae5', borderLeft: '4px solid #10b981' };
} else if (mood === 'neutral') {
return { ...baseStyles, backgroundColor: '#e0f2fe', borderLeft: '4px solid #3b82f6' };
} else {
return { ...baseStyles, backgroundColor: '#ede9fe', borderLeft: '4px solid #8b5cf6' };
}
}
});
});
// ============================================
// FORM CONFIGURATION
// ============================================
form.configureSubmitButton({
label: 'Complete Check-in',
isVisible: () => moodSection.emojiRating('currentMood')?.value() !== null
});
form.configureCompletionScreen({
type: 'text',
title: 'Thank You for Checking In',
message: 'Taking time to reflect on your mental health is an important act of self-care. Remember, every day is a new opportunity. Take care of yourself.'
});
}