viewlogic 1.1.0 → 1.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # ViewLogic Router
1
+ # ViewLogic Router v1.1.1
2
2
 
3
3
  <p align="center">
4
4
  <a href="https://github.com/hopegiver/viewlogic">
@@ -12,7 +12,15 @@
12
12
  </a>
13
13
  </p>
14
14
 
15
- > A revolutionary Vue 3 routing system with clear separation of View and Logic, enabling real-time development without build steps
15
+ > A revolutionary Vue 3 routing system with automatic data fetching, form handling, and zero build development
16
+
17
+ ## 🆕 Latest Updates (v1.1.1)
18
+
19
+ - ✨ **Automatic Form Handling** - Revolutionary form submission with `{paramName}` variable parameters
20
+ - 🔄 **Multiple API Support** - Parallel data fetching from multiple APIs with named data storage
21
+ - 🛡️ **Enhanced Validation** - HTML5 + custom function validation with graceful error handling
22
+ - 🚀 **Component Loading Resilience** - Router continues to work even if components fail to load
23
+ - 📝 **Comprehensive Documentation** - Extensive real-world examples and usage patterns
16
24
 
17
25
  ## 🎯 Core Philosophy: Simplicity Through Design
18
26
 
@@ -36,6 +44,7 @@ Clear separation between **View** (presentation) and **Logic** (business logic),
36
44
  - 🌐 **i18n Ready** - Built-in internationalization support
37
45
  - 🔐 **Authentication** - Built-in auth management system
38
46
  - 💾 **Smart Caching** - Intelligent route and component caching
47
+ - 📝 **Automatic Form Handling** - Revolutionary form submission with variable parameters
39
48
  - 🚀 **Ultra-Lightweight** - Complete routing system in just 13KB gzipped (48KB minified)
40
49
 
41
50
  ## 📦 Installation
@@ -314,7 +323,8 @@ export default {
314
323
  const title = this.$t('product.title');
315
324
 
316
325
  // Data automatically fetched if dataURL is defined in component
317
- // this.$fetchData() is called automatically in mounted()
326
+ // Single API: this.products available
327
+ // Multiple APIs: this.products, this.categories, this.stats, etc. available
318
328
  console.log('Auto-loaded data:', this.products); // From dataURL
319
329
  },
320
330
  methods: {
@@ -374,7 +384,10 @@ export default {
374
384
  - `$t(key, params)` - Translate text with optional parameters
375
385
 
376
386
  #### Data Management Functions
377
- - `$fetchData()` - Fetch data from dataURL (if defined in component)
387
+ - `$fetchData()` - Fetch data from single dataURL or all multiple dataURLs
388
+ - `$fetchData('apiName')` - Fetch data from specific named API (multiple dataURL mode)
389
+ - `$fetchAllData()` - Explicitly fetch all APIs (works for both single and multiple dataURL)
390
+ - `$fetchMultipleData()` - Internal method for multiple API handling
378
391
 
379
392
  ### Component Data Properties
380
393
 
@@ -556,6 +569,7 @@ ViewLogic Router provides a complete routing solution in an incredibly small pac
556
569
  - ✅ Development/production modes
557
570
  - ✅ **Automatic data fetching with dataURL**
558
571
  - ✅ **Revolutionary DynamicInclude & HtmlInclude components**
572
+ - ✅ **Automatic form handling with variable parameters**
559
573
  - ✅ **10+ Built-in UI components (Button, Modal, Card, etc.)**
560
574
 
561
575
  ### Why So Small?
@@ -570,46 +584,7 @@ ViewLogic Router provides a complete routing solution in an incredibly small pac
570
584
  - **Mobile Optimized** - Perfect for mobile-first applications
571
585
  - **CDN Friendly** - Small size ideal for CDN distribution
572
586
 
573
- ## Performance Comparison: Development vs Production
574
-
575
- ### Development Mode Performance
576
- ```
577
- Route Loading Process:
578
- ├── 1️⃣ Load logic file (products/list.js)
579
- ├── 2️⃣ Load view file (products/list.html)
580
- ├── 3️⃣ Load style file (products/list.css)
581
- └── 4️⃣ Load layout file (default.html)
582
-
583
- Total: 4 HTTP requests per route
584
- Best for: Development and debugging
585
- ```
586
-
587
- ### Production Mode Performance
588
- ```
589
- Route Loading Process:
590
- └── 1️⃣ Load single bundle (products/list.js)
591
- ├── ✅ View template (pre-bundled)
592
- ├── ✅ Business logic (minified)
593
- └── ✅ Styles (inline CSS)
594
-
595
- Total: 1 HTTP request per route
596
- Best for: Production deployment
597
- ```
598
-
599
- ### Performance Impact
600
- | Mode | Requests per Route | Bundle Size | Load Time | Use Case |
601
- |------|-------------------|-------------|-----------|----------|
602
- | **Development** | 4 files | Unminified | Slower | Real-time development |
603
- | **Production** | 1 file | Minified | **75% Faster** | Live deployment |
604
-
605
- ### Why Production is Faster
606
- - **Single Request**: No multiple file fetching overhead
607
- - **Pre-bundled Assets**: View, logic, and styles combined at build time
608
- - **Minified Code**: Smaller file sizes for faster network transfer
609
- - **Optimized Parsing**: Browser parses one optimized bundle instead of multiple files
610
- - **Better Caching**: Single file per route enables more efficient browser/CDN caching
611
-
612
- ## 🏆 Performance vs Other Router Systems
587
+ ## 🏆 Performance Comparison
613
588
 
614
589
  ### Bundle Size Comparison
615
590
  | Router System | Bundle Size (Gzipped) | Features Included |
@@ -711,6 +686,10 @@ ViewLogic Router includes groundbreaking components that revolutionize how you h
711
686
  - **Script Execution** - Optional JavaScript execution in HTML content
712
687
 
713
688
  ### Automatic Data Fetching with dataURL
689
+
690
+ ViewLogic Router includes revolutionary automatic data fetching that eliminates manual API calls in component lifecycle hooks.
691
+
692
+ #### Single API (Simple Usage)
714
693
  ```javascript
715
694
  // src/logic/products/list.js
716
695
  export default {
@@ -736,13 +715,59 @@ export default {
736
715
  };
737
716
  ```
738
717
 
718
+ #### Multiple APIs (Advanced Usage) - 🆕 Revolutionary!
719
+ ```javascript
720
+ // src/logic/dashboard/main.js
721
+ export default {
722
+ name: 'DashboardMain',
723
+ dataURL: {
724
+ products: '/api/products',
725
+ categories: '/api/categories',
726
+ stats: '/api/dashboard/stats',
727
+ user: '/api/user/profile'
728
+ }, // ✨ Multiple APIs with named data!
729
+ data() {
730
+ return {
731
+ title: 'Dashboard'
732
+ // products: [], categories: [], stats: {}, user: {}
733
+ // All auto-populated from respective APIs!
734
+ };
735
+ },
736
+ mounted() {
737
+ // All APIs called in parallel, data available by name!
738
+ console.log('Products:', this.products);
739
+ console.log('Categories:', this.categories);
740
+ console.log('Stats:', this.stats);
741
+ console.log('User:', this.user);
742
+ console.log('Loading state:', this.$dataLoading);
743
+ },
744
+ methods: {
745
+ async refreshProducts() {
746
+ // Refresh specific API only
747
+ await this.$fetchData('products');
748
+ },
749
+ async refreshStats() {
750
+ // Refresh specific API only
751
+ await this.$fetchData('stats');
752
+ },
753
+ async refreshAllData() {
754
+ // Refresh all APIs
755
+ await this.$fetchAllData();
756
+ }
757
+ }
758
+ };
759
+ ```
760
+
739
761
  **Features:**
740
762
  - **Zero-Config API Calls** - Just define `dataURL` and data is automatically fetched
741
- - **Query Parameter Integration** - Current route parameters are automatically sent to API
763
+ - **🆕 Multiple API Support** - Define multiple APIs with custom names
764
+ - **🚀 Parallel Processing** - Multiple APIs called simultaneously for best performance
765
+ - **🎯 Selective Refresh** - Refresh specific APIs independently
766
+ - **Query Parameter Integration** - Current route parameters are automatically sent to all APIs
742
767
  - **Loading State Management** - `$dataLoading` property automatically managed
743
- - **Error Handling** - Built-in error handling with events
744
- - **Data Merging** - API response automatically merged into component data
745
- - **Event Support** - `@data-loaded` and `@data-error` events available
768
+ - **Advanced Error Handling** - Per-API error handling with detailed events
769
+ - **Named Data Storage** - Each API result stored with its defined name
770
+ - **Event Support** - `@data-loaded` and `@data-error` events with detailed info
746
771
 
747
772
  ### Why These Components Are Revolutionary
748
773
 
@@ -821,12 +846,21 @@ export default {
821
846
  ### Use Cases
822
847
 
823
848
  #### Automatic Data Fetching (dataURL)
849
+
850
+ **Single API Usage:**
824
851
  - **🛒 Product Listings** - `dataURL: '/api/products'` automatically loads and populates product data
825
852
  - **👤 User Profiles** - `dataURL: '/api/user'` fetches user information with authentication
826
853
  - **📊 Dashboard Data** - `dataURL: '/api/dashboard/stats'` loads analytics data
827
854
  - **📰 Article Content** - `dataURL: '/api/articles'` populates blog posts or news
828
855
  - **🔍 Search Results** - Query parameters automatically sent to search API
829
856
 
857
+ **🆕 Multiple API Usage (Revolutionary!):**
858
+ - **📊 Dashboard Pages** - `dataURL: { stats: '/api/stats', users: '/api/users', orders: '/api/orders' }`
859
+ - **🛒 E-commerce Pages** - `dataURL: { products: '/api/products', cart: '/api/cart', wishlist: '/api/wishlist' }`
860
+ - **👥 Social Media** - `dataURL: { posts: '/api/posts', friends: '/api/friends', notifications: '/api/notifications' }`
861
+ - **📱 Admin Panels** - `dataURL: { analytics: '/api/analytics', logs: '/api/logs', settings: '/api/settings' }`
862
+ - **🎯 Landing Pages** - `dataURL: { hero: '/api/hero-content', testimonials: '/api/testimonials', features: '/api/features' }`
863
+
830
864
  #### Dynamic Components
831
865
  - **📰 Dynamic Content Management** - Load blog posts, news articles dynamically
832
866
  - **🛒 Product Details** - Fetch product information on-demand
@@ -849,284 +883,337 @@ export default {
849
883
 
850
884
  These components eliminate the need for complex state management and manual DOM manipulation, making dynamic content loading as simple as using a regular component.
851
885
 
852
- ## 🔗 Revolutionary Query-Only Parameter System
886
+ ## 📝 Automatic Form Handling with Variable Parameters
887
+
888
+ ViewLogic Router includes revolutionary automatic form handling that eliminates the need for manual form submission logic. Just define your forms with `action` attributes and the router handles the rest!
889
+
890
+ ### Basic Form Handling
853
891
 
854
- ViewLogic Router takes a radically different approach to URL parameters - **everything is query-based**. This design decision brings unprecedented simplicity and flexibility.
892
+ ```html
893
+ <!-- src/views/contact.html -->
894
+ <div class="contact-page">
895
+ <h1>Contact Us</h1>
896
+ <form action="/api/contact" method="POST">
897
+ <input type="text" name="name" required placeholder="Your Name">
898
+ <input type="email" name="email" required placeholder="Your Email">
899
+ <textarea name="message" required placeholder="Your Message"></textarea>
900
+ <button type="submit">Send Message</button>
901
+ </form>
902
+ </div>
903
+ ```
855
904
 
856
- ### Traditional Routing Problems
857
905
  ```javascript
858
- // Traditional Vue Router - Complex path parameters
859
- const routes = [
860
- { path: '/users/:id', component: UserDetail },
861
- { path: '/users/:id/posts/:postId', component: PostDetail },
862
- { path: '/categories/:category/products/:productId', component: ProductDetail }
863
- ]
864
-
865
- // Accessing parameters is inconsistent and complex
906
+ // src/logic/contact.js
866
907
  export default {
908
+ name: 'ContactPage',
867
909
  mounted() {
868
- const userId = this.$route.params.id; // Path parameter
869
- const page = this.$route.query.page; // Query parameter
870
- const search = this.$route.query.search; // Query parameter
871
-
872
- // Complex parameter access logic needed
873
- if (userId && page) {
874
- // Load data...
875
- }
910
+ // Forms are automatically bound - no additional code needed!
911
+ // Form submission will automatically POST to /api/contact
912
+ console.log('Form handling is automatic!');
876
913
  }
877
- }
914
+ };
915
+ ```
916
+
917
+ ### Variable Parameter Forms - 🆕 Revolutionary!
918
+
919
+ The most powerful feature is **variable parameter support** in action URLs. You can use simple template syntax to inject dynamic values:
920
+
921
+ ```html
922
+ <!-- Dynamic form actions with variable parameters -->
923
+ <form action="/api/users/{userId}/posts" method="POST"
924
+ data-success="handlePostSuccess"
925
+ data-error="handlePostError">
926
+ <input type="text" name="title" required placeholder="Post Title">
927
+ <textarea name="content" required placeholder="Post Content"></textarea>
928
+ <button type="submit">Create Post</button>
929
+ </form>
930
+
931
+ <!-- Order update with dynamic order ID -->
932
+ <form action="/api/orders/{orderId}/update" method="PUT"
933
+ data-success="orderUpdated"
934
+ data-redirect="/orders">
935
+ <input type="number" name="quantity" required>
936
+ <select name="status">
937
+ <option value="pending">Pending</option>
938
+ <option value="processing">Processing</option>
939
+ <option value="completed">Completed</option>
940
+ </select>
941
+ <button type="submit">Update Order</button>
942
+ </form>
943
+
944
+ <!-- File upload support -->
945
+ <form action="/api/profile/{userId}/avatar" method="POST" enctype="multipart/form-data"
946
+ data-success="avatarUploaded">
947
+ <input type="file" name="avatar" accept="image/*" required>
948
+ <button type="submit">Upload Avatar</button>
949
+ </form>
878
950
  ```
879
951
 
880
- ### ViewLogic Router Solution - Pure Simplicity
881
952
  ```javascript
882
- // ViewLogic Router - Everything is query-based, no route definitions needed
883
- // Just navigate with parameters
884
- router.navigateTo('users', { id: 123 }); // /users?id=123
885
- router.navigateTo('posts', {
886
- userId: 123,
887
- postId: 456
888
- }); // /posts?userId=123&postId=456
889
-
890
- // In your route component - unified parameter access
953
+ // Component logic - parameters are resolved automatically
891
954
  export default {
892
- mounted() {
893
- const userId = this.getParam('id'); // Always the same method
894
- const postId = this.getParam('postId', 1); // With default value
895
- const allParams = this.getParams(); // Get everything
896
-
897
- // Simple and consistent - no complex logic needed
898
- if (userId) {
899
- this.loadUserData(userId);
900
- }
955
+ name: 'UserProfile',
956
+ data() {
957
+ return {
958
+ userId: 123, // {userId} will be replaced with this value
959
+ orderId: 456 // {orderId} will be replaced with this value
960
+ };
901
961
  },
902
962
  methods: {
903
- loadUserData(id) {
904
- // Use global functions directly
905
- this.navigateTo('user-profile', { id });
963
+ handlePostSuccess(response) {
964
+ console.log('Post created successfully!', response);
965
+ },
966
+ orderUpdated(response) {
967
+ console.log('Order updated!', response);
906
968
  }
907
969
  }
908
- }
970
+ };
909
971
  ```
910
972
 
911
- ### Advantages of Query-Only Parameters
973
+ ### How Parameter Resolution Works
912
974
 
913
- #### 1. **Simplified Route Definition**
914
- ```javascript
915
- // Traditional: Complex nested routes
916
- const routes = [
917
- {
918
- path: '/products/:category',
919
- component: ProductList,
920
- children: [
921
- { path: ':id', component: ProductDetail },
922
- { path: ':id/reviews/:reviewId', component: ReviewDetail }
923
- ]
924
- }
925
- ];
975
+ Parameters are resolved automatically from multiple sources in this order:
926
976
 
927
- // ViewLogic: Simple flat routes
928
- const routes = ['products', 'product-detail', 'review-detail'];
929
- ```
977
+ 1. **Route Parameters**: `this.getParam('paramName')` - from URL query parameters
978
+ 2. **Component Data**: `this.paramName` - from component's data properties
979
+ 3. **Computed Properties**: `this.paramName` - from component's computed properties
930
980
 
931
- #### 2. **Consistent Parameter Access**
932
981
  ```javascript
933
- // Traditional: Multiple ways to access parameters
934
- export default {
935
- mounted() {
936
- const pathParam = this.$route.params.id; // Path parameters
937
- const queryParam = this.$route.query.page; // Query parameters
938
- // Need complex logic to handle both types
939
- }
940
- }
941
-
942
- // ViewLogic: One unified way with global functions
982
+ // Component example
943
983
  export default {
984
+ name: 'UserProfile',
985
+ data() {
986
+ return {
987
+ userId: 123, // Available as {userId} in action URLs
988
+ productId: 456 // Available as {productId} in action URLs
989
+ };
990
+ },
991
+ computed: {
992
+ currentOrderId() { // Available as {currentOrderId} in action URLs
993
+ return this.getParam('orderId') || this.defaultOrderId;
994
+ }
995
+ },
944
996
  mounted() {
945
- const id = this.getParam('id'); // Always the same
946
- const page = this.getParam('page', 1); // Always with defaults
947
- // Clean and simple - no $route needed!
997
+ // Route parameters also work: /user-profile?userId=789
998
+ // {userId} will use 789 from URL, or fall back to data() value of 123
948
999
  }
949
- }
1000
+ };
950
1001
  ```
951
1002
 
952
- #### 3. **Better SEO and URL Sharing**
953
- ```javascript
954
- // Traditional: Hard to understand URLs
955
- /products/electronics/123/reviews/456
1003
+ ### Event Handlers and Callbacks
1004
+
1005
+ Define success and error handlers using data attributes:
956
1006
 
957
- // ViewLogic: Clear, readable URLs
958
- /product-detail?category=electronics&id=123
959
- /review-detail?productId=123&reviewId=456
1007
+ ```html
1008
+ <form action="/api/newsletter/subscribe" method="POST"
1009
+ data-success="subscriptionSuccess"
1010
+ data-error="subscriptionError"
1011
+ data-redirect="/thank-you">
1012
+ <input type="email" name="email" required>
1013
+ <button type="submit">Subscribe</button>
1014
+ </form>
960
1015
  ```
961
1016
 
962
- #### 4. **Enhanced Developer Experience**
963
1017
  ```javascript
964
- // Easy parameter manipulation in route components
1018
+ // src/logic/newsletter.js
965
1019
  export default {
966
- mounted() {
967
- // Easy parameter reading with defaults - no router instance needed!
968
- const category = this.getParam('category', 'all');
969
- const sortBy = this.getParam('sort', 'name');
970
- const currentPage = this.getParam('page', 1);
971
- },
1020
+ name: 'NewsletterPage',
972
1021
  methods: {
973
- applyFilters() {
974
- // Easy navigation with parameters
975
- this.navigateTo('products', {
976
- category: 'electronics',
977
- sort: 'price',
978
- page: 2
979
- });
1022
+ subscriptionSuccess(response, formData) {
1023
+ console.log('Subscription successful!', response);
1024
+ this.$toast('Thank you for subscribing!', 'success');
1025
+ // Form will automatically redirect to /thank-you
1026
+ },
1027
+ subscriptionError(error, formData) {
1028
+ console.error('Subscription failed:', error);
1029
+ this.$toast('Subscription failed. Please try again.', 'error');
980
1030
  }
981
1031
  }
982
- }
1032
+ };
1033
+ ```
1034
+
1035
+ ### Complete Form Options
1036
+
1037
+ ```html
1038
+ <!-- All available data attributes -->
1039
+ <form action="/api/complex/{{getParam('id')}}" method="POST"
1040
+ data-success="handleSuccess" <!-- Success callback method -->
1041
+ data-error="handleError" <!-- Error callback method -->
1042
+ data-redirect="/success" <!-- Auto-redirect on success -->
1043
+ data-confirm="Are you sure?" <!-- Confirmation dialog -->
1044
+ data-loading="Processing..." <!-- Loading message -->
1045
+ enctype="multipart/form-data"> <!-- File upload support -->
1046
+
1047
+ <input type="text" name="title" required>
1048
+ <input type="file" name="attachment" accept=".pdf,.doc">
1049
+ <button type="submit">Submit</button>
1050
+ </form>
1051
+ ```
1052
+
1053
+ ### Authentication Integration
1054
+
1055
+ Forms automatically include authentication tokens when available:
1056
+
1057
+ ```html
1058
+ <!-- Authentication token automatically added for authenticated users -->
1059
+ <form action="/api/protected/resource" method="POST">
1060
+ <input type="text" name="data" required>
1061
+ <button type="submit">Save Protected Data</button>
1062
+ </form>
983
1063
  ```
984
1064
 
985
- ### Real-World Comparison
986
-
987
- | Feature | Traditional Path Params | ViewLogic Query-Only |
988
- |---------|------------------------|---------------------|
989
- | **Route Definition** | Complex nested structure | Simple flat routes |
990
- | **Parameter Access** | Mixed (`params` + `query`) | Unified (`getParam`) |
991
- | **URL Readability** | `/users/123/posts/456` | `/post?userId=123&id=456` |
992
- | **Default Values** | Manual checks needed | Built-in support |
993
- | **Parameter Validation** | Custom validation | Built-in sanitization |
994
- | **SEO Friendliness** | Poor (cryptic paths) | Excellent (descriptive) |
995
- | **URL Bookmarking** | Limited flexibility | Full flexibility |
996
- | **Testing** | Complex mock objects | Simple query strings |
997
-
998
- ### Why Query-Only is Superior
999
-
1000
- 1. **🎯 Simplicity**: No complex route definitions or nested structures
1001
- 2. **🔍 Transparency**: URLs are self-explanatory and human-readable
1002
- 3. **🛠️ Consistency**: One way to handle all parameters
1003
- 4. **⚡ Performance**: Faster route matching without regex patterns
1004
- 5. **🔐 Security**: Built-in parameter validation and sanitization
1005
- 6. **📱 Mobile Friendly**: URLs work perfectly with mobile deep linking
1006
- 7. **🎨 Flexibility**: Easy to add/remove parameters without changing route structure
1007
-
1008
- ### Migration Benefits
1009
1065
  ```javascript
1010
- // Before: Complex route configuration
1011
- const routes = [
1012
- { path: '/blog/:year/:month/:slug', name: 'blog-post' }
1013
- ];
1066
+ // Authentication token automatically included in headers:
1067
+ // Authorization: Bearer <user-token>
1068
+ // No additional code needed!
1069
+ ```
1070
+
1071
+ ### Form Validation
1072
+
1073
+ Built-in client-side validation with custom validation support:
1074
+
1075
+ ```html
1076
+ <!-- HTML5 validation attributes work automatically -->
1077
+ <form action="/api/user/register" method="POST" data-success="registrationSuccess">
1078
+ <input type="email" name="email" required
1079
+ pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$">
1080
+ <input type="password" name="password" required minlength="8">
1081
+ <input type="password" name="confirmPassword" required>
1082
+ <button type="submit">Register</button>
1083
+ </form>
1084
+ ```
1085
+
1086
+ ### Real-World Examples
1087
+
1088
+ #### User Profile Update
1089
+ ```html
1090
+ <!-- User profile with dynamic user ID -->
1091
+ <form action="/api/users/{userId}" method="PUT"
1092
+ data-success="profileUpdated"
1093
+ data-redirect="/profile?updated=true">
1094
+ <input type="text" name="firstName" :value="user.firstName">
1095
+ <input type="text" name="lastName" :value="user.lastName">
1096
+ <input type="email" name="email" :value="user.email">
1097
+ <button type="submit">Update Profile</button>
1098
+ </form>
1099
+ ```
1100
+
1101
+ #### E-commerce Order Management
1102
+ ```html
1103
+ <!-- Order status update with order ID from route -->
1104
+ <form action="/api/orders/{orderId}/status" method="PUT"
1105
+ data-success="orderStatusUpdated">
1106
+ <select name="status" required>
1107
+ <option value="pending">Pending</option>
1108
+ <option value="shipped">Shipped</option>
1109
+ <option value="delivered">Delivered</option>
1110
+ </select>
1111
+ <textarea name="notes" placeholder="Optional notes"></textarea>
1112
+ <button type="submit">Update Status</button>
1113
+ </form>
1114
+ ```
1115
+
1116
+ #### Blog Post Creation
1117
+ ```html
1118
+ <!-- Create post for specific category -->
1119
+ <form action="/api/categories/{categoryId}/posts" method="POST"
1120
+ data-success="postCreated"
1121
+ data-redirect="/posts">
1122
+ <input type="text" name="title" required>
1123
+ <textarea name="content" required></textarea>
1124
+ <input type="file" name="featured_image" accept="image/*">
1125
+ <button type="submit">Create Post</button>
1126
+ </form>
1127
+ ```
1014
1128
 
1015
- // Traditional component access
1129
+ ### Advantages Over Traditional Form Handling
1130
+
1131
+ | Feature | Traditional Vue/React | ViewLogic Router |
1132
+ |---------|----------------------|------------------|
1133
+ | **Setup Required** | Manual event handlers + API calls | ✅ Zero setup - just add `action` |
1134
+ | **Variable Parameters** | Manual string interpolation | ✅ Template syntax with function evaluation |
1135
+ | **Authentication** | Manual token handling | ✅ Automatic token injection |
1136
+ | **File Uploads** | Complex FormData handling | ✅ Automatic multipart support |
1137
+ | **Loading States** | Manual loading management | ✅ Automatic loading indicators |
1138
+ | **Error Handling** | Custom error logic | ✅ Built-in error callbacks |
1139
+ | **Validation** | External validation libraries | ✅ HTML5 + custom validation |
1140
+ | **Redirect Logic** | Manual navigation code | ✅ `data-redirect` attribute |
1141
+
1142
+ ### Code Comparison: Traditional vs ViewLogic
1143
+
1144
+ **Traditional Approach** (30+ lines):
1145
+ ```javascript
1146
+ // Lots of boilerplate for simple form
1016
1147
  export default {
1017
- mounted() {
1018
- const year = this.$route.params.year;
1019
- const month = this.$route.params.month;
1020
- const slug = this.$route.params.slug;
1021
- // Complex logic needed...
1148
+ data() { return { form: {}, loading: false, error: null }; },
1149
+ methods: {
1150
+ async submitForm() {
1151
+ // 20+ lines of fetch, error handling, tokens, etc.
1152
+ }
1022
1153
  }
1023
- }
1154
+ };
1155
+ ```
1024
1156
 
1025
- // After: Simple and flexible - no route definitions needed!
1157
+ **ViewLogic Approach** (5 lines):
1158
+ ```html
1159
+ <form action="/api/contact" data-success="handleSuccess">
1160
+ <input name="name" required>
1161
+ <button type="submit">Send</button>
1162
+ </form>
1163
+ ```
1164
+ ```javascript
1026
1165
  export default {
1027
- mounted() {
1028
- // Clean global function access
1029
- const year = this.getParam('year', new Date().getFullYear());
1030
- const month = this.getParam('month', new Date().getMonth() + 1);
1031
- const slug = this.getParam('slug');
1032
- const utm_source = this.getParam('utm_source'); // Easy to add tracking params
1033
- },
1034
1166
  methods: {
1035
- navigateToPost() {
1036
- this.navigateTo('blog-post', {
1037
- year: 2024,
1038
- month: 12,
1039
- slug: 'my-article',
1040
- utm_source: 'newsletter'
1041
- });
1042
- }
1167
+ handleSuccess(response) { /* success handling */ }
1043
1168
  }
1044
- }
1169
+ };
1045
1170
  ```
1046
1171
 
1047
- This approach makes ViewLogic Router the most developer-friendly routing system available, eliminating the complexity that has plagued traditional routers for years.
1172
+ **Result**: 80% less code with more features (auto-auth, validation, error handling).
1048
1173
 
1049
- ## 🛡️ Error Handling
1174
+ ## 🔗 Query-Only Parameter System
1050
1175
 
1051
- The router includes comprehensive error handling:
1176
+ ViewLogic Router uses **only query parameters** - no complex path parameters like `/users/:id`. Everything is simple query-based: `/users?id=123`.
1052
1177
 
1053
- ```javascript
1054
- // Global error handler
1055
- router.errorHandler.log('error', 'Custom error message');
1178
+ ### Key Benefits
1179
+ 1. **Simple URLs**: `/product?id=123&category=electronics` (clear and readable)
1180
+ 2. **Consistent Access**: Always use `this.getParam('id')` - never mix path/query
1181
+ 3. **No Route Config**: No complex route definitions needed
1182
+ 4. **SEO Friendly**: Descriptive parameter names in URLs
1056
1183
 
1057
- // Route error handling
1058
- router.errorHandler.handleRouteError('routeName', error);
1184
+ ### Usage Example
1185
+ ```javascript
1186
+ // Navigate
1187
+ this.navigateTo('products', { id: 123, category: 'electronics' });
1188
+ // → /products?id=123&category=electronics
1059
1189
 
1060
- // 404 handling is automatic
1190
+ // Access in component
1191
+ export default {
1192
+ mounted() {
1193
+ const id = this.getParam('id'); // Get parameter
1194
+ const category = this.getParam('category', 'all'); // With default
1195
+ const allParams = this.getParams(); // Get all parameters
1196
+ }
1197
+ };
1061
1198
  ```
1062
1199
 
1063
- ## 🚀 Production Deployment
1064
1200
 
1065
- ### 1. Build your routes for production:
1066
- ```bash
1067
- npm run build
1068
- # This will:
1069
- # - Combine view + logic + style files from src/
1070
- # - Generate optimized route bundles in routes/ folder
1071
- # - Minify and optimize each route
1072
- # - Copy routes/ to root level for deployment
1073
- ```
1201
+ ## 🛡️ Error Handling
1074
1202
 
1075
- ### 2. Deploy with production configuration:
1076
- ```html
1077
- <!DOCTYPE html>
1078
- <html>
1079
- <head>
1080
- <title>My ViewLogic App</title>
1081
- <link rel="stylesheet" href="/css/base.css">
1082
- </head>
1083
- <body>
1084
- <div id="app"></div>
1085
-
1086
- <!-- Vue 3 Production -->
1087
- <script src="https://unpkg.com/vue@3/dist/vue.global.prod.js"></script>
1088
-
1089
- <!-- ViewLogic Router from CDN -->
1090
- <script src="https://cdn.jsdelivr.net/npm/viewlogic/dist/viewlogic-router.umd.js"></script>
1091
-
1092
- <script>
1093
- ViewLogicRouter({
1094
- environment: 'production',
1095
- basePath: '/', // Root path
1096
- routesPath: '/routes', // Routes folder at root level
1097
- i18nPath: '/i18n', // i18n folder at root level
1098
- cacheMode: 'session', // Enable session caching
1099
- useComponents: true,
1100
- useI18n: true
1101
- });
1102
- </script>
1103
- </body>
1104
- </html>
1105
- ```
1203
+ Built-in comprehensive error handling with automatic 404 detection, graceful component loading failures, and parameter validation with fallbacks.
1106
1204
 
1107
- ### 3. Production deployment structure:
1108
- ```
1109
- production/
1110
- ├── index.html
1111
- ├── i18n/ # Language files
1112
- │ ├── ko.json
1113
- │ └── en.json
1114
- ├── css/
1115
- │ └── base.css # Global styles
1116
- ├── js/ # Optional (can use CDN instead)
1117
- │ ├── viewlogic-router.umd.js
1118
- │ └── viewlogic-router.min.js
1119
- ├── routes/ # Built route bundles
1120
- │ ├── home.js # Bundled: view + logic + style
1121
- │ ├── about.js
1122
- │ └── products/
1123
- │ ├── list.js
1124
- │ └── detail.js
1125
- └── assets/
1126
- ├── images/
1127
- └── fonts/
1205
+ ## 🚀 Production Deployment
1128
1206
 
1129
- # Note: src/ folder is NOT deployed to production
1207
+ 1. **Build**: `npm run build` - Combines view + logic + style into optimized route bundles
1208
+ 2. **Deploy**: Set `environment: 'production'` and use CDN or local files
1209
+ 3. **Structure**: Deploy `routes/`, `css/`, `i18n/` folders (exclude `src/`)
1210
+
1211
+ **CDN Usage:**
1212
+ ```html
1213
+ <script src="https://cdn.jsdelivr.net/npm/viewlogic/dist/viewlogic-router.umd.js"></script>
1214
+ <script>
1215
+ ViewLogicRouter({ environment: 'production' }).mount('#app');
1216
+ </script>
1130
1217
  ```
1131
1218
 
1132
1219
  ## 🤝 Contributing