fansunited-management-components 1.50.7 → 1.50.9
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/index.es.js +2068 -2056
- package/index.umd.js +134 -134
- package/package.json +1 -1
- package/src/context/ComponentContext.d.ts +25 -0
- package/src/hooks/useComponentContext.d.ts +20 -3
- package/src/index.d.ts +4 -0
package/package.json
CHANGED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { default as React, PropsWithChildren, ReactNode } from 'react';
|
|
2
|
+
import { ComponentsMap } from '../constants/components';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Provides a registry of public Fans United components by name.
|
|
6
|
+
* Use `useComponentContext()` to resolve components dynamically with preserved types.
|
|
7
|
+
*/
|
|
8
|
+
type ComponentProviderProps = {
|
|
9
|
+
config?: any;
|
|
10
|
+
children?: ReactNode;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* React context mapping component names to their React function components.
|
|
14
|
+
* Uses explicit ComponentsMap interface to preserve individual component types.
|
|
15
|
+
*/
|
|
16
|
+
declare const ComponentContext: React.Context<ComponentsMap | null>;
|
|
17
|
+
/**
|
|
18
|
+
* Provider that exposes the components registry to descendants with preserved types.
|
|
19
|
+
* Each component maintains its original prop types and JSDoc documentation.
|
|
20
|
+
*
|
|
21
|
+
* @param {{ config?: any; children?: React.ReactNode }} props
|
|
22
|
+
* @returns {JSX.Element}
|
|
23
|
+
*/
|
|
24
|
+
declare const ComponentProvider: React.FC<ComponentProviderProps & PropsWithChildren>;
|
|
25
|
+
export { ComponentContext, ComponentProvider };
|
|
@@ -1,13 +1,30 @@
|
|
|
1
|
+
import { ComponentsMap } from '../constants/components';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Hook to access the registry of public components provided by ComponentProvider.
|
|
3
|
-
*
|
|
5
|
+
* Each component maintains its original type information, props, and JSDoc documentation.
|
|
4
6
|
*
|
|
5
|
-
* @returns {ComponentsMap} Registry of components with preserved types and JSDoc
|
|
7
|
+
* @returns {ComponentsMap} Registry of components with preserved individual types and JSDoc
|
|
6
8
|
* @throws {Error} If used outside of a ComponentProvider.
|
|
7
9
|
*
|
|
8
10
|
* @example
|
|
9
11
|
* ```tsx
|
|
10
12
|
* const { Spinner, Login } = useComponentContext();
|
|
13
|
+
* // TypeScript will now show:
|
|
14
|
+
* // - Spinner with proper props (my: number) and JSDoc
|
|
15
|
+
* // - Login with its specific props and JSDoc
|
|
11
16
|
* ```
|
|
12
17
|
*/
|
|
13
|
-
export declare const useComponentContext: () =>
|
|
18
|
+
export declare const useComponentContext: () => ComponentsMap;
|
|
19
|
+
/**
|
|
20
|
+
* Get a specific component with full type safety and JSDoc preservation.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```tsx
|
|
24
|
+
* const components = useComponentContext();
|
|
25
|
+
* const SpinnerComponent = getTypedComponent(components, 'Spinner');
|
|
26
|
+
* // SpinnerComponent now has full type info: React.FC<{my: number}>
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function getTypedComponent<K extends keyof ComponentsMap>(components: ComponentsMap, componentName: K): ComponentsMap[K];
|
|
30
|
+
export declare const useTypedComponentGetter: () => <K extends keyof ComponentsMap>(componentName: K) => ComponentsMap[K];
|
package/src/index.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { getTypedComponent } from './hooks/useComponentContext';
|
|
2
|
+
|
|
1
3
|
declare const _default: {
|
|
2
4
|
APIProvider: import('react').FC<{
|
|
3
5
|
config: any;
|
|
@@ -25,5 +27,7 @@ declare const _default: {
|
|
|
25
27
|
isMobile: boolean;
|
|
26
28
|
isPhone: boolean;
|
|
27
29
|
};
|
|
30
|
+
getTypedComponent: typeof getTypedComponent;
|
|
31
|
+
useTypedComponentGetter: () => <K extends keyof import('./constants/components').ComponentsMap>(componentName: K) => import('./constants/components').ComponentsMap[K];
|
|
28
32
|
};
|
|
29
33
|
export default _default;
|