77 @update:model-value =" create"
88 >
99 <template #button >
10- <Button size =" icon" class =" size-6" >
11- <Icon name =" plus" class =" size-5" />
12- </Button >
10+ <slot >
11+ <Button size =" icon" class =" size-6" >
12+ <Icon name =" plus" class =" size-5" />
13+ </Button >
14+ </slot >
1315 </template >
1416 </SearchInput >
1517</template >
1820import { createPipe , isValidPipeName , type Pipe } from " ~/types" ;
1921import { pipes } from " ../Pipes" ;
2022
23+ const props = defineProps <{
24+ allowEmpty? : boolean ;
25+ }>();
26+
2127const emit = defineEmits <{
2228 create: [Pipe ];
29+ createEmpty: [];
2330}>();
2431
2532const { presets } = usePresets ();
@@ -44,18 +51,29 @@ const groups = computed(() => {
4451 items: (string | { label: string ; value: string })[];
4552 }[] = [];
4653
54+ if (props .allowEmpty ) {
55+ groups .push ({
56+ name: " " ,
57+ items: [
58+ {
59+ label: " Empty" ,
60+ value: " $empty" ,
61+ },
62+ ],
63+ });
64+ }
65+
4766 // Force the order
67+ if (presetsChoices .value .length > 0 ) {
68+ groups .push ({ name: " Preset" , items: presetsChoices .value });
69+ }
4870 groups .push ({ name: " DEV" , items: [] });
4971 groups .push ({ name: " Preset" , items: [] });
5072 groups .push ({ name: " Parser" , items: [] });
5173 groups .push ({ name: " Sanitizer" , items: [] });
5274 groups .push ({ name: " Render" , items: [] });
5375 groups .push ({ name: " Other" , items: [] });
5476
55- if (presetsChoices .value .length > 0 ) {
56- groups .push ({ name: " Preset" , items: presetsChoices .value });
57- }
58-
5977 pipes .forEach ((pipe ) => {
6078 const group = groups .find ((g ) => g .name === pipe .category );
6179 if (group ) {
@@ -70,11 +88,15 @@ const groups = computed(() => {
7088});
7189
7290function create(name : string ) {
91+ if (name === " $empty" ) {
92+ emit (" createEmpty" );
93+ return ;
94+ }
7395 if (name .startsWith (" preset:" )) {
7496 const preset = presets .value .find ((p ) => p .id === name .slice (7 ));
7597 if (! preset ) return ;
7698 for (const pipe of preset .pipes ) {
77- emit (" create" , pipe );
99+ emit (" create" , clonePipe ( pipe ) );
78100 }
79101 } else if (isValidPipeName (name )) {
80102 const newPipe = createPipe (name );
0 commit comments