Skip to content

Commit c5e2ceb

Browse files
authored
feat: hide internal components in FormAdd (#88)
1 parent 828682b commit c5e2ceb

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

packages/former/src/components/FormAdd.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<template>
22
<div v-if="mode === 'build'" class="flex flex-col gap-2">
33
<div class="flex flex-col gap-4">
4-
<div v-for="(component, i) in components" :key="i" class="flex flex-col gap-2">
4+
<div v-for="[name, component] in relevantComponents" :key="name" class="flex flex-col gap-2">
55
<span>{{ component.label }}</span>
66

77
<div
88
class="flex gap-2 w-full items-center cursor-move hover:bg-blue-100 dark:hover:bg-zinc-700"
99
draggable="true"
10-
@dragstart="startDrag($event, i as string)"
10+
@dragstart="startDrag($event, name)"
1111
>
1212
<span class="drag-handle p-2">::</span>
1313

1414
<div class="flex flex-grow flex-col border dark:border-zinc-400 rounded p-2 gap-2">
1515
<div class="pointer-events-none">
16-
<component :is="component.component" :id="i" :model-value="undefined" :mode>
16+
<component :is="component.component" :id="name" :model-value="undefined" :mode>
1717
<slot />
1818
</component>
1919
</div>
@@ -39,4 +39,6 @@ provide('schema', ref([]));
3939
function startDrag(e: DragEvent, nodeType: string) {
4040
setDragEventData(e, formId.value, 'new_node_type', nodeType);
4141
}
42+
43+
const relevantComponents = Object.entries(components).filter(([, { internal }]) => !internal);
4244
</script>

packages/former/src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export type FormFieldType = {
3535
label: string;
3636
propsSchema: SchemaNode[];
3737
component: FormFieldComponent | Raw<FormFieldComponent>;
38+
internal?: boolean;
3839
};
3940

4041
export type FormComponents = { [key: string]: FormFieldType };

0 commit comments

Comments
 (0)