@ilokesto/utilinent 0.0.16 → 0.0.18
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.
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { ComponentPropsWithRef } from "react";
|
|
2
2
|
import { ShowProps, ShowPropsArray } from "../types";
|
|
3
|
+
type ShowTagHelper<K extends keyof JSX.IntrinsicElements> = {
|
|
4
|
+
<T extends unknown>(props: ShowProps<T> & ComponentPropsWithRef<K>): React.ReactNode;
|
|
5
|
+
<T extends unknown[]>(props: ShowPropsArray<T> & ComponentPropsWithRef<K>): React.ReactNode;
|
|
6
|
+
};
|
|
7
|
+
type ShowTagHelpers = {
|
|
8
|
+
[K in keyof JSX.IntrinsicElements]: ShowTagHelper<K>;
|
|
9
|
+
};
|
|
3
10
|
type ShowType = {
|
|
4
|
-
<T extends unknown[]>(props: ShowPropsArray<T>): React.ReactNode;
|
|
5
11
|
<T extends unknown>(props: ShowProps<T>): React.ReactNode;
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
<T extends unknown[]>(props: ShowPropsArray<T> & ComponentPropsWithRef<K>): React.ReactNode;
|
|
9
|
-
<T extends unknown>(props: ShowProps<T> & ComponentPropsWithRef<K>): React.ReactNode;
|
|
10
|
-
};
|
|
11
|
-
};
|
|
12
|
+
<T extends unknown[]>(props: ShowPropsArray<T>): React.ReactNode;
|
|
13
|
+
} & ShowTagHelpers;
|
|
12
14
|
export declare const Show: ShowType;
|
|
13
15
|
export {};
|
package/dist/components/Show.js
CHANGED
|
@@ -15,4 +15,8 @@ const renderForTag = (tag) => ({ when, children, fallback = null, ...props }) =>
|
|
|
15
15
|
const content = typeof children === "function" ? children(when) : children;
|
|
16
16
|
return createElement(tag, props, content);
|
|
17
17
|
};
|
|
18
|
-
|
|
18
|
+
const tagEntries = htmlTags.reduce((acc, tag) => {
|
|
19
|
+
acc[tag] = renderForTag(tag);
|
|
20
|
+
return acc;
|
|
21
|
+
}, {});
|
|
22
|
+
export const Show = Object.assign(BaseShow, tagEntries);
|