@gears-frontx/react 0.1.0 → 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.
@@ -0,0 +1,231 @@
1
+ import * as React from 'react';
2
+ import { ReactNode } from 'react';
3
+ import { ChildMfeBridge, AccessRecord, AccessQuery, FrontXConfig, FrontXApp, RootState, Formatters, Language } from '@gears-frontx/framework';
4
+
5
+ /**
6
+ * MFE Context Value
7
+ * Contains bridge and metadata about the MFE instance.
8
+ */
9
+ interface MfeContextValue {
10
+ /** Child bridge for communication with host */
11
+ bridge: ChildMfeBridge;
12
+ /** Extension ID */
13
+ extensionId: string;
14
+ /** Domain ID where MFE is mounted */
15
+ domainId: string;
16
+ }
17
+ /**
18
+ * MFE Context
19
+ * Holds the MFE bridge and metadata for child components.
20
+ */
21
+ declare const MfeContext: React.Context<MfeContextValue | null>;
22
+ /**
23
+ * Use the MFE context.
24
+ * Throws if used outside of MFE context.
25
+ *
26
+ * @returns The MFE context value
27
+ */
28
+ declare function useMfeContext(): MfeContextValue;
29
+
30
+ /**
31
+ * @gears-frontx/react - Type Definitions
32
+ *
33
+ * Core types for FrontX React bindings.
34
+ * Provides type-safe hooks and components.
35
+ *
36
+ * Now using real imports from @gears-frontx/framework since packages are built together.
37
+ */
38
+
39
+ /**
40
+ * Gears FrontX-owned query result type.
41
+ * Returned by useApiQuery — callers depend on this contract, not on TanStack internals.
42
+ */
43
+ interface ApiQueryResult<TData, TError = Error> {
44
+ data: TData | undefined;
45
+ error: TError | null;
46
+ isLoading: boolean;
47
+ isFetching: boolean;
48
+ isError: boolean;
49
+ refetch: () => Promise<unknown>;
50
+ }
51
+ /**
52
+ * Gears FrontX-owned suspense query result type.
53
+ * Returned by useApiSuspenseQuery — callers depend on this contract, not on TanStack internals.
54
+ */
55
+ interface ApiSuspenseQueryResult<TData, TError = Error> {
56
+ data: TData;
57
+ error: TError | null;
58
+ isFetching: boolean;
59
+ refetch: () => Promise<void>;
60
+ }
61
+ /**
62
+ * Gears FrontX-owned infinite query result type.
63
+ * Returned by useApiInfiniteQuery for descriptor-driven pagination.
64
+ */
65
+ interface ApiInfiniteQueryResult<TPage, TError = Error> {
66
+ data: readonly TPage[] | undefined;
67
+ error: TError | null;
68
+ isLoading: boolean;
69
+ isFetching: boolean;
70
+ isError: boolean;
71
+ hasNextPage: boolean;
72
+ hasPreviousPage: boolean;
73
+ isFetchingNextPage: boolean;
74
+ isFetchingPreviousPage: boolean;
75
+ fetchNextPage: () => Promise<void>;
76
+ fetchPreviousPage: () => Promise<void>;
77
+ refetch: () => Promise<void>;
78
+ }
79
+ /**
80
+ * Gears FrontX-owned suspense infinite query result type.
81
+ * Returned by useApiSuspenseInfiniteQuery for descriptor-driven pagination.
82
+ */
83
+ interface ApiSuspenseInfiniteQueryResult<TPage, TError = Error> {
84
+ data: readonly TPage[];
85
+ error: TError | null;
86
+ isFetching: boolean;
87
+ hasNextPage: boolean;
88
+ hasPreviousPage: boolean;
89
+ isFetchingNextPage: boolean;
90
+ isFetchingPreviousPage: boolean;
91
+ fetchNextPage: () => Promise<void>;
92
+ fetchPreviousPage: () => Promise<void>;
93
+ refetch: () => Promise<void>;
94
+ }
95
+ /**
96
+ * Gears FrontX-owned mutation result type.
97
+ * Returned by useApiMutation — callers depend on this contract, not on TanStack internals.
98
+ */
99
+ interface ApiMutationResult<TData, TError = Error, TVariables = void> {
100
+ mutate: (variables: TVariables) => void;
101
+ mutateAsync: (variables: TVariables) => Promise<TData>;
102
+ isPending: boolean;
103
+ error: TError | null;
104
+ data: TData | undefined;
105
+ reset: () => void;
106
+ }
107
+ type Selector<TResult, TState = RootState> = (state: TState) => TResult;
108
+ type TranslationParams = Record<string, string | number | boolean>;
109
+ /**
110
+ * FrontX Provider Props
111
+ * Props for the main FrontXProvider component.
112
+ *
113
+ * @example
114
+ * ```tsx
115
+ * <FrontXProvider config={{ devMode: true }}>
116
+ * <App />
117
+ * </FrontXProvider>
118
+ *
119
+ * // With pre-built app
120
+ * const app = createFrontX().use(microfrontends()).build();
121
+ * <FrontXProvider app={app}>
122
+ * <App />
123
+ * </FrontXProvider>
124
+ *
125
+ * // With MFE bridge (for MFE components)
126
+ * <FrontXProvider mfeBridge={{ bridge, extensionId, domainId }}>
127
+ * <MyMfeApp />
128
+ * </FrontXProvider>
129
+ *
130
+ * // QueryCache is resolved from the app's plugin composition
131
+ * <FrontXProvider app={app}>
132
+ * <MyMfeApp />
133
+ * </FrontXProvider>
134
+ * ```
135
+ */
136
+ interface FrontXProviderProps {
137
+ /** Child components */
138
+ children: ReactNode;
139
+ /** FrontX configuration */
140
+ config?: FrontXConfig;
141
+ /** Pre-built FrontX app instance (optional) */
142
+ app?: FrontXApp;
143
+ /** MFE bridge context (for MFE components) */
144
+ mfeBridge?: MfeContextValue;
145
+ }
146
+ /**
147
+ * useFrontX Hook Return Type
148
+ * Returns the FrontX app instance from context.
149
+ */
150
+ type UseFrontXReturn = FrontXApp;
151
+ /**
152
+ * useAppSelector Hook
153
+ * Type-safe selector hook for Redux state.
154
+ *
155
+ * @template TResult - The result type of the selector
156
+ */
157
+ type UseAppSelector = <TResult>(selector: Selector<TResult>) => TResult;
158
+ /**
159
+ * useAppDispatch Hook Return Type
160
+ * Returns the typed dispatch function.
161
+ */
162
+ type UseAppDispatchReturn = (action: unknown) => unknown;
163
+ /**
164
+ * useTranslation Hook Return Type
165
+ * Translation utilities.
166
+ */
167
+ interface UseTranslationReturn {
168
+ /** Translate a key */
169
+ t: (key: string, params?: TranslationParams) => string;
170
+ /** Current language */
171
+ language: Language | null;
172
+ /** Change language */
173
+ setLanguage: (language: Language) => void;
174
+ /** Check if current language is RTL */
175
+ isRTL: boolean;
176
+ }
177
+ /**
178
+ * useScreenTranslations Hook Return Type
179
+ * Screen-level translation loading state.
180
+ */
181
+ interface UseScreenTranslationsReturn {
182
+ /** Whether translations are loaded */
183
+ isLoaded: boolean;
184
+ /** Loading error (if any) */
185
+ error: Error | null;
186
+ }
187
+ /**
188
+ * useTheme Hook Return Type
189
+ * Theme utilities.
190
+ */
191
+ interface UseThemeReturn {
192
+ /** Current theme ID */
193
+ currentTheme: string | undefined;
194
+ /** All available themes */
195
+ themes: Array<{
196
+ id: string;
197
+ name: string;
198
+ }>;
199
+ /** Change theme */
200
+ setTheme: (themeId: string) => void;
201
+ }
202
+ /**
203
+ * useFormatters Hook Return Type
204
+ * Locale-aware formatters (locale from i18nRegistry.getLanguage()).
205
+ * References @gears-frontx/i18n Formatters so signatures stay in sync.
206
+ */
207
+ type UseFormattersReturn = Formatters;
208
+ /**
209
+ * useCanAccess Hook Return Type
210
+ * Result of an RBAC access check.
211
+ * allow is false until an explicit 'allow' decision arrives (pessimistic default).
212
+ */
213
+ interface UseCanAccessResult {
214
+ allow: boolean;
215
+ isResolving: boolean;
216
+ }
217
+ /**
218
+ * CanAccess Component Props.
219
+ * Pessimistic: renders `denied` (or `loading`) until an authoritative 'allow' arrives.
220
+ */
221
+ interface CanAccessProps<TRecord extends AccessRecord = AccessRecord> {
222
+ query: AccessQuery<TRecord>;
223
+ /** Content rendered when access is explicitly allowed. */
224
+ allowed: ReactNode;
225
+ /** Content rendered on deny or error. Defaults to null. */
226
+ denied?: ReactNode;
227
+ /** Optional slot shown while the decision is resolving. Falls back to `denied`. */
228
+ loading?: ReactNode;
229
+ }
230
+
231
+ export { type ApiQueryResult as A, type CanAccessProps as C, type FrontXProviderProps as F, type MfeContextValue as M, type UseTranslationReturn as U, type ApiInfiniteQueryResult as a, type ApiMutationResult as b, type UseScreenTranslationsReturn as c, type UseFormattersReturn as d, type UseThemeReturn as e, type ApiSuspenseQueryResult as f, type ApiSuspenseInfiniteQueryResult as g, type UseCanAccessResult as h, MfeContext as i, type UseAppDispatchReturn as j, type UseAppSelector as k, type UseFrontXReturn as l, useMfeContext as u };
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/types.ts"],"sourcesContent":["/**\n * @gears-frontx/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 @gears-frontx/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 '@gears-frontx/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 @gears-frontx/store\ntype Selector<TResult, TState = RootState> = (state: TState) => TResult;\n\n// Language is imported from @gears-frontx/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 @gears-frontx/i18n Formatters so signatures stay in sync.\n */\nexport type UseFormattersReturn = Formatters;\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../src/types.ts"],"sourcesContent":["/**\n * @gears-frontx/react - Type Definitions\n *\n * Core types for FrontX React bindings.\n * Provides type-safe hooks and components.\n *\n * Now using real imports from @gears-frontx/framework since packages are built together.\n */\n\nimport type { ReactNode } from 'react';\nimport type {\n FrontXConfig,\n FrontXApp,\n RootState,\n Language,\n Formatters,\n AccessQuery,\n AccessRecord,\n} from '@gears-frontx/framework';\nimport type { MfeContextValue } from './mfe/MfeContext';\n\n// Re-export imported types for convenience\nexport type { FrontXConfig, FrontXApp };\n\n// ============================================================================\n// API Hook Result Types\n// ============================================================================\n\n/**\n * Gears FrontX-owned query result type.\n * Returned by useApiQuery — callers depend on this contract, not on TanStack internals.\n */\n// @cpt-FEATURE:implement-endpoint-descriptors:p3\n// @cpt-begin:implement-endpoint-descriptors:p3:inst-api-query-result\nexport interface ApiQueryResult<TData, TError = Error> {\n data: TData | undefined;\n error: TError | null;\n isLoading: boolean;\n isFetching: boolean;\n isError: boolean;\n refetch: () => Promise<unknown>;\n}\n// @cpt-end:implement-endpoint-descriptors:p3:inst-api-query-result\n\n/**\n * Gears FrontX-owned suspense query result type.\n * Returned by useApiSuspenseQuery — callers depend on this contract, not on TanStack internals.\n */\n// @cpt-begin:cpt-frontx-dod-request-lifecycle-use-api-query:p2:inst-suspense-query-result\nexport interface ApiSuspenseQueryResult<TData, TError = Error> {\n data: TData;\n error: TError | null;\n isFetching: boolean;\n refetch: () => Promise<void>;\n}\n// @cpt-end:cpt-frontx-dod-request-lifecycle-use-api-query:p2:inst-suspense-query-result\n\n/**\n * Gears FrontX-owned infinite query result type.\n * Returned by useApiInfiniteQuery for descriptor-driven pagination.\n */\n// @cpt-begin:cpt-frontx-dod-request-lifecycle-use-api-query:p2:inst-infinite-query-result\nexport interface ApiInfiniteQueryResult<TPage, TError = Error> {\n data: readonly TPage[] | undefined;\n error: TError | null;\n isLoading: boolean;\n isFetching: boolean;\n isError: boolean;\n hasNextPage: boolean;\n hasPreviousPage: boolean;\n isFetchingNextPage: boolean;\n isFetchingPreviousPage: boolean;\n fetchNextPage: () => Promise<void>;\n fetchPreviousPage: () => Promise<void>;\n refetch: () => Promise<void>;\n}\n// @cpt-end:cpt-frontx-dod-request-lifecycle-use-api-query:p2:inst-infinite-query-result\n\n/**\n * Gears FrontX-owned suspense infinite query result type.\n * Returned by useApiSuspenseInfiniteQuery for descriptor-driven pagination.\n */\n// @cpt-begin:cpt-frontx-dod-request-lifecycle-use-api-query:p2:inst-suspense-infinite-query-result\nexport interface ApiSuspenseInfiniteQueryResult<TPage, TError = Error> {\n data: readonly TPage[];\n error: TError | null;\n isFetching: boolean;\n hasNextPage: boolean;\n hasPreviousPage: boolean;\n isFetchingNextPage: boolean;\n isFetchingPreviousPage: boolean;\n fetchNextPage: () => Promise<void>;\n fetchPreviousPage: () => Promise<void>;\n refetch: () => Promise<void>;\n}\n// @cpt-end:cpt-frontx-dod-request-lifecycle-use-api-query:p2:inst-suspense-infinite-query-result\n\n/**\n * Gears FrontX-owned mutation result type.\n * Returned by useApiMutation — callers depend on this contract, not on TanStack internals.\n */\n// @cpt-begin:implement-endpoint-descriptors:p3:inst-api-mutation-result\nexport interface ApiMutationResult<TData, TError = Error, TVariables = void> {\n mutate: (variables: TVariables) => void;\n mutateAsync: (variables: TVariables) => Promise<TData>;\n isPending: boolean;\n error: TError | null;\n data: TData | undefined;\n reset: () => void;\n}\n// @cpt-end:implement-endpoint-descriptors:p3:inst-api-mutation-result\n\n// ============================================================================\n// Type Aliases\n// ============================================================================\n\n// From @gears-frontx/store\ntype Selector<TResult, TState = RootState> = (state: TState) => TResult;\n\n// Language is imported from @gears-frontx/framework\ntype TranslationParams = Record<string, string | number | boolean>;\n\n// ============================================================================\n// FrontX Provider Props\n// ============================================================================\n\n/**\n * FrontX Provider Props\n * Props for the main FrontXProvider component.\n *\n * @example\n * ```tsx\n * <FrontXProvider config={{ devMode: true }}>\n * <App />\n * </FrontXProvider>\n *\n * // With pre-built app\n * const app = createFrontX().use(microfrontends()).build();\n * <FrontXProvider app={app}>\n * <App />\n * </FrontXProvider>\n *\n * // With MFE bridge (for MFE components)\n * <FrontXProvider mfeBridge={{ bridge, extensionId, domainId }}>\n * <MyMfeApp />\n * </FrontXProvider>\n *\n * // QueryCache is resolved from the app's plugin composition\n * <FrontXProvider app={app}>\n * <MyMfeApp />\n * </FrontXProvider>\n * ```\n */\nexport interface FrontXProviderProps {\n /** Child components */\n children: ReactNode;\n /** FrontX configuration */\n config?: FrontXConfig;\n /** Pre-built FrontX app instance (optional) */\n app?: FrontXApp;\n /** MFE bridge context (for MFE components) */\n mfeBridge?: MfeContextValue;\n}\n\n// ============================================================================\n// Hook Return Types\n// ============================================================================\n\n/**\n * useFrontX Hook Return Type\n * Returns the FrontX app instance from context.\n */\nexport type UseFrontXReturn = FrontXApp;\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 @gears-frontx/i18n Formatters so signatures stay in sync.\n */\nexport type UseFormattersReturn = Formatters;\n\n/**\n * useCanAccess Hook Return Type\n * Result of an RBAC access check.\n * allow is false until an explicit 'allow' decision arrives (pessimistic default).\n */\nexport interface UseCanAccessResult {\n allow: boolean;\n isResolving: boolean;\n}\n\n/**\n * CanAccess Component Props.\n * Pessimistic: renders `denied` (or `loading`) until an authoritative 'allow' arrives.\n */\nexport interface CanAccessProps<TRecord extends AccessRecord = AccessRecord> {\n query: AccessQuery<TRecord>;\n /** Content rendered when access is explicitly allowed. */\n allowed: ReactNode;\n /** Content rendered on deny or error. Defaults to null. */\n denied?: ReactNode;\n /** Optional slot shown while the decision is resolving. Falls back to `denied`. */\n loading?: ReactNode;\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
package/dist/types.d.cts CHANGED
@@ -1,3 +1,3 @@
1
1
  import 'react';
2
- export { HAI3App, HAI3Config } from '@gears-frontx/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-Cp8Zm5s0.cjs';
2
+ export { FrontXApp, FrontXConfig } from '@gears-frontx/framework';
3
+ export { a as ApiInfiniteQueryResult, b as ApiMutationResult, A as ApiQueryResult, g as ApiSuspenseInfiniteQueryResult, f as ApiSuspenseQueryResult, C as CanAccessProps, F as FrontXProviderProps, j as UseAppDispatchReturn, k as UseAppSelector, h as UseCanAccessResult, d as UseFormattersReturn, l as UseFrontXReturn, c as UseScreenTranslationsReturn, e as UseThemeReturn, U as UseTranslationReturn } from './types-Cjd20AT-.cjs';
package/dist/types.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import 'react';
2
- export { HAI3App, HAI3Config } from '@gears-frontx/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-Cp8Zm5s0.js';
2
+ export { FrontXApp, FrontXConfig } from '@gears-frontx/framework';
3
+ export { a as ApiInfiniteQueryResult, b as ApiMutationResult, A as ApiQueryResult, g as ApiSuspenseInfiniteQueryResult, f as ApiSuspenseQueryResult, C as CanAccessProps, F as FrontXProviderProps, j as UseAppDispatchReturn, k as UseAppSelector, h as UseCanAccessResult, d as UseFormattersReturn, l as UseFrontXReturn, c as UseScreenTranslationsReturn, e as UseThemeReturn, U as UseTranslationReturn } from './types-Cjd20AT-.js';
package/llms.txt CHANGED
@@ -1,19 +1,20 @@
1
1
  # @gears-frontx/react
2
2
 
3
- > React bindings, hooks, and components for HAI3 SDK. Provides type-safe integration with React applications including MFE (Microfrontend) support.
3
+ > React bindings, hooks, and components for FrontX SDK. Provides type-safe integration with React applications including MFE (Microfrontend) support.
4
4
 
5
- Part of the HAI3 React Layer (L3) - depends on @gears-frontx/framework. Peer dependency on react and react-dom.
5
+ Part of the FrontX React Layer (L3) - depends on @gears-frontx/framework. Peer dependency on react and react-dom.
6
6
 
7
7
  ## Core API
8
8
 
9
- - [HAI3Provider](https://hai3.dev/docs/react/provider): Root context provider
10
- - [MFE Components](https://hai3.dev/docs/react/mfe): ExtensionDomainSlot, MfeProvider, RefContainerProvider
9
+ - [Gears FrontXProvider](https://frontx.dev/docs/react/provider): Root context provider
10
+ - [MFE Components](https://frontx.dev/docs/react/mfe): ExtensionDomainSlot, MfeProvider, RefContainerProvider
11
+ - `Gears FrontXProvider` resolves the shared `QueryClient` from `queryCache()` / `queryCacheShared()` through the app instance; mounted MFEs reuse the host cache by building their local app with `queryCacheShared()`, which joins the same shared `QueryClient` without mutating L1 contracts
11
12
 
12
13
  ## Hooks
13
14
 
14
15
  | Hook | Purpose |
15
16
  |------|---------|
16
- | `useHAI3()` | Access app instance |
17
+ | `useFrontX()` | Access app instance |
17
18
  | `useAppDispatch()` | Type-safe dispatch |
18
19
  | `useAppSelector()` | Type-safe selector |
19
20
  | `useTranslation()` | Translation utilities (t, language, setLanguage, isRTL) |
@@ -32,23 +33,23 @@ Part of the HAI3 React Layer (L3) - depends on @gears-frontx/framework. Peer dep
32
33
  ## Quick Start
33
34
 
34
35
  ```tsx
35
- import { HAI3Provider, ExtensionDomainSlot, useTranslation, useHAI3 } from '@gears-frontx/react';
36
+ import { Gears FrontXProvider, useTranslation, useFrontX } from '@gears-frontx/react';
36
37
 
37
38
  // Wrap app with provider
38
39
  function App() {
39
40
  return (
40
- <HAI3Provider>
41
+ <Gears FrontXProvider>
41
42
  <Layout>
42
- <ExtensionDomainSlot domainId="screen" fallback={<Loading />} />
43
+ <MainScreen />
43
44
  </Layout>
44
- </HAI3Provider>
45
+ </Gears FrontXProvider>
45
46
  );
46
47
  }
47
48
 
48
49
  // Use hooks in components
49
50
  function MyComponent() {
50
51
  const { t, isRTL } = useTranslation();
51
- const app = useHAI3();
52
+ const app = useFrontX();
52
53
 
53
54
  return (
54
55
  <div dir={isRTL ? 'rtl' : 'ltr'}>
@@ -66,13 +67,12 @@ function MyComponent() {
66
67
  import { ExtensionDomainSlot } from '@gears-frontx/react';
67
68
 
68
69
  function LayoutScreen() {
69
- const screenContainerRef = useRef<HTMLDivElement>(null);
70
-
71
70
  return (
72
71
  <ExtensionDomainSlot
72
+ registry={registry}
73
73
  domainId="screen"
74
- containerRef={screenContainerRef}
75
- fallback={<Loading />}
74
+ extensionId="home"
75
+ loadingComponent={<Loading />}
76
76
  />
77
77
  );
78
78
  }
@@ -81,15 +81,15 @@ function LayoutScreen() {
81
81
  ### Using MFE Bridge
82
82
 
83
83
  ```tsx
84
- import { useMfeBridge, useSharedProperty, HAI3_ACTION_LOAD_EXT, HAI3_SHARED_PROPERTY_THEME } from '@gears-frontx/react';
84
+ import { useMfeBridge, useSharedProperty, Gears FrontX_ACTION_LOAD_EXT, Gears FrontX_SHARED_PROPERTY_THEME } from '@gears-frontx/react';
85
85
 
86
86
  function MyExtension() {
87
87
  const bridge = useMfeBridge();
88
- const theme = useSharedProperty(HAI3_SHARED_PROPERTY_THEME);
88
+ const theme = useSharedProperty(Gears FrontX_SHARED_PROPERTY_THEME);
89
89
 
90
90
  const handleAction = async () => {
91
91
  await bridge.executeActionsChain({
92
- action: { type: HAI3_ACTION_LOAD_EXT, target: 'screen', payload: { extensionId: 'other' } }
92
+ action: { type: Gears FrontX_ACTION_LOAD_EXT, target: 'screen', payload: { extensionId: 'other' } }
93
93
  });
94
94
  };
95
95
 
@@ -117,6 +117,6 @@ function ScreenList() {
117
117
 
118
118
  ## Optional
119
119
 
120
- - [Screen Translations](https://hai3.dev/docs/react/translations): Per-screen lazy loading
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
120
+ - [Screen Translations](https://frontx.dev/docs/react/translations): Per-screen lazy loading
121
+ - [Custom Hooks](https://frontx.dev/docs/react/hooks): Building on FrontX hooks
122
+ - [MFE Bridge Communication](https://frontx.dev/docs/react/mfe-bridge): Parent-child patterns
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gears-frontx/react",
3
- "version": "0.1.0",
4
- "description": "React bindings and hooks for HAI3 framework",
3
+ "version": "0.2.0-alpha.0",
4
+ "description": "React bindings and hooks for FrontX framework",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
7
7
  "module": "./dist/index.js",
@@ -12,6 +12,11 @@
12
12
  "import": "./dist/index.js",
13
13
  "require": "./dist/index.cjs"
14
14
  },
15
+ "./testing": {
16
+ "types": "./dist/testing.d.ts",
17
+ "import": "./dist/testing.js",
18
+ "require": "./dist/testing.cjs"
19
+ },
15
20
  "./types": {
16
21
  "types": "./dist/types.d.ts",
17
22
  "import": "./dist/types.js",
@@ -27,25 +32,29 @@
27
32
  "scripts": {
28
33
  "build": "tsup",
29
34
  "type-check": "tsc --noEmit",
30
- "test": "vitest run",
31
- "test:watch": "vitest"
35
+ "type-check:test": "tsc -p tsconfig.test.json",
36
+ "test": "npm run test:unit",
37
+ "test:unit": "vitest --run --passWithNoTests=false",
38
+ "test:unit:watch": "vitest --watch"
32
39
  },
33
- "dependencies": {},
34
40
  "devDependencies": {
35
- "tsup": "^8.0.0",
36
- "typescript": "^5.4.2",
37
- "react": "^19.2.4",
41
+ "@reduxjs/toolkit": "^2.5.0",
42
+ "@tanstack/react-query": "^5.90.0",
43
+ "@testing-library/react": "16.3.2",
38
44
  "@types/react": "^19.0.8",
39
- "react-redux": "^9.1.0",
40
45
  "@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"
46
+ "@vitejs/plugin-react": "4.3.4",
47
+ "@vitest/coverage-v8": "4.1.4",
48
+ "jsdom": "26.1.0",
49
+ "react": "^19.2.4",
50
+ "react-redux": "^9.1.0",
51
+ "tsup": "^8.0.0",
52
+ "typescript": "^5.4.2",
53
+ "vitest": "4.1.4"
46
54
  },
47
55
  "peerDependencies": {
48
56
  "@gears-frontx/framework": "*",
57
+ "@tanstack/react-query": ">=5.0.0",
49
58
  "react": "^19.2.4",
50
59
  "react-redux": ">=8.0.0"
51
60
  },
@@ -58,18 +67,21 @@
58
67
  },
59
68
  "react-redux": {
60
69
  "optional": false
70
+ },
71
+ "@tanstack/react-query": {
72
+ "optional": false
61
73
  }
62
74
  },
63
75
  "publishConfig": {
64
76
  "access": "public"
65
77
  },
66
78
  "keywords": [
67
- "hai3",
79
+ "frontx",
68
80
  "react",
69
81
  "hooks",
70
82
  "provider",
71
83
  "typescript"
72
84
  ],
73
- "author": "HAI3",
85
+ "author": "Cyber Fabric",
74
86
  "license": "Apache-2.0"
75
87
  }
@@ -1,47 +0,0 @@
1
- <!-- @standalone -->
2
- # hai3:new-screenset - Create New Screenset
3
-
4
- ## PREREQUISITES (CRITICAL - STOP IF FAILED)
5
- Run `hai3 --version`.
6
- STOP: If fails, tell user to install.
7
- FORBIDDEN: Creating screenset manually or by copying peers.
8
-
9
- ## AI WORKFLOW (REQUIRED)
10
- 1) Check prerequisites above.
11
- 2) Read .ai/targets/SCREENSETS.md and .ai/targets/EVENTS.md before starting.
12
- 3) Gather requirements from user (including UI sections).
13
- 4) Implement.
14
-
15
- ## GATHER REQUIREMENTS
16
- Ask user for:
17
- - Screenset name (camelCase).
18
- - Category: Drafts | Mockups | Production.
19
- - Initial screens.
20
- - UI sections per screen (e.g., "stats cards, charts, activity feed").
21
-
22
- ## STEP 1: Implementation
23
- 1) Create screenset via `hai3 screenset create` (REQUIRED).
24
- 2) Create components BEFORE screen file per Component Plan.
25
- 3) Implement data flow per .ai/targets/EVENTS.md:
26
- - Actions emit events via eventBus.emit()
27
- - Effects subscribe and update slices
28
- - FORBIDDEN: Direct slice dispatch from components
29
- 4) Add API service with mocks.
30
- 5) Validate: `npm run type-check && npm run arch:check && npm run lint`.
31
- 6) Test via Chrome DevTools MCP (REQUIRED):
32
- - Navigate to new screenset
33
- - Verify screen renders without console errors
34
- - Test user interactions trigger correct events
35
- - Verify state updates via Redux DevTools
36
- - STOP if MCP connection fails
37
-
38
- ## COMPONENT PLAN
39
- - REQUIRED: Use local components (e.g. `components/ui/`) — no shared UI kit package.
40
- - components/ui/: base UI primitives (shadcn components or custom)
41
- - components/: multi-screen shared components
42
- - screens/{screen}/components/: screen-specific components
43
-
44
- ## DATA FLOW
45
- - Events: {domain events per EVENTS.md}
46
- - State: slices/, events/, effects/, actions/
47
- - API: api/{Name}ApiService.ts with mocks
@@ -1,136 +0,0 @@
1
- import * as React from 'react';
2
- import { ReactNode } from 'react';
3
- import { ChildMfeBridge, HAI3Config, HAI3App, RootState, Formatters, Language } from '@gears-frontx/framework';
4
-
5
- /**
6
- * MFE Context Value
7
- * Contains bridge and metadata about the MFE instance.
8
- */
9
- interface MfeContextValue {
10
- /** Child bridge for communication with host */
11
- bridge: ChildMfeBridge;
12
- /** Extension ID */
13
- extensionId: string;
14
- /** Domain ID where MFE is mounted */
15
- domainId: string;
16
- }
17
- /**
18
- * MFE Context
19
- * Holds the MFE bridge and metadata for child components.
20
- */
21
- declare const MfeContext: React.Context<MfeContextValue | null>;
22
- /**
23
- * Use the MFE context.
24
- * Throws if used outside of MFE context.
25
- *
26
- * @returns The MFE context value
27
- */
28
- declare function useMfeContext(): MfeContextValue;
29
-
30
- /**
31
- * @gears-frontx/react - Type Definitions
32
- *
33
- * Core types for HAI3 React bindings.
34
- * Provides type-safe hooks and components.
35
- *
36
- * Now using real imports from @gears-frontx/framework since packages are built together.
37
- */
38
-
39
- type Selector<TResult, TState = RootState> = (state: TState) => TResult;
40
- type TranslationParams = Record<string, string | number | boolean>;
41
- /**
42
- * HAI3 Provider Props
43
- * Props for the main HAI3Provider component.
44
- *
45
- * @example
46
- * ```tsx
47
- * <HAI3Provider config={{ devMode: true }}>
48
- * <App />
49
- * </HAI3Provider>
50
- *
51
- * // With pre-built app
52
- * const app = createHAI3().use(screensets()).use(microfrontends()).build();
53
- * <HAI3Provider app={app}>
54
- * <App />
55
- * </HAI3Provider>
56
- *
57
- * // With MFE bridge (for MFE components)
58
- * <HAI3Provider mfeBridge={{ bridge, extensionId, domainId }}>
59
- * <MyMfeApp />
60
- * </HAI3Provider>
61
- * ```
62
- */
63
- interface HAI3ProviderProps {
64
- /** Child components */
65
- children: ReactNode;
66
- /** HAI3 configuration */
67
- config?: HAI3Config;
68
- /** Pre-built HAI3 app instance (optional) */
69
- app?: HAI3App;
70
- /** MFE bridge context (for MFE components) */
71
- mfeBridge?: MfeContextValue;
72
- }
73
- /**
74
- * useHAI3 Hook Return Type
75
- * Returns the HAI3 app instance from context.
76
- */
77
- type UseHAI3Return = HAI3App;
78
- /**
79
- * useAppSelector Hook
80
- * Type-safe selector hook for Redux state.
81
- *
82
- * @template TResult - The result type of the selector
83
- */
84
- type UseAppSelector = <TResult>(selector: Selector<TResult>) => TResult;
85
- /**
86
- * useAppDispatch Hook Return Type
87
- * Returns the typed dispatch function.
88
- */
89
- type UseAppDispatchReturn = (action: unknown) => unknown;
90
- /**
91
- * useTranslation Hook Return Type
92
- * Translation utilities.
93
- */
94
- interface UseTranslationReturn {
95
- /** Translate a key */
96
- t: (key: string, params?: TranslationParams) => string;
97
- /** Current language */
98
- language: Language | null;
99
- /** Change language */
100
- setLanguage: (language: Language) => void;
101
- /** Check if current language is RTL */
102
- isRTL: boolean;
103
- }
104
- /**
105
- * useScreenTranslations Hook Return Type
106
- * Screen-level translation loading state.
107
- */
108
- interface UseScreenTranslationsReturn {
109
- /** Whether translations are loaded */
110
- isLoaded: boolean;
111
- /** Loading error (if any) */
112
- error: Error | null;
113
- }
114
- /**
115
- * useTheme Hook Return Type
116
- * Theme utilities.
117
- */
118
- interface UseThemeReturn {
119
- /** Current theme ID */
120
- currentTheme: string | undefined;
121
- /** All available themes */
122
- themes: Array<{
123
- id: string;
124
- name: string;
125
- }>;
126
- /** Change theme */
127
- setTheme: (themeId: string) => void;
128
- }
129
- /**
130
- * useFormatters Hook Return Type
131
- * Locale-aware formatters (locale from i18nRegistry.getLanguage()).
132
- * References @gears-frontx/i18n Formatters so signatures stay in sync.
133
- */
134
- type UseFormattersReturn = Formatters;
135
-
136
- export { type HAI3ProviderProps as H, type MfeContextValue as M, type UseTranslationReturn as U, type UseScreenTranslationsReturn as a, type UseFormattersReturn as b, type UseThemeReturn as c, MfeContext as d, type UseAppDispatchReturn as e, type UseAppSelector as f, type UseHAI3Return as g, useMfeContext as u };