UNPKG

primevue

Version:

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![npm version](https://badge.fury.io/js/primevue.svg)](https://badge.fury.io/js/primevue) [![Discord Chat](https://img.shields.io/discord/55794023

2 lines (1 loc) 24.6 kB
import e from"primevue/icons/search";import t from"primevue/icons/spinner";import{DomHandler as n,ObjectUtils as o}from"primevue/utils";import i from"primevue/basecomponent";import{useStyle as r}from"primevue/usestyle";import l from"primevue/icons/check";import c from"primevue/icons/chevrondown";import a from"primevue/icons/chevronright";import s from"primevue/icons/minus";import d from"primevue/ripple";import{resolveComponent as u,resolveDirective as h,openBlock as p,createElementBlock as f,mergeProps as y,createElementVNode as g,withDirectives as b,createBlock as m,resolveDynamicComponent as v,normalizeClass as k,createCommentVNode as x,Fragment as S,createTextVNode as w,toDisplayString as C,renderList as K,renderSlot as I,vModelText as T,createVNode as O}from"vue";var N=r("\n.p-tree-container {\n margin: 0;\n padding: 0;\n list-style-type: none;\n overflow: auto;\n}\n\n.p-treenode-children {\n margin: 0;\n padding: 0;\n list-style-type: none;\n}\n\n.p-tree-wrapper {\n overflow: auto;\n}\n\n.p-treenode-selectable {\n cursor: pointer;\n user-select: none;\n}\n\n.p-tree-toggler {\n cursor: pointer;\n user-select: none;\n display: inline-flex;\n align-items: center;\n justify-content: center;\n overflow: hidden;\n position: relative;\n flex-shrink: 0;\n}\n\n.p-treenode-leaf > .p-treenode-content .p-tree-toggler {\n visibility: hidden;\n}\n\n.p-treenode-content {\n display: flex;\n align-items: center;\n}\n\n.p-tree-filter {\n width: 100%;\n}\n\n.p-tree-filter-container {\n position: relative;\n display: block;\n width: 100%;\n}\n\n.p-tree-filter-icon {\n position: absolute;\n top: 50%;\n margin-top: -0.5rem;\n}\n\n.p-tree-loading {\n position: relative;\n min-height: 4rem;\n}\n\n.p-tree .p-tree-loading-overlay {\n position: absolute;\n z-index: 1;\n display: flex;\n align-items: center;\n justify-content: center;\n}\n\n.p-tree-flex-scrollable {\n display: flex;\n flex: 1;\n height: 100%;\n flex-direction: column;\n}\n\n.p-tree-flex-scrollable .p-tree-wrapper {\n flex: 1;\n}\n",{name:"tree",manual:!0}),M={name:"BaseTree",extends:i,props:{value:{type:null,default:null},expandedKeys:{type:null,default:null},selectionKeys:{type:null,default:null},selectionMode:{type:String,default:null},metaKeySelection:{type:Boolean,default:!0},loading:{type:Boolean,default:!1},loadingIcon:{type:String,default:void 0},filter:{type:Boolean,default:!1},filterBy:{type:String,default:"label"},filterMode:{type:String,default:"lenient"},filterPlaceholder:{type:String,default:null},filterLocale:{type:String,default:void 0},scrollHeight:{type:String,default:null},level:{type:Number,default:0},"aria-labelledby":{type:String,default:null},"aria-label":{type:String,default:null}},css:{classes:{root:function(e){var t=e.props;return["p-tree p-component",{"p-tree-selectable":null!=t.selectionMode,"p-tree-loading":t.loading,"p-tree-flex-scrollable":"flex"===t.scrollHeight}]},loadingOverlay:"p-tree-loading-overlay p-component-overlay",loadingIcon:"p-tree-loading-icon",filterContainer:"p-tree-filter-container",input:"p-tree-filter p-inputtext p-component",searchIcon:"p-tree-filter-icon",wrapper:"p-tree-wrapper",container:"p-tree-container",node:function(e){return["p-treenode",{"p-treenode-leaf":e.instance.leaf}]},content:function(e){var t=e.instance;return["p-treenode-content",t.node.styleClass,{"p-treenode-selectable":t.selectable,"p-highlight":t.checkboxMode?t.checked:t.selected}]},toggler:"p-tree-toggler p-link",togglerIcon:"p-tree-toggler-icon",checkboxContainer:"p-checkbox p-component",checkbox:function(e){var t=e.instance;return["p-checkbox-box",{"p-highlight":t.checked,"p-indeterminate":t.partialChecked}]},checkboxIcon:"p-checkbox-icon",nodeIcon:function(e){return["p-treenode-icon",e.instance.node.icon]},label:"p-treenode-label",subgroup:"p-treenode-children"},loadStyle:N.load},provide:function(){return{$parentInstance:this}}};function A(e){return A="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},A(e)}function j(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=V(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var o=0,i=function(){};return{s:i,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,l=!0,c=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return l=e.done,e},e:function(e){c=!0,r=e},f:function(){try{l||null==n.return||n.return()}finally{if(c)throw r}}}}function P(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function E(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?P(Object(n),!0).forEach((function(t){$(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):P(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function $(e,t,n){return(t=D(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function D(e){var t=F(e,"string");return"symbol"===A(t)?t:String(t)}function F(e,t){if("object"!==A(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!==A(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function L(e){return _(e)||B(e)||V(e)||R()}function R(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function V(e,t){if(e){if("string"==typeof e)return U(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?U(e,t):void 0}}function B(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function _(e){if(Array.isArray(e))return U(e)}function U(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}var H={name:"TreeNode",hostName:"Tree",extends:i,emits:["node-toggle","node-click","checkbox-change"],props:{node:{type:null,default:null},expandedKeys:{type:null,default:null},selectionKeys:{type:null,default:null},selectionMode:{type:String,default:null},templates:{type:null,default:null},level:{type:Number,default:null},index:{type:Number,default:null}},nodeTouched:!1,toggleClicked:!1,mounted:function(){this.setAllNodesTabIndexes()},methods:{toggle:function(){this.$emit("node-toggle",this.node),this.toggleClicked=!0},label:function(e){return"function"==typeof e.label?e.label():e.label},onChildNodeToggle:function(e){this.$emit("node-toggle",e)},getPTOptions:function(e){return this.ptm(e,{context:{index:this.index,expanded:this.expanded,selected:this.selected,checked:this.checked,leaf:this.leaf}})},onClick:function(e){this.toggleClicked||n.getAttribute(e.target,'[data-pc-section="toggler"]')||n.getAttribute(e.target.parentElement,'[data-pc-section="toggler"]')?this.toggleClicked=!1:(this.isCheckboxSelectionMode()?this.toggleCheckbox():this.$emit("node-click",{originalEvent:e,nodeTouched:this.nodeTouched,node:this.node}),this.nodeTouched=!1)},onChildNodeClick:function(e){this.$emit("node-click",e)},onTouchEnd:function(){this.nodeTouched=!0},onKeyDown:function(e){if(this.isSameNode(e))switch(e.code){case"Tab":this.onTabKey(e);break;case"ArrowDown":this.onArrowDown(e);break;case"ArrowUp":this.onArrowUp(e);break;case"ArrowRight":this.onArrowRight(e);break;case"ArrowLeft":this.onArrowLeft(e);break;case"Enter":case"Space":this.onEnterKey(e)}},onArrowDown:function(e){var t="toggler"===e.target.getAttribute("data-pc-section")?e.target.closest('[role="treeitem"]'):e.target,n=t.children[1];if(n)this.focusRowChange(t,n.children[0]);else if(t.nextElementSibling)this.focusRowChange(t,t.nextElementSibling);else{var o=this.findNextSiblingOfAncestor(t);o&&this.focusRowChange(t,o)}e.preventDefault()},onArrowUp:function(e){var t=e.target;if(t.previousElementSibling)this.focusRowChange(t,t.previousElementSibling,this.findLastVisibleDescendant(t.previousElementSibling));else{var n=this.getParentNodeElement(t);n&&this.focusRowChange(t,n)}e.preventDefault()},onArrowRight:function(e){var t=this;this.leaf||this.expanded||(e.currentTarget.tabIndex=-1,this.$emit("node-toggle",this.node),this.$nextTick((function(){t.onArrowDown(e)})))},onArrowLeft:function(e){var t=n.findSingle(e.currentTarget,'[data-pc-section="toggler"]');if(0===this.level&&!this.expanded)return!1;if(this.expanded&&!this.leaf)return t.click(),!1;var o=this.findBeforeClickableNode(e.currentTarget);o&&this.focusRowChange(e.currentTarget,o)},onEnterKey:function(e){this.setTabIndexForSelectionMode(e,this.nodeTouched),this.onClick(e),e.preventDefault()},onTabKey:function(){this.setAllNodesTabIndexes()},setAllNodesTabIndexes:function(){var e=n.find(this.$refs.currentNode.closest('[data-pc-section="container"]'),'[role="treeitem"]'),t=L(e).some((function(e){return"true"===e.getAttribute("aria-selected")||"true"===e.getAttribute("aria-checked")}));(L(e).forEach((function(e){e.tabIndex=-1})),t)?L(e).filter((function(e){return"true"===e.getAttribute("aria-selected")||"true"===e.getAttribute("aria-checked")}))[0].tabIndex=0:L(e)[0].tabIndex=0},setTabIndexForSelectionMode:function(e,t){if(null!==this.selectionMode){var o=L(n.find(this.$refs.currentNode.parentElement,'[role="treeitem"]'));e.currentTarget.tabIndex=!1===t?-1:0,o.every((function(e){return-1===e.tabIndex}))&&(o[0].tabIndex=0)}},focusRowChange:function(e,t,n){e.tabIndex="-1",t.tabIndex="0",this.focusNode(n||t)},findBeforeClickableNode:function(e){var t=e.closest("ul").closest("li");if(t){var o=n.findSingle(t,"button");return o&&"hidden"!==o.style.visibility?t:this.findBeforeClickableNode(e.previousElementSibling)}return null},toggleCheckbox:function(){var e=this.selectionKeys?E({},this.selectionKeys):{},t=!this.checked;this.propagateDown(this.node,t,e),this.$emit("checkbox-change",{node:this.node,check:t,selectionKeys:e})},propagateDown:function(e,t,n){if(t?n[e.key]={checked:!0,partialChecked:!1}:delete n[e.key],e.children&&e.children.length){var o,i=j(e.children);try{for(i.s();!(o=i.n()).done;){this.propagateDown(o.value,t,n)}}catch(e){i.e(e)}finally{i.f()}}},propagateUp:function(e){var t,n=e.check,o=E({},e.selectionKeys),i=0,r=!1,l=j(this.node.children);try{for(l.s();!(t=l.n()).done;){var c=t.value;o[c.key]&&o[c.key].checked?i++:o[c.key]&&o[c.key].partialChecked&&(r=!0)}}catch(e){l.e(e)}finally{l.f()}n&&i===this.node.children.length?o[this.node.key]={checked:!0,partialChecked:!1}:(n||delete o[this.node.key],r||i>0&&i!==this.node.children.length?o[this.node.key]={checked:!1,partialChecked:!0}:delete o[this.node.key]),this.$emit("checkbox-change",{node:e.node,check:e.check,selectionKeys:o})},onChildCheckboxChange:function(e){this.$emit("checkbox-change",e)},findNextSiblingOfAncestor:function(e){var t=this.getParentNodeElement(e);return t?t.nextElementSibling?t.nextElementSibling:this.findNextSiblingOfAncestor(t):null},findLastVisibleDescendant:function(e){var t=e.children[1];return t?this.findLastVisibleDescendant(t.children[t.children.length-1]):e},getParentNodeElement:function(e){var t=e.parentElement.parentElement;return"treeitem"===n.getAttribute(t,"role")?t:null},focusNode:function(e){e.focus()},isCheckboxSelectionMode:function(){return"checkbox"===this.selectionMode},isSameNode:function(e){return e.currentTarget&&(e.currentTarget.isSameNode(e.target)||e.currentTarget.isSameNode(e.target.closest('[role="treeitem"]')))}},computed:{hasChildren:function(){return this.node.children&&this.node.children.length>0},expanded:function(){return this.expandedKeys&&!0===this.expandedKeys[this.node.key]},leaf:function(){return!1!==this.node.leaf&&!(this.node.children&&this.node.children.length)},selectable:function(){return!1!==this.node.selectable&&null!=this.selectionMode},selected:function(){return!(!this.selectionMode||!this.selectionKeys)&&!0===this.selectionKeys[this.node.key]},checkboxMode:function(){return"checkbox"===this.selectionMode&&!1!==this.node.selectable},checked:function(){return!!this.selectionKeys&&(this.selectionKeys[this.node.key]&&this.selectionKeys[this.node.key].checked)},partialChecked:function(){return!!this.selectionKeys&&(this.selectionKeys[this.node.key]&&this.selectionKeys[this.node.key].partialChecked)},ariaChecked:function(){return"single"===this.selectionMode||"multiple"===this.selectionMode?this.selected:void 0},ariaSelected:function(){return this.checkboxMode?this.checked:void 0}},components:{ChevronDownIcon:c,ChevronRightIcon:a,CheckIcon:l,MinusIcon:s},directives:{ripple:d}},W=["aria-label","aria-selected","aria-expanded","aria-setsize","aria-posinset","aria-level","aria-checked","tabindex"],z=["data-p-highlight","data-p-selectable"],q=["data-p-checked","data-p-partialchecked"];function G(e){return G="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},G(e)}function J(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=X(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var o=0,i=function(){};return{s:i,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var r,l=!0,c=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return l=e.done,e},e:function(e){c=!0,r=e},f:function(){try{l||null==n.return||n.return()}finally{if(c)throw r}}}}function Q(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function X(e,t){if(e){if("string"==typeof e)return ee(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ee(e,t):void 0}}function Y(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function Z(e){if(Array.isArray(e))return ee(e)}function ee(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function te(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function ne(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?te(Object(n),!0).forEach((function(t){oe(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):te(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function oe(e,t,n){return(t=ie(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ie(e){var t=re(e,"string");return"symbol"===G(t)?t:String(t)}function re(e,t){if("object"!==G(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!==G(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}H.render=function(e,t,n,o,i,r){var l=u("TreeNode",!0),c=h("ripple");return p(),f("li",y({ref:"currentNode",class:e.cx("node"),role:"treeitem","aria-label":r.label(n.node),"aria-selected":r.ariaSelected,"aria-expanded":r.expanded,"aria-setsize":n.node.children?n.node.children.length:0,"aria-posinset":n.index+1,"aria-level":n.level,"aria-checked":r.ariaChecked,tabindex:0===n.index?0:-1,onKeydown:t[3]||(t[3]=function(){return r.onKeyDown&&r.onKeyDown.apply(r,arguments)})},1===n.level?r.getPTOptions("node"):e.ptm("subgroup")),[g("div",y({class:e.cx("content"),onClick:t[1]||(t[1]=function(){return r.onClick&&r.onClick.apply(r,arguments)}),onTouchend:t[2]||(t[2]=function(){return r.onTouchEnd&&r.onTouchEnd.apply(r,arguments)}),style:n.node.style},r.getPTOptions("content"),{"data-p-highlight":r.checkboxMode?r.checked:r.selected,"data-p-selectable":r.selectable}),[b((p(),f("button",y({type:"button",class:e.cx("toggler"),onClick:t[0]||(t[0]=function(){return r.toggle&&r.toggle.apply(r,arguments)}),tabindex:"-1","aria-hidden":"true"},r.getPTOptions("toggler")),[n.templates.togglericon?(p(),m(v(n.templates.togglericon),{key:0,node:n.node,expanded:r.expanded,class:k(e.cx("togglerIcon"))},null,8,["node","expanded","class"])):r.expanded?(p(),m(v(n.node.expandedIcon?"span":"ChevronDownIcon"),y({key:1,class:e.cx("togglerIcon")},r.getPTOptions("togglerIcon")),null,16,["class"])):(p(),m(v(n.node.collapsedIcon?"span":"ChevronRightIcon"),y({key:2,class:e.cx("togglerIcon")},r.getPTOptions("togglerIcon")),null,16,["class"]))],16)),[[c]]),r.checkboxMode?(p(),f("div",y({key:0,class:e.cx("checkboxContainer"),"aria-hidden":"true"},r.getPTOptions("checkboxContainer")),[g("div",y({class:e.cx("checkbox"),role:"checkbox"},r.getPTOptions("checkbox"),{"data-p-checked":r.checked,"data-p-partialchecked":r.partialChecked}),[n.templates.checkboxicon?(p(),m(v(n.templates.checkboxicon),{key:0,checked:r.checked,partialChecked:r.partialChecked,class:k(e.cx("checkboxIcon"))},null,8,["checked","partialChecked","class"])):(p(),m(v(r.checked?"CheckIcon":r.partialChecked?"MinusIcon":null),y({key:1,class:e.cx("checkboxIcon")},r.getPTOptions("checkboxIcon")),null,16,["class"]))],16,q)],16)):x("",!0),g("span",y({class:e.cx("nodeIcon")},r.getPTOptions("nodeIcon")),null,16),g("span",y({class:e.cx("label")},r.getPTOptions("label")),[n.templates[n.node.type]||n.templates.default?(p(),m(v(n.templates[n.node.type]||n.templates.default),{key:0,node:n.node},null,8,["node"])):(p(),f(S,{key:1},[w(C(r.label(n.node)),1)],64))],16)],16,z),r.hasChildren&&r.expanded?(p(),f("ul",y({key:0,class:e.cx("subgroup"),role:"group"},e.ptm("subgroup")),[(p(!0),f(S,null,K(n.node.children,(function(t){return p(),m(l,{key:t.key,node:t,templates:n.templates,level:n.level+1,expandedKeys:n.expandedKeys,onNodeToggle:r.onChildNodeToggle,onNodeClick:r.onChildNodeClick,selectionMode:n.selectionMode,selectionKeys:n.selectionKeys,onCheckboxChange:r.propagateUp,pt:e.pt},null,8,["node","templates","level","expandedKeys","onNodeToggle","onNodeClick","selectionMode","selectionKeys","onCheckboxChange","pt"])})),128))],16)):x("",!0)],16,W)};var le={name:"Tree",extends:M,emits:["node-expand","node-collapse","update:expandedKeys","update:selectionKeys","node-select","node-unselect"],data:function(){return{d_expandedKeys:this.expandedKeys||{},filterValue:null}},watch:{expandedKeys:function(e){this.d_expandedKeys=e}},methods:{onNodeToggle:function(e){var t=e.key;this.d_expandedKeys[t]?(delete this.d_expandedKeys[t],this.$emit("node-collapse",e)):(this.d_expandedKeys[t]=!0,this.$emit("node-expand",e)),this.d_expandedKeys=ne({},this.d_expandedKeys),this.$emit("update:expandedKeys",this.d_expandedKeys)},onNodeClick:function(e){if(null!=this.selectionMode&&!1!==e.node.selectable){var t=!e.nodeTouched&&this.metaKeySelection?this.handleSelectionWithMetaKey(e):this.handleSelectionWithoutMetaKey(e);this.$emit("update:selectionKeys",t)}},onCheckboxChange:function(e){this.$emit("update:selectionKeys",e.selectionKeys),this.$emit(e.check?"node-select":"node-unselect",e.node)},handleSelectionWithMetaKey:function(e){var t,n=e.originalEvent,o=e.node,i=n.metaKey||n.ctrlKey;return this.isNodeSelected(o)&&i?(this.isSingleSelectionMode()?t={}:delete(t=ne({},this.selectionKeys))[o.key],this.$emit("node-unselect",o)):(this.isSingleSelectionMode()?t={}:this.isMultipleSelectionMode()&&(t=i&&this.selectionKeys?ne({},this.selectionKeys):{}),t[o.key]=!0,this.$emit("node-select",o)),t},handleSelectionWithoutMetaKey:function(e){var t,n=e.node,o=this.isNodeSelected(n);return this.isSingleSelectionMode()?o?(t={},this.$emit("node-unselect",n)):((t={})[n.key]=!0,this.$emit("node-select",n)):o?(delete(t=ne({},this.selectionKeys))[n.key],this.$emit("node-unselect",n)):((t=this.selectionKeys?ne({},this.selectionKeys):{})[n.key]=!0,this.$emit("node-select",n)),t},isSingleSelectionMode:function(){return"single"===this.selectionMode},isMultipleSelectionMode:function(){return"multiple"===this.selectionMode},isNodeSelected:function(e){return!(!this.selectionMode||!this.selectionKeys)&&!0===this.selectionKeys[e.key]},isChecked:function(e){return!!this.selectionKeys&&(this.selectionKeys[e.key]&&this.selectionKeys[e.key].checked)},isNodeLeaf:function(e){return!1!==e.leaf&&!(e.children&&e.children.length)},onFilterKeydown:function(e){13===e.which&&e.preventDefault()},findFilteredNodes:function(e,t){if(e){var n=!1;if(e.children){var o=Z(c=e.children)||Y(c)||X(c)||Q();e.children=[];var i,r=J(o);try{for(r.s();!(i=r.n()).done;){var l=ne({},i.value);this.isFilterMatched(l,t)&&(n=!0,e.children.push(l))}}catch(e){r.e(e)}finally{r.f()}}if(n)return!0}var c},isFilterMatched:function(e,t){var n,i=t.searchFields,r=t.filterText,l=t.strict,c=!1,a=J(i);try{for(a.s();!(n=a.n()).done;){String(o.resolveFieldData(e,n.value)).toLocaleLowerCase(this.filterLocale).indexOf(r)>-1&&(c=!0)}}catch(e){a.e(e)}finally{a.f()}return(!c||l&&!this.isNodeLeaf(e))&&(c=this.findFilteredNodes(e,{searchFields:i,filterText:r,strict:l})||c),c}},computed:{filteredValue:function(){var e,t=[],n=this.filterBy.split(","),o=this.filterValue.trim().toLocaleLowerCase(this.filterLocale),i="strict"===this.filterMode,r=J(this.value);try{for(r.s();!(e=r.n()).done;){var l=ne({},e.value),c={searchFields:n,filterText:o,strict:i};(i&&(this.findFilteredNodes(l,c)||this.isFilterMatched(l,c))||!i&&(this.isFilterMatched(l,c)||this.findFilteredNodes(l,c)))&&t.push(l)}}catch(e){r.e(e)}finally{r.f()}return t},valueToRender:function(){return this.filterValue&&this.filterValue.trim().length>0?this.filteredValue:this.value}},components:{TreeNode:H,SearchIcon:e,SpinnerIcon:t}},ce=["placeholder"],ae=["aria-labelledby","aria-label"];le.render=function(e,t,n,o,i,r){var l=u("SpinnerIcon"),c=u("SearchIcon"),a=u("TreeNode");return p(),f("div",y({class:e.cx("root")},e.ptm("root"),{"data-pc-name":"tree"}),[e.loading?(p(),f("div",y({key:0,class:e.cx("loadingOverlay")},e.ptm("loadingOverlay")),[I(e.$slots,"loadingicon",{class:k(e.cx("loadingIcon"))},(function(){return[e.loadingIcon?(p(),f("i",y({key:0,class:[e.cx("loadingIcon"),"pi-spin",e.loadingIcon]},e.ptm("loadingIcon")),null,16)):(p(),m(l,y({key:1,spin:"",class:e.cx("loadingIcon")},e.ptm("loadingIcon")),null,16,["class"]))]}))],16)):x("",!0),e.filter?(p(),f("div",y({key:1,class:e.cx("filterContainer")},e.ptm("filterContainer")),[b(g("input",y({"onUpdate:modelValue":t[0]||(t[0]=function(e){return i.filterValue=e}),type:"text",autocomplete:"off",class:e.cx("input"),placeholder:e.filterPlaceholder,onKeydown:t[1]||(t[1]=function(){return r.onFilterKeydown&&r.onFilterKeydown.apply(r,arguments)})},e.ptm("input")),null,16,ce),[[T,i.filterValue]]),I(e.$slots,"searchicon",{class:k(e.cx("searchIcon"))},(function(){return[O(c,y({class:e.cx("searchIcon")},e.ptm("searchIcon")),null,16,["class"])]}))],16)):x("",!0),g("div",y({class:e.cx("wrapper"),style:{maxHeight:e.scrollHeight}},e.ptm("wrapper")),[g("ul",y({class:e.cx("container"),role:"tree","aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel},e.ptm("container")),[(p(!0),f(S,null,K(r.valueToRender,(function(t,n){return p(),m(a,{key:t.key,node:t,templates:e.$slots,level:e.level+1,index:n,expandedKeys:i.d_expandedKeys,onNodeToggle:r.onNodeToggle,onNodeClick:r.onNodeClick,selectionMode:e.selectionMode,selectionKeys:e.selectionKeys,onCheckboxChange:r.onCheckboxChange,pt:e.pt},null,8,["node","templates","level","index","expandedKeys","onNodeToggle","onNodeClick","selectionMode","selectionKeys","onCheckboxChange","pt"])})),128))],16,ae)],16)],16)};export{le as default};