Add joinJSX utility function

This commit is contained in:
thepaperpilot 2022-08-13 22:28:11 -05:00
parent 6f8ed688eb
commit 1729fa8561

View file

@ -12,7 +12,6 @@ import {
onUnmounted,
ref,
shallowRef,
toRef,
unref,
watchEffect
} from "vue";
@ -38,10 +37,10 @@ export function coerceComponent(
return component;
}
export type VueFeature = {
export interface VueFeature {
[ComponentKey]: GenericComponent;
[GatherProps]: () => Record<string, unknown>;
};
}
export function render(object: VueFeature | CoercableComponent): JSX.Element | DefineComponent {
if (isCoercableComponent(object)) {
@ -86,6 +85,16 @@ export function renderColJSX(...objects: (VueFeature | CoercableComponent)[]): J
return <Col>{objects.map(renderJSX)}</Col>;
}
export function joinJSX(objects: JSX.Element[], joiner: JSX.Element): JSX.Element {
return objects.reduce((acc, curr) => (
<>
{acc}
{joiner}
{curr}
</>
));
}
export function isCoercableComponent(component: unknown): component is CoercableComponent {
if (typeof component === "string") {
return true;