primevue 3.36.0 → 3.37.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +50 -20
- package/animate/Animate.d.ts +87 -0
- package/animate/animate.cjs.js +71 -0
- package/animate/animate.cjs.min.js +1 -0
- package/animate/animate.esm.js +65 -0
- package/animate/animate.esm.min.js +1 -0
- package/animate/animate.js +72 -0
- package/animate/animate.min.js +1 -0
- package/animate/package.json +6 -0
- package/animate/style/AnimateStyle.d.ts +3 -0
- package/animate/style/animatestyle.cjs.js +5 -0
- package/animate/style/animatestyle.cjs.min.js +1 -0
- package/animate/style/animatestyle.esm.js +3 -0
- package/animate/style/animatestyle.esm.min.js +1 -0
- package/animate/style/animatestyle.js +10 -0
- package/animate/style/animatestyle.min.js +1 -0
- package/animate/style/package.json +6 -0
- package/calendar/Calendar.vue +2 -2
- package/calendar/calendar.cjs.js +43 -42
- package/calendar/calendar.cjs.min.js +1 -1
- package/calendar/calendar.esm.js +43 -42
- package/calendar/calendar.esm.min.js +1 -1
- package/calendar/calendar.js +43 -42
- package/calendar/calendar.min.js +1 -1
- package/config/PrimeVue.d.ts +2 -0
- package/config/config.cjs.js +15 -13
- package/config/config.cjs.min.js +1 -1
- package/config/config.esm.js +15 -13
- package/config/config.esm.min.js +1 -1
- package/config/config.js +15 -13
- package/config/config.min.js +1 -1
- package/contextmenu/ContextMenu.d.ts +5 -0
- package/contextmenu/ContextMenuSub.vue +1 -0
- package/contextmenu/contextmenu.cjs.js +1 -0
- package/contextmenu/contextmenu.cjs.min.js +1 -1
- package/contextmenu/contextmenu.esm.js +1 -0
- package/contextmenu/contextmenu.esm.min.js +1 -1
- package/contextmenu/contextmenu.js +1 -0
- package/contextmenu/contextmenu.min.js +1 -1
- package/core/core.js +447 -392
- package/core/core.min.js +9 -7
- package/megamenu/MegaMenu.d.ts +5 -0
- package/megamenu/MegaMenuSub.vue +2 -1
- package/megamenu/megamenu.cjs.js +2 -1
- package/megamenu/megamenu.cjs.min.js +1 -1
- package/megamenu/megamenu.esm.js +2 -1
- package/megamenu/megamenu.esm.min.js +1 -1
- package/megamenu/megamenu.js +2 -1
- package/megamenu/megamenu.min.js +1 -1
- package/menu/Menu.d.ts +5 -0
- package/menu/Menu.vue +1 -1
- package/menu/Menuitem.vue +2 -1
- package/menu/menu.cjs.js +3 -2
- package/menu/menu.cjs.min.js +1 -1
- package/menu/menu.esm.js +3 -2
- package/menu/menu.esm.min.js +1 -1
- package/menu/menu.js +3 -2
- package/menu/menu.min.js +1 -1
- package/menubar/Menubar.d.ts +5 -0
- package/menubar/MenubarSub.vue +1 -0
- package/menubar/menubar.cjs.js +1 -0
- package/menubar/menubar.cjs.min.js +1 -1
- package/menubar/menubar.esm.js +1 -0
- package/menubar/menubar.esm.min.js +1 -1
- package/menubar/menubar.js +1 -0
- package/menubar/menubar.min.js +1 -1
- package/multiselect/MultiSelect.vue +4 -3
- package/multiselect/multiselect.cjs.js +4 -3
- package/multiselect/multiselect.cjs.min.js +1 -1
- package/multiselect/multiselect.esm.js +4 -3
- package/multiselect/multiselect.esm.min.js +1 -1
- package/multiselect/multiselect.js +4 -3
- package/multiselect/multiselect.min.js +1 -1
- package/overlaypanel/BaseOverlayPanel.vue +4 -0
- package/overlaypanel/OverlayPanel.d.ts +5 -0
- package/overlaypanel/OverlayPanel.vue +22 -0
- package/overlaypanel/overlaypanel.cjs.js +25 -0
- package/overlaypanel/overlaypanel.cjs.min.js +1 -1
- package/overlaypanel/overlaypanel.esm.js +25 -0
- package/overlaypanel/overlaypanel.esm.min.js +1 -1
- package/overlaypanel/overlaypanel.js +25 -0
- package/overlaypanel/overlaypanel.min.js +1 -1
- package/package.json +17 -3
- package/panelmenu/PanelMenu.d.ts +13 -0
- package/panelmenu/PanelMenu.vue +20 -2
- package/panelmenu/PanelMenuSub.vue +2 -1
- package/panelmenu/panelmenu.cjs.js +20 -5
- package/panelmenu/panelmenu.cjs.min.js +1 -1
- package/panelmenu/panelmenu.esm.js +20 -5
- package/panelmenu/panelmenu.esm.min.js +1 -1
- package/panelmenu/panelmenu.js +21 -6
- package/panelmenu/panelmenu.min.js +1 -1
- package/passthrough/tailwind/index.cjs.js +397 -371
- package/passthrough/tailwind/index.cjs.min.js +1 -1
- package/passthrough/tailwind/index.esm.js +397 -371
- package/passthrough/tailwind/index.esm.min.js +1 -1
- package/passthrough/tailwind/index.js +397 -371
- package/passthrough/tailwind/index.min.js +1 -1
- package/picklist/PickList.vue +2 -2
- package/picklist/picklist.cjs.js +2 -2
- package/picklist/picklist.cjs.min.js +1 -1
- package/picklist/picklist.esm.js +2 -2
- package/picklist/picklist.esm.min.js +1 -1
- package/picklist/picklist.js +2 -2
- package/picklist/picklist.min.js +1 -1
- package/resources/themes/arya-blue/theme.css +2 -2
- package/resources/themes/arya-green/theme.css +2 -2
- package/resources/themes/arya-orange/theme.css +2 -2
- package/resources/themes/arya-purple/theme.css +2 -2
- package/resources/themes/bootstrap4-dark-blue/theme.css +2 -2
- package/resources/themes/bootstrap4-dark-purple/theme.css +2 -2
- package/resources/themes/bootstrap4-light-blue/theme.css +2 -2
- package/resources/themes/bootstrap4-light-purple/theme.css +2 -2
- package/resources/themes/fluent-light/theme.css +2 -2
- package/resources/themes/lara-dark-blue/theme.css +587 -575
- package/resources/themes/lara-dark-indigo/theme.css +587 -575
- package/resources/themes/lara-dark-purple/theme.css +587 -575
- package/resources/themes/lara-dark-teal/theme.css +662 -650
- package/resources/themes/lara-light-blue/theme.css +629 -625
- package/resources/themes/lara-light-indigo/theme.css +629 -625
- package/resources/themes/lara-light-purple/theme.css +629 -625
- package/resources/themes/lara-light-teal/theme.css +879 -875
- package/resources/themes/luna-amber/theme.css +2 -2
- package/resources/themes/luna-blue/theme.css +2 -2
- package/resources/themes/luna-green/theme.css +2 -2
- package/resources/themes/luna-pink/theme.css +2 -2
- package/resources/themes/md-dark-deeppurple/theme.css +2 -2
- package/resources/themes/md-dark-indigo/theme.css +2 -2
- package/resources/themes/md-light-deeppurple/theme.css +2 -2
- package/resources/themes/md-light-indigo/theme.css +2 -2
- package/resources/themes/mdc-dark-deeppurple/theme.css +2 -2
- package/resources/themes/mdc-dark-indigo/theme.css +2 -2
- package/resources/themes/mdc-light-deeppurple/theme.css +2 -2
- package/resources/themes/mdc-light-indigo/theme.css +2 -2
- package/resources/themes/mira/theme.css +2 -2
- package/resources/themes/nano/theme.css +2 -2
- package/resources/themes/nova/theme.css +2 -2
- package/resources/themes/nova-accent/theme.css +2 -2
- package/resources/themes/nova-alt/theme.css +2 -2
- package/resources/themes/nova-vue/theme.css +2 -2
- package/resources/themes/rhea/theme.css +2 -2
- package/resources/themes/saga-blue/theme.css +2 -2
- package/resources/themes/saga-green/theme.css +2 -2
- package/resources/themes/saga-orange/theme.css +2 -2
- package/resources/themes/saga-purple/theme.css +2 -2
- package/resources/themes/soho-dark/theme.css +2 -2
- package/resources/themes/soho-light/theme.css +2 -2
- package/resources/themes/tailwind-light/theme.css +2 -2
- package/resources/themes/vela-blue/theme.css +2 -2
- package/resources/themes/vela-green/theme.css +2 -2
- package/resources/themes/vela-orange/theme.css +2 -2
- package/resources/themes/vela-purple/theme.css +2 -2
- package/resources/themes/viva-dark/theme.css +2 -2
- package/resources/themes/viva-light/theme.css +2 -2
- package/selectbutton/BaseSelectButton.vue +1 -1
- package/selectbutton/SelectButton.d.ts +2 -2
- package/selectbutton/SelectButton.vue +1 -1
- package/selectbutton/selectbutton.cjs.js +2 -2
- package/selectbutton/selectbutton.cjs.min.js +1 -1
- package/selectbutton/selectbutton.esm.js +2 -2
- package/selectbutton/selectbutton.esm.min.js +1 -1
- package/selectbutton/selectbutton.js +2 -2
- package/selectbutton/selectbutton.min.js +1 -1
- package/slider/Slider.vue +2 -2
- package/slider/slider.cjs.js +1 -1
- package/slider/slider.cjs.min.js +1 -1
- package/slider/slider.esm.js +1 -1
- package/slider/slider.esm.min.js +1 -1
- package/slider/slider.js +1 -1
- package/slider/slider.min.js +1 -1
- package/splitbutton/SplitButton.vue +4 -1
- package/splitbutton/splitbutton.cjs.js +3 -1
- package/splitbutton/splitbutton.cjs.min.js +1 -1
- package/splitbutton/splitbutton.esm.js +3 -1
- package/splitbutton/splitbutton.esm.min.js +1 -1
- package/splitbutton/splitbutton.js +3 -1
- package/splitbutton/splitbutton.min.js +1 -1
- package/styleclass/StyleClass.d.ts +6 -6
- package/tieredmenu/TieredMenu.d.ts +5 -0
- package/tieredmenu/TieredMenuSub.vue +2 -1
- package/tieredmenu/tieredmenu.cjs.js +2 -1
- package/tieredmenu/tieredmenu.cjs.min.js +1 -1
- package/tieredmenu/tieredmenu.esm.js +2 -1
- package/tieredmenu/tieredmenu.esm.min.js +1 -1
- package/tieredmenu/tieredmenu.js +2 -1
- package/tieredmenu/tieredmenu.min.js +1 -1
- package/tooltip/Tooltip.d.ts +6 -1
- package/tooltip/style/tooltipstyle.cjs.js +1 -1
- package/tooltip/style/tooltipstyle.cjs.min.js +1 -1
- package/tooltip/style/tooltipstyle.esm.js +1 -1
- package/tooltip/style/tooltipstyle.esm.min.js +1 -1
- package/tooltip/style/tooltipstyle.js +1 -1
- package/tooltip/style/tooltipstyle.min.js +1 -1
- package/tooltip/tooltip.cjs.js +15 -1
- package/tooltip/tooltip.cjs.min.js +1 -1
- package/tooltip/tooltip.esm.js +15 -1
- package/tooltip/tooltip.esm.min.js +1 -1
- package/tooltip/tooltip.js +15 -1
- package/tooltip/tooltip.min.js +1 -1
- package/tree/Tree.d.ts +6 -1
- package/tree/Tree.vue +1 -1
- package/tree/tree.cjs.js +1 -1
- package/tree/tree.cjs.min.js +1 -1
- package/tree/tree.esm.js +1 -1
- package/tree/tree.esm.min.js +1 -1
- package/tree/tree.js +1 -1
- package/tree/tree.min.js +1 -1
- package/treetable/TreeTable.d.ts +0 -18
- package/utils/utils.cjs.js +2 -2
- package/utils/utils.esm.js +2 -2
- package/utils/utils.js +2 -2
- package/vetur-attributes.json +4 -0
- package/vetur-tags.json +1 -0
- package/web-types.json +11 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var t=require("primevue/utils"),e=require("primevue/basedirective"),o=require("primevue/tooltip/style");function i(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}function n(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function l(t,e){if(t){if("string"==typeof t)return r(t,e);var o=Object.prototype.toString.call(t).slice(8,-1);return"Object"===o&&t.constructor&&(o=t.constructor.name),"Map"===o||"Set"===o?Array.from(t):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?r(t,e):void 0}}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var o=0,i=new Array(e);o<e;o++)i[o]=t[o];return i}function s(t,e){var o=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=o){var i,n,l,r,s=[],u=!0,a=!1;try{if(l=(o=o.call(t)).next,0===e){if(Object(o)!==o)return;u=!1}else for(;!(u=(i=l.call(o)).done)&&(s.push(i.value),s.length!==e);u=!0);}catch(t){a=!0,n=t}finally{try{if(!u&&null!=o.return&&(r=o.return(),Object(r)!==r))return}finally{if(a)throw n}}return s}}function u(t){if(Array.isArray(t))return t}function a(t){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a(t)}var p=i(e).default.extend({style:i(o).default}).extend("tooltip",{beforeMount:function(e,o){var i,n=this.getTarget(e);if(n.$_ptooltipModifiers=this.getModifiers(o),o.value){if("string"==typeof o.value)n.$_ptooltipValue=o.value,n.$_ptooltipDisabled=!1,n.$_ptooltipEscape=!1,n.$_ptooltipClass=null,n.$_ptooltipFitContent=!0,n.$_ptooltipIdAttr=t.UniqueComponentId()+"_tooltip",n.$_ptooltipShowDelay=0,n.$_ptooltipHideDelay=0;else if("object"===a(o.value)&&o.value){if(t.ObjectUtils.isEmpty(o.value.value)||""===o.value.value.trim())return;n.$_ptooltipValue=o.value.value,n.$_ptooltipDisabled=!!o.value.disabled===o.value.disabled&&o.value.disabled,n.$_ptooltipEscape=!!o.value.escape===o.value.escape&&o.value.escape,n.$_ptooltipClass=o.value.class||"",n.$_ptooltipFitContent=!!o.value.fitContent!==o.value.fitContent||o.value.fitContent,n.$_ptooltipIdAttr=o.value.id||t.UniqueComponentId()+"_tooltip",n.$_ptooltipShowDelay=o.value.showDelay||0,n.$_ptooltipHideDelay=o.value.hideDelay||0}n.$_ptooltipZIndex=null===(i=o.instance.$primevue)||void 0===i||null===(i=i.config)||void 0===i||null===(i=i.zIndex)||void 0===i?void 0:i.tooltip,this.bindEvents(n,o),e.setAttribute("data-pd-tooltip",!0)}},updated:function(e,o){var i=this.getTarget(e);if(i.$_ptooltipModifiers=this.getModifiers(o),this.unbindEvents(i),o.value)if("string"==typeof o.value)i.$_ptooltipValue=o.value,i.$_ptooltipDisabled=!1,i.$_ptooltipEscape=!1,i.$_ptooltipClass=null,i.$_ptooltipIdAttr=i.$_ptooltipIdAttr||t.UniqueComponentId()+"_tooltip",i.$_ptooltipShowDelay=0,i.$_ptooltipHideDelay=0,this.bindEvents(i,o);else if("object"===a(o.value)&&o.value){if(t.ObjectUtils.isEmpty(o.value.value)||""===o.value.value.trim())return void this.unbindEvents(i,o);i.$_ptooltipValue=o.value.value,i.$_ptooltipDisabled=!!o.value.disabled===o.value.disabled&&o.value.disabled,i.$_ptooltipEscape=!!o.value.escape===o.value.escape&&o.value.escape,i.$_ptooltipClass=o.value.class||"",i.$_ptooltipFitContent=!!o.value.fitContent!==o.value.fitContent||o.value.fitContent,i.$_ptooltipIdAttr=o.value.id||i.$_ptooltipIdAttr||t.UniqueComponentId()+"_tooltip",i.$_ptooltipShowDelay=o.value.showDelay||0,i.$_ptooltipHideDelay=o.value.hideDelay||0,this.bindEvents(i,o)}},unmounted:function(t,e){var o=this.getTarget(t);this.remove(o),this.unbindEvents(o,e),o.$_ptooltipScrollHandler&&(o.$_ptooltipScrollHandler.destroy(),o.$_ptooltipScrollHandler=null)},timer:void 0,methods:{bindEvents:function(t,e){var o=this;t.$_ptooltipModifiers.focus?(t.$_focusevent=function(t){return o.onFocus(t,e)},t.addEventListener("focus",t.$_focusevent),t.addEventListener("blur",this.onBlur.bind(this))):(t.$_mouseenterevent=function(t){return o.onMouseEnter(t,e)},t.addEventListener("mouseenter",t.$_mouseenterevent),t.addEventListener("mouseleave",this.onMouseLeave.bind(this)),t.addEventListener("click",this.onClick.bind(this))),t.addEventListener("keydown",this.onKeydown.bind(this))},unbindEvents:function(t){t.$_ptooltipModifiers.focus?(t.removeEventListener("focus",t.$_focusevent),t.$_focusevent=null,t.removeEventListener("blur",this.onBlur.bind(this))):(t.removeEventListener("mouseenter",t.$_mouseenterevent),t.$_mouseenterevent=null,t.removeEventListener("mouseleave",this.onMouseLeave.bind(this)),t.removeEventListener("click",this.onClick.bind(this))),t.removeEventListener("keydown",this.onKeydown.bind(this))},bindScrollListener:function(e){var o=this;e.$_ptooltipScrollHandler||(e.$_ptooltipScrollHandler=new t.ConnectedOverlayScrollHandler(e,(function(){o.hide(e)}))),e.$_ptooltipScrollHandler.bindScrollListener()},unbindScrollListener:function(t){t.$_ptooltipScrollHandler&&t.$_ptooltipScrollHandler.unbindScrollListener()},onMouseEnter:function(t,e){var o=t.currentTarget;this.show(o,e,o.$_ptooltipShowDelay)},onMouseLeave:function(t){var e=t.currentTarget;this.hide(e,e.$_ptooltipHideDelay)},onFocus:function(t,e){var o=t.currentTarget;this.show(o,e,o.$_ptooltipShowDelay)},onBlur:function(t){var e=t.currentTarget;this.hide(e,e.$_ptooltipHideDelay)},onClick:function(t){var e=t.currentTarget;this.hide(e,e.$_ptooltipHideDelay)},onKeydown:function(t){"Escape"===t.code&&this.hide(t.currentTarget,t.currentTarget.$_ptooltipHideDelay)},tooltipActions:function(e,o){if(!e.$_ptooltipDisabled&&t.DomHandler.isExist(e)){var i=this.create(e,o);this.align(e),!this.isUnstyled()&&t.DomHandler.fadeIn(i,250);var n=this;window.addEventListener("resize",(function o(){t.DomHandler.isTouchDevice()||n.hide(e),window.removeEventListener("resize",o)})),this.bindScrollListener(e),t.ZIndexUtils.set("tooltip",i,e.$_ptooltipZIndex)}},show:function(t,e,o){var i=this;void 0!==o?this.timer=setTimeout((function(){return i.tooltipActions(t,e)}),o):this.tooltipActions(t,e)},tooltipRemoval:function(t){this.remove(t),this.unbindScrollListener(t)},hide:function(t,e){var o=this;clearTimeout(this.timer),void 0!==e?setTimeout((function(){return o.tooltipRemoval(t)}),e):this.tooltipRemoval(t)},getTooltipElement:function(t){return document.getElementById(t.$_ptooltipId)},create:function(e,o){var i=e.$_ptooltipModifiers,n=t.DomHandler.createElement("div",{class:!this.isUnstyled()&&this.cx("arrow"),style:{top:null!=i&&i.bottom?"0":!(null!=i&&i.right||null!=i&&i.left)&&(null!=i&&i.right||null!=i&&i.left||null!=i&&i.top||null!=i&&i.bottom)?null:"50%",bottom:null!=i&&i.top?"0":null,left:(null==i||!i.right)&&(null!=i&&i.right||null!=i&&i.left||null!=i&&i.top||null!=i&&i.bottom)?null!=i&&i.top||null!=i&&i.bottom?"50%":null:"0",right:null!=i&&i.left?"0":null},"p-bind":this.ptm("arrow",{context:i})}),l=t.DomHandler.createElement("div",{class:!this.isUnstyled()&&this.cx("text"),"p-bind":this.ptm("text",{context:i})});e.$_ptooltipEscape?l.innerHTML=e.$_ptooltipValue:(l.innerHTML="",l.appendChild(document.createTextNode(e.$_ptooltipValue)));var r=t.DomHandler.createElement("div",{id:e.$_ptooltipIdAttr,role:"tooltip",style:{display:"inline-block",width:e.$_ptooltipFitContent?"fit-content":void 0},class:[!this.isUnstyled()&&this.cx("root"),e.$_ptooltipClass],"p-bind":this.ptm("root",{context:i})},n,l);return document.body.appendChild(r),e.$_ptooltipId=r.id,this.$el=r,r},remove:function(e){if(e){var o=this.getTooltipElement(e);o&&o.parentElement&&(t.ZIndexUtils.clear(o),document.body.removeChild(o)),e.$_ptooltipId=null}},align:function(t){var e=t.$_ptooltipModifiers;e.top?(this.alignTop(t),this.isOutOfBounds(t)&&(this.alignBottom(t),this.isOutOfBounds(t)&&this.alignTop(t))):e.left?(this.alignLeft(t),this.isOutOfBounds(t)&&(this.alignRight(t),this.isOutOfBounds(t)&&(this.alignTop(t),this.isOutOfBounds(t)&&(this.alignBottom(t),this.isOutOfBounds(t)&&this.alignLeft(t))))):e.bottom?(this.alignBottom(t),this.isOutOfBounds(t)&&(this.alignTop(t),this.isOutOfBounds(t)&&this.alignBottom(t))):(this.alignRight(t),this.isOutOfBounds(t)&&(this.alignLeft(t),this.isOutOfBounds(t)&&(this.alignTop(t),this.isOutOfBounds(t)&&(this.alignBottom(t),this.isOutOfBounds(t)&&this.alignRight(t)))))},getHostOffset:function(e){var o=e.getBoundingClientRect();return{left:o.left+t.DomHandler.getWindowScrollLeft(),top:o.top+t.DomHandler.getWindowScrollTop()}},alignRight:function(e){this.preAlign(e,"right");var o=this.getTooltipElement(e),i=this.getHostOffset(e),n=i.left+t.DomHandler.getOuterWidth(e),l=i.top+(t.DomHandler.getOuterHeight(e)-t.DomHandler.getOuterHeight(o))/2;o.style.left=n+"px",o.style.top=l+"px"},alignLeft:function(e){this.preAlign(e,"left");var o=this.getTooltipElement(e),i=this.getHostOffset(e),n=i.left-t.DomHandler.getOuterWidth(o),l=i.top+(t.DomHandler.getOuterHeight(e)-t.DomHandler.getOuterHeight(o))/2;o.style.left=n+"px",o.style.top=l+"px"},alignTop:function(e){this.preAlign(e,"top");var o=this.getTooltipElement(e),i=this.getHostOffset(e),n=i.left+(t.DomHandler.getOuterWidth(e)-t.DomHandler.getOuterWidth(o))/2,l=i.top-t.DomHandler.getOuterHeight(o);o.style.left=n+"px",o.style.top=l+"px"},alignBottom:function(e){this.preAlign(e,"bottom");var o=this.getTooltipElement(e),i=this.getHostOffset(e),n=i.left+(t.DomHandler.getOuterWidth(e)-t.DomHandler.getOuterWidth(o))/2,l=i.top+t.DomHandler.getOuterHeight(e);o.style.left=n+"px",o.style.top=l+"px"},preAlign:function(e,o){var i=this.getTooltipElement(e);i.style.left="-999px",i.style.top="-999px",t.DomHandler.removeClass(i,"p-tooltip-".concat(i.$_ptooltipPosition)),!this.isUnstyled()&&t.DomHandler.addClass(i,"p-tooltip-".concat(o)),i.$_ptooltipPosition=o,i.setAttribute("data-p-position",o)},isOutOfBounds:function(e){var o=this.getTooltipElement(e),i=o.getBoundingClientRect(),n=i.top,l=i.left,r=t.DomHandler.getOuterWidth(o),s=t.DomHandler.getOuterHeight(o),u=t.DomHandler.getViewport();return l+r>u.width||l<0||n<0||n+s>u.height},getTarget:function(e){return t.DomHandler.hasClass(e,"p-inputwrapper")?t.DomHandler.findSingle(e,"input"):e},getModifiers:function(t){return t.modifiers&&Object.keys(t.modifiers).length?t.modifiers:t.arg&&"object"===a(t.arg)?Object.entries(t.arg).reduce((function(t,e){var o,i,r=(i=2,u(o=e)||s(o,i)||l(o,i)||n()),a=r[0];return"event"!==a&&"position"!==a||(t[r[1]]=!0),t}),{}):{}}}});module.exports=p;
|
|
1
|
+
"use strict";var t=require("primevue/utils"),e=require("primevue/basedirective"),o=require("primevue/tooltip/style");function i(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}function n(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function l(t,e){if(t){if("string"==typeof t)return r(t,e);var o=Object.prototype.toString.call(t).slice(8,-1);return"Object"===o&&t.constructor&&(o=t.constructor.name),"Map"===o||"Set"===o?Array.from(t):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?r(t,e):void 0}}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var o=0,i=new Array(e);o<e;o++)i[o]=t[o];return i}function s(t,e){var o=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=o){var i,n,l,r,s=[],a=!0,u=!1;try{if(l=(o=o.call(t)).next,0===e){if(Object(o)!==o)return;a=!1}else for(;!(a=(i=l.call(o)).done)&&(s.push(i.value),s.length!==e);a=!0);}catch(t){u=!0,n=t}finally{try{if(!a&&null!=o.return&&(r=o.return(),Object(r)!==r))return}finally{if(u)throw n}}return s}}function a(t){if(Array.isArray(t))return t}function u(t){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(t)}var p=i(e).default.extend({style:i(o).default}).extend("tooltip",{beforeMount:function(e,o){var i,n=this.getTarget(e);if(n.$_ptooltipModifiers=this.getModifiers(o),o.value){if("string"==typeof o.value)n.$_ptooltipValue=o.value,n.$_ptooltipDisabled=!1,n.$_ptooltipEscape=!1,n.$_ptooltipClass=null,n.$_ptooltipFitContent=!0,n.$_ptooltipIdAttr=t.UniqueComponentId()+"_tooltip",n.$_ptooltipShowDelay=0,n.$_ptooltipHideDelay=0,n.$_ptooltipAutoHide=!0;else if("object"===u(o.value)&&o.value){if(t.ObjectUtils.isEmpty(o.value.value)||""===o.value.value.trim())return;n.$_ptooltipValue=o.value.value,n.$_ptooltipDisabled=!!o.value.disabled===o.value.disabled&&o.value.disabled,n.$_ptooltipEscape=!!o.value.escape===o.value.escape&&o.value.escape,n.$_ptooltipClass=o.value.class||"",n.$_ptooltipFitContent=!!o.value.fitContent!==o.value.fitContent||o.value.fitContent,n.$_ptooltipIdAttr=o.value.id||t.UniqueComponentId()+"_tooltip",n.$_ptooltipShowDelay=o.value.showDelay||0,n.$_ptooltipHideDelay=o.value.hideDelay||0,n.$_ptooltipAutoHide=!!o.value.autoHide!==o.value.autoHide||o.value.autoHide}n.$_ptooltipZIndex=null===(i=o.instance.$primevue)||void 0===i||null===(i=i.config)||void 0===i||null===(i=i.zIndex)||void 0===i?void 0:i.tooltip,this.bindEvents(n,o),e.setAttribute("data-pd-tooltip",!0)}},updated:function(e,o){var i=this.getTarget(e);if(i.$_ptooltipModifiers=this.getModifiers(o),this.unbindEvents(i),o.value)if("string"==typeof o.value)i.$_ptooltipValue=o.value,i.$_ptooltipDisabled=!1,i.$_ptooltipEscape=!1,i.$_ptooltipClass=null,i.$_ptooltipIdAttr=i.$_ptooltipIdAttr||t.UniqueComponentId()+"_tooltip",i.$_ptooltipShowDelay=0,i.$_ptooltipHideDelay=0,i.$_ptooltipAutoHide=!0,this.bindEvents(i,o);else if("object"===u(o.value)&&o.value){if(t.ObjectUtils.isEmpty(o.value.value)||""===o.value.value.trim())return void this.unbindEvents(i,o);i.$_ptooltipValue=o.value.value,i.$_ptooltipDisabled=!!o.value.disabled===o.value.disabled&&o.value.disabled,i.$_ptooltipEscape=!!o.value.escape===o.value.escape&&o.value.escape,i.$_ptooltipClass=o.value.class||"",i.$_ptooltipFitContent=!!o.value.fitContent!==o.value.fitContent||o.value.fitContent,i.$_ptooltipIdAttr=o.value.id||i.$_ptooltipIdAttr||t.UniqueComponentId()+"_tooltip",i.$_ptooltipShowDelay=o.value.showDelay||0,i.$_ptooltipHideDelay=o.value.hideDelay||0,i.$_ptooltipAutoHide=!!o.value.autoHide!==o.value.autoHide||o.value.autoHide,this.bindEvents(i,o)}},unmounted:function(t,e){var o=this.getTarget(t);this.remove(o),this.unbindEvents(o,e),o.$_ptooltipScrollHandler&&(o.$_ptooltipScrollHandler.destroy(),o.$_ptooltipScrollHandler=null)},timer:void 0,methods:{bindEvents:function(t,e){var o=this;t.$_ptooltipModifiers.focus?(t.$_focusevent=function(t){return o.onFocus(t,e)},t.addEventListener("focus",t.$_focusevent),t.addEventListener("blur",this.onBlur.bind(this))):(t.$_mouseenterevent=function(t){return o.onMouseEnter(t,e)},t.addEventListener("mouseenter",t.$_mouseenterevent),t.addEventListener("mouseleave",this.onMouseLeave.bind(this)),t.addEventListener("click",this.onClick.bind(this))),t.addEventListener("keydown",this.onKeydown.bind(this))},unbindEvents:function(t){t.$_ptooltipModifiers.focus?(t.removeEventListener("focus",t.$_focusevent),t.$_focusevent=null,t.removeEventListener("blur",this.onBlur.bind(this))):(t.removeEventListener("mouseenter",t.$_mouseenterevent),t.$_mouseenterevent=null,t.removeEventListener("mouseleave",this.onMouseLeave.bind(this)),t.removeEventListener("click",this.onClick.bind(this))),t.removeEventListener("keydown",this.onKeydown.bind(this))},bindScrollListener:function(e){var o=this;e.$_ptooltipScrollHandler||(e.$_ptooltipScrollHandler=new t.ConnectedOverlayScrollHandler(e,(function(){o.hide(e)}))),e.$_ptooltipScrollHandler.bindScrollListener()},unbindScrollListener:function(t){t.$_ptooltipScrollHandler&&t.$_ptooltipScrollHandler.unbindScrollListener()},onMouseEnter:function(t,e){var o=t.currentTarget;this.show(o,e,o.$_ptooltipShowDelay)},onMouseLeave:function(e){var o=e.currentTarget,i=o.$_ptooltipHideDelay;o.$_ptooltipAutoHide?this.hide(o,i):!("tooltip"===t.DomHandler.getAttribute(e.target,"data-pc-name")||"arrow"===t.DomHandler.getAttribute(e.target,"data-pc-section")||"text"===t.DomHandler.getAttribute(e.target,"data-pc-section")||"tooltip"===t.DomHandler.getAttribute(e.relatedTarget,"data-pc-name")||"arrow"===t.DomHandler.getAttribute(e.relatedTarget,"data-pc-section")||"text"===t.DomHandler.getAttribute(e.relatedTarget,"data-pc-section"))&&this.hide(o,i)},onFocus:function(t,e){var o=t.currentTarget;this.show(o,e,o.$_ptooltipShowDelay)},onBlur:function(t){var e=t.currentTarget;this.hide(e,e.$_ptooltipHideDelay)},onClick:function(t){var e=t.currentTarget;this.hide(e,e.$_ptooltipHideDelay)},onKeydown:function(t){"Escape"===t.code&&this.hide(t.currentTarget,t.currentTarget.$_ptooltipHideDelay)},tooltipActions:function(e,o){if(!e.$_ptooltipDisabled&&t.DomHandler.isExist(e)){var i=this.create(e,o);this.align(e),!this.isUnstyled()&&t.DomHandler.fadeIn(i,250);var n=this;window.addEventListener("resize",(function o(){t.DomHandler.isTouchDevice()||n.hide(e),window.removeEventListener("resize",o)})),i.addEventListener("mouseleave",(function t(){n.hide(e),i.removeEventListener("mouseleave",t)})),this.bindScrollListener(e),t.ZIndexUtils.set("tooltip",i,e.$_ptooltipZIndex)}},show:function(t,e,o){var i=this;void 0!==o?this.timer=setTimeout((function(){return i.tooltipActions(t,e)}),o):this.tooltipActions(t,e)},tooltipRemoval:function(t){this.remove(t),this.unbindScrollListener(t)},hide:function(t,e){var o=this;clearTimeout(this.timer),void 0!==e?setTimeout((function(){return o.tooltipRemoval(t)}),e):this.tooltipRemoval(t)},getTooltipElement:function(t){return document.getElementById(t.$_ptooltipId)},create:function(e,o){var i=e.$_ptooltipModifiers,n=t.DomHandler.createElement("div",{class:!this.isUnstyled()&&this.cx("arrow"),style:{top:null!=i&&i.bottom?"0":!(null!=i&&i.right||null!=i&&i.left)&&(null!=i&&i.right||null!=i&&i.left||null!=i&&i.top||null!=i&&i.bottom)?null:"50%",bottom:null!=i&&i.top?"0":null,left:(null==i||!i.right)&&(null!=i&&i.right||null!=i&&i.left||null!=i&&i.top||null!=i&&i.bottom)?null!=i&&i.top||null!=i&&i.bottom?"50%":null:"0",right:null!=i&&i.left?"0":null},"p-bind":this.ptm("arrow",{context:i})}),l=t.DomHandler.createElement("div",{class:!this.isUnstyled()&&this.cx("text"),"p-bind":this.ptm("text",{context:i})});e.$_ptooltipEscape?l.innerHTML=e.$_ptooltipValue:(l.innerHTML="",l.appendChild(document.createTextNode(e.$_ptooltipValue)));var r=t.DomHandler.createElement("div",{id:e.$_ptooltipIdAttr,role:"tooltip",style:{display:"inline-block",width:e.$_ptooltipFitContent?"fit-content":void 0},class:[!this.isUnstyled()&&this.cx("root"),e.$_ptooltipClass],"p-bind":this.ptm("root",{context:i})},n,l);return document.body.appendChild(r),e.$_ptooltipId=r.id,this.$el=r,r},remove:function(e){if(e){var o=this.getTooltipElement(e);o&&o.parentElement&&(t.ZIndexUtils.clear(o),document.body.removeChild(o)),e.$_ptooltipId=null}},align:function(t){var e=t.$_ptooltipModifiers;e.top?(this.alignTop(t),this.isOutOfBounds(t)&&(this.alignBottom(t),this.isOutOfBounds(t)&&this.alignTop(t))):e.left?(this.alignLeft(t),this.isOutOfBounds(t)&&(this.alignRight(t),this.isOutOfBounds(t)&&(this.alignTop(t),this.isOutOfBounds(t)&&(this.alignBottom(t),this.isOutOfBounds(t)&&this.alignLeft(t))))):e.bottom?(this.alignBottom(t),this.isOutOfBounds(t)&&(this.alignTop(t),this.isOutOfBounds(t)&&this.alignBottom(t))):(this.alignRight(t),this.isOutOfBounds(t)&&(this.alignLeft(t),this.isOutOfBounds(t)&&(this.alignTop(t),this.isOutOfBounds(t)&&(this.alignBottom(t),this.isOutOfBounds(t)&&this.alignRight(t)))))},getHostOffset:function(e){var o=e.getBoundingClientRect();return{left:o.left+t.DomHandler.getWindowScrollLeft(),top:o.top+t.DomHandler.getWindowScrollTop()}},alignRight:function(e){this.preAlign(e,"right");var o=this.getTooltipElement(e),i=this.getHostOffset(e),n=i.left+t.DomHandler.getOuterWidth(e),l=i.top+(t.DomHandler.getOuterHeight(e)-t.DomHandler.getOuterHeight(o))/2;o.style.left=n+"px",o.style.top=l+"px"},alignLeft:function(e){this.preAlign(e,"left");var o=this.getTooltipElement(e),i=this.getHostOffset(e),n=i.left-t.DomHandler.getOuterWidth(o),l=i.top+(t.DomHandler.getOuterHeight(e)-t.DomHandler.getOuterHeight(o))/2;o.style.left=n+"px",o.style.top=l+"px"},alignTop:function(e){this.preAlign(e,"top");var o=this.getTooltipElement(e),i=this.getHostOffset(e),n=i.left+(t.DomHandler.getOuterWidth(e)-t.DomHandler.getOuterWidth(o))/2,l=i.top-t.DomHandler.getOuterHeight(o);o.style.left=n+"px",o.style.top=l+"px"},alignBottom:function(e){this.preAlign(e,"bottom");var o=this.getTooltipElement(e),i=this.getHostOffset(e),n=i.left+(t.DomHandler.getOuterWidth(e)-t.DomHandler.getOuterWidth(o))/2,l=i.top+t.DomHandler.getOuterHeight(e);o.style.left=n+"px",o.style.top=l+"px"},preAlign:function(e,o){var i=this.getTooltipElement(e);i.style.left="-999px",i.style.top="-999px",t.DomHandler.removeClass(i,"p-tooltip-".concat(i.$_ptooltipPosition)),!this.isUnstyled()&&t.DomHandler.addClass(i,"p-tooltip-".concat(o)),i.$_ptooltipPosition=o,i.setAttribute("data-p-position",o)},isOutOfBounds:function(e){var o=this.getTooltipElement(e),i=o.getBoundingClientRect(),n=i.top,l=i.left,r=t.DomHandler.getOuterWidth(o),s=t.DomHandler.getOuterHeight(o),a=t.DomHandler.getViewport();return l+r>a.width||l<0||n<0||n+s>a.height},getTarget:function(e){return t.DomHandler.hasClass(e,"p-inputwrapper")?t.DomHandler.findSingle(e,"input"):e},getModifiers:function(t){return t.modifiers&&Object.keys(t.modifiers).length?t.modifiers:t.arg&&"object"===u(t.arg)?Object.entries(t.arg).reduce((function(t,e){var o,i,r=(i=2,a(o=e)||s(o,i)||l(o,i)||n()),u=r[0];return"event"!==u&&"position"!==u||(t[r[1]]=!0),t}),{}):{}}}});module.exports=p;
|
package/tooltip/tooltip.esm.js
CHANGED
|
@@ -27,6 +27,7 @@ var Tooltip = BaseTooltip.extend('tooltip', {
|
|
|
27
27
|
target.$_ptooltipIdAttr = UniqueComponentId() + '_tooltip';
|
|
28
28
|
target.$_ptooltipShowDelay = 0;
|
|
29
29
|
target.$_ptooltipHideDelay = 0;
|
|
30
|
+
target.$_ptooltipAutoHide = true;
|
|
30
31
|
} else if (_typeof(options.value) === 'object' && options.value) {
|
|
31
32
|
if (ObjectUtils.isEmpty(options.value.value) || options.value.value.trim() === '') return;else {
|
|
32
33
|
target.$_ptooltipValue = options.value.value;
|
|
@@ -37,6 +38,7 @@ var Tooltip = BaseTooltip.extend('tooltip', {
|
|
|
37
38
|
target.$_ptooltipIdAttr = options.value.id || UniqueComponentId() + '_tooltip';
|
|
38
39
|
target.$_ptooltipShowDelay = options.value.showDelay || 0;
|
|
39
40
|
target.$_ptooltipHideDelay = options.value.hideDelay || 0;
|
|
41
|
+
target.$_ptooltipAutoHide = !!options.value.autoHide === options.value.autoHide ? options.value.autoHide : true;
|
|
40
42
|
}
|
|
41
43
|
}
|
|
42
44
|
target.$_ptooltipZIndex = (_options$instance$$pr = options.instance.$primevue) === null || _options$instance$$pr === void 0 || (_options$instance$$pr = _options$instance$$pr.config) === null || _options$instance$$pr === void 0 || (_options$instance$$pr = _options$instance$$pr.zIndex) === null || _options$instance$$pr === void 0 ? void 0 : _options$instance$$pr.tooltip;
|
|
@@ -58,6 +60,7 @@ var Tooltip = BaseTooltip.extend('tooltip', {
|
|
|
58
60
|
target.$_ptooltipIdAttr = target.$_ptooltipIdAttr || UniqueComponentId() + '_tooltip';
|
|
59
61
|
target.$_ptooltipShowDelay = 0;
|
|
60
62
|
target.$_ptooltipHideDelay = 0;
|
|
63
|
+
target.$_ptooltipAutoHide = true;
|
|
61
64
|
this.bindEvents(target, options);
|
|
62
65
|
} else if (_typeof(options.value) === 'object' && options.value) {
|
|
63
66
|
if (ObjectUtils.isEmpty(options.value.value) || options.value.value.trim() === '') {
|
|
@@ -72,6 +75,7 @@ var Tooltip = BaseTooltip.extend('tooltip', {
|
|
|
72
75
|
target.$_ptooltipIdAttr = options.value.id || target.$_ptooltipIdAttr || UniqueComponentId() + '_tooltip';
|
|
73
76
|
target.$_ptooltipShowDelay = options.value.showDelay || 0;
|
|
74
77
|
target.$_ptooltipHideDelay = options.value.hideDelay || 0;
|
|
78
|
+
target.$_ptooltipAutoHide = !!options.value.autoHide === options.value.autoHide ? options.value.autoHide : true;
|
|
75
79
|
this.bindEvents(target, options);
|
|
76
80
|
}
|
|
77
81
|
}
|
|
@@ -142,7 +146,13 @@ var Tooltip = BaseTooltip.extend('tooltip', {
|
|
|
142
146
|
onMouseLeave: function onMouseLeave(event) {
|
|
143
147
|
var el = event.currentTarget;
|
|
144
148
|
var hideDelay = el.$_ptooltipHideDelay;
|
|
145
|
-
|
|
149
|
+
var autoHide = el.$_ptooltipAutoHide;
|
|
150
|
+
if (!autoHide) {
|
|
151
|
+
var valid = DomHandler.getAttribute(event.target, 'data-pc-name') === 'tooltip' || DomHandler.getAttribute(event.target, 'data-pc-section') === 'arrow' || DomHandler.getAttribute(event.target, 'data-pc-section') === 'text' || DomHandler.getAttribute(event.relatedTarget, 'data-pc-name') === 'tooltip' || DomHandler.getAttribute(event.relatedTarget, 'data-pc-section') === 'arrow' || DomHandler.getAttribute(event.relatedTarget, 'data-pc-section') === 'text';
|
|
152
|
+
!valid && this.hide(el, hideDelay);
|
|
153
|
+
} else {
|
|
154
|
+
this.hide(el, hideDelay);
|
|
155
|
+
}
|
|
146
156
|
},
|
|
147
157
|
onFocus: function onFocus(event, options) {
|
|
148
158
|
var el = event.currentTarget;
|
|
@@ -178,6 +188,10 @@ var Tooltip = BaseTooltip.extend('tooltip', {
|
|
|
178
188
|
}
|
|
179
189
|
window.removeEventListener('resize', onWindowResize);
|
|
180
190
|
});
|
|
191
|
+
tooltipElement.addEventListener('mouseleave', function onTooltipLeave() {
|
|
192
|
+
$this.hide(el);
|
|
193
|
+
tooltipElement.removeEventListener('mouseleave', onTooltipLeave);
|
|
194
|
+
});
|
|
181
195
|
this.bindScrollListener(el);
|
|
182
196
|
ZIndexUtils.set('tooltip', tooltipElement, el.$_ptooltipZIndex);
|
|
183
197
|
},
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{UniqueComponentId as t,ObjectUtils as e,ConnectedOverlayScrollHandler as i,DomHandler as o,ZIndexUtils as n}from"primevue/utils";import l from"primevue/basedirective";import s from"primevue/tooltip/style";function r(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function u(t,e){if(t){if("string"==typeof t)return p(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?p(t,e):void 0}}function p(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,o=new Array(e);i<e;i++)o[i]=t[i];return o}function a(t,e){var i=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=i){var o,n,l,s,r=[],u=!0,p=!1;try{if(l=(i=i.call(t)).next,0===e){if(Object(i)!==i)return;u=!1}else for(;!(u=(o=l.call(i)).done)&&(r.push(o.value),r.length!==e);u=!0);}catch(t){p=!0,n=t}finally{try{if(!u&&null!=i.return&&(s=i.return(),Object(s)!==s))return}finally{if(p)throw n}}return r}}function d(t){if(Array.isArray(t))return t}function h(t){return h="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},h(t)}var c=l.extend({style:s}).extend("tooltip",{beforeMount:function(i,o){var n,l=this.getTarget(i);if(l.$_ptooltipModifiers=this.getModifiers(o),o.value){if("string"==typeof o.value)l.$_ptooltipValue=o.value,l.$_ptooltipDisabled=!1,l.$_ptooltipEscape=!1,l.$_ptooltipClass=null,l.$_ptooltipFitContent=!0,l.$_ptooltipIdAttr=t()+"_tooltip",l.$_ptooltipShowDelay=0,l.$_ptooltipHideDelay=0;else if("object"===h(o.value)&&o.value){if(e.isEmpty(o.value.value)||""===o.value.value.trim())return;l.$_ptooltipValue=o.value.value,l.$_ptooltipDisabled=!!o.value.disabled===o.value.disabled&&o.value.disabled,l.$_ptooltipEscape=!!o.value.escape===o.value.escape&&o.value.escape,l.$_ptooltipClass=o.value.class||"",l.$_ptooltipFitContent=!!o.value.fitContent!==o.value.fitContent||o.value.fitContent,l.$_ptooltipIdAttr=o.value.id||t()+"_tooltip",l.$_ptooltipShowDelay=o.value.showDelay||0,l.$_ptooltipHideDelay=o.value.hideDelay||0}l.$_ptooltipZIndex=null===(n=o.instance.$primevue)||void 0===n||null===(n=n.config)||void 0===n||null===(n=n.zIndex)||void 0===n?void 0:n.tooltip,this.bindEvents(l,o),i.setAttribute("data-pd-tooltip",!0)}},updated:function(i,o){var n=this.getTarget(i);if(n.$_ptooltipModifiers=this.getModifiers(o),this.unbindEvents(n),o.value)if("string"==typeof o.value)n.$_ptooltipValue=o.value,n.$_ptooltipDisabled=!1,n.$_ptooltipEscape=!1,n.$_ptooltipClass=null,n.$_ptooltipIdAttr=n.$_ptooltipIdAttr||t()+"_tooltip",n.$_ptooltipShowDelay=0,n.$_ptooltipHideDelay=0,this.bindEvents(n,o);else if("object"===h(o.value)&&o.value){if(e.isEmpty(o.value.value)||""===o.value.value.trim())return void this.unbindEvents(n,o);n.$_ptooltipValue=o.value.value,n.$_ptooltipDisabled=!!o.value.disabled===o.value.disabled&&o.value.disabled,n.$_ptooltipEscape=!!o.value.escape===o.value.escape&&o.value.escape,n.$_ptooltipClass=o.value.class||"",n.$_ptooltipFitContent=!!o.value.fitContent!==o.value.fitContent||o.value.fitContent,n.$_ptooltipIdAttr=o.value.id||n.$_ptooltipIdAttr||t()+"_tooltip",n.$_ptooltipShowDelay=o.value.showDelay||0,n.$_ptooltipHideDelay=o.value.hideDelay||0,this.bindEvents(n,o)}},unmounted:function(t,e){var i=this.getTarget(t);this.remove(i),this.unbindEvents(i,e),i.$_ptooltipScrollHandler&&(i.$_ptooltipScrollHandler.destroy(),i.$_ptooltipScrollHandler=null)},timer:void 0,methods:{bindEvents:function(t,e){var i=this;t.$_ptooltipModifiers.focus?(t.$_focusevent=function(t){return i.onFocus(t,e)},t.addEventListener("focus",t.$_focusevent),t.addEventListener("blur",this.onBlur.bind(this))):(t.$_mouseenterevent=function(t){return i.onMouseEnter(t,e)},t.addEventListener("mouseenter",t.$_mouseenterevent),t.addEventListener("mouseleave",this.onMouseLeave.bind(this)),t.addEventListener("click",this.onClick.bind(this))),t.addEventListener("keydown",this.onKeydown.bind(this))},unbindEvents:function(t){t.$_ptooltipModifiers.focus?(t.removeEventListener("focus",t.$_focusevent),t.$_focusevent=null,t.removeEventListener("blur",this.onBlur.bind(this))):(t.removeEventListener("mouseenter",t.$_mouseenterevent),t.$_mouseenterevent=null,t.removeEventListener("mouseleave",this.onMouseLeave.bind(this)),t.removeEventListener("click",this.onClick.bind(this))),t.removeEventListener("keydown",this.onKeydown.bind(this))},bindScrollListener:function(t){var e=this;t.$_ptooltipScrollHandler||(t.$_ptooltipScrollHandler=new i(t,(function(){e.hide(t)}))),t.$_ptooltipScrollHandler.bindScrollListener()},unbindScrollListener:function(t){t.$_ptooltipScrollHandler&&t.$_ptooltipScrollHandler.unbindScrollListener()},onMouseEnter:function(t,e){var i=t.currentTarget;this.show(i,e,i.$_ptooltipShowDelay)},onMouseLeave:function(t){var e=t.currentTarget;this.hide(e,e.$_ptooltipHideDelay)},onFocus:function(t,e){var i=t.currentTarget;this.show(i,e,i.$_ptooltipShowDelay)},onBlur:function(t){var e=t.currentTarget;this.hide(e,e.$_ptooltipHideDelay)},onClick:function(t){var e=t.currentTarget;this.hide(e,e.$_ptooltipHideDelay)},onKeydown:function(t){"Escape"===t.code&&this.hide(t.currentTarget,t.currentTarget.$_ptooltipHideDelay)},tooltipActions:function(t,e){if(!t.$_ptooltipDisabled&&o.isExist(t)){var i=this.create(t,e);this.align(t),!this.isUnstyled()&&o.fadeIn(i,250);var l=this;window.addEventListener("resize",(function e(){o.isTouchDevice()||l.hide(t),window.removeEventListener("resize",e)})),this.bindScrollListener(t),n.set("tooltip",i,t.$_ptooltipZIndex)}},show:function(t,e,i){var o=this;void 0!==i?this.timer=setTimeout((function(){return o.tooltipActions(t,e)}),i):this.tooltipActions(t,e)},tooltipRemoval:function(t){this.remove(t),this.unbindScrollListener(t)},hide:function(t,e){var i=this;clearTimeout(this.timer),void 0!==e?setTimeout((function(){return i.tooltipRemoval(t)}),e):this.tooltipRemoval(t)},getTooltipElement:function(t){return document.getElementById(t.$_ptooltipId)},create:function(t,e){var i=t.$_ptooltipModifiers,n=o.createElement("div",{class:!this.isUnstyled()&&this.cx("arrow"),style:{top:null!=i&&i.bottom?"0":!(null!=i&&i.right||null!=i&&i.left)&&(null!=i&&i.right||null!=i&&i.left||null!=i&&i.top||null!=i&&i.bottom)?null:"50%",bottom:null!=i&&i.top?"0":null,left:(null==i||!i.right)&&(null!=i&&i.right||null!=i&&i.left||null!=i&&i.top||null!=i&&i.bottom)?null!=i&&i.top||null!=i&&i.bottom?"50%":null:"0",right:null!=i&&i.left?"0":null},"p-bind":this.ptm("arrow",{context:i})}),l=o.createElement("div",{class:!this.isUnstyled()&&this.cx("text"),"p-bind":this.ptm("text",{context:i})});t.$_ptooltipEscape?l.innerHTML=t.$_ptooltipValue:(l.innerHTML="",l.appendChild(document.createTextNode(t.$_ptooltipValue)));var s=o.createElement("div",{id:t.$_ptooltipIdAttr,role:"tooltip",style:{display:"inline-block",width:t.$_ptooltipFitContent?"fit-content":void 0},class:[!this.isUnstyled()&&this.cx("root"),t.$_ptooltipClass],"p-bind":this.ptm("root",{context:i})},n,l);return document.body.appendChild(s),t.$_ptooltipId=s.id,this.$el=s,s},remove:function(t){if(t){var e=this.getTooltipElement(t);e&&e.parentElement&&(n.clear(e),document.body.removeChild(e)),t.$_ptooltipId=null}},align:function(t){var e=t.$_ptooltipModifiers;e.top?(this.alignTop(t),this.isOutOfBounds(t)&&(this.alignBottom(t),this.isOutOfBounds(t)&&this.alignTop(t))):e.left?(this.alignLeft(t),this.isOutOfBounds(t)&&(this.alignRight(t),this.isOutOfBounds(t)&&(this.alignTop(t),this.isOutOfBounds(t)&&(this.alignBottom(t),this.isOutOfBounds(t)&&this.alignLeft(t))))):e.bottom?(this.alignBottom(t),this.isOutOfBounds(t)&&(this.alignTop(t),this.isOutOfBounds(t)&&this.alignBottom(t))):(this.alignRight(t),this.isOutOfBounds(t)&&(this.alignLeft(t),this.isOutOfBounds(t)&&(this.alignTop(t),this.isOutOfBounds(t)&&(this.alignBottom(t),this.isOutOfBounds(t)&&this.alignRight(t)))))},getHostOffset:function(t){var e=t.getBoundingClientRect();return{left:e.left+o.getWindowScrollLeft(),top:e.top+o.getWindowScrollTop()}},alignRight:function(t){this.preAlign(t,"right");var e=this.getTooltipElement(t),i=this.getHostOffset(t),n=i.left+o.getOuterWidth(t),l=i.top+(o.getOuterHeight(t)-o.getOuterHeight(e))/2;e.style.left=n+"px",e.style.top=l+"px"},alignLeft:function(t){this.preAlign(t,"left");var e=this.getTooltipElement(t),i=this.getHostOffset(t),n=i.left-o.getOuterWidth(e),l=i.top+(o.getOuterHeight(t)-o.getOuterHeight(e))/2;e.style.left=n+"px",e.style.top=l+"px"},alignTop:function(t){this.preAlign(t,"top");var e=this.getTooltipElement(t),i=this.getHostOffset(t),n=i.left+(o.getOuterWidth(t)-o.getOuterWidth(e))/2,l=i.top-o.getOuterHeight(e);e.style.left=n+"px",e.style.top=l+"px"},alignBottom:function(t){this.preAlign(t,"bottom");var e=this.getTooltipElement(t),i=this.getHostOffset(t),n=i.left+(o.getOuterWidth(t)-o.getOuterWidth(e))/2,l=i.top+o.getOuterHeight(t);e.style.left=n+"px",e.style.top=l+"px"},preAlign:function(t,e){var i=this.getTooltipElement(t);i.style.left="-999px",i.style.top="-999px",o.removeClass(i,"p-tooltip-".concat(i.$_ptooltipPosition)),!this.isUnstyled()&&o.addClass(i,"p-tooltip-".concat(e)),i.$_ptooltipPosition=e,i.setAttribute("data-p-position",e)},isOutOfBounds:function(t){var e=this.getTooltipElement(t),i=e.getBoundingClientRect(),n=i.top,l=i.left,s=o.getOuterWidth(e),r=o.getOuterHeight(e),u=o.getViewport();return l+s>u.width||l<0||n<0||n+r>u.height},getTarget:function(t){return o.hasClass(t,"p-inputwrapper")?o.findSingle(t,"input"):t},getModifiers:function(t){return t.modifiers&&Object.keys(t.modifiers).length?t.modifiers:t.arg&&"object"===h(t.arg)?Object.entries(t.arg).reduce((function(t,e){var i,o,n=(o=2,d(i=e)||a(i,o)||u(i,o)||r()),l=n[0];return"event"!==l&&"position"!==l||(t[n[1]]=!0),t}),{}):{}}}});export{c as default};
|
|
1
|
+
import{UniqueComponentId as t,ObjectUtils as e,ConnectedOverlayScrollHandler as i,DomHandler as o,ZIndexUtils as l}from"primevue/utils";import n from"primevue/basedirective";import r from"primevue/tooltip/style";function s(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function u(t,e){if(t){if("string"==typeof t)return a(t,e);var i=Object.prototype.toString.call(t).slice(8,-1);return"Object"===i&&t.constructor&&(i=t.constructor.name),"Map"===i||"Set"===i?Array.from(t):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?a(t,e):void 0}}function a(t,e){(null==e||e>t.length)&&(e=t.length);for(var i=0,o=new Array(e);i<e;i++)o[i]=t[i];return o}function p(t,e){var i=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=i){var o,l,n,r,s=[],u=!0,a=!1;try{if(n=(i=i.call(t)).next,0===e){if(Object(i)!==i)return;u=!1}else for(;!(u=(o=n.call(i)).done)&&(s.push(o.value),s.length!==e);u=!0);}catch(t){a=!0,l=t}finally{try{if(!u&&null!=i.return&&(r=i.return(),Object(r)!==r))return}finally{if(a)throw l}}return s}}function d(t){if(Array.isArray(t))return t}function c(t){return c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},c(t)}var h=n.extend({style:r}).extend("tooltip",{beforeMount:function(i,o){var l,n=this.getTarget(i);if(n.$_ptooltipModifiers=this.getModifiers(o),o.value){if("string"==typeof o.value)n.$_ptooltipValue=o.value,n.$_ptooltipDisabled=!1,n.$_ptooltipEscape=!1,n.$_ptooltipClass=null,n.$_ptooltipFitContent=!0,n.$_ptooltipIdAttr=t()+"_tooltip",n.$_ptooltipShowDelay=0,n.$_ptooltipHideDelay=0,n.$_ptooltipAutoHide=!0;else if("object"===c(o.value)&&o.value){if(e.isEmpty(o.value.value)||""===o.value.value.trim())return;n.$_ptooltipValue=o.value.value,n.$_ptooltipDisabled=!!o.value.disabled===o.value.disabled&&o.value.disabled,n.$_ptooltipEscape=!!o.value.escape===o.value.escape&&o.value.escape,n.$_ptooltipClass=o.value.class||"",n.$_ptooltipFitContent=!!o.value.fitContent!==o.value.fitContent||o.value.fitContent,n.$_ptooltipIdAttr=o.value.id||t()+"_tooltip",n.$_ptooltipShowDelay=o.value.showDelay||0,n.$_ptooltipHideDelay=o.value.hideDelay||0,n.$_ptooltipAutoHide=!!o.value.autoHide!==o.value.autoHide||o.value.autoHide}n.$_ptooltipZIndex=null===(l=o.instance.$primevue)||void 0===l||null===(l=l.config)||void 0===l||null===(l=l.zIndex)||void 0===l?void 0:l.tooltip,this.bindEvents(n,o),i.setAttribute("data-pd-tooltip",!0)}},updated:function(i,o){var l=this.getTarget(i);if(l.$_ptooltipModifiers=this.getModifiers(o),this.unbindEvents(l),o.value)if("string"==typeof o.value)l.$_ptooltipValue=o.value,l.$_ptooltipDisabled=!1,l.$_ptooltipEscape=!1,l.$_ptooltipClass=null,l.$_ptooltipIdAttr=l.$_ptooltipIdAttr||t()+"_tooltip",l.$_ptooltipShowDelay=0,l.$_ptooltipHideDelay=0,l.$_ptooltipAutoHide=!0,this.bindEvents(l,o);else if("object"===c(o.value)&&o.value){if(e.isEmpty(o.value.value)||""===o.value.value.trim())return void this.unbindEvents(l,o);l.$_ptooltipValue=o.value.value,l.$_ptooltipDisabled=!!o.value.disabled===o.value.disabled&&o.value.disabled,l.$_ptooltipEscape=!!o.value.escape===o.value.escape&&o.value.escape,l.$_ptooltipClass=o.value.class||"",l.$_ptooltipFitContent=!!o.value.fitContent!==o.value.fitContent||o.value.fitContent,l.$_ptooltipIdAttr=o.value.id||l.$_ptooltipIdAttr||t()+"_tooltip",l.$_ptooltipShowDelay=o.value.showDelay||0,l.$_ptooltipHideDelay=o.value.hideDelay||0,l.$_ptooltipAutoHide=!!o.value.autoHide!==o.value.autoHide||o.value.autoHide,this.bindEvents(l,o)}},unmounted:function(t,e){var i=this.getTarget(t);this.remove(i),this.unbindEvents(i,e),i.$_ptooltipScrollHandler&&(i.$_ptooltipScrollHandler.destroy(),i.$_ptooltipScrollHandler=null)},timer:void 0,methods:{bindEvents:function(t,e){var i=this;t.$_ptooltipModifiers.focus?(t.$_focusevent=function(t){return i.onFocus(t,e)},t.addEventListener("focus",t.$_focusevent),t.addEventListener("blur",this.onBlur.bind(this))):(t.$_mouseenterevent=function(t){return i.onMouseEnter(t,e)},t.addEventListener("mouseenter",t.$_mouseenterevent),t.addEventListener("mouseleave",this.onMouseLeave.bind(this)),t.addEventListener("click",this.onClick.bind(this))),t.addEventListener("keydown",this.onKeydown.bind(this))},unbindEvents:function(t){t.$_ptooltipModifiers.focus?(t.removeEventListener("focus",t.$_focusevent),t.$_focusevent=null,t.removeEventListener("blur",this.onBlur.bind(this))):(t.removeEventListener("mouseenter",t.$_mouseenterevent),t.$_mouseenterevent=null,t.removeEventListener("mouseleave",this.onMouseLeave.bind(this)),t.removeEventListener("click",this.onClick.bind(this))),t.removeEventListener("keydown",this.onKeydown.bind(this))},bindScrollListener:function(t){var e=this;t.$_ptooltipScrollHandler||(t.$_ptooltipScrollHandler=new i(t,(function(){e.hide(t)}))),t.$_ptooltipScrollHandler.bindScrollListener()},unbindScrollListener:function(t){t.$_ptooltipScrollHandler&&t.$_ptooltipScrollHandler.unbindScrollListener()},onMouseEnter:function(t,e){var i=t.currentTarget;this.show(i,e,i.$_ptooltipShowDelay)},onMouseLeave:function(t){var e=t.currentTarget,i=e.$_ptooltipHideDelay;e.$_ptooltipAutoHide?this.hide(e,i):!("tooltip"===o.getAttribute(t.target,"data-pc-name")||"arrow"===o.getAttribute(t.target,"data-pc-section")||"text"===o.getAttribute(t.target,"data-pc-section")||"tooltip"===o.getAttribute(t.relatedTarget,"data-pc-name")||"arrow"===o.getAttribute(t.relatedTarget,"data-pc-section")||"text"===o.getAttribute(t.relatedTarget,"data-pc-section"))&&this.hide(e,i)},onFocus:function(t,e){var i=t.currentTarget;this.show(i,e,i.$_ptooltipShowDelay)},onBlur:function(t){var e=t.currentTarget;this.hide(e,e.$_ptooltipHideDelay)},onClick:function(t){var e=t.currentTarget;this.hide(e,e.$_ptooltipHideDelay)},onKeydown:function(t){"Escape"===t.code&&this.hide(t.currentTarget,t.currentTarget.$_ptooltipHideDelay)},tooltipActions:function(t,e){if(!t.$_ptooltipDisabled&&o.isExist(t)){var i=this.create(t,e);this.align(t),!this.isUnstyled()&&o.fadeIn(i,250);var n=this;window.addEventListener("resize",(function e(){o.isTouchDevice()||n.hide(t),window.removeEventListener("resize",e)})),i.addEventListener("mouseleave",(function e(){n.hide(t),i.removeEventListener("mouseleave",e)})),this.bindScrollListener(t),l.set("tooltip",i,t.$_ptooltipZIndex)}},show:function(t,e,i){var o=this;void 0!==i?this.timer=setTimeout((function(){return o.tooltipActions(t,e)}),i):this.tooltipActions(t,e)},tooltipRemoval:function(t){this.remove(t),this.unbindScrollListener(t)},hide:function(t,e){var i=this;clearTimeout(this.timer),void 0!==e?setTimeout((function(){return i.tooltipRemoval(t)}),e):this.tooltipRemoval(t)},getTooltipElement:function(t){return document.getElementById(t.$_ptooltipId)},create:function(t,e){var i=t.$_ptooltipModifiers,l=o.createElement("div",{class:!this.isUnstyled()&&this.cx("arrow"),style:{top:null!=i&&i.bottom?"0":!(null!=i&&i.right||null!=i&&i.left)&&(null!=i&&i.right||null!=i&&i.left||null!=i&&i.top||null!=i&&i.bottom)?null:"50%",bottom:null!=i&&i.top?"0":null,left:(null==i||!i.right)&&(null!=i&&i.right||null!=i&&i.left||null!=i&&i.top||null!=i&&i.bottom)?null!=i&&i.top||null!=i&&i.bottom?"50%":null:"0",right:null!=i&&i.left?"0":null},"p-bind":this.ptm("arrow",{context:i})}),n=o.createElement("div",{class:!this.isUnstyled()&&this.cx("text"),"p-bind":this.ptm("text",{context:i})});t.$_ptooltipEscape?n.innerHTML=t.$_ptooltipValue:(n.innerHTML="",n.appendChild(document.createTextNode(t.$_ptooltipValue)));var r=o.createElement("div",{id:t.$_ptooltipIdAttr,role:"tooltip",style:{display:"inline-block",width:t.$_ptooltipFitContent?"fit-content":void 0},class:[!this.isUnstyled()&&this.cx("root"),t.$_ptooltipClass],"p-bind":this.ptm("root",{context:i})},l,n);return document.body.appendChild(r),t.$_ptooltipId=r.id,this.$el=r,r},remove:function(t){if(t){var e=this.getTooltipElement(t);e&&e.parentElement&&(l.clear(e),document.body.removeChild(e)),t.$_ptooltipId=null}},align:function(t){var e=t.$_ptooltipModifiers;e.top?(this.alignTop(t),this.isOutOfBounds(t)&&(this.alignBottom(t),this.isOutOfBounds(t)&&this.alignTop(t))):e.left?(this.alignLeft(t),this.isOutOfBounds(t)&&(this.alignRight(t),this.isOutOfBounds(t)&&(this.alignTop(t),this.isOutOfBounds(t)&&(this.alignBottom(t),this.isOutOfBounds(t)&&this.alignLeft(t))))):e.bottom?(this.alignBottom(t),this.isOutOfBounds(t)&&(this.alignTop(t),this.isOutOfBounds(t)&&this.alignBottom(t))):(this.alignRight(t),this.isOutOfBounds(t)&&(this.alignLeft(t),this.isOutOfBounds(t)&&(this.alignTop(t),this.isOutOfBounds(t)&&(this.alignBottom(t),this.isOutOfBounds(t)&&this.alignRight(t)))))},getHostOffset:function(t){var e=t.getBoundingClientRect();return{left:e.left+o.getWindowScrollLeft(),top:e.top+o.getWindowScrollTop()}},alignRight:function(t){this.preAlign(t,"right");var e=this.getTooltipElement(t),i=this.getHostOffset(t),l=i.left+o.getOuterWidth(t),n=i.top+(o.getOuterHeight(t)-o.getOuterHeight(e))/2;e.style.left=l+"px",e.style.top=n+"px"},alignLeft:function(t){this.preAlign(t,"left");var e=this.getTooltipElement(t),i=this.getHostOffset(t),l=i.left-o.getOuterWidth(e),n=i.top+(o.getOuterHeight(t)-o.getOuterHeight(e))/2;e.style.left=l+"px",e.style.top=n+"px"},alignTop:function(t){this.preAlign(t,"top");var e=this.getTooltipElement(t),i=this.getHostOffset(t),l=i.left+(o.getOuterWidth(t)-o.getOuterWidth(e))/2,n=i.top-o.getOuterHeight(e);e.style.left=l+"px",e.style.top=n+"px"},alignBottom:function(t){this.preAlign(t,"bottom");var e=this.getTooltipElement(t),i=this.getHostOffset(t),l=i.left+(o.getOuterWidth(t)-o.getOuterWidth(e))/2,n=i.top+o.getOuterHeight(t);e.style.left=l+"px",e.style.top=n+"px"},preAlign:function(t,e){var i=this.getTooltipElement(t);i.style.left="-999px",i.style.top="-999px",o.removeClass(i,"p-tooltip-".concat(i.$_ptooltipPosition)),!this.isUnstyled()&&o.addClass(i,"p-tooltip-".concat(e)),i.$_ptooltipPosition=e,i.setAttribute("data-p-position",e)},isOutOfBounds:function(t){var e=this.getTooltipElement(t),i=e.getBoundingClientRect(),l=i.top,n=i.left,r=o.getOuterWidth(e),s=o.getOuterHeight(e),u=o.getViewport();return n+r>u.width||n<0||l<0||l+s>u.height},getTarget:function(t){return o.hasClass(t,"p-inputwrapper")?o.findSingle(t,"input"):t},getModifiers:function(t){return t.modifiers&&Object.keys(t.modifiers).length?t.modifiers:t.arg&&"object"===c(t.arg)?Object.entries(t.arg).reduce((function(t,e){var i,o,l=(o=2,d(i=e)||p(i,o)||u(i,o)||s()),n=l[0];return"event"!==n&&"position"!==n||(t[l[1]]=!0),t}),{}):{}}}});export{h as default};
|
package/tooltip/tooltip.js
CHANGED
|
@@ -32,6 +32,7 @@ this.primevue.tooltip = (function (utils, BaseDirective, TooltipStyle) {
|
|
|
32
32
|
target.$_ptooltipIdAttr = utils.UniqueComponentId() + '_tooltip';
|
|
33
33
|
target.$_ptooltipShowDelay = 0;
|
|
34
34
|
target.$_ptooltipHideDelay = 0;
|
|
35
|
+
target.$_ptooltipAutoHide = true;
|
|
35
36
|
} else if (_typeof(options.value) === 'object' && options.value) {
|
|
36
37
|
if (utils.ObjectUtils.isEmpty(options.value.value) || options.value.value.trim() === '') return;else {
|
|
37
38
|
target.$_ptooltipValue = options.value.value;
|
|
@@ -42,6 +43,7 @@ this.primevue.tooltip = (function (utils, BaseDirective, TooltipStyle) {
|
|
|
42
43
|
target.$_ptooltipIdAttr = options.value.id || utils.UniqueComponentId() + '_tooltip';
|
|
43
44
|
target.$_ptooltipShowDelay = options.value.showDelay || 0;
|
|
44
45
|
target.$_ptooltipHideDelay = options.value.hideDelay || 0;
|
|
46
|
+
target.$_ptooltipAutoHide = !!options.value.autoHide === options.value.autoHide ? options.value.autoHide : true;
|
|
45
47
|
}
|
|
46
48
|
}
|
|
47
49
|
target.$_ptooltipZIndex = (_options$instance$$pr = options.instance.$primevue) === null || _options$instance$$pr === void 0 || (_options$instance$$pr = _options$instance$$pr.config) === null || _options$instance$$pr === void 0 || (_options$instance$$pr = _options$instance$$pr.zIndex) === null || _options$instance$$pr === void 0 ? void 0 : _options$instance$$pr.tooltip;
|
|
@@ -63,6 +65,7 @@ this.primevue.tooltip = (function (utils, BaseDirective, TooltipStyle) {
|
|
|
63
65
|
target.$_ptooltipIdAttr = target.$_ptooltipIdAttr || utils.UniqueComponentId() + '_tooltip';
|
|
64
66
|
target.$_ptooltipShowDelay = 0;
|
|
65
67
|
target.$_ptooltipHideDelay = 0;
|
|
68
|
+
target.$_ptooltipAutoHide = true;
|
|
66
69
|
this.bindEvents(target, options);
|
|
67
70
|
} else if (_typeof(options.value) === 'object' && options.value) {
|
|
68
71
|
if (utils.ObjectUtils.isEmpty(options.value.value) || options.value.value.trim() === '') {
|
|
@@ -77,6 +80,7 @@ this.primevue.tooltip = (function (utils, BaseDirective, TooltipStyle) {
|
|
|
77
80
|
target.$_ptooltipIdAttr = options.value.id || target.$_ptooltipIdAttr || utils.UniqueComponentId() + '_tooltip';
|
|
78
81
|
target.$_ptooltipShowDelay = options.value.showDelay || 0;
|
|
79
82
|
target.$_ptooltipHideDelay = options.value.hideDelay || 0;
|
|
83
|
+
target.$_ptooltipAutoHide = !!options.value.autoHide === options.value.autoHide ? options.value.autoHide : true;
|
|
80
84
|
this.bindEvents(target, options);
|
|
81
85
|
}
|
|
82
86
|
}
|
|
@@ -147,7 +151,13 @@ this.primevue.tooltip = (function (utils, BaseDirective, TooltipStyle) {
|
|
|
147
151
|
onMouseLeave: function onMouseLeave(event) {
|
|
148
152
|
var el = event.currentTarget;
|
|
149
153
|
var hideDelay = el.$_ptooltipHideDelay;
|
|
150
|
-
|
|
154
|
+
var autoHide = el.$_ptooltipAutoHide;
|
|
155
|
+
if (!autoHide) {
|
|
156
|
+
var valid = utils.DomHandler.getAttribute(event.target, 'data-pc-name') === 'tooltip' || utils.DomHandler.getAttribute(event.target, 'data-pc-section') === 'arrow' || utils.DomHandler.getAttribute(event.target, 'data-pc-section') === 'text' || utils.DomHandler.getAttribute(event.relatedTarget, 'data-pc-name') === 'tooltip' || utils.DomHandler.getAttribute(event.relatedTarget, 'data-pc-section') === 'arrow' || utils.DomHandler.getAttribute(event.relatedTarget, 'data-pc-section') === 'text';
|
|
157
|
+
!valid && this.hide(el, hideDelay);
|
|
158
|
+
} else {
|
|
159
|
+
this.hide(el, hideDelay);
|
|
160
|
+
}
|
|
151
161
|
},
|
|
152
162
|
onFocus: function onFocus(event, options) {
|
|
153
163
|
var el = event.currentTarget;
|
|
@@ -183,6 +193,10 @@ this.primevue.tooltip = (function (utils, BaseDirective, TooltipStyle) {
|
|
|
183
193
|
}
|
|
184
194
|
window.removeEventListener('resize', onWindowResize);
|
|
185
195
|
});
|
|
196
|
+
tooltipElement.addEventListener('mouseleave', function onTooltipLeave() {
|
|
197
|
+
$this.hide(el);
|
|
198
|
+
tooltipElement.removeEventListener('mouseleave', onTooltipLeave);
|
|
199
|
+
});
|
|
186
200
|
this.bindScrollListener(el);
|
|
187
201
|
utils.ZIndexUtils.set('tooltip', tooltipElement, el.$_ptooltipZIndex);
|
|
188
202
|
},
|
package/tooltip/tooltip.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
this.primevue=this.primevue||{},this.primevue.tooltip=function(t,e,o){"use strict";function i(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}function n(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function l(t,e){if(t){if("string"==typeof t)return r(t,e);var o=Object.prototype.toString.call(t).slice(8,-1);return"Object"===o&&t.constructor&&(o=t.constructor.name),"Map"===o||"Set"===o?Array.from(t):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?r(t,e):void 0}}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var o=0,i=new Array(e);o<e;o++)i[o]=t[o];return i}function s(t,e){var o=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=o){var i,n,l,r,s=[],u=!0,a=!1;try{if(l=(o=o.call(t)).next,0===e){if(Object(o)!==o)return;u=!1}else for(;!(u=(i=l.call(o)).done)&&(s.push(i.value),s.length!==e);u=!0);}catch(t){a=!0,n=t}finally{try{if(!u&&null!=o.return&&(r=o.return(),Object(r)!==r))return}finally{if(a)throw n}}return s}}function u(t){if(Array.isArray(t))return t}function a(t){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},a(t)}return i(e).default.extend({style:i(o).default}).extend("tooltip",{beforeMount:function(e,o){var i,n=this.getTarget(e);if(n.$_ptooltipModifiers=this.getModifiers(o),o.value){if("string"==typeof o.value)n.$_ptooltipValue=o.value,n.$_ptooltipDisabled=!1,n.$_ptooltipEscape=!1,n.$_ptooltipClass=null,n.$_ptooltipFitContent=!0,n.$_ptooltipIdAttr=t.UniqueComponentId()+"_tooltip",n.$_ptooltipShowDelay=0,n.$_ptooltipHideDelay=0;else if("object"===a(o.value)&&o.value){if(t.ObjectUtils.isEmpty(o.value.value)||""===o.value.value.trim())return;n.$_ptooltipValue=o.value.value,n.$_ptooltipDisabled=!!o.value.disabled===o.value.disabled&&o.value.disabled,n.$_ptooltipEscape=!!o.value.escape===o.value.escape&&o.value.escape,n.$_ptooltipClass=o.value.class||"",n.$_ptooltipFitContent=!!o.value.fitContent!==o.value.fitContent||o.value.fitContent,n.$_ptooltipIdAttr=o.value.id||t.UniqueComponentId()+"_tooltip",n.$_ptooltipShowDelay=o.value.showDelay||0,n.$_ptooltipHideDelay=o.value.hideDelay||0}n.$_ptooltipZIndex=null===(i=o.instance.$primevue)||void 0===i||null===(i=i.config)||void 0===i||null===(i=i.zIndex)||void 0===i?void 0:i.tooltip,this.bindEvents(n,o),e.setAttribute("data-pd-tooltip",!0)}},updated:function(e,o){var i=this.getTarget(e);if(i.$_ptooltipModifiers=this.getModifiers(o),this.unbindEvents(i),o.value)if("string"==typeof o.value)i.$_ptooltipValue=o.value,i.$_ptooltipDisabled=!1,i.$_ptooltipEscape=!1,i.$_ptooltipClass=null,i.$_ptooltipIdAttr=i.$_ptooltipIdAttr||t.UniqueComponentId()+"_tooltip",i.$_ptooltipShowDelay=0,i.$_ptooltipHideDelay=0,this.bindEvents(i,o);else if("object"===a(o.value)&&o.value){if(t.ObjectUtils.isEmpty(o.value.value)||""===o.value.value.trim())return void this.unbindEvents(i,o);i.$_ptooltipValue=o.value.value,i.$_ptooltipDisabled=!!o.value.disabled===o.value.disabled&&o.value.disabled,i.$_ptooltipEscape=!!o.value.escape===o.value.escape&&o.value.escape,i.$_ptooltipClass=o.value.class||"",i.$_ptooltipFitContent=!!o.value.fitContent!==o.value.fitContent||o.value.fitContent,i.$_ptooltipIdAttr=o.value.id||i.$_ptooltipIdAttr||t.UniqueComponentId()+"_tooltip",i.$_ptooltipShowDelay=o.value.showDelay||0,i.$_ptooltipHideDelay=o.value.hideDelay||0,this.bindEvents(i,o)}},unmounted:function(t,e){var o=this.getTarget(t);this.remove(o),this.unbindEvents(o,e),o.$_ptooltipScrollHandler&&(o.$_ptooltipScrollHandler.destroy(),o.$_ptooltipScrollHandler=null)},timer:void 0,methods:{bindEvents:function(t,e){var o=this;t.$_ptooltipModifiers.focus?(t.$_focusevent=function(t){return o.onFocus(t,e)},t.addEventListener("focus",t.$_focusevent),t.addEventListener("blur",this.onBlur.bind(this))):(t.$_mouseenterevent=function(t){return o.onMouseEnter(t,e)},t.addEventListener("mouseenter",t.$_mouseenterevent),t.addEventListener("mouseleave",this.onMouseLeave.bind(this)),t.addEventListener("click",this.onClick.bind(this))),t.addEventListener("keydown",this.onKeydown.bind(this))},unbindEvents:function(t){t.$_ptooltipModifiers.focus?(t.removeEventListener("focus",t.$_focusevent),t.$_focusevent=null,t.removeEventListener("blur",this.onBlur.bind(this))):(t.removeEventListener("mouseenter",t.$_mouseenterevent),t.$_mouseenterevent=null,t.removeEventListener("mouseleave",this.onMouseLeave.bind(this)),t.removeEventListener("click",this.onClick.bind(this))),t.removeEventListener("keydown",this.onKeydown.bind(this))},bindScrollListener:function(e){var o=this;e.$_ptooltipScrollHandler||(e.$_ptooltipScrollHandler=new t.ConnectedOverlayScrollHandler(e,(function(){o.hide(e)}))),e.$_ptooltipScrollHandler.bindScrollListener()},unbindScrollListener:function(t){t.$_ptooltipScrollHandler&&t.$_ptooltipScrollHandler.unbindScrollListener()},onMouseEnter:function(t,e){var o=t.currentTarget;this.show(o,e,o.$_ptooltipShowDelay)},onMouseLeave:function(t){var e=t.currentTarget;this.hide(e,e.$_ptooltipHideDelay)},onFocus:function(t,e){var o=t.currentTarget;this.show(o,e,o.$_ptooltipShowDelay)},onBlur:function(t){var e=t.currentTarget;this.hide(e,e.$_ptooltipHideDelay)},onClick:function(t){var e=t.currentTarget;this.hide(e,e.$_ptooltipHideDelay)},onKeydown:function(t){"Escape"===t.code&&this.hide(t.currentTarget,t.currentTarget.$_ptooltipHideDelay)},tooltipActions:function(e,o){if(!e.$_ptooltipDisabled&&t.DomHandler.isExist(e)){var i=this.create(e,o);this.align(e),!this.isUnstyled()&&t.DomHandler.fadeIn(i,250);var n=this;window.addEventListener("resize",(function o(){t.DomHandler.isTouchDevice()||n.hide(e),window.removeEventListener("resize",o)})),this.bindScrollListener(e),t.ZIndexUtils.set("tooltip",i,e.$_ptooltipZIndex)}},show:function(t,e,o){var i=this;void 0!==o?this.timer=setTimeout((function(){return i.tooltipActions(t,e)}),o):this.tooltipActions(t,e)},tooltipRemoval:function(t){this.remove(t),this.unbindScrollListener(t)},hide:function(t,e){var o=this;clearTimeout(this.timer),void 0!==e?setTimeout((function(){return o.tooltipRemoval(t)}),e):this.tooltipRemoval(t)},getTooltipElement:function(t){return document.getElementById(t.$_ptooltipId)},create:function(e,o){var i=e.$_ptooltipModifiers,n=t.DomHandler.createElement("div",{class:!this.isUnstyled()&&this.cx("arrow"),style:{top:null!=i&&i.bottom?"0":!(null!=i&&i.right||null!=i&&i.left)&&(null!=i&&i.right||null!=i&&i.left||null!=i&&i.top||null!=i&&i.bottom)?null:"50%",bottom:null!=i&&i.top?"0":null,left:(null==i||!i.right)&&(null!=i&&i.right||null!=i&&i.left||null!=i&&i.top||null!=i&&i.bottom)?null!=i&&i.top||null!=i&&i.bottom?"50%":null:"0",right:null!=i&&i.left?"0":null},"p-bind":this.ptm("arrow",{context:i})}),l=t.DomHandler.createElement("div",{class:!this.isUnstyled()&&this.cx("text"),"p-bind":this.ptm("text",{context:i})});e.$_ptooltipEscape?l.innerHTML=e.$_ptooltipValue:(l.innerHTML="",l.appendChild(document.createTextNode(e.$_ptooltipValue)));var r=t.DomHandler.createElement("div",{id:e.$_ptooltipIdAttr,role:"tooltip",style:{display:"inline-block",width:e.$_ptooltipFitContent?"fit-content":void 0},class:[!this.isUnstyled()&&this.cx("root"),e.$_ptooltipClass],"p-bind":this.ptm("root",{context:i})},n,l);return document.body.appendChild(r),e.$_ptooltipId=r.id,this.$el=r,r},remove:function(e){if(e){var o=this.getTooltipElement(e);o&&o.parentElement&&(t.ZIndexUtils.clear(o),document.body.removeChild(o)),e.$_ptooltipId=null}},align:function(t){var e=t.$_ptooltipModifiers;e.top?(this.alignTop(t),this.isOutOfBounds(t)&&(this.alignBottom(t),this.isOutOfBounds(t)&&this.alignTop(t))):e.left?(this.alignLeft(t),this.isOutOfBounds(t)&&(this.alignRight(t),this.isOutOfBounds(t)&&(this.alignTop(t),this.isOutOfBounds(t)&&(this.alignBottom(t),this.isOutOfBounds(t)&&this.alignLeft(t))))):e.bottom?(this.alignBottom(t),this.isOutOfBounds(t)&&(this.alignTop(t),this.isOutOfBounds(t)&&this.alignBottom(t))):(this.alignRight(t),this.isOutOfBounds(t)&&(this.alignLeft(t),this.isOutOfBounds(t)&&(this.alignTop(t),this.isOutOfBounds(t)&&(this.alignBottom(t),this.isOutOfBounds(t)&&this.alignRight(t)))))},getHostOffset:function(e){var o=e.getBoundingClientRect();return{left:o.left+t.DomHandler.getWindowScrollLeft(),top:o.top+t.DomHandler.getWindowScrollTop()}},alignRight:function(e){this.preAlign(e,"right");var o=this.getTooltipElement(e),i=this.getHostOffset(e),n=i.left+t.DomHandler.getOuterWidth(e),l=i.top+(t.DomHandler.getOuterHeight(e)-t.DomHandler.getOuterHeight(o))/2;o.style.left=n+"px",o.style.top=l+"px"},alignLeft:function(e){this.preAlign(e,"left");var o=this.getTooltipElement(e),i=this.getHostOffset(e),n=i.left-t.DomHandler.getOuterWidth(o),l=i.top+(t.DomHandler.getOuterHeight(e)-t.DomHandler.getOuterHeight(o))/2;o.style.left=n+"px",o.style.top=l+"px"},alignTop:function(e){this.preAlign(e,"top");var o=this.getTooltipElement(e),i=this.getHostOffset(e),n=i.left+(t.DomHandler.getOuterWidth(e)-t.DomHandler.getOuterWidth(o))/2,l=i.top-t.DomHandler.getOuterHeight(o);o.style.left=n+"px",o.style.top=l+"px"},alignBottom:function(e){this.preAlign(e,"bottom");var o=this.getTooltipElement(e),i=this.getHostOffset(e),n=i.left+(t.DomHandler.getOuterWidth(e)-t.DomHandler.getOuterWidth(o))/2,l=i.top+t.DomHandler.getOuterHeight(e);o.style.left=n+"px",o.style.top=l+"px"},preAlign:function(e,o){var i=this.getTooltipElement(e);i.style.left="-999px",i.style.top="-999px",t.DomHandler.removeClass(i,"p-tooltip-".concat(i.$_ptooltipPosition)),!this.isUnstyled()&&t.DomHandler.addClass(i,"p-tooltip-".concat(o)),i.$_ptooltipPosition=o,i.setAttribute("data-p-position",o)},isOutOfBounds:function(e){var o=this.getTooltipElement(e),i=o.getBoundingClientRect(),n=i.top,l=i.left,r=t.DomHandler.getOuterWidth(o),s=t.DomHandler.getOuterHeight(o),u=t.DomHandler.getViewport();return l+r>u.width||l<0||n<0||n+s>u.height},getTarget:function(e){return t.DomHandler.hasClass(e,"p-inputwrapper")?t.DomHandler.findSingle(e,"input"):e},getModifiers:function(t){return t.modifiers&&Object.keys(t.modifiers).length?t.modifiers:t.arg&&"object"===a(t.arg)?Object.entries(t.arg).reduce((function(t,e){var o,i,r=(i=2,u(o=e)||s(o,i)||l(o,i)||n()),a=r[0];return"event"!==a&&"position"!==a||(t[r[1]]=!0),t}),{}):{}}}})}(primevue.utils,primevue.basedirective,primevue.tooltip.style);
|
|
1
|
+
this.primevue=this.primevue||{},this.primevue.tooltip=function(t,e,o){"use strict";function i(t){return t&&"object"==typeof t&&"default"in t?t:{default:t}}function n(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function l(t,e){if(t){if("string"==typeof t)return r(t,e);var o=Object.prototype.toString.call(t).slice(8,-1);return"Object"===o&&t.constructor&&(o=t.constructor.name),"Map"===o||"Set"===o?Array.from(t):"Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o)?r(t,e):void 0}}function r(t,e){(null==e||e>t.length)&&(e=t.length);for(var o=0,i=new Array(e);o<e;o++)i[o]=t[o];return i}function s(t,e){var o=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=o){var i,n,l,r,s=[],a=!0,u=!1;try{if(l=(o=o.call(t)).next,0===e){if(Object(o)!==o)return;a=!1}else for(;!(a=(i=l.call(o)).done)&&(s.push(i.value),s.length!==e);a=!0);}catch(t){u=!0,n=t}finally{try{if(!a&&null!=o.return&&(r=o.return(),Object(r)!==r))return}finally{if(u)throw n}}return s}}function a(t){if(Array.isArray(t))return t}function u(t){return u="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},u(t)}return i(e).default.extend({style:i(o).default}).extend("tooltip",{beforeMount:function(e,o){var i,n=this.getTarget(e);if(n.$_ptooltipModifiers=this.getModifiers(o),o.value){if("string"==typeof o.value)n.$_ptooltipValue=o.value,n.$_ptooltipDisabled=!1,n.$_ptooltipEscape=!1,n.$_ptooltipClass=null,n.$_ptooltipFitContent=!0,n.$_ptooltipIdAttr=t.UniqueComponentId()+"_tooltip",n.$_ptooltipShowDelay=0,n.$_ptooltipHideDelay=0,n.$_ptooltipAutoHide=!0;else if("object"===u(o.value)&&o.value){if(t.ObjectUtils.isEmpty(o.value.value)||""===o.value.value.trim())return;n.$_ptooltipValue=o.value.value,n.$_ptooltipDisabled=!!o.value.disabled===o.value.disabled&&o.value.disabled,n.$_ptooltipEscape=!!o.value.escape===o.value.escape&&o.value.escape,n.$_ptooltipClass=o.value.class||"",n.$_ptooltipFitContent=!!o.value.fitContent!==o.value.fitContent||o.value.fitContent,n.$_ptooltipIdAttr=o.value.id||t.UniqueComponentId()+"_tooltip",n.$_ptooltipShowDelay=o.value.showDelay||0,n.$_ptooltipHideDelay=o.value.hideDelay||0,n.$_ptooltipAutoHide=!!o.value.autoHide!==o.value.autoHide||o.value.autoHide}n.$_ptooltipZIndex=null===(i=o.instance.$primevue)||void 0===i||null===(i=i.config)||void 0===i||null===(i=i.zIndex)||void 0===i?void 0:i.tooltip,this.bindEvents(n,o),e.setAttribute("data-pd-tooltip",!0)}},updated:function(e,o){var i=this.getTarget(e);if(i.$_ptooltipModifiers=this.getModifiers(o),this.unbindEvents(i),o.value)if("string"==typeof o.value)i.$_ptooltipValue=o.value,i.$_ptooltipDisabled=!1,i.$_ptooltipEscape=!1,i.$_ptooltipClass=null,i.$_ptooltipIdAttr=i.$_ptooltipIdAttr||t.UniqueComponentId()+"_tooltip",i.$_ptooltipShowDelay=0,i.$_ptooltipHideDelay=0,i.$_ptooltipAutoHide=!0,this.bindEvents(i,o);else if("object"===u(o.value)&&o.value){if(t.ObjectUtils.isEmpty(o.value.value)||""===o.value.value.trim())return void this.unbindEvents(i,o);i.$_ptooltipValue=o.value.value,i.$_ptooltipDisabled=!!o.value.disabled===o.value.disabled&&o.value.disabled,i.$_ptooltipEscape=!!o.value.escape===o.value.escape&&o.value.escape,i.$_ptooltipClass=o.value.class||"",i.$_ptooltipFitContent=!!o.value.fitContent!==o.value.fitContent||o.value.fitContent,i.$_ptooltipIdAttr=o.value.id||i.$_ptooltipIdAttr||t.UniqueComponentId()+"_tooltip",i.$_ptooltipShowDelay=o.value.showDelay||0,i.$_ptooltipHideDelay=o.value.hideDelay||0,i.$_ptooltipAutoHide=!!o.value.autoHide!==o.value.autoHide||o.value.autoHide,this.bindEvents(i,o)}},unmounted:function(t,e){var o=this.getTarget(t);this.remove(o),this.unbindEvents(o,e),o.$_ptooltipScrollHandler&&(o.$_ptooltipScrollHandler.destroy(),o.$_ptooltipScrollHandler=null)},timer:void 0,methods:{bindEvents:function(t,e){var o=this;t.$_ptooltipModifiers.focus?(t.$_focusevent=function(t){return o.onFocus(t,e)},t.addEventListener("focus",t.$_focusevent),t.addEventListener("blur",this.onBlur.bind(this))):(t.$_mouseenterevent=function(t){return o.onMouseEnter(t,e)},t.addEventListener("mouseenter",t.$_mouseenterevent),t.addEventListener("mouseleave",this.onMouseLeave.bind(this)),t.addEventListener("click",this.onClick.bind(this))),t.addEventListener("keydown",this.onKeydown.bind(this))},unbindEvents:function(t){t.$_ptooltipModifiers.focus?(t.removeEventListener("focus",t.$_focusevent),t.$_focusevent=null,t.removeEventListener("blur",this.onBlur.bind(this))):(t.removeEventListener("mouseenter",t.$_mouseenterevent),t.$_mouseenterevent=null,t.removeEventListener("mouseleave",this.onMouseLeave.bind(this)),t.removeEventListener("click",this.onClick.bind(this))),t.removeEventListener("keydown",this.onKeydown.bind(this))},bindScrollListener:function(e){var o=this;e.$_ptooltipScrollHandler||(e.$_ptooltipScrollHandler=new t.ConnectedOverlayScrollHandler(e,(function(){o.hide(e)}))),e.$_ptooltipScrollHandler.bindScrollListener()},unbindScrollListener:function(t){t.$_ptooltipScrollHandler&&t.$_ptooltipScrollHandler.unbindScrollListener()},onMouseEnter:function(t,e){var o=t.currentTarget;this.show(o,e,o.$_ptooltipShowDelay)},onMouseLeave:function(e){var o=e.currentTarget,i=o.$_ptooltipHideDelay;o.$_ptooltipAutoHide?this.hide(o,i):!("tooltip"===t.DomHandler.getAttribute(e.target,"data-pc-name")||"arrow"===t.DomHandler.getAttribute(e.target,"data-pc-section")||"text"===t.DomHandler.getAttribute(e.target,"data-pc-section")||"tooltip"===t.DomHandler.getAttribute(e.relatedTarget,"data-pc-name")||"arrow"===t.DomHandler.getAttribute(e.relatedTarget,"data-pc-section")||"text"===t.DomHandler.getAttribute(e.relatedTarget,"data-pc-section"))&&this.hide(o,i)},onFocus:function(t,e){var o=t.currentTarget;this.show(o,e,o.$_ptooltipShowDelay)},onBlur:function(t){var e=t.currentTarget;this.hide(e,e.$_ptooltipHideDelay)},onClick:function(t){var e=t.currentTarget;this.hide(e,e.$_ptooltipHideDelay)},onKeydown:function(t){"Escape"===t.code&&this.hide(t.currentTarget,t.currentTarget.$_ptooltipHideDelay)},tooltipActions:function(e,o){if(!e.$_ptooltipDisabled&&t.DomHandler.isExist(e)){var i=this.create(e,o);this.align(e),!this.isUnstyled()&&t.DomHandler.fadeIn(i,250);var n=this;window.addEventListener("resize",(function o(){t.DomHandler.isTouchDevice()||n.hide(e),window.removeEventListener("resize",o)})),i.addEventListener("mouseleave",(function t(){n.hide(e),i.removeEventListener("mouseleave",t)})),this.bindScrollListener(e),t.ZIndexUtils.set("tooltip",i,e.$_ptooltipZIndex)}},show:function(t,e,o){var i=this;void 0!==o?this.timer=setTimeout((function(){return i.tooltipActions(t,e)}),o):this.tooltipActions(t,e)},tooltipRemoval:function(t){this.remove(t),this.unbindScrollListener(t)},hide:function(t,e){var o=this;clearTimeout(this.timer),void 0!==e?setTimeout((function(){return o.tooltipRemoval(t)}),e):this.tooltipRemoval(t)},getTooltipElement:function(t){return document.getElementById(t.$_ptooltipId)},create:function(e,o){var i=e.$_ptooltipModifiers,n=t.DomHandler.createElement("div",{class:!this.isUnstyled()&&this.cx("arrow"),style:{top:null!=i&&i.bottom?"0":!(null!=i&&i.right||null!=i&&i.left)&&(null!=i&&i.right||null!=i&&i.left||null!=i&&i.top||null!=i&&i.bottom)?null:"50%",bottom:null!=i&&i.top?"0":null,left:(null==i||!i.right)&&(null!=i&&i.right||null!=i&&i.left||null!=i&&i.top||null!=i&&i.bottom)?null!=i&&i.top||null!=i&&i.bottom?"50%":null:"0",right:null!=i&&i.left?"0":null},"p-bind":this.ptm("arrow",{context:i})}),l=t.DomHandler.createElement("div",{class:!this.isUnstyled()&&this.cx("text"),"p-bind":this.ptm("text",{context:i})});e.$_ptooltipEscape?l.innerHTML=e.$_ptooltipValue:(l.innerHTML="",l.appendChild(document.createTextNode(e.$_ptooltipValue)));var r=t.DomHandler.createElement("div",{id:e.$_ptooltipIdAttr,role:"tooltip",style:{display:"inline-block",width:e.$_ptooltipFitContent?"fit-content":void 0},class:[!this.isUnstyled()&&this.cx("root"),e.$_ptooltipClass],"p-bind":this.ptm("root",{context:i})},n,l);return document.body.appendChild(r),e.$_ptooltipId=r.id,this.$el=r,r},remove:function(e){if(e){var o=this.getTooltipElement(e);o&&o.parentElement&&(t.ZIndexUtils.clear(o),document.body.removeChild(o)),e.$_ptooltipId=null}},align:function(t){var e=t.$_ptooltipModifiers;e.top?(this.alignTop(t),this.isOutOfBounds(t)&&(this.alignBottom(t),this.isOutOfBounds(t)&&this.alignTop(t))):e.left?(this.alignLeft(t),this.isOutOfBounds(t)&&(this.alignRight(t),this.isOutOfBounds(t)&&(this.alignTop(t),this.isOutOfBounds(t)&&(this.alignBottom(t),this.isOutOfBounds(t)&&this.alignLeft(t))))):e.bottom?(this.alignBottom(t),this.isOutOfBounds(t)&&(this.alignTop(t),this.isOutOfBounds(t)&&this.alignBottom(t))):(this.alignRight(t),this.isOutOfBounds(t)&&(this.alignLeft(t),this.isOutOfBounds(t)&&(this.alignTop(t),this.isOutOfBounds(t)&&(this.alignBottom(t),this.isOutOfBounds(t)&&this.alignRight(t)))))},getHostOffset:function(e){var o=e.getBoundingClientRect();return{left:o.left+t.DomHandler.getWindowScrollLeft(),top:o.top+t.DomHandler.getWindowScrollTop()}},alignRight:function(e){this.preAlign(e,"right");var o=this.getTooltipElement(e),i=this.getHostOffset(e),n=i.left+t.DomHandler.getOuterWidth(e),l=i.top+(t.DomHandler.getOuterHeight(e)-t.DomHandler.getOuterHeight(o))/2;o.style.left=n+"px",o.style.top=l+"px"},alignLeft:function(e){this.preAlign(e,"left");var o=this.getTooltipElement(e),i=this.getHostOffset(e),n=i.left-t.DomHandler.getOuterWidth(o),l=i.top+(t.DomHandler.getOuterHeight(e)-t.DomHandler.getOuterHeight(o))/2;o.style.left=n+"px",o.style.top=l+"px"},alignTop:function(e){this.preAlign(e,"top");var o=this.getTooltipElement(e),i=this.getHostOffset(e),n=i.left+(t.DomHandler.getOuterWidth(e)-t.DomHandler.getOuterWidth(o))/2,l=i.top-t.DomHandler.getOuterHeight(o);o.style.left=n+"px",o.style.top=l+"px"},alignBottom:function(e){this.preAlign(e,"bottom");var o=this.getTooltipElement(e),i=this.getHostOffset(e),n=i.left+(t.DomHandler.getOuterWidth(e)-t.DomHandler.getOuterWidth(o))/2,l=i.top+t.DomHandler.getOuterHeight(e);o.style.left=n+"px",o.style.top=l+"px"},preAlign:function(e,o){var i=this.getTooltipElement(e);i.style.left="-999px",i.style.top="-999px",t.DomHandler.removeClass(i,"p-tooltip-".concat(i.$_ptooltipPosition)),!this.isUnstyled()&&t.DomHandler.addClass(i,"p-tooltip-".concat(o)),i.$_ptooltipPosition=o,i.setAttribute("data-p-position",o)},isOutOfBounds:function(e){var o=this.getTooltipElement(e),i=o.getBoundingClientRect(),n=i.top,l=i.left,r=t.DomHandler.getOuterWidth(o),s=t.DomHandler.getOuterHeight(o),a=t.DomHandler.getViewport();return l+r>a.width||l<0||n<0||n+s>a.height},getTarget:function(e){return t.DomHandler.hasClass(e,"p-inputwrapper")?t.DomHandler.findSingle(e,"input"):e},getModifiers:function(t){return t.modifiers&&Object.keys(t.modifiers).length?t.modifiers:t.arg&&"object"===u(t.arg)?Object.entries(t.arg).reduce((function(t,e){var o,i,r=(i=2,a(o=e)||s(o,i)||l(o,i)||n()),u=r[0];return"event"!==u&&"position"!==u||(t[r[1]]=!0),t}),{}):{}}}})}(primevue.utils,primevue.basedirective,primevue.tooltip.style);
|
package/tree/Tree.d.ts
CHANGED
|
@@ -350,7 +350,12 @@ export interface TreeSlots {
|
|
|
350
350
|
/**
|
|
351
351
|
* Default content slot.
|
|
352
352
|
*/
|
|
353
|
-
default(
|
|
353
|
+
default(scope: {
|
|
354
|
+
/**
|
|
355
|
+
* Tree node instance
|
|
356
|
+
*/
|
|
357
|
+
node: TreeNode;
|
|
358
|
+
}): VNode[];
|
|
354
359
|
/**
|
|
355
360
|
* Custom loading icon template.
|
|
356
361
|
* @param {Object} scope - loadingicon slot's params.
|
package/tree/Tree.vue
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
</div>
|
|
10
10
|
</template>
|
|
11
11
|
<div v-if="filter" :class="cx('filterContainer')" v-bind="ptm('filterContainer')">
|
|
12
|
-
<input v-model="filterValue" type="text" autocomplete="off" :class="cx('input')" :placeholder="filterPlaceholder" @keydown="onFilterKeydown" v-bind="ptm('
|
|
12
|
+
<input v-model="filterValue" type="text" autocomplete="off" :class="cx('input')" :placeholder="filterPlaceholder" @keydown="onFilterKeydown" v-bind="ptm('input')" />
|
|
13
13
|
<slot name="searchicon" :class="cx('searchIcon')">
|
|
14
14
|
<SearchIcon :class="cx('searchIcon')" v-bind="ptm('searchIcon')" />
|
|
15
15
|
</slot>
|
package/tree/tree.cjs.js
CHANGED
|
@@ -832,7 +832,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
832
832
|
onKeydown: _cache[1] || (_cache[1] = function () {
|
|
833
833
|
return $options.onFilterKeydown && $options.onFilterKeydown.apply($options, arguments);
|
|
834
834
|
})
|
|
835
|
-
}, _ctx.ptm('
|
|
835
|
+
}, _ctx.ptm('input')), null, 16, _hoisted_1), [[vue.vModelText, $data.filterValue]]), vue.renderSlot(_ctx.$slots, "searchicon", {
|
|
836
836
|
"class": vue.normalizeClass(_ctx.cx('searchIcon'))
|
|
837
837
|
}, function () {
|
|
838
838
|
return [vue.createVNode(_component_SearchIcon, vue.mergeProps({
|
package/tree/tree.cjs.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var e=require("primevue/icons/search"),t=require("primevue/icons/spinner"),n=require("primevue/utils"),o=require("primevue/basecomponent"),r=require("primevue/tree/style"),i=require("primevue/icons/check"),l=require("primevue/icons/chevrondown"),c=require("primevue/icons/chevronright"),a=require("primevue/icons/minus"),s=require("primevue/ripple"),d=require("vue");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=u(e),p=u(t),f=u(o),y=u(r),g=u(i),m={name:"BaseTree",extends:f.default,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}},style:y.default,provide:function(){return{$parentInstance:this}}};function b(e){return b="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},b(e)}function k(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=T(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var o=0,r=function(){};return{s:r,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:r}}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 i,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,i=e},f:function(){try{l||null==n.return||n.return()}finally{if(c)throw i}}}}function v(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 x(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?v(Object(n),!0).forEach((function(t){C(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):v(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function C(e,t,n){return(t=S(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function S(e){var t=w(e,"string");return"symbol"===b(t)?t:String(t)}function w(e,t){if("object"!==b(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!==b(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function K(e){return O(e)||I(e)||T(e)||N()}function N(){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 T(e,t){if(e){if("string"==typeof e)return P(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)?P(e,t):void 0}}function I(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function O(e){if(Array.isArray(e))return P(e)}function P(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 E={name:"TreeNode",hostName:"Tree",extends:f.default,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.DomHandler.getAttribute(e.target,'[data-pc-section="toggler"]')||n.DomHandler.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.DomHandler.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.DomHandler.find(this.$refs.currentNode.closest('[data-pc-section="container"]'),'[role="treeitem"]'),t=K(e).some((function(e){return"true"===e.getAttribute("aria-selected")||"true"===e.getAttribute("aria-checked")}));(K(e).forEach((function(e){e.tabIndex=-1})),t)?K(e).filter((function(e){return"true"===e.getAttribute("aria-selected")||"true"===e.getAttribute("aria-checked")}))[0].tabIndex=0:K(e)[0].tabIndex=0},setTabIndexForSelectionMode:function(e,t){if(null!==this.selectionMode){var o=K(n.DomHandler.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.DomHandler.findSingle(t,"button");return o&&"hidden"!==o.style.visibility?t:this.findBeforeClickableNode(e.previousElementSibling)}return null},toggleCheckbox:function(){var e=this.selectionKeys?x({},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,r=k(e.children);try{for(r.s();!(o=r.n()).done;){this.propagateDown(o.value,t,n)}}catch(e){r.e(e)}finally{r.f()}}},propagateUp:function(e){var t,n=e.check,o=x({},e.selectionKeys),r=0,i=!1,l=k(this.node.children);try{for(l.s();!(t=l.n()).done;){var c=t.value;o[c.key]&&o[c.key].checked?r++:o[c.key]&&o[c.key].partialChecked&&(i=!0)}}catch(e){l.e(e)}finally{l.f()}n&&r===this.node.children.length?o[this.node.key]={checked:!0,partialChecked:!1}:(n||delete o[this.node.key],i||r>0&&r!==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.DomHandler.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:u(l).default,ChevronRightIcon:u(c).default,CheckIcon:g.default,MinusIcon:u(a).default},directives:{ripple:u(s).default}},M=["aria-label","aria-selected","aria-expanded","aria-setsize","aria-posinset","aria-level","aria-checked","tabindex"],B=["data-p-highlight","data-p-selectable"],A=["data-p-checked","data-p-partialchecked"];function D(e){return D="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},D(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,r=function(){};return{s:r,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:r}}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 i,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,i=e},f:function(){try{l||null==n.return||n.return()}finally{if(c)throw i}}}}function $(){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 R(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)?R(e,t):void 0}}function F(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function L(e){if(Array.isArray(e))return R(e)}function R(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 q(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 H(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?q(Object(n),!0).forEach((function(t){U(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):q(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function U(e,t,n){return(t=_(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _(e){var t=z(e,"string");return"symbol"===D(t)?t:String(t)}function z(e,t){if("object"!==D(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!==D(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}E.render=function(e,t,n,o,r,i){var l=d.resolveComponent("TreeNode",!0),c=d.resolveDirective("ripple");return d.openBlock(),d.createElementBlock("li",d.mergeProps({ref:"currentNode",class:e.cx("node"),role:"treeitem","aria-label":i.label(n.node),"aria-selected":i.ariaSelected,"aria-expanded":i.expanded,"aria-setsize":n.node.children?n.node.children.length:0,"aria-posinset":n.index+1,"aria-level":n.level,"aria-checked":i.ariaChecked,tabindex:0===n.index?0:-1,onKeydown:t[4]||(t[4]=function(){return i.onKeyDown&&i.onKeyDown.apply(i,arguments)})},1===n.level?i.getPTOptions("node"):e.ptm("subgroup")),[d.createElementVNode("div",d.mergeProps({class:e.cx("content"),onClick:t[2]||(t[2]=function(){return i.onClick&&i.onClick.apply(i,arguments)}),onTouchend:t[3]||(t[3]=function(){return i.onTouchEnd&&i.onTouchEnd.apply(i,arguments)}),style:n.node.style},i.getPTOptions("content"),{"data-p-highlight":i.checkboxMode?i.checked:i.selected,"data-p-selectable":i.selectable}),[d.withDirectives((d.openBlock(),d.createElementBlock("button",d.mergeProps({type:"button",class:e.cx("toggler"),onClick:t[0]||(t[0]=function(){return i.toggle&&i.toggle.apply(i,arguments)}),tabindex:"-1","aria-hidden":"true"},i.getPTOptions("toggler")),[n.templates.togglericon?(d.openBlock(),d.createBlock(d.resolveDynamicComponent(n.templates.togglericon),{key:0,node:n.node,expanded:i.expanded,class:d.normalizeClass(e.cx("togglerIcon"))},null,8,["node","expanded","class"])):i.expanded?(d.openBlock(),d.createBlock(d.resolveDynamicComponent(n.node.expandedIcon?"span":"ChevronDownIcon"),d.mergeProps({key:1,class:e.cx("togglerIcon")},i.getPTOptions("togglerIcon")),null,16,["class"])):(d.openBlock(),d.createBlock(d.resolveDynamicComponent(n.node.collapsedIcon?"span":"ChevronRightIcon"),d.mergeProps({key:2,class:e.cx("togglerIcon")},i.getPTOptions("togglerIcon")),null,16,["class"]))],16)),[[c]]),i.checkboxMode?(d.openBlock(),d.createElementBlock("div",d.mergeProps({key:0,class:e.cx("checkboxContainer"),"aria-hidden":"true"},i.getPTOptions("checkboxContainer")),[d.createElementVNode("div",d.mergeProps({class:e.cx("checkbox"),role:"checkbox"},i.getPTOptions("checkbox"),{"data-p-checked":i.checked,"data-p-partialchecked":i.partialChecked}),[n.templates.checkboxicon?(d.openBlock(),d.createBlock(d.resolveDynamicComponent(n.templates.checkboxicon),{key:0,checked:i.checked,partialChecked:i.partialChecked,class:d.normalizeClass(e.cx("checkboxIcon"))},null,8,["checked","partialChecked","class"])):(d.openBlock(),d.createBlock(d.resolveDynamicComponent(i.checked?"CheckIcon":i.partialChecked?"MinusIcon":null),d.mergeProps({key:1,class:e.cx("checkboxIcon")},i.getPTOptions("checkboxIcon")),null,16,["class"]))],16,A)],16)):d.createCommentVNode("",!0),d.createElementVNode("span",d.mergeProps({class:e.cx("nodeIcon")},i.getPTOptions("nodeIcon")),null,16),d.createElementVNode("span",d.mergeProps({class:e.cx("label")},i.getPTOptions("label"),{onKeydown:t[1]||(t[1]=d.withModifiers((function(){}),["stop"]))}),[n.templates[n.node.type]||n.templates.default?(d.openBlock(),d.createBlock(d.resolveDynamicComponent(n.templates[n.node.type]||n.templates.default),{key:0,node:n.node},null,8,["node"])):(d.openBlock(),d.createElementBlock(d.Fragment,{key:1},[d.createTextVNode(d.toDisplayString(i.label(n.node)),1)],64))],16)],16,B),i.hasChildren&&i.expanded?(d.openBlock(),d.createElementBlock("ul",d.mergeProps({key:0,class:e.cx("subgroup"),role:"group"},e.ptm("subgroup")),[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(n.node.children,(function(t){return d.openBlock(),d.createBlock(l,{key:t.key,node:t,templates:n.templates,level:n.level+1,expandedKeys:n.expandedKeys,onNodeToggle:i.onChildNodeToggle,onNodeClick:i.onChildNodeClick,selectionMode:n.selectionMode,selectionKeys:n.selectionKeys,onCheckboxChange:i.propagateUp,pt:e.pt},null,8,["node","templates","level","expandedKeys","onNodeToggle","onNodeClick","selectionMode","selectionKeys","onCheckboxChange","pt"])})),128))],16)):d.createCommentVNode("",!0)],16,M)};var W={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=H({},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,r=n.metaKey||n.ctrlKey;return this.isNodeSelected(o)&&r?(this.isSingleSelectionMode()?t={}:delete(t=H({},this.selectionKeys))[o.key],this.$emit("node-unselect",o)):(this.isSingleSelectionMode()?t={}:this.isMultipleSelectionMode()&&(t=r&&this.selectionKeys?H({},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=H({},this.selectionKeys))[n.key],this.$emit("node-unselect",n)):((t=this.selectionKeys?H({},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){"Enter"===e.code&&e.preventDefault()},findFilteredNodes:function(e,t){if(e){var n=!1;if(e.children){var o=L(c=e.children)||F(c)||V(c)||$();e.children=[];var r,i=j(o);try{for(i.s();!(r=i.n()).done;){var l=H({},r.value);this.isFilterMatched(l,t)&&(n=!0,e.children.push(l))}}catch(e){i.e(e)}finally{i.f()}}if(n)return!0}var c},isFilterMatched:function(e,t){var o,r=t.searchFields,i=t.filterText,l=t.strict,c=!1,a=j(r);try{for(a.s();!(o=a.n()).done;){String(n.ObjectUtils.resolveFieldData(e,o.value)).toLocaleLowerCase(this.filterLocale).indexOf(i)>-1&&(c=!0)}}catch(e){a.e(e)}finally{a.f()}return(!c||l&&!this.isNodeLeaf(e))&&(c=this.findFilteredNodes(e,{searchFields:r,filterText:i,strict:l})||c),c}},computed:{filteredValue:function(){var e,t=[],n=this.filterBy.split(","),o=this.filterValue.trim().toLocaleLowerCase(this.filterLocale),r="strict"===this.filterMode,i=j(this.value);try{for(i.s();!(e=i.n()).done;){var l=H({},e.value),c={searchFields:n,filterText:o,strict:r};(r&&(this.findFilteredNodes(l,c)||this.isFilterMatched(l,c))||!r&&(this.isFilterMatched(l,c)||this.findFilteredNodes(l,c)))&&t.push(l)}}catch(e){i.e(e)}finally{i.f()}return t},valueToRender:function(){return this.filterValue&&this.filterValue.trim().length>0?this.filteredValue:this.value}},components:{TreeNode:E,SearchIcon:h.default,SpinnerIcon:p.default}},G=["placeholder"],J=["aria-labelledby","aria-label"];W.render=function(e,t,n,o,r,i){var l=d.resolveComponent("SpinnerIcon"),c=d.resolveComponent("SearchIcon"),a=d.resolveComponent("TreeNode");return d.openBlock(),d.createElementBlock("div",d.mergeProps({class:e.cx("root")},e.ptm("root"),{"data-pc-name":"tree"}),[e.loading?(d.openBlock(),d.createElementBlock("div",d.mergeProps({key:0,class:e.cx("loadingOverlay")},e.ptm("loadingOverlay")),[d.renderSlot(e.$slots,"loadingicon",{class:d.normalizeClass(e.cx("loadingIcon"))},(function(){return[e.loadingIcon?(d.openBlock(),d.createElementBlock("i",d.mergeProps({key:0,class:[e.cx("loadingIcon"),"pi-spin",e.loadingIcon]},e.ptm("loadingIcon")),null,16)):(d.openBlock(),d.createBlock(l,d.mergeProps({key:1,spin:"",class:e.cx("loadingIcon")},e.ptm("loadingIcon")),null,16,["class"]))]}))],16)):d.createCommentVNode("",!0),e.filter?(d.openBlock(),d.createElementBlock("div",d.mergeProps({key:1,class:e.cx("filterContainer")},e.ptm("filterContainer")),[d.withDirectives(d.createElementVNode("input",d.mergeProps({"onUpdate:modelValue":t[0]||(t[0]=function(e){return r.filterValue=e}),type:"text",autocomplete:"off",class:e.cx("input"),placeholder:e.filterPlaceholder,onKeydown:t[1]||(t[1]=function(){return i.onFilterKeydown&&i.onFilterKeydown.apply(i,arguments)})},e.ptm("filterinput")),null,16,G),[[d.vModelText,r.filterValue]]),d.renderSlot(e.$slots,"searchicon",{class:d.normalizeClass(e.cx("searchIcon"))},(function(){return[d.createVNode(c,d.mergeProps({class:e.cx("searchIcon")},e.ptm("searchIcon")),null,16,["class"])]}))],16)):d.createCommentVNode("",!0),d.createElementVNode("div",d.mergeProps({class:e.cx("wrapper"),style:{maxHeight:e.scrollHeight}},e.ptm("wrapper")),[d.createElementVNode("ul",d.mergeProps({class:e.cx("container"),role:"tree","aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel},e.ptm("container")),[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(i.valueToRender,(function(t,n){return d.openBlock(),d.createBlock(a,{key:t.key,node:t,templates:e.$slots,level:e.level+1,index:n,expandedKeys:r.d_expandedKeys,onNodeToggle:i.onNodeToggle,onNodeClick:i.onNodeClick,selectionMode:e.selectionMode,selectionKeys:e.selectionKeys,onCheckboxChange:i.onCheckboxChange,pt:e.pt,unstyled:e.unstyled},null,8,["node","templates","level","index","expandedKeys","onNodeToggle","onNodeClick","selectionMode","selectionKeys","onCheckboxChange","pt","unstyled"])})),128))],16,J)],16)],16)},module.exports=W;
|
|
1
|
+
"use strict";var e=require("primevue/icons/search"),t=require("primevue/icons/spinner"),n=require("primevue/utils"),o=require("primevue/basecomponent"),r=require("primevue/tree/style"),i=require("primevue/icons/check"),l=require("primevue/icons/chevrondown"),c=require("primevue/icons/chevronright"),a=require("primevue/icons/minus"),s=require("primevue/ripple"),d=require("vue");function u(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var h=u(e),p=u(t),f=u(o),y=u(r),g=u(i),m={name:"BaseTree",extends:f.default,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}},style:y.default,provide:function(){return{$parentInstance:this}}};function b(e){return b="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},b(e)}function k(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=T(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var o=0,r=function(){};return{s:r,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:r}}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 i,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,i=e},f:function(){try{l||null==n.return||n.return()}finally{if(c)throw i}}}}function v(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 x(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?v(Object(n),!0).forEach((function(t){C(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):v(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function C(e,t,n){return(t=S(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function S(e){var t=w(e,"string");return"symbol"===b(t)?t:String(t)}function w(e,t){if("object"!==b(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!==b(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}function K(e){return O(e)||I(e)||T(e)||N()}function N(){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 T(e,t){if(e){if("string"==typeof e)return P(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)?P(e,t):void 0}}function I(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function O(e){if(Array.isArray(e))return P(e)}function P(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 E={name:"TreeNode",hostName:"Tree",extends:f.default,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.DomHandler.getAttribute(e.target,'[data-pc-section="toggler"]')||n.DomHandler.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.DomHandler.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.DomHandler.find(this.$refs.currentNode.closest('[data-pc-section="container"]'),'[role="treeitem"]'),t=K(e).some((function(e){return"true"===e.getAttribute("aria-selected")||"true"===e.getAttribute("aria-checked")}));(K(e).forEach((function(e){e.tabIndex=-1})),t)?K(e).filter((function(e){return"true"===e.getAttribute("aria-selected")||"true"===e.getAttribute("aria-checked")}))[0].tabIndex=0:K(e)[0].tabIndex=0},setTabIndexForSelectionMode:function(e,t){if(null!==this.selectionMode){var o=K(n.DomHandler.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.DomHandler.findSingle(t,"button");return o&&"hidden"!==o.style.visibility?t:this.findBeforeClickableNode(e.previousElementSibling)}return null},toggleCheckbox:function(){var e=this.selectionKeys?x({},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,r=k(e.children);try{for(r.s();!(o=r.n()).done;){this.propagateDown(o.value,t,n)}}catch(e){r.e(e)}finally{r.f()}}},propagateUp:function(e){var t,n=e.check,o=x({},e.selectionKeys),r=0,i=!1,l=k(this.node.children);try{for(l.s();!(t=l.n()).done;){var c=t.value;o[c.key]&&o[c.key].checked?r++:o[c.key]&&o[c.key].partialChecked&&(i=!0)}}catch(e){l.e(e)}finally{l.f()}n&&r===this.node.children.length?o[this.node.key]={checked:!0,partialChecked:!1}:(n||delete o[this.node.key],i||r>0&&r!==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.DomHandler.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:u(l).default,ChevronRightIcon:u(c).default,CheckIcon:g.default,MinusIcon:u(a).default},directives:{ripple:u(s).default}},M=["aria-label","aria-selected","aria-expanded","aria-setsize","aria-posinset","aria-level","aria-checked","tabindex"],B=["data-p-highlight","data-p-selectable"],A=["data-p-checked","data-p-partialchecked"];function D(e){return D="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},D(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,r=function(){};return{s:r,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:r}}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 i,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,i=e},f:function(){try{l||null==n.return||n.return()}finally{if(c)throw i}}}}function $(){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 R(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)?R(e,t):void 0}}function F(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function L(e){if(Array.isArray(e))return R(e)}function R(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 q(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 H(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?q(Object(n),!0).forEach((function(t){U(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):q(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function U(e,t,n){return(t=_(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function _(e){var t=z(e,"string");return"symbol"===D(t)?t:String(t)}function z(e,t){if("object"!==D(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t||"default");if("object"!==D(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}E.render=function(e,t,n,o,r,i){var l=d.resolveComponent("TreeNode",!0),c=d.resolveDirective("ripple");return d.openBlock(),d.createElementBlock("li",d.mergeProps({ref:"currentNode",class:e.cx("node"),role:"treeitem","aria-label":i.label(n.node),"aria-selected":i.ariaSelected,"aria-expanded":i.expanded,"aria-setsize":n.node.children?n.node.children.length:0,"aria-posinset":n.index+1,"aria-level":n.level,"aria-checked":i.ariaChecked,tabindex:0===n.index?0:-1,onKeydown:t[4]||(t[4]=function(){return i.onKeyDown&&i.onKeyDown.apply(i,arguments)})},1===n.level?i.getPTOptions("node"):e.ptm("subgroup")),[d.createElementVNode("div",d.mergeProps({class:e.cx("content"),onClick:t[2]||(t[2]=function(){return i.onClick&&i.onClick.apply(i,arguments)}),onTouchend:t[3]||(t[3]=function(){return i.onTouchEnd&&i.onTouchEnd.apply(i,arguments)}),style:n.node.style},i.getPTOptions("content"),{"data-p-highlight":i.checkboxMode?i.checked:i.selected,"data-p-selectable":i.selectable}),[d.withDirectives((d.openBlock(),d.createElementBlock("button",d.mergeProps({type:"button",class:e.cx("toggler"),onClick:t[0]||(t[0]=function(){return i.toggle&&i.toggle.apply(i,arguments)}),tabindex:"-1","aria-hidden":"true"},i.getPTOptions("toggler")),[n.templates.togglericon?(d.openBlock(),d.createBlock(d.resolveDynamicComponent(n.templates.togglericon),{key:0,node:n.node,expanded:i.expanded,class:d.normalizeClass(e.cx("togglerIcon"))},null,8,["node","expanded","class"])):i.expanded?(d.openBlock(),d.createBlock(d.resolveDynamicComponent(n.node.expandedIcon?"span":"ChevronDownIcon"),d.mergeProps({key:1,class:e.cx("togglerIcon")},i.getPTOptions("togglerIcon")),null,16,["class"])):(d.openBlock(),d.createBlock(d.resolveDynamicComponent(n.node.collapsedIcon?"span":"ChevronRightIcon"),d.mergeProps({key:2,class:e.cx("togglerIcon")},i.getPTOptions("togglerIcon")),null,16,["class"]))],16)),[[c]]),i.checkboxMode?(d.openBlock(),d.createElementBlock("div",d.mergeProps({key:0,class:e.cx("checkboxContainer"),"aria-hidden":"true"},i.getPTOptions("checkboxContainer")),[d.createElementVNode("div",d.mergeProps({class:e.cx("checkbox"),role:"checkbox"},i.getPTOptions("checkbox"),{"data-p-checked":i.checked,"data-p-partialchecked":i.partialChecked}),[n.templates.checkboxicon?(d.openBlock(),d.createBlock(d.resolveDynamicComponent(n.templates.checkboxicon),{key:0,checked:i.checked,partialChecked:i.partialChecked,class:d.normalizeClass(e.cx("checkboxIcon"))},null,8,["checked","partialChecked","class"])):(d.openBlock(),d.createBlock(d.resolveDynamicComponent(i.checked?"CheckIcon":i.partialChecked?"MinusIcon":null),d.mergeProps({key:1,class:e.cx("checkboxIcon")},i.getPTOptions("checkboxIcon")),null,16,["class"]))],16,A)],16)):d.createCommentVNode("",!0),d.createElementVNode("span",d.mergeProps({class:e.cx("nodeIcon")},i.getPTOptions("nodeIcon")),null,16),d.createElementVNode("span",d.mergeProps({class:e.cx("label")},i.getPTOptions("label"),{onKeydown:t[1]||(t[1]=d.withModifiers((function(){}),["stop"]))}),[n.templates[n.node.type]||n.templates.default?(d.openBlock(),d.createBlock(d.resolveDynamicComponent(n.templates[n.node.type]||n.templates.default),{key:0,node:n.node},null,8,["node"])):(d.openBlock(),d.createElementBlock(d.Fragment,{key:1},[d.createTextVNode(d.toDisplayString(i.label(n.node)),1)],64))],16)],16,B),i.hasChildren&&i.expanded?(d.openBlock(),d.createElementBlock("ul",d.mergeProps({key:0,class:e.cx("subgroup"),role:"group"},e.ptm("subgroup")),[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(n.node.children,(function(t){return d.openBlock(),d.createBlock(l,{key:t.key,node:t,templates:n.templates,level:n.level+1,expandedKeys:n.expandedKeys,onNodeToggle:i.onChildNodeToggle,onNodeClick:i.onChildNodeClick,selectionMode:n.selectionMode,selectionKeys:n.selectionKeys,onCheckboxChange:i.propagateUp,pt:e.pt},null,8,["node","templates","level","expandedKeys","onNodeToggle","onNodeClick","selectionMode","selectionKeys","onCheckboxChange","pt"])})),128))],16)):d.createCommentVNode("",!0)],16,M)};var W={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=H({},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,r=n.metaKey||n.ctrlKey;return this.isNodeSelected(o)&&r?(this.isSingleSelectionMode()?t={}:delete(t=H({},this.selectionKeys))[o.key],this.$emit("node-unselect",o)):(this.isSingleSelectionMode()?t={}:this.isMultipleSelectionMode()&&(t=r&&this.selectionKeys?H({},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=H({},this.selectionKeys))[n.key],this.$emit("node-unselect",n)):((t=this.selectionKeys?H({},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){"Enter"===e.code&&e.preventDefault()},findFilteredNodes:function(e,t){if(e){var n=!1;if(e.children){var o=L(c=e.children)||F(c)||V(c)||$();e.children=[];var r,i=j(o);try{for(i.s();!(r=i.n()).done;){var l=H({},r.value);this.isFilterMatched(l,t)&&(n=!0,e.children.push(l))}}catch(e){i.e(e)}finally{i.f()}}if(n)return!0}var c},isFilterMatched:function(e,t){var o,r=t.searchFields,i=t.filterText,l=t.strict,c=!1,a=j(r);try{for(a.s();!(o=a.n()).done;){String(n.ObjectUtils.resolveFieldData(e,o.value)).toLocaleLowerCase(this.filterLocale).indexOf(i)>-1&&(c=!0)}}catch(e){a.e(e)}finally{a.f()}return(!c||l&&!this.isNodeLeaf(e))&&(c=this.findFilteredNodes(e,{searchFields:r,filterText:i,strict:l})||c),c}},computed:{filteredValue:function(){var e,t=[],n=this.filterBy.split(","),o=this.filterValue.trim().toLocaleLowerCase(this.filterLocale),r="strict"===this.filterMode,i=j(this.value);try{for(i.s();!(e=i.n()).done;){var l=H({},e.value),c={searchFields:n,filterText:o,strict:r};(r&&(this.findFilteredNodes(l,c)||this.isFilterMatched(l,c))||!r&&(this.isFilterMatched(l,c)||this.findFilteredNodes(l,c)))&&t.push(l)}}catch(e){i.e(e)}finally{i.f()}return t},valueToRender:function(){return this.filterValue&&this.filterValue.trim().length>0?this.filteredValue:this.value}},components:{TreeNode:E,SearchIcon:h.default,SpinnerIcon:p.default}},G=["placeholder"],J=["aria-labelledby","aria-label"];W.render=function(e,t,n,o,r,i){var l=d.resolveComponent("SpinnerIcon"),c=d.resolveComponent("SearchIcon"),a=d.resolveComponent("TreeNode");return d.openBlock(),d.createElementBlock("div",d.mergeProps({class:e.cx("root")},e.ptm("root"),{"data-pc-name":"tree"}),[e.loading?(d.openBlock(),d.createElementBlock("div",d.mergeProps({key:0,class:e.cx("loadingOverlay")},e.ptm("loadingOverlay")),[d.renderSlot(e.$slots,"loadingicon",{class:d.normalizeClass(e.cx("loadingIcon"))},(function(){return[e.loadingIcon?(d.openBlock(),d.createElementBlock("i",d.mergeProps({key:0,class:[e.cx("loadingIcon"),"pi-spin",e.loadingIcon]},e.ptm("loadingIcon")),null,16)):(d.openBlock(),d.createBlock(l,d.mergeProps({key:1,spin:"",class:e.cx("loadingIcon")},e.ptm("loadingIcon")),null,16,["class"]))]}))],16)):d.createCommentVNode("",!0),e.filter?(d.openBlock(),d.createElementBlock("div",d.mergeProps({key:1,class:e.cx("filterContainer")},e.ptm("filterContainer")),[d.withDirectives(d.createElementVNode("input",d.mergeProps({"onUpdate:modelValue":t[0]||(t[0]=function(e){return r.filterValue=e}),type:"text",autocomplete:"off",class:e.cx("input"),placeholder:e.filterPlaceholder,onKeydown:t[1]||(t[1]=function(){return i.onFilterKeydown&&i.onFilterKeydown.apply(i,arguments)})},e.ptm("input")),null,16,G),[[d.vModelText,r.filterValue]]),d.renderSlot(e.$slots,"searchicon",{class:d.normalizeClass(e.cx("searchIcon"))},(function(){return[d.createVNode(c,d.mergeProps({class:e.cx("searchIcon")},e.ptm("searchIcon")),null,16,["class"])]}))],16)):d.createCommentVNode("",!0),d.createElementVNode("div",d.mergeProps({class:e.cx("wrapper"),style:{maxHeight:e.scrollHeight}},e.ptm("wrapper")),[d.createElementVNode("ul",d.mergeProps({class:e.cx("container"),role:"tree","aria-labelledby":e.ariaLabelledby,"aria-label":e.ariaLabel},e.ptm("container")),[(d.openBlock(!0),d.createElementBlock(d.Fragment,null,d.renderList(i.valueToRender,(function(t,n){return d.openBlock(),d.createBlock(a,{key:t.key,node:t,templates:e.$slots,level:e.level+1,index:n,expandedKeys:r.d_expandedKeys,onNodeToggle:i.onNodeToggle,onNodeClick:i.onNodeClick,selectionMode:e.selectionMode,selectionKeys:e.selectionKeys,onCheckboxChange:i.onCheckboxChange,pt:e.pt,unstyled:e.unstyled},null,8,["node","templates","level","index","expandedKeys","onNodeToggle","onNodeClick","selectionMode","selectionKeys","onCheckboxChange","pt","unstyled"])})),128))],16,J)],16)],16)},module.exports=W;
|
package/tree/tree.esm.js
CHANGED
|
@@ -818,7 +818,7 @@ function render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
818
818
|
onKeydown: _cache[1] || (_cache[1] = function () {
|
|
819
819
|
return $options.onFilterKeydown && $options.onFilterKeydown.apply($options, arguments);
|
|
820
820
|
})
|
|
821
|
-
}, _ctx.ptm('
|
|
821
|
+
}, _ctx.ptm('input')), null, 16, _hoisted_1), [[vModelText, $data.filterValue]]), renderSlot(_ctx.$slots, "searchicon", {
|
|
822
822
|
"class": normalizeClass(_ctx.cx('searchIcon'))
|
|
823
823
|
}, function () {
|
|
824
824
|
return [createVNode(_component_SearchIcon, mergeProps({
|
package/tree/tree.esm.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
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 r from"primevue/tree/style";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 f,createElementBlock as p,mergeProps as y,createElementVNode as g,withDirectives as b,createBlock as m,resolveDynamicComponent as k,normalizeClass as v,createCommentVNode as x,withModifiers as S,Fragment as C,createTextVNode as K,toDisplayString as w,renderList as T,renderSlot as I,vModelText as O,createVNode as N}from"vue";var 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}},style:r,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 P(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 j(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?j(Object(n),!0).forEach((function(t){$(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):j(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 W={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=P(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=P(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}},H=["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)}W.render=function(e,t,n,o,i,r){var l=u("TreeNode",!0),c=h("ripple");return f(),p("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[4]||(t[4]=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[2]||(t[2]=function(){return r.onClick&&r.onClick.apply(r,arguments)}),onTouchend:t[3]||(t[3]=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((f(),p("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?(f(),m(k(n.templates.togglericon),{key:0,node:n.node,expanded:r.expanded,class:v(e.cx("togglerIcon"))},null,8,["node","expanded","class"])):r.expanded?(f(),m(k(n.node.expandedIcon?"span":"ChevronDownIcon"),y({key:1,class:e.cx("togglerIcon")},r.getPTOptions("togglerIcon")),null,16,["class"])):(f(),m(k(n.node.collapsedIcon?"span":"ChevronRightIcon"),y({key:2,class:e.cx("togglerIcon")},r.getPTOptions("togglerIcon")),null,16,["class"]))],16)),[[c]]),r.checkboxMode?(f(),p("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?(f(),m(k(n.templates.checkboxicon),{key:0,checked:r.checked,partialChecked:r.partialChecked,class:v(e.cx("checkboxIcon"))},null,8,["checked","partialChecked","class"])):(f(),m(k(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"),{onKeydown:t[1]||(t[1]=S((function(){}),["stop"]))}),[n.templates[n.node.type]||n.templates.default?(f(),m(k(n.templates[n.node.type]||n.templates.default),{key:0,node:n.node},null,8,["node"])):(f(),p(C,{key:1},[K(w(r.label(n.node)),1)],64))],16)],16,z),r.hasChildren&&r.expanded?(f(),p("ul",y({key:0,class:e.cx("subgroup"),role:"group"},e.ptm("subgroup")),[(f(!0),p(C,null,T(n.node.children,(function(t){return f(),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,H)};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){"Enter"===e.code&&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:W,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 f(),p("div",y({class:e.cx("root")},e.ptm("root"),{"data-pc-name":"tree"}),[e.loading?(f(),p("div",y({key:0,class:e.cx("loadingOverlay")},e.ptm("loadingOverlay")),[I(e.$slots,"loadingicon",{class:v(e.cx("loadingIcon"))},(function(){return[e.loadingIcon?(f(),p("i",y({key:0,class:[e.cx("loadingIcon"),"pi-spin",e.loadingIcon]},e.ptm("loadingIcon")),null,16)):(f(),m(l,y({key:1,spin:"",class:e.cx("loadingIcon")},e.ptm("loadingIcon")),null,16,["class"]))]}))],16)):x("",!0),e.filter?(f(),p("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("filterinput")),null,16,ce),[[O,i.filterValue]]),I(e.$slots,"searchicon",{class:v(e.cx("searchIcon"))},(function(){return[N(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")),[(f(!0),p(C,null,T(r.valueToRender,(function(t,n){return f(),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,unstyled:e.unstyled},null,8,["node","templates","level","index","expandedKeys","onNodeToggle","onNodeClick","selectionMode","selectionKeys","onCheckboxChange","pt","unstyled"])})),128))],16,ae)],16)],16)};export{le as default};
|
|
1
|
+
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 r from"primevue/tree/style";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 f,createElementBlock as p,mergeProps as y,createElementVNode as g,withDirectives as b,createBlock as m,resolveDynamicComponent as k,normalizeClass as v,createCommentVNode as x,withModifiers as S,Fragment as C,createTextVNode as K,toDisplayString as w,renderList as T,renderSlot as I,vModelText as O,createVNode as N}from"vue";var 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}},style:r,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 P(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 j(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?j(Object(n),!0).forEach((function(t){$(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):j(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 W={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=P(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=P(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}},H=["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)}W.render=function(e,t,n,o,i,r){var l=u("TreeNode",!0),c=h("ripple");return f(),p("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[4]||(t[4]=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[2]||(t[2]=function(){return r.onClick&&r.onClick.apply(r,arguments)}),onTouchend:t[3]||(t[3]=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((f(),p("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?(f(),m(k(n.templates.togglericon),{key:0,node:n.node,expanded:r.expanded,class:v(e.cx("togglerIcon"))},null,8,["node","expanded","class"])):r.expanded?(f(),m(k(n.node.expandedIcon?"span":"ChevronDownIcon"),y({key:1,class:e.cx("togglerIcon")},r.getPTOptions("togglerIcon")),null,16,["class"])):(f(),m(k(n.node.collapsedIcon?"span":"ChevronRightIcon"),y({key:2,class:e.cx("togglerIcon")},r.getPTOptions("togglerIcon")),null,16,["class"]))],16)),[[c]]),r.checkboxMode?(f(),p("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?(f(),m(k(n.templates.checkboxicon),{key:0,checked:r.checked,partialChecked:r.partialChecked,class:v(e.cx("checkboxIcon"))},null,8,["checked","partialChecked","class"])):(f(),m(k(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"),{onKeydown:t[1]||(t[1]=S((function(){}),["stop"]))}),[n.templates[n.node.type]||n.templates.default?(f(),m(k(n.templates[n.node.type]||n.templates.default),{key:0,node:n.node},null,8,["node"])):(f(),p(C,{key:1},[K(w(r.label(n.node)),1)],64))],16)],16,z),r.hasChildren&&r.expanded?(f(),p("ul",y({key:0,class:e.cx("subgroup"),role:"group"},e.ptm("subgroup")),[(f(!0),p(C,null,T(n.node.children,(function(t){return f(),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,H)};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){"Enter"===e.code&&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:W,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 f(),p("div",y({class:e.cx("root")},e.ptm("root"),{"data-pc-name":"tree"}),[e.loading?(f(),p("div",y({key:0,class:e.cx("loadingOverlay")},e.ptm("loadingOverlay")),[I(e.$slots,"loadingicon",{class:v(e.cx("loadingIcon"))},(function(){return[e.loadingIcon?(f(),p("i",y({key:0,class:[e.cx("loadingIcon"),"pi-spin",e.loadingIcon]},e.ptm("loadingIcon")),null,16)):(f(),m(l,y({key:1,spin:"",class:e.cx("loadingIcon")},e.ptm("loadingIcon")),null,16,["class"]))]}))],16)):x("",!0),e.filter?(f(),p("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),[[O,i.filterValue]]),I(e.$slots,"searchicon",{class:v(e.cx("searchIcon"))},(function(){return[N(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")),[(f(!0),p(C,null,T(r.valueToRender,(function(t,n){return f(),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,unstyled:e.unstyled},null,8,["node","templates","level","index","expandedKeys","onNodeToggle","onNodeClick","selectionMode","selectionKeys","onCheckboxChange","pt","unstyled"])})),128))],16,ae)],16)],16)};export{le as default};
|
package/tree/tree.js
CHANGED
|
@@ -822,7 +822,7 @@ this.primevue.tree = (function (SearchIcon, SpinnerIcon, utils, BaseComponent, T
|
|
|
822
822
|
onKeydown: _cache[1] || (_cache[1] = function () {
|
|
823
823
|
return $options.onFilterKeydown && $options.onFilterKeydown.apply($options, arguments);
|
|
824
824
|
})
|
|
825
|
-
}, _ctx.ptm('
|
|
825
|
+
}, _ctx.ptm('input')), null, 16, _hoisted_1), [[vue.vModelText, $data.filterValue]]), vue.renderSlot(_ctx.$slots, "searchicon", {
|
|
826
826
|
"class": vue.normalizeClass(_ctx.cx('searchIcon'))
|
|
827
827
|
}, function () {
|
|
828
828
|
return [vue.createVNode(_component_SearchIcon, vue.mergeProps({
|