@rakeyshgidwani/roger-ui-bank-theme-stan-design 0.1.4 → 0.1.6
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/CHANGELOG.md +1 -1
- package/dist/index.d.ts +131 -131
- package/dist/index.esm.js +148 -148
- package/dist/index.js +148 -148
- package/dist/styles.css +1 -1
- package/package.json +1 -1
- package/src/components/ui/accessibility-demo.tsx +271 -0
- package/src/components/ui/advanced-component-architecture-demo.tsx +916 -0
- package/src/components/ui/advanced-transition-system-demo.tsx +670 -0
- package/src/components/ui/advanced-transition-system.tsx +395 -0
- package/src/components/ui/animation/animated-container.tsx +166 -0
- package/src/components/ui/animation/index.ts +19 -0
- package/src/components/ui/animation/staggered-container.tsx +68 -0
- package/src/components/ui/animation-demo.tsx +250 -0
- package/src/components/ui/badge.tsx +33 -0
- package/src/components/ui/battery-conscious-animation-demo.tsx +568 -0
- package/src/components/ui/border-radius-shadow-demo.tsx +187 -0
- package/src/components/ui/button.tsx +36 -0
- package/src/components/ui/card.tsx +207 -0
- package/src/components/ui/checkbox.tsx +30 -0
- package/src/components/ui/color-preview.tsx +411 -0
- package/src/components/ui/data-display/chart.tsx +653 -0
- package/src/components/ui/data-display/data-grid-simple.tsx +76 -0
- package/src/components/ui/data-display/data-grid.tsx +680 -0
- package/src/components/ui/data-display/list.tsx +456 -0
- package/src/components/ui/data-display/table.tsx +482 -0
- package/src/components/ui/data-display/timeline.tsx +441 -0
- package/src/components/ui/data-display/tree.tsx +602 -0
- package/src/components/ui/data-display/types.ts +536 -0
- package/src/components/ui/enterprise-mobile-experience-demo.tsx +749 -0
- package/src/components/ui/enterprise-mobile-experience.tsx +464 -0
- package/src/components/ui/feedback/alert.tsx +157 -0
- package/src/components/ui/feedback/progress.tsx +292 -0
- package/src/components/ui/feedback/skeleton.tsx +185 -0
- package/src/components/ui/feedback/toast.tsx +280 -0
- package/src/components/ui/feedback/types.ts +125 -0
- package/src/components/ui/font-preview.tsx +288 -0
- package/src/components/ui/form-demo.tsx +553 -0
- package/src/components/ui/hardware-acceleration-demo.tsx +547 -0
- package/src/components/ui/input.tsx +35 -0
- package/src/components/ui/label.tsx +16 -0
- package/src/components/ui/layout-demo.tsx +367 -0
- package/src/components/ui/layouts/adaptive-layout.tsx +139 -0
- package/src/components/ui/layouts/desktop-layout.tsx +224 -0
- package/src/components/ui/layouts/index.ts +10 -0
- package/src/components/ui/layouts/mobile-layout.tsx +162 -0
- package/src/components/ui/layouts/tablet-layout.tsx +197 -0
- package/src/components/ui/mobile-form-validation.tsx +451 -0
- package/src/components/ui/mobile-input-demo.tsx +201 -0
- package/src/components/ui/mobile-input.tsx +281 -0
- package/src/components/ui/mobile-skeleton-loading-demo.tsx +638 -0
- package/src/components/ui/navigation/breadcrumb.tsx +158 -0
- package/src/components/ui/navigation/index.ts +36 -0
- package/src/components/ui/navigation/menu.tsx +374 -0
- package/src/components/ui/navigation/navigation-demo.tsx +324 -0
- package/src/components/ui/navigation/pagination.tsx +272 -0
- package/src/components/ui/navigation/sidebar.tsx +383 -0
- package/src/components/ui/navigation/stepper.tsx +303 -0
- package/src/components/ui/navigation/tabs.tsx +205 -0
- package/src/components/ui/navigation/types.ts +299 -0
- package/src/components/ui/overlay/backdrop.tsx +81 -0
- package/src/components/ui/overlay/focus-manager.tsx +143 -0
- package/src/components/ui/overlay/index.ts +36 -0
- package/src/components/ui/overlay/modal.tsx +270 -0
- package/src/components/ui/overlay/overlay-manager.tsx +110 -0
- package/src/components/ui/overlay/popover.tsx +462 -0
- package/src/components/ui/overlay/portal.tsx +79 -0
- package/src/components/ui/overlay/tooltip.tsx +303 -0
- package/src/components/ui/overlay/types.ts +196 -0
- package/src/components/ui/performance-demo.tsx +596 -0
- package/src/components/ui/semantic-input-system-demo.tsx +502 -0
- package/src/components/ui/semantic-input-system-demo.tsx.disabled +873 -0
- package/src/components/ui/tablet-layout.tsx +192 -0
- package/src/components/ui/theme-customizer.tsx +386 -0
- package/src/components/ui/theme-preview.tsx +310 -0
- package/src/components/ui/theme-switcher.tsx +264 -0
- package/src/components/ui/theme-toggle.tsx +38 -0
- package/src/components/ui/token-demo.tsx +195 -0
- package/src/components/ui/touch-demo.tsx +462 -0
- package/src/components/ui/touch-friendly-interface-demo.tsx +519 -0
- package/src/components/ui/touch-friendly-interface.tsx +296 -0
- package/src/hooks/index.ts +190 -0
- package/src/hooks/use-accessibility-support.ts +518 -0
- package/src/hooks/use-adaptive-layout.ts +289 -0
- package/src/hooks/use-advanced-patterns.ts +294 -0
- package/src/hooks/use-advanced-transition-system.ts +393 -0
- package/src/hooks/use-animation-profile.ts +288 -0
- package/src/hooks/use-battery-animations.ts +384 -0
- package/src/hooks/use-battery-conscious-loading.ts +475 -0
- package/src/hooks/use-battery-optimization.ts +330 -0
- package/src/hooks/use-battery-status.ts +299 -0
- package/src/hooks/use-component-performance.ts +344 -0
- package/src/hooks/use-device-loading-states.ts +459 -0
- package/src/hooks/use-device.tsx +110 -0
- package/src/hooks/use-enterprise-mobile-experience.ts +488 -0
- package/src/hooks/use-form-feedback.ts +403 -0
- package/src/hooks/use-form-performance.ts +513 -0
- package/src/hooks/use-frame-rate.ts +251 -0
- package/src/hooks/use-gestures.ts +338 -0
- package/src/hooks/use-hardware-acceleration.ts +341 -0
- package/src/hooks/use-input-accessibility.ts +455 -0
- package/src/hooks/use-input-performance.ts +506 -0
- package/src/hooks/use-layout-performance.ts +319 -0
- package/src/hooks/use-loading-accessibility.ts +535 -0
- package/src/hooks/use-loading-performance.ts +473 -0
- package/src/hooks/use-memory-usage.ts +287 -0
- package/src/hooks/use-mobile-form-layout.ts +464 -0
- package/src/hooks/use-mobile-form-validation.ts +518 -0
- package/src/hooks/use-mobile-keyboard-optimization.ts +472 -0
- package/src/hooks/use-mobile-layout.ts +302 -0
- package/src/hooks/use-mobile-optimization.ts +406 -0
- package/src/hooks/use-mobile-skeleton.ts +402 -0
- package/src/hooks/use-mobile-touch.ts +414 -0
- package/src/hooks/use-performance-throttling.ts +348 -0
- package/src/hooks/use-performance.ts +316 -0
- package/src/hooks/use-reusable-architecture.ts +414 -0
- package/src/hooks/use-semantic-input-types.ts +357 -0
- package/src/hooks/use-semantic-input.ts +565 -0
- package/src/hooks/use-tablet-layout.ts +384 -0
- package/src/hooks/use-touch-friendly-input.ts +524 -0
- package/src/hooks/use-touch-friendly-interface.ts +331 -0
- package/src/hooks/use-touch-optimization.ts +375 -0
- package/src/index.ts +279 -279
- package/src/lib/utils.ts +6 -0
- package/src/themes/README.md +272 -0
- package/src/themes/ThemeContext.tsx +31 -0
- package/src/themes/ThemeProvider.tsx +232 -0
- package/src/themes/accessibility/index.ts +27 -0
- package/src/themes/accessibility.ts +259 -0
- package/src/themes/aria-patterns.ts +420 -0
- package/src/themes/base-themes.ts +55 -0
- package/src/themes/colorManager.ts +380 -0
- package/src/themes/examples/dark-theme.ts +154 -0
- package/src/themes/examples/minimal-theme.ts +108 -0
- package/src/themes/focus-management.ts +701 -0
- package/src/themes/fontLoader.ts +201 -0
- package/src/themes/high-contrast.ts +621 -0
- package/src/themes/index.ts +19 -0
- package/src/themes/inheritance.ts +227 -0
- package/src/themes/keyboard-navigation.ts +550 -0
- package/src/themes/motion-reduction.ts +662 -0
- package/src/themes/navigation.ts +238 -0
- package/src/themes/screen-reader.ts +645 -0
- package/src/themes/systemThemeDetector.ts +182 -0
- package/src/themes/themeCSSUpdater.ts +262 -0
- package/src/themes/themePersistence.ts +238 -0
- package/src/themes/themes/default.ts +586 -0
- package/src/themes/themes/harvey.ts +554 -0
- package/src/themes/themes/stan-design.ts +683 -0
- package/src/themes/types.ts +460 -0
- package/src/themes/useSystemTheme.ts +48 -0
- package/src/themes/useTheme.ts +87 -0
- package/src/themes/validation.ts +462 -0
- package/src/tokens/index.ts +34 -0
- package/src/tokens/tokenExporter.ts +397 -0
- package/src/tokens/tokenGenerator.ts +276 -0
- package/src/tokens/tokenManager.ts +248 -0
- package/src/tokens/tokenValidator.ts +543 -0
- package/src/tokens/types.ts +78 -0
- package/src/utils/bundle-analyzer.ts +260 -0
- package/src/utils/bundle-splitting.ts +483 -0
- package/src/utils/lazy-loading.ts +441 -0
- package/src/utils/performance-monitor.ts +513 -0
- package/src/utils/tree-shaking.ts +274 -0
|
@@ -0,0 +1,414 @@
|
|
|
1
|
+
import { useState, useCallback, useEffect, ComponentType, CSSProperties } from 'react'
|
|
2
|
+
|
|
3
|
+
export interface ReusableArchitectureConfig {
|
|
4
|
+
enableComponentComposition?: boolean
|
|
5
|
+
enablePatternSharing?: boolean
|
|
6
|
+
enableStyleSharing?: boolean
|
|
7
|
+
enableBehaviorSharing?: boolean
|
|
8
|
+
enableTemplateSystem?: boolean
|
|
9
|
+
enableComponentRegistry?: boolean
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface ComponentTemplate {
|
|
13
|
+
id: string
|
|
14
|
+
name: string
|
|
15
|
+
component: ComponentType<any>
|
|
16
|
+
props: Record<string, any>
|
|
17
|
+
styles: CSSProperties
|
|
18
|
+
behaviors: string[]
|
|
19
|
+
patterns: string[]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export interface SharedPattern {
|
|
23
|
+
id: string
|
|
24
|
+
name: string
|
|
25
|
+
description: string
|
|
26
|
+
implementation: string
|
|
27
|
+
usage: string[]
|
|
28
|
+
category: 'composition' | 'styling' | 'behavior' | 'performance'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface SharedStyle {
|
|
32
|
+
id: string
|
|
33
|
+
name: string
|
|
34
|
+
css: string
|
|
35
|
+
variables: Record<string, string>
|
|
36
|
+
breakpoints: Record<string, string>
|
|
37
|
+
usage: string[]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface SharedBehavior {
|
|
41
|
+
id: string
|
|
42
|
+
name: string
|
|
43
|
+
description: string
|
|
44
|
+
hook: string
|
|
45
|
+
dependencies: string[]
|
|
46
|
+
usage: string[]
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export interface ReusableArchitectureCallbacks {
|
|
50
|
+
onTemplateCreated?: (template: ComponentTemplate) => void
|
|
51
|
+
onPatternShared?: (pattern: SharedPattern) => void
|
|
52
|
+
onStyleShared?: (style: SharedStyle) => void
|
|
53
|
+
onBehaviorShared?: (behavior: SharedBehavior) => void
|
|
54
|
+
onArchitectureOptimized?: (optimization: string) => void
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export const useReusableArchitecture = (
|
|
58
|
+
config: ReusableArchitectureConfig = {},
|
|
59
|
+
callbacks: ReusableArchitectureCallbacks = {}
|
|
60
|
+
) => {
|
|
61
|
+
const {
|
|
62
|
+
enableComponentComposition = true,
|
|
63
|
+
enablePatternSharing = true,
|
|
64
|
+
enableStyleSharing = true,
|
|
65
|
+
enableBehaviorSharing = true,
|
|
66
|
+
enableTemplateSystem = true,
|
|
67
|
+
enableComponentRegistry = true
|
|
68
|
+
} = config
|
|
69
|
+
|
|
70
|
+
const [templates, setTemplates] = useState<Map<string, ComponentTemplate>>(new Map())
|
|
71
|
+
const [sharedPatterns, setSharedPatterns] = useState<Map<string, SharedPattern>>(new Map())
|
|
72
|
+
const [sharedStyles, setSharedStyles] = useState<Map<string, SharedStyle>>(new Map())
|
|
73
|
+
const [sharedBehaviors, setSharedBehaviors] = useState<Map<string, SharedBehavior>>(new Map())
|
|
74
|
+
const [isOptimizing, setIsOptimizing] = useState(false)
|
|
75
|
+
const [optimizations, setOptimizations] = useState<string[]>([])
|
|
76
|
+
|
|
77
|
+
// Component composition
|
|
78
|
+
const composeComponent = useCallback((
|
|
79
|
+
baseComponent: ComponentType<any>,
|
|
80
|
+
enhancements: Array<(Component: ComponentType<any>) => ComponentType<any>>
|
|
81
|
+
) => {
|
|
82
|
+
if (!enableComponentComposition) return baseComponent
|
|
83
|
+
|
|
84
|
+
let composedComponent = baseComponent
|
|
85
|
+
|
|
86
|
+
enhancements.forEach(enhancement => {
|
|
87
|
+
composedComponent = enhancement(composedComponent)
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
const optimization = `Component composition applied with ${enhancements.length} enhancements`
|
|
91
|
+
setOptimizations(prev => [...prev, optimization])
|
|
92
|
+
callbacks.onArchitectureOptimized?.(optimization)
|
|
93
|
+
|
|
94
|
+
return composedComponent
|
|
95
|
+
}, [enableComponentComposition, callbacks])
|
|
96
|
+
|
|
97
|
+
// Template system
|
|
98
|
+
const createTemplate = useCallback((
|
|
99
|
+
template: Omit<ComponentTemplate, 'id'>
|
|
100
|
+
) => {
|
|
101
|
+
if (!enableTemplateSystem) return null
|
|
102
|
+
|
|
103
|
+
const id = `template-${Date.now()}`
|
|
104
|
+
const newTemplate: ComponentTemplate = {
|
|
105
|
+
...template,
|
|
106
|
+
id
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
templates.set(id, newTemplate)
|
|
110
|
+
setTemplates(new Map(templates))
|
|
111
|
+
|
|
112
|
+
callbacks.onTemplateCreated?.(newTemplate)
|
|
113
|
+
|
|
114
|
+
return id
|
|
115
|
+
}, [enableTemplateSystem, templates, callbacks])
|
|
116
|
+
|
|
117
|
+
const getTemplate = useCallback((id: string) => {
|
|
118
|
+
return templates.get(id)
|
|
119
|
+
}, [templates])
|
|
120
|
+
|
|
121
|
+
const updateTemplate = useCallback((
|
|
122
|
+
id: string,
|
|
123
|
+
updates: Partial<ComponentTemplate>
|
|
124
|
+
) => {
|
|
125
|
+
const template = templates.get(id)
|
|
126
|
+
if (!template) return false
|
|
127
|
+
|
|
128
|
+
const updatedTemplate = { ...template, ...updates }
|
|
129
|
+
templates.set(id, updatedTemplate)
|
|
130
|
+
setTemplates(new Map(templates))
|
|
131
|
+
|
|
132
|
+
return true
|
|
133
|
+
}, [templates])
|
|
134
|
+
|
|
135
|
+
const deleteTemplate = useCallback((id: string) => {
|
|
136
|
+
const deleted = templates.delete(id)
|
|
137
|
+
if (deleted) {
|
|
138
|
+
setTemplates(new Map(templates))
|
|
139
|
+
}
|
|
140
|
+
return deleted
|
|
141
|
+
}, [templates])
|
|
142
|
+
|
|
143
|
+
// Pattern sharing
|
|
144
|
+
const sharePattern = useCallback((
|
|
145
|
+
pattern: Omit<SharedPattern, 'id'>
|
|
146
|
+
) => {
|
|
147
|
+
if (!enablePatternSharing) return null
|
|
148
|
+
|
|
149
|
+
const id = `pattern-${Date.now()}`
|
|
150
|
+
const newPattern: SharedPattern = {
|
|
151
|
+
...pattern,
|
|
152
|
+
id
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
sharedPatterns.set(id, newPattern)
|
|
156
|
+
setSharedPatterns(new Map(sharedPatterns))
|
|
157
|
+
|
|
158
|
+
callbacks.onPatternShared?.(newPattern)
|
|
159
|
+
|
|
160
|
+
return id
|
|
161
|
+
}, [enablePatternSharing, sharedPatterns, callbacks])
|
|
162
|
+
|
|
163
|
+
const getPattern = useCallback((id: string) => {
|
|
164
|
+
return sharedPatterns.get(id)
|
|
165
|
+
}, [sharedPatterns])
|
|
166
|
+
|
|
167
|
+
const findPatternsByCategory = useCallback((category: string) => {
|
|
168
|
+
return Array.from(sharedPatterns.values()).filter(pattern => pattern.category === category)
|
|
169
|
+
}, [sharedPatterns])
|
|
170
|
+
|
|
171
|
+
// Style sharing
|
|
172
|
+
const shareStyle = useCallback((
|
|
173
|
+
style: Omit<SharedStyle, 'id'>
|
|
174
|
+
) => {
|
|
175
|
+
if (!enableStyleSharing) return null
|
|
176
|
+
|
|
177
|
+
const id = `style-${Date.now()}`
|
|
178
|
+
const newStyle: SharedStyle = {
|
|
179
|
+
...style,
|
|
180
|
+
id
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
sharedStyles.set(id, newStyle)
|
|
184
|
+
setSharedStyles(new Map(sharedStyles))
|
|
185
|
+
|
|
186
|
+
callbacks.onStyleShared?.(newStyle)
|
|
187
|
+
|
|
188
|
+
return id
|
|
189
|
+
}, [enableStyleSharing, sharedStyles, callbacks])
|
|
190
|
+
|
|
191
|
+
const getStyle = useCallback((id: string) => {
|
|
192
|
+
return sharedStyles.get(id)
|
|
193
|
+
}, [sharedStyles])
|
|
194
|
+
|
|
195
|
+
const applyStyle = useCallback((
|
|
196
|
+
styleId: string,
|
|
197
|
+
targetComponent: string
|
|
198
|
+
) => {
|
|
199
|
+
const style = sharedStyles.get(styleId)
|
|
200
|
+
if (!style) return false
|
|
201
|
+
|
|
202
|
+
// Update style usage
|
|
203
|
+
if (!style.usage.includes(targetComponent)) {
|
|
204
|
+
style.usage.push(targetComponent)
|
|
205
|
+
sharedStyles.set(styleId, style)
|
|
206
|
+
setSharedStyles(new Map(sharedStyles))
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
return true
|
|
210
|
+
}, [sharedStyles])
|
|
211
|
+
|
|
212
|
+
// Behavior sharing
|
|
213
|
+
const shareBehavior = useCallback((
|
|
214
|
+
behavior: Omit<SharedBehavior, 'id'>
|
|
215
|
+
) => {
|
|
216
|
+
if (!enableBehaviorSharing) return null
|
|
217
|
+
|
|
218
|
+
const id = `behavior-${Date.now()}`
|
|
219
|
+
const newBehavior: SharedBehavior = {
|
|
220
|
+
...behavior,
|
|
221
|
+
id
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
sharedBehaviors.set(id, newBehavior)
|
|
225
|
+
setSharedBehaviors(new Map(sharedBehaviors))
|
|
226
|
+
|
|
227
|
+
callbacks.onBehaviorShared?.(newBehavior)
|
|
228
|
+
|
|
229
|
+
return id
|
|
230
|
+
}, [enableBehaviorSharing, sharedBehaviors, callbacks])
|
|
231
|
+
|
|
232
|
+
const getBehavior = useCallback((id: string) => {
|
|
233
|
+
return sharedBehaviors.get(id)
|
|
234
|
+
}, [sharedBehaviors])
|
|
235
|
+
|
|
236
|
+
const applyBehavior = useCallback((
|
|
237
|
+
behaviorId: string,
|
|
238
|
+
targetComponent: string
|
|
239
|
+
) => {
|
|
240
|
+
const behavior = sharedBehaviors.get(behaviorId)
|
|
241
|
+
if (!behavior) return false
|
|
242
|
+
|
|
243
|
+
// Update behavior usage
|
|
244
|
+
if (!behavior.usage.includes(targetComponent)) {
|
|
245
|
+
behavior.usage.push(targetComponent)
|
|
246
|
+
sharedBehaviors.set(behaviorId, behavior)
|
|
247
|
+
setSharedBehaviors(new Map(sharedBehaviors))
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
return true
|
|
251
|
+
}, [sharedBehaviors])
|
|
252
|
+
|
|
253
|
+
// Component registry
|
|
254
|
+
const registerComponent = useCallback((
|
|
255
|
+
id: string,
|
|
256
|
+
component: ComponentType<any>,
|
|
257
|
+
metadata: {
|
|
258
|
+
name: string
|
|
259
|
+
description: string
|
|
260
|
+
category: string
|
|
261
|
+
tags: string[]
|
|
262
|
+
}
|
|
263
|
+
) => {
|
|
264
|
+
if (!enableComponentRegistry) return false
|
|
265
|
+
|
|
266
|
+
const template: ComponentTemplate = {
|
|
267
|
+
id,
|
|
268
|
+
name: metadata.name,
|
|
269
|
+
component,
|
|
270
|
+
props: {},
|
|
271
|
+
styles: {},
|
|
272
|
+
behaviors: [],
|
|
273
|
+
patterns: []
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
templates.set(id, template)
|
|
277
|
+
setTemplates(new Map(templates))
|
|
278
|
+
|
|
279
|
+
return true
|
|
280
|
+
}, [enableComponentRegistry, templates])
|
|
281
|
+
|
|
282
|
+
// Architecture analysis
|
|
283
|
+
const analyzeArchitecture = useCallback(() => {
|
|
284
|
+
const analysis = {
|
|
285
|
+
totalTemplates: templates.size,
|
|
286
|
+
totalPatterns: sharedPatterns.size,
|
|
287
|
+
totalStyles: sharedStyles.size,
|
|
288
|
+
totalBehaviors: sharedBehaviors.size,
|
|
289
|
+
compositionLevel: 'none' as 'none' | 'basic' | 'intermediate' | 'advanced',
|
|
290
|
+
reusabilityScore: 0,
|
|
291
|
+
recommendations: [] as string[]
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
// Calculate composition level
|
|
295
|
+
if (templates.size > 10) {
|
|
296
|
+
analysis.compositionLevel = 'advanced'
|
|
297
|
+
} else if (templates.size > 5) {
|
|
298
|
+
analysis.compositionLevel = 'intermediate'
|
|
299
|
+
} else if (templates.size > 0) {
|
|
300
|
+
analysis.compositionLevel = 'basic'
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
// Calculate reusability score
|
|
304
|
+
const totalUsage = Array.from(sharedStyles.values()).reduce((sum, style) => sum + style.usage.length, 0) +
|
|
305
|
+
Array.from(sharedBehaviors.values()).reduce((sum, behavior) => sum + behavior.usage.length, 0)
|
|
306
|
+
|
|
307
|
+
analysis.reusabilityScore = Math.min(100, (totalUsage / Math.max(1, sharedStyles.size + sharedBehaviors.size)) * 20)
|
|
308
|
+
|
|
309
|
+
// Generate recommendations
|
|
310
|
+
if (templates.size === 0) {
|
|
311
|
+
analysis.recommendations.push('Create component templates for reusable components')
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
if (sharedPatterns.size === 0) {
|
|
315
|
+
analysis.recommendations.push('Share common patterns for consistency')
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
if (sharedStyles.size === 0) {
|
|
319
|
+
analysis.recommendations.push('Create shared style systems')
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
if (sharedBehaviors.size === 0) {
|
|
323
|
+
analysis.recommendations.push('Share common behaviors and hooks')
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if (analysis.reusabilityScore < 50) {
|
|
327
|
+
analysis.recommendations.push('Increase component reusability through better composition')
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
return analysis
|
|
331
|
+
}, [templates, sharedPatterns, sharedStyles, sharedBehaviors])
|
|
332
|
+
|
|
333
|
+
// Architecture optimization
|
|
334
|
+
const optimizeArchitecture = useCallback(() => {
|
|
335
|
+
setIsOptimizing(true)
|
|
336
|
+
|
|
337
|
+
setTimeout(() => {
|
|
338
|
+
const architectureOptimizations = [
|
|
339
|
+
'Component composition patterns optimized',
|
|
340
|
+
'Pattern sharing system enhanced',
|
|
341
|
+
'Style sharing architecture improved',
|
|
342
|
+
'Behavior sharing system optimized',
|
|
343
|
+
'Template system performance enhanced'
|
|
344
|
+
]
|
|
345
|
+
|
|
346
|
+
setOptimizations(prev => [...prev, ...architectureOptimizations])
|
|
347
|
+
setIsOptimizing(false)
|
|
348
|
+
|
|
349
|
+
architectureOptimizations.forEach(optimization => {
|
|
350
|
+
callbacks.onArchitectureOptimized?.(optimization)
|
|
351
|
+
})
|
|
352
|
+
}, 400)
|
|
353
|
+
}, [callbacks])
|
|
354
|
+
|
|
355
|
+
// Cleanup on unmount
|
|
356
|
+
useEffect(() => {
|
|
357
|
+
return () => {
|
|
358
|
+
templates.clear()
|
|
359
|
+
sharedPatterns.clear()
|
|
360
|
+
sharedStyles.clear()
|
|
361
|
+
sharedBehaviors.clear()
|
|
362
|
+
}
|
|
363
|
+
}, [templates, sharedPatterns, sharedStyles, sharedBehaviors])
|
|
364
|
+
|
|
365
|
+
return {
|
|
366
|
+
// State
|
|
367
|
+
templates: Array.from(templates.values()),
|
|
368
|
+
sharedPatterns: Array.from(sharedPatterns.values()),
|
|
369
|
+
sharedStyles: Array.from(sharedStyles.values()),
|
|
370
|
+
sharedBehaviors: Array.from(sharedBehaviors.values()),
|
|
371
|
+
isOptimizing,
|
|
372
|
+
optimizations,
|
|
373
|
+
|
|
374
|
+
// Component composition
|
|
375
|
+
composeComponent,
|
|
376
|
+
|
|
377
|
+
// Template system
|
|
378
|
+
createTemplate,
|
|
379
|
+
getTemplate,
|
|
380
|
+
updateTemplate,
|
|
381
|
+
deleteTemplate,
|
|
382
|
+
|
|
383
|
+
// Pattern sharing
|
|
384
|
+
sharePattern,
|
|
385
|
+
getPattern,
|
|
386
|
+
findPatternsByCategory,
|
|
387
|
+
|
|
388
|
+
// Style sharing
|
|
389
|
+
shareStyle,
|
|
390
|
+
getStyle,
|
|
391
|
+
applyStyle,
|
|
392
|
+
|
|
393
|
+
// Behavior sharing
|
|
394
|
+
shareBehavior,
|
|
395
|
+
getBehavior,
|
|
396
|
+
applyBehavior,
|
|
397
|
+
|
|
398
|
+
// Component registry
|
|
399
|
+
registerComponent,
|
|
400
|
+
|
|
401
|
+
// Analysis and optimization
|
|
402
|
+
analyzeArchitecture,
|
|
403
|
+
optimizeArchitecture,
|
|
404
|
+
|
|
405
|
+
// Utility functions
|
|
406
|
+
hasTemplate: (id: string) => templates.has(id),
|
|
407
|
+
hasPattern: (id: string) => sharedPatterns.has(id),
|
|
408
|
+
hasStyle: (id: string) => sharedStyles.has(id),
|
|
409
|
+
hasBehavior: (id: string) => sharedBehaviors.has(id),
|
|
410
|
+
clearOptimizations: () => setOptimizations([])
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
export default useReusableArchitecture
|