-
{label}
-
- {refs.map((ref, idx) => {
- const props = resolveRefProps(ref, entries, typeEntryMap)
- return (
- onNavigate(props.target)}
- onRemove={onRemoveRef ? () => onRemoveRef(ref) : undefined}
- />
- )
- })}
-
- {onAddRef &&
}
-
- )
-}
-
-function extractRelationshipRefs(frontmatter: ParsedFrontmatter): { key: string; refs: string[] }[] {
- return Object.entries(frontmatter)
- .filter(([key, value]) => key !== 'Type' && (RELATIONSHIP_KEYS.has(key) || containsWikilinks(value)))
- .map(([key, value]) => {
- const refs: string[] = []
- if (typeof value === 'string' && isWikilink(value)) refs.push(value)
- else if (Array.isArray(value)) value.forEach(v => { if (typeof v === 'string' && isWikilink(v)) refs.push(v) })
- return { key, refs }
- })
- .filter(({ refs }) => refs.length > 0)
-}
-
-function NoteTargetInput({ entries, value, onChange, onSubmit, onCancel }: {
- entries: VaultEntry[]
- value: string
- onChange: (v: string) => void
- onSubmit?: () => void
- onCancel?: () => void
-}) {
- const [focused, setFocused] = useState(false)
- const search = useNoteSearch(entries, value, 8)
-
- const handleKeyDown = useCallback((e: React.KeyboardEvent) => {
- search.handleKeyDown(e)
- if (e.key === 'Enter') {
- e.preventDefault()
- if (search.selectedEntry) { onChange(search.selectedEntry.title); setFocused(false) }
- else onSubmit?.()
- } else if (e.key === 'Escape') { onCancel?.() }
- }, [search, onChange, onSubmit, onCancel])
-
- const showDropdown = focused && value.trim() && search.results.length > 0
-
- return (
-