web-mojo 2.2.28 → 2.2.30
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 +296 -367
- package/dist/admin.cjs.js +1 -1
- package/dist/admin.cjs.js.map +1 -1
- package/dist/admin.es.js +47 -7
- package/dist/admin.es.js.map +1 -1
- package/dist/auth.cjs.js +1 -1
- package/dist/auth.es.js +1 -1
- package/dist/charts.cjs.js +1 -1
- package/dist/charts.es.js +1 -1
- package/dist/chunks/{ChatView-ChGpB5fY.js → ChatView-CQk-sfqb.js} +2 -2
- package/dist/chunks/{ChatView-ChGpB5fY.js.map → ChatView-CQk-sfqb.js.map} +1 -1
- package/dist/chunks/{ChatView-wMhIMZ01.js → ChatView-DPzQ-iXx.js} +65 -20
- package/dist/chunks/{ChatView-wMhIMZ01.js.map → ChatView-DPzQ-iXx.js.map} +1 -1
- package/dist/chunks/{Collection-9DhgHESv.js → Collection-mUHj_157.js} +2 -2
- package/dist/chunks/{Collection-9DhgHESv.js.map → Collection-mUHj_157.js.map} +1 -1
- package/dist/chunks/{ContextMenu-fsEv-iq5.js → ContextMenu-B-l9KTz3.js} +2 -2
- package/dist/chunks/{ContextMenu-fsEv-iq5.js.map → ContextMenu-B-l9KTz3.js.map} +1 -1
- package/dist/chunks/{ListView-Whl0135W.js → ListView-C8SEk-3W.js} +2 -2
- package/dist/chunks/{ListView-Whl0135W.js.map → ListView-C8SEk-3W.js.map} +1 -1
- package/dist/chunks/{TokenManager-EiNkojsp.js → TokenManager-DPH8v1BZ.js} +3 -3
- package/dist/chunks/{TokenManager-EiNkojsp.js.map → TokenManager-DPH8v1BZ.js.map} +1 -1
- package/dist/chunks/{version-CbWgDs2g.js → version-CAfUFzNd.js} +4 -4
- package/dist/chunks/{version-CbWgDs2g.js.map → version-CAfUFzNd.js.map} +1 -1
- package/dist/chunks/{version-DGV8FEbm.js → version-DDuf9Z9u.js} +2 -2
- package/dist/chunks/{version-DGV8FEbm.js.map → version-DDuf9Z9u.js.map} +1 -1
- package/dist/docit.cjs.js +1 -1
- package/dist/docit.es.js +4 -4
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +8 -8
- package/dist/lightbox.cjs.js +1 -1
- package/dist/lightbox.es.js +1 -1
- package/dist/map.cjs.js +1 -1
- package/dist/map.cjs.js.map +1 -1
- package/dist/map.es.js +2 -2
- package/dist/map.es.js.map +1 -1
- package/dist/timeline.es.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,17 +1,37 @@
|
|
|
1
|
-
# MOJO Framework 2.1.0
|
|
1
|
+
# WEB-MOJO Framework 2.1.0
|
|
2
2
|
|
|
3
3
|
[](https://opensource.org/licenses/Apache-2.0)
|
|
4
|
-
[](https://
|
|
4
|
+
[](https://www.npmjs.com/package/web-mojo)
|
|
5
|
+
[](https://www.npmjs.com/package/web-mojo)
|
|
5
6
|
|
|
6
|
-
**MOJO** is a modern, lightweight JavaScript framework for building data-driven web applications. Built with a **core + extensions** architecture, MOJO provides maximum flexibility while maintaining clean boundaries and optimal performance.
|
|
7
|
+
**WEB-MOJO** is a modern, lightweight JavaScript framework for building data-driven web applications. Built with a **core + extensions** architecture, WEB-MOJO provides maximum flexibility while maintaining clean boundaries and optimal performance.
|
|
7
8
|
|
|
8
|
-
|
|
9
|
+
> **Part of the MOJO Framework Family** - WEB-MOJO is the browser-based framework. See our other MOJO frameworks for native mobile and desktop applications.
|
|
9
10
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
## 📚 Documentation
|
|
12
|
+
|
|
13
|
+
**📖 [View Full Documentation](https://nativemojo.com/web-mojo/)**
|
|
14
|
+
|
|
15
|
+
Complete guides covering:
|
|
16
|
+
- **Core Concepts** - View, Model, Collection, Templates, Events
|
|
17
|
+
- **Features** - Location, Maps, Admin tools, Tab navigation
|
|
18
|
+
- **Components** - Charts, File upload, DataView, and more
|
|
19
|
+
- **Best Practices** - KISS principles, common pitfalls, optimization
|
|
20
|
+
|
|
21
|
+
---
|
|
22
|
+
|
|
23
|
+
## ✨ Key Features
|
|
24
|
+
|
|
25
|
+
🏗️ **Core + Extensions Architecture** - Clean separation with plugin system
|
|
26
|
+
📦 **Subpath Exports** - Import exactly what you need
|
|
27
|
+
⚡ **Lazy Loading** - Reduced bundle sizes with dynamic imports
|
|
28
|
+
🔌 **Plugin System** - Extensions enhance core without dependencies
|
|
29
|
+
🎯 **Tree Shaking** - Optimized builds with modern bundlers
|
|
30
|
+
🎨 **Mustache Templates** - Logic-less templates with 70+ formatters
|
|
31
|
+
📊 **Data-Driven** - Model and Collection classes with REST API integration
|
|
32
|
+
🎭 **Event Delegation** - Convention-based event handling
|
|
33
|
+
|
|
34
|
+
---
|
|
15
35
|
|
|
16
36
|
## 🚀 Quick Start
|
|
17
37
|
|
|
@@ -29,8 +49,16 @@ import { WebApp, Page, View } from 'web-mojo';
|
|
|
29
49
|
|
|
30
50
|
// Create a simple page
|
|
31
51
|
class HomePage extends Page {
|
|
32
|
-
|
|
33
|
-
|
|
52
|
+
constructor(options = {}) {
|
|
53
|
+
super({
|
|
54
|
+
template: `
|
|
55
|
+
<div class="home">
|
|
56
|
+
<h1>Welcome to WEB-MOJO!</h1>
|
|
57
|
+
<p>Building modern web apps made simple.</p>
|
|
58
|
+
</div>
|
|
59
|
+
`,
|
|
60
|
+
...options
|
|
61
|
+
});
|
|
34
62
|
}
|
|
35
63
|
}
|
|
36
64
|
|
|
@@ -44,454 +72,355 @@ app.registerPage('home', HomePage);
|
|
|
44
72
|
app.start();
|
|
45
73
|
```
|
|
46
74
|
|
|
47
|
-
|
|
75
|
+
### With Data Models
|
|
76
|
+
|
|
77
|
+
```javascript
|
|
78
|
+
import { View, Model } from 'web-mojo';
|
|
79
|
+
|
|
80
|
+
class User extends Model {
|
|
81
|
+
urlRoot = '/api/users';
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
class UserProfileView extends View {
|
|
85
|
+
template = `
|
|
86
|
+
<div class="profile">
|
|
87
|
+
<h2>{{model.name}}</h2>
|
|
88
|
+
<p>{{model.email}}</p>
|
|
89
|
+
<p>Member since: {{model.created_at|date}}</p>
|
|
90
|
+
</div>
|
|
91
|
+
`;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// Usage
|
|
95
|
+
const user = new User({ id: 123 });
|
|
96
|
+
await user.fetch();
|
|
97
|
+
|
|
98
|
+
const view = new UserProfileView({ model: user });
|
|
99
|
+
await view.render();
|
|
100
|
+
await view.mount(document.body);
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
---
|
|
104
|
+
|
|
105
|
+
## 📦 Architecture
|
|
48
106
|
|
|
49
|
-
MOJO
|
|
107
|
+
WEB-MOJO uses a **core + extensions** architecture:
|
|
50
108
|
|
|
51
109
|
### Core Package (`web-mojo`)
|
|
110
|
+
|
|
52
111
|
The stable runtime and building blocks:
|
|
53
|
-
|
|
54
|
-
- **
|
|
55
|
-
- **
|
|
56
|
-
- **
|
|
112
|
+
|
|
113
|
+
- **WebApp** & **PortalApp** - Application containers with routing
|
|
114
|
+
- **View** & **Page** - Component system with lifecycle hooks
|
|
115
|
+
- **Model** & **Collection** - Data layer with REST API integration
|
|
116
|
+
- **Router** - URL routing and navigation
|
|
57
117
|
- **Dialog** - Modal system
|
|
58
|
-
- **
|
|
118
|
+
- **Templates** - Mustache templating with 70+ data formatters
|
|
119
|
+
- **Events** - Convention-based event delegation
|
|
120
|
+
- **Essential utilities** - File upload, geolocation, utilities
|
|
59
121
|
|
|
60
122
|
### Extensions
|
|
123
|
+
|
|
61
124
|
Feature-rich packages that extend core functionality:
|
|
62
125
|
|
|
63
126
|
#### 🔐 Authentication (`web-mojo/auth`)
|
|
64
|
-
Complete authentication system with JWT tokens
|
|
65
|
-
|
|
66
|
-
```javascript
|
|
67
|
-
import { mountAuth } from 'web-mojo/auth';
|
|
68
|
-
|
|
69
|
-
// See docs/AuthPage.md for details.
|
|
70
|
-
mountAuth(document.getElementById('auth-root'), {
|
|
71
|
-
baseURL: 'https://api.example.com',
|
|
72
|
-
onSuccessRedirect: '/dashboard',
|
|
73
|
-
});
|
|
74
|
-
```
|
|
127
|
+
Complete authentication system with JWT tokens, login/register forms, and session management.
|
|
75
128
|
|
|
76
129
|
#### 🖼️ Lightbox (`web-mojo/lightbox`)
|
|
77
|
-
Image and PDF viewers with editing capabilities
|
|
78
|
-
|
|
79
|
-
```javascript
|
|
80
|
-
import 'web-mojo/lightbox'; // Auto-registers plugins
|
|
81
|
-
|
|
82
|
-
// Core can now use lightbox features
|
|
83
|
-
import { Dialog } from 'web-mojo';
|
|
84
|
-
// Dialog automatically gets image cropping when lightbox is loaded
|
|
85
|
-
```
|
|
130
|
+
Image and PDF viewers with editing capabilities including cropping and annotation.
|
|
86
131
|
|
|
87
132
|
#### 📊 Charts (`web-mojo/charts`)
|
|
88
|
-
Interactive charts built on Chart.js
|
|
89
|
-
|
|
90
|
-
```javascript
|
|
91
|
-
import { PieChart, SeriesChart } from 'web-mojo/charts';
|
|
92
|
-
|
|
93
|
-
const chart = new PieChart({
|
|
94
|
-
data: salesData,
|
|
95
|
-
container: '#chart'
|
|
96
|
-
});
|
|
97
|
-
```
|
|
133
|
+
Interactive charts built on Chart.js with PieChart, SeriesChart, and more.
|
|
98
134
|
|
|
99
135
|
#### 📚 Documentation (`web-mojo/docit`)
|
|
100
|
-
|
|
136
|
+
Full-featured documentation portal system with markdown editing and syntax highlighting.
|
|
101
137
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
const docs = new DocItApp({
|
|
106
|
-
books: ['user-guide', 'api-docs']
|
|
107
|
-
});
|
|
108
|
-
```
|
|
138
|
+
#### 🗺️ Maps (`web-mojo/map`)
|
|
139
|
+
MapLibre GL integration with geolocation tracking and custom controls.
|
|
109
140
|
|
|
110
141
|
#### ⚡ Loader (`web-mojo/loader`)
|
|
111
|
-
Beautiful loading animations
|
|
112
|
-
|
|
113
|
-
```html
|
|
114
|
-
<script src="web-mojo/loader"></script>
|
|
115
|
-
<script>
|
|
116
|
-
// Your app initialization
|
|
117
|
-
// Call hideInitialLoader() when ready
|
|
118
|
-
</script>
|
|
119
|
-
```
|
|
142
|
+
Beautiful loading animations and progress indicators.
|
|
120
143
|
|
|
121
|
-
|
|
144
|
+
---
|
|
122
145
|
|
|
123
|
-
|
|
146
|
+
## 🎯 Core Concepts
|
|
124
147
|
|
|
125
|
-
|
|
126
|
-
import { PortalApp, Page } from 'web-mojo';
|
|
127
|
-
import 'web-mojo/lightbox'; // Enable image features
|
|
148
|
+
### Views - Component System
|
|
128
149
|
|
|
129
|
-
|
|
130
|
-
name: 'Admin Portal',
|
|
131
|
-
sidebar: {
|
|
132
|
-
menus: [{
|
|
133
|
-
items: [
|
|
134
|
-
{ text: 'Dashboard', route: 'dashboard', icon: 'bi-speedometer2' },
|
|
135
|
-
{ text: 'Users', route: 'users', icon: 'bi-people' }
|
|
136
|
-
]
|
|
137
|
-
}]
|
|
138
|
-
}
|
|
139
|
-
});
|
|
150
|
+
Views are the building blocks of your UI with a complete lifecycle:
|
|
140
151
|
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
</div>
|
|
157
|
-
</div>
|
|
158
|
-
</div>
|
|
159
|
-
`,
|
|
160
|
-
...options
|
|
161
|
-
});
|
|
152
|
+
```javascript
|
|
153
|
+
import { View } from 'web-mojo';
|
|
154
|
+
|
|
155
|
+
class TodoView extends View {
|
|
156
|
+
template = `
|
|
157
|
+
<div class="todo {{#completed}}completed{{/completed}}">
|
|
158
|
+
<input type="checkbox" {{#completed}}checked{{/completed}} data-action="change:toggle">
|
|
159
|
+
<span>{{title}}</span>
|
|
160
|
+
<button data-action="click:remove">×</button>
|
|
161
|
+
</div>
|
|
162
|
+
`;
|
|
163
|
+
|
|
164
|
+
toggle() {
|
|
165
|
+
this.model.set('completed', !this.model.get('completed'));
|
|
166
|
+
this.model.save();
|
|
162
167
|
}
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
const { Dialog } = await import('web-mojo');
|
|
167
|
-
Dialog.showInfo('Hello from MOJO!');
|
|
168
|
+
|
|
169
|
+
remove() {
|
|
170
|
+
this.model.destroy();
|
|
168
171
|
}
|
|
169
172
|
}
|
|
170
|
-
|
|
171
|
-
app.registerPage('dashboard', DashboardPage);
|
|
172
|
-
app.start();
|
|
173
173
|
```
|
|
174
174
|
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
```javascript
|
|
178
|
-
import { mountAuth } from 'web-mojo/auth';
|
|
179
|
-
|
|
180
|
-
// Auth portal (standalone). See docs/AuthPage.md for details.
|
|
181
|
-
mountAuth(document.getElementById('auth-root'), {
|
|
182
|
-
baseURL: 'https://api.example.com',
|
|
183
|
-
onSuccessRedirect: '/portal/',
|
|
184
|
-
branding: {
|
|
185
|
-
title: 'Acme Corp',
|
|
186
|
-
logoUrl: '/assets/logo.png',
|
|
187
|
-
subtitle: 'Sign in to your account',
|
|
188
|
-
},
|
|
189
|
-
});
|
|
190
|
-
|
|
191
|
-
// Main app (after authentication)
|
|
192
|
-
const mainApp = new WebApp({
|
|
193
|
-
name: 'Acme Portal',
|
|
194
|
-
api: {
|
|
195
|
-
baseURL: 'https://api.example.com',
|
|
196
|
-
token: localStorage.getItem('auth_token')
|
|
197
|
-
}
|
|
198
|
-
});
|
|
175
|
+
**[→ View Documentation](https://nativemojo.com/web-mojo/#core/View.md)**
|
|
199
176
|
|
|
200
|
-
|
|
201
|
-
authApp.events.on('auth:login', (user) => {
|
|
202
|
-
window.location.href = '/dashboard';
|
|
203
|
-
});
|
|
204
|
-
```
|
|
177
|
+
### Models - Data Layer
|
|
205
178
|
|
|
206
|
-
|
|
179
|
+
Models manage your data with built-in REST API integration:
|
|
207
180
|
|
|
208
181
|
```javascript
|
|
209
|
-
import { Model
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
// Create views
|
|
222
|
-
class UserTableView extends View {
|
|
223
|
-
constructor(options = {}) {
|
|
224
|
-
super({
|
|
225
|
-
template: `
|
|
226
|
-
<table class="table">
|
|
227
|
-
<thead>
|
|
228
|
-
<tr><th>Name</th><th>Email</th><th>Actions</th></tr>
|
|
229
|
-
</thead>
|
|
230
|
-
<tbody>
|
|
231
|
-
{{#users}}
|
|
232
|
-
<tr>
|
|
233
|
-
<td>{{name}}</td>
|
|
234
|
-
<td>{{email}}</td>
|
|
235
|
-
<td>
|
|
236
|
-
<button class="btn btn-sm btn-primary"
|
|
237
|
-
data-action="edit-user"
|
|
238
|
-
data-user-id="{{id}}">Edit</button>
|
|
239
|
-
</td>
|
|
240
|
-
</tr>
|
|
241
|
-
{{/users}}
|
|
242
|
-
</tbody>
|
|
243
|
-
</table>
|
|
244
|
-
`,
|
|
245
|
-
...options
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
this.collection = new UserList();
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
async onMount() {
|
|
252
|
-
await this.collection.fetch();
|
|
253
|
-
this.render();
|
|
182
|
+
import { Model } from 'web-mojo';
|
|
183
|
+
|
|
184
|
+
class Todo extends Model {
|
|
185
|
+
urlRoot = '/api/todos';
|
|
186
|
+
|
|
187
|
+
defaults() {
|
|
188
|
+
return {
|
|
189
|
+
title: '',
|
|
190
|
+
completed: false,
|
|
191
|
+
created_at: new Date()
|
|
192
|
+
};
|
|
254
193
|
}
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
const { Dialog } = await import('web-mojo');
|
|
261
|
-
Dialog.showModelForm(user, {
|
|
262
|
-
title: 'Edit User',
|
|
263
|
-
fields: ['name', 'email']
|
|
264
|
-
});
|
|
194
|
+
|
|
195
|
+
validate(attrs) {
|
|
196
|
+
if (!attrs.title || attrs.title.trim() === '') {
|
|
197
|
+
return 'Title is required';
|
|
198
|
+
}
|
|
265
199
|
}
|
|
266
200
|
}
|
|
267
|
-
```
|
|
268
201
|
|
|
269
|
-
|
|
202
|
+
// Usage
|
|
203
|
+
const todo = new Todo({ title: 'Learn WEB-MOJO' });
|
|
204
|
+
await todo.save(); // POST /api/todos
|
|
270
205
|
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
web-mojo/
|
|
274
|
-
├── src/
|
|
275
|
-
│ ├── index.js # Core entry point
|
|
276
|
-
│ ├── auth.js # Auth extension entry
|
|
277
|
-
│ ├── lightbox.js # Lightbox extension entry
|
|
278
|
-
│ ├── charts.js # Charts extension entry
|
|
279
|
-
│ ├── docit.js # DocIt extension entry
|
|
280
|
-
│ ├── loader.js # Loader entry
|
|
281
|
-
│ ├── core/ # Core framework
|
|
282
|
-
│ │ ├── View.js
|
|
283
|
-
│ │ ├── Page.js
|
|
284
|
-
│ │ ├── WebApp.js
|
|
285
|
-
│ │ ├── PortalApp.js
|
|
286
|
-
│ │ ├── models/
|
|
287
|
-
│ │ ├── views/
|
|
288
|
-
│ │ ├── services/
|
|
289
|
-
│ │ └── utils/
|
|
290
|
-
│ └── extensions/ # Extension packages
|
|
291
|
-
│ ├── auth/
|
|
292
|
-
│ ├── lightbox/
|
|
293
|
-
│ ├── charts/
|
|
294
|
-
│ └── docit/
|
|
295
|
-
├── examples/ # Live examples
|
|
296
|
-
└── dist/ # Built packages
|
|
206
|
+
todo.set('completed', true);
|
|
207
|
+
await todo.save(); // PUT /api/todos/123
|
|
297
208
|
```
|
|
298
209
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
```bash
|
|
302
|
-
# Install dependencies
|
|
303
|
-
npm install
|
|
210
|
+
**[→ Model Documentation](https://nativemojo.com/web-mojo/#core/Model.md)**
|
|
304
211
|
|
|
305
|
-
|
|
306
|
-
npm run build:lib
|
|
212
|
+
### Templates - Mustache with Formatters
|
|
307
213
|
|
|
308
|
-
|
|
309
|
-
npm run dev
|
|
214
|
+
Logic-less templates with powerful data formatting:
|
|
310
215
|
|
|
311
|
-
|
|
312
|
-
|
|
216
|
+
```javascript
|
|
217
|
+
template = `
|
|
218
|
+
<div class="user-card">
|
|
219
|
+
<h3>{{model.name|uppercase}}</h3>
|
|
220
|
+
<p>{{model.email|lowercase}}</p>
|
|
221
|
+
<p>Joined: {{model.created_at|date:'MMM dd, YYYY'}}</p>
|
|
222
|
+
<p>Revenue: {{model.total_revenue|currency}}</p>
|
|
223
|
+
|
|
224
|
+
{{#model.is_active|bool}}
|
|
225
|
+
<span class="badge-success">Active</span>
|
|
226
|
+
{{/model.is_active|bool}}
|
|
227
|
+
</div>
|
|
228
|
+
`;
|
|
313
229
|
```
|
|
314
230
|
|
|
315
|
-
|
|
316
|
-
When developing the framework itself:
|
|
231
|
+
**70+ built-in formatters** for dates, numbers, text, HTML, and more!
|
|
317
232
|
|
|
318
|
-
|
|
319
|
-
// Use aliases for clean imports
|
|
320
|
-
import View from '@core/View.js';
|
|
321
|
-
import AuthApp from '@ext/auth/AuthApp.js';
|
|
322
|
-
import { PieChart } from '@ext/charts/PieChart.js';
|
|
323
|
-
```
|
|
233
|
+
**[→ Templates Documentation](https://nativemojo.com/web-mojo/#core/Templates.md)**
|
|
324
234
|
|
|
325
|
-
|
|
235
|
+
### Events - Convention-Based
|
|
326
236
|
|
|
327
|
-
|
|
328
|
-
Main application container with routing and page management.
|
|
237
|
+
Clean event handling with data attributes:
|
|
329
238
|
|
|
330
239
|
```javascript
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
240
|
+
class ButtonView extends View {
|
|
241
|
+
template = `
|
|
242
|
+
<button data-action="click:handleClick">Click Me</button>
|
|
243
|
+
<input data-action="input:handleInput" placeholder="Type here">
|
|
244
|
+
`;
|
|
245
|
+
|
|
246
|
+
handleClick(e) {
|
|
247
|
+
console.log('Button clicked!');
|
|
338
248
|
}
|
|
339
|
-
|
|
249
|
+
|
|
250
|
+
handleInput(e) {
|
|
251
|
+
console.log('Input value:', e.target.value);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
```
|
|
340
255
|
|
|
341
|
-
|
|
342
|
-
app.registerPage('home', HomePage);
|
|
343
|
-
app.registerPage('users', UserListPage);
|
|
256
|
+
**[→ Events Documentation](https://nativemojo.com/web-mojo/#core/Events.md)**
|
|
344
257
|
|
|
345
|
-
|
|
346
|
-
await app.navigate('users');
|
|
347
|
-
await app.navigate('user/123');
|
|
258
|
+
---
|
|
348
259
|
|
|
349
|
-
|
|
350
|
-
await app.start();
|
|
351
|
-
```
|
|
260
|
+
## 🏗️ Portal Applications
|
|
352
261
|
|
|
353
|
-
|
|
354
|
-
Extended WebApp with built-in sidebar and top navigation.
|
|
262
|
+
Build admin portals and dashboards with PortalApp:
|
|
355
263
|
|
|
356
264
|
```javascript
|
|
265
|
+
import { PortalApp, Page } from 'web-mojo';
|
|
266
|
+
|
|
357
267
|
const app = new PortalApp({
|
|
358
|
-
|
|
268
|
+
name: 'Admin Portal',
|
|
359
269
|
sidebar: {
|
|
360
270
|
menus: [{
|
|
361
|
-
|
|
271
|
+
title: 'Main',
|
|
362
272
|
items: [
|
|
363
|
-
{ text: '
|
|
364
|
-
{
|
|
365
|
-
|
|
366
|
-
icon: 'bi-gear',
|
|
367
|
-
children: [
|
|
368
|
-
{ text: 'Users', route: 'users' },
|
|
369
|
-
{ text: 'Settings', route: 'settings' }
|
|
370
|
-
]
|
|
371
|
-
}
|
|
273
|
+
{ text: 'Dashboard', route: 'dashboard', icon: 'bi-speedometer2' },
|
|
274
|
+
{ text: 'Users', route: 'users', icon: 'bi-people' },
|
|
275
|
+
{ text: 'Settings', route: 'settings', icon: 'bi-gear' }
|
|
372
276
|
]
|
|
373
277
|
}]
|
|
374
|
-
},
|
|
375
|
-
topbar: {
|
|
376
|
-
brand: 'My Portal',
|
|
377
|
-
rightItems: [
|
|
378
|
-
{ icon: 'bi-bell', action: 'notifications' }
|
|
379
|
-
]
|
|
380
278
|
}
|
|
381
279
|
});
|
|
280
|
+
|
|
281
|
+
app.registerPage('dashboard', DashboardPage);
|
|
282
|
+
app.registerPage('users', UsersPage);
|
|
283
|
+
app.start();
|
|
382
284
|
```
|
|
383
285
|
|
|
384
|
-
|
|
286
|
+
---
|
|
385
287
|
|
|
386
|
-
|
|
387
|
-
class MyView extends View {
|
|
388
|
-
constructor(options = {}) {
|
|
389
|
-
super({
|
|
390
|
-
className: 'my-view',
|
|
391
|
-
template: `
|
|
392
|
-
<div>
|
|
393
|
-
<h3>{{title}}</h3>
|
|
394
|
-
<button data-action="click-me">Click Me</button>
|
|
395
|
-
<div data-region="content"></div>
|
|
396
|
-
</div>
|
|
397
|
-
`,
|
|
398
|
-
...options
|
|
399
|
-
});
|
|
400
|
-
}
|
|
288
|
+
## 📖 Documentation Structure
|
|
401
289
|
|
|
402
|
-
|
|
403
|
-
async onMount() { /* Called when mounted to DOM */ }
|
|
404
|
-
async onUnmount() { /* Called when removed */ }
|
|
290
|
+
Our documentation is organized for easy navigation:
|
|
405
291
|
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
292
|
+
- **[Core Concepts](https://nativemojo.com/web-mojo/#core/View.md)** - View, Model, Collection, Templates, Events
|
|
293
|
+
- **[Features](https://nativemojo.com/web-mojo/#features/Location.md)** - Location, Maps, Admin, Tabs
|
|
294
|
+
- **[Components](https://nativemojo.com/web-mojo/#components/Charts.md)** - UI components and widgets
|
|
295
|
+
- **[API Reference](https://nativemojo.com/web-mojo/)** - Complete API documentation
|
|
410
296
|
|
|
411
|
-
|
|
412
|
-
onCustomEvent(data) { /* Handle custom events */ }
|
|
413
|
-
}
|
|
414
|
-
```
|
|
297
|
+
### Essential Reading
|
|
415
298
|
|
|
416
|
-
|
|
299
|
+
**Start here:**
|
|
300
|
+
1. [View Basics](https://nativemojo.com/web-mojo/#core/View.md) - Component system
|
|
301
|
+
2. [Templates](https://nativemojo.com/web-mojo/#core/Templates.md) - Templating with common pitfalls
|
|
302
|
+
3. [Model](https://nativemojo.com/web-mojo/#core/Model.md) - Data layer
|
|
417
303
|
|
|
418
|
-
|
|
419
|
-
|
|
304
|
+
**Then explore:**
|
|
305
|
+
4. [Child Views](https://nativemojo.com/web-mojo/#core/ViewChildViews.md) - Component composition
|
|
306
|
+
5. [Collection](https://nativemojo.com/web-mojo/#core/Collection.md) - Working with lists
|
|
307
|
+
6. [Events](https://nativemojo.com/web-mojo/#core/Events.md) - Event handling
|
|
420
308
|
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
export default {
|
|
424
|
-
optimizeDeps: {
|
|
425
|
-
exclude: ['web-mojo']
|
|
426
|
-
},
|
|
427
|
-
ssr: {
|
|
428
|
-
noExternal: ['web-mojo']
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
```
|
|
309
|
+
**Advanced:**
|
|
310
|
+
7. [Advanced Views](https://nativemojo.com/web-mojo/#core/AdvancedViews.md) - Canvas, WebGL, optimization
|
|
432
311
|
|
|
433
|
-
|
|
434
|
-
```javascript
|
|
435
|
-
// Bundle all CSS automatically
|
|
436
|
-
import 'web-mojo'; // Includes core CSS
|
|
437
|
-
|
|
438
|
-
// Simple Auth CSS is included by the module (no extra import required).
|
|
439
|
-
// For theming details, see docs/AuthPage.md.
|
|
440
|
-
// If you need manual CSS, you can use: /src/extensions/auth/css/auth.css
|
|
441
|
-
import 'web-mojo/css/core';
|
|
442
|
-
import 'web-mojo/css/portal';
|
|
443
|
-
```
|
|
312
|
+
---
|
|
444
313
|
|
|
445
|
-
##
|
|
314
|
+
## 🎨 Philosophy
|
|
446
315
|
|
|
447
|
-
|
|
448
|
-
```javascript
|
|
449
|
-
// Old (2.0.x)
|
|
450
|
-
import WebApp from '/src/core/WebApp.js';
|
|
451
|
-
import AuthApp from '/src/auth/AuthApp.js';
|
|
316
|
+
WEB-MOJO follows these core principles:
|
|
452
317
|
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
318
|
+
### KISS - Keep It Simple, Stupid
|
|
319
|
+
- Simple patterns over complex abstractions
|
|
320
|
+
- Readable code over clever code
|
|
321
|
+
- Convention over configuration
|
|
457
322
|
|
|
458
|
-
###
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
323
|
+
### Model-First Approach
|
|
324
|
+
- Use models directly in templates
|
|
325
|
+
- Avoid custom data structures
|
|
326
|
+
- Let formatters handle presentation
|
|
462
327
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
328
|
+
### Logic-Less Templates
|
|
329
|
+
- Business logic in views, not templates
|
|
330
|
+
- Formatters for display formatting
|
|
331
|
+
- View methods for computed values
|
|
466
332
|
|
|
467
|
-
|
|
333
|
+
**[→ Read More About Our Philosophy](https://nativemojo.com/web-mojo/#core/Templates.md)**
|
|
334
|
+
|
|
335
|
+
---
|
|
336
|
+
|
|
337
|
+
## 🛠️ Development
|
|
338
|
+
|
|
339
|
+
### Prerequisites
|
|
468
340
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
5. Commit your changes (`git commit -m 'Add amazing feature'`)
|
|
474
|
-
6. Push to the branch (`git push origin feature/amazing-feature`)
|
|
475
|
-
7. Open a Pull Request
|
|
341
|
+
- Node.js 18+
|
|
342
|
+
- npm or yarn
|
|
343
|
+
|
|
344
|
+
### Setup
|
|
476
345
|
|
|
477
|
-
### Development Setup
|
|
478
346
|
```bash
|
|
479
|
-
|
|
347
|
+
# Clone repository
|
|
348
|
+
git clone https://github.com/NativeMojo/web-mojo.git
|
|
480
349
|
cd web-mojo
|
|
350
|
+
|
|
351
|
+
# Install dependencies
|
|
481
352
|
npm install
|
|
353
|
+
|
|
354
|
+
# Run development server
|
|
482
355
|
npm run dev
|
|
356
|
+
|
|
357
|
+
# Build for production
|
|
358
|
+
npm run build
|
|
359
|
+
|
|
360
|
+
# Run tests
|
|
361
|
+
npm test
|
|
483
362
|
```
|
|
484
363
|
|
|
485
|
-
|
|
364
|
+
### Project Structure
|
|
365
|
+
|
|
366
|
+
```
|
|
367
|
+
web-mojo/
|
|
368
|
+
├── src/
|
|
369
|
+
│ ├── core/ # Core framework
|
|
370
|
+
│ ├── extensions/ # Extensions (auth, charts, etc.)
|
|
371
|
+
│ └── styles/ # CSS styles
|
|
372
|
+
├── docs/ # Documentation
|
|
373
|
+
│ ├── core/ # Core concept docs
|
|
374
|
+
│ ├── features/ # Feature docs
|
|
375
|
+
│ └── components/ # Component docs
|
|
376
|
+
├── examples/ # Example projects
|
|
377
|
+
└── tests/ # Test suites
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
---
|
|
381
|
+
|
|
382
|
+
## 🤝 Contributing
|
|
383
|
+
|
|
384
|
+
We welcome contributions! Please:
|
|
385
|
+
|
|
386
|
+
1. Read our [Contributing Guide](CONTRIBUTING.md)
|
|
387
|
+
2. Check [existing issues](https://github.com/NativeMojo/web-mojo/issues)
|
|
388
|
+
3. Follow our coding standards
|
|
389
|
+
4. Write tests for new features
|
|
390
|
+
5. Update documentation
|
|
486
391
|
|
|
487
|
-
|
|
392
|
+
### Documentation Contributions
|
|
393
|
+
|
|
394
|
+
Documentation improvements are especially welcome! Ensure:
|
|
395
|
+
- ✅ Examples are tested and working
|
|
396
|
+
- ✅ Common pitfalls are documented
|
|
397
|
+
- ✅ Cross-references are updated
|
|
398
|
+
- ✅ KISS principles are followed
|
|
399
|
+
|
|
400
|
+
---
|
|
401
|
+
|
|
402
|
+
## 📝 License
|
|
403
|
+
|
|
404
|
+
Apache 2.0 - See [LICENSE](LICENSE) file
|
|
405
|
+
|
|
406
|
+
---
|
|
407
|
+
|
|
408
|
+
## 🔗 Links
|
|
409
|
+
|
|
410
|
+
- **[Documentation](https://nativemojo.com/web-mojo/)** - Complete framework documentation
|
|
411
|
+
- **[NPM Package](https://www.npmjs.com/package/web-mojo)** - Install from npm
|
|
412
|
+
- **[GitHub Repository](https://github.com/NativeMojo/web-mojo)** - Source code
|
|
413
|
+
- **[Issues](https://github.com/NativeMojo/web-mojo/issues)** - Report bugs
|
|
414
|
+
- **[Examples](./examples/)** - Working example projects
|
|
415
|
+
|
|
416
|
+
---
|
|
488
417
|
|
|
489
|
-
##
|
|
418
|
+
## 🌟 Community
|
|
490
419
|
|
|
491
|
-
-
|
|
492
|
-
-
|
|
493
|
-
-
|
|
420
|
+
- **Website:** [nativemojo.com](https://nativemojo.com)
|
|
421
|
+
- **Discussions:** [GitHub Discussions](https://github.com/NativeMojo/web-mojo/discussions)
|
|
422
|
+
- **Issues:** [GitHub Issues](https://github.com/NativeMojo/web-mojo/issues)
|
|
494
423
|
|
|
495
424
|
---
|
|
496
425
|
|
|
497
|
-
Built with ❤️ by the
|
|
426
|
+
**Built with ❤️ by the NativeMojo team**
|