import type { Meta, StoryObj } from "@storybook/react"; import { SurveyBuilder } from "./survey-builder"; const meta: Meta = { title: "Widgets/SurveyBuilder", component: SurveyBuilder, parameters: { layout: "padded", }, tags: ["autodocs"], argTypes: { survey: { control: false }, readOnly: { control: "boolean" }, onChange: { action: "survey changed" }, onQuestionSelect: { action: "question selected" }, }, }; export default meta; type Story = StoryObj; /** * Default empty survey builder. * Ready to add questions and configure settings. */ export const Default: Story = { args: { survey: { id: "1", title: "New Survey", description: "Create your survey by adding questions", questions: [], settings: { showProgressBar: true, allowBack: true, randomizeQuestions: false, }, }, readOnly: false, }, }; /** * Survey with various question types. * Demonstrates different input fields and options. */ export const WithQuestions: Story = { args: { survey: { id: "2", title: "Sample Survey", description: "A survey with multiple question types", questions: [ { id: "q1", type: "text", title: "What is your name?", required: true, placeholder: "Enter your full name", }, { id: "q2", type: "email", title: "What is your email address?", description: "We will use this to send you updates", required: true, placeholder: "you@example.com.ai", }, { id: "q3", type: "single-choice", title: "How satisfied are you with our service?", required: true, options: [ { id: "o1", label: "Very Satisfied", value: "5" }, { id: "o2", label: "Satisfied", value: "4" }, { id: "o3", label: "Neutral", value: "3" }, { id: "o4", label: "Dissatisfied", value: "2" }, { id: "o5", label: "Very Dissatisfied", value: "1" }, ], }, { id: "q4", type: "multiple-choice", title: "Which features do you use most? (Select all that apply)", options: [ { id: "o1", label: "Dashboard", value: "dashboard" }, { id: "o2", label: "Reports", value: "reports" }, { id: "o3", label: "Analytics", value: "analytics" }, { id: "o4", label: "Integrations", value: "integrations" }, ], }, { id: "q5", type: "rating", title: "Rate our customer support", description: "1 = Poor, 5 = Excellent", required: false, validation: { min: 1, max: 5, }, }, { id: "q6", type: "textarea", title: "Any additional comments?", placeholder: "Share your thoughts...", required: false, }, ], settings: { showProgressBar: true, allowBack: true, randomizeQuestions: false, }, }, readOnly: false, }, }; /** * Customer feedback survey template. * Pre-configured questions for collecting customer feedback. */ export const CustomerFeedback: Story = { args: { survey: { id: "3", title: "Customer Feedback Survey", description: "Help us improve by sharing your experience", questions: [ { id: "q1", type: "rating", title: "How would you rate your overall experience with our product?", required: true, validation: { min: 1, max: 5 }, }, { id: "q2", type: "single-choice", title: "How likely are you to recommend us to a friend or colleague?", description: "Net Promoter Score", required: true, options: [ { id: "o1", label: "0 - Not at all likely", value: "0" }, { id: "o2", label: "5 - Neutral", value: "5" }, { id: "o3", label: "10 - Extremely likely", value: "10" }, ], }, { id: "q3", type: "multiple-choice", title: "What aspects of our service do you value most?", options: [ { id: "o1", label: "Quality", value: "quality" }, { id: "o2", label: "Price", value: "price" }, { id: "o3", label: "Customer Service", value: "service" }, { id: "o4", label: "Speed/Efficiency", value: "speed" }, { id: "o5", label: "Reliability", value: "reliability" }, ], }, { id: "q4", type: "textarea", title: "What can we do to improve?", placeholder: "Your suggestions help us get better", required: false, }, ], settings: { showProgressBar: true, allowBack: true, randomizeQuestions: false, }, }, readOnly: false, }, }; /** * Employee engagement survey template. * Questions designed for internal team feedback. */ export const EmployeeEngagement: Story = { args: { survey: { id: "4", title: "Employee Engagement Survey", description: "Your feedback helps us create a better workplace", questions: [ { id: "q1", type: "scale", title: "How satisfied are you with your current role?", required: true, validation: { min: 1, max: 10 }, }, { id: "q2", type: "single-choice", title: "Do you feel valued by your team?", required: true, options: [ { id: "o1", label: "Always", value: "always" }, { id: "o2", label: "Often", value: "often" }, { id: "o3", label: "Sometimes", value: "sometimes" }, { id: "o4", label: "Rarely", value: "rarely" }, { id: "o5", label: "Never", value: "never" }, ], }, { id: "q3", type: "multiple-choice", title: "What would improve your work experience?", options: [ { id: "o1", label: "Better work-life balance", value: "balance" }, { id: "o2", label: "Career development opportunities", value: "development", }, { id: "o3", label: "More recognition", value: "recognition" }, { id: "o4", label: "Better tools and resources", value: "tools" }, { id: "o5", label: "Improved communication", value: "communication", }, ], }, { id: "q4", type: "rating", title: "How effective is communication from management?", required: true, validation: { min: 1, max: 5 }, }, { id: "q5", type: "boolean", title: "Would you recommend this company as a great place to work?", required: true, }, { id: "q6", type: "textarea", title: "What do you enjoy most about working here?", required: false, }, { id: "q7", type: "textarea", title: "What suggestions do you have for improvement?", required: false, }, ], settings: { showProgressBar: true, allowBack: true, randomizeQuestions: false, }, }, readOnly: false, }, }; /** * Read-only survey preview. * Shows the survey without editing capabilities. */ export const ReadOnly: Story = { args: { survey: { id: "5", title: "Sample Survey", description: "Preview mode - no editing allowed", questions: [ { id: "q1", type: "text", title: "What is your name?", required: true, }, { id: "q2", type: "email", title: "What is your email?", required: true, }, { id: "q3", type: "single-choice", title: "How did you hear about us?", options: [ { id: "o1", label: "Search Engine", value: "search" }, { id: "o2", label: "Social Media", value: "social" }, { id: "o3", label: "Friend/Colleague", value: "referral" }, { id: "o4", label: "Other", value: "other" }, ], }, ], settings: { showProgressBar: true, allowBack: true, randomizeQuestions: false, }, }, readOnly: true, }, };