@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,85 @@
1
+ /**
2
+ * VerifyEmailView Component
3
+ *
4
+ * Auto-verifies email on mount when token is provided.
5
+ * Shows success/error/loading states.
6
+ */
7
+ import React, { useState, useEffect } from 'react';
8
+ import { useAuth } from '../../hooks/useAuth.js';
9
+ import {
10
+ Box,
11
+ Typography,
12
+ Alert,
13
+ CircularProgress,
14
+ Link
15
+ } from '@mui/material';
16
+
17
+ export function VerifyEmailView({ token, onSuccess, onLoginClick }) {
18
+ const { verifyEmail } = useAuth();
19
+
20
+ const [status, setStatus] = useState('loading'); // loading | success | error
21
+ const [message, setMessage] = useState('');
22
+
23
+ useEffect(() => {
24
+ if (!token) {
25
+ setStatus('error');
26
+ setMessage('No verification token provided');
27
+ return;
28
+ }
29
+
30
+ async function verify() {
31
+ try {
32
+ const result = await verifyEmail(token);
33
+
34
+ if (result.success) {
35
+ setStatus('success');
36
+ setMessage(result.message || 'Email verified successfully. You can now log in.');
37
+ onSuccess?.(result);
38
+ } else {
39
+ setStatus('error');
40
+ setMessage(result.error || 'Verification failed');
41
+ }
42
+ } catch (err) {
43
+ setStatus('error');
44
+ setMessage(err.message || 'An error occurred');
45
+ }
46
+ }
47
+
48
+ verify();
49
+ }, [token, verifyEmail, onSuccess]);
50
+
51
+ return (
52
+ <Box sx={{ textAlign: 'center' }}>
53
+ <Typography variant="h5" component="h1" gutterBottom>
54
+ Email Verification
55
+ </Typography>
56
+
57
+ {status === 'loading' && (
58
+ <Box sx={{ my: 3 }}>
59
+ <CircularProgress />
60
+ <Typography variant="body2" color="text.secondary" mt={2}>
61
+ Verifying your email...
62
+ </Typography>
63
+ </Box>
64
+ )}
65
+
66
+ {status === 'success' && (
67
+ <Alert severity="success" sx={{ mb: 2 }}>{message}</Alert>
68
+ )}
69
+
70
+ {status === 'error' && (
71
+ <Alert severity="error" sx={{ mb: 2 }}>{message}</Alert>
72
+ )}
73
+
74
+ {status !== 'loading' && (
75
+ <Typography variant="body2" mt={2}>
76
+ <Link component="button" type="button" onClick={onLoginClick} underline="hover">
77
+ Go to sign in
78
+ </Link>
79
+ </Typography>
80
+ )}
81
+ </Box>
82
+ );
83
+ }
84
+
85
+ export default VerifyEmailView;
@@ -0,0 +1,5 @@
1
+ export { DevTenantSelector } from './DevTenantSelector.jsx';
2
+ export { RegisterForm } from './RegisterForm.jsx';
3
+ export { ForgotPasswordForm } from './ForgotPasswordForm.jsx';
4
+ export { ResetPasswordForm } from './ResetPasswordForm.jsx';
5
+ export { VerifyEmailView } from './VerifyEmailView.jsx';
@@ -0,0 +1,39 @@
1
+ // Web Components
2
+ export { AuthProvider, AuthContext } from './AuthProvider.jsx';
3
+ export { TenantProvider, TenantContext } from './TenantProvider.jsx';
4
+ export { NotificationProvider, useNotification } from './NotificationProvider.jsx';
5
+ export { Layout } from './Layout.jsx';
6
+ export { Navigation } from './Navigation/index.js';
7
+ export { AppRouter } from './AppRouter/index.js';
8
+
9
+ // Universal Config-Driven Components
10
+ export { Grid } from './Grid/index.js';
11
+ export { Form, FormField } from './Form/index.js';
12
+ export { DetailView } from './DetailView/index.js';
13
+ export { SimpleList } from './SimpleList/index.js';
14
+ export { CardList } from './CardList/index.js';
15
+
16
+ // Pagination Components
17
+ export { Pagination, InfiniteScroll } from './Pagination/index.js';
18
+
19
+ // JSON View System
20
+ export { JsonView, JsonViewContext, useJsonView, ViewComponent, ViewToolbar } from './JsonView/index.js';
21
+ export { SplitLayout, TabLayout, SingleLayout } from './JsonView/layouts/index.js';
22
+
23
+ // Workflow Components
24
+ export { WorkflowActions } from './WorkflowActions/index.js';
25
+ export { WorkflowField } from './WorkflowField/index.js';
26
+
27
+ // Shell
28
+ export { AppShell, useShellConfig } from './AppShell/index.js';
29
+ export { MobileLayout } from './MobileLayout/index.js';
30
+ export { IconRegistry, iconRegistry, resolveIcon } from './IconRegistry/index.js';
31
+
32
+ // Mobile Layouts
33
+ export { MobileStackLayout, CardListLayout, FullscreenLayout, WizardLayout } from './layouts/index.js';
34
+
35
+ // Mobile Primitives
36
+ export { QuickActionButton, StatCard, EmptyState, StarRating, Badge, BadgeLegend, BadgeThemeEditor, ServerAutocomplete } from './mobile/index.js';
37
+
38
+ // Auth Components
39
+ export { DevTenantSelector, RegisterForm, ForgotPasswordForm, ResetPasswordForm, VerifyEmailView } from './auth/index.js';
@@ -0,0 +1,68 @@
1
+ /**
2
+ * CardListLayout
3
+ *
4
+ * Search + title/action header + scrollable card list + empty state.
5
+ */
6
+ import React, { useState } from 'react';
7
+ import { Box, TextField, InputAdornment, Typography } from '@mui/material';
8
+ import SearchIcon from '@mui/icons-material/Search';
9
+
10
+ export function CardListLayout({
11
+ children,
12
+ searchPlaceholder = 'Search...',
13
+ onSearch,
14
+ title,
15
+ action,
16
+ emptyMessage = 'No items found',
17
+ isEmpty = false,
18
+ maxWidth = 600,
19
+ }) {
20
+ const [searchTerm, setSearchTerm] = useState('');
21
+
22
+ const handleSearch = (e) => {
23
+ const value = e.target.value;
24
+ setSearchTerm(value);
25
+ onSearch?.(value);
26
+ };
27
+
28
+ return (
29
+ <Box sx={{ display: 'flex', flexDirection: 'column', height: '100%', maxWidth, mx: 'auto', width: '100%' }}>
30
+ <Box sx={{ px: 2, pt: 2, pb: 1 }}>
31
+ {title && (
32
+ <Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', mb: 1 }}>
33
+ <Typography variant="h6">{title}</Typography>
34
+ {action}
35
+ </Box>
36
+ )}
37
+ {onSearch && (
38
+ <TextField
39
+ fullWidth
40
+ size="small"
41
+ placeholder={searchPlaceholder}
42
+ value={searchTerm}
43
+ onChange={handleSearch}
44
+ InputProps={{
45
+ startAdornment: (
46
+ <InputAdornment position="start">
47
+ <SearchIcon />
48
+ </InputAdornment>
49
+ ),
50
+ }}
51
+ />
52
+ )}
53
+ </Box>
54
+
55
+ <Box sx={{ flex: 1, overflow: 'auto', px: 2, pb: 2, display: 'flex', flexDirection: 'column', gap: 1.5 }}>
56
+ {isEmpty ? (
57
+ <Box sx={{ display: 'flex', alignItems: 'center', justifyContent: 'center', py: 6 }}>
58
+ <Typography color="text.secondary">{emptyMessage}</Typography>
59
+ </Box>
60
+ ) : (
61
+ children
62
+ )}
63
+ </Box>
64
+ </Box>
65
+ );
66
+ }
67
+
68
+ export default CardListLayout;
@@ -0,0 +1,30 @@
1
+ /**
2
+ * FullscreenLayout
3
+ *
4
+ * Fixed position full viewport container.
5
+ */
6
+ import React from 'react';
7
+ import { Box } from '@mui/material';
8
+
9
+ export function FullscreenLayout({ children, sx = {} }) {
10
+ return (
11
+ <Box
12
+ sx={{
13
+ position: 'fixed',
14
+ top: 0,
15
+ left: 0,
16
+ right: 0,
17
+ bottom: 0,
18
+ display: 'flex',
19
+ flexDirection: 'column',
20
+ overflow: 'hidden',
21
+ bgcolor: 'background.default',
22
+ ...sx,
23
+ }}
24
+ >
25
+ {children}
26
+ </Box>
27
+ );
28
+ }
29
+
30
+ export default FullscreenLayout;
@@ -0,0 +1,28 @@
1
+ /**
2
+ * MobileStackLayout
3
+ *
4
+ * Flex column layout with gap, padding, and centered maxWidth.
5
+ */
6
+ import React from 'react';
7
+ import { Box } from '@mui/material';
8
+
9
+ export function MobileStackLayout({ children, spacing = 2, padding = 2, maxWidth = 600, sx = {} }) {
10
+ return (
11
+ <Box
12
+ sx={{
13
+ display: 'flex',
14
+ flexDirection: 'column',
15
+ gap: spacing,
16
+ p: padding,
17
+ maxWidth,
18
+ mx: 'auto',
19
+ width: '100%',
20
+ ...sx,
21
+ }}
22
+ >
23
+ {children}
24
+ </Box>
25
+ );
26
+ }
27
+
28
+ export default MobileStackLayout;
@@ -0,0 +1,86 @@
1
+ /**
2
+ * WizardLayout
3
+ *
4
+ * Stepper + back/next/finish wizard container.
5
+ * Supports an optional onCancel callback shown on the first step.
6
+ * Relies on its parent providing a constrained height (e.g. MobileLayout's
7
+ * fixed-position scroll container) so the flex column fills exactly and the
8
+ * button bar stays pinned at the bottom.
9
+ */
10
+ import React from 'react';
11
+ import { Box, Stepper, Step, StepLabel, Button } from '@mui/material';
12
+
13
+ export function WizardLayout({
14
+ steps,
15
+ activeStep,
16
+ onNext,
17
+ onBack,
18
+ onCancel,
19
+ onFinish,
20
+ nextLabel = 'Next',
21
+ finishLabel = 'Finish',
22
+ cancelLabel = 'Cancel',
23
+ nextDisabled = false,
24
+ maxWidth = 600,
25
+ children,
26
+ }) {
27
+ const isLastStep = activeStep === steps.length - 1;
28
+
29
+ return (
30
+ <Box sx={{
31
+ display: 'flex',
32
+ flexDirection: 'column',
33
+ height: 'calc(100dvh - 56px)',
34
+ maxWidth,
35
+ mx: 'auto',
36
+ width: '100%',
37
+ }}>
38
+ <Box sx={{ px: 2, pt: 2, flexShrink: 0 }}>
39
+ <Stepper activeStep={activeStep} alternativeLabel>
40
+ {steps.map((label) => (
41
+ <Step key={label}>
42
+ <StepLabel>{label}</StepLabel>
43
+ </Step>
44
+ ))}
45
+ </Stepper>
46
+ </Box>
47
+
48
+ <Box sx={{ flex: 1, overflow: 'auto', p: 2, WebkitOverflowScrolling: 'touch' }}>
49
+ {children}
50
+ </Box>
51
+
52
+ <Box sx={{ display: 'flex', gap: 1, p: 2, borderTop: 1, borderColor: 'divider', flexShrink: 0 }}>
53
+ <Button
54
+ variant="outlined"
55
+ onClick={activeStep === 0 && onCancel ? onCancel : onBack}
56
+ disabled={activeStep === 0 && !onCancel}
57
+ sx={{ flex: 1, minHeight: 48 }}
58
+ >
59
+ {activeStep === 0 && onCancel ? cancelLabel : 'Back'}
60
+ </Button>
61
+ {isLastStep ? (
62
+ <Button
63
+ variant="contained"
64
+ color="primary"
65
+ onClick={onFinish}
66
+ disabled={nextDisabled}
67
+ sx={{ flex: 2, minHeight: 48, fontWeight: 700, fontSize: '1.1rem' }}
68
+ >
69
+ {finishLabel}
70
+ </Button>
71
+ ) : (
72
+ <Button
73
+ variant="contained"
74
+ onClick={onNext}
75
+ disabled={nextDisabled}
76
+ sx={{ flex: 1, minHeight: 48 }}
77
+ >
78
+ {nextLabel}
79
+ </Button>
80
+ )}
81
+ </Box>
82
+ </Box>
83
+ );
84
+ }
85
+
86
+ export default WizardLayout;
@@ -0,0 +1,4 @@
1
+ export { MobileStackLayout } from './MobileStackLayout.jsx';
2
+ export { CardListLayout } from './CardListLayout.jsx';
3
+ export { FullscreenLayout } from './FullscreenLayout.jsx';
4
+ export { WizardLayout } from './WizardLayout.jsx';
@@ -0,0 +1,105 @@
1
+ import React from 'react';
2
+ import { Box, Typography } from '@mui/material';
3
+
4
+ const SIZES = {
5
+ sm: { box: 24, font: '0.75rem' },
6
+ md: { box: 30, font: '0.875rem' },
7
+ };
8
+
9
+ /**
10
+ * Generic badge component — renders a value inside a configurable shape.
11
+ *
12
+ * @param {Object} props
13
+ * @param {React.ReactNode} props.children - Content to display inside badge
14
+ * @param {Object} props.config - Badge styling: { bg, color, border, shape }
15
+ * @param {boolean} [props.active=true] - Whether to apply badge styling (false = plain text)
16
+ * @param {'sm'|'md'} [props.size='sm'] - Badge size
17
+ */
18
+ export function Badge({ children, config, active = true, size = 'sm' }) {
19
+ const dims = SIZES[size] || SIZES.sm;
20
+
21
+ if (children == null) {
22
+ return (
23
+ <Typography variant="body2" sx={{ color: 'text.disabled', textAlign: 'center', fontSize: dims.font }}>
24
+ -
25
+ </Typography>
26
+ );
27
+ }
28
+
29
+ if (!config || !active) {
30
+ return (
31
+ <Box
32
+ component="span"
33
+ sx={{
34
+ display: 'inline-flex',
35
+ alignItems: 'center',
36
+ justifyContent: 'center',
37
+ minWidth: dims.box,
38
+ fontWeight: 500,
39
+ fontSize: dims.font,
40
+ color: config?.color || 'text.primary',
41
+ lineHeight: 1,
42
+ }}
43
+ >
44
+ {children}
45
+ </Box>
46
+ );
47
+ }
48
+
49
+ return (
50
+ <Box
51
+ component="span"
52
+ sx={{
53
+ display: 'inline-flex',
54
+ alignItems: 'center',
55
+ justifyContent: 'center',
56
+ width: dims.box,
57
+ height: dims.box,
58
+ minWidth: dims.box,
59
+ borderRadius: config.shape === 'circle' ? '50%' : config.shape === 'square' ? '4px' : 0,
60
+ bgcolor: config.bg || 'transparent',
61
+ color: config.color || 'text.primary',
62
+ border: config.border || 'none',
63
+ fontWeight: 700,
64
+ fontSize: dims.font,
65
+ lineHeight: 1,
66
+ }}
67
+ >
68
+ {children}
69
+ </Box>
70
+ );
71
+ }
72
+
73
+ /**
74
+ * Badge legend — shows a row of badge type indicators.
75
+ *
76
+ * @param {Object} props
77
+ * @param {Array<{key: string, label: string, config: Object}>} props.items
78
+ * @param {'sm'|'md'} [props.size='sm']
79
+ */
80
+ export function BadgeLegend({ items, size = 'sm' }) {
81
+ const dims = SIZES[size] || SIZES.sm;
82
+
83
+ return (
84
+ <Box sx={{ display: 'flex', justifyContent: 'center', gap: 1.5, flexWrap: 'wrap', py: 0.5 }}>
85
+ {items.map(({ key, label, config }) => (
86
+ <Box key={key} sx={{ display: 'flex', alignItems: 'center', gap: 0.5 }}>
87
+ <Box
88
+ sx={{
89
+ width: dims.box * 0.65,
90
+ height: dims.box * 0.65,
91
+ borderRadius: config.shape === 'circle' ? '50%' : '2px',
92
+ bgcolor: config.bg,
93
+ border: config.border,
94
+ }}
95
+ />
96
+ <Typography variant="caption" color="text.secondary" sx={{ fontSize: '0.65rem' }}>
97
+ {label}
98
+ </Typography>
99
+ </Box>
100
+ ))}
101
+ </Box>
102
+ );
103
+ }
104
+
105
+ export default Badge;
@@ -0,0 +1,104 @@
1
+ import React from 'react';
2
+ import {
3
+ Box, Table, TableBody, TableCell, TableHead, TableRow,
4
+ ToggleButton, ToggleButtonGroup,
5
+ } from '@mui/material';
6
+ import CircleIcon from '@mui/icons-material/Circle';
7
+ import SquareIcon from '@mui/icons-material/Square';
8
+ import RemoveIcon from '@mui/icons-material/Remove';
9
+
10
+ /**
11
+ * Generic badge theme editor — table of badge types with color pickers and shape toggles.
12
+ *
13
+ * @param {Object} props
14
+ * @param {Array<{key: string, label: string, preview: React.ReactNode}>} props.types - Badge types to edit
15
+ * @param {Object} props.theme - Current theme: { [typeKey]: { bg, color, border, shape } }
16
+ * @param {Function} props.onColorChange - (typeKey, field, value) => void
17
+ * @param {Function} props.onShapeChange - (typeKey, shape) => void
18
+ */
19
+ export function BadgeThemeEditor({ types, theme, onColorChange, onShapeChange }) {
20
+ return (
21
+ <Box sx={{ overflow: 'auto', px: 1 }}>
22
+ <Table size="small">
23
+ <TableHead>
24
+ <TableRow>
25
+ <TableCell sx={{ fontWeight: 700 }}>Type</TableCell>
26
+ <TableCell sx={{ fontWeight: 700 }} align="center">Preview</TableCell>
27
+ <TableCell sx={{ fontWeight: 700 }} align="center">BG</TableCell>
28
+ <TableCell sx={{ fontWeight: 700 }} align="center">Text</TableCell>
29
+ <TableCell sx={{ fontWeight: 700 }} align="center">Shape</TableCell>
30
+ </TableRow>
31
+ </TableHead>
32
+ <TableBody>
33
+ {types.map(({ key, label, preview }) => {
34
+ const badge = theme[key];
35
+ if (!badge) return null;
36
+ const isSpecial = badge.shape !== 'none';
37
+
38
+ return (
39
+ <TableRow key={key}>
40
+ <TableCell sx={{ fontWeight: 600 }}>{label}</TableCell>
41
+ <TableCell align="center">
42
+ <Box
43
+ sx={{
44
+ display: 'inline-flex',
45
+ alignItems: 'center',
46
+ justifyContent: 'center',
47
+ width: isSpecial ? 30 : 'auto',
48
+ height: isSpecial ? 30 : 'auto',
49
+ minWidth: 30,
50
+ borderRadius: badge.shape === 'circle' ? '50%' : badge.shape === 'square' ? '4px' : 0,
51
+ bgcolor: badge.bg,
52
+ color: badge.color,
53
+ border: badge.border,
54
+ fontWeight: isSpecial ? 700 : 500,
55
+ fontSize: '0.875rem',
56
+ }}
57
+ >
58
+ {preview}
59
+ </Box>
60
+ </TableCell>
61
+ <TableCell align="center">
62
+ <input
63
+ type="color"
64
+ value={badge.bg === 'transparent' ? '#ffffff' : badge.bg}
65
+ onChange={e => onColorChange(key, 'bg', e.target.value)}
66
+ style={{ width: 32, height: 28, border: 'none', cursor: 'pointer', background: 'none' }}
67
+ />
68
+ </TableCell>
69
+ <TableCell align="center">
70
+ <input
71
+ type="color"
72
+ value={badge.color}
73
+ onChange={e => onColorChange(key, 'color', e.target.value)}
74
+ style={{ width: 32, height: 28, border: 'none', cursor: 'pointer', background: 'none' }}
75
+ />
76
+ </TableCell>
77
+ <TableCell align="center">
78
+ <ToggleButtonGroup
79
+ size="small"
80
+ exclusive
81
+ value={badge.shape}
82
+ onChange={(_, val) => { if (val) onShapeChange(key, val); }}
83
+ >
84
+ <ToggleButton value="circle" sx={{ p: 0.5 }}>
85
+ <CircleIcon sx={{ fontSize: 16 }} />
86
+ </ToggleButton>
87
+ <ToggleButton value="square" sx={{ p: 0.5 }}>
88
+ <SquareIcon sx={{ fontSize: 16 }} />
89
+ </ToggleButton>
90
+ <ToggleButton value="none" sx={{ p: 0.5 }}>
91
+ <RemoveIcon sx={{ fontSize: 16 }} />
92
+ </ToggleButton>
93
+ </ToggleButtonGroup>
94
+ </TableCell>
95
+ </TableRow>
96
+ );
97
+ })}
98
+ </TableBody>
99
+ </Table>
100
+ </Box>
101
+ );
102
+ }
103
+
104
+ export default BadgeThemeEditor;
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import { Box, Typography, Button } from '@mui/material';
3
+
4
+ export function EmptyState({ icon: Icon, title, description, actionLabel, onAction }) {
5
+ return (
6
+ <Box sx={{
7
+ display: 'flex', flexDirection: 'column', alignItems: 'center',
8
+ justifyContent: 'center', py: 6, px: 3, textAlign: 'center',
9
+ }}>
10
+ {Icon && (
11
+ <Icon sx={{ fontSize: 64, color: 'grey.400', mb: 2 }} />
12
+ )}
13
+ <Typography variant="h6" fontWeight={600} gutterBottom>
14
+ {title}
15
+ </Typography>
16
+ {description && (
17
+ <Typography variant="body2" color="text.secondary" sx={{ mb: 3, maxWidth: 300 }}>
18
+ {description}
19
+ </Typography>
20
+ )}
21
+ {actionLabel && onAction && (
22
+ <Button variant="contained" onClick={onAction}>
23
+ {actionLabel}
24
+ </Button>
25
+ )}
26
+ </Box>
27
+ );
28
+ }
29
+
30
+ export default EmptyState;
@@ -0,0 +1,77 @@
1
+ /**
2
+ * QuickActionButton
3
+ *
4
+ * 80x80 touch button with colored circle icon + label.
5
+ */
6
+ import React from 'react';
7
+ import { ButtonBase, Box, Typography } from '@mui/material';
8
+
9
+ export function QuickActionButton({ icon, label, onClick, color = 'primary' }) {
10
+ return (
11
+ <ButtonBase
12
+ onClick={onClick}
13
+ sx={{
14
+ display: 'flex',
15
+ flexDirection: 'column',
16
+ alignItems: 'center',
17
+ justifyContent: 'center',
18
+ width: 80,
19
+ minHeight: 80,
20
+ borderRadius: 2,
21
+ bgcolor: 'background.paper',
22
+ border: '1px solid',
23
+ borderColor: 'divider',
24
+ p: 1,
25
+ gap: 0.5,
26
+ transition: 'box-shadow 0.15s, transform 0.1s',
27
+ '&:hover': {
28
+ bgcolor: 'action.hover',
29
+ },
30
+ '&:active': {
31
+ boxShadow: 3,
32
+ transform: 'scale(0.97)',
33
+ },
34
+ minWidth: 48,
35
+ touchAction: 'manipulation',
36
+ }}
37
+ >
38
+ <Box
39
+ sx={{
40
+ display: 'flex',
41
+ alignItems: 'center',
42
+ justifyContent: 'center',
43
+ width: 44,
44
+ height: 44,
45
+ borderRadius: '50%',
46
+ bgcolor: `${color}.main`,
47
+ color: 'common.white',
48
+ '& .MuiSvgIcon-root': {
49
+ fontSize: '1.5rem',
50
+ },
51
+ }}
52
+ >
53
+ {icon}
54
+ </Box>
55
+
56
+ {label && (
57
+ <Typography
58
+ variant="caption"
59
+ sx={{
60
+ fontWeight: 600,
61
+ color: 'text.secondary',
62
+ lineHeight: 1.2,
63
+ textAlign: 'center',
64
+ maxWidth: '100%',
65
+ overflow: 'hidden',
66
+ textOverflow: 'ellipsis',
67
+ whiteSpace: 'nowrap',
68
+ }}
69
+ >
70
+ {label}
71
+ </Typography>
72
+ )}
73
+ </ButtonBase>
74
+ );
75
+ }
76
+
77
+ export default QuickActionButton;