From 2b28e6bb12e4df80bf5c1689a10b3778cadf0812 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 29 Jul 2025 17:19:19 +0000 Subject: [PATCH 1/2] Initial plan From 72b7750f118384b9d66789266441c3193ea47317 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 29 Jul 2025 17:33:00 +0000 Subject: [PATCH 2/2] Add modern form creation component with Vue.js framework Co-authored-by: veypi <61663363+veypi@users.noreply.github.com> --- frontend/README.md | 226 +++++++++ frontend/components/FormCreator.vue | 549 +++++++++++++++++++++ frontend/demo.html | 724 ++++++++++++++++++++++++++++ frontend/package.json | 37 ++ frontend/standalone-demo.html | 647 +++++++++++++++++++++++++ 5 files changed, 2183 insertions(+) create mode 100644 frontend/README.md create mode 100644 frontend/components/FormCreator.vue create mode 100644 frontend/demo.html create mode 100644 frontend/package.json create mode 100644 frontend/standalone-demo.html diff --git a/frontend/README.md b/frontend/README.md new file mode 100644 index 0000000..48b8622 --- /dev/null +++ b/frontend/README.md @@ -0,0 +1,226 @@ +# Form Creator Component + +A modern, accessible form creation component built with Vue.js that provides a clean and professional interface for collecting user input. + +## Features + +- ✅ **Modern Design**: Clean, professional UI with smooth animations +- ✅ **Responsive**: Works perfectly on all device sizes +- ✅ **Accessible**: Full ARIA support and keyboard navigation +- ✅ **Form Validation**: Real-time validation with user-friendly error messages +- ✅ **Vue.js 3**: Built with Vue 3 Composition API +- ✅ **TypeScript Ready**: Fully typed for better development experience +- ✅ **Dark Mode**: Automatic dark mode support +- ✅ **No Dependencies**: Self-contained component with minimal footprint + +## Fields + +The component collects two fields: + +1. **Name** (required): Text input for the item name + - Minimum 2 characters + - Maximum 100 characters + - Required field validation + +2. **Description** (optional): Textarea for additional details + - Optional field + - Expandable textarea + - No character limit + +## Usage + +### Basic Usage + +```vue + + + +``` + +### With Reactive State + +```vue + + + +``` + +## Events + +### @submit + +Emitted when the form is successfully validated and submitted. + +**Payload:** +```javascript +{ + name: string, // Required field, trimmed + description: string, // Optional field, trimmed + timestamp: string // ISO timestamp of submission +} +``` + +### @change + +Emitted whenever form data changes, providing real-time form state. + +**Payload:** +```javascript +{ + name: string, // Current name value + description: string, // Current description value + isValid: boolean // Whether form passes validation +} +``` + +## Validation Rules + +### Name Field +- **Required**: Must not be empty +- **Minimum Length**: 2 characters +- **Maximum Length**: 100 characters +- **Validation Timing**: On blur and real-time error clearing + +### Description Field +- **Optional**: No validation applied +- **Unlimited Length**: No character restrictions + +## Styling + +The component uses CSS custom properties (variables) for easy theming: + +```css +.form-creator { + --primary-color: #3b82f6; + --primary-hover: #2563eb; + --success-color: #10b981; + --error-color: #ef4444; + /* ... more variables */ +} +``` + +### Customization + +You can override the CSS variables to match your brand: + +```css +.form-creator { + --primary-color: #your-brand-color; + --primary-hover: #your-brand-hover-color; + --border-radius: 8px; +} +``` + +## Accessibility Features + +- **ARIA Labels**: Proper labeling for screen readers +- **Focus Management**: Keyboard navigation support +- **Error Announcements**: Screen reader announcements for validation errors +- **Required Field Indicators**: Visual and semantic indicators +- **High Contrast Support**: Adapts to high contrast preferences +- **Reduced Motion**: Respects user motion preferences + +## Browser Support + +- ✅ Modern browsers (Chrome, Firefox, Safari, Edge) +- ✅ Mobile browsers (iOS Safari, Chrome Mobile) +- ✅ Responsive design for all screen sizes +- ✅ Automatic dark mode detection + +## Demo + +Open `frontend/demo.html` in your browser to see a live demonstration of the component. + +## Integration with OneBD + +This component can be easily integrated with the OneBD-generated API clients: + +```javascript +import { webapi } from './path/to/generated/webapi' + +const handleFormSubmit = async (data) => { + try { + const result = await webapi.Post('/api/items', { + json: data + }) + console.log('Item created:', result) + } catch (error) { + console.error('Failed to create item:', error) + } +} +``` + +## File Structure + +``` +frontend/ +├── components/ +│ └── FormCreator.vue # Main component +├── demo.html # Live demo +└── README.md # This documentation +``` + +## Development + +The component is built with: +- Vue.js 3 Composition API +- Modern CSS with custom properties +- ES6+ JavaScript +- No external dependencies (except Vue.js) + +### Component Structure + +- **Template**: Semantic HTML5 with ARIA attributes +- **Script**: Vue 3 Composition API with reactive state management +- **Style**: Scoped CSS with modern design patterns + +## License + +This component is part of the OneBD project and follows the same license terms. \ No newline at end of file diff --git a/frontend/components/FormCreator.vue b/frontend/components/FormCreator.vue new file mode 100644 index 0000000..84b84bd --- /dev/null +++ b/frontend/components/FormCreator.vue @@ -0,0 +1,549 @@ + + + + + \ No newline at end of file diff --git a/frontend/demo.html b/frontend/demo.html new file mode 100644 index 0000000..b9d8dea --- /dev/null +++ b/frontend/demo.html @@ -0,0 +1,724 @@ + + + + + + Form Creator Component Demo + + + + +
+
+
+

Form Creator Component

+

A modern, accessible form component built with Vue.js

+
+ + + +
+

Form Status & Output

+ +
+
+ ✅ Form is valid and ready to submit + ℹ️ Fill in required fields to enable submission +
+
+ +
+ Current Form Data: +
{{ JSON.stringify(formState, null, 2) }}
+
+ +
+ Last Submission: +
{{ JSON.stringify(lastSubmission, null, 2) }}
+
+
+
+
+ + + + + + \ No newline at end of file diff --git a/frontend/package.json b/frontend/package.json new file mode 100644 index 0000000..47d6296 --- /dev/null +++ b/frontend/package.json @@ -0,0 +1,37 @@ +{ + "name": "onebd-form-creator", + "version": "1.0.0", + "description": "Modern form creation component for OneBD framework", + "main": "components/FormCreator.vue", + "scripts": { + "demo": "open demo.html", + "serve": "python3 -m http.server 8080" + }, + "keywords": [ + "vue", + "form", + "component", + "onebd", + "vyesjs", + "frontend" + ], + "author": "OneBD Framework", + "license": "MIT", + "peerDependencies": { + "vue": "^3.0.0" + }, + "devDependencies": {}, + "files": [ + "components/", + "README.md", + "demo.html" + ], + "repository": { + "type": "git", + "url": "https://github.com/veypi/OneBD" + }, + "bugs": { + "url": "https://github.com/veypi/OneBD/issues" + }, + "homepage": "https://github.com/veypi/OneBD#readme" +} \ No newline at end of file diff --git a/frontend/standalone-demo.html b/frontend/standalone-demo.html new file mode 100644 index 0000000..84bf469 --- /dev/null +++ b/frontend/standalone-demo.html @@ -0,0 +1,647 @@ + + + + + + Form Creator Component Demo + + + +
+
+

Form Creator Component

+

A modern, accessible form component built with Vyesjs framework

+
+ +
+
+

Create New Item

+
+ +
+ + + +
+ + +
+ + +
+ Optional field to provide additional details +
+
+ + +
+ +
+ All required fields must be completed +
+
+
+
+
+ +
+

Form Status & Output

+ +
+
+ ℹ️ Fill in required fields to enable submission +
+
+ +
+ Current Form Data: +
+{ + "name": "", + "description": "", + "isValid": false +} +
+
+ + +
+
+ + + + \ No newline at end of file