@hai3/react 0.2.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 +227 -0
- package/commands/hai3-duplicate-screenset.md +58 -0
- package/commands/hai3-new-component.md +76 -0
- package/commands/hai3-new-screen.md +81 -0
- package/commands/hai3-new-screenset.md +85 -0
- package/dist/index.cjs +27587 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +345 -0
- package/dist/index.d.ts +345 -0
- package/dist/index.js +27558 -0
- package/dist/index.js.map +1 -0
- package/dist/types.cjs +19 -0
- package/dist/types.cjs.map +1 -0
- package/dist/types.d.cts +247 -0
- package/dist/types.d.ts +247 -0
- package/dist/types.js +1 -0
- package/dist/types.js.map +1 -0
- package/llms.txt +60 -0
- package/package.json +59 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { ReactNode } from 'react';
|
|
3
|
+
import { HAI3ProviderProps, UseTranslationReturn, UseScreenTranslationsReturn, UseNavigationReturn, UseThemeReturn, TextLoaderProps, AppRouterProps } from './types.cjs';
|
|
4
|
+
export { AppRouterComponent, HAI3ProviderComponent, TextLoaderComponent, UseAppDispatchReturn, UseAppSelector, UseHAI3Return, UseLanguageReturn, UseMenuReturn, UseOverlayReturn, UsePopupReturn, UseScreenReturn, UseScreensetReturn } from './types.cjs';
|
|
5
|
+
import { HAI3App, AppDispatch, RootState, TranslationMap, TranslationLoader } from '@hai3/framework';
|
|
6
|
+
export { ACCOUNTS_DOMAIN, ApiProtocol, ApiService, ApiServiceConfig, ApiServicesMap, AppDispatch, BaseApiService, ChangeThemePayload, EventHandler, EventPayloadMap, FooterConfig, FooterState, HAI3App, HAI3AppBuilder, HAI3Config, HAI3Plugin, HAI3Store, HeaderConfig, HeaderState, HeaderUser, I18nConfig, I18nRegistry, I18nRegistryImpl, I18nRegistryType, JsonCompatible, JsonObject, JsonPrimitive, JsonValue, LAYOUT_SLICE_NAME, LanguageMetadata, LayoutDomain, LayoutDomainReducers, LayoutDomainState, LayoutState, LegacyTheme, MenuItem, MenuItemConfig, MenuScreenItem, MenuState, MockMap, MockPlugin, NavigateToScreenPayload, NavigateToScreensetPayload, OverlayConfig, OverlayState, PluginFactory, PluginLifecycle, PluginProvides, PopupConfig, PopupSliceState, PopupState, Preset, Presets, RestProtocol, RestProtocolConfig, RootState, RootStateWithLayout, RouteRegistry, SUPPORTED_LANGUAGES, ScreenConfig, ScreenId, ScreenLoader, ScreenState, ScreensetCategory, ScreensetConfig, ScreensetDefinition, ScreensetId, ScreensetRegistry, ScreensetsConfig, SetLanguagePayload, ShowPopupPayload, SidebarPosition, SidebarState, SliceObject, SseProtocol, SseProtocolConfig, Subscription, TENANT_SLICE_NAME, Tenant, TenantChangedPayload, TenantClearedPayload, TenantEvents, TenantState, ThemeApplyFn, ThemeConfig, ThemeRegistry, TranslationDictionary, TranslationLoader, TranslationMap, apiRegistry, changeTenant, clearActiveScreen, clearTenant, clearTenantAction, clearUser, closeAllPopups, closePopup, closeTopPopup, createHAI3, createHAI3App, createI18nRegistry, createRouteRegistry, createScreensetRegistry, createSlice, createStore, createThemeRegistry, effects, eventBus, fetchCurrentUser, footerActions, footerSlice, getLanguageMetadata, getStore, hasSlice, headerActions, headerSlice, hideOverlay, i18n, i18nRegistry, initTenantEffects, layout, layoutDomainReducers, layoutReducer, menuActions, menuSlice, navigateTo, navigateToScreen, navigation, openPopup, overlayActions, overlaySlice, popupActions, popupSlice, presets, registerSlice, routeRegistry, routing, screenActions, screenSlice, screensetRegistry, screensets, setActiveScreen, setFooterConfig, setFooterVisible, setHeaderLoading, setMenuCollapsed, setMenuConfig, setMenuItems, setMenuVisible, setOverlayVisible, setScreenLoading, setSidebarCollapsed, setSidebarConfig, setSidebarContent, setSidebarPosition, setSidebarTitle, setSidebarVisible, setSidebarWidth, setTenant, setTenantLoading, setTenantLoadingState, setUser, showOverlay, sidebarActions, sidebarSlice, tenantActions, tenantReducer, tenantSlice, themeRegistry, themes, toggleMenu, toggleSidebar } from '@hai3/framework';
|
|
7
|
+
import { TypedUseSelectorHook } from 'react-redux';
|
|
8
|
+
import { ComponentName, UiKitComponentMap, UiKitIcon } from '@hai3/uikit';
|
|
9
|
+
export { ComponentName, UiKitComponent, UiKitComponentMap, UiKitIcon } from '@hai3/uikit';
|
|
10
|
+
export { Language, LanguageDisplayMode, TextDirection } from '@hai3/i18n';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* HAI3 Provider - Main provider component for HAI3 applications
|
|
14
|
+
*
|
|
15
|
+
* React Layer: L3 (Depends on @hai3/framework)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* HAI3 Provider Component
|
|
20
|
+
*
|
|
21
|
+
* Provides the HAI3 application context to all child components.
|
|
22
|
+
* Creates the HAI3 app instance with the full preset by default.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* // Default - creates app with full preset
|
|
27
|
+
* <HAI3Provider>
|
|
28
|
+
* <App />
|
|
29
|
+
* </HAI3Provider>
|
|
30
|
+
*
|
|
31
|
+
* // With configuration
|
|
32
|
+
* <HAI3Provider config={{ devMode: true }}>
|
|
33
|
+
* <App />
|
|
34
|
+
* </HAI3Provider>
|
|
35
|
+
*
|
|
36
|
+
* // With pre-built app
|
|
37
|
+
* const app = createHAI3().use(screensets()).build();
|
|
38
|
+
* <HAI3Provider app={app}>
|
|
39
|
+
* <App />
|
|
40
|
+
* </HAI3Provider>
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
declare const HAI3Provider: React__default.FC<HAI3ProviderProps>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* HAI3 Context
|
|
47
|
+
* Holds the HAI3 app instance for the application.
|
|
48
|
+
*/
|
|
49
|
+
declare const HAI3Context: React.Context<HAI3App | null>;
|
|
50
|
+
/**
|
|
51
|
+
* Use the HAI3 context.
|
|
52
|
+
* Throws if used outside of HAI3Provider.
|
|
53
|
+
*
|
|
54
|
+
* @returns The HAI3 app instance
|
|
55
|
+
*/
|
|
56
|
+
declare function useHAI3(): HAI3App;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* useAppDispatch Hook - Type-safe dispatch hook
|
|
60
|
+
*
|
|
61
|
+
* React Layer: L3
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Type-safe dispatch hook.
|
|
66
|
+
*
|
|
67
|
+
* @returns The typed dispatch function
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```tsx
|
|
71
|
+
* const dispatch = useAppDispatch();
|
|
72
|
+
* dispatch(someAction());
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
declare function useAppDispatch(): AppDispatch;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* useAppSelector Hook - Type-safe selector hook
|
|
79
|
+
*
|
|
80
|
+
* React Layer: L3
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Type-safe selector hook.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```tsx
|
|
88
|
+
* const activeScreen = useAppSelector(selectActiveScreen);
|
|
89
|
+
* const menuCollapsed = useAppSelector(selectMenuCollapsed);
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
declare const useAppSelector: TypedUseSelectorHook<RootState>;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* useTranslation Hook - Translation utilities
|
|
96
|
+
*
|
|
97
|
+
* React Layer: L3
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Hook for accessing translation utilities.
|
|
102
|
+
*
|
|
103
|
+
* @returns Translation utilities
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```tsx
|
|
107
|
+
* const { t, language, setLanguage, isRTL } = useTranslation();
|
|
108
|
+
*
|
|
109
|
+
* return (
|
|
110
|
+
* <div dir={isRTL ? 'rtl' : 'ltr'}>
|
|
111
|
+
* <h1>{t('common:app.title')}</h1>
|
|
112
|
+
* <p>{t('common:app.welcome', { name: 'John' })}</p>
|
|
113
|
+
* </div>
|
|
114
|
+
* );
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
declare function useTranslation(): UseTranslationReturn;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* useScreenTranslations Hook - Screen-level translation loading
|
|
121
|
+
*
|
|
122
|
+
* React Layer: L3
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Hook for loading screen-level translations.
|
|
127
|
+
* Use this in screen components to lazy-load translations.
|
|
128
|
+
* Automatically reloads translations when language changes.
|
|
129
|
+
*
|
|
130
|
+
* @param screensetId - The screenset ID
|
|
131
|
+
* @param screenId - The screen ID
|
|
132
|
+
* @param translations - Either a TranslationMap object or a TranslationLoader function
|
|
133
|
+
* (from I18nRegistry.createLoader)
|
|
134
|
+
* @returns Loading state
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```tsx
|
|
138
|
+
* // Option 1: Using I18nRegistry.createLoader (recommended)
|
|
139
|
+
* const translations = I18nRegistry.createLoader({
|
|
140
|
+
* en: () => import('./i18n/en.json'),
|
|
141
|
+
* es: () => import('./i18n/es.json'),
|
|
142
|
+
* });
|
|
143
|
+
*
|
|
144
|
+
* // Option 2: Using raw TranslationMap
|
|
145
|
+
* const translations = {
|
|
146
|
+
* en: () => import('./i18n/en.json'),
|
|
147
|
+
* es: () => import('./i18n/es.json'),
|
|
148
|
+
* };
|
|
149
|
+
*
|
|
150
|
+
* export const HomeScreen: React.FC = () => {
|
|
151
|
+
* const { isLoaded, error } = useScreenTranslations(
|
|
152
|
+
* 'demo',
|
|
153
|
+
* 'home',
|
|
154
|
+
* translations
|
|
155
|
+
* );
|
|
156
|
+
*
|
|
157
|
+
* if (!isLoaded) return <LoadingSpinner />;
|
|
158
|
+
* if (error) return <ErrorMessage error={error} />;
|
|
159
|
+
*
|
|
160
|
+
* return <div>...</div>;
|
|
161
|
+
* };
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
declare function useScreenTranslations(screensetId: string, screenId: string, translations: TranslationMap | TranslationLoader): UseScreenTranslationsReturn;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* useNavigation Hook - Navigation utilities
|
|
168
|
+
*
|
|
169
|
+
* React Layer: L3
|
|
170
|
+
*/
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Hook for navigation utilities.
|
|
174
|
+
*
|
|
175
|
+
* @returns Navigation utilities
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```tsx
|
|
179
|
+
* const { navigateToScreen, navigateToScreenset, currentScreen } = useNavigation();
|
|
180
|
+
*
|
|
181
|
+
* return (
|
|
182
|
+
* <button onClick={() => navigateToScreen('demo', 'home')}>
|
|
183
|
+
* Go to Home
|
|
184
|
+
* </button>
|
|
185
|
+
* );
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
declare function useNavigation(): UseNavigationReturn;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* useTheme Hook - Theme utilities
|
|
192
|
+
*
|
|
193
|
+
* React Layer: L3
|
|
194
|
+
*/
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Hook for theme utilities.
|
|
198
|
+
*
|
|
199
|
+
* @returns Theme utilities
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```tsx
|
|
203
|
+
* const { currentTheme, themes, setTheme } = useTheme();
|
|
204
|
+
*
|
|
205
|
+
* return (
|
|
206
|
+
* <select
|
|
207
|
+
* value={currentTheme}
|
|
208
|
+
* onChange={(e) => setTheme(e.target.value)}
|
|
209
|
+
* >
|
|
210
|
+
* {themes.map((theme) => (
|
|
211
|
+
* <option key={theme.id} value={theme.id}>
|
|
212
|
+
* {theme.name}
|
|
213
|
+
* </option>
|
|
214
|
+
* ))}
|
|
215
|
+
* </select>
|
|
216
|
+
* );
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
219
|
+
declare function useTheme(): UseThemeReturn;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* TextLoader Component - Prevents flash of untranslated content
|
|
223
|
+
*
|
|
224
|
+
* React Layer: L3
|
|
225
|
+
*/
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* TextLoader Component
|
|
229
|
+
*
|
|
230
|
+
* Generic wrapper for translated text that automatically shows a skeleton loader
|
|
231
|
+
* while translations are being loaded. This eliminates the need for manual
|
|
232
|
+
* loading state checks throughout the application.
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* ```tsx
|
|
236
|
+
* // Heading - default bg-muted skeleton
|
|
237
|
+
* <TextLoader skeletonClassName="h-10 w-64">
|
|
238
|
+
* <h1 className="text-4xl font-bold">{t('screen.title')}</h1>
|
|
239
|
+
* </TextLoader>
|
|
240
|
+
*
|
|
241
|
+
* // Button label - inherits button text color
|
|
242
|
+
* <Button>
|
|
243
|
+
* <TextLoader skeletonClassName="h-4 w-24" inheritColor>
|
|
244
|
+
* {t('button.submit')}
|
|
245
|
+
* </TextLoader>
|
|
246
|
+
* </Button>
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
declare const TextLoader: React__default.FC<TextLoaderProps>;
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* AppRouter Component - Renders the active screen
|
|
253
|
+
*
|
|
254
|
+
* React Layer: L3
|
|
255
|
+
*/
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* AppRouter Component
|
|
259
|
+
*
|
|
260
|
+
* Renders the currently active screen based on navigation state.
|
|
261
|
+
* Handles lazy loading and error boundaries.
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* ```tsx
|
|
265
|
+
* <HAI3Provider>
|
|
266
|
+
* <Layout>
|
|
267
|
+
* <AppRouter
|
|
268
|
+
* fallback={<LoadingSpinner />}
|
|
269
|
+
* errorFallback={(error) => <ErrorPage error={error} />}
|
|
270
|
+
* />
|
|
271
|
+
* </Layout>
|
|
272
|
+
* </HAI3Provider>
|
|
273
|
+
* ```
|
|
274
|
+
*/
|
|
275
|
+
declare const AppRouter: React__default.FC<AppRouterProps>;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* UI Kit Registry Service
|
|
279
|
+
* Unified registry for UI components and icons
|
|
280
|
+
* Allows applications to register UI Kit implementations at runtime
|
|
281
|
+
*
|
|
282
|
+
* OPEN/CLOSED PRINCIPLE:
|
|
283
|
+
* - Registry is CLOSED for modification
|
|
284
|
+
* - UI elements register themselves at app level
|
|
285
|
+
* - UI Core depends on interfaces, not implementations
|
|
286
|
+
*/
|
|
287
|
+
|
|
288
|
+
declare class UiKitRegistry {
|
|
289
|
+
private components;
|
|
290
|
+
private icons;
|
|
291
|
+
/**
|
|
292
|
+
* Register a component implementation
|
|
293
|
+
*/
|
|
294
|
+
registerComponent<K extends ComponentName>(name: K, component: UiKitComponentMap[K]): void;
|
|
295
|
+
/**
|
|
296
|
+
* Register multiple components at once
|
|
297
|
+
* Type-safe: only accepts components defined in UiKitComponentMap
|
|
298
|
+
*/
|
|
299
|
+
registerComponents(components: Partial<UiKitComponentMap>): void;
|
|
300
|
+
/**
|
|
301
|
+
* Get a component by name
|
|
302
|
+
*/
|
|
303
|
+
getComponent<K extends ComponentName>(name: K): UiKitComponentMap[K];
|
|
304
|
+
/**
|
|
305
|
+
* Check if a component is registered
|
|
306
|
+
*/
|
|
307
|
+
hasComponent(name: ComponentName): boolean;
|
|
308
|
+
/**
|
|
309
|
+
* Get all registered component names
|
|
310
|
+
*/
|
|
311
|
+
getRegisteredComponents(): ComponentName[];
|
|
312
|
+
/**
|
|
313
|
+
* Register an icon
|
|
314
|
+
* Only accepts UiKitIcon enum or exported string constants
|
|
315
|
+
* NO hardcoded string literals
|
|
316
|
+
*/
|
|
317
|
+
registerIcon(id: UiKitIcon | string, icon: ReactNode): void;
|
|
318
|
+
/**
|
|
319
|
+
* Register multiple icons at once
|
|
320
|
+
* Only accepts UiKitIcon enum or exported string constants
|
|
321
|
+
* NO hardcoded string literals
|
|
322
|
+
*/
|
|
323
|
+
registerIcons(icons: Record<string, ReactNode>): void;
|
|
324
|
+
/**
|
|
325
|
+
* Get an icon by ID
|
|
326
|
+
* Accepts UiKitIcon enum or exported string constants
|
|
327
|
+
*/
|
|
328
|
+
getIcon(id: UiKitIcon | string): ReactNode | undefined;
|
|
329
|
+
/**
|
|
330
|
+
* Get all registered icons
|
|
331
|
+
*/
|
|
332
|
+
getAllIcons(): Record<string, ReactNode>;
|
|
333
|
+
/**
|
|
334
|
+
* Check if an icon is registered
|
|
335
|
+
* Accepts UiKitIcon enum or exported string constants
|
|
336
|
+
*/
|
|
337
|
+
hasIcon(id: UiKitIcon | string): boolean;
|
|
338
|
+
/**
|
|
339
|
+
* Clear all registrations (for testing)
|
|
340
|
+
*/
|
|
341
|
+
clear(): void;
|
|
342
|
+
}
|
|
343
|
+
declare const uikitRegistry: UiKitRegistry;
|
|
344
|
+
|
|
345
|
+
export { AppRouter, AppRouterProps, HAI3Context, HAI3Provider, HAI3ProviderProps, TextLoader, TextLoaderProps, UseNavigationReturn, UseScreenTranslationsReturn, UseThemeReturn, UseTranslationReturn, uikitRegistry, useAppDispatch, useAppSelector, useHAI3, useNavigation, useScreenTranslations, useTheme, useTranslation };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,345 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import React__default, { ReactNode } from 'react';
|
|
3
|
+
import { HAI3ProviderProps, UseTranslationReturn, UseScreenTranslationsReturn, UseNavigationReturn, UseThemeReturn, TextLoaderProps, AppRouterProps } from './types.js';
|
|
4
|
+
export { AppRouterComponent, HAI3ProviderComponent, TextLoaderComponent, UseAppDispatchReturn, UseAppSelector, UseHAI3Return, UseLanguageReturn, UseMenuReturn, UseOverlayReturn, UsePopupReturn, UseScreenReturn, UseScreensetReturn } from './types.js';
|
|
5
|
+
import { HAI3App, AppDispatch, RootState, TranslationMap, TranslationLoader } from '@hai3/framework';
|
|
6
|
+
export { ACCOUNTS_DOMAIN, ApiProtocol, ApiService, ApiServiceConfig, ApiServicesMap, AppDispatch, BaseApiService, ChangeThemePayload, EventHandler, EventPayloadMap, FooterConfig, FooterState, HAI3App, HAI3AppBuilder, HAI3Config, HAI3Plugin, HAI3Store, HeaderConfig, HeaderState, HeaderUser, I18nConfig, I18nRegistry, I18nRegistryImpl, I18nRegistryType, JsonCompatible, JsonObject, JsonPrimitive, JsonValue, LAYOUT_SLICE_NAME, LanguageMetadata, LayoutDomain, LayoutDomainReducers, LayoutDomainState, LayoutState, LegacyTheme, MenuItem, MenuItemConfig, MenuScreenItem, MenuState, MockMap, MockPlugin, NavigateToScreenPayload, NavigateToScreensetPayload, OverlayConfig, OverlayState, PluginFactory, PluginLifecycle, PluginProvides, PopupConfig, PopupSliceState, PopupState, Preset, Presets, RestProtocol, RestProtocolConfig, RootState, RootStateWithLayout, RouteRegistry, SUPPORTED_LANGUAGES, ScreenConfig, ScreenId, ScreenLoader, ScreenState, ScreensetCategory, ScreensetConfig, ScreensetDefinition, ScreensetId, ScreensetRegistry, ScreensetsConfig, SetLanguagePayload, ShowPopupPayload, SidebarPosition, SidebarState, SliceObject, SseProtocol, SseProtocolConfig, Subscription, TENANT_SLICE_NAME, Tenant, TenantChangedPayload, TenantClearedPayload, TenantEvents, TenantState, ThemeApplyFn, ThemeConfig, ThemeRegistry, TranslationDictionary, TranslationLoader, TranslationMap, apiRegistry, changeTenant, clearActiveScreen, clearTenant, clearTenantAction, clearUser, closeAllPopups, closePopup, closeTopPopup, createHAI3, createHAI3App, createI18nRegistry, createRouteRegistry, createScreensetRegistry, createSlice, createStore, createThemeRegistry, effects, eventBus, fetchCurrentUser, footerActions, footerSlice, getLanguageMetadata, getStore, hasSlice, headerActions, headerSlice, hideOverlay, i18n, i18nRegistry, initTenantEffects, layout, layoutDomainReducers, layoutReducer, menuActions, menuSlice, navigateTo, navigateToScreen, navigation, openPopup, overlayActions, overlaySlice, popupActions, popupSlice, presets, registerSlice, routeRegistry, routing, screenActions, screenSlice, screensetRegistry, screensets, setActiveScreen, setFooterConfig, setFooterVisible, setHeaderLoading, setMenuCollapsed, setMenuConfig, setMenuItems, setMenuVisible, setOverlayVisible, setScreenLoading, setSidebarCollapsed, setSidebarConfig, setSidebarContent, setSidebarPosition, setSidebarTitle, setSidebarVisible, setSidebarWidth, setTenant, setTenantLoading, setTenantLoadingState, setUser, showOverlay, sidebarActions, sidebarSlice, tenantActions, tenantReducer, tenantSlice, themeRegistry, themes, toggleMenu, toggleSidebar } from '@hai3/framework';
|
|
7
|
+
import { TypedUseSelectorHook } from 'react-redux';
|
|
8
|
+
import { ComponentName, UiKitComponentMap, UiKitIcon } from '@hai3/uikit';
|
|
9
|
+
export { ComponentName, UiKitComponent, UiKitComponentMap, UiKitIcon } from '@hai3/uikit';
|
|
10
|
+
export { Language, LanguageDisplayMode, TextDirection } from '@hai3/i18n';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* HAI3 Provider - Main provider component for HAI3 applications
|
|
14
|
+
*
|
|
15
|
+
* React Layer: L3 (Depends on @hai3/framework)
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* HAI3 Provider Component
|
|
20
|
+
*
|
|
21
|
+
* Provides the HAI3 application context to all child components.
|
|
22
|
+
* Creates the HAI3 app instance with the full preset by default.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* ```tsx
|
|
26
|
+
* // Default - creates app with full preset
|
|
27
|
+
* <HAI3Provider>
|
|
28
|
+
* <App />
|
|
29
|
+
* </HAI3Provider>
|
|
30
|
+
*
|
|
31
|
+
* // With configuration
|
|
32
|
+
* <HAI3Provider config={{ devMode: true }}>
|
|
33
|
+
* <App />
|
|
34
|
+
* </HAI3Provider>
|
|
35
|
+
*
|
|
36
|
+
* // With pre-built app
|
|
37
|
+
* const app = createHAI3().use(screensets()).build();
|
|
38
|
+
* <HAI3Provider app={app}>
|
|
39
|
+
* <App />
|
|
40
|
+
* </HAI3Provider>
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
declare const HAI3Provider: React__default.FC<HAI3ProviderProps>;
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* HAI3 Context
|
|
47
|
+
* Holds the HAI3 app instance for the application.
|
|
48
|
+
*/
|
|
49
|
+
declare const HAI3Context: React.Context<HAI3App | null>;
|
|
50
|
+
/**
|
|
51
|
+
* Use the HAI3 context.
|
|
52
|
+
* Throws if used outside of HAI3Provider.
|
|
53
|
+
*
|
|
54
|
+
* @returns The HAI3 app instance
|
|
55
|
+
*/
|
|
56
|
+
declare function useHAI3(): HAI3App;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* useAppDispatch Hook - Type-safe dispatch hook
|
|
60
|
+
*
|
|
61
|
+
* React Layer: L3
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Type-safe dispatch hook.
|
|
66
|
+
*
|
|
67
|
+
* @returns The typed dispatch function
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```tsx
|
|
71
|
+
* const dispatch = useAppDispatch();
|
|
72
|
+
* dispatch(someAction());
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
75
|
+
declare function useAppDispatch(): AppDispatch;
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* useAppSelector Hook - Type-safe selector hook
|
|
79
|
+
*
|
|
80
|
+
* React Layer: L3
|
|
81
|
+
*/
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Type-safe selector hook.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```tsx
|
|
88
|
+
* const activeScreen = useAppSelector(selectActiveScreen);
|
|
89
|
+
* const menuCollapsed = useAppSelector(selectMenuCollapsed);
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
declare const useAppSelector: TypedUseSelectorHook<RootState>;
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* useTranslation Hook - Translation utilities
|
|
96
|
+
*
|
|
97
|
+
* React Layer: L3
|
|
98
|
+
*/
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Hook for accessing translation utilities.
|
|
102
|
+
*
|
|
103
|
+
* @returns Translation utilities
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```tsx
|
|
107
|
+
* const { t, language, setLanguage, isRTL } = useTranslation();
|
|
108
|
+
*
|
|
109
|
+
* return (
|
|
110
|
+
* <div dir={isRTL ? 'rtl' : 'ltr'}>
|
|
111
|
+
* <h1>{t('common:app.title')}</h1>
|
|
112
|
+
* <p>{t('common:app.welcome', { name: 'John' })}</p>
|
|
113
|
+
* </div>
|
|
114
|
+
* );
|
|
115
|
+
* ```
|
|
116
|
+
*/
|
|
117
|
+
declare function useTranslation(): UseTranslationReturn;
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* useScreenTranslations Hook - Screen-level translation loading
|
|
121
|
+
*
|
|
122
|
+
* React Layer: L3
|
|
123
|
+
*/
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Hook for loading screen-level translations.
|
|
127
|
+
* Use this in screen components to lazy-load translations.
|
|
128
|
+
* Automatically reloads translations when language changes.
|
|
129
|
+
*
|
|
130
|
+
* @param screensetId - The screenset ID
|
|
131
|
+
* @param screenId - The screen ID
|
|
132
|
+
* @param translations - Either a TranslationMap object or a TranslationLoader function
|
|
133
|
+
* (from I18nRegistry.createLoader)
|
|
134
|
+
* @returns Loading state
|
|
135
|
+
*
|
|
136
|
+
* @example
|
|
137
|
+
* ```tsx
|
|
138
|
+
* // Option 1: Using I18nRegistry.createLoader (recommended)
|
|
139
|
+
* const translations = I18nRegistry.createLoader({
|
|
140
|
+
* en: () => import('./i18n/en.json'),
|
|
141
|
+
* es: () => import('./i18n/es.json'),
|
|
142
|
+
* });
|
|
143
|
+
*
|
|
144
|
+
* // Option 2: Using raw TranslationMap
|
|
145
|
+
* const translations = {
|
|
146
|
+
* en: () => import('./i18n/en.json'),
|
|
147
|
+
* es: () => import('./i18n/es.json'),
|
|
148
|
+
* };
|
|
149
|
+
*
|
|
150
|
+
* export const HomeScreen: React.FC = () => {
|
|
151
|
+
* const { isLoaded, error } = useScreenTranslations(
|
|
152
|
+
* 'demo',
|
|
153
|
+
* 'home',
|
|
154
|
+
* translations
|
|
155
|
+
* );
|
|
156
|
+
*
|
|
157
|
+
* if (!isLoaded) return <LoadingSpinner />;
|
|
158
|
+
* if (error) return <ErrorMessage error={error} />;
|
|
159
|
+
*
|
|
160
|
+
* return <div>...</div>;
|
|
161
|
+
* };
|
|
162
|
+
* ```
|
|
163
|
+
*/
|
|
164
|
+
declare function useScreenTranslations(screensetId: string, screenId: string, translations: TranslationMap | TranslationLoader): UseScreenTranslationsReturn;
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* useNavigation Hook - Navigation utilities
|
|
168
|
+
*
|
|
169
|
+
* React Layer: L3
|
|
170
|
+
*/
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Hook for navigation utilities.
|
|
174
|
+
*
|
|
175
|
+
* @returns Navigation utilities
|
|
176
|
+
*
|
|
177
|
+
* @example
|
|
178
|
+
* ```tsx
|
|
179
|
+
* const { navigateToScreen, navigateToScreenset, currentScreen } = useNavigation();
|
|
180
|
+
*
|
|
181
|
+
* return (
|
|
182
|
+
* <button onClick={() => navigateToScreen('demo', 'home')}>
|
|
183
|
+
* Go to Home
|
|
184
|
+
* </button>
|
|
185
|
+
* );
|
|
186
|
+
* ```
|
|
187
|
+
*/
|
|
188
|
+
declare function useNavigation(): UseNavigationReturn;
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* useTheme Hook - Theme utilities
|
|
192
|
+
*
|
|
193
|
+
* React Layer: L3
|
|
194
|
+
*/
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Hook for theme utilities.
|
|
198
|
+
*
|
|
199
|
+
* @returns Theme utilities
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* ```tsx
|
|
203
|
+
* const { currentTheme, themes, setTheme } = useTheme();
|
|
204
|
+
*
|
|
205
|
+
* return (
|
|
206
|
+
* <select
|
|
207
|
+
* value={currentTheme}
|
|
208
|
+
* onChange={(e) => setTheme(e.target.value)}
|
|
209
|
+
* >
|
|
210
|
+
* {themes.map((theme) => (
|
|
211
|
+
* <option key={theme.id} value={theme.id}>
|
|
212
|
+
* {theme.name}
|
|
213
|
+
* </option>
|
|
214
|
+
* ))}
|
|
215
|
+
* </select>
|
|
216
|
+
* );
|
|
217
|
+
* ```
|
|
218
|
+
*/
|
|
219
|
+
declare function useTheme(): UseThemeReturn;
|
|
220
|
+
|
|
221
|
+
/**
|
|
222
|
+
* TextLoader Component - Prevents flash of untranslated content
|
|
223
|
+
*
|
|
224
|
+
* React Layer: L3
|
|
225
|
+
*/
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* TextLoader Component
|
|
229
|
+
*
|
|
230
|
+
* Generic wrapper for translated text that automatically shows a skeleton loader
|
|
231
|
+
* while translations are being loaded. This eliminates the need for manual
|
|
232
|
+
* loading state checks throughout the application.
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* ```tsx
|
|
236
|
+
* // Heading - default bg-muted skeleton
|
|
237
|
+
* <TextLoader skeletonClassName="h-10 w-64">
|
|
238
|
+
* <h1 className="text-4xl font-bold">{t('screen.title')}</h1>
|
|
239
|
+
* </TextLoader>
|
|
240
|
+
*
|
|
241
|
+
* // Button label - inherits button text color
|
|
242
|
+
* <Button>
|
|
243
|
+
* <TextLoader skeletonClassName="h-4 w-24" inheritColor>
|
|
244
|
+
* {t('button.submit')}
|
|
245
|
+
* </TextLoader>
|
|
246
|
+
* </Button>
|
|
247
|
+
* ```
|
|
248
|
+
*/
|
|
249
|
+
declare const TextLoader: React__default.FC<TextLoaderProps>;
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* AppRouter Component - Renders the active screen
|
|
253
|
+
*
|
|
254
|
+
* React Layer: L3
|
|
255
|
+
*/
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* AppRouter Component
|
|
259
|
+
*
|
|
260
|
+
* Renders the currently active screen based on navigation state.
|
|
261
|
+
* Handles lazy loading and error boundaries.
|
|
262
|
+
*
|
|
263
|
+
* @example
|
|
264
|
+
* ```tsx
|
|
265
|
+
* <HAI3Provider>
|
|
266
|
+
* <Layout>
|
|
267
|
+
* <AppRouter
|
|
268
|
+
* fallback={<LoadingSpinner />}
|
|
269
|
+
* errorFallback={(error) => <ErrorPage error={error} />}
|
|
270
|
+
* />
|
|
271
|
+
* </Layout>
|
|
272
|
+
* </HAI3Provider>
|
|
273
|
+
* ```
|
|
274
|
+
*/
|
|
275
|
+
declare const AppRouter: React__default.FC<AppRouterProps>;
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* UI Kit Registry Service
|
|
279
|
+
* Unified registry for UI components and icons
|
|
280
|
+
* Allows applications to register UI Kit implementations at runtime
|
|
281
|
+
*
|
|
282
|
+
* OPEN/CLOSED PRINCIPLE:
|
|
283
|
+
* - Registry is CLOSED for modification
|
|
284
|
+
* - UI elements register themselves at app level
|
|
285
|
+
* - UI Core depends on interfaces, not implementations
|
|
286
|
+
*/
|
|
287
|
+
|
|
288
|
+
declare class UiKitRegistry {
|
|
289
|
+
private components;
|
|
290
|
+
private icons;
|
|
291
|
+
/**
|
|
292
|
+
* Register a component implementation
|
|
293
|
+
*/
|
|
294
|
+
registerComponent<K extends ComponentName>(name: K, component: UiKitComponentMap[K]): void;
|
|
295
|
+
/**
|
|
296
|
+
* Register multiple components at once
|
|
297
|
+
* Type-safe: only accepts components defined in UiKitComponentMap
|
|
298
|
+
*/
|
|
299
|
+
registerComponents(components: Partial<UiKitComponentMap>): void;
|
|
300
|
+
/**
|
|
301
|
+
* Get a component by name
|
|
302
|
+
*/
|
|
303
|
+
getComponent<K extends ComponentName>(name: K): UiKitComponentMap[K];
|
|
304
|
+
/**
|
|
305
|
+
* Check if a component is registered
|
|
306
|
+
*/
|
|
307
|
+
hasComponent(name: ComponentName): boolean;
|
|
308
|
+
/**
|
|
309
|
+
* Get all registered component names
|
|
310
|
+
*/
|
|
311
|
+
getRegisteredComponents(): ComponentName[];
|
|
312
|
+
/**
|
|
313
|
+
* Register an icon
|
|
314
|
+
* Only accepts UiKitIcon enum or exported string constants
|
|
315
|
+
* NO hardcoded string literals
|
|
316
|
+
*/
|
|
317
|
+
registerIcon(id: UiKitIcon | string, icon: ReactNode): void;
|
|
318
|
+
/**
|
|
319
|
+
* Register multiple icons at once
|
|
320
|
+
* Only accepts UiKitIcon enum or exported string constants
|
|
321
|
+
* NO hardcoded string literals
|
|
322
|
+
*/
|
|
323
|
+
registerIcons(icons: Record<string, ReactNode>): void;
|
|
324
|
+
/**
|
|
325
|
+
* Get an icon by ID
|
|
326
|
+
* Accepts UiKitIcon enum or exported string constants
|
|
327
|
+
*/
|
|
328
|
+
getIcon(id: UiKitIcon | string): ReactNode | undefined;
|
|
329
|
+
/**
|
|
330
|
+
* Get all registered icons
|
|
331
|
+
*/
|
|
332
|
+
getAllIcons(): Record<string, ReactNode>;
|
|
333
|
+
/**
|
|
334
|
+
* Check if an icon is registered
|
|
335
|
+
* Accepts UiKitIcon enum or exported string constants
|
|
336
|
+
*/
|
|
337
|
+
hasIcon(id: UiKitIcon | string): boolean;
|
|
338
|
+
/**
|
|
339
|
+
* Clear all registrations (for testing)
|
|
340
|
+
*/
|
|
341
|
+
clear(): void;
|
|
342
|
+
}
|
|
343
|
+
declare const uikitRegistry: UiKitRegistry;
|
|
344
|
+
|
|
345
|
+
export { AppRouter, AppRouterProps, HAI3Context, HAI3Provider, HAI3ProviderProps, TextLoader, TextLoaderProps, UseNavigationReturn, UseScreenTranslationsReturn, UseThemeReturn, UseTranslationReturn, uikitRegistry, useAppDispatch, useAppSelector, useHAI3, useNavigation, useScreenTranslations, useTheme, useTranslation };
|