import { defineComponent, ref, watch, type Ref, h } from 'vue' import type { LinkTooltipConfig } from '../slices' import { Icon } from '../../__internal__/components/icon' import { keepAlive } from '../../__internal__/keep-alive' keepAlive(h) type EditLinkProps = { config: Ref src: Ref onConfirm: (href: string) => void onCancel: () => void } export const EditLink = defineComponent({ props: { config: { type: Object, required: true, }, src: { type: Object, required: true, }, onConfirm: { type: Function, required: true, }, onCancel: { type: Function, required: true, }, }, setup({ config, src, onConfirm, onCancel }) { const link = ref(src) watch(src, (value) => { link.value = value }) const onConfirmEdit = () => { onConfirm(link.value) } const onKeydown = (e: KeyboardEvent) => { e.stopPropagation() if (e.key === 'Enter') { e.preventDefault() onConfirmEdit() } if (e.key === 'Escape') { e.preventDefault() onCancel() } } return () => { return ( ) } }, })