@hai3/react 0.3.0-alpha.0 → 0.4.0-alpha.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.
- package/CLAUDE.md +255 -43
- package/commands/hai3-new-mfe.md +167 -0
- package/dist/index.cjs +539 -280
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +342 -90
- package/dist/index.d.ts +342 -90
- package/dist/index.js +422 -149
- package/dist/index.js.map +1 -1
- package/dist/types-CcLYaLwF.d.cts +136 -0
- package/dist/types-CcLYaLwF.d.ts +136 -0
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +3 -238
- package/dist/types.d.ts +3 -238
- package/llms.txt +72 -9
- package/package.json +10 -3
package/dist/types.d.cts
CHANGED
|
@@ -1,238 +1,3 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
export {
|
|
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
|
|
2
|
-
|
|
3
|
-
export {
|
|
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
|
-
- [
|
|
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,
|
|
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
|
-
<
|
|
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
|
|
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
|
+
"version": "0.4.0-alpha.0",
|
|
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": "*",
|