From 6887a2b9bce084b2f3601d5cd8b7a669fb34baaf Mon Sep 17 00:00:00 2001 From: Md Afiq Iskandar Date: Tue, 24 Jun 2025 12:31:21 +0800 Subject: [PATCH 1/2] Add Form Section Component to Enhance Form Builder Functionality - Introduced a new Form Section component for grouping related form fields, allowing for better organization and layout within forms. - Enhanced ComponentPreview to render the Form Section component with customizable properties such as header visibility, collapsibility, and border styles. - Updated FormBuilderComponents to include the Form Section in the available components list with default properties. - Implemented drag-and-drop functionality for nested components within the Form Section, improving user experience in form design. - Enhanced FormBuilderFieldSettingsModal to support configuration options for the Form Section, including visual and spacing settings. - Improved overall styling and responsiveness of the Form Section component to align with existing UI standards. - Updated documentation to reflect the addition of the Form Section and its configuration options. --- components/ComponentPreview.vue | 535 +++++++++++++++++++ components/FormBuilderCanvas.vue | 9 +- components/FormBuilderComponents.vue | 30 ++ components/FormBuilderFieldSettingsModal.vue | 401 ++++++-------- pages/form-builder/index.vue | 478 +++++++++++++---- 5 files changed, 1132 insertions(+), 321 deletions(-) diff --git a/components/ComponentPreview.vue b/components/ComponentPreview.vue index eb2a021..5f85bf4 100644 --- a/components/ComponentPreview.vue +++ b/components/ComponentPreview.vue @@ -339,16 +339,182 @@ + +
+
+ +
+
+
+

+ {{ component.props.label || 'Section Title' }} +

+

+ {{ component.props.description }} +

+
+
+ +
+
+
+ + +
+ +
+ +
+ +
+ + +
+
+ +

Form Section Container

+

+ This section will contain the form fields grouped here +

+
+
+
+ + +
+ +
+ + + +
+ + +
+
+ +

Drop Components Here

+

+ Drag form fields from the sidebar to add them to this section +

+
+
+
+
+
+
+
Unknown component type: {{ component.type }}
+ + + \ No newline at end of file diff --git a/components/FormBuilderCanvas.vue b/components/FormBuilderCanvas.vue index 248574e..0076bf9 100644 --- a/components/FormBuilderCanvas.vue +++ b/components/FormBuilderCanvas.vue @@ -82,6 +82,7 @@ @@ -113,7 +114,7 @@ const props = defineProps({ } }); -const emit = defineEmits(['select-component', 'move-component', 'delete-component', 'update-component', 'optimize-layout']); +const emit = defineEmits(['select-component', 'move-component', 'delete-component', 'update-component', 'optimize-layout', 'select-nested-component']); const selectedComponentId = ref(null); const resizeMode = ref(false); @@ -162,6 +163,12 @@ const deleteComponent = (id) => { emit('delete-component', id); }; +// Handle nested component selection from sections +const handleNestedComponentSelect = (component) => { + // Pass the nested component selection up to the main form builder + emit('select-nested-component', component); +}; + // Toggle resize mode const toggleResizeMode = (component) => { resizeMode.value = !resizeMode.value; diff --git a/components/FormBuilderComponents.vue b/components/FormBuilderComponents.vue index cd53f0f..235a79b 100644 --- a/components/FormBuilderComponents.vue +++ b/components/FormBuilderComponents.vue @@ -603,6 +603,36 @@ const availableComponents = [ }, // Layout + { + type: 'form-section', + name: 'Form Section', + category: 'Layout', + icon: 'material-symbols:view-module-outline', + description: 'Container to group related form fields into sections', + defaultProps: { + label: 'Section Title', + description: 'Optional section description', + collapsible: false, + collapsed: false, + showBorder: true, + borderStyle: 'solid', // solid, dashed, dotted + backgroundColor: '#ffffff', + headerBackground: '#f9fafb', + showHeader: true, + headerSize: 'medium', // small, medium, large + spacing: 'normal', // compact, normal, relaxed + width: '100%', + gridColumn: 'span 12', + children: [], // Array to hold nested components + // Conditional Logic Properties + conditionalLogic: { + enabled: false, + conditions: [], + action: 'show', + operator: 'and' + } + } + }, { type: 'info-display', name: 'Info Display', diff --git a/components/FormBuilderFieldSettingsModal.vue b/components/FormBuilderFieldSettingsModal.vue index 864fb1e..30a42e6 100644 --- a/components/FormBuilderFieldSettingsModal.vue +++ b/components/FormBuilderFieldSettingsModal.vue @@ -608,264 +608,202 @@ - -