@hai3/react 0.3.0-alpha.0 → 0.4.0-alpha.1

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["/**\n * @hai3/react - Type Definitions\n *\n * Core types for HAI3 React bindings.\n * Provides type-safe hooks and components.\n *\n * Now using real imports from @hai3/framework since packages are built together.\n */\n\nimport type { ReactNode } from 'react';\nimport type {\n HAI3Config,\n HAI3App,\n RootState,\n Language,\n LanguageMetadata,\n MenuItemConfig,\n ScreensetDefinition,\n ScreensetCategory,\n} from '@hai3/framework';\n\n// Re-export imported types for convenience\nexport type { HAI3Config, HAI3App, MenuItemConfig, ScreensetDefinition, ScreensetCategory };\n\n// ============================================================================\n// Type Aliases\n// ============================================================================\n\n// From @hai3/store\ntype Selector<TResult, TState = RootState> = (state: TState) => TResult;\n\n// Language is imported from @hai3/framework\ntype TranslationParams = Record<string, string | number | boolean>;\n\n// ============================================================================\n// HAI3 Provider Props\n// ============================================================================\n\n/**\n * Router configuration type\n */\nexport type RouterType = 'browser' | 'hash' | 'memory';\n\n/**\n * Router configuration\n */\nexport interface RouterConfig {\n /** Router type - browser (default), hash, or memory */\n type?: RouterType;\n /** Auto-navigate to first screen on load (default: true) */\n autoNavigate?: boolean;\n}\n\n/**\n * HAI3 Provider Props\n * Props for the main HAI3Provider component.\n *\n * @example\n * ```tsx\n * <HAI3Provider config={{ devMode: true }}>\n * <App />\n * </HAI3Provider>\n *\n * // With router configuration\n * <HAI3Provider router={{ type: 'hash' }}>\n * <App />\n * </HAI3Provider>\n * ```\n */\nexport interface HAI3ProviderProps {\n /** Child components */\n children: ReactNode;\n /** HAI3 configuration */\n config?: HAI3Config;\n /** Pre-built HAI3 app instance (optional) */\n app?: HAI3App;\n /** Router configuration */\n router?: RouterConfig;\n}\n\n// ============================================================================\n// Hook Return Types\n// ============================================================================\n\n/**\n * useHAI3 Hook Return Type\n * Returns the HAI3 app instance from context.\n */\nexport type UseHAI3Return = HAI3App;\n\n/**\n * useAppSelector Hook\n * Type-safe selector hook for Redux state.\n *\n * @template TResult - The result type of the selector\n */\nexport type UseAppSelector = <TResult>(selector: Selector<TResult>) => TResult;\n\n/**\n * useAppDispatch Hook Return Type\n * Returns the typed dispatch function.\n */\nexport type UseAppDispatchReturn = (action: unknown) => unknown;\n\n/**\n * useTranslation Hook Return Type\n * Translation utilities.\n */\nexport interface UseTranslationReturn {\n /** Translate a key */\n t: (key: string, params?: TranslationParams) => string;\n /** Current language */\n language: Language | null;\n /** Change language */\n setLanguage: (language: Language) => Promise<void>;\n /** Check if current language is RTL */\n isRTL: boolean;\n}\n\n/**\n * useScreenTranslations Hook Return Type\n * Screen-level translation loading state.\n */\nexport interface UseScreenTranslationsReturn {\n /** Whether translations are loaded */\n isLoaded: boolean;\n /** Loading error (if any) */\n error: Error | null;\n}\n\n/**\n * useLanguage Hook Return Type\n * Language selection utilities.\n */\nexport interface UseLanguageReturn {\n /** Current language */\n current: Language | null;\n /** All supported languages */\n supported: LanguageMetadata[];\n /** Change language */\n setLanguage: (language: Language) => Promise<void>;\n /** Check if current language is RTL */\n isRTL: boolean;\n}\n\n/**\n * useTheme Hook Return Type\n * Theme utilities.\n */\nexport interface UseThemeReturn {\n /** Current theme ID */\n currentTheme: string | undefined;\n /** All available themes */\n themes: Array<{ id: string; name: string }>;\n /** Change theme */\n setTheme: (themeId: string) => void;\n}\n\n/**\n * useMenu Hook Return Type\n * Menu state and actions.\n */\nexport interface UseMenuReturn {\n /** Menu items */\n items: MenuItemConfig[];\n /** Whether menu is collapsed */\n collapsed: boolean;\n /** Whether menu is visible */\n visible: boolean;\n /** Toggle menu collapse */\n toggle: () => void;\n /** Set collapsed state */\n setCollapsed: (collapsed: boolean) => void;\n}\n\n/**\n * useScreen Hook Return Type\n * Current screen state.\n */\nexport interface UseScreenReturn {\n /** Active screen ID */\n activeScreen: string | null;\n /** Whether screen is loading */\n isLoading: boolean;\n}\n\n/**\n * useNavigation Hook Return Type\n * Navigation utilities.\n */\nexport interface UseNavigationReturn {\n /** Navigate to a screen, optionally with route params */\n navigateToScreen: (screensetId: string, screenId: string, params?: Record<string, string>) => void;\n /** Navigate to a screenset (uses default screen) */\n navigateToScreenset: (screensetId: string) => void;\n /** Current screenset ID */\n currentScreenset: string | null;\n /** Current screen ID */\n currentScreen: string | null;\n}\n\n/**\n * useScreenset Hook Return Type\n * Current screenset state.\n */\nexport interface UseScreensetReturn {\n /** Current screenset */\n screenset: ScreensetDefinition | undefined;\n /** Current screenset ID */\n screensetId: string | null;\n /** Current category */\n category: ScreensetCategory | null;\n}\n\n/**\n * usePopup Hook Return Type\n * Popup utilities.\n */\nexport interface UsePopupReturn {\n /** Show a popup */\n show: (config: { id: string; title?: string; content?: () => Promise<{ default: React.ComponentType }> }) => void;\n /** Hide current popup */\n hide: () => void;\n /** Hide all popups */\n hideAll: () => void;\n /** Whether any popup is open */\n isOpen: boolean;\n /** Current popup stack */\n stack: Array<{ id: string; title?: string }>;\n}\n\n/**\n * useOverlay Hook Return Type\n * Overlay utilities.\n */\nexport interface UseOverlayReturn {\n /** Show an overlay */\n show: (config: { id: string; content?: () => Promise<{ default: React.ComponentType }> }) => void;\n /** Hide current overlay */\n hide: () => void;\n /** Whether any overlay is open */\n isOpen: boolean;\n}\n\n// ============================================================================\n// App Router Props\n// ============================================================================\n\n/**\n * App Router Props\n * Props for the AppRouter component.\n */\nexport interface AppRouterProps {\n /** Fallback component while loading */\n fallback?: ReactNode;\n /** Error boundary fallback */\n errorFallback?: ReactNode | ((error: Error) => ReactNode);\n}\n\n// ============================================================================\n// Component Types\n// ============================================================================\n\n/**\n * HAI3Provider Component Type\n */\nexport type HAI3ProviderComponent = React.FC<HAI3ProviderProps>;\n\n/**\n * AppRouter Component Type\n */\nexport type AppRouterComponent = React.FC<AppRouterProps>;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["/**\n * @hai3/react - Type Definitions\n *\n * Core types for HAI3 React bindings.\n * Provides type-safe hooks and components.\n *\n * Now using real imports from @hai3/framework since packages are built together.\n */\n\nimport type { ReactNode } from 'react';\nimport type {\n HAI3Config,\n HAI3App,\n RootState,\n Language,\n Formatters,\n} from '@hai3/framework';\nimport type { MfeContextValue } from './mfe/MfeContext';\n\n// Re-export imported types for convenience\nexport type { HAI3Config, HAI3App };\n\n// ============================================================================\n// Type Aliases\n// ============================================================================\n\n// From @hai3/store\ntype Selector<TResult, TState = RootState> = (state: TState) => TResult;\n\n// Language is imported from @hai3/framework\ntype TranslationParams = Record<string, string | number | boolean>;\n\n// ============================================================================\n// HAI3 Provider Props\n// ============================================================================\n\n/**\n * HAI3 Provider Props\n * Props for the main HAI3Provider component.\n *\n * @example\n * ```tsx\n * <HAI3Provider config={{ devMode: true }}>\n * <App />\n * </HAI3Provider>\n *\n * // With pre-built app\n * const app = createHAI3().use(screensets()).use(microfrontends()).build();\n * <HAI3Provider app={app}>\n * <App />\n * </HAI3Provider>\n *\n * // With MFE bridge (for MFE components)\n * <HAI3Provider mfeBridge={{ bridge, extensionId, domainId }}>\n * <MyMfeApp />\n * </HAI3Provider>\n * ```\n */\nexport interface HAI3ProviderProps {\n /** Child components */\n children: ReactNode;\n /** HAI3 configuration */\n config?: HAI3Config;\n /** Pre-built HAI3 app instance (optional) */\n app?: HAI3App;\n /** MFE bridge context (for MFE components) */\n mfeBridge?: MfeContextValue;\n}\n\n// ============================================================================\n// Hook Return Types\n// ============================================================================\n\n/**\n * useHAI3 Hook Return Type\n * Returns the HAI3 app instance from context.\n */\nexport type UseHAI3Return = HAI3App;\n\n/**\n * useAppSelector Hook\n * Type-safe selector hook for Redux state.\n *\n * @template TResult - The result type of the selector\n */\nexport type UseAppSelector = <TResult>(selector: Selector<TResult>) => TResult;\n\n/**\n * useAppDispatch Hook Return Type\n * Returns the typed dispatch function.\n */\nexport type UseAppDispatchReturn = (action: unknown) => unknown;\n\n/**\n * useTranslation Hook Return Type\n * Translation utilities.\n */\nexport interface UseTranslationReturn {\n /** Translate a key */\n t: (key: string, params?: TranslationParams) => string;\n /** Current language */\n language: Language | null;\n /** Change language */\n setLanguage: (language: Language) => void;\n /** Check if current language is RTL */\n isRTL: boolean;\n}\n\n/**\n * useScreenTranslations Hook Return Type\n * Screen-level translation loading state.\n */\nexport interface UseScreenTranslationsReturn {\n /** Whether translations are loaded */\n isLoaded: boolean;\n /** Loading error (if any) */\n error: Error | null;\n}\n\n/**\n * useTheme Hook Return Type\n * Theme utilities.\n */\nexport interface UseThemeReturn {\n /** Current theme ID */\n currentTheme: string | undefined;\n /** All available themes */\n themes: Array<{ id: string; name: string }>;\n /** Change theme */\n setTheme: (themeId: string) => void;\n}\n\n/**\n * useFormatters Hook Return Type\n * Locale-aware formatters (locale from i18nRegistry.getLanguage()).\n * References @hai3/i18n Formatters so signatures stay in sync.\n */\nexport type UseFormattersReturn = Formatters;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
package/dist/types.d.cts CHANGED
@@ -1,238 +1,3 @@
1
- import { ReactNode } from 'react';
2
- import { HAI3Config, HAI3App, RootState, Language, LanguageMetadata, MenuItemConfig, ScreensetDefinition, ScreensetCategory } from '@hai3/framework';
3
- export { HAI3App, HAI3Config, MenuItemConfig, ScreensetCategory, ScreensetDefinition } from '@hai3/framework';
4
-
5
- /**
6
- * @hai3/react - Type Definitions
7
- *
8
- * Core types for HAI3 React bindings.
9
- * Provides type-safe hooks and components.
10
- *
11
- * Now using real imports from @hai3/framework since packages are built together.
12
- */
13
-
14
- type Selector<TResult, TState = RootState> = (state: TState) => TResult;
15
- type TranslationParams = Record<string, string | number | boolean>;
16
- /**
17
- * Router configuration type
18
- */
19
- type RouterType = 'browser' | 'hash' | 'memory';
20
- /**
21
- * Router configuration
22
- */
23
- interface RouterConfig {
24
- /** Router type - browser (default), hash, or memory */
25
- type?: RouterType;
26
- /** Auto-navigate to first screen on load (default: true) */
27
- autoNavigate?: boolean;
28
- }
29
- /**
30
- * HAI3 Provider Props
31
- * Props for the main HAI3Provider component.
32
- *
33
- * @example
34
- * ```tsx
35
- * <HAI3Provider config={{ devMode: true }}>
36
- * <App />
37
- * </HAI3Provider>
38
- *
39
- * // With router configuration
40
- * <HAI3Provider router={{ type: 'hash' }}>
41
- * <App />
42
- * </HAI3Provider>
43
- * ```
44
- */
45
- interface HAI3ProviderProps {
46
- /** Child components */
47
- children: ReactNode;
48
- /** HAI3 configuration */
49
- config?: HAI3Config;
50
- /** Pre-built HAI3 app instance (optional) */
51
- app?: HAI3App;
52
- /** Router configuration */
53
- router?: RouterConfig;
54
- }
55
- /**
56
- * useHAI3 Hook Return Type
57
- * Returns the HAI3 app instance from context.
58
- */
59
- type UseHAI3Return = HAI3App;
60
- /**
61
- * useAppSelector Hook
62
- * Type-safe selector hook for Redux state.
63
- *
64
- * @template TResult - The result type of the selector
65
- */
66
- type UseAppSelector = <TResult>(selector: Selector<TResult>) => TResult;
67
- /**
68
- * useAppDispatch Hook Return Type
69
- * Returns the typed dispatch function.
70
- */
71
- type UseAppDispatchReturn = (action: unknown) => unknown;
72
- /**
73
- * useTranslation Hook Return Type
74
- * Translation utilities.
75
- */
76
- interface UseTranslationReturn {
77
- /** Translate a key */
78
- t: (key: string, params?: TranslationParams) => string;
79
- /** Current language */
80
- language: Language | null;
81
- /** Change language */
82
- setLanguage: (language: Language) => Promise<void>;
83
- /** Check if current language is RTL */
84
- isRTL: boolean;
85
- }
86
- /**
87
- * useScreenTranslations Hook Return Type
88
- * Screen-level translation loading state.
89
- */
90
- interface UseScreenTranslationsReturn {
91
- /** Whether translations are loaded */
92
- isLoaded: boolean;
93
- /** Loading error (if any) */
94
- error: Error | null;
95
- }
96
- /**
97
- * useLanguage Hook Return Type
98
- * Language selection utilities.
99
- */
100
- interface UseLanguageReturn {
101
- /** Current language */
102
- current: Language | null;
103
- /** All supported languages */
104
- supported: LanguageMetadata[];
105
- /** Change language */
106
- setLanguage: (language: Language) => Promise<void>;
107
- /** Check if current language is RTL */
108
- isRTL: boolean;
109
- }
110
- /**
111
- * useTheme Hook Return Type
112
- * Theme utilities.
113
- */
114
- interface UseThemeReturn {
115
- /** Current theme ID */
116
- currentTheme: string | undefined;
117
- /** All available themes */
118
- themes: Array<{
119
- id: string;
120
- name: string;
121
- }>;
122
- /** Change theme */
123
- setTheme: (themeId: string) => void;
124
- }
125
- /**
126
- * useMenu Hook Return Type
127
- * Menu state and actions.
128
- */
129
- interface UseMenuReturn {
130
- /** Menu items */
131
- items: MenuItemConfig[];
132
- /** Whether menu is collapsed */
133
- collapsed: boolean;
134
- /** Whether menu is visible */
135
- visible: boolean;
136
- /** Toggle menu collapse */
137
- toggle: () => void;
138
- /** Set collapsed state */
139
- setCollapsed: (collapsed: boolean) => void;
140
- }
141
- /**
142
- * useScreen Hook Return Type
143
- * Current screen state.
144
- */
145
- interface UseScreenReturn {
146
- /** Active screen ID */
147
- activeScreen: string | null;
148
- /** Whether screen is loading */
149
- isLoading: boolean;
150
- }
151
- /**
152
- * useNavigation Hook Return Type
153
- * Navigation utilities.
154
- */
155
- interface UseNavigationReturn {
156
- /** Navigate to a screen, optionally with route params */
157
- navigateToScreen: (screensetId: string, screenId: string, params?: Record<string, string>) => void;
158
- /** Navigate to a screenset (uses default screen) */
159
- navigateToScreenset: (screensetId: string) => void;
160
- /** Current screenset ID */
161
- currentScreenset: string | null;
162
- /** Current screen ID */
163
- currentScreen: string | null;
164
- }
165
- /**
166
- * useScreenset Hook Return Type
167
- * Current screenset state.
168
- */
169
- interface UseScreensetReturn {
170
- /** Current screenset */
171
- screenset: ScreensetDefinition | undefined;
172
- /** Current screenset ID */
173
- screensetId: string | null;
174
- /** Current category */
175
- category: ScreensetCategory | null;
176
- }
177
- /**
178
- * usePopup Hook Return Type
179
- * Popup utilities.
180
- */
181
- interface UsePopupReturn {
182
- /** Show a popup */
183
- show: (config: {
184
- id: string;
185
- title?: string;
186
- content?: () => Promise<{
187
- default: React.ComponentType;
188
- }>;
189
- }) => void;
190
- /** Hide current popup */
191
- hide: () => void;
192
- /** Hide all popups */
193
- hideAll: () => void;
194
- /** Whether any popup is open */
195
- isOpen: boolean;
196
- /** Current popup stack */
197
- stack: Array<{
198
- id: string;
199
- title?: string;
200
- }>;
201
- }
202
- /**
203
- * useOverlay Hook Return Type
204
- * Overlay utilities.
205
- */
206
- interface UseOverlayReturn {
207
- /** Show an overlay */
208
- show: (config: {
209
- id: string;
210
- content?: () => Promise<{
211
- default: React.ComponentType;
212
- }>;
213
- }) => void;
214
- /** Hide current overlay */
215
- hide: () => void;
216
- /** Whether any overlay is open */
217
- isOpen: boolean;
218
- }
219
- /**
220
- * App Router Props
221
- * Props for the AppRouter component.
222
- */
223
- interface AppRouterProps {
224
- /** Fallback component while loading */
225
- fallback?: ReactNode;
226
- /** Error boundary fallback */
227
- errorFallback?: ReactNode | ((error: Error) => ReactNode);
228
- }
229
- /**
230
- * HAI3Provider Component Type
231
- */
232
- type HAI3ProviderComponent = React.FC<HAI3ProviderProps>;
233
- /**
234
- * AppRouter Component Type
235
- */
236
- type AppRouterComponent = React.FC<AppRouterProps>;
237
-
238
- export type { AppRouterComponent, AppRouterProps, HAI3ProviderComponent, HAI3ProviderProps, RouterConfig, RouterType, UseAppDispatchReturn, UseAppSelector, UseHAI3Return, UseLanguageReturn, UseMenuReturn, UseNavigationReturn, UseOverlayReturn, UsePopupReturn, UseScreenReturn, UseScreenTranslationsReturn, UseScreensetReturn, UseThemeReturn, UseTranslationReturn };
1
+ import 'react';
2
+ export { HAI3App, HAI3Config } from '@hai3/framework';
3
+ export { H as HAI3ProviderProps, e as UseAppDispatchReturn, f as UseAppSelector, b as UseFormattersReturn, g as UseHAI3Return, a as UseScreenTranslationsReturn, c as UseThemeReturn, U as UseTranslationReturn } from './types-CcLYaLwF.cjs';
package/dist/types.d.ts CHANGED
@@ -1,238 +1,3 @@
1
- import { ReactNode } from 'react';
2
- import { HAI3Config, HAI3App, RootState, Language, LanguageMetadata, MenuItemConfig, ScreensetDefinition, ScreensetCategory } from '@hai3/framework';
3
- export { HAI3App, HAI3Config, MenuItemConfig, ScreensetCategory, ScreensetDefinition } from '@hai3/framework';
4
-
5
- /**
6
- * @hai3/react - Type Definitions
7
- *
8
- * Core types for HAI3 React bindings.
9
- * Provides type-safe hooks and components.
10
- *
11
- * Now using real imports from @hai3/framework since packages are built together.
12
- */
13
-
14
- type Selector<TResult, TState = RootState> = (state: TState) => TResult;
15
- type TranslationParams = Record<string, string | number | boolean>;
16
- /**
17
- * Router configuration type
18
- */
19
- type RouterType = 'browser' | 'hash' | 'memory';
20
- /**
21
- * Router configuration
22
- */
23
- interface RouterConfig {
24
- /** Router type - browser (default), hash, or memory */
25
- type?: RouterType;
26
- /** Auto-navigate to first screen on load (default: true) */
27
- autoNavigate?: boolean;
28
- }
29
- /**
30
- * HAI3 Provider Props
31
- * Props for the main HAI3Provider component.
32
- *
33
- * @example
34
- * ```tsx
35
- * <HAI3Provider config={{ devMode: true }}>
36
- * <App />
37
- * </HAI3Provider>
38
- *
39
- * // With router configuration
40
- * <HAI3Provider router={{ type: 'hash' }}>
41
- * <App />
42
- * </HAI3Provider>
43
- * ```
44
- */
45
- interface HAI3ProviderProps {
46
- /** Child components */
47
- children: ReactNode;
48
- /** HAI3 configuration */
49
- config?: HAI3Config;
50
- /** Pre-built HAI3 app instance (optional) */
51
- app?: HAI3App;
52
- /** Router configuration */
53
- router?: RouterConfig;
54
- }
55
- /**
56
- * useHAI3 Hook Return Type
57
- * Returns the HAI3 app instance from context.
58
- */
59
- type UseHAI3Return = HAI3App;
60
- /**
61
- * useAppSelector Hook
62
- * Type-safe selector hook for Redux state.
63
- *
64
- * @template TResult - The result type of the selector
65
- */
66
- type UseAppSelector = <TResult>(selector: Selector<TResult>) => TResult;
67
- /**
68
- * useAppDispatch Hook Return Type
69
- * Returns the typed dispatch function.
70
- */
71
- type UseAppDispatchReturn = (action: unknown) => unknown;
72
- /**
73
- * useTranslation Hook Return Type
74
- * Translation utilities.
75
- */
76
- interface UseTranslationReturn {
77
- /** Translate a key */
78
- t: (key: string, params?: TranslationParams) => string;
79
- /** Current language */
80
- language: Language | null;
81
- /** Change language */
82
- setLanguage: (language: Language) => Promise<void>;
83
- /** Check if current language is RTL */
84
- isRTL: boolean;
85
- }
86
- /**
87
- * useScreenTranslations Hook Return Type
88
- * Screen-level translation loading state.
89
- */
90
- interface UseScreenTranslationsReturn {
91
- /** Whether translations are loaded */
92
- isLoaded: boolean;
93
- /** Loading error (if any) */
94
- error: Error | null;
95
- }
96
- /**
97
- * useLanguage Hook Return Type
98
- * Language selection utilities.
99
- */
100
- interface UseLanguageReturn {
101
- /** Current language */
102
- current: Language | null;
103
- /** All supported languages */
104
- supported: LanguageMetadata[];
105
- /** Change language */
106
- setLanguage: (language: Language) => Promise<void>;
107
- /** Check if current language is RTL */
108
- isRTL: boolean;
109
- }
110
- /**
111
- * useTheme Hook Return Type
112
- * Theme utilities.
113
- */
114
- interface UseThemeReturn {
115
- /** Current theme ID */
116
- currentTheme: string | undefined;
117
- /** All available themes */
118
- themes: Array<{
119
- id: string;
120
- name: string;
121
- }>;
122
- /** Change theme */
123
- setTheme: (themeId: string) => void;
124
- }
125
- /**
126
- * useMenu Hook Return Type
127
- * Menu state and actions.
128
- */
129
- interface UseMenuReturn {
130
- /** Menu items */
131
- items: MenuItemConfig[];
132
- /** Whether menu is collapsed */
133
- collapsed: boolean;
134
- /** Whether menu is visible */
135
- visible: boolean;
136
- /** Toggle menu collapse */
137
- toggle: () => void;
138
- /** Set collapsed state */
139
- setCollapsed: (collapsed: boolean) => void;
140
- }
141
- /**
142
- * useScreen Hook Return Type
143
- * Current screen state.
144
- */
145
- interface UseScreenReturn {
146
- /** Active screen ID */
147
- activeScreen: string | null;
148
- /** Whether screen is loading */
149
- isLoading: boolean;
150
- }
151
- /**
152
- * useNavigation Hook Return Type
153
- * Navigation utilities.
154
- */
155
- interface UseNavigationReturn {
156
- /** Navigate to a screen, optionally with route params */
157
- navigateToScreen: (screensetId: string, screenId: string, params?: Record<string, string>) => void;
158
- /** Navigate to a screenset (uses default screen) */
159
- navigateToScreenset: (screensetId: string) => void;
160
- /** Current screenset ID */
161
- currentScreenset: string | null;
162
- /** Current screen ID */
163
- currentScreen: string | null;
164
- }
165
- /**
166
- * useScreenset Hook Return Type
167
- * Current screenset state.
168
- */
169
- interface UseScreensetReturn {
170
- /** Current screenset */
171
- screenset: ScreensetDefinition | undefined;
172
- /** Current screenset ID */
173
- screensetId: string | null;
174
- /** Current category */
175
- category: ScreensetCategory | null;
176
- }
177
- /**
178
- * usePopup Hook Return Type
179
- * Popup utilities.
180
- */
181
- interface UsePopupReturn {
182
- /** Show a popup */
183
- show: (config: {
184
- id: string;
185
- title?: string;
186
- content?: () => Promise<{
187
- default: React.ComponentType;
188
- }>;
189
- }) => void;
190
- /** Hide current popup */
191
- hide: () => void;
192
- /** Hide all popups */
193
- hideAll: () => void;
194
- /** Whether any popup is open */
195
- isOpen: boolean;
196
- /** Current popup stack */
197
- stack: Array<{
198
- id: string;
199
- title?: string;
200
- }>;
201
- }
202
- /**
203
- * useOverlay Hook Return Type
204
- * Overlay utilities.
205
- */
206
- interface UseOverlayReturn {
207
- /** Show an overlay */
208
- show: (config: {
209
- id: string;
210
- content?: () => Promise<{
211
- default: React.ComponentType;
212
- }>;
213
- }) => void;
214
- /** Hide current overlay */
215
- hide: () => void;
216
- /** Whether any overlay is open */
217
- isOpen: boolean;
218
- }
219
- /**
220
- * App Router Props
221
- * Props for the AppRouter component.
222
- */
223
- interface AppRouterProps {
224
- /** Fallback component while loading */
225
- fallback?: ReactNode;
226
- /** Error boundary fallback */
227
- errorFallback?: ReactNode | ((error: Error) => ReactNode);
228
- }
229
- /**
230
- * HAI3Provider Component Type
231
- */
232
- type HAI3ProviderComponent = React.FC<HAI3ProviderProps>;
233
- /**
234
- * AppRouter Component Type
235
- */
236
- type AppRouterComponent = React.FC<AppRouterProps>;
237
-
238
- export type { AppRouterComponent, AppRouterProps, HAI3ProviderComponent, HAI3ProviderProps, RouterConfig, RouterType, UseAppDispatchReturn, UseAppSelector, UseHAI3Return, UseLanguageReturn, UseMenuReturn, UseNavigationReturn, UseOverlayReturn, UsePopupReturn, UseScreenReturn, UseScreenTranslationsReturn, UseScreensetReturn, UseThemeReturn, UseTranslationReturn };
1
+ import 'react';
2
+ export { HAI3App, HAI3Config } from '@hai3/framework';
3
+ export { H as HAI3ProviderProps, e as UseAppDispatchReturn, f as UseAppSelector, b as UseFormattersReturn, g as UseHAI3Return, a as UseScreenTranslationsReturn, c as UseThemeReturn, U as UseTranslationReturn } from './types-CcLYaLwF.js';
package/llms.txt CHANGED
@@ -1,13 +1,13 @@
1
1
  # @hai3/react
2
2
 
3
- > React bindings, hooks, and components for HAI3 SDK. Provides type-safe integration with React applications.
3
+ > React bindings, hooks, and components for HAI3 SDK. Provides type-safe integration with React applications including MFE (Microfrontend) support.
4
4
 
5
5
  Part of the HAI3 React Layer (L3) - depends on @hai3/framework. Peer dependency on react and react-dom.
6
6
 
7
7
  ## Core API
8
8
 
9
9
  - [HAI3Provider](https://hai3.dev/docs/react/provider): Root context provider
10
- - [AppRouter](https://hai3.dev/docs/react/router): Screen rendering with lazy loading
10
+ - [MFE Components](https://hai3.dev/docs/react/mfe): ExtensionDomainSlot, MfeProvider, RefContainerProvider
11
11
 
12
12
  ## Hooks
13
13
 
@@ -18,20 +18,28 @@ Part of the HAI3 React Layer (L3) - depends on @hai3/framework. Peer dependency
18
18
  | `useAppSelector()` | Type-safe selector |
19
19
  | `useTranslation()` | Translation utilities (t, language, setLanguage, isRTL) |
20
20
  | `useScreenTranslations()` | Lazy load screen translations |
21
- | `useNavigation()` | Navigate between screens |
22
21
  | `useTheme()` | Theme utilities (currentTheme, themes, setTheme) |
23
22
 
23
+ ## MFE Hooks
24
+
25
+ | Hook | Purpose |
26
+ |------|---------|
27
+ | `useMfeBridge()` | Access MFE bridge (child MFEs) |
28
+ | `useSharedProperty()` | Subscribe to shared property changes |
29
+ | `useHostAction()` | Invoke actions on host application |
30
+ | `useDomainExtensions()` | Subscribe to extensions in a domain |
31
+
24
32
  ## Quick Start
25
33
 
26
34
  ```tsx
27
- import { HAI3Provider, AppRouter, useTranslation, useNavigation } from '@hai3/react';
35
+ import { HAI3Provider, ExtensionDomainSlot, useTranslation, useHAI3 } from '@hai3/react';
28
36
 
29
37
  // Wrap app with provider
30
38
  function App() {
31
39
  return (
32
40
  <HAI3Provider>
33
41
  <Layout>
34
- <AppRouter fallback={<Loading />} />
42
+ <ExtensionDomainSlot domainId="screen" fallback={<Loading />} />
35
43
  </Layout>
36
44
  </HAI3Provider>
37
45
  );
@@ -40,20 +48,75 @@ function App() {
40
48
  // Use hooks in components
41
49
  function MyComponent() {
42
50
  const { t, isRTL } = useTranslation();
43
- const { navigateToScreen } = useNavigation();
51
+ const app = useHAI3();
44
52
 
45
53
  return (
46
54
  <div dir={isRTL ? 'rtl' : 'ltr'}>
47
55
  <h1>{t('common:title')}</h1>
48
- <button onClick={() => navigateToScreen('demo', 'home')}>
49
- Go Home
50
- </button>
51
56
  </div>
52
57
  );
53
58
  }
54
59
  ```
55
60
 
61
+ ## MFE Patterns
62
+
63
+ ### Using ExtensionDomainSlot
64
+
65
+ ```tsx
66
+ import { ExtensionDomainSlot } from '@hai3/react';
67
+
68
+ function LayoutScreen() {
69
+ const screenContainerRef = useRef<HTMLDivElement>(null);
70
+
71
+ return (
72
+ <ExtensionDomainSlot
73
+ domainId="screen"
74
+ containerRef={screenContainerRef}
75
+ fallback={<Loading />}
76
+ />
77
+ );
78
+ }
79
+ ```
80
+
81
+ ### Using MFE Bridge
82
+
83
+ ```tsx
84
+ import { useMfeBridge, useSharedProperty, HAI3_ACTION_LOAD_EXT, HAI3_SHARED_PROPERTY_THEME } from '@hai3/react';
85
+
86
+ function MyExtension() {
87
+ const bridge = useMfeBridge();
88
+ const theme = useSharedProperty(HAI3_SHARED_PROPERTY_THEME);
89
+
90
+ const handleAction = async () => {
91
+ await bridge.executeActionsChain({
92
+ action: { type: HAI3_ACTION_LOAD_EXT, target: 'screen', payload: { extensionId: 'other' } }
93
+ });
94
+ };
95
+
96
+ return <div style={{ backgroundColor: theme?.primaryColor }}>...</div>;
97
+ }
98
+ ```
99
+
100
+ ### Subscribing to Domain Extensions
101
+
102
+ ```tsx
103
+ import { useDomainExtensions } from '@hai3/react';
104
+
105
+ function ScreenList() {
106
+ const screenExtensions = useDomainExtensions('screen');
107
+
108
+ return (
109
+ <ul>
110
+ {screenExtensions.map((ext) => (
111
+ <li key={ext.id}>{ext.title}</li>
112
+ ))}
113
+ </ul>
114
+ );
115
+ }
116
+ ```
117
+
56
118
  ## Optional
57
119
 
58
120
  - [Screen Translations](https://hai3.dev/docs/react/translations): Per-screen lazy loading
59
121
  - [Custom Hooks](https://hai3.dev/docs/react/hooks): Building on HAI3 hooks
122
+ - [MFE Bridge Communication](https://hai3.dev/docs/react/mfe-bridge): Parent-child patterns
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hai3/react",
3
- "version": "0.3.0-alpha.0",
3
+ "version": "0.4.0-alpha.1",
4
4
  "description": "React bindings and hooks for HAI3 framework",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -26,7 +26,9 @@
26
26
  ],
27
27
  "scripts": {
28
28
  "build": "tsup",
29
- "type-check": "tsc --noEmit"
29
+ "type-check": "tsc --noEmit",
30
+ "test": "vitest run",
31
+ "test:watch": "vitest"
30
32
  },
31
33
  "dependencies": {},
32
34
  "devDependencies": {
@@ -35,7 +37,12 @@
35
37
  "react": "^19.2.4",
36
38
  "@types/react": "^19.0.8",
37
39
  "react-redux": "^9.1.0",
38
- "@types/react-redux": "^7.1.33"
40
+ "@types/react-redux": "^7.1.33",
41
+ "vitest": "^4.0.18",
42
+ "@vitest/coverage-v8": "^4.0.18",
43
+ "@testing-library/react": "^16.1.0",
44
+ "@reduxjs/toolkit": "^2.5.0",
45
+ "jsdom": "^25.0.1"
39
46
  },
40
47
  "peerDependencies": {
41
48
  "@hai3/framework": "*",