@delightui/components 0.1.108 → 0.1.109
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/dist/cjs/components/utils/index.d.ts +2 -0
- package/dist/cjs/components/utils/useInflateView/index.d.ts +2 -0
- package/dist/cjs/components/utils/useInflateView/useInflateView.d.ts +42 -0
- package/dist/cjs/components/utils/useInflateView/useInflateView.types.d.ts +12 -0
- package/dist/cjs/library.js +1 -1
- package/dist/cjs/library.js.map +1 -1
- package/dist/esm/components/utils/index.d.ts +2 -0
- package/dist/esm/components/utils/useInflateView/index.d.ts +2 -0
- package/dist/esm/components/utils/useInflateView/useInflateView.d.ts +42 -0
- package/dist/esm/components/utils/useInflateView/useInflateView.types.d.ts +12 -0
- package/dist/esm/library.js +1 -1
- package/dist/esm/library.js.map +1 -1
- package/dist/index.d.ts +55 -2
- package/docs/README.md +3 -0
- package/docs/components/utils/useInflateView.md +442 -0
- package/package.json +1 -1
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
export { ConditionalView } from './ConditionalView';
|
|
2
2
|
export { WrapTextNodes } from './WrapTextNodes';
|
|
3
3
|
export { RenderStateView } from './RenderStateView';
|
|
4
|
+
export { useInflateView } from './useInflateView';
|
|
4
5
|
export type { AccessibilityActions, AccessibilityProps } from './accessibilityUtils';
|
|
5
6
|
export { getClickAccessibilityProps } from './accessibilityUtils';
|
|
6
7
|
export * from './ConditionalView';
|
|
7
8
|
export * from './WrapTextNodes';
|
|
8
9
|
export * from './RenderStateView';
|
|
10
|
+
export * from './useInflateView';
|
|
9
11
|
export * from './utils';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ComponentType, ReactElement } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* A hook that takes a component type and props and returns a memoized React element.
|
|
4
|
+
* This is useful for creating reusable component instances with memoization to prevent
|
|
5
|
+
* unnecessary re-renders when props haven't changed.
|
|
6
|
+
*
|
|
7
|
+
* @template T - The props type for the component
|
|
8
|
+
* @param Component - React component to render
|
|
9
|
+
* @param props - Props to pass to the component
|
|
10
|
+
* @returns Memoized React element
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* ```tsx
|
|
14
|
+
* const MyComponent = ({ title, count }) => (
|
|
15
|
+
* <div>
|
|
16
|
+
* <h1>{title}</h1>
|
|
17
|
+
* <p>Count: {count}</p>
|
|
18
|
+
* </div>
|
|
19
|
+
* );
|
|
20
|
+
*
|
|
21
|
+
* function ParentComponent() {
|
|
22
|
+
* const [count, setCount] = useState(0);
|
|
23
|
+
*
|
|
24
|
+
* // This view will only re-render when title or count changes
|
|
25
|
+
* const inflatedView = useInflateView(MyComponent, {
|
|
26
|
+
* title: 'My Title',
|
|
27
|
+
* count: count
|
|
28
|
+
* });
|
|
29
|
+
*
|
|
30
|
+
* return (
|
|
31
|
+
* <div>
|
|
32
|
+
* {inflatedView}
|
|
33
|
+
* <button onClick={() => setCount(c => c + 1)}>
|
|
34
|
+
* Increment
|
|
35
|
+
* </button>
|
|
36
|
+
* </div>
|
|
37
|
+
* );
|
|
38
|
+
* }
|
|
39
|
+
* ```
|
|
40
|
+
*/
|
|
41
|
+
export declare const useInflateView: <T extends Record<string, unknown>>(Component: ComponentType<T>, props: T) => ReactElement;
|
|
42
|
+
export default useInflateView;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ComponentType, ReactElement } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* Return type for the useInflateView hook.
|
|
4
|
+
*/
|
|
5
|
+
export type UseInflateViewReturn = ReactElement;
|
|
6
|
+
/**
|
|
7
|
+
* Parameters for the useInflateView hook.
|
|
8
|
+
*/
|
|
9
|
+
export type UseInflateViewParams<T extends Record<string, unknown>> = {
|
|
10
|
+
Component: ComponentType<T>;
|
|
11
|
+
props: T;
|
|
12
|
+
};
|