From 42f2c6f96919b77d3b6d949316c34b6a13f3915f Mon Sep 17 00:00:00 2001 From: Jacob Walls Date: Mon, 9 Sep 2024 16:56:48 -0400 Subject: [PATCH] Tree: allow `filterBy` to be a getter --- apps/showcase/doc/common/apidoc/index.json | 4 ++-- packages/primevue/scripts/components/tree.js | 4 ++-- packages/primevue/src/tree/BaseTree.vue | 2 +- packages/primevue/src/tree/Tree.d.ts | 4 ++-- packages/primevue/src/tree/Tree.vue | 4 ++-- 5 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/showcase/doc/common/apidoc/index.json b/apps/showcase/doc/common/apidoc/index.json index 550ed5dbd2..43143d7952 100644 --- a/apps/showcase/doc/common/apidoc/index.json +++ b/apps/showcase/doc/common/apidoc/index.json @@ -65529,9 +65529,9 @@ "name": "filterBy", "optional": true, "readonly": false, - "type": "string", + "type": "string | ((node: TreeNode) => string)", "default": "label", - "description": "When filtering is enabled, filterBy decides which field or fields (comma separated) to search against." + "description": "When filtering is enabled, filterBy decides which field or fields (comma separated) to search against. A callable taking a TreeNode can be provided instead of a list of field names." }, { "name": "filterMode", diff --git a/packages/primevue/scripts/components/tree.js b/packages/primevue/scripts/components/tree.js index f0cba052cf..d0169aa6c9 100644 --- a/packages/primevue/scripts/components/tree.js +++ b/packages/primevue/scripts/components/tree.js @@ -50,9 +50,9 @@ const TreeProps = [ }, { name: 'filterBy', - type: 'string', + type: 'string | ((node: TreeNode) => string)', default: 'label', - description: 'When filtering is enabled, filterBy decides which field or fields (comma separated) to search against.' + description: 'When filtering is enabled, filterBy decides which field or fields (comma separated) to search against. A callable taking a TreeNode can be provided instead of a list of field names.' }, { name: 'filterMode', diff --git a/packages/primevue/src/tree/BaseTree.vue b/packages/primevue/src/tree/BaseTree.vue index e66e563f7e..32bfa5a582 100644 --- a/packages/primevue/src/tree/BaseTree.vue +++ b/packages/primevue/src/tree/BaseTree.vue @@ -43,7 +43,7 @@ export default { default: false }, filterBy: { - type: String, + type: String | ((node) => String), default: 'label' }, filterMode: { diff --git a/packages/primevue/src/tree/Tree.d.ts b/packages/primevue/src/tree/Tree.d.ts index 0c5cdd0f22..05b4d1cb30 100755 --- a/packages/primevue/src/tree/Tree.d.ts +++ b/packages/primevue/src/tree/Tree.d.ts @@ -277,10 +277,10 @@ export interface TreeProps { */ filter?: boolean | undefined; /** - * When filtering is enabled, filterBy decides which field or fields (comma separated) to search against. + * When filtering is enabled, filterBy decides which field or fields (comma separated) to search against. A callable taking a TreeNode can be provided instead of a list of field names. * @defaultValue label */ - filterBy?: string | undefined; + filterBy?: string | ((node: TreeNode) => string) | undefined; /** * Mode for filtering. * @defaultValue lenient diff --git a/packages/primevue/src/tree/Tree.vue b/packages/primevue/src/tree/Tree.vue index e85aa7d814..a71e46d644 100755 --- a/packages/primevue/src/tree/Tree.vue +++ b/packages/primevue/src/tree/Tree.vue @@ -42,7 +42,7 @@