Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/tree-select/demos/enUS/index.demo-entry.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ action.vue
async.vue
status.vue
file-picker.vue
node-display-mode.vue
debug.vue
```

Expand Down
171 changes: 171 additions & 0 deletions src/tree-select/demos/enUS/node-display-mode.demo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
<markdown>
# Node display mode

You can use `get-children` to implement different ways of displaying nodes.
</markdown>

<script lang="ts">
import type { TreeSelectOption } from 'naive-ui'
import { defineComponent, ref } from 'vue'

export default defineComponent({
setup() {
return {
active: ref(false),
handleUpdateValue(
value: string | number | Array<string | number> | null,
option: TreeSelectOption | null | Array<TreeSelectOption | null>
) {
console.log(value, option)
},
options: [
{
label: 'Rubber Soul',
key: 'Rubber Soul',
children: [
{
label:
'Everybody\'s Got Something to Hide Except Me and My Monkey',
key: 'Everybody\'s Got Something to Hide Except Me and My Monkey',
children: []
},
{
label: 'Drive My Car',
key: 'Drive My Car',
disabled: true,
children: []
},
{
label: 'Norwegian Wood',
key: 'Norwegian Wood',
children: []
},
{
label: 'You Won\'t See',
key: 'You Won\'t See',
disabled: true,
children: []
},
{
label: 'Nowhere Man',
key: 'Nowhere Man',
children: []
},
{
label: 'Think For Yourself',
key: 'Think For Yourself',
children: []
},
{
label: 'The Word',
key: 'The Word',
children: []
},
{
label: 'Michelle',
key: 'Michelle',
disabled: true,
children: []
},
{
label: 'What goes on',
key: 'What goes on',
children: []
},
{
label: 'Girl',
key: 'Girl',
children: []
},
{
label: 'I\'m looking through you',
key: 'I\'m looking through you',
children: []
},
{
label: 'In My Life',
key: 'In My Life',
children: []
},
{
label: 'Wait',
key: 'Wait',
children: []
}
]
},
{
label: 'Let It Be',
key: 'Let It Be Album',
children: [
{
label: 'Two Of Us',
key: 'Two Of Us'
},
{
label: 'Dig A Pony',
key: 'Dig A Pony'
},
{
label: 'Across The Universe',
key: 'Across The Universe'
},
{
label: 'I Me Mine',
key: 'I Me Mine'
},
{
label: 'Dig It',
key: 'Dig It'
},
{
label: 'Let It Be',
key: 'Let It Be'
},
{
label: 'Maggie Mae',
key: 'Maggie Mae'
},
{
label: 'I\'ve Got A Feeling',
key: 'I\'ve Got A Feeling'
},
{
label: 'One After 909',
key: 'One After 909'
},
{
label: 'The Long And Winding Road',
key: 'The Long And Winding Road'
},
{
label: 'For You Blue',
key: 'For You Blue'
},
{
label: 'Get Back',
key: 'Get Back'
}
]
}
]
}
}
})
</script>

<template>
<n-flex vertical align="start">
<n-switch v-model:value="active" />
<n-tree-select
:options="options"
default-value="Drive My Car"
:get-children="
active
? (v) => (v.children?.length ? v.children : undefined)

Check failure on line 165 in src/tree-select/demos/enUS/node-display-mode.demo.vue

View workflow job for this annotation

GitHub Actions / lint (22)

Parameter 'v' implicitly has an 'any' type.
: undefined
"
@update:value="handleUpdateValue"
/>
</n-flex>
</template>
1 change: 1 addition & 0 deletions src/tree-select/demos/zhCN/index.demo-entry.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ multiple.vue
checkbox.vue
check-strategy.vue
filterable.vue
node-display-mode.vue
check-strategy-debug.vue
action.vue
async.vue
Expand Down
171 changes: 171 additions & 0 deletions src/tree-select/demos/zhCN/node-display-mode.demo.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
<markdown>
# 节点展示方式

你可以使用 `get-children` 实现不同的节点展示方式
</markdown>

<script lang="ts">
import type { TreeSelectOption } from 'naive-ui'
import { defineComponent, ref } from 'vue'

export default defineComponent({
setup() {
return {
active: ref(false),
handleUpdateValue(
value: string | number | Array<string | number> | null,
option: TreeSelectOption | null | Array<TreeSelectOption | null>
) {
console.log(value, option)
},
options: [
{
label: 'Rubber Soul',
key: 'Rubber Soul',
children: [
{
label:
'Everybody\'s Got Something to Hide Except Me and My Monkey',
key: 'Everybody\'s Got Something to Hide Except Me and My Monkey',
children: []
},
{
label: 'Drive My Car',
key: 'Drive My Car',
disabled: true,
children: []
},
{
label: 'Norwegian Wood',
key: 'Norwegian Wood',
children: []
},
{
label: 'You Won\'t See',
key: 'You Won\'t See',
disabled: true,
children: []
},
{
label: 'Nowhere Man',
key: 'Nowhere Man',
children: []
},
{
label: 'Think For Yourself',
key: 'Think For Yourself',
children: []
},
{
label: 'The Word',
key: 'The Word',
children: []
},
{
label: 'Michelle',
key: 'Michelle',
disabled: true,
children: []
},
{
label: 'What goes on',
key: 'What goes on',
children: []
},
{
label: 'Girl',
key: 'Girl',
children: []
},
{
label: 'I\'m looking through you',
key: 'I\'m looking through you',
children: []
},
{
label: 'In My Life',
key: 'In My Life',
children: []
},
{
label: 'Wait',
key: 'Wait',
children: []
}
]
},
{
label: 'Let It Be',
key: 'Let It Be Album',
children: [
{
label: 'Two Of Us',
key: 'Two Of Us'
},
{
label: 'Dig A Pony',
key: 'Dig A Pony'
},
{
label: 'Across The Universe',
key: 'Across The Universe'
},
{
label: 'I Me Mine',
key: 'I Me Mine'
},
{
label: 'Dig It',
key: 'Dig It'
},
{
label: 'Let It Be',
key: 'Let It Be'
},
{
label: 'Maggie Mae',
key: 'Maggie Mae'
},
{
label: 'I\'ve Got A Feeling',
key: 'I\'ve Got A Feeling'
},
{
label: 'One After 909',
key: 'One After 909'
},
{
label: 'The Long And Winding Road',
key: 'The Long And Winding Road'
},
{
label: 'For You Blue',
key: 'For You Blue'
},
{
label: 'Get Back',
key: 'Get Back'
}
]
}
]
}
}
})
</script>

<template>
<n-flex vertical align="start">
<n-switch v-model:value="active" />
<n-tree-select
:options="options"
default-value="Drive My Car"
:get-children="
active
? (v) => (v.children?.length ? v.children : undefined)

Check failure on line 165 in src/tree-select/demos/zhCN/node-display-mode.demo.vue

View workflow job for this annotation

GitHub Actions / lint (22)

Parameter 'v' implicitly has an 'any' type.
: undefined
"
@update:value="handleUpdateValue"
/>
</n-flex>
</template>
1 change: 1 addition & 0 deletions src/tree/demos/enUS/index.demo-entry.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ node-props.vue
show-line.vue
checkbox-placement.vue
override-click-behavior.vue
node-display-mode.vue
```

## API
Expand Down
Loading
Loading