@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.
Files changed (160) hide show
  1. package/dist/index.js +6 -0
  2. package/dist/index.js.map +7 -0
  3. package/dist/native/index.js +2522 -0
  4. package/dist/native/index.js.map +7 -0
  5. package/dist/server/index.js +2776 -0
  6. package/dist/server/index.js.map +7 -0
  7. package/dist/server/workflow/index.js +537 -0
  8. package/dist/server/workflow/index.js.map +7 -0
  9. package/dist/shared/index.js +62 -0
  10. package/dist/shared/index.js.map +7 -0
  11. package/dist/web/index.js +7323 -0
  12. package/dist/web/index.js.map +7 -0
  13. package/package.json +81 -0
  14. package/schemas/Workflow.json +14 -0
  15. package/schemas/WorkflowHistory.json +22 -0
  16. package/schemas/WorkflowInstance.json +16 -0
  17. package/schemas/WorkflowState.json +18 -0
  18. package/schemas/WorkflowTransition.json +27 -0
  19. package/src/index.js +8 -0
  20. package/src/native/components/NativeAuthProvider.jsx +249 -0
  21. package/src/native/components/NativeDetail.jsx +270 -0
  22. package/src/native/components/NativeForm.jsx +543 -0
  23. package/src/native/components/NativeGrid.jsx +90 -0
  24. package/src/native/components/NativeJsonGrid.jsx +213 -0
  25. package/src/native/components/NativeJsonView.jsx +454 -0
  26. package/src/native/components/NativeJsonViewContext.js +17 -0
  27. package/src/native/components/NativeShell.jsx +68 -0
  28. package/src/native/components/NativeViewComponent.jsx +351 -0
  29. package/src/native/extensions/NativeExtensionRegistry.js +81 -0
  30. package/src/native/hooks/useNativeStore.js +72 -0
  31. package/src/native/index.js +15 -0
  32. package/src/native/layouts/NativeStackLayout.jsx +30 -0
  33. package/src/native/layouts/NativeTabLayout.jsx +96 -0
  34. package/src/native/storage.js +13 -0
  35. package/src/native/stores/NativeBaseStore.js +348 -0
  36. package/src/native/stores/NativeStoreContext.jsx +53 -0
  37. package/src/server/ai/capabilities-routes.js +106 -0
  38. package/src/server/ai/index.js +1 -0
  39. package/src/server/cache/MemoryCache.js +153 -0
  40. package/src/server/cache/index.js +2 -0
  41. package/src/server/cache/middleware.js +12 -0
  42. package/src/server/db/index.js +14 -0
  43. package/src/server/db/mongo.js +137 -0
  44. package/src/server/db/postgres.js +144 -0
  45. package/src/server/index.js +38 -0
  46. package/src/server/middleware/auth.js +682 -0
  47. package/src/server/middleware/can-flags.js +132 -0
  48. package/src/server/middleware/entityRoles.js +105 -0
  49. package/src/server/middleware/index.js +58 -0
  50. package/src/server/middleware/permissions.js +240 -0
  51. package/src/server/middleware/tenant.js +203 -0
  52. package/src/server/realtime/EventBus.js +45 -0
  53. package/src/server/realtime/WebSocketServer.js +105 -0
  54. package/src/server/realtime/index.js +3 -0
  55. package/src/server/realtime/middleware.js +18 -0
  56. package/src/server/services/email-templates.js +157 -0
  57. package/src/server/services/email.js +78 -0
  58. package/src/server/services/index.js +15 -0
  59. package/src/server/services/storage.js +119 -0
  60. package/src/server/utils/index.js +16 -0
  61. package/src/server/utils/paginate.js +65 -0
  62. package/src/server/utils/query-builder.js +293 -0
  63. package/src/server/utils/route-loader.js +61 -0
  64. package/src/server/workflow/WorkflowEngine.js +494 -0
  65. package/src/server/workflow/index.js +2 -0
  66. package/src/server/workflow/workflow-routes.js +174 -0
  67. package/src/shared/index.js +10 -0
  68. package/src/shared/utils/field-accessor.js +108 -0
  69. package/src/shared/utils/index.js +7 -0
  70. package/src/shared/utils/validation-utils.js +83 -0
  71. package/src/web/components/AppRouter/AppRouter.jsx +130 -0
  72. package/src/web/components/AppRouter/index.js +1 -0
  73. package/src/web/components/AppShell/AppShell.jsx +101 -0
  74. package/src/web/components/AppShell/DefaultUserMenu.jsx +54 -0
  75. package/src/web/components/AppShell/ShellConfig.js +53 -0
  76. package/src/web/components/AppShell/index.js +3 -0
  77. package/src/web/components/AuthProvider.jsx +426 -0
  78. package/src/web/components/CardList/CardList.jsx +272 -0
  79. package/src/web/components/CardList/index.js +2 -0
  80. package/src/web/components/DetailView/DetailView.jsx +281 -0
  81. package/src/web/components/DetailView/index.js +2 -0
  82. package/src/web/components/Form/Form.jsx +300 -0
  83. package/src/web/components/Form/FormField.jsx +226 -0
  84. package/src/web/components/Form/index.js +3 -0
  85. package/src/web/components/Grid/Grid.jsx +304 -0
  86. package/src/web/components/Grid/index.js +2 -0
  87. package/src/web/components/IconRegistry/IconRegistry.jsx +127 -0
  88. package/src/web/components/IconRegistry/index.js +1 -0
  89. package/src/web/components/JsonView/JsonView.jsx +647 -0
  90. package/src/web/components/JsonView/ViewComponent.jsx +1045 -0
  91. package/src/web/components/JsonView/ViewToolbar.jsx +141 -0
  92. package/src/web/components/JsonView/index.js +14 -0
  93. package/src/web/components/JsonView/layouts/SingleLayout.jsx +41 -0
  94. package/src/web/components/JsonView/layouts/SplitLayout.jsx +122 -0
  95. package/src/web/components/JsonView/layouts/TabLayout.jsx +112 -0
  96. package/src/web/components/JsonView/layouts/index.js +8 -0
  97. package/src/web/components/Layout.jsx +265 -0
  98. package/src/web/components/MobileLayout/MobileLayout.jsx +385 -0
  99. package/src/web/components/MobileLayout/index.js +1 -0
  100. package/src/web/components/Navigation/Navigation.jsx +248 -0
  101. package/src/web/components/Navigation/index.js +1 -0
  102. package/src/web/components/NotificationProvider.jsx +55 -0
  103. package/src/web/components/Pagination/InfiniteScroll.jsx +82 -0
  104. package/src/web/components/Pagination/Pagination.jsx +73 -0
  105. package/src/web/components/Pagination/index.js +8 -0
  106. package/src/web/components/SimpleList/SimpleList.jsx +177 -0
  107. package/src/web/components/SimpleList/index.js +2 -0
  108. package/src/web/components/TenantProvider.jsx +121 -0
  109. package/src/web/components/WorkflowActions/WorkflowActions.jsx +71 -0
  110. package/src/web/components/WorkflowActions/index.js +1 -0
  111. package/src/web/components/WorkflowField/WorkflowField.jsx +176 -0
  112. package/src/web/components/WorkflowField/index.js +2 -0
  113. package/src/web/components/WorkflowField/workflowColors.js +32 -0
  114. package/src/web/components/auth/DevTenantSelector.jsx +90 -0
  115. package/src/web/components/auth/ForgotPasswordForm.jsx +94 -0
  116. package/src/web/components/auth/RegisterForm.jsx +168 -0
  117. package/src/web/components/auth/ResetPasswordForm.jsx +121 -0
  118. package/src/web/components/auth/VerifyEmailView.jsx +85 -0
  119. package/src/web/components/auth/index.js +5 -0
  120. package/src/web/components/index.js +39 -0
  121. package/src/web/components/layouts/CardListLayout.jsx +68 -0
  122. package/src/web/components/layouts/FullscreenLayout.jsx +30 -0
  123. package/src/web/components/layouts/MobileStackLayout.jsx +28 -0
  124. package/src/web/components/layouts/WizardLayout.jsx +86 -0
  125. package/src/web/components/layouts/index.js +4 -0
  126. package/src/web/components/mobile/Badge.jsx +105 -0
  127. package/src/web/components/mobile/BadgeThemeEditor.jsx +104 -0
  128. package/src/web/components/mobile/EmptyState.jsx +30 -0
  129. package/src/web/components/mobile/QuickActionButton.jsx +77 -0
  130. package/src/web/components/mobile/ServerAutocomplete.jsx +123 -0
  131. package/src/web/components/mobile/StarRating.jsx +42 -0
  132. package/src/web/components/mobile/StatCard.jsx +65 -0
  133. package/src/web/components/mobile/index.js +7 -0
  134. package/src/web/extensions/ExtensionRegistry.js +79 -0
  135. package/src/web/extensions/index.js +7 -0
  136. package/src/web/hooks/index.js +15 -0
  137. package/src/web/hooks/useApi.js +76 -0
  138. package/src/web/hooks/useAuth.js +37 -0
  139. package/src/web/hooks/useDebouncedSave.js +158 -0
  140. package/src/web/hooks/useIsMobile.js +14 -0
  141. package/src/web/hooks/useOfflineQueue.js +99 -0
  142. package/src/web/hooks/useSelectionModel.js +143 -0
  143. package/src/web/hooks/useServerAutocomplete.js +146 -0
  144. package/src/web/hooks/useStore.js +107 -0
  145. package/src/web/hooks/useSubscription.js +130 -0
  146. package/src/web/hooks/useTenant.js +39 -0
  147. package/src/web/hooks/useTenantResolver.js +65 -0
  148. package/src/web/hooks/useUndoRedo.js +77 -0
  149. package/src/web/hooks/useViews.js +113 -0
  150. package/src/web/hooks/useWorkflow.js +190 -0
  151. package/src/web/index.js +117 -0
  152. package/src/web/stores/BaseStore.js +439 -0
  153. package/src/web/stores/StoreContext.jsx +93 -0
  154. package/src/web/stores/index.js +3 -0
  155. package/src/web/theme/index.js +3 -0
  156. package/src/web/theme/mui-theme.js +228 -0
  157. package/src/web/utils/formatTimeAgo.js +22 -0
  158. package/src/web/utils/index.js +1 -0
  159. package/src/web/views/ViewRegistry.js +235 -0
  160. 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,8 @@
1
+ /**
2
+ * Layout Components for JsonView
3
+ *
4
+ * Different layout strategies for arranging view components.
5
+ */
6
+ export { SplitLayout } from './SplitLayout.jsx';
7
+ export { TabLayout } from './TabLayout.jsx';
8
+ export { SingleLayout } from './SingleLayout.jsx';
@@ -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;