# Form Builder Technical Appendix
This document provides technical details and code snippets for the form builder implementation.
## Table of Contents
1. [Component Structure](#component-structure)
2. [State Management](#state-management)
3. [Drag and Drop Implementation](#drag-and-drop-implementation)
4. [FormKit Integration](#formkit-integration)
5. [Validation System](#validation-system)
6. [Icons and UI Elements](#icons-and-ui-elements)
7. [Responsive Design](#responsive-design)
## Component Structure
The form builder is built with a modular component structure:
```
pages/
├── form-builder/
│ ├── index.vue # Main form builder page
│ └── manage.vue # Form management page
components/
├── FormBuilderComponents.vue # Left panel components
├── FormBuilderCanvas.vue # Middle panel canvas
├── FormBuilderConfiguration.vue # Right panel configuration
└── ComponentPreview.vue # Component rendering
stores/
└── formBuilder.js # State management
composables/
└── useToast.js # Toast notifications
```
## State Management
### Pinia Store (stores/formBuilder.js)
The form builder uses Pinia for state management:
```javascript
export const useFormBuilderStore = defineStore('formBuilder', {
state: () => ({
formComponents: [],
selectedComponentId: null,
formName: 'New Form',
formDescription: '',
isDraggingOver: false,
savedForms: []
}),
getters: {
selectedComponent: (state) => {
return state.selectedComponentId
? state.formComponents.find(c => c.id === state.selectedComponentId)
: null;
},
formConfig: (state) => {
return {
id: uuidv4(),
name: state.formName,
description: state.formDescription,
components: state.formComponents.map(c => ({
type: c.type,
props: c.props
})),
createdAt: new Date().toISOString()
};
}
},
actions: {
addComponent(component) {
const newComponent = {
...component,
id: uuidv4(),
props: {
...component.defaultProps,
name: `${component.type}_${this.formComponents.length + 1}`,
label: `${component.name} ${this.formComponents.length + 1}`
}
};
this.formComponents.push(newComponent);
this.selectComponent(newComponent.id);
},
// ... other actions
},
persist: {
paths: ['savedForms']
}
});
```
## Drag and Drop Implementation
### Draggable Components
The form builder uses `vuedraggable` for drag-and-drop functionality:
```vue
Available Validations