How vform666/variant-form3-vite works
Project’s Main Purpose and Type
• The README clearly states it is “Variant Form 3 For Vue 3.x” – a low-code form designer that supports both form design (designer component) and form rendering (render component).
• The project is a front-end focused, Vue 3 application built with Vite, intended to be integrated into Vue 3 projects via component registration.
Break Down the Core Components
a. Frontend Shell & Entry:
– index.html and main.js form the entry point.
– Vite configuration files (vite.config.js, vite-lib.config.js, vite-lib-render.config.js) define build pipelines for different outputs.
b. Form Designer Module:
– Located in src/components/form-designer.
– Contains UI parts for drag-and-drop design, component panels, toolbars, and a setting panel.
– Includes many submodules (e.g., code-editor, widget-panel, property-editor with its many specialized editors).
– Extension support provided in src/extension for loading and integrating extra form components.
c. Form Renderer Module:
– Located in src/components/form-render.
– Responsible for rendering the designed forms based on a JSON schema and handling interaction/validation.
d. Supporting Utilities:
– src/utils contains helpers for generating code (vue2js-generator.js, vue3js-generator.js, sfc-generator.js, code-generator.js), directives, event bus, internationalization (i18n.js, smart-vue-i18n), and configuration.
– Libraries like “vuedraggable” in the lib folder facilitate drag-and-drop functionality.
e. Assets and Styles:
– Global styles in src/styles (global.scss, index.scss) ensure a consistent UI.
Relationships and Data Flow
• That both modules share the underlying form schema, which is manipulated by the designer and interpreted/rendered by the renderer.
– Data flow from the designer’s output (JSON/form configuration) to the renderer’s consumption.
– Interaction layers: UI actions in the designer panel trigger changes in the settings panel (via property-editor components) and update underlying data.
– Utility functions that bridge code generation and runtime behavior.
• That the extension loader (in src/extension) is responsible for importing additional widgets and sample extensions, thereby promoting customizability.
Architectural Patterns and Design Principles
• The project relies on component-based architecture typical to Vue applications.
• It separates concerns by dividing the UI into multiple layers: design components (widget panels, toolbars, settings), rendering components, and utility helpers.
• There is a focus on reusability and extensibility: for instance, the detailed property-editor folders indicate a strategy to modularize widget configuration.
• Use of external libraries (e.g., Element Plus for UI components, vuedraggable for drag & drop) is highlighted in both the README and file structure.