Skip to content

Commit e9b23dd

Browse files
committed
chore: change pathSelectable to nodeSelectable
1 parent e81c564 commit e9b23dd

File tree

6 files changed

+11
-12
lines changed

6 files changed

+11
-12
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ plugins: [
120120
| itemHeight | The height of node when using virtual | number | 20 |
121121
| selectedValue(v-model) | Selected data path | string, array | - |
122122
| rootPath | Root data path | string | `root` |
123-
| pathSelectable | Defines whether a path supports selection | (path, content) => boolean | - |
123+
| nodeSelectable | Defines whether a node supports selection | (node) => boolean | - |
124124
| selectableType | Support path select, default none | `multiple` \| `single` | - |
125125
| showSelectController | Show the select controller | boolean | false |
126126
| selectOnClickNode | Trigger select when click node | boolean | true |

README.zh_CN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
| 属性 | 说明 | 类型 | 默认值 |
1414
| ------------------------ | ------------------------------------------- | --------------------------------- | ------------- |
1515
| data(v-model) | 源数据,注意不是 `JSON` 字符串 | `JSON` 数据对象 | - |
16-
| deep | 深度,大于该深度的路径将被折叠 | number | Infinity |
16+
| deep | 深度,大于该深度的节点将被折叠 | number | Infinity |
1717
| showLength | 在数据折叠的时候展示长度 | boolean | false |
1818
| showLine | 展示标识线 | boolean | true |
1919
| showLineNumber | 展示行计数 | boolean | false |
@@ -24,7 +24,7 @@
2424
| itemHeight | 使用虚拟滚动时,定义节点高度 | number | 20 |
2525
| selectedValue(v-model) | 双向绑定选中的数据路径 | string, array | string, array |
2626
| rootPath | 定义最顶层数据路径 | string | `root` |
27-
| pathSelectable | 定义哪些数据路径可以被选择 | function(path, content) | - |
27+
| nodeSelectable | 定义哪些数据节点可以被选择 | function(node) | - |
2828
| selectableType | 定义选择功能,默认无 | `multiple` \| `single` | - |
2929
| showSelectController | 展示选择器 | boolean | false |
3030
| selectOnClickNode | 支持点击节点的时候触发选择 | boolean | true |

example/SelectControl.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@
7878
:show-line-number="state.showLineNumber"
7979
:select-on-click-node="state.selectOnClickNode"
8080
:collapsed-on-click-brackets="state.collapsedOnClickBrackets"
81-
:path-selectable="(path, data) => typeof state.data !== 'number'"
81+
:node-selectable="node => typeof node.content !== 'number'"
8282
:selectable-type="state.selectableType"
8383
:show-select-controller="state.showSelectController"
8484
:show-icon="state.showIcon"

example/VirtualList.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
</div>
3030
</div>
3131
<div class="block">
32-
<h3>vue-json-pretty(1000+ items):</h3>
32+
<h3>vue-json-pretty(10000+ items):</h3>
3333
<vue-json-pretty
3434
:virtual="true"
3535
:item-height="+state.itemHeight"
@@ -52,7 +52,7 @@ const defaultData = {
5252
data: [],
5353
};
5454
55-
for (let i = 0; i < 1000; i++) {
55+
for (let i = 0; i < 10000; i++) {
5656
defaultData.data.push({
5757
news_id: i,
5858
title: 'iPhone X Review: Innovative future with real black technology',

src/components/Tree/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ export default defineComponent({
7777
'update:selectedValue',
7878
'update:data',
7979
],
80+
8081
setup(props, { emit, slots }) {
8182
const treeRef = ref<HTMLElement>();
8283

@@ -264,7 +265,7 @@ export default defineComponent({
264265
showLineNumber={props.showLineNumber}
265266
showSelectController={props.showSelectController}
266267
selectOnClickNode={props.selectOnClickNode}
267-
pathSelectable={props.pathSelectable}
268+
nodeSelectable={props.nodeSelectable}
268269
highlightSelectedNode={props.highlightSelectedNode}
269270
editable={props.editable}
270271
editableTrigger={props.editableTrigger}

src/components/TreeNode/index.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,8 @@ export const treeNodePropsPass = {
4747
default: true,
4848
},
4949
// When using the selectableType, define whether current path/content is enabled.
50-
pathSelectable: {
51-
type: Function as PropType<(path: string, content: unknown) => boolean>,
50+
nodeSelectable: {
51+
type: Function as PropType<(node: NodeDataType) => boolean>,
5252
default: (): boolean => true,
5353
},
5454
// Highlight current node when selected.
@@ -119,9 +119,7 @@ export default defineComponent({
119119

120120
// Whether the current node supports the selected function.
121121
const selectable = computed(
122-
() =>
123-
props.pathSelectable(props.node.path, props.node.content) &&
124-
(isMultiple.value || isSingle.value),
122+
() => props.nodeSelectable(props.node) && (isMultiple.value || isSingle.value),
125123
);
126124

127125
const state = reactive({

0 commit comments

Comments
 (0)