@gears-frontx/react 0.1.0 → 0.2.0-alpha.2
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 +191 -45
- package/dist/index.cjs +1131 -392
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +418 -119
- package/dist/index.d.ts +418 -119
- package/dist/index.js +977 -242
- package/dist/index.js.map +1 -1
- package/dist/testing-Dlmfu6tE.d.cts +56 -0
- package/dist/testing-Dlmfu6tE.d.ts +56 -0
- package/dist/testing.cjs +77 -0
- package/dist/testing.cjs.map +1 -0
- package/dist/testing.d.cts +4 -0
- package/dist/testing.d.ts +4 -0
- package/dist/testing.js +54 -0
- package/dist/testing.js.map +1 -0
- package/dist/types-Cjd20AT-.d.cts +231 -0
- package/dist/types-Cjd20AT-.d.ts +231 -0
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +2 -2
- package/dist/types.d.ts +2 -2
- package/llms.txt +20 -20
- package/package.json +29 -18
- package/commands/hai3-duplicate-screenset.md +0 -58
- package/commands/hai3-new-component.md +0 -48
- package/commands/hai3-new-mfe.md +0 -166
- package/commands/hai3-new-screen.md +0 -39
- package/commands/hai3-new-screenset.md +0 -47
- package/dist/types-Cp8Zm5s0.d.cts +0 -136
- package/dist/types-Cp8Zm5s0.d.ts +0 -136
|
@@ -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 };
|
package/dist/types.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/types.ts"],"sourcesContent":["/**\n * @gears-frontx/react - Type Definitions\n *\n * Core types for
|
|
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 {
|
|
3
|
-
export {
|
|
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 {
|
|
3
|
-
export {
|
|
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
|
|
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
|
|
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
|
-
- [
|
|
10
|
-
- [MFE Components](https://
|
|
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
|
-
| `
|
|
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 {
|
|
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
|
-
<
|
|
41
|
+
<Gears FrontXProvider>
|
|
41
42
|
<Layout>
|
|
42
|
-
<
|
|
43
|
+
<MainScreen />
|
|
43
44
|
</Layout>
|
|
44
|
-
</
|
|
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 =
|
|
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
|
-
|
|
75
|
-
|
|
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,
|
|
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(
|
|
88
|
+
const theme = useSharedProperty(Gears FrontX_SHARED_PROPERTY_THEME);
|
|
89
89
|
|
|
90
90
|
const handleAction = async () => {
|
|
91
91
|
await bridge.executeActionsChain({
|
|
92
|
-
action: { type:
|
|
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://
|
|
121
|
-
- [Custom Hooks](https://
|
|
122
|
-
- [MFE Bridge Communication](https://
|
|
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.
|
|
4
|
-
"description": "React bindings and hooks for
|
|
3
|
+
"version": "0.2.0-alpha.2",
|
|
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",
|
|
@@ -21,31 +26,34 @@
|
|
|
21
26
|
"files": [
|
|
22
27
|
"dist",
|
|
23
28
|
"CLAUDE.md",
|
|
24
|
-
"llms.txt"
|
|
25
|
-
"commands"
|
|
29
|
+
"llms.txt"
|
|
26
30
|
],
|
|
27
31
|
"scripts": {
|
|
28
32
|
"build": "tsup",
|
|
29
33
|
"type-check": "tsc --noEmit",
|
|
30
|
-
"test": "
|
|
31
|
-
"test
|
|
34
|
+
"type-check:test": "tsc -p tsconfig.test.json",
|
|
35
|
+
"test": "npm run test:unit",
|
|
36
|
+
"test:unit": "vitest --run --passWithNoTests=false",
|
|
37
|
+
"test:unit:watch": "vitest --watch"
|
|
32
38
|
},
|
|
33
|
-
"dependencies": {},
|
|
34
39
|
"devDependencies": {
|
|
35
|
-
"
|
|
36
|
-
"
|
|
40
|
+
"@reduxjs/toolkit": "^2.5.0",
|
|
41
|
+
"@tanstack/react-query": "^5.90.0",
|
|
42
|
+
"@testing-library/react": "16.3.2",
|
|
43
|
+
"@types/react": "^19.2.18",
|
|
44
|
+
"@types/react-redux": "^7.1.33",
|
|
45
|
+
"@vitejs/plugin-react": "4.3.4",
|
|
46
|
+
"@vitest/coverage-v8": "4.1.4",
|
|
47
|
+
"jsdom": "26.1.0",
|
|
37
48
|
"react": "^19.2.4",
|
|
38
|
-
"@types/react": "^19.0.8",
|
|
39
49
|
"react-redux": "^9.1.0",
|
|
40
|
-
"
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"@testing-library/react": "^16.1.0",
|
|
44
|
-
"@reduxjs/toolkit": "^2.5.0",
|
|
45
|
-
"jsdom": "^25.0.1"
|
|
50
|
+
"tsup": "^8.0.0",
|
|
51
|
+
"typescript": "^5.4.2",
|
|
52
|
+
"vitest": "4.1.4"
|
|
46
53
|
},
|
|
47
54
|
"peerDependencies": {
|
|
48
55
|
"@gears-frontx/framework": "*",
|
|
56
|
+
"@tanstack/react-query": ">=5.0.0",
|
|
49
57
|
"react": "^19.2.4",
|
|
50
58
|
"react-redux": ">=8.0.0"
|
|
51
59
|
},
|
|
@@ -58,18 +66,21 @@
|
|
|
58
66
|
},
|
|
59
67
|
"react-redux": {
|
|
60
68
|
"optional": false
|
|
69
|
+
},
|
|
70
|
+
"@tanstack/react-query": {
|
|
71
|
+
"optional": false
|
|
61
72
|
}
|
|
62
73
|
},
|
|
63
74
|
"publishConfig": {
|
|
64
75
|
"access": "public"
|
|
65
76
|
},
|
|
66
77
|
"keywords": [
|
|
67
|
-
"
|
|
78
|
+
"frontx",
|
|
68
79
|
"react",
|
|
69
80
|
"hooks",
|
|
70
81
|
"provider",
|
|
71
82
|
"typescript"
|
|
72
83
|
],
|
|
73
|
-
"author": "
|
|
84
|
+
"author": "Cyber Fabric",
|
|
74
85
|
"license": "Apache-2.0"
|
|
75
86
|
}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
<!-- @standalone -->
|
|
2
|
-
# hai3:duplicate-screenset - Duplicate Screenset
|
|
3
|
-
|
|
4
|
-
## AI WORKFLOW (REQUIRED)
|
|
5
|
-
1) Read .ai/targets/SCREENSETS.md before starting.
|
|
6
|
-
2) Gather requirements from user.
|
|
7
|
-
3) Follow steps below.
|
|
8
|
-
|
|
9
|
-
REQUIRED: Copy folder and update ids.ts only (2 steps, 96% reduction).
|
|
10
|
-
REQUIRED: Pass arch:check with zero errors.
|
|
11
|
-
REQUIRED: Test via Chrome DevTools MCP (never skip).
|
|
12
|
-
|
|
13
|
-
## GATHER REQUIREMENTS
|
|
14
|
-
Ask user for:
|
|
15
|
-
- SOURCE screenset name (existing screenset to copy).
|
|
16
|
-
- TARGET screenset name (camelCase, single word preferred).
|
|
17
|
-
- TARGET category: Drafts | Mockups | Production.
|
|
18
|
-
|
|
19
|
-
## STEP 1: Copy Screenset via CLI
|
|
20
|
-
```bash
|
|
21
|
-
hai3 screenset copy SOURCE TARGET --category={category}
|
|
22
|
-
```
|
|
23
|
-
The CLI automatically:
|
|
24
|
-
- Copies all files (screens, slices, actions, events, effects, API, icons, i18n).
|
|
25
|
-
- Updates ids.ts with TARGET_SCREENSET_ID and all SCREEN_IDs.
|
|
26
|
-
- Everything auto-updates via template literals:
|
|
27
|
-
- Event enums: ${TARGET_SCREENSET_ID}/${DOMAIN_ID}/eventName.
|
|
28
|
-
- Icon IDs: ${TARGET_SCREENSET_ID}:iconName.
|
|
29
|
-
- API domain: ${TARGET_SCREENSET_ID}:serviceName.
|
|
30
|
-
- Redux state key.
|
|
31
|
-
- Screenset auto-discovered (no manual registration).
|
|
32
|
-
|
|
33
|
-
## STEP 2: Validate
|
|
34
|
-
```bash
|
|
35
|
-
npm run type-check
|
|
36
|
-
npm run arch:check
|
|
37
|
-
npm run lint
|
|
38
|
-
grep -rn "OLD_SCREENSET_ID" src/screensets/TARGET/ # Must return 0 matches
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
## STEP 3: Test via Chrome DevTools MCP
|
|
42
|
-
STOP: If MCP connection is broken, fix it first. NEVER skip testing.
|
|
43
|
-
- npm run dev.
|
|
44
|
-
- Verify TARGET in screenset selector.
|
|
45
|
-
- Click TARGET screenset in dev panel.
|
|
46
|
-
- Verify URL changes to target screenset.
|
|
47
|
-
- Check 0 console errors.
|
|
48
|
-
- Test all primary features.
|
|
49
|
-
- Verify auto-discovery worked (screenset appears without manual registration).
|
|
50
|
-
|
|
51
|
-
## CHECKLIST
|
|
52
|
-
- [ ] Gather requirements (source, target name, category).
|
|
53
|
-
- [ ] Run `hai3 screenset copy SOURCE TARGET --category={category}`.
|
|
54
|
-
- [ ] Run type-check (MUST pass).
|
|
55
|
-
- [ ] Run arch:check (MUST pass).
|
|
56
|
-
- [ ] Run lint (MUST pass).
|
|
57
|
-
- [ ] Verify zero occurrences of old screenset ID.
|
|
58
|
-
- [ ] Test via Chrome DevTools MCP (NEVER skip).
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
<!-- @standalone -->
|
|
2
|
-
# hai3:new-component - Add New UI Component
|
|
3
|
-
|
|
4
|
-
## AI WORKFLOW (REQUIRED)
|
|
5
|
-
1) Check for existing equivalent in project (e.g. components/ui/) and configured UI library first.
|
|
6
|
-
2) Gather requirements from user.
|
|
7
|
-
3) Implement.
|
|
8
|
-
|
|
9
|
-
## CHECK EXISTING COMPONENTS FIRST
|
|
10
|
-
- REQUIRED: Read `frontx.config.json` to find the `uikit` value.
|
|
11
|
-
- If uikit is a third-party package (not `shadcn` or `none`): read its exports from `node_modules/<package>/` to check for existing components.
|
|
12
|
-
- REQUIRED: Before creating a new component, scan the project AND the configured UI library for existing equivalents.
|
|
13
|
-
- REQUIRED: Reuse existing components if equivalent exists.
|
|
14
|
-
|
|
15
|
-
## GATHER REQUIREMENTS
|
|
16
|
-
Ask user for:
|
|
17
|
-
- Component name (e.g., "DataTable", "ColorPicker").
|
|
18
|
-
- Component description and props.
|
|
19
|
-
|
|
20
|
-
## IF SCREENSET COMPONENT
|
|
21
|
-
|
|
22
|
-
### STEP 0: Determine Subfolder
|
|
23
|
-
- components/ui/: Base UI primitives (shadcn components or custom).
|
|
24
|
-
- screens/{screen}/components/: Screen-specific components.
|
|
25
|
-
- components/: Shared composites used across screens.
|
|
26
|
-
|
|
27
|
-
### STEP 1: Implementation
|
|
28
|
-
|
|
29
|
-
#### 1.1 Create Component
|
|
30
|
-
File: src/components/ui/{ComponentName}.tsx (base primitives)
|
|
31
|
-
or: src/screens/{screen}/components/{ComponentName}.tsx (screen-specific)
|
|
32
|
-
or: src/components/{ComponentName}.tsx (shared composites)
|
|
33
|
-
- Must be reusable within the MFE.
|
|
34
|
-
- NO Redux or state management.
|
|
35
|
-
- Accept value/onChange pattern for state.
|
|
36
|
-
|
|
37
|
-
#### 1.2 Export
|
|
38
|
-
Export from local index if needed.
|
|
39
|
-
|
|
40
|
-
#### 1.3 Validation
|
|
41
|
-
Run: npm run arch:check && npm run dev
|
|
42
|
-
Test component in UI.
|
|
43
|
-
|
|
44
|
-
## RULES
|
|
45
|
-
- REQUIRED: Check existing project UI components first; create new only if missing.
|
|
46
|
-
- FORBIDDEN: Redux, business logic, side effects in components.
|
|
47
|
-
- FORBIDDEN: Inline styles outside components/ui/.
|
|
48
|
-
- REQUIRED: Accept value/onChange pattern for state.
|