@aventoapp/framework 0.1.0
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/dist/index.js +6 -0
- package/dist/index.js.map +7 -0
- package/dist/native/index.js +2522 -0
- package/dist/native/index.js.map +7 -0
- package/dist/server/index.js +2776 -0
- package/dist/server/index.js.map +7 -0
- package/dist/server/workflow/index.js +537 -0
- package/dist/server/workflow/index.js.map +7 -0
- package/dist/shared/index.js +62 -0
- package/dist/shared/index.js.map +7 -0
- package/dist/web/index.js +7323 -0
- package/dist/web/index.js.map +7 -0
- package/package.json +81 -0
- package/schemas/Workflow.json +14 -0
- package/schemas/WorkflowHistory.json +22 -0
- package/schemas/WorkflowInstance.json +16 -0
- package/schemas/WorkflowState.json +18 -0
- package/schemas/WorkflowTransition.json +27 -0
- package/src/index.js +8 -0
- package/src/native/components/NativeAuthProvider.jsx +249 -0
- package/src/native/components/NativeDetail.jsx +270 -0
- package/src/native/components/NativeForm.jsx +543 -0
- package/src/native/components/NativeGrid.jsx +90 -0
- package/src/native/components/NativeJsonGrid.jsx +213 -0
- package/src/native/components/NativeJsonView.jsx +454 -0
- package/src/native/components/NativeJsonViewContext.js +17 -0
- package/src/native/components/NativeShell.jsx +68 -0
- package/src/native/components/NativeViewComponent.jsx +351 -0
- package/src/native/extensions/NativeExtensionRegistry.js +81 -0
- package/src/native/hooks/useNativeStore.js +72 -0
- package/src/native/index.js +15 -0
- package/src/native/layouts/NativeStackLayout.jsx +30 -0
- package/src/native/layouts/NativeTabLayout.jsx +96 -0
- package/src/native/storage.js +13 -0
- package/src/native/stores/NativeBaseStore.js +348 -0
- package/src/native/stores/NativeStoreContext.jsx +53 -0
- package/src/server/ai/capabilities-routes.js +106 -0
- package/src/server/ai/index.js +1 -0
- package/src/server/cache/MemoryCache.js +153 -0
- package/src/server/cache/index.js +2 -0
- package/src/server/cache/middleware.js +12 -0
- package/src/server/db/index.js +14 -0
- package/src/server/db/mongo.js +137 -0
- package/src/server/db/postgres.js +144 -0
- package/src/server/index.js +38 -0
- package/src/server/middleware/auth.js +682 -0
- package/src/server/middleware/can-flags.js +132 -0
- package/src/server/middleware/entityRoles.js +105 -0
- package/src/server/middleware/index.js +58 -0
- package/src/server/middleware/permissions.js +240 -0
- package/src/server/middleware/tenant.js +203 -0
- package/src/server/realtime/EventBus.js +45 -0
- package/src/server/realtime/WebSocketServer.js +105 -0
- package/src/server/realtime/index.js +3 -0
- package/src/server/realtime/middleware.js +18 -0
- package/src/server/services/email-templates.js +157 -0
- package/src/server/services/email.js +78 -0
- package/src/server/services/index.js +15 -0
- package/src/server/services/storage.js +119 -0
- package/src/server/utils/index.js +16 -0
- package/src/server/utils/paginate.js +65 -0
- package/src/server/utils/query-builder.js +293 -0
- package/src/server/utils/route-loader.js +61 -0
- package/src/server/workflow/WorkflowEngine.js +494 -0
- package/src/server/workflow/index.js +2 -0
- package/src/server/workflow/workflow-routes.js +174 -0
- package/src/shared/index.js +10 -0
- package/src/shared/utils/field-accessor.js +108 -0
- package/src/shared/utils/index.js +7 -0
- package/src/shared/utils/validation-utils.js +83 -0
- package/src/web/components/AppRouter/AppRouter.jsx +130 -0
- package/src/web/components/AppRouter/index.js +1 -0
- package/src/web/components/AppShell/AppShell.jsx +101 -0
- package/src/web/components/AppShell/DefaultUserMenu.jsx +54 -0
- package/src/web/components/AppShell/ShellConfig.js +53 -0
- package/src/web/components/AppShell/index.js +3 -0
- package/src/web/components/AuthProvider.jsx +426 -0
- package/src/web/components/CardList/CardList.jsx +272 -0
- package/src/web/components/CardList/index.js +2 -0
- package/src/web/components/DetailView/DetailView.jsx +281 -0
- package/src/web/components/DetailView/index.js +2 -0
- package/src/web/components/Form/Form.jsx +300 -0
- package/src/web/components/Form/FormField.jsx +226 -0
- package/src/web/components/Form/index.js +3 -0
- package/src/web/components/Grid/Grid.jsx +304 -0
- package/src/web/components/Grid/index.js +2 -0
- package/src/web/components/IconRegistry/IconRegistry.jsx +127 -0
- package/src/web/components/IconRegistry/index.js +1 -0
- package/src/web/components/JsonView/JsonView.jsx +647 -0
- package/src/web/components/JsonView/ViewComponent.jsx +1045 -0
- package/src/web/components/JsonView/ViewToolbar.jsx +141 -0
- package/src/web/components/JsonView/index.js +14 -0
- package/src/web/components/JsonView/layouts/SingleLayout.jsx +41 -0
- package/src/web/components/JsonView/layouts/SplitLayout.jsx +122 -0
- package/src/web/components/JsonView/layouts/TabLayout.jsx +112 -0
- package/src/web/components/JsonView/layouts/index.js +8 -0
- package/src/web/components/Layout.jsx +265 -0
- package/src/web/components/MobileLayout/MobileLayout.jsx +385 -0
- package/src/web/components/MobileLayout/index.js +1 -0
- package/src/web/components/Navigation/Navigation.jsx +248 -0
- package/src/web/components/Navigation/index.js +1 -0
- package/src/web/components/NotificationProvider.jsx +55 -0
- package/src/web/components/Pagination/InfiniteScroll.jsx +82 -0
- package/src/web/components/Pagination/Pagination.jsx +73 -0
- package/src/web/components/Pagination/index.js +8 -0
- package/src/web/components/SimpleList/SimpleList.jsx +177 -0
- package/src/web/components/SimpleList/index.js +2 -0
- package/src/web/components/TenantProvider.jsx +121 -0
- package/src/web/components/WorkflowActions/WorkflowActions.jsx +71 -0
- package/src/web/components/WorkflowActions/index.js +1 -0
- package/src/web/components/WorkflowField/WorkflowField.jsx +176 -0
- package/src/web/components/WorkflowField/index.js +2 -0
- package/src/web/components/WorkflowField/workflowColors.js +32 -0
- package/src/web/components/auth/DevTenantSelector.jsx +90 -0
- package/src/web/components/auth/ForgotPasswordForm.jsx +94 -0
- package/src/web/components/auth/RegisterForm.jsx +168 -0
- package/src/web/components/auth/ResetPasswordForm.jsx +121 -0
- package/src/web/components/auth/VerifyEmailView.jsx +85 -0
- package/src/web/components/auth/index.js +5 -0
- package/src/web/components/index.js +39 -0
- package/src/web/components/layouts/CardListLayout.jsx +68 -0
- package/src/web/components/layouts/FullscreenLayout.jsx +30 -0
- package/src/web/components/layouts/MobileStackLayout.jsx +28 -0
- package/src/web/components/layouts/WizardLayout.jsx +86 -0
- package/src/web/components/layouts/index.js +4 -0
- package/src/web/components/mobile/Badge.jsx +105 -0
- package/src/web/components/mobile/BadgeThemeEditor.jsx +104 -0
- package/src/web/components/mobile/EmptyState.jsx +30 -0
- package/src/web/components/mobile/QuickActionButton.jsx +77 -0
- package/src/web/components/mobile/ServerAutocomplete.jsx +123 -0
- package/src/web/components/mobile/StarRating.jsx +42 -0
- package/src/web/components/mobile/StatCard.jsx +65 -0
- package/src/web/components/mobile/index.js +7 -0
- package/src/web/extensions/ExtensionRegistry.js +79 -0
- package/src/web/extensions/index.js +7 -0
- package/src/web/hooks/index.js +15 -0
- package/src/web/hooks/useApi.js +76 -0
- package/src/web/hooks/useAuth.js +37 -0
- package/src/web/hooks/useDebouncedSave.js +158 -0
- package/src/web/hooks/useIsMobile.js +14 -0
- package/src/web/hooks/useOfflineQueue.js +99 -0
- package/src/web/hooks/useSelectionModel.js +143 -0
- package/src/web/hooks/useServerAutocomplete.js +146 -0
- package/src/web/hooks/useStore.js +107 -0
- package/src/web/hooks/useSubscription.js +130 -0
- package/src/web/hooks/useTenant.js +39 -0
- package/src/web/hooks/useTenantResolver.js +65 -0
- package/src/web/hooks/useUndoRedo.js +77 -0
- package/src/web/hooks/useViews.js +113 -0
- package/src/web/hooks/useWorkflow.js +190 -0
- package/src/web/index.js +117 -0
- package/src/web/stores/BaseStore.js +439 -0
- package/src/web/stores/StoreContext.jsx +93 -0
- package/src/web/stores/index.js +3 -0
- package/src/web/theme/index.js +3 -0
- package/src/web/theme/mui-theme.js +228 -0
- package/src/web/utils/formatTimeAgo.js +22 -0
- package/src/web/utils/index.js +1 -0
- package/src/web/views/ViewRegistry.js +235 -0
- package/src/web/views/index.js +2 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ViewToolbar Component
|
|
3
|
+
*
|
|
4
|
+
* Renders view-level action buttons (refresh, create new, etc.)
|
|
5
|
+
* and pagination controls when enabled.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { Box, Button, IconButton, Tooltip, CircularProgress } from '@mui/material';
|
|
9
|
+
import RefreshIcon from '@mui/icons-material/Refresh';
|
|
10
|
+
import AddIcon from '@mui/icons-material/Add';
|
|
11
|
+
import FilterListIcon from '@mui/icons-material/FilterList';
|
|
12
|
+
import SearchIcon from '@mui/icons-material/Search';
|
|
13
|
+
import DownloadIcon from '@mui/icons-material/Download';
|
|
14
|
+
import UploadIcon from '@mui/icons-material/Upload';
|
|
15
|
+
import SettingsIcon from '@mui/icons-material/Settings';
|
|
16
|
+
import { Pagination } from '../Pagination/index.js';
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Icon mapping for toolbar actions
|
|
20
|
+
*/
|
|
21
|
+
const ICONS = {
|
|
22
|
+
Refresh: RefreshIcon,
|
|
23
|
+
Add: AddIcon,
|
|
24
|
+
Filter: FilterListIcon,
|
|
25
|
+
Search: SearchIcon,
|
|
26
|
+
Download: DownloadIcon,
|
|
27
|
+
Upload: UploadIcon,
|
|
28
|
+
Settings: SettingsIcon
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* ViewToolbar
|
|
33
|
+
*
|
|
34
|
+
* @param {Object} config - Toolbar configuration
|
|
35
|
+
* @param {Array} config.actions - Array of action configurations
|
|
36
|
+
* @param {Function} onAction - Called when action is clicked (actionId, actionConfig)
|
|
37
|
+
* @param {boolean} loading - Whether view is loading
|
|
38
|
+
* @param {Object} pagination - Pagination state (page, pageSize, total, etc.)
|
|
39
|
+
* @param {Object} paginationConfig - Pagination configuration from dataSource
|
|
40
|
+
* @param {Function} onPageChange - Called when page changes
|
|
41
|
+
* @param {Function} onPageSizeChange - Called when page size changes
|
|
42
|
+
*/
|
|
43
|
+
export function ViewToolbar({
|
|
44
|
+
config,
|
|
45
|
+
onAction,
|
|
46
|
+
loading = false,
|
|
47
|
+
pagination,
|
|
48
|
+
paginationConfig,
|
|
49
|
+
onPageChange,
|
|
50
|
+
onPageSizeChange
|
|
51
|
+
}) {
|
|
52
|
+
const { actions = [] } = config || {};
|
|
53
|
+
const showPagination = paginationConfig?.mode === 'pages' && pagination;
|
|
54
|
+
|
|
55
|
+
if (actions.length === 0 && !showPagination) {
|
|
56
|
+
return null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const handleClick = (action) => {
|
|
60
|
+
onAction?.(action.id, action);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
return (
|
|
64
|
+
<Box
|
|
65
|
+
sx={{
|
|
66
|
+
display: 'flex',
|
|
67
|
+
alignItems: 'center',
|
|
68
|
+
gap: 1,
|
|
69
|
+
p: 1,
|
|
70
|
+
borderBottom: 1,
|
|
71
|
+
borderColor: 'divider',
|
|
72
|
+
bgcolor: 'background.paper'
|
|
73
|
+
}}
|
|
74
|
+
>
|
|
75
|
+
{/* Action buttons */}
|
|
76
|
+
{actions.map((action) => {
|
|
77
|
+
const Icon = action.icon ? ICONS[action.icon] : null;
|
|
78
|
+
const isRefresh = action.id === 'refresh';
|
|
79
|
+
|
|
80
|
+
// Icon-only actions
|
|
81
|
+
if (action.iconOnly) {
|
|
82
|
+
return (
|
|
83
|
+
<Tooltip key={action.id} title={action.label}>
|
|
84
|
+
<IconButton
|
|
85
|
+
size="small"
|
|
86
|
+
onClick={() => handleClick(action)}
|
|
87
|
+
disabled={loading && isRefresh}
|
|
88
|
+
color={action.color || 'default'}
|
|
89
|
+
>
|
|
90
|
+
{loading && isRefresh ? (
|
|
91
|
+
<CircularProgress size={20} />
|
|
92
|
+
) : Icon ? (
|
|
93
|
+
<Icon />
|
|
94
|
+
) : (
|
|
95
|
+
action.label?.charAt(0)
|
|
96
|
+
)}
|
|
97
|
+
</IconButton>
|
|
98
|
+
</Tooltip>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
// Button actions
|
|
103
|
+
return (
|
|
104
|
+
<Button
|
|
105
|
+
key={action.id}
|
|
106
|
+
variant={action.variant || 'outlined'}
|
|
107
|
+
color={action.color || 'primary'}
|
|
108
|
+
size="small"
|
|
109
|
+
startIcon={
|
|
110
|
+
loading && isRefresh ? (
|
|
111
|
+
<CircularProgress size={16} />
|
|
112
|
+
) : Icon ? (
|
|
113
|
+
<Icon />
|
|
114
|
+
) : null
|
|
115
|
+
}
|
|
116
|
+
onClick={() => handleClick(action)}
|
|
117
|
+
disabled={loading && isRefresh}
|
|
118
|
+
>
|
|
119
|
+
{action.label}
|
|
120
|
+
</Button>
|
|
121
|
+
);
|
|
122
|
+
})}
|
|
123
|
+
|
|
124
|
+
{/* Spacer to push pagination to right */}
|
|
125
|
+
{showPagination && <Box sx={{ flex: 1 }} />}
|
|
126
|
+
|
|
127
|
+
{/* Pagination controls */}
|
|
128
|
+
{showPagination && (
|
|
129
|
+
<Pagination
|
|
130
|
+
pagination={pagination}
|
|
131
|
+
pageSizeOptions={paginationConfig.pageSizeOptions}
|
|
132
|
+
onPageChange={onPageChange}
|
|
133
|
+
onPageSizeChange={onPageSizeChange}
|
|
134
|
+
disabled={loading}
|
|
135
|
+
/>
|
|
136
|
+
)}
|
|
137
|
+
</Box>
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export default ViewToolbar;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JsonView Components
|
|
3
|
+
*
|
|
4
|
+
* Config-driven view rendering system that parses JSON view definitions
|
|
5
|
+
* and renders layouts with interconnected components.
|
|
6
|
+
*/
|
|
7
|
+
export { JsonView, JsonViewContext, useJsonView } from './JsonView.jsx';
|
|
8
|
+
export { ViewComponent } from './ViewComponent.jsx';
|
|
9
|
+
export { ViewToolbar } from './ViewToolbar.jsx';
|
|
10
|
+
|
|
11
|
+
// Layouts
|
|
12
|
+
export { SplitLayout } from './layouts/SplitLayout.jsx';
|
|
13
|
+
export { TabLayout } from './layouts/TabLayout.jsx';
|
|
14
|
+
export { SingleLayout } from './layouts/SingleLayout.jsx';
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SingleLayout Component
|
|
3
|
+
*
|
|
4
|
+
* Renders a single primary component. Additional components (like forms)
|
|
5
|
+
* are rendered as dialogs.
|
|
6
|
+
*/
|
|
7
|
+
import React from 'react';
|
|
8
|
+
import { Box } from '@mui/material';
|
|
9
|
+
import { ViewComponent } from '../ViewComponent.jsx';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* SingleLayout
|
|
13
|
+
*
|
|
14
|
+
* @param {Object} config - Layout configuration
|
|
15
|
+
* @param {Array} components - Array of component configurations
|
|
16
|
+
*/
|
|
17
|
+
export function SingleLayout({ config = {}, components = [] }) {
|
|
18
|
+
const { padding = 2 } = config;
|
|
19
|
+
|
|
20
|
+
// Find the primary component (first non-form component, or first component)
|
|
21
|
+
const primaryComponent = components.find(c => c.type !== 'form') || components[0];
|
|
22
|
+
const dialogComponents = components.filter(c => c.type === 'form');
|
|
23
|
+
|
|
24
|
+
if (!primaryComponent) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return (
|
|
29
|
+
<Box sx={{ p: padding, height: '100%' }}>
|
|
30
|
+
{/* Primary component */}
|
|
31
|
+
<ViewComponent componentConfig={primaryComponent} />
|
|
32
|
+
|
|
33
|
+
{/* Dialog components (forms) */}
|
|
34
|
+
{dialogComponents.map(comp => (
|
|
35
|
+
<ViewComponent key={comp.id} componentConfig={comp} />
|
|
36
|
+
))}
|
|
37
|
+
</Box>
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default SingleLayout;
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* SplitLayout Component
|
|
3
|
+
*
|
|
4
|
+
* Renders components side-by-side (horizontal) or stacked (vertical)
|
|
5
|
+
* with configurable sizes. Perfect for master-detail views.
|
|
6
|
+
*/
|
|
7
|
+
import React, { useMemo } from 'react';
|
|
8
|
+
import { Box } from '@mui/material';
|
|
9
|
+
import { ViewComponent } from '../ViewComponent.jsx';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Parse size value (supports "60%", "400px", "auto")
|
|
13
|
+
*/
|
|
14
|
+
function parseSize(size) {
|
|
15
|
+
if (!size) return 'auto';
|
|
16
|
+
if (typeof size === 'number') return `${size}px`;
|
|
17
|
+
return size;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* SplitLayout
|
|
22
|
+
*
|
|
23
|
+
* @param {Object} config - Layout configuration
|
|
24
|
+
* @param {string} config.direction - 'horizontal' | 'vertical' (default: horizontal)
|
|
25
|
+
* @param {Array} config.sizes - Array of size values (e.g., ["60%", "40%"])
|
|
26
|
+
* @param {number} config.gap - Gap between panels (default: 2)
|
|
27
|
+
* @param {number} config.padding - Container padding (default: 2)
|
|
28
|
+
* @param {Array} components - Array of component configurations
|
|
29
|
+
*/
|
|
30
|
+
export function SplitLayout({ config = {}, components = [] }) {
|
|
31
|
+
const {
|
|
32
|
+
direction = 'horizontal',
|
|
33
|
+
sizes = [],
|
|
34
|
+
gap = 2,
|
|
35
|
+
padding = 2
|
|
36
|
+
} = config;
|
|
37
|
+
|
|
38
|
+
// Separate panel components from dialog components
|
|
39
|
+
const panelComponents = useMemo(() => {
|
|
40
|
+
return components.filter(c =>
|
|
41
|
+
c.type !== 'form' ||
|
|
42
|
+
c.position === 'left' ||
|
|
43
|
+
c.position === 'right' ||
|
|
44
|
+
c.position === 'top' ||
|
|
45
|
+
c.position === 'bottom'
|
|
46
|
+
);
|
|
47
|
+
}, [components]);
|
|
48
|
+
|
|
49
|
+
const dialogComponents = useMemo(() => {
|
|
50
|
+
return components.filter(c =>
|
|
51
|
+
c.type === 'form' &&
|
|
52
|
+
!['left', 'right', 'top', 'bottom'].includes(c.position)
|
|
53
|
+
);
|
|
54
|
+
}, [components]);
|
|
55
|
+
|
|
56
|
+
// Sort components by position
|
|
57
|
+
const sortedPanelComponents = useMemo(() => {
|
|
58
|
+
const positionOrder = direction === 'horizontal'
|
|
59
|
+
? { left: 0, right: 1 }
|
|
60
|
+
: { top: 0, bottom: 1 };
|
|
61
|
+
|
|
62
|
+
return [...panelComponents].sort((a, b) => {
|
|
63
|
+
const orderA = positionOrder[a.position] ?? panelComponents.indexOf(a);
|
|
64
|
+
const orderB = positionOrder[b.position] ?? panelComponents.indexOf(b);
|
|
65
|
+
return orderA - orderB;
|
|
66
|
+
});
|
|
67
|
+
}, [panelComponents, direction]);
|
|
68
|
+
|
|
69
|
+
const isHorizontal = direction === 'horizontal';
|
|
70
|
+
|
|
71
|
+
return (
|
|
72
|
+
<Box sx={{ p: padding, height: '100%' }}>
|
|
73
|
+
<Box
|
|
74
|
+
sx={{
|
|
75
|
+
display: 'flex',
|
|
76
|
+
flexDirection: isHorizontal ? 'row' : 'column',
|
|
77
|
+
gap,
|
|
78
|
+
height: '100%'
|
|
79
|
+
}}
|
|
80
|
+
>
|
|
81
|
+
{sortedPanelComponents.map((comp, index) => {
|
|
82
|
+
const size = sizes[index] || 'auto';
|
|
83
|
+
const parsedSize = parseSize(size);
|
|
84
|
+
|
|
85
|
+
// Calculate flex properties
|
|
86
|
+
let flexStyle = {};
|
|
87
|
+
if (parsedSize === 'auto') {
|
|
88
|
+
flexStyle = { flex: 1 };
|
|
89
|
+
} else if (parsedSize.endsWith('%')) {
|
|
90
|
+
const percent = parseFloat(parsedSize);
|
|
91
|
+
flexStyle = { flex: `0 0 ${percent}%`, maxWidth: isHorizontal ? `${percent}%` : undefined };
|
|
92
|
+
} else {
|
|
93
|
+
flexStyle = { flex: `0 0 ${parsedSize}`, width: isHorizontal ? parsedSize : undefined };
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return (
|
|
97
|
+
<Box
|
|
98
|
+
key={comp.id}
|
|
99
|
+
sx={{
|
|
100
|
+
...flexStyle,
|
|
101
|
+
display: 'flex',
|
|
102
|
+
flexDirection: 'column',
|
|
103
|
+
overflow: 'auto',
|
|
104
|
+
minWidth: 0, // Allow flex items to shrink below content size
|
|
105
|
+
minHeight: 0
|
|
106
|
+
}}
|
|
107
|
+
>
|
|
108
|
+
<ViewComponent componentConfig={comp} />
|
|
109
|
+
</Box>
|
|
110
|
+
);
|
|
111
|
+
})}
|
|
112
|
+
</Box>
|
|
113
|
+
|
|
114
|
+
{/* Dialog components (forms without position) */}
|
|
115
|
+
{dialogComponents.map(comp => (
|
|
116
|
+
<ViewComponent key={comp.id} componentConfig={comp} />
|
|
117
|
+
))}
|
|
118
|
+
</Box>
|
|
119
|
+
);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export default SplitLayout;
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TabLayout Component
|
|
3
|
+
*
|
|
4
|
+
* Renders components in a tabbed interface with configurable titles and icons.
|
|
5
|
+
*/
|
|
6
|
+
import React, { useState, useMemo } from 'react';
|
|
7
|
+
import { Box, Tabs, Tab } from '@mui/material';
|
|
8
|
+
import { ViewComponent } from '../ViewComponent.jsx';
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* TabPanel - Container for tab content
|
|
12
|
+
*/
|
|
13
|
+
function TabPanel({ children, value, index, ...other }) {
|
|
14
|
+
return (
|
|
15
|
+
<div
|
|
16
|
+
role="tabpanel"
|
|
17
|
+
hidden={value !== index}
|
|
18
|
+
id={`tabpanel-${index}`}
|
|
19
|
+
aria-labelledby={`tab-${index}`}
|
|
20
|
+
style={{ height: '100%' }}
|
|
21
|
+
{...other}
|
|
22
|
+
>
|
|
23
|
+
{value === index && (
|
|
24
|
+
<Box sx={{ height: '100%', overflow: 'auto' }}>
|
|
25
|
+
{children}
|
|
26
|
+
</Box>
|
|
27
|
+
)}
|
|
28
|
+
</div>
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* TabLayout
|
|
34
|
+
*
|
|
35
|
+
* @param {Object} config - Layout configuration
|
|
36
|
+
* @param {string} config.variant - Tab variant: 'standard' | 'scrollable' | 'fullWidth'
|
|
37
|
+
* @param {string} config.position - Tab position: 'top' | 'bottom' (default: top)
|
|
38
|
+
* @param {number} config.padding - Content padding (default: 2)
|
|
39
|
+
* @param {Array} components - Array of component configurations
|
|
40
|
+
*/
|
|
41
|
+
export function TabLayout({ config = {}, components = [] }) {
|
|
42
|
+
const {
|
|
43
|
+
variant = 'standard',
|
|
44
|
+
position = 'top',
|
|
45
|
+
padding = 2
|
|
46
|
+
} = config;
|
|
47
|
+
|
|
48
|
+
const [activeTab, setActiveTab] = useState(0);
|
|
49
|
+
|
|
50
|
+
// Separate tab components from dialog components
|
|
51
|
+
const tabComponents = useMemo(() => {
|
|
52
|
+
return components.filter(c => c.type !== 'form' || c.showInTab);
|
|
53
|
+
}, [components]);
|
|
54
|
+
|
|
55
|
+
const dialogComponents = useMemo(() => {
|
|
56
|
+
return components.filter(c => c.type === 'form' && !c.showInTab);
|
|
57
|
+
}, [components]);
|
|
58
|
+
|
|
59
|
+
const handleTabChange = (event, newValue) => {
|
|
60
|
+
setActiveTab(newValue);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
if (tabComponents.length === 0) {
|
|
64
|
+
return null;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const tabsComponent = (
|
|
68
|
+
<Tabs
|
|
69
|
+
value={activeTab}
|
|
70
|
+
onChange={handleTabChange}
|
|
71
|
+
variant={variant}
|
|
72
|
+
scrollButtons={variant === 'scrollable' ? 'auto' : false}
|
|
73
|
+
sx={{ borderBottom: 1, borderColor: 'divider' }}
|
|
74
|
+
>
|
|
75
|
+
{tabComponents.map((comp, index) => (
|
|
76
|
+
<Tab
|
|
77
|
+
key={comp.id}
|
|
78
|
+
label={comp.tabTitle || comp.config?.entityName || comp.id}
|
|
79
|
+
id={`tab-${index}`}
|
|
80
|
+
aria-controls={`tabpanel-${index}`}
|
|
81
|
+
/>
|
|
82
|
+
))}
|
|
83
|
+
</Tabs>
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
const tabPanels = tabComponents.map((comp, index) => (
|
|
87
|
+
<TabPanel key={comp.id} value={activeTab} index={index}>
|
|
88
|
+
<Box sx={{ p: padding }}>
|
|
89
|
+
<ViewComponent componentConfig={comp} />
|
|
90
|
+
</Box>
|
|
91
|
+
</TabPanel>
|
|
92
|
+
));
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<Box sx={{ display: 'flex', flexDirection: 'column', height: '100%' }}>
|
|
96
|
+
{position === 'top' && tabsComponent}
|
|
97
|
+
|
|
98
|
+
<Box sx={{ flex: 1, overflow: 'hidden' }}>
|
|
99
|
+
{tabPanels}
|
|
100
|
+
</Box>
|
|
101
|
+
|
|
102
|
+
{position === 'bottom' && tabsComponent}
|
|
103
|
+
|
|
104
|
+
{/* Dialog components */}
|
|
105
|
+
{dialogComponents.map(comp => (
|
|
106
|
+
<ViewComponent key={comp.id} componentConfig={comp} />
|
|
107
|
+
))}
|
|
108
|
+
</Box>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export default TabLayout;
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Layout Component
|
|
3
|
+
*
|
|
4
|
+
* Main application layout with AppBar, collapsible Drawer navigation,
|
|
5
|
+
* and main content area.
|
|
6
|
+
*/
|
|
7
|
+
import React, { useState, useCallback } from 'react';
|
|
8
|
+
import {
|
|
9
|
+
AppBar,
|
|
10
|
+
Box,
|
|
11
|
+
Drawer,
|
|
12
|
+
IconButton,
|
|
13
|
+
List,
|
|
14
|
+
ListItem,
|
|
15
|
+
ListItemButton,
|
|
16
|
+
ListItemIcon,
|
|
17
|
+
ListItemText,
|
|
18
|
+
Toolbar,
|
|
19
|
+
Typography,
|
|
20
|
+
Divider,
|
|
21
|
+
useTheme,
|
|
22
|
+
useMediaQuery
|
|
23
|
+
} from '@mui/material';
|
|
24
|
+
import MenuIcon from '@mui/icons-material/Menu';
|
|
25
|
+
import ChevronLeftIcon from '@mui/icons-material/ChevronLeft';
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Default drawer width
|
|
29
|
+
*/
|
|
30
|
+
const DRAWER_WIDTH = 240;
|
|
31
|
+
const DRAWER_WIDTH_COLLAPSED = 64;
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* App Layout Component
|
|
35
|
+
*
|
|
36
|
+
* @param {Object} props
|
|
37
|
+
* @param {React.ReactNode} props.children - Main content
|
|
38
|
+
* @param {string} props.title - App title shown in AppBar
|
|
39
|
+
* @param {Array} props.navItems - Navigation items [{icon, label, path, onClick}]
|
|
40
|
+
* @param {React.ReactNode} props.logo - Optional logo component
|
|
41
|
+
* @param {React.ReactNode} props.headerActions - Actions to show in AppBar (right side)
|
|
42
|
+
* @param {React.ReactNode} props.userMenu - User menu component (avatar, dropdown)
|
|
43
|
+
* @param {string} props.activePath - Currently active navigation path
|
|
44
|
+
* @param {Function} props.onNavigate - Callback when nav item clicked
|
|
45
|
+
*/
|
|
46
|
+
export function Layout({
|
|
47
|
+
children,
|
|
48
|
+
title = 'Avento App',
|
|
49
|
+
navItems = [],
|
|
50
|
+
logo,
|
|
51
|
+
headerActions,
|
|
52
|
+
userMenu,
|
|
53
|
+
activePath,
|
|
54
|
+
onNavigate
|
|
55
|
+
}) {
|
|
56
|
+
const theme = useTheme();
|
|
57
|
+
const isMobile = useMediaQuery(theme.breakpoints.down('md'));
|
|
58
|
+
const [drawerOpen, setDrawerOpen] = useState(!isMobile);
|
|
59
|
+
const [mobileOpen, setMobileOpen] = useState(false);
|
|
60
|
+
|
|
61
|
+
const handleDrawerToggle = useCallback(() => {
|
|
62
|
+
if (isMobile) {
|
|
63
|
+
setMobileOpen(prev => !prev);
|
|
64
|
+
} else {
|
|
65
|
+
setDrawerOpen(prev => !prev);
|
|
66
|
+
}
|
|
67
|
+
}, [isMobile]);
|
|
68
|
+
|
|
69
|
+
const handleNavClick = useCallback((item) => {
|
|
70
|
+
if (item.onClick) {
|
|
71
|
+
item.onClick(item);
|
|
72
|
+
}
|
|
73
|
+
if (onNavigate) {
|
|
74
|
+
onNavigate(item.path, item);
|
|
75
|
+
}
|
|
76
|
+
if (isMobile) {
|
|
77
|
+
setMobileOpen(false);
|
|
78
|
+
}
|
|
79
|
+
}, [onNavigate, isMobile]);
|
|
80
|
+
|
|
81
|
+
const drawerWidth = drawerOpen ? DRAWER_WIDTH : DRAWER_WIDTH_COLLAPSED;
|
|
82
|
+
|
|
83
|
+
const drawerContent = (
|
|
84
|
+
<Box sx={{ height: '100%', display: 'flex', flexDirection: 'column' }}>
|
|
85
|
+
{/* Drawer Header */}
|
|
86
|
+
<Toolbar
|
|
87
|
+
sx={{
|
|
88
|
+
display: 'flex',
|
|
89
|
+
alignItems: 'center',
|
|
90
|
+
justifyContent: drawerOpen ? 'space-between' : 'center',
|
|
91
|
+
px: drawerOpen ? 2 : 1
|
|
92
|
+
}}
|
|
93
|
+
>
|
|
94
|
+
{drawerOpen && (
|
|
95
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
|
|
96
|
+
{logo}
|
|
97
|
+
{!logo && (
|
|
98
|
+
<Typography variant="h6" noWrap>
|
|
99
|
+
{title}
|
|
100
|
+
</Typography>
|
|
101
|
+
)}
|
|
102
|
+
</Box>
|
|
103
|
+
)}
|
|
104
|
+
{!isMobile && (
|
|
105
|
+
<IconButton onClick={handleDrawerToggle} size="small">
|
|
106
|
+
<ChevronLeftIcon
|
|
107
|
+
sx={{
|
|
108
|
+
transform: drawerOpen ? 'rotate(0deg)' : 'rotate(180deg)',
|
|
109
|
+
transition: theme.transitions.create('transform')
|
|
110
|
+
}}
|
|
111
|
+
/>
|
|
112
|
+
</IconButton>
|
|
113
|
+
)}
|
|
114
|
+
</Toolbar>
|
|
115
|
+
|
|
116
|
+
<Divider />
|
|
117
|
+
|
|
118
|
+
{/* Navigation Items */}
|
|
119
|
+
<List sx={{ flex: 1, pt: 1 }}>
|
|
120
|
+
{navItems.map((item, index) => (
|
|
121
|
+
<ListItem key={item.path || index} disablePadding sx={{ display: 'block' }}>
|
|
122
|
+
<ListItemButton
|
|
123
|
+
selected={activePath === item.path}
|
|
124
|
+
onClick={() => handleNavClick(item)}
|
|
125
|
+
sx={{
|
|
126
|
+
minHeight: 48,
|
|
127
|
+
justifyContent: drawerOpen ? 'initial' : 'center',
|
|
128
|
+
px: 2.5,
|
|
129
|
+
'&.Mui-selected': {
|
|
130
|
+
backgroundColor: theme.palette.primary.main + '14',
|
|
131
|
+
borderRight: `3px solid ${theme.palette.primary.main}`,
|
|
132
|
+
'&:hover': {
|
|
133
|
+
backgroundColor: theme.palette.primary.main + '20'
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}}
|
|
137
|
+
>
|
|
138
|
+
{item.icon && (
|
|
139
|
+
<ListItemIcon
|
|
140
|
+
sx={{
|
|
141
|
+
minWidth: 0,
|
|
142
|
+
mr: drawerOpen ? 2 : 'auto',
|
|
143
|
+
justifyContent: 'center',
|
|
144
|
+
color: activePath === item.path ? theme.palette.primary.main : 'inherit'
|
|
145
|
+
}}
|
|
146
|
+
>
|
|
147
|
+
{item.icon}
|
|
148
|
+
</ListItemIcon>
|
|
149
|
+
)}
|
|
150
|
+
{drawerOpen && (
|
|
151
|
+
<ListItemText
|
|
152
|
+
primary={item.label}
|
|
153
|
+
primaryTypographyProps={{
|
|
154
|
+
fontWeight: activePath === item.path ? 600 : 400
|
|
155
|
+
}}
|
|
156
|
+
/>
|
|
157
|
+
)}
|
|
158
|
+
</ListItemButton>
|
|
159
|
+
</ListItem>
|
|
160
|
+
))}
|
|
161
|
+
</List>
|
|
162
|
+
</Box>
|
|
163
|
+
);
|
|
164
|
+
|
|
165
|
+
return (
|
|
166
|
+
<Box sx={{ display: 'flex', minHeight: '100vh' }}>
|
|
167
|
+
{/* AppBar */}
|
|
168
|
+
<AppBar
|
|
169
|
+
position="fixed"
|
|
170
|
+
sx={{
|
|
171
|
+
width: { md: `calc(100% - ${drawerWidth}px)` },
|
|
172
|
+
ml: { md: `${drawerWidth}px` },
|
|
173
|
+
transition: theme.transitions.create(['width', 'margin'], {
|
|
174
|
+
easing: theme.transitions.easing.sharp,
|
|
175
|
+
duration: theme.transitions.duration.leavingScreen
|
|
176
|
+
}),
|
|
177
|
+
backgroundColor: 'background.paper',
|
|
178
|
+
color: 'text.primary'
|
|
179
|
+
}}
|
|
180
|
+
>
|
|
181
|
+
<Toolbar>
|
|
182
|
+
<IconButton
|
|
183
|
+
color="inherit"
|
|
184
|
+
edge="start"
|
|
185
|
+
onClick={handleDrawerToggle}
|
|
186
|
+
sx={{ mr: 2, display: { md: 'none' } }}
|
|
187
|
+
>
|
|
188
|
+
<MenuIcon />
|
|
189
|
+
</IconButton>
|
|
190
|
+
|
|
191
|
+
<Typography variant="h6" noWrap component="div" sx={{ flexGrow: 1 }}>
|
|
192
|
+
{title}
|
|
193
|
+
</Typography>
|
|
194
|
+
|
|
195
|
+
{headerActions && (
|
|
196
|
+
<Box sx={{ display: 'flex', alignItems: 'center', gap: 1, mr: 2 }}>
|
|
197
|
+
{headerActions}
|
|
198
|
+
</Box>
|
|
199
|
+
)}
|
|
200
|
+
|
|
201
|
+
{userMenu}
|
|
202
|
+
</Toolbar>
|
|
203
|
+
</AppBar>
|
|
204
|
+
|
|
205
|
+
{/* Mobile Drawer */}
|
|
206
|
+
<Drawer
|
|
207
|
+
variant="temporary"
|
|
208
|
+
open={mobileOpen}
|
|
209
|
+
onClose={handleDrawerToggle}
|
|
210
|
+
ModalProps={{ keepMounted: true }}
|
|
211
|
+
sx={{
|
|
212
|
+
display: { xs: 'block', md: 'none' },
|
|
213
|
+
'& .MuiDrawer-paper': {
|
|
214
|
+
boxSizing: 'border-box',
|
|
215
|
+
width: DRAWER_WIDTH
|
|
216
|
+
}
|
|
217
|
+
}}
|
|
218
|
+
>
|
|
219
|
+
{drawerContent}
|
|
220
|
+
</Drawer>
|
|
221
|
+
|
|
222
|
+
{/* Desktop Drawer */}
|
|
223
|
+
<Drawer
|
|
224
|
+
variant="permanent"
|
|
225
|
+
sx={{
|
|
226
|
+
display: { xs: 'none', md: 'block' },
|
|
227
|
+
'& .MuiDrawer-paper': {
|
|
228
|
+
boxSizing: 'border-box',
|
|
229
|
+
width: drawerWidth,
|
|
230
|
+
transition: theme.transitions.create('width', {
|
|
231
|
+
easing: theme.transitions.easing.sharp,
|
|
232
|
+
duration: theme.transitions.duration.enteringScreen
|
|
233
|
+
}),
|
|
234
|
+
overflowX: 'hidden'
|
|
235
|
+
}
|
|
236
|
+
}}
|
|
237
|
+
open
|
|
238
|
+
>
|
|
239
|
+
{drawerContent}
|
|
240
|
+
</Drawer>
|
|
241
|
+
|
|
242
|
+
{/* Main Content */}
|
|
243
|
+
<Box
|
|
244
|
+
component="main"
|
|
245
|
+
sx={{
|
|
246
|
+
flexGrow: 1,
|
|
247
|
+
p: 3,
|
|
248
|
+
ml: { md: `${drawerWidth}px` },
|
|
249
|
+
width: { xs: '100%', md: `calc(100% - ${drawerWidth}px)` },
|
|
250
|
+
minHeight: '100vh',
|
|
251
|
+
backgroundColor: 'background.default',
|
|
252
|
+
transition: theme.transitions.create(['width', 'margin'], {
|
|
253
|
+
easing: theme.transitions.easing.sharp,
|
|
254
|
+
duration: theme.transitions.duration.leavingScreen
|
|
255
|
+
})
|
|
256
|
+
}}
|
|
257
|
+
>
|
|
258
|
+
<Toolbar /> {/* Spacer for AppBar */}
|
|
259
|
+
{children}
|
|
260
|
+
</Box>
|
|
261
|
+
</Box>
|
|
262
|
+
);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
export default Layout;
|