mui-toolpad-extended-tuni 1.0.2 → 1.0.3
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 +395 -8
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,20 +1,407 @@
|
|
|
1
1
|
<!-- @format -->
|
|
2
2
|
|
|
3
|
-
# MUI Toolpad
|
|
3
|
+
# MUI Toolpad Extended Library (TUNI)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
A React library extending MUI Toolpad functionality with additional features for educational applications. This library provides components and tools for building interactive educational interfaces.
|
|
6
6
|
|
|
7
|
-
##
|
|
7
|
+
## Prerequisites
|
|
8
|
+
|
|
9
|
+
This library requires the following peer dependencies:
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
- React ≥18.0.0
|
|
12
|
+
- React DOM ≥18.0.0
|
|
13
|
+
- @mui/material ≥6.0.0
|
|
14
|
+
- @mui/icons-material ≥6.0.0
|
|
15
|
+
- @emotion/react ≥11.0.0
|
|
16
|
+
- @emotion/styled ≥11.0.0
|
|
17
|
+
|
|
18
|
+
## Installation
|
|
10
19
|
|
|
11
20
|
```bash
|
|
12
|
-
npm install @jalez/mui-toolpad-extended-tuni
|
|
21
|
+
npm install @jalez/mui-toolpad-extended-tuni
|
|
13
22
|
```
|
|
14
23
|
|
|
15
|
-
|
|
24
|
+
## Basic Usage
|
|
16
25
|
|
|
17
|
-
|
|
26
|
+
1. Wrap your application with `EduMLProvider`:
|
|
27
|
+
|
|
28
|
+
```tsx
|
|
29
|
+
import { BrowserRouter } from 'react-router-dom';
|
|
18
30
|
import { EduMLProvider } from '@jalez/mui-toolpad-extended-tuni';
|
|
19
|
-
|
|
31
|
+
|
|
32
|
+
function App() {
|
|
33
|
+
return (
|
|
34
|
+
<BrowserRouter>
|
|
35
|
+
<EduMLProvider>{/* Your application content */}</EduMLProvider>
|
|
36
|
+
</BrowserRouter>
|
|
37
|
+
);
|
|
38
|
+
}
|
|
20
39
|
```
|
|
40
|
+
|
|
41
|
+
2. Use the included stores and components:
|
|
42
|
+
|
|
43
|
+
```tsx
|
|
44
|
+
import {
|
|
45
|
+
useUserStore,
|
|
46
|
+
useCourseStore,
|
|
47
|
+
useNavigationStore,
|
|
48
|
+
} from '@jalez/mui-toolpad-extended-tuni';
|
|
49
|
+
|
|
50
|
+
function MyComponent() {
|
|
51
|
+
const { user } = useUserStore();
|
|
52
|
+
const { currentCourse } = useCourseStore();
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<div>
|
|
56
|
+
<h1>Welcome, {user?.name}!</h1>
|
|
57
|
+
<p>Current course: {currentCourse?.title}</p>
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
## Core Components
|
|
64
|
+
|
|
65
|
+
### EduMLProvider
|
|
66
|
+
|
|
67
|
+
The main provider component that sets up the application context:
|
|
68
|
+
|
|
69
|
+
```tsx
|
|
70
|
+
import { BrowserRouter } from 'react-router-dom';
|
|
71
|
+
import { EduMLProvider } from '@jalez/mui-toolpad-extended-tuni';
|
|
72
|
+
|
|
73
|
+
function App() {
|
|
74
|
+
return (
|
|
75
|
+
<BrowserRouter>
|
|
76
|
+
<EduMLProvider>
|
|
77
|
+
<YourComponents />
|
|
78
|
+
</EduMLProvider>
|
|
79
|
+
</BrowserRouter>
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
### LoadingScreen
|
|
85
|
+
|
|
86
|
+
A customizable loading indicator with animations:
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
import { LoadingScreen } from '@jalez/mui-toolpad-extended-tuni';
|
|
90
|
+
|
|
91
|
+
function MyComponent() {
|
|
92
|
+
return isLoading ? <LoadingScreen /> : <YourContent />;
|
|
93
|
+
}
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### Notifications
|
|
97
|
+
|
|
98
|
+
Built-in notification system using notistack:
|
|
99
|
+
|
|
100
|
+
```tsx
|
|
101
|
+
import { useNotificationStore } from '@jalez/mui-toolpad-extended-tuni';
|
|
102
|
+
|
|
103
|
+
function MyComponent() {
|
|
104
|
+
const { addNotificationData } = useNotificationStore();
|
|
105
|
+
|
|
106
|
+
const showNotification = () => {
|
|
107
|
+
addNotificationData({
|
|
108
|
+
type: 'success',
|
|
109
|
+
message: 'Operation completed successfully',
|
|
110
|
+
singular: true, // Optional: show only once
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
### EduMLDialog
|
|
117
|
+
|
|
118
|
+
A responsive dialog component:
|
|
119
|
+
|
|
120
|
+
```tsx
|
|
121
|
+
import { EduMLDialog } from '@jalez/mui-toolpad-extended-tuni';
|
|
122
|
+
|
|
123
|
+
function MyComponent() {
|
|
124
|
+
const [open, setOpen] = useState(false);
|
|
125
|
+
|
|
126
|
+
return (
|
|
127
|
+
<EduMLDialog open={open} onClose={() => setOpen(false)}>
|
|
128
|
+
<DialogContent>Your content here</DialogContent>
|
|
129
|
+
</EduMLDialog>
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
### Course Management Components
|
|
135
|
+
|
|
136
|
+
#### CourseSelector
|
|
137
|
+
|
|
138
|
+
A component for listing and selecting courses:
|
|
139
|
+
|
|
140
|
+
```tsx
|
|
141
|
+
import { CourseSelector } from '@jalez/mui-toolpad-extended-tuni';
|
|
142
|
+
|
|
143
|
+
function MyComponent() {
|
|
144
|
+
return <CourseSelector />;
|
|
145
|
+
}
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
#### CourseTools
|
|
149
|
+
|
|
150
|
+
Manages course-specific tools and LTI configuration:
|
|
151
|
+
|
|
152
|
+
```tsx
|
|
153
|
+
import { CourseTools } from '@jalez/mui-toolpad-extended-tuni';
|
|
154
|
+
|
|
155
|
+
function MyComponent() {
|
|
156
|
+
return <CourseTools />;
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
#### LTI Login Configuration
|
|
161
|
+
|
|
162
|
+
For teachers to set up course authentication:
|
|
163
|
+
|
|
164
|
+
```tsx
|
|
165
|
+
import { LtiLoginUrlForm } from '@jalez/mui-toolpad-extended-tuni';
|
|
166
|
+
|
|
167
|
+
function MyComponent() {
|
|
168
|
+
return <LtiLoginUrlForm />;
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
### Error Handling Components
|
|
173
|
+
|
|
174
|
+
#### ErrorBoundary
|
|
175
|
+
|
|
176
|
+
Catches and handles React component errors:
|
|
177
|
+
|
|
178
|
+
```tsx
|
|
179
|
+
import { ErrorBoundary } from '@jalez/mui-toolpad-extended-tuni';
|
|
180
|
+
|
|
181
|
+
function App() {
|
|
182
|
+
return (
|
|
183
|
+
<ErrorBoundary>
|
|
184
|
+
<YourComponents />
|
|
185
|
+
</ErrorBoundary>
|
|
186
|
+
);
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
#### NullStateWarning
|
|
191
|
+
|
|
192
|
+
Detects and displays warnings for null states:
|
|
193
|
+
|
|
194
|
+
```tsx
|
|
195
|
+
import { NullStateWarning } from '@jalez/mui-toolpad-extended-tuni';
|
|
196
|
+
|
|
197
|
+
function MyComponent() {
|
|
198
|
+
const states = [{ user: currentUser }, { course: currentCourse }];
|
|
199
|
+
|
|
200
|
+
return (
|
|
201
|
+
<NullStateWarning states={states}>
|
|
202
|
+
<YourContent />
|
|
203
|
+
</NullStateWarning>
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
## Development Tools
|
|
209
|
+
|
|
210
|
+
When running in development mode (localhost), the library provides additional tools:
|
|
211
|
+
|
|
212
|
+
- User Switcher: Easily switch between different user roles (student/teacher/guest)
|
|
213
|
+
- Development Toolbar: Additional debugging and testing features
|
|
214
|
+
|
|
215
|
+
## Features
|
|
216
|
+
|
|
217
|
+
- User authentication and management
|
|
218
|
+
- Course handling and navigation
|
|
219
|
+
- Notification system
|
|
220
|
+
- Custom dialog management
|
|
221
|
+
- Role-based navigation filtering
|
|
222
|
+
- LTI integration support
|
|
223
|
+
- Customizable theme
|
|
224
|
+
|
|
225
|
+
## Available Stores
|
|
226
|
+
|
|
227
|
+
### useUserStore
|
|
228
|
+
|
|
229
|
+
```tsx
|
|
230
|
+
const {
|
|
231
|
+
user, // Current user data
|
|
232
|
+
getUser, // Fetch user data
|
|
233
|
+
changeRole, // Switch user role
|
|
234
|
+
logout, // Logout current user
|
|
235
|
+
} = useUserStore();
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### useCourseStore
|
|
239
|
+
|
|
240
|
+
```tsx
|
|
241
|
+
const {
|
|
242
|
+
currentCourse, // Current active course
|
|
243
|
+
courses, // List of available courses
|
|
244
|
+
getCourses, // Fetch all courses
|
|
245
|
+
getCourseByUrl, // Get course by URL
|
|
246
|
+
} = useCourseStore();
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### useNavigationStore
|
|
250
|
+
|
|
251
|
+
```tsx
|
|
252
|
+
const {
|
|
253
|
+
navigation, // Current navigation structure
|
|
254
|
+
updateSection, // Update navigation section
|
|
255
|
+
setNavigation, // Set entire navigation
|
|
256
|
+
} = useNavigationStore();
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
### useNotificationStore
|
|
260
|
+
|
|
261
|
+
```tsx
|
|
262
|
+
const {
|
|
263
|
+
addNotificationData, // Add new notification
|
|
264
|
+
removeNotificationData, // Remove notification
|
|
265
|
+
} = useNotificationStore();
|
|
266
|
+
```
|
|
267
|
+
|
|
268
|
+
## Utility Functions
|
|
269
|
+
|
|
270
|
+
### String Manipulation
|
|
271
|
+
|
|
272
|
+
```tsx
|
|
273
|
+
import {
|
|
274
|
+
slugify,
|
|
275
|
+
camelCaseToUnderscore,
|
|
276
|
+
underscoreToCamelCase,
|
|
277
|
+
} from '@jalez/mui-toolpad-extended-tuni';
|
|
278
|
+
|
|
279
|
+
// Convert strings to URL-friendly format
|
|
280
|
+
const slug = slugify('My Course Title'); // 'my-course-title'
|
|
281
|
+
|
|
282
|
+
// Convert between case styles
|
|
283
|
+
const underscore = camelCaseToUnderscore('myVariable'); // 'my_variable'
|
|
284
|
+
const camelCase = underscoreToCamelCase('my_variable'); // 'myVariable'
|
|
285
|
+
```
|
|
286
|
+
|
|
287
|
+
### Object Key Conversion
|
|
288
|
+
|
|
289
|
+
```tsx
|
|
290
|
+
import {
|
|
291
|
+
convertObjectKeysToCamelCase,
|
|
292
|
+
convertObjectKeysToUnderscore,
|
|
293
|
+
} from '@jalez/mui-toolpad-extended-tuni';
|
|
294
|
+
|
|
295
|
+
// Convert API responses
|
|
296
|
+
const camelCaseData = convertObjectKeysToCamelCase(apiResponse);
|
|
297
|
+
const underscoreData = convertObjectKeysToUnderscore(requestData);
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
## Network Configuration
|
|
301
|
+
|
|
302
|
+
The library includes pre-configured Axios instance for API communications:
|
|
303
|
+
|
|
304
|
+
```tsx
|
|
305
|
+
import { axiosInstance } from '@jalez/mui-toolpad-extended-tuni';
|
|
306
|
+
|
|
307
|
+
// Handles CSRF tokens and base URL automatically
|
|
308
|
+
const response = await axiosInstance.get('/api/endpoint');
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
## Course Types and Interfaces
|
|
312
|
+
|
|
313
|
+
```tsx
|
|
314
|
+
interface Course {
|
|
315
|
+
id: string;
|
|
316
|
+
title: string;
|
|
317
|
+
description: string;
|
|
318
|
+
createdAt: string;
|
|
319
|
+
ltiLoginUrl: string;
|
|
320
|
+
updatedAt: string;
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
// Course creation payload
|
|
324
|
+
interface CourseRaw {
|
|
325
|
+
title: string;
|
|
326
|
+
description: string;
|
|
327
|
+
}
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
## Theme Customization
|
|
331
|
+
|
|
332
|
+
The library includes a customizable Material-UI theme:
|
|
333
|
+
|
|
334
|
+
```tsx
|
|
335
|
+
import { EduMLTheme } from '@jalez/mui-toolpad-extended-tuni';
|
|
336
|
+
|
|
337
|
+
// Theme includes predefined:
|
|
338
|
+
// - Color schemes (light/dark)
|
|
339
|
+
// - Typography scales
|
|
340
|
+
// - Component style overrides
|
|
341
|
+
// - Transition effects
|
|
342
|
+
// - Z-index hierarchy
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
## Current Limitations
|
|
346
|
+
|
|
347
|
+
1. **Authentication:**
|
|
348
|
+
|
|
349
|
+
- LTI login URL must be configured per course
|
|
350
|
+
- Only supports single active session
|
|
351
|
+
- Development mode uses mock authentication
|
|
352
|
+
|
|
353
|
+
2. **Course Management:**
|
|
354
|
+
|
|
355
|
+
- Limited to predefined course structure
|
|
356
|
+
- No bulk operations support
|
|
357
|
+
- Course tools must follow specific navigation structure
|
|
358
|
+
|
|
359
|
+
3. **State Management:**
|
|
360
|
+
|
|
361
|
+
- No persistence between page reloads
|
|
362
|
+
- Limited offline support
|
|
363
|
+
- State updates are synchronous
|
|
364
|
+
|
|
365
|
+
4. **Network:**
|
|
366
|
+
|
|
367
|
+
- Base URL is fixed to '/'
|
|
368
|
+
- CSRF token handling is mandatory
|
|
369
|
+
- No request caching implementation
|
|
370
|
+
|
|
371
|
+
5. **Browser Support:**
|
|
372
|
+
- Requires modern browser features
|
|
373
|
+
- Limited mobile responsiveness
|
|
374
|
+
- No IE11 support
|
|
375
|
+
|
|
376
|
+
## Types and Interfaces
|
|
377
|
+
|
|
378
|
+
### Common Types
|
|
379
|
+
|
|
380
|
+
```typescript
|
|
381
|
+
type fetchState = 'idle' | 'loading' | 'error' | 'success';
|
|
382
|
+
|
|
383
|
+
interface NavigationStoreItem {
|
|
384
|
+
kind: 'header' | 'page';
|
|
385
|
+
title: string;
|
|
386
|
+
segment?: string;
|
|
387
|
+
children?: NavigationStoreItem[];
|
|
388
|
+
}
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
## License
|
|
392
|
+
|
|
393
|
+
MIT License - See LICENSE file for details.
|
|
394
|
+
|
|
395
|
+
## Contributing
|
|
396
|
+
|
|
397
|
+
When contributing, please note:
|
|
398
|
+
|
|
399
|
+
- All components must implement error boundaries
|
|
400
|
+
- State management should use Zustand stores
|
|
401
|
+
- Network requests must use the provided axios instance
|
|
402
|
+
- Theme modifications should extend EduMLTheme
|
|
403
|
+
- Components should handle null states appropriately
|
|
404
|
+
|
|
405
|
+
## Support
|
|
406
|
+
|
|
407
|
+
For issues and feature requests, please use the GitHub issue tracker.
|