forked from profectus/Profectus
Add joinJSX utility function
This commit is contained in:
parent
6f8ed688eb
commit
1729fa8561
1 changed files with 12 additions and 3 deletions
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue