﻿# nf-infinite-menu {#infinite-menu}

Data-driven recursive menus with custom fields, hidden/disabled items, routing and external links.

Import the components below; see the package README for standalone installation.

## Examples {#examples}

### Basic usage {#example-1}

### Basic usage
```vue
<script setup>
import { ref } from 'vue'
import { NfConfigProvider, NfInfiniteMenu, NfButton } from '@94ai-plus/common-ui'
const selected = ref('')
const data = ref([{ name: 'Workspace', index: 'workspace', children: [{ name: 'Overview', index: 'overview' }, { name: 'Reports', index: 'reports', children: [{ name: 'Daily', index: 'daily' }, { name: 'Monthly', index: 'monthly', disabled: true }] }] }, { name: 'Settings', index: 'settings' }, { name: 'Hidden', index: 'hidden', hidden: true }])
</script>

<template>
  <NfConfigProvider theme="chalk" locale="zh-CN">
    <NfButton @click="data[0].children[0].name = 'Updated overview'">Update data</NfButton>
    <NfInfiniteMenu :data="data" :router="false" default-active="settings" :default-openeds="['workspace']" @select="index => selected = index" style="max-width:320px" />
    <output>{{ selected }}</output>
  </NfConfigProvider>
</template>
```

### More examples 2 {#example-2}

### More examples 2
```vue
<script setup>
import { NfConfigProvider, NfInfiniteMenu } from '@94ai-plus/common-ui'
const data = [{ title: 'Tools', id: 'tools', nodes: [{ title: 'Vue', id: 'vue', link: 'https://vuejs.org/' }, { title: 'Disabled', id: 'disabled', disabled: true }] }]
</script>

<template>
  <NfConfigProvider theme="chalk" locale="zh-CN">
    <NfInfiniteMenu :data="data" name="title" index="id" children="nodes" index-prefix="docs-" :router="false" link :blank="true" mode="horizontal" />
  </NfConfigProvider>
</template>
```

### More examples 3 {#example-3}

### More examples 3
```vue
<script setup>
import { ref } from 'vue'
import { NfConfigProvider, NfInfiniteMenu, NfButton } from '@94ai-plus/common-ui'
const menu = ref()
const data = [{ name: 'Group', index: 'group', children: [{ name: 'Item', index: 'item' }] }]
</script>

<template>
  <NfConfigProvider theme="chalk" locale="zh-CN">
    <NfButton @click="menu.open('group')">Open</NfButton>
    <NfButton @click="menu.close('group')">Close</NfButton>
    <NfInfiniteMenu ref="menu" :data="data" :router="false" style="max-width:320px" />
  </NfConfigProvider>
</template>
```

## Props {#props}

| Name | Type | Default | Description |
| --- | --- | --- | --- |
| `data` | `MenuItem[]` | `required` | Menu tree; use unique index values. |
| `name / index / icon / children` | `string` | `name / index / icon / children` | Field names. Icon class is read from item.meta[icon]. |
| `indexPrefix` | `string` | `''` | Prepended to every menu index. |
| `router` | `boolean` | `true` | Element Plus router mode; set false without a router. |
| `link / blank` | `boolean` | `false / true` | External links / open a new tab. Link mode disables native router navigation. |
| `customClass / popperClass` | `string` | `''` | Menu / submenu popup class. |
| `showTimeout / hideTimeout` | `number` | `300 / 300` | Submenu delay in ms; per-item values override. |
| `disabled` | `boolean` | `false` | Disable all items. |
| `popperAppendToBody` | `boolean` | `true` | Submenu teleported; per-item false is preserved. |
| `...MenuProps` | `Element Plus Menu` | `native` | mode, collapse, defaultActive, defaultOpeneds, uniqueOpened, colors, etc. |

## Events {#events}

| Name | Type | Description |
| --- | --- | --- |
| `select / open / close` | `Element Plus Menu events` | All native listeners are forwarded. |

## Methods {#methods}

| Name | Type | Description |
| --- | --- | --- |
| `open(index) / close(index)` | `void` | Open or close a submenu. |
| `handleResize() / updateActiveIndex(index)` | `void` | Native menu methods. |

## Migration notes {#migration}

Data and field mappings remain reactive. Hidden items are omitted; a parent with no visible children becomes a leaf. false/0 overrides are preserved. Unsafe link schemes are rejected and new windows use noopener.
