|
| 1 | +<script lang="ts" setup> |
| 2 | +import type { NodeProps } from '@vue-flow/core'; |
| 3 | +import { NodeResizer } from '@vue-flow/node-resizer'; |
| 4 | +
|
| 5 | +import type { DataContextMerger } from '@/types/graph'; |
| 6 | +import { ContextMergerModeEnum } from '@/types/enums'; |
| 7 | +
|
| 8 | +const emit = defineEmits(['updateNodeInternals', 'update:deleteNode', 'update:unlinkNode']); |
| 9 | +
|
| 10 | +// --- Composables --- |
| 11 | +const { getBlockById } = useBlocks(); |
| 12 | +const blockDefinition = getBlockById('primary-context-merger'); |
| 13 | +
|
| 14 | +// --- Routing --- |
| 15 | +const route = useRoute(); |
| 16 | +const graphId = computed(() => (route.params.id as string) ?? ''); |
| 17 | +
|
| 18 | +// --- Props --- |
| 19 | +const props = defineProps<NodeProps<DataContextMerger>>(); |
| 20 | +
|
| 21 | +// --- Methods --- |
| 22 | +</script> |
| 23 | +<template> |
| 24 | + <NodeResizer |
| 25 | + :is-visible="true" |
| 26 | + :min-width="blockDefinition?.minSize?.width" |
| 27 | + :min-height="blockDefinition?.minSize?.height" |
| 28 | + color="transparent" |
| 29 | + :node-id="props.id" |
| 30 | + /> |
| 31 | + |
| 32 | + <UiGraphNodeUtilsRunToolbar |
| 33 | + :graph-id="graphId" |
| 34 | + :node-id="props.id" |
| 35 | + :selected="props.selected" |
| 36 | + source="input" |
| 37 | + :in-group="props.parentNodeId !== undefined" |
| 38 | + @update:delete-node="emit('update:deleteNode', props.id)" |
| 39 | + @update:unlink-node="emit('update:unlinkNode', props.id)" |
| 40 | + /> |
| 41 | + |
| 42 | + <div |
| 43 | + class="bg-golden-ochre border-golden-ochre-dark relative flex h-full w-full flex-col |
| 44 | + rounded-3xl border-2 p-4 pt-3 shadow-lg transition-all duration-200 ease-in-out" |
| 45 | + :class="{ |
| 46 | + 'opacity-50': props.dragging, |
| 47 | + 'shadow-golden-ochre-dark !shadow-[0px_0px_15px_3px]': props.selected, |
| 48 | + }" |
| 49 | + > |
| 50 | + <!-- Block Header --> |
| 51 | + <div class="mb-2 flex w-full items-center justify-center"> |
| 52 | + <label class="flex w-fit items-center gap-2"> |
| 53 | + <UiIcon |
| 54 | + :name="blockDefinition?.icon || ''" |
| 55 | + class="dark:text-soft-silk text-anthracite h-6 w-6 opacity-80" |
| 56 | + /> |
| 57 | + <span class="dark:text-soft-silk/80 text-anthracite text-lg font-bold"> |
| 58 | + {{ blockDefinition?.name }} |
| 59 | + </span> |
| 60 | + </label> |
| 61 | + </div> |
| 62 | + |
| 63 | + <!-- Block Content --> |
| 64 | + <div class="flex flex-1 items-center justify-center gap-4"> |
| 65 | + <!-- Choose between multiple input modes : full, summary, last_n --> |
| 66 | + <template |
| 67 | + v-for="mode in [ |
| 68 | + ContextMergerModeEnum.FULL, |
| 69 | + ContextMergerModeEnum.SUMMARY, |
| 70 | + ContextMergerModeEnum.LAST_N, |
| 71 | + ]" |
| 72 | + :key="mode" |
| 73 | + > |
| 74 | + <div |
| 75 | + class="flex w-fit items-center justify-between rounded-lg border bg-white/10 |
| 76 | + px-2 py-1 hover:bg-white/20" |
| 77 | + :class="{ |
| 78 | + 'border-golden-ochre-dark bg-white/20': props.data.mode === mode, |
| 79 | + 'hover:border-golden-ochre-dark/50 border-transparent': |
| 80 | + props.data.mode !== mode, |
| 81 | + }" |
| 82 | + @click="props.data.mode = mode" |
| 83 | + > |
| 84 | + <label class="dark:text-soft-silk text-anthracite font-medium capitalize"> |
| 85 | + {{ mode.replace('_', ' ') }} |
| 86 | + </label> |
| 87 | + </div> |
| 88 | + </template> |
| 89 | + </div> |
| 90 | + </div> |
| 91 | + |
| 92 | + <UiGraphNodeUtilsHandleContext |
| 93 | + :id="props.id" |
| 94 | + type="target" |
| 95 | + :node-id="props.id" |
| 96 | + :options="[]" |
| 97 | + :style="{ left: '50%' }" |
| 98 | + :is-dragging="props.dragging" |
| 99 | + class="handletopcustom" |
| 100 | + multiple-input |
| 101 | + /> |
| 102 | + <UiGraphNodeUtilsHandleContext |
| 103 | + :id="props.id" |
| 104 | + :node-id="props.id" |
| 105 | + :options="[]" |
| 106 | + type="source" |
| 107 | + :is-dragging="props.dragging" |
| 108 | + /> |
| 109 | +</template> |
| 110 | + |
| 111 | +<style> |
| 112 | +.handletopcustom > .vue-flow__handle { |
| 113 | + width: 150px !important; |
| 114 | +} |
| 115 | +</style> |
0 commit comments