From 6d5fa083d72a9b8891a2a6565090fadd68eb332a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Esnault?= Date: Thu, 3 Oct 2024 17:21:40 +0200 Subject: [PATCH 1/3] add isCheckable --- docs/components/CheckableItemSelection.vue | 50 ++++++++++++++++++++++ docs/components/DocNode.vue | 9 ++++ docs/partials/guides.pug | 5 +++ package.json | 2 +- src/components/Option.vue | 3 ++ src/mixins/treeselectMixin.js | 4 +- 6 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 docs/components/CheckableItemSelection.vue diff --git a/docs/components/CheckableItemSelection.vue b/docs/components/CheckableItemSelection.vue new file mode 100644 index 00000000..c8217235 --- /dev/null +++ b/docs/components/CheckableItemSelection.vue @@ -0,0 +1,50 @@ + + + diff --git a/docs/components/DocNode.vue b/docs/components/DocNode.vue index 3e291b8e..1f94fa65 100644 --- a/docs/components/DocNode.vue +++ b/docs/components/DocNode.vue @@ -49,6 +49,15 @@ here for detailed information. + + isChecakble + Boolean + + Used to make item checkable. See + here for detailed + information. + + isNew Boolean diff --git a/docs/partials/guides.pug b/docs/partials/guides.pug index 106f2051..4900a20b 100644 --- a/docs/partials/guides.pug +++ b/docs/partials/guides.pug @@ -94,6 +94,11 @@ Set `flattenSearchResults: true` to flatten the tree when searching. With this option set to `true`, only the results that match will be shown. With this set to `false` (default), its ancestors will also be displayed, even if they would not individually be included in the results. +demo('FlattenSearchResults') ++subsection('Checkable Item Selection') + :markdown-it + You can make item checkable by setting `isCheckable: true` on any leaf node or branch node. + +demo('CheckableItemSelection') + +subsection('Disable Item Selection') :markdown-it You can disable item selection by setting `isDisabled: true` on any leaf node or branch node. For non-flat mode, setting on a branch node will disable all its descendants as well. diff --git a/package.json b/package.json index a34032fa..c683e217 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@energiency/vue-treeselect", - "version": "1.0.1", + "version": "1.0.2-beta.1", "description": "A multi-select component with nested options support for Vue.js", "author": "Energiency ", "license": "MIT", diff --git a/src/components/Option.vue b/src/components/Option.vue index d6decf82..d8688b35 100755 --- a/src/components/Option.vue +++ b/src/components/Option.vue @@ -76,6 +76,9 @@ const renderCheckboxContainer = (h, context, children) => { if (instance.disableBranchNodes && node.isBranch) { return null; } + if (!node.isCheckable) { + return null; + } return
{children}
; }; diff --git a/src/mixins/treeselectMixin.js b/src/mixins/treeselectMixin.js index b3328724..dd4d6377 100644 --- a/src/mixins/treeselectMixin.js +++ b/src/mixins/treeselectMixin.js @@ -1687,6 +1687,7 @@ export default { const isDisabled = !!node.isDisabled || (!this.flat && !isRootNode && parentNode.isDisabled); + const isCheckable = node.isCheckable ?? true; const isNew = !!node.isNew; const lowerCased = this.matchKeys.reduce( (prev, key) => ({ @@ -1717,6 +1718,7 @@ export default { this.$set(normalized, "lowerCased", lowerCased); this.$set(normalized, "nestedSearchLabel", nestedSearchLabel); this.$set(normalized, "isDisabled", isDisabled); + this.$set(normalized, "isCheckable", isCheckable); this.$set(normalized, "isNew", isNew); this.$set(normalized, "isMatched", false); this.$set(normalized, "isHighlighted", false); @@ -1962,7 +1964,7 @@ export default { }, select(node) { - if (this.disabled || node.isDisabled) { + if (this.disabled || node.isDisabled || !node.isCheckable) { return; } From 857c65e213f90389de2cc82b04019d5c10e7d36a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9mie=20Ledentu?= Date: Mon, 7 Oct 2024 10:32:27 +0200 Subject: [PATCH 2/3] chore: revert version upgrade in package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index c683e217..a34032fa 100755 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@energiency/vue-treeselect", - "version": "1.0.2-beta.1", + "version": "1.0.1", "description": "A multi-select component with nested options support for Vue.js", "author": "Energiency ", "license": "MIT", From a2a0dcf7b847d9b8040d19a57c9bb4b4c2613c49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Esnault?= Date: Mon, 7 Oct 2024 10:42:45 +0200 Subject: [PATCH 3/3] fix typo --- docs/components/DocNode.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/components/DocNode.vue b/docs/components/DocNode.vue index 1f94fa65..7368cbf4 100644 --- a/docs/components/DocNode.vue +++ b/docs/components/DocNode.vue @@ -50,7 +50,7 @@ - isChecakble + isCheckable Boolean Used to make item checkable. See