@pattern-stack/frontend-patterns 0.0.3 → 0.0.4
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.es.js +1 -1
- package/dist/index.js +1 -0
- package/package.json +5 -3
- package/src/App.css +42 -0
- package/src/App.tsx +54 -0
- package/src/__tests__/README.md +221 -0
- package/src/__tests__/atoms/hooks/simple-hooks.test.ts +44 -0
- package/src/__tests__/atoms/ui/button.test.tsx +68 -0
- package/src/__tests__/atoms/utils/simple.test.ts +18 -0
- package/src/__tests__/atoms/utils/utils.test.ts +77 -0
- package/src/__tests__/features/auth/simple-auth.test.tsx +40 -0
- package/src/__tests__/molecules/layout/simple-layout.test.tsx +81 -0
- package/src/__tests__/organisms/showcase/simple-showcase.test.tsx +167 -0
- package/src/__tests__/setup.ts +51 -0
- package/src/__tests__/utils.tsx +123 -0
- package/src/atoms/composed/Accordion/Accordion.tsx +271 -0
- package/src/atoms/composed/Accordion/index.ts +1 -0
- package/src/atoms/composed/Alert/Alert.tsx +132 -0
- package/src/atoms/composed/Alert/index.ts +1 -0
- package/src/atoms/composed/Breadcrumb/Breadcrumb.tsx +83 -0
- package/src/atoms/composed/Breadcrumb/index.ts +1 -0
- package/src/atoms/composed/Chart/Chart.tsx +425 -0
- package/src/atoms/composed/Chart/index.ts +2 -0
- package/src/atoms/composed/ColorSwatch/ColorSwatch.tsx +72 -0
- package/src/atoms/composed/ColorSwatch/index.ts +1 -0
- package/src/atoms/composed/DarkModeToggle.tsx +66 -0
- package/src/atoms/composed/DataBadge/DataBadge.tsx +81 -0
- package/src/atoms/composed/DataBadge/index.ts +1 -0
- package/src/atoms/composed/DataTable/DataTable.tsx +394 -0
- package/src/atoms/composed/DataTable/TableCellWithTooltip.tsx +41 -0
- package/src/atoms/composed/DataTable/index.ts +2 -0
- package/src/atoms/composed/DateTimePicker/DateTimePicker.tsx +611 -0
- package/src/atoms/composed/DateTimePicker/index.ts +2 -0
- package/src/atoms/composed/DetailedCard/DetailedCard.tsx +181 -0
- package/src/atoms/composed/DetailedCard/index.ts +2 -0
- package/src/atoms/composed/EmptyState/EmptyState.tsx +90 -0
- package/src/atoms/composed/EmptyState/index.ts +1 -0
- package/src/atoms/composed/FileUpload/FileUpload.tsx +477 -0
- package/src/atoms/composed/FileUpload/index.ts +2 -0
- package/src/atoms/composed/FormField/FormField.tsx +92 -0
- package/src/atoms/composed/FormField/index.ts +1 -0
- package/src/atoms/composed/GlobalSearch/GlobalSearch.tsx +37 -0
- package/src/atoms/composed/GlobalSearch/index.ts +1 -0
- package/src/atoms/composed/IconBadge/IconBadge.tsx +95 -0
- package/src/atoms/composed/IconBadge/index.ts +2 -0
- package/src/atoms/composed/Modal/Modal.tsx +223 -0
- package/src/atoms/composed/Modal/index.ts +2 -0
- package/src/atoms/composed/PaletteSwitcher.tsx +386 -0
- package/src/atoms/composed/ProgressBar/ProgressBar.tsx +116 -0
- package/src/atoms/composed/ProgressBar/index.ts +1 -0
- package/src/atoms/composed/StatCard/StatCard.tsx +219 -0
- package/src/atoms/composed/StatCard/index.ts +1 -0
- package/src/atoms/composed/StyleGuide.tsx +717 -0
- package/src/atoms/composed/Toast/Toast.tsx +219 -0
- package/src/atoms/composed/Toast/index.ts +1 -0
- package/src/atoms/composed/Tooltip/Tooltip.tsx +213 -0
- package/src/atoms/composed/Tooltip/index.ts +1 -0
- package/src/atoms/composed/UserAvatar/UserAvatar.tsx +139 -0
- package/src/atoms/composed/UserAvatar/index.ts +1 -0
- package/src/atoms/composed/UserMenu/UserMenu.tsx +16 -0
- package/src/atoms/composed/UserMenu/index.ts +1 -0
- package/src/atoms/composed/index.ts +29 -0
- package/src/atoms/hooks/useApi.ts +80 -0
- package/src/atoms/hooks/useHealth.ts +17 -0
- package/src/atoms/index.ts +13 -0
- package/src/atoms/services/api/client.ts +134 -0
- package/src/atoms/services/auth-service.ts +248 -0
- package/src/atoms/services/health.ts +15 -0
- package/src/atoms/services/index.ts +3 -0
- package/src/atoms/shared/config/constants.ts +17 -0
- package/src/atoms/shared/config/dashboard-sizes.ts +111 -0
- package/src/atoms/shared/config/environment.ts +10 -0
- package/src/atoms/shared/index.ts +4 -0
- package/src/atoms/shared/styles/color-palettes.css +566 -0
- package/src/atoms/types/auth.ts +62 -0
- package/src/atoms/types/generated.ts +1469 -0
- package/src/atoms/types/index.ts +4 -0
- package/src/atoms/types/loading.ts +28 -0
- package/src/atoms/ui/Badge.tsx +30 -0
- package/src/atoms/ui/ErrorBoundary.tsx +59 -0
- package/src/atoms/ui/Select.tsx +53 -0
- package/src/atoms/ui/Switch.tsx +42 -0
- package/src/atoms/ui/Tabs.tsx +118 -0
- package/src/atoms/ui/avatar.tsx +48 -0
- package/src/atoms/ui/button.tsx +70 -0
- package/src/atoms/ui/card.tsx +76 -0
- package/src/atoms/ui/dropdown-menu.tsx +199 -0
- package/src/atoms/ui/index.ts +39 -0
- package/src/atoms/ui/input.tsx +23 -0
- package/src/atoms/ui/label.tsx +23 -0
- package/src/atoms/ui/skeleton.tsx +13 -0
- package/src/atoms/ui/spinner.tsx +49 -0
- package/src/atoms/ui/table.tsx +116 -0
- package/src/atoms/utils/animations.ts +135 -0
- package/src/atoms/utils/tooltip-helpers.ts +140 -0
- package/src/atoms/utils/utils.ts +9 -0
- package/src/features/auth/components/LoginForm.tsx +168 -0
- package/src/features/auth/components/LogoutButton.tsx +19 -0
- package/src/features/auth/components/ProtectedRoute.tsx +60 -0
- package/src/features/auth/components/index.ts +4 -0
- package/src/features/auth/hooks/index.ts +2 -0
- package/src/features/auth/hooks/useAuth.tsx +205 -0
- package/src/features/auth/hooks/usePermissions.ts +35 -0
- package/src/features/auth/index.ts +2 -0
- package/src/features/index.ts +2 -0
- package/src/index.css +704 -0
- package/src/index.ts +13 -0
- package/src/main.tsx +48 -0
- package/src/molecules/.gitkeep +0 -0
- package/src/molecules/forms/FormGroup.tsx +75 -0
- package/src/molecules/forms/SearchInput.tsx +259 -0
- package/src/molecules/forms/index.ts +4 -0
- package/src/molecules/index.ts +4 -0
- package/src/molecules/layout/AppHeader/AppHeader.tsx +42 -0
- package/src/molecules/layout/AppHeader/index.ts +1 -0
- package/src/molecules/layout/AppLayout.tsx +29 -0
- package/src/molecules/layout/PageTemplate.tsx +87 -0
- package/src/molecules/layout/SectionHeader/SectionHeader.tsx +87 -0
- package/src/molecules/layout/SectionHeader/index.ts +1 -0
- package/src/molecules/layout/ShowcaseSection.tsx +57 -0
- package/src/molecules/layout/Sidebar.tsx +144 -0
- package/src/molecules/layout/SidebarButton/SidebarButton.tsx +99 -0
- package/src/molecules/layout/SidebarButton/index.ts +1 -0
- package/src/molecules/layout/SidebarContext.tsx +31 -0
- package/src/molecules/layout/index.ts +7 -0
- package/src/molecules/navigation/NavMenu.tsx +188 -0
- package/src/molecules/navigation/Pagination.tsx +172 -0
- package/src/molecules/navigation/index.ts +4 -0
- package/src/organisms/index.ts +5 -0
- package/src/organisms/showcase/ComponentShowcasePage.tsx +2496 -0
- package/src/organisms/showcase/index.ts +1 -0
- package/src/pages/AdminShowcase/AdminCRUDShowcase.tsx +242 -0
- package/src/pages/AdminShowcase/AdminDashboardShowcase.tsx +171 -0
- package/src/pages/AdminShowcase/AdminDetailShowcase.tsx +385 -0
- package/src/pages/AdminShowcase/index.tsx +3 -0
- package/src/pages/ComponentShowcase/BadgesShowcase.tsx +188 -0
- package/src/pages/ComponentShowcase/CardsShowcase.tsx +392 -0
- package/src/pages/ComponentShowcase/PalettesShowcase.tsx +207 -0
- package/src/pages/ComponentShowcase/StatesShowcase.tsx +485 -0
- package/src/pages/ComponentShowcase/TablesShowcase.tsx +134 -0
- package/src/pages/ComponentShowcase/TypographyShowcase.tsx +255 -0
- package/src/pages/ComponentShowcase/index.tsx +188 -0
- package/src/pages/index.ts +2 -0
- package/src/templates/AuthTemplate.tsx +216 -0
- package/src/templates/ComponentShowcaseTemplate.tsx +173 -0
- package/src/templates/DashboardTemplate.tsx +232 -0
- package/src/templates/DataTemplate.tsx +319 -0
- package/src/templates/admin/AdminCRUDTemplate.tsx +630 -0
- package/src/templates/admin/AdminDashboardTemplate.tsx +351 -0
- package/src/templates/admin/AdminDetailTemplate.tsx +563 -0
- package/src/templates/admin/index.ts +29 -0
- package/src/templates/factory.tsx +169 -0
- package/src/templates/index.ts +37 -0
- package/src/vite-env.d.ts +1 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import React from 'react'
|
|
2
|
+
import type { ReactNode } from 'react'
|
|
3
|
+
import { createRoot } from 'react-dom/client'
|
|
4
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
5
|
+
import { ReactQueryDevtools } from '@tanstack/react-query-devtools'
|
|
6
|
+
import { BrowserRouter, Routes, Route } from 'react-router-dom'
|
|
7
|
+
import { AuthProvider } from '../features/auth'
|
|
8
|
+
import { SidebarProvider } from '../molecules/layout'
|
|
9
|
+
import { AppLayout } from '../molecules/layout'
|
|
10
|
+
import { DashboardTemplate } from './DashboardTemplate'
|
|
11
|
+
import type { AuthConfig } from '../atoms/types'
|
|
12
|
+
|
|
13
|
+
// App configuration interface
|
|
14
|
+
export interface AppConfig {
|
|
15
|
+
title: string
|
|
16
|
+
description?: string
|
|
17
|
+
version?: string
|
|
18
|
+
enableAuth?: boolean
|
|
19
|
+
enableQuery?: boolean
|
|
20
|
+
enableTheming?: boolean
|
|
21
|
+
enableRouting?: boolean
|
|
22
|
+
apiUrl?: string
|
|
23
|
+
apiTimeout?: number
|
|
24
|
+
theme?: string
|
|
25
|
+
darkMode?: boolean
|
|
26
|
+
auth?: AuthConfig
|
|
27
|
+
customProviders?: React.ComponentType<{ children: ReactNode }>[]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// App instance interface
|
|
31
|
+
export interface AppInstance {
|
|
32
|
+
render: () => ReactNode
|
|
33
|
+
addRoutes: (path: string, component: ReactNode) => void
|
|
34
|
+
mount: (elementId?: string) => void
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// Main app factory function
|
|
38
|
+
export function createReactApp(config: AppConfig | string): AppInstance {
|
|
39
|
+
// Handle simple string config
|
|
40
|
+
const appConfig: AppConfig = typeof config === 'string'
|
|
41
|
+
? { title: config }
|
|
42
|
+
: config
|
|
43
|
+
|
|
44
|
+
// Set defaults
|
|
45
|
+
const {
|
|
46
|
+
title,
|
|
47
|
+
description = `${title} Application`,
|
|
48
|
+
version = '1.0.0',
|
|
49
|
+
enableAuth = true,
|
|
50
|
+
enableQuery = true,
|
|
51
|
+
enableRouting = true,
|
|
52
|
+
auth,
|
|
53
|
+
customProviders = []
|
|
54
|
+
} = appConfig
|
|
55
|
+
|
|
56
|
+
// Initialize query client
|
|
57
|
+
const queryClient = new QueryClient({
|
|
58
|
+
defaultOptions: {
|
|
59
|
+
queries: {
|
|
60
|
+
retry: 1,
|
|
61
|
+
refetchOnWindowFocus: false,
|
|
62
|
+
staleTime: 5 * 60 * 1000, // 5 minutes
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
})
|
|
66
|
+
|
|
67
|
+
// Store routes
|
|
68
|
+
const routes: Array<{ path: string; component: ReactNode }> = []
|
|
69
|
+
|
|
70
|
+
// Default home page
|
|
71
|
+
const DefaultHome = () => (
|
|
72
|
+
<DashboardTemplate title={title} description={description}>
|
|
73
|
+
<div className="flex flex-col items-center justify-center min-h-[400px] text-center">
|
|
74
|
+
<h1 className="text-4xl font-bold text-gray-900 mb-4">🌿 {title}</h1>
|
|
75
|
+
<p className="text-lg text-gray-600 mb-6">{description}</p>
|
|
76
|
+
<div className="space-y-2 text-sm text-gray-500">
|
|
77
|
+
<p>✅ Template integration successful</p>
|
|
78
|
+
<p>🔧 Version: {version}</p>
|
|
79
|
+
<p>🚀 Ready for development</p>
|
|
80
|
+
</div>
|
|
81
|
+
</div>
|
|
82
|
+
</DashboardTemplate>
|
|
83
|
+
)
|
|
84
|
+
|
|
85
|
+
// Build provider tree
|
|
86
|
+
const createProviderTree = (children: ReactNode): ReactNode => {
|
|
87
|
+
let tree = children
|
|
88
|
+
|
|
89
|
+
// Wrap with custom providers (in reverse order)
|
|
90
|
+
customProviders.reverse().forEach((Provider) => {
|
|
91
|
+
tree = <Provider key={Provider.name}>{tree}</Provider>
|
|
92
|
+
})
|
|
93
|
+
|
|
94
|
+
// Wrap with layout providers
|
|
95
|
+
if (enableRouting) {
|
|
96
|
+
tree = (
|
|
97
|
+
<SidebarProvider>
|
|
98
|
+
{tree}
|
|
99
|
+
</SidebarProvider>
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// Wrap with auth provider
|
|
104
|
+
if (enableAuth) {
|
|
105
|
+
tree = <AuthProvider config={auth}>{tree}</AuthProvider>
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// Wrap with query provider
|
|
109
|
+
if (enableQuery) {
|
|
110
|
+
tree = (
|
|
111
|
+
<QueryClientProvider client={queryClient}>
|
|
112
|
+
{tree}
|
|
113
|
+
{import.meta.env.DEV && <ReactQueryDevtools initialIsOpen={false} />}
|
|
114
|
+
</QueryClientProvider>
|
|
115
|
+
)
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// Wrap with router
|
|
119
|
+
if (enableRouting) {
|
|
120
|
+
tree = <BrowserRouter>{tree}</BrowserRouter>
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
return tree
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// Create app instance
|
|
127
|
+
const appInstance: AppInstance = {
|
|
128
|
+
addRoutes(path: string, component: ReactNode) {
|
|
129
|
+
routes.push({ path, component })
|
|
130
|
+
},
|
|
131
|
+
|
|
132
|
+
render() {
|
|
133
|
+
const AppContent = () => (
|
|
134
|
+
<Routes>
|
|
135
|
+
<Route path="/" element={<AppLayout />}>
|
|
136
|
+
<Route index element={<DefaultHome />} />
|
|
137
|
+
{routes.map(({ path, component }, index) => (
|
|
138
|
+
<Route key={index} path={path} element={component} />
|
|
139
|
+
))}
|
|
140
|
+
</Route>
|
|
141
|
+
</Routes>
|
|
142
|
+
)
|
|
143
|
+
|
|
144
|
+
return createProviderTree(<AppContent />)
|
|
145
|
+
},
|
|
146
|
+
|
|
147
|
+
mount(elementId = 'root') {
|
|
148
|
+
const element = document.getElementById(elementId)
|
|
149
|
+
if (!element) {
|
|
150
|
+
throw new Error(`Element with id "${elementId}" not found`)
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
const root = createRoot(element)
|
|
154
|
+
root.render(
|
|
155
|
+
<React.StrictMode>
|
|
156
|
+
{this.render()}
|
|
157
|
+
</React.StrictMode>
|
|
158
|
+
)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return appInstance
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// Convenience function for simple apps
|
|
166
|
+
export function createSimpleApp(title: string): AppInstance {
|
|
167
|
+
return createReactApp({ title })
|
|
168
|
+
}
|
|
169
|
+
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Page templates for common layout patterns
|
|
2
|
+
export { ComponentShowcaseTemplate } from './ComponentShowcaseTemplate';
|
|
3
|
+
export {
|
|
4
|
+
DashboardTemplate,
|
|
5
|
+
DashboardGrid,
|
|
6
|
+
DashboardCard,
|
|
7
|
+
type DashboardTemplateProps,
|
|
8
|
+
type DashboardGridProps,
|
|
9
|
+
type DashboardCardProps
|
|
10
|
+
} from './DashboardTemplate';
|
|
11
|
+
export {
|
|
12
|
+
AuthTemplate,
|
|
13
|
+
AuthFormField,
|
|
14
|
+
AuthLink,
|
|
15
|
+
AuthDivider,
|
|
16
|
+
type AuthTemplateProps,
|
|
17
|
+
type AuthFormFieldProps,
|
|
18
|
+
type AuthLinkProps,
|
|
19
|
+
type AuthDividerProps
|
|
20
|
+
} from './AuthTemplate';
|
|
21
|
+
export {
|
|
22
|
+
DataTemplate,
|
|
23
|
+
DataDetailTemplate,
|
|
24
|
+
type DataTemplateProps,
|
|
25
|
+
type DataDetailTemplateProps
|
|
26
|
+
} from './DataTemplate';
|
|
27
|
+
|
|
28
|
+
// Admin templates for administrative interfaces
|
|
29
|
+
export * from './admin';
|
|
30
|
+
|
|
31
|
+
// React App Factory
|
|
32
|
+
export {
|
|
33
|
+
createReactApp,
|
|
34
|
+
createSimpleApp,
|
|
35
|
+
type AppConfig,
|
|
36
|
+
type AppInstance
|
|
37
|
+
} from './factory';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
/// <reference types="vite/client" />
|